linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Reinette Chatre <reinette.chatre@intel.com>
Cc: linville@tuxdriver.com, linux-wireless@vger.kernel.org,
	ipw3945-devel@lists.sourceforge.net
Subject: Re: [PATCH 2/6] iwlwifi: enable iwl_send_static_wepkey_cmd to sleep
Date: Fri, 19 Feb 2010 10:13:19 +0100	[thread overview]
Message-ID: <1266570799.3991.52.camel@jlt3.sipsolutions.net> (raw)
In-Reply-To: <1266559387-19637-3-git-send-email-reinette.chatre@intel.com>

On Thu, 2010-02-18 at 22:03 -0800, Reinette Chatre wrote:
> From: Reinette Chatre <reinette.chatre@intel.com>
> 
> iwl_send_static_wepkey_cmd is only called from places that are able to
> sleep. Modify it so that it itself is able to sleep.

Oops, this patch seems wrong (was just working on the wep key restore
stuff):

int iwl_remove_default_wep_key(struct iwl_priv *priv,
                               struct ieee80211_key_conf *keyconf)
...
        spin_lock_irqsave(&priv->sta_lock, flags);
...
        ret = iwl_send_static_wepkey_cmd(priv, 1);
...
        spin_unlock_irqrestore(&priv->sta_lock, flags);

and same in iwl_set_default_wep_key().


How about this in addition? Changes protection from sta_lock to mutex
for wep keys (untested!).

johannes

diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 1d8c940..d0a2e7d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -2841,7 +2841,6 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 
 	mutex_lock(&priv->mutex);
 	iwl_scan_cancel_timeout(priv, 100);
-	mutex_unlock(&priv->mutex);
 
 	/* If we are getting WEP group key and we didn't receive any key mapping
 	 * so far, we are in legacy wep mode (group key only), otherwise we are
@@ -2877,6 +2876,7 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 		ret = -EINVAL;
 	}
 
+	mutex_unlock(&priv->mutex);
 	IWL_DEBUG_MAC80211(priv, "leave\n");
 
 	return ret;
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 18cf981..e544be9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -806,6 +806,8 @@ int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty)
 		.flags = CMD_SYNC,
 	};
 
+	might_sleep();
+
 	memset(wep_cmd, 0, cmd_size +
 			(sizeof(struct iwl_wep_key) * WEP_KEYS_MAX));
 
@@ -841,27 +843,28 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv,
 			       struct ieee80211_key_conf *keyconf)
 {
 	int ret;
-	unsigned long flags;
 
-	spin_lock_irqsave(&priv->sta_lock, flags);
+	WARN_ON(!mutex_is_locked(&priv->mutex));
+
 	IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n",
 		      keyconf->keyidx);
 
-	if (!test_and_clear_bit(keyconf->keyidx, &priv->ucode_key_table))
+	if (!test_and_clear_bit(keyconf->keyidx, &priv->ucode_key_table)) {
 		IWL_ERR(priv, "index %d not used in uCode key table.\n",
-			  keyconf->keyidx);
+			keyconf->keyidx);
+		return -ENOENT;
+	}
 
 	priv->default_wep_key--;
 	memset(&priv->wep_keys[keyconf->keyidx], 0, sizeof(priv->wep_keys[0]));
 	if (iwl_is_rfkill(priv)) {
 		IWL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n");
-		spin_unlock_irqrestore(&priv->sta_lock, flags);
+		/* but keys in device are clear anyway so return success */
 		return 0;
 	}
 	ret = iwl_send_static_wepkey_cmd(priv, 1);
 	IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n",
 		      keyconf->keyidx, ret);
-	spin_unlock_irqrestore(&priv->sta_lock, flags);
 
 	return ret;
 }
@@ -871,7 +874,8 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
 			    struct ieee80211_key_conf *keyconf)
 {
 	int ret;
-	unsigned long flags;
+
+	WARN_ON(!mutex_is_locked(&priv->mutex));
 
 	if (keyconf->keylen != WEP_KEY_LEN_128 &&
 	    keyconf->keylen != WEP_KEY_LEN_64) {
@@ -883,12 +887,13 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
 	keyconf->hw_key_idx = HW_KEY_DEFAULT;
 	priv->stations[IWL_AP_ID].keyinfo.alg = ALG_WEP;
 
-	spin_lock_irqsave(&priv->sta_lock, flags);
 	priv->default_wep_key++;
 
-	if (test_and_set_bit(keyconf->keyidx, &priv->ucode_key_table))
+	if (test_and_set_bit(keyconf->keyidx, &priv->ucode_key_table)) {
 		IWL_ERR(priv, "index %d already used in uCode key table.\n",
 			keyconf->keyidx);
+		return -EBUSY;
+	}
 
 	priv->wep_keys[keyconf->keyidx].key_size = keyconf->keylen;
 	memcpy(&priv->wep_keys[keyconf->keyidx].key, &keyconf->key,
@@ -897,7 +902,6 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
 	ret = iwl_send_static_wepkey_cmd(priv, 0);
 	IWL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n",
 		keyconf->keylen, keyconf->keyidx, ret);
-	spin_unlock_irqrestore(&priv->sta_lock, flags);
 
 	return ret;
 }



  reply	other threads:[~2010-02-19  9:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-19  6:03 [PATCH 0/6] iwlwifi updates for 2.6.34 Reinette Chatre
2010-02-19  6:03 ` [PATCH 1/6] iwl3945: remove STATUS macros from header Reinette Chatre
2010-02-19  6:03 ` [PATCH 2/6] iwlwifi: enable iwl_send_static_wepkey_cmd to sleep Reinette Chatre
2010-02-19  9:13   ` Johannes Berg [this message]
2010-02-19 12:59     ` Johannes Berg
2010-02-19 17:15       ` reinette chatre
2010-02-19 17:22         ` Johannes Berg
2010-02-19 17:30           ` reinette chatre
2010-02-19  6:03 ` [PATCH 3/6] iwlwifi: enable serialization of synchronous commands Reinette Chatre
2010-02-19  6:03 ` [PATCH 4/6] iwlwifi: indicate calib version for 6050 series Reinette Chatre
2010-02-19  6:03 ` [PATCH 5/6] iwlwifi: separated time check for different type of force reset Reinette Chatre
2010-02-19  6:03 ` [PATCH 6/6] iwlwifi: add debugfs to monitor force reset parameters Reinette Chatre

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=1266570799.3991.52.camel@jlt3.sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=ipw3945-devel@lists.sourceforge.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=reinette.chatre@intel.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).