[package] mac80211: add more ath9k patches
[openwrt.git] / package / mac80211 / patches / 008-mac80211-fix-todo-lock.patch
1 From: Johannes Berg <johannes@sipsolutions.net>
2 Subject: mac80211: fix todo lock
3
4 The key todo lock can be taken from different locks
5 that require it to be _bh to avoid lock inversion
6 due to (soft)irqs.
7
8 This should fix the two problems reported by Bob and
9 Gabor:
10 http://mid.gmane.org/20090619113049.GB18956@hash.localnet
11 http://mid.gmane.org/4A3FA376.8020307@openwrt.org
12
13 Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
14 Cc: Bob Copeland <me@bobcopeland.com>
15 Cc: Gabor Juhos <juhosg@openwrt.org>
16 ---
17 net/mac80211/key.c | 28 +++++++++++++++-------------
18 1 file changed, 15 insertions(+), 13 deletions(-)
19
20 --- a/net/mac80211/key.c
21 +++ b/net/mac80211/key.c
22 @@ -70,6 +70,8 @@ static DECLARE_WORK(todo_work, key_todo)
23 *
24 * @key: key to add to do item for
25 * @flag: todo flag(s)
26 + *
27 + * Must be called with IRQs or softirqs disabled.
28 */
29 static void add_todo(struct ieee80211_key *key, u32 flag)
30 {
31 @@ -143,9 +145,9 @@ static void ieee80211_key_enable_hw_acce
32 ret = drv_set_key(key->local, SET_KEY, &sdata->vif, sta, &key->conf);
33
34 if (!ret) {
35 - spin_lock(&todo_lock);
36 + spin_lock_bh(&todo_lock);
37 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
38 - spin_unlock(&todo_lock);
39 + spin_unlock_bh(&todo_lock);
40 }
41
42 if (ret && ret != -ENOSPC && ret != -EOPNOTSUPP)
43 @@ -167,12 +169,12 @@ static void ieee80211_key_disable_hw_acc
44 if (!key || !key->local->ops->set_key)
45 return;
46
47 - spin_lock(&todo_lock);
48 + spin_lock_bh(&todo_lock);
49 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) {
50 - spin_unlock(&todo_lock);
51 + spin_unlock_bh(&todo_lock);
52 return;
53 }
54 - spin_unlock(&todo_lock);
55 + spin_unlock_bh(&todo_lock);
56
57 sta = get_sta_for_key(key);
58 sdata = key->sdata;
59 @@ -191,9 +193,9 @@ static void ieee80211_key_disable_hw_acc
60 wiphy_name(key->local->hw.wiphy),
61 key->conf.keyidx, sta ? sta->addr : bcast_addr, ret);
62
63 - spin_lock(&todo_lock);
64 + spin_lock_bh(&todo_lock);
65 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
66 - spin_unlock(&todo_lock);
67 + spin_unlock_bh(&todo_lock);
68 }
69
70 static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata,
71 @@ -440,14 +442,14 @@ void ieee80211_key_link(struct ieee80211
72
73 __ieee80211_key_replace(sdata, sta, old_key, key);
74
75 - spin_unlock_irqrestore(&sdata->local->key_lock, flags);
76 -
77 /* free old key later */
78 add_todo(old_key, KEY_FLAG_TODO_DELETE);
79
80 add_todo(key, KEY_FLAG_TODO_ADD_DEBUGFS);
81 if (netif_running(sdata->dev))
82 add_todo(key, KEY_FLAG_TODO_HWACCEL_ADD);
83 +
84 + spin_unlock_irqrestore(&sdata->local->key_lock, flags);
85 }
86
87 static void __ieee80211_key_free(struct ieee80211_key *key)
88 @@ -550,7 +552,7 @@ static void __ieee80211_key_todo(void)
89 */
90 synchronize_rcu();
91
92 - spin_lock(&todo_lock);
93 + spin_lock_bh(&todo_lock);
94 while (!list_empty(&todo_list)) {
95 key = list_first_entry(&todo_list, struct ieee80211_key, todo);
96 list_del_init(&key->todo);
97 @@ -561,7 +563,7 @@ static void __ieee80211_key_todo(void)
98 KEY_FLAG_TODO_HWACCEL_REMOVE |
99 KEY_FLAG_TODO_DELETE);
100 key->flags &= ~todoflags;
101 - spin_unlock(&todo_lock);
102 + spin_unlock_bh(&todo_lock);
103
104 work_done = false;
105
106 @@ -594,9 +596,9 @@ static void __ieee80211_key_todo(void)
107
108 WARN_ON(!work_done);
109
110 - spin_lock(&todo_lock);
111 + spin_lock_bh(&todo_lock);
112 }
113 - spin_unlock(&todo_lock);
114 + spin_unlock_bh(&todo_lock);
115 }
116
117 void ieee80211_key_todo(void)
This page took 0.053496 seconds and 5 git commands to generate.