Skip to content

Commit 72cc85e

Browse files
benzeajfvogel
authored andcommitted
wifi: mac80211: use wiphy_hrtimer_work for csa.switch_work
[ Upstream commit fbc1cc6973099f45e4c30b86f12b4435c7cb7d24 ] The work item may be scheduled relatively far in the future. As the event happens at a specific point in time, the normal timer accuracy is not sufficient in that case. Switch to use wiphy_hrtimer_work so that the accuracy is sufficient. To make this work, use the same clock to store the timestamp. CC: stable@vger.kernel.org Fixes: ec3252b ("wifi: mac80211: use wiphy work for channel switch") Signed-off-by: Benjamin Berg <benjamin.berg@intel.com> Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20251028125710.68258c7e4ac4.I4ff2b2cdffbbf858bf5f08baccc7a88c4f9efe6f@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit c0a9c2c1b7b9915ab1d474d9df8b14aa33f49704) Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
1 parent 8066c83 commit 72cc85e

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

net/mac80211/chan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ ieee80211_link_chanctx_reservation_complete(struct ieee80211_link_data *link)
12461246
&link->csa.finalize_work);
12471247
break;
12481248
case NL80211_IFTYPE_STATION:
1249-
wiphy_delayed_work_queue(sdata->local->hw.wiphy,
1249+
wiphy_hrtimer_work_queue(sdata->local->hw.wiphy,
12501250
&link->u.mgd.csa.switch_work, 0);
12511251
break;
12521252
case NL80211_IFTYPE_UNSPECIFIED:

net/mac80211/ieee80211_i.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,10 +981,10 @@ struct ieee80211_link_data_managed {
981981
bool operating_11g_mode;
982982

983983
struct {
984-
struct wiphy_delayed_work switch_work;
984+
struct wiphy_hrtimer_work switch_work;
985985
struct cfg80211_chan_def ap_chandef;
986986
struct ieee80211_parsed_tpe tpe;
987-
unsigned long time;
987+
ktime_t time;
988988
bool waiting_bcn;
989989
bool ignored_same_chan;
990990
bool blocked_tx;

net/mac80211/link.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,10 @@ static int _ieee80211_set_active_links(struct ieee80211_sub_if_data *sdata,
469469
* from there.
470470
*/
471471
if (link->conf->csa_active)
472-
wiphy_delayed_work_queue(local->hw.wiphy,
472+
wiphy_hrtimer_work_queue(local->hw.wiphy,
473473
&link->u.mgd.csa.switch_work,
474474
link->u.mgd.csa.time -
475-
jiffies);
475+
ktime_get_boottime());
476476
}
477477

478478
list_for_each_entry(sta, &local->sta_list, list) {

net/mac80211/mlme.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2225,7 +2225,7 @@ void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success,
22252225
return;
22262226
}
22272227

2228-
wiphy_delayed_work_queue(sdata->local->hw.wiphy,
2228+
wiphy_hrtimer_work_queue(sdata->local->hw.wiphy,
22292229
&link->u.mgd.csa.switch_work, 0);
22302230
}
22312231

@@ -2384,7 +2384,8 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
23842384
.timestamp = timestamp,
23852385
.device_timestamp = device_timestamp,
23862386
};
2387-
unsigned long now;
2387+
u32 csa_time_tu;
2388+
ktime_t now;
23882389
int res;
23892390

23902391
lockdep_assert_wiphy(local->hw.wiphy);
@@ -2614,10 +2615,9 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
26142615
csa_ie.mode);
26152616

26162617
/* we may have to handle timeout for deactivated link in software */
2617-
now = jiffies;
2618-
link->u.mgd.csa.time = now +
2619-
TU_TO_JIFFIES((max_t(int, csa_ie.count, 1) - 1) *
2620-
link->conf->beacon_int);
2618+
now = ktime_get_boottime();
2619+
csa_time_tu = (max_t(int, csa_ie.count, 1) - 1) * link->conf->beacon_int;
2620+
link->u.mgd.csa.time = now + ns_to_ktime(ieee80211_tu_to_usec(csa_time_tu) * NSEC_PER_USEC);
26212621

26222622
if (ieee80211_vif_link_active(&sdata->vif, link->link_id) &&
26232623
local->ops->channel_switch) {
@@ -2632,7 +2632,7 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
26322632
}
26332633

26342634
/* channel switch handled in software */
2635-
wiphy_delayed_work_queue(local->hw.wiphy,
2635+
wiphy_hrtimer_work_queue(local->hw.wiphy,
26362636
&link->u.mgd.csa.switch_work,
26372637
link->u.mgd.csa.time - now);
26382638
return;
@@ -8137,7 +8137,7 @@ void ieee80211_mgd_setup_link(struct ieee80211_link_data *link)
81378137
else
81388138
link->u.mgd.req_smps = IEEE80211_SMPS_OFF;
81398139

8140-
wiphy_delayed_work_init(&link->u.mgd.csa.switch_work,
8140+
wiphy_hrtimer_work_init(&link->u.mgd.csa.switch_work,
81418141
ieee80211_csa_switch_work);
81428142

81438143
ieee80211_clear_tpe(&link->conf->tpe);
@@ -9267,7 +9267,7 @@ void ieee80211_mgd_stop_link(struct ieee80211_link_data *link)
92679267
&link->u.mgd.request_smps_work);
92689268
wiphy_work_cancel(link->sdata->local->hw.wiphy,
92699269
&link->u.mgd.recalc_smps);
9270-
wiphy_delayed_work_cancel(link->sdata->local->hw.wiphy,
9270+
wiphy_hrtimer_work_cancel(link->sdata->local->hw.wiphy,
92719271
&link->u.mgd.csa.switch_work);
92729272
}
92739273

0 commit comments

Comments
 (0)