Skip to content

Commit fbc1cc6

Browse files
benzeajmberg-intel
authored andcommitted
wifi: mac80211: use wiphy_hrtimer_work for csa.switch_work
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>
1 parent 3f654d5 commit fbc1cc6

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
@@ -1290,7 +1290,7 @@ ieee80211_link_chanctx_reservation_complete(struct ieee80211_link_data *link)
12901290
&link->csa.finalize_work);
12911291
break;
12921292
case NL80211_IFTYPE_STATION:
1293-
wiphy_delayed_work_queue(sdata->local->hw.wiphy,
1293+
wiphy_hrtimer_work_queue(sdata->local->hw.wiphy,
12941294
&link->u.mgd.csa.switch_work, 0);
12951295
break;
12961296
case NL80211_IFTYPE_UNSPECIFIED:

net/mac80211/ieee80211_i.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,10 +1017,10 @@ struct ieee80211_link_data_managed {
10171017
bool operating_11g_mode;
10181018

10191019
struct {
1020-
struct wiphy_delayed_work switch_work;
1020+
struct wiphy_hrtimer_work switch_work;
10211021
struct cfg80211_chan_def ap_chandef;
10221022
struct ieee80211_parsed_tpe tpe;
1023-
unsigned long time;
1023+
ktime_t time;
10241024
bool waiting_bcn;
10251025
bool ignored_same_chan;
10261026
bool blocked_tx;

net/mac80211/link.c

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

481481
for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) {

net/mac80211/mlme.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2594,7 +2594,7 @@ void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success,
25942594
return;
25952595
}
25962596

2597-
wiphy_delayed_work_queue(sdata->local->hw.wiphy,
2597+
wiphy_hrtimer_work_queue(sdata->local->hw.wiphy,
25982598
&link->u.mgd.csa.switch_work, 0);
25992599
}
26002600

@@ -2753,7 +2753,8 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
27532753
.timestamp = timestamp,
27542754
.device_timestamp = device_timestamp,
27552755
};
2756-
unsigned long now;
2756+
u32 csa_time_tu;
2757+
ktime_t now;
27572758
int res;
27582759

27592760
lockdep_assert_wiphy(local->hw.wiphy);
@@ -2983,10 +2984,9 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
29832984
csa_ie.mode);
29842985

29852986
/* we may have to handle timeout for deactivated link in software */
2986-
now = jiffies;
2987-
link->u.mgd.csa.time = now +
2988-
TU_TO_JIFFIES((max_t(int, csa_ie.count, 1) - 1) *
2989-
link->conf->beacon_int);
2987+
now = ktime_get_boottime();
2988+
csa_time_tu = (max_t(int, csa_ie.count, 1) - 1) * link->conf->beacon_int;
2989+
link->u.mgd.csa.time = now + us_to_ktime(ieee80211_tu_to_usec(csa_time_tu));
29902990

29912991
if (ieee80211_vif_link_active(&sdata->vif, link->link_id) &&
29922992
local->ops->channel_switch) {
@@ -3001,7 +3001,7 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
30013001
}
30023002

30033003
/* channel switch handled in software */
3004-
wiphy_delayed_work_queue(local->hw.wiphy,
3004+
wiphy_hrtimer_work_queue(local->hw.wiphy,
30053005
&link->u.mgd.csa.switch_work,
30063006
link->u.mgd.csa.time - now);
30073007
return;
@@ -8849,7 +8849,7 @@ void ieee80211_mgd_setup_link(struct ieee80211_link_data *link)
88498849
else
88508850
link->u.mgd.req_smps = IEEE80211_SMPS_OFF;
88518851

8852-
wiphy_delayed_work_init(&link->u.mgd.csa.switch_work,
8852+
wiphy_hrtimer_work_init(&link->u.mgd.csa.switch_work,
88538853
ieee80211_csa_switch_work);
88548854

88558855
ieee80211_clear_tpe(&link->conf->tpe);
@@ -10064,7 +10064,7 @@ void ieee80211_mgd_stop_link(struct ieee80211_link_data *link)
1006410064
&link->u.mgd.request_smps_work);
1006510065
wiphy_work_cancel(link->sdata->local->hw.wiphy,
1006610066
&link->u.mgd.recalc_smps);
10067-
wiphy_delayed_work_cancel(link->sdata->local->hw.wiphy,
10067+
wiphy_hrtimer_work_cancel(link->sdata->local->hw.wiphy,
1006810068
&link->u.mgd.csa.switch_work);
1006910069
}
1007010070

0 commit comments

Comments
 (0)