Skip to content

Commit 12e7f51

Browse files
Stanislaw Gruszkajmberg-intel
authored andcommitted
mac80211: cleanup generic suspend/resume procedures
Since now we disconnect before suspend, various code which save connection state can now be removed from suspend and resume procedure. Cleanup on resume side is smaller as ieee80211_reconfig() is also used for H/W restart. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 8125696 commit 12e7f51

5 files changed

Lines changed: 6 additions & 154 deletions

File tree

‎net/mac80211/ieee80211_i.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -768,10 +768,6 @@ struct ieee80211_sub_if_data {
768768
} debugfs;
769769
#endif
770770

771-
#ifdef CONFIG_PM
772-
struct ieee80211_bss_conf suspend_bss_conf;
773-
#endif
774-
775771
/* must be last, dynamically sized area in this! */
776772
struct ieee80211_vif vif;
777773
};

‎net/mac80211/key.c‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -566,20 +566,6 @@ void ieee80211_iter_keys(struct ieee80211_hw *hw,
566566
}
567567
EXPORT_SYMBOL(ieee80211_iter_keys);
568568

569-
void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata)
570-
{
571-
struct ieee80211_key *key;
572-
573-
ASSERT_RTNL();
574-
575-
mutex_lock(&sdata->local->key_mtx);
576-
577-
list_for_each_entry(key, &sdata->key_list, list)
578-
ieee80211_key_disable_hw_accel(key);
579-
580-
mutex_unlock(&sdata->local->key_mtx);
581-
}
582-
583569
void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata)
584570
{
585571
struct ieee80211_key *key, *tmp;

‎net/mac80211/key.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ void ieee80211_set_default_mgmt_key(struct ieee80211_sub_if_data *sdata,
143143
int idx);
144144
void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata);
145145
void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata);
146-
void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata);
147146

148147
#define key_mtx_dereference(local, ref) \
149148
rcu_dereference_protected(ref, lockdep_is_held(&((local)->key_mtx)))

‎net/mac80211/pm.c‎

Lines changed: 6 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,11 @@
66
#include "driver-ops.h"
77
#include "led.h"
88

9-
/* return value indicates whether the driver should be further notified */
10-
static void ieee80211_quiesce(struct ieee80211_sub_if_data *sdata)
11-
{
12-
switch (sdata->vif.type) {
13-
case NL80211_IFTYPE_STATION:
14-
ieee80211_sta_quiesce(sdata);
15-
break;
16-
case NL80211_IFTYPE_ADHOC:
17-
ieee80211_ibss_quiesce(sdata);
18-
break;
19-
case NL80211_IFTYPE_MESH_POINT:
20-
ieee80211_mesh_quiesce(sdata);
21-
break;
22-
default:
23-
break;
24-
}
25-
26-
cancel_work_sync(&sdata->work);
27-
}
28-
299
int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
3010
{
3111
struct ieee80211_local *local = hw_to_local(hw);
3212
struct ieee80211_sub_if_data *sdata;
3313
struct sta_info *sta;
34-
struct ieee80211_chanctx *ctx;
3514

3615
if (!local->open_count)
3716
goto suspend;
@@ -95,17 +74,10 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
9574
WARN_ON(err != 1);
9675
return err;
9776
} else {
98-
list_for_each_entry(sdata, &local->interfaces, list)
99-
if (ieee80211_sdata_running(sdata))
100-
ieee80211_quiesce(sdata);
10177
goto suspend;
10278
}
10379
}
10480

105-
/* disable keys */
106-
list_for_each_entry(sdata, &local->interfaces, list)
107-
ieee80211_disable_keys(sdata);
108-
10981
/* tear down aggregation sessions and remove STAs */
11082
mutex_lock(&local->sta_mtx);
11183
list_for_each_entry(sta, &local->sta_list, list) {
@@ -117,100 +89,25 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
11789
WARN_ON(drv_sta_state(local, sta->sdata, sta,
11890
state, state - 1));
11991
}
120-
121-
mesh_plink_quiesce(sta);
12292
}
12393
mutex_unlock(&local->sta_mtx);
12494

12595
/* remove all interfaces */
12696
list_for_each_entry(sdata, &local->interfaces, list) {
127-
static u8 zero_addr[ETH_ALEN] = {};
128-
u32 changed = 0;
129-
13097
if (!ieee80211_sdata_running(sdata))
13198
continue;
132-
133-
switch (sdata->vif.type) {
134-
case NL80211_IFTYPE_AP_VLAN:
135-
case NL80211_IFTYPE_MONITOR:
136-
/* skip these */
137-
continue;
138-
case NL80211_IFTYPE_STATION:
139-
if (sdata->vif.bss_conf.assoc)
140-
changed = BSS_CHANGED_ASSOC |
141-
BSS_CHANGED_BSSID |
142-
BSS_CHANGED_IDLE;
143-
break;
144-
case NL80211_IFTYPE_AP:
145-
case NL80211_IFTYPE_ADHOC:
146-
case NL80211_IFTYPE_MESH_POINT:
147-
if (sdata->vif.bss_conf.enable_beacon)
148-
changed = BSS_CHANGED_BEACON_ENABLED;
149-
break;
150-
default:
151-
break;
152-
}
153-
154-
ieee80211_quiesce(sdata);
155-
156-
sdata->suspend_bss_conf = sdata->vif.bss_conf;
157-
memset(&sdata->vif.bss_conf, 0, sizeof(sdata->vif.bss_conf));
158-
sdata->vif.bss_conf.idle = true;
159-
if (sdata->suspend_bss_conf.bssid)
160-
sdata->vif.bss_conf.bssid = zero_addr;
161-
162-
/* disable beaconing or remove association */
163-
ieee80211_bss_info_change_notify(sdata, changed);
164-
165-
if (sdata->vif.type == NL80211_IFTYPE_AP &&
166-
rcu_access_pointer(sdata->u.ap.beacon))
167-
drv_stop_ap(local, sdata);
168-
169-
if (local->use_chanctx) {
170-
struct ieee80211_chanctx_conf *conf;
171-
172-
mutex_lock(&local->chanctx_mtx);
173-
conf = rcu_dereference_protected(
174-
sdata->vif.chanctx_conf,
175-
lockdep_is_held(&local->chanctx_mtx));
176-
if (conf) {
177-
ctx = container_of(conf,
178-
struct ieee80211_chanctx,
179-
conf);
180-
drv_unassign_vif_chanctx(local, sdata, ctx);
181-
}
182-
183-
mutex_unlock(&local->chanctx_mtx);
184-
}
18599
drv_remove_interface(local, sdata);
186100
}
187101

188102
sdata = rtnl_dereference(local->monitor_sdata);
189-
if (sdata) {
190-
if (local->use_chanctx) {
191-
struct ieee80211_chanctx_conf *conf;
192-
193-
mutex_lock(&local->chanctx_mtx);
194-
conf = rcu_dereference_protected(
195-
sdata->vif.chanctx_conf,
196-
lockdep_is_held(&local->chanctx_mtx));
197-
if (conf) {
198-
ctx = container_of(conf,
199-
struct ieee80211_chanctx,
200-
conf);
201-
drv_unassign_vif_chanctx(local, sdata, ctx);
202-
}
203-
204-
mutex_unlock(&local->chanctx_mtx);
205-
}
206-
103+
if (sdata)
207104
drv_remove_interface(local, sdata);
208-
}
209105

210-
mutex_lock(&local->chanctx_mtx);
211-
list_for_each_entry(ctx, &local->chanctx_list, list)
212-
drv_remove_chanctx(local, ctx);
213-
mutex_unlock(&local->chanctx_mtx);
106+
/*
107+
* We disconnected on all interfaces before suspend, all channel
108+
* contexts should be released.
109+
*/
110+
WARN_ON(!list_empty(&local->chanctx_list));
214111

215112
/* stop hardware - this must stop RX */
216113
if (local->open_count)

‎net/mac80211/util.c‎

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,11 +1534,6 @@ int ieee80211_reconfig(struct ieee80211_local *local)
15341534
BSS_CHANGED_IDLE |
15351535
BSS_CHANGED_TXPOWER;
15361536

1537-
#ifdef CONFIG_PM
1538-
if (local->resuming && !reconfig_due_to_wowlan)
1539-
sdata->vif.bss_conf = sdata->suspend_bss_conf;
1540-
#endif
1541-
15421537
switch (sdata->vif.type) {
15431538
case NL80211_IFTYPE_STATION:
15441539
changed |= BSS_CHANGED_ASSOC |
@@ -1678,28 +1673,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
16781673
mb();
16791674
local->resuming = false;
16801675

1681-
list_for_each_entry(sdata, &local->interfaces, list) {
1682-
switch(sdata->vif.type) {
1683-
case NL80211_IFTYPE_STATION:
1684-
ieee80211_sta_restart(sdata);
1685-
break;
1686-
case NL80211_IFTYPE_ADHOC:
1687-
ieee80211_ibss_restart(sdata);
1688-
break;
1689-
case NL80211_IFTYPE_MESH_POINT:
1690-
ieee80211_mesh_restart(sdata);
1691-
break;
1692-
default:
1693-
break;
1694-
}
1695-
}
1696-
16971676
mod_timer(&local->sta_cleanup, jiffies + 1);
1698-
1699-
mutex_lock(&local->sta_mtx);
1700-
list_for_each_entry(sta, &local->sta_list, list)
1701-
mesh_plink_restart(sta);
1702-
mutex_unlock(&local->sta_mtx);
17031677
#else
17041678
WARN_ON(1);
17051679
#endif

0 commit comments

Comments
 (0)