From: Johannes Berg <johannes@sipsolutions.net>
To: John Linville <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org, Bob Copeland <me@bobcopeland.com>,
Gabor Juhos <juhosg@openwrt.org>
Subject: [PATCH 02/20 v4] mac80211: fix todo lock
Date: Wed, 01 Jul 2009 21:26:43 +0200 [thread overview]
Message-ID: <20090701193418.623952016@sipsolutions.net> (raw)
In-Reply-To: 20090701192641.072258140@sipsolutions.net
The key todo lock can be taken from different locks
that require it to be _bh to avoid lock inversion
due to (soft)irqs.
This should fix the two problems reported by Bob and
Gabor:
http://mid.gmane.org/20090619113049.GB18956@hash.localnet
http://mid.gmane.org/4A3FA376.8020307@openwrt.org
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Bob Copeland <me@bobcopeland.com>
Cc: Gabor Juhos <juhosg@openwrt.org>
---
net/mac80211/key.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
--- wireless-testing.orig/net/mac80211/key.c 2009-07-01 08:55:08.000000000 +0200
+++ wireless-testing/net/mac80211/key.c 2009-07-01 08:59:43.000000000 +0200
@@ -67,6 +67,8 @@ static DECLARE_WORK(todo_work, key_todo)
*
* @key: key to add to do item for
* @flag: todo flag(s)
+ *
+ * Must be called with IRQs or softirqs disabled.
*/
static void add_todo(struct ieee80211_key *key, u32 flag)
{
@@ -140,9 +142,9 @@ static void ieee80211_key_enable_hw_acce
ret = drv_set_key(key->local, SET_KEY, &sdata->vif, sta, &key->conf);
if (!ret) {
- spin_lock(&todo_lock);
+ spin_lock_bh(&todo_lock);
key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
- spin_unlock(&todo_lock);
+ spin_unlock_bh(&todo_lock);
}
if (ret && ret != -ENOSPC && ret != -EOPNOTSUPP)
@@ -164,12 +166,12 @@ static void ieee80211_key_disable_hw_acc
if (!key || !key->local->ops->set_key)
return;
- spin_lock(&todo_lock);
+ spin_lock_bh(&todo_lock);
if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) {
- spin_unlock(&todo_lock);
+ spin_unlock_bh(&todo_lock);
return;
}
- spin_unlock(&todo_lock);
+ spin_unlock_bh(&todo_lock);
sta = get_sta_for_key(key);
sdata = key->sdata;
@@ -188,9 +190,9 @@ static void ieee80211_key_disable_hw_acc
wiphy_name(key->local->hw.wiphy),
key->conf.keyidx, sta ? sta->addr : bcast_addr, ret);
- spin_lock(&todo_lock);
+ spin_lock_bh(&todo_lock);
key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
- spin_unlock(&todo_lock);
+ spin_unlock_bh(&todo_lock);
}
static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata,
@@ -437,14 +439,14 @@ void ieee80211_key_link(struct ieee80211
__ieee80211_key_replace(sdata, sta, old_key, key);
- spin_unlock_irqrestore(&sdata->local->key_lock, flags);
-
/* free old key later */
add_todo(old_key, KEY_FLAG_TODO_DELETE);
add_todo(key, KEY_FLAG_TODO_ADD_DEBUGFS);
if (netif_running(sdata->dev))
add_todo(key, KEY_FLAG_TODO_HWACCEL_ADD);
+
+ spin_unlock_irqrestore(&sdata->local->key_lock, flags);
}
static void __ieee80211_key_free(struct ieee80211_key *key)
@@ -547,7 +549,7 @@ static void __ieee80211_key_todo(void)
*/
synchronize_rcu();
- spin_lock(&todo_lock);
+ spin_lock_bh(&todo_lock);
while (!list_empty(&todo_list)) {
key = list_first_entry(&todo_list, struct ieee80211_key, todo);
list_del_init(&key->todo);
@@ -558,7 +560,7 @@ static void __ieee80211_key_todo(void)
KEY_FLAG_TODO_HWACCEL_REMOVE |
KEY_FLAG_TODO_DELETE);
key->flags &= ~todoflags;
- spin_unlock(&todo_lock);
+ spin_unlock_bh(&todo_lock);
work_done = false;
@@ -591,9 +593,9 @@ static void __ieee80211_key_todo(void)
WARN_ON(!work_done);
- spin_lock(&todo_lock);
+ spin_lock_bh(&todo_lock);
}
- spin_unlock(&todo_lock);
+ spin_unlock_bh(&todo_lock);
}
void ieee80211_key_todo(void)
--
next prev parent reply other threads:[~2009-07-01 19:35 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-01 19:26 [PATCH 00/20 v4] wireless patch dump Johannes Berg
2009-07-01 19:26 ` [PATCH 01/20 v4] wext: allow returning NULL stats Johannes Berg
2009-07-01 19:26 ` Johannes Berg [this message]
2009-07-01 19:26 ` [PATCH 03/20 v4] wext: default to y Johannes Berg
2009-07-01 19:26 ` [PATCH 04/20 v4] cfg80211: move break statement to correct place Johannes Berg
2009-07-01 19:26 ` [PATCH 05/20 v4] nl80211: clean up function definitions Johannes Berg
2009-07-01 19:26 ` [PATCH 06/20 v4] cfg80211: use proper allocation flags Johannes Berg
2009-07-01 19:26 ` [PATCH 07/20 v4] cfg80211: remove wireless_dev->bssid Johannes Berg
2009-07-01 19:26 ` [PATCH 08/20 v4] mac80211: tell SME about real auth state Johannes Berg
2009-07-01 19:26 ` [PATCH 09/20 v4] wext: constify extra argument to wireless_send_event Johannes Berg
2009-07-01 19:26 ` [PATCH 10/20 v4] cfg80211: introduce nl80211 testmode command Johannes Berg
2009-07-01 19:26 ` [PATCH 11/20 v4] mac80211: remove an unused function declaration Johannes Berg
2009-07-01 19:26 ` [PATCH 12/20 v4] wireless: define AKM suites Johannes Berg
2009-07-01 19:26 ` [PATCH 13/20 v4] cfg80211: connect/disconnect API Johannes Berg
2009-07-01 19:26 ` [PATCH 14/20 v4] cfg80211: emulate connect with auth/assoc Johannes Berg
2009-07-02 7:13 ` [PATCH 14/20 v4.1] " Johannes Berg
2009-07-01 19:26 ` [PATCH 15/20 v4] cfg80211: managed mode wext compatibility Johannes Berg
2009-07-02 23:55 ` [PATCH] iwmc3200wifi: cfg80211 managed mode port Samuel Ortiz
2009-07-03 8:02 ` Johannes Berg
2009-07-03 13:10 ` Samuel Ortiz
2009-07-05 1:37 ` Johannes Berg
2009-07-03 0:00 ` [PATCH] cfg80211: check for current_bss from giwrate Samuel Ortiz
2009-07-03 8:01 ` Johannes Berg
2009-07-01 19:26 ` [PATCH 16/20 v4] cfg80211: implement iwpower Johannes Berg
2009-07-01 19:26 ` [PATCH 17/20 v4] cfg80211: implement IWAP for WDS Johannes Berg
2009-07-01 19:26 ` [PATCH 18/20 v4] cfg80211: implement IWRATE Johannes Berg
2009-07-01 19:27 ` [PATCH 19/20 v4] cfg80211: implement get_wireless_stats Johannes Berg
2009-07-01 19:27 ` [PATCH 20/20 v4] mac80211: re-add HT disabling Johannes Berg
2009-07-01 19:40 ` [PATCH 21/20 v4] mac80211: remove auth algorithm retry Johannes Berg
2009-07-01 19:41 ` [PATCH 22/20 v4] mac80211: remove dead code, clean up Johannes Berg
2009-07-02 7:58 ` [PATCH] cfg80211: send events for userspace SME Johannes Berg
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=20090701193418.623952016@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=juhosg@openwrt.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=me@bobcopeland.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).