aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ucode.c51
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h2
3 files changed, 14 insertions, 41 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}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index c8cd33387a59..c66fcea4737b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -2241,7 +2241,7 @@ static void iwl_alive_start(struct iwl_priv *priv)
2241 /* Initialize uCode has loaded Runtime uCode ... verify inst image. 2241 /* Initialize uCode has loaded Runtime uCode ... verify inst image.
2242 * This is a paranoid check, because we would not have gotten the 2242 * This is a paranoid check, because we would not have gotten the
2243 * "runtime" alive if code weren't properly loaded. */ 2243 * "runtime" alive if code weren't properly loaded. */
2244 if (iwl_verify_ucode(priv)) { 2244 if (iwl_verify_ucode(priv, &priv->ucode_code)) {
2245 /* Runtime instruction load was bad; 2245 /* Runtime instruction load was bad;
2246 * take it all the way back down so we can try again */ 2246 * take it all the way back down so we can try again */
2247 IWL_DEBUG_INFO(priv, "Bad runtime uCode load.\n"); 2247 IWL_DEBUG_INFO(priv, "Bad runtime uCode load.\n");
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index 4a0a46e6be3f..d2953bc7beee 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -152,7 +152,7 @@ void iwlagn_rx_calib_complete(struct iwl_priv *priv,
152 struct iwl_rx_mem_buffer *rxb); 152 struct iwl_rx_mem_buffer *rxb);
153void iwlagn_init_alive_start(struct iwl_priv *priv); 153void iwlagn_init_alive_start(struct iwl_priv *priv);
154int iwlagn_alive_notify(struct iwl_priv *priv); 154int iwlagn_alive_notify(struct iwl_priv *priv);
155int iwl_verify_ucode(struct iwl_priv *priv); 155int iwl_verify_ucode(struct iwl_priv *priv, struct fw_desc *fw_desc);
156void iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type); 156void iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type);
157void iwlagn_send_prio_tbl(struct iwl_priv *priv); 157void iwlagn_send_prio_tbl(struct iwl_priv *priv);
158 158