linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wey-Yi Guy <wey-yi.w.guy@intel.com>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org,
	ipw3945-devel@lists.sourceforge.net,
	Johannes Berg <johannes.berg@intel.com>,
	Wey-Yi Guy <wey-yi.w.guy@intel.com>
Subject: [PATCH 09/25] iwlagn: verify specific ucode
Date: Tue,  5 Apr 2011 09:41:56 -0700	[thread overview]
Message-ID: <1302021732-21250-10-git-send-email-wey-yi.w.guy@intel.com> (raw)
In-Reply-To: <1302021732-21250-1-git-send-email-wey-yi.w.guy@intel.com>

From: Johannes Berg <johannes.berg@intel.com>

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>
---
 drivers/net/wireless/iwlwifi/iwl-agn-ucode.c |   51 ++++++--------------------
 drivers/net/wireless/iwlwifi/iwl-agn.c       |    2 +-
 drivers/net/wireless/iwlwifi/iwl-agn.h       |    2 +-
 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 2205b60..c7b9b83 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)
 	/* 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;
 }
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 18d6d66..8fd9a60 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -2239,7 +2239,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");
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index 4a0a46e..d2953bc 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,
 			   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);
 
-- 
1.7.0.4


  parent reply	other threads:[~2011-04-05 17:01 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-05 16:41 [PATCH 00/25] update for 2.6.40 Wey-Yi Guy
2011-04-05 16:41 ` [PATCH 01/25] iwlagn: remove unused variable Wey-Yi Guy
2011-04-05 16:41 ` [PATCH 02/25] iwlagn: clean up some 3945/4965 remnants Wey-Yi Guy
2011-04-05 16:41 ` [PATCH 03/25] iwlagn: make mac80211 handlers static Wey-Yi Guy
2011-04-05 16:41 ` [PATCH 04/25] iwlagn: clean up ucode loading Wey-Yi Guy
2011-04-05 16:41 ` [PATCH 05/25] iwlagn: remove more 3945/4965 related defines Wey-Yi Guy
2011-04-05 16:41 ` [PATCH 06/25] iwlagn: remove pointless return variables Wey-Yi Guy
2011-04-05 16:41 ` [PATCH 07/25] iwlagn: return send calibration result Wey-Yi Guy
2011-04-05 16:41 ` [PATCH 08/25] iwlagn: simplify ucode check code Wey-Yi Guy
2011-04-05 16:41 ` Wey-Yi Guy [this message]
2011-04-05 16:41 ` [PATCH 10/25] iwlagn: remove bootstrap code Wey-Yi Guy
2011-04-05 16:41 ` [PATCH 11/25] iwlagn: centralize and fix ucode restart Wey-Yi Guy
2011-04-05 16:41 ` [PATCH 12/25] iwlagn: remove ucode_data_backup Wey-Yi Guy
2011-04-05 16:42 ` [PATCH 13/25] iwlagn: change Copyright to 2011 Wey-Yi Guy
2011-04-05 16:42 ` [PATCH 14/25] iwlagn: check more error return code Wey-Yi Guy
2011-04-05 16:42 ` [PATCH 15/25] iwlagn: add feature flags Wey-Yi Guy
2011-04-05 16:42 ` [PATCH 16/25] iwlagn: fix ucode verify message Wey-Yi Guy
2011-04-05 16:42 ` [PATCH 17/25] iwlagn: clean up alive handling Wey-Yi Guy
2011-04-05 16:42 ` [PATCH 18/25] iwlagn: init cmd_queue earlier Wey-Yi Guy
2011-04-05 16:42 ` [PATCH 19/25] iwlagn: remove BSM clock setting Wey-Yi Guy
2011-04-05 16:42 ` [PATCH 20/25] iwlagn: remove hw_wa_rev Wey-Yi Guy
2011-04-05 16:42 ` [PATCH 21/25] iwlagn: remove hw_rev Wey-Yi Guy
2011-04-05 16:42 ` [PATCH 22/25] iwlagn: remove rev_id Wey-Yi Guy
2011-04-05 16:42 ` [PATCH 23/25] iwlagn: remove rxb page bookkeeping Wey-Yi Guy
2011-04-05 16:42 ` [PATCH 24/25] iwlagn: remove ISR ops Wey-Yi Guy
2011-04-05 16:42 ` [PATCH 25/25] iwlagn: move IO functions out of line Wey-Yi Guy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302021732-21250-10-git-send-email-wey-yi.w.guy@intel.com \
    --to=wey-yi.w.guy@intel.com \
    --cc=ipw3945-devel@lists.sourceforge.net \
    --cc=johannes.berg@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).