Skip to content

Commit ec3252b

Browse files
committed
wifi: mac80211: use wiphy work for channel switch
Channel switch obviously must be handled per link, and we have a (potential) deadlock when canceling that work. Use the new delayed wiphy work to handle this instead and get rid of the explicit timer that way too. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 1444f58 commit ec3252b

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

net/mac80211/chan.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,8 +1205,8 @@ ieee80211_link_chanctx_reservation_complete(struct ieee80211_link_data *link)
12051205
&link->csa_finalize_work);
12061206
break;
12071207
case NL80211_IFTYPE_STATION:
1208-
ieee80211_queue_work(&sdata->local->hw,
1209-
&link->u.mgd.chswitch_work);
1208+
wiphy_delayed_work_queue(sdata->local->hw.wiphy,
1209+
&link->u.mgd.chswitch_work, 0);
12101210
break;
12111211
case NL80211_IFTYPE_UNSPECIFIED:
12121212
case NL80211_IFTYPE_AP_VLAN:

net/mac80211/ieee80211_i.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,8 +918,7 @@ struct ieee80211_link_data_managed {
918918

919919
bool csa_waiting_bcn;
920920
bool csa_ignored_same_chan;
921-
struct timer_list chswitch_timer;
922-
struct work_struct chswitch_work;
921+
struct wiphy_delayed_work chswitch_work;
923922

924923
struct wiphy_work request_smps_work;
925924
bool beacon_crc_valid;

net/mac80211/mlme.c

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,10 +1679,12 @@ void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local,
16791679
}
16801680

16811681
/* spectrum management related things */
1682-
static void ieee80211_chswitch_work(struct work_struct *work)
1682+
static void ieee80211_chswitch_work(struct wiphy *wiphy,
1683+
struct wiphy_work *work)
16831684
{
16841685
struct ieee80211_link_data *link =
1685-
container_of(work, struct ieee80211_link_data, u.mgd.chswitch_work);
1686+
container_of(work, struct ieee80211_link_data,
1687+
u.mgd.chswitch_work.work);
16861688
struct ieee80211_sub_if_data *sdata = link->sdata;
16871689
struct ieee80211_local *local = sdata->local;
16881690
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
@@ -1802,21 +1804,13 @@ void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success)
18021804
ieee80211_queue_work(&sdata->local->hw,
18031805
&ifmgd->csa_connection_drop_work);
18041806
} else {
1805-
ieee80211_queue_work(&sdata->local->hw,
1806-
&sdata->deflink.u.mgd.chswitch_work);
1807+
wiphy_delayed_work_queue(sdata->local->hw.wiphy,
1808+
&sdata->deflink.u.mgd.chswitch_work,
1809+
0);
18071810
}
18081811
}
18091812
EXPORT_SYMBOL(ieee80211_chswitch_done);
18101813

1811-
static void ieee80211_chswitch_timer(struct timer_list *t)
1812-
{
1813-
struct ieee80211_link_data *link =
1814-
from_timer(link, t, u.mgd.chswitch_timer);
1815-
1816-
ieee80211_queue_work(&link->sdata->local->hw,
1817-
&link->u.mgd.chswitch_work);
1818-
}
1819-
18201814
static void
18211815
ieee80211_sta_abort_chanswitch(struct ieee80211_link_data *link)
18221816
{
@@ -1860,6 +1854,7 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
18601854
struct ieee80211_csa_ie csa_ie;
18611855
struct ieee80211_channel_switch ch_switch;
18621856
struct ieee80211_bss *bss;
1857+
unsigned long timeout;
18631858
int res;
18641859

18651860
sdata_assert_lock(sdata);
@@ -2003,12 +1998,11 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
20031998
}
20041999

20052000
/* channel switch handled in software */
2006-
if (csa_ie.count <= 1)
2007-
ieee80211_queue_work(&local->hw, &link->u.mgd.chswitch_work);
2008-
else
2009-
mod_timer(&link->u.mgd.chswitch_timer,
2010-
TU_TO_EXP_TIME((csa_ie.count - 1) *
2011-
cbss->beacon_interval));
2001+
timeout = TU_TO_JIFFIES((max_t(int, csa_ie.count, 1) - 1) *
2002+
cbss->beacon_interval);
2003+
wiphy_delayed_work_queue(local->hw.wiphy,
2004+
&link->u.mgd.chswitch_work,
2005+
timeout);
20122006
return;
20132007
lock_and_drop_connection:
20142008
mutex_lock(&local->mtx);
@@ -3030,7 +3024,6 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
30303024
del_timer_sync(&sdata->u.mgd.conn_mon_timer);
30313025
del_timer_sync(&sdata->u.mgd.bcn_mon_timer);
30323026
del_timer_sync(&sdata->u.mgd.timer);
3033-
del_timer_sync(&sdata->deflink.u.mgd.chswitch_timer);
30343027

30353028
sdata->vif.bss_conf.dtim_period = 0;
30363029
sdata->vif.bss_conf.beacon_rate = NULL;
@@ -6596,8 +6589,8 @@ void ieee80211_mgd_setup_link(struct ieee80211_link_data *link)
65966589
else
65976590
link->u.mgd.req_smps = IEEE80211_SMPS_OFF;
65986591

6599-
INIT_WORK(&link->u.mgd.chswitch_work, ieee80211_chswitch_work);
6600-
timer_setup(&link->u.mgd.chswitch_timer, ieee80211_chswitch_timer, 0);
6592+
wiphy_delayed_work_init(&link->u.mgd.chswitch_work,
6593+
ieee80211_chswitch_work);
66016594

66026595
if (sdata->u.mgd.assoc_data)
66036596
ether_addr_copy(link->conf->addr,
@@ -7555,7 +7548,8 @@ void ieee80211_mgd_stop_link(struct ieee80211_link_data *link)
75557548
{
75567549
wiphy_work_cancel(link->sdata->local->hw.wiphy,
75577550
&link->u.mgd.request_smps_work);
7558-
cancel_work_sync(&link->u.mgd.chswitch_work);
7551+
wiphy_delayed_work_cancel(link->sdata->local->hw.wiphy,
7552+
&link->u.mgd.chswitch_work);
75597553
}
75607554

75617555
void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata)

0 commit comments

Comments
 (0)