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>
This commit is contained in:
Johannes Berg 2023-06-06 14:49:29 +02:00
parent 1444f58931
commit ec3252bff7
3 changed files with 20 additions and 27 deletions

View File

@ -1205,8 +1205,8 @@ ieee80211_link_chanctx_reservation_complete(struct ieee80211_link_data *link)
&link->csa_finalize_work); &link->csa_finalize_work);
break; break;
case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_STATION:
ieee80211_queue_work(&sdata->local->hw, wiphy_delayed_work_queue(sdata->local->hw.wiphy,
&link->u.mgd.chswitch_work); &link->u.mgd.chswitch_work, 0);
break; break;
case NL80211_IFTYPE_UNSPECIFIED: case NL80211_IFTYPE_UNSPECIFIED:
case NL80211_IFTYPE_AP_VLAN: case NL80211_IFTYPE_AP_VLAN:

View File

@ -918,8 +918,7 @@ struct ieee80211_link_data_managed {
bool csa_waiting_bcn; bool csa_waiting_bcn;
bool csa_ignored_same_chan; bool csa_ignored_same_chan;
struct timer_list chswitch_timer; struct wiphy_delayed_work chswitch_work;
struct work_struct chswitch_work;
struct wiphy_work request_smps_work; struct wiphy_work request_smps_work;
bool beacon_crc_valid; bool beacon_crc_valid;

View File

@ -1679,10 +1679,12 @@ void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local,
} }
/* spectrum management related things */ /* spectrum management related things */
static void ieee80211_chswitch_work(struct work_struct *work) static void ieee80211_chswitch_work(struct wiphy *wiphy,
struct wiphy_work *work)
{ {
struct ieee80211_link_data *link = struct ieee80211_link_data *link =
container_of(work, struct ieee80211_link_data, u.mgd.chswitch_work); container_of(work, struct ieee80211_link_data,
u.mgd.chswitch_work.work);
struct ieee80211_sub_if_data *sdata = link->sdata; struct ieee80211_sub_if_data *sdata = link->sdata;
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
@ -1802,21 +1804,13 @@ void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success)
ieee80211_queue_work(&sdata->local->hw, ieee80211_queue_work(&sdata->local->hw,
&ifmgd->csa_connection_drop_work); &ifmgd->csa_connection_drop_work);
} else { } else {
ieee80211_queue_work(&sdata->local->hw, wiphy_delayed_work_queue(sdata->local->hw.wiphy,
&sdata->deflink.u.mgd.chswitch_work); &sdata->deflink.u.mgd.chswitch_work,
0);
} }
} }
EXPORT_SYMBOL(ieee80211_chswitch_done); EXPORT_SYMBOL(ieee80211_chswitch_done);
static void ieee80211_chswitch_timer(struct timer_list *t)
{
struct ieee80211_link_data *link =
from_timer(link, t, u.mgd.chswitch_timer);
ieee80211_queue_work(&link->sdata->local->hw,
&link->u.mgd.chswitch_work);
}
static void static void
ieee80211_sta_abort_chanswitch(struct ieee80211_link_data *link) ieee80211_sta_abort_chanswitch(struct ieee80211_link_data *link)
{ {
@ -1860,6 +1854,7 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
struct ieee80211_csa_ie csa_ie; struct ieee80211_csa_ie csa_ie;
struct ieee80211_channel_switch ch_switch; struct ieee80211_channel_switch ch_switch;
struct ieee80211_bss *bss; struct ieee80211_bss *bss;
unsigned long timeout;
int res; int res;
sdata_assert_lock(sdata); sdata_assert_lock(sdata);
@ -2003,12 +1998,11 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
} }
/* channel switch handled in software */ /* channel switch handled in software */
if (csa_ie.count <= 1) timeout = TU_TO_JIFFIES((max_t(int, csa_ie.count, 1) - 1) *
ieee80211_queue_work(&local->hw, &link->u.mgd.chswitch_work); cbss->beacon_interval);
else wiphy_delayed_work_queue(local->hw.wiphy,
mod_timer(&link->u.mgd.chswitch_timer, &link->u.mgd.chswitch_work,
TU_TO_EXP_TIME((csa_ie.count - 1) * timeout);
cbss->beacon_interval));
return; return;
lock_and_drop_connection: lock_and_drop_connection:
mutex_lock(&local->mtx); mutex_lock(&local->mtx);
@ -3030,7 +3024,6 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
del_timer_sync(&sdata->u.mgd.conn_mon_timer); del_timer_sync(&sdata->u.mgd.conn_mon_timer);
del_timer_sync(&sdata->u.mgd.bcn_mon_timer); del_timer_sync(&sdata->u.mgd.bcn_mon_timer);
del_timer_sync(&sdata->u.mgd.timer); del_timer_sync(&sdata->u.mgd.timer);
del_timer_sync(&sdata->deflink.u.mgd.chswitch_timer);
sdata->vif.bss_conf.dtim_period = 0; sdata->vif.bss_conf.dtim_period = 0;
sdata->vif.bss_conf.beacon_rate = NULL; sdata->vif.bss_conf.beacon_rate = NULL;
@ -6596,8 +6589,8 @@ void ieee80211_mgd_setup_link(struct ieee80211_link_data *link)
else else
link->u.mgd.req_smps = IEEE80211_SMPS_OFF; link->u.mgd.req_smps = IEEE80211_SMPS_OFF;
INIT_WORK(&link->u.mgd.chswitch_work, ieee80211_chswitch_work); wiphy_delayed_work_init(&link->u.mgd.chswitch_work,
timer_setup(&link->u.mgd.chswitch_timer, ieee80211_chswitch_timer, 0); ieee80211_chswitch_work);
if (sdata->u.mgd.assoc_data) if (sdata->u.mgd.assoc_data)
ether_addr_copy(link->conf->addr, ether_addr_copy(link->conf->addr,
@ -7555,7 +7548,8 @@ void ieee80211_mgd_stop_link(struct ieee80211_link_data *link)
{ {
wiphy_work_cancel(link->sdata->local->hw.wiphy, wiphy_work_cancel(link->sdata->local->hw.wiphy,
&link->u.mgd.request_smps_work); &link->u.mgd.request_smps_work);
cancel_work_sync(&link->u.mgd.chswitch_work); wiphy_delayed_work_cancel(link->sdata->local->hw.wiphy,
&link->u.mgd.chswitch_work);
} }
void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata) void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata)