aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2011-04-05 12:41:56 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-04-07 15:51:36 -0400
commit35b1d92dfb361d24664381a0e4ae8ed47c771a66 (patch)
treed433ef0eb0a9ec31986745774bcbe011a62f5718 /drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
parentfb66216f9ebb146ad457829fcb62ae8f4348cda2 (diff)
iwlagn: verify specific ucode
When we loaded a ucode, there's no point in checking any one that is present, we know which one is supposed to be present so also verify that it is exactly the right one. That also simplifies the code and makes it faster since it doesn't have to check all. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-agn-ucode.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ucode.c51
1 files changed, 12 insertions, 39 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
index 2205b6035207..c7b9b8377efe 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
@@ -311,7 +311,7 @@ void iwlagn_init_alive_start(struct iwl_priv *priv)
311 /* initialize uCode was loaded... verify inst image. 311 /* initialize uCode was loaded... verify inst image.
312 * This is a paranoid check, because we would not have gotten the 312 * This is a paranoid check, because we would not have gotten the
313 * "initialize" alive if code weren't properly loaded. */ 313 * "initialize" alive if code weren't properly loaded. */
314 if (iwl_verify_ucode(priv)) { 314 if (iwl_verify_ucode(priv, &priv->ucode_init)) {
315 /* Runtime instruction load was bad; 315 /* Runtime instruction load was bad;
316 * take it all the way back down so we can try again */ 316 * take it all the way back down so we can try again */
317 IWL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n"); 317 IWL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n");
@@ -539,8 +539,11 @@ int iwlagn_alive_notify(struct iwl_priv *priv)
539 * using sample data 100 bytes apart. If these sample points are good, 539 * using sample data 100 bytes apart. If these sample points are good,
540 * it's a pretty good bet that everything between them is good, too. 540 * it's a pretty good bet that everything between them is good, too.
541 */ 541 */
542static int iwlcore_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32 len) 542static int iwlcore_verify_inst_sparse(struct iwl_priv *priv,
543 struct fw_desc *fw_desc)
543{ 544{
545 __le32 *image = (__le32 *)fw_desc->v_addr;
546 u32 len = fw_desc->len;
544 u32 val; 547 u32 val;
545 u32 i; 548 u32 i;
546 549
@@ -561,8 +564,10 @@ static int iwlcore_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32
561} 564}
562 565
563static void iwl_print_mismatch_inst(struct iwl_priv *priv, 566static void iwl_print_mismatch_inst(struct iwl_priv *priv,
564 __le32 *image, u32 len) 567 struct fw_desc *fw_desc)
565{ 568{
569 __le32 *image = (__le32 *)fw_desc->v_addr;
570 u32 len = fw_desc->len;
566 u32 val; 571 u32 val;
567 u32 offs; 572 u32 offs;
568 int errors = 0; 573 int errors = 0;
@@ -592,47 +597,15 @@ static void iwl_print_mismatch_inst(struct iwl_priv *priv,
592 * iwl_verify_ucode - determine which instruction image is in SRAM, 597 * iwl_verify_ucode - determine which instruction image is in SRAM,
593 * and verify its contents 598 * and verify its contents
594 */ 599 */
595int iwl_verify_ucode(struct iwl_priv *priv) 600int iwl_verify_ucode(struct iwl_priv *priv, struct fw_desc *fw_desc)
596{ 601{
597 __le32 *image; 602 if (!iwlcore_verify_inst_sparse(priv, fw_desc)) {
598 u32 len;
599 int ret;
600
601 /* Try bootstrap */
602 image = (__le32 *)priv->ucode_boot.v_addr;
603 len = priv->ucode_boot.len;
604 ret = iwlcore_verify_inst_sparse(priv, image, len);
605 if (!ret) {
606 IWL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n"); 603 IWL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n");
607 return 0; 604 return 0;
608 } 605 }
609 606
610 /* Try initialize */ 607 IWL_ERR(priv, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n");
611 image = (__le32 *)priv->ucode_init.v_addr;
612 len = priv->ucode_init.len;
613 ret = iwlcore_verify_inst_sparse(priv, image, len);
614 if (!ret) {
615 IWL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n");
616 return 0;
617 }
618
619 /* Try runtime/protocol */
620 image = (__le32 *)priv->ucode_code.v_addr;
621 len = priv->ucode_code.len;
622 ret = iwlcore_verify_inst_sparse(priv, image, len);
623 if (!ret) {
624 IWL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n");
625 return 0;
626 }
627
628 IWL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n");
629
630 /* Since nothing seems to match, show first several data entries in
631 * instruction SRAM, so maybe visual inspection will give a clue.
632 * Selection of bootstrap image (vs. other images) is arbitrary. */
633 image = (__le32 *)priv->ucode_boot.v_addr;
634 len = priv->ucode_boot.len;
635 iwl_print_mismatch_inst(priv, image, len);
636 608
609 iwl_print_mismatch_inst(priv, fw_desc);
637 return -EIO; 610 return -EIO;
638} 611}