]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
iwlagn: verify specific ucode
authorJohannes Berg <johannes.berg@intel.com>
Tue, 5 Apr 2011 16:41:56 +0000 (09:41 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 7 Apr 2011 19:51:36 +0000 (15:51 -0400)
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>
drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
drivers/net/wireless/iwlwifi/iwl-agn.c
drivers/net/wireless/iwlwifi/iwl-agn.h

index 2205b6035207ea71ae5df81cab4c40829d697d17..c7b9b8377efef626d807c9b5a03a7513cd6ec980 100644 (file)
@@ -311,7 +311,7 @@ void iwlagn_init_alive_start(struct iwl_priv *priv)
        /* initialize uCode was loaded... verify inst image.
         * This is a paranoid check, because we would not have gotten the
         * "initialize" alive if code weren't properly loaded.  */
-       if (iwl_verify_ucode(priv)) {
+       if (iwl_verify_ucode(priv, &priv->ucode_init)) {
                /* Runtime instruction load was bad;
                 * take it all the way back down so we can try again */
                IWL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n");
@@ -539,8 +539,11 @@ int iwlagn_alive_notify(struct iwl_priv *priv)
  *   using sample data 100 bytes apart.  If these sample points are good,
  *   it's a pretty good bet that everything between them is good, too.
  */
-static int iwlcore_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32 len)
+static int iwlcore_verify_inst_sparse(struct iwl_priv *priv,
+                                     struct fw_desc *fw_desc)
 {
+       __le32 *image = (__le32 *)fw_desc->v_addr;
+       u32 len = fw_desc->len;
        u32 val;
        u32 i;
 
@@ -561,8 +564,10 @@ static int iwlcore_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32
 }
 
 static void iwl_print_mismatch_inst(struct iwl_priv *priv,
-                                   __le32 *image, u32 len)
+                                   struct fw_desc *fw_desc)
 {
+       __le32 *image = (__le32 *)fw_desc->v_addr;
+       u32 len = fw_desc->len;
        u32 val;
        u32 offs;
        int errors = 0;
@@ -592,47 +597,15 @@ static void iwl_print_mismatch_inst(struct iwl_priv *priv,
  * iwl_verify_ucode - determine which instruction image is in SRAM,
  *    and verify its contents
  */
-int iwl_verify_ucode(struct iwl_priv *priv)
+int iwl_verify_ucode(struct iwl_priv *priv, struct fw_desc *fw_desc)
 {
-       __le32 *image;
-       u32 len;
-       int ret;
-
-       /* Try bootstrap */
-       image = (__le32 *)priv->ucode_boot.v_addr;
-       len = priv->ucode_boot.len;
-       ret = iwlcore_verify_inst_sparse(priv, image, len);
-       if (!ret) {
+       if (!iwlcore_verify_inst_sparse(priv, fw_desc)) {
                IWL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n");
                return 0;
        }
 
-       /* Try initialize */
-       image = (__le32 *)priv->ucode_init.v_addr;
-       len = priv->ucode_init.len;
-       ret = iwlcore_verify_inst_sparse(priv, image, len);
-       if (!ret) {
-               IWL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n");
-               return 0;
-       }
-
-       /* Try runtime/protocol */
-       image = (__le32 *)priv->ucode_code.v_addr;
-       len = priv->ucode_code.len;
-       ret = iwlcore_verify_inst_sparse(priv, image, len);
-       if (!ret) {
-               IWL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n");
-               return 0;
-       }
-
-       IWL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n");
-
-       /* Since nothing seems to match, show first several data entries in
-        * instruction SRAM, so maybe visual inspection will give a clue.
-        * Selection of bootstrap image (vs. other images) is arbitrary. */
-       image = (__le32 *)priv->ucode_boot.v_addr;
-       len = priv->ucode_boot.len;
-       iwl_print_mismatch_inst(priv, image, len);
+       IWL_ERR(priv, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n");
 
+       iwl_print_mismatch_inst(priv, fw_desc);
        return -EIO;
 }
index c8cd33387a59409da8fe11756df0382668ac2b5d..c66fcea4737ba3b1793022f03e4e90ede7c527de 100644 (file)
@@ -2241,7 +2241,7 @@ static void iwl_alive_start(struct iwl_priv *priv)
        /* Initialize uCode has loaded Runtime uCode ... verify inst image.
         * This is a paranoid check, because we would not have gotten the
         * "runtime" alive if code weren't properly loaded.  */
-       if (iwl_verify_ucode(priv)) {
+       if (iwl_verify_ucode(priv, &priv->ucode_code)) {
                /* Runtime instruction load was bad;
                 * take it all the way back down so we can try again */
                IWL_DEBUG_INFO(priv, "Bad runtime uCode load.\n");
index 4a0a46e6be3fb37c75a3c00ef95e1258bc4695f6..d2953bc7beee9900bbf3767f4eeb9448e8ce1acf 100644 (file)
@@ -152,7 +152,7 @@ void iwlagn_rx_calib_complete(struct iwl_priv *priv,
                           struct iwl_rx_mem_buffer *rxb);
 void iwlagn_init_alive_start(struct iwl_priv *priv);
 int iwlagn_alive_notify(struct iwl_priv *priv);
-int iwl_verify_ucode(struct iwl_priv *priv);
+int iwl_verify_ucode(struct iwl_priv *priv, struct fw_desc *fw_desc);
 void iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type);
 void iwlagn_send_prio_tbl(struct iwl_priv *priv);