wifi: mac80211: move DFS CAC work to wiphy work
authorJohannes Berg <johannes.berg@intel.com>
Mon, 28 Aug 2023 11:59:37 +0000 (13:59 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 11 Sep 2023 09:27:19 +0000 (11:27 +0200)
Move the DFS CAC work over to hold the wiphy lock
there without worry about work cancellation.

Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/cfg.c
net/mac80211/ieee80211_i.h
net/mac80211/iface.c
net/mac80211/link.c
net/mac80211/mlme.c
net/mac80211/util.c

index fa20a260f9c84b4cf28949ed703a61a239e989c7..36e3515bf8d91065013b289bbd7d4b6d61293de4 100644 (file)
@@ -1643,7 +1643,7 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev,
 
        if (sdata->wdev.cac_started) {
                chandef = link_conf->chandef;
-               cancel_delayed_work_sync(&link->dfs_cac_timer_work);
+               wiphy_delayed_work_cancel(wiphy, &link->dfs_cac_timer_work);
                cfg80211_cac_event(sdata->dev, &chandef,
                                   NL80211_RADAR_CAC_ABORTED,
                                   GFP_KERNEL);
@@ -3424,9 +3424,8 @@ static int ieee80211_start_radar_detection(struct wiphy *wiphy,
        if (err)
                goto out_unlock;
 
-       ieee80211_queue_delayed_work(&sdata->local->hw,
-                                    &sdata->deflink.dfs_cac_timer_work,
-                                    msecs_to_jiffies(cac_time_ms));
+       wiphy_delayed_work_queue(wiphy, &sdata->deflink.dfs_cac_timer_work,
+                                msecs_to_jiffies(cac_time_ms));
 
  out_unlock:
        mutex_unlock(&local->mtx);
@@ -3445,7 +3444,8 @@ static void ieee80211_end_cac(struct wiphy *wiphy,
                 * by the time it gets it, sdata->wdev.cac_started
                 * will no longer be true
                 */
-               cancel_delayed_work(&sdata->deflink.dfs_cac_timer_work);
+               wiphy_delayed_work_cancel(wiphy,
+                                         &sdata->deflink.dfs_cac_timer_work);
 
                if (sdata->wdev.cac_started) {
                        ieee80211_link_release_channel(&sdata->deflink);
index 7604e43a441c3bdf21fdb7f3b1a789fb18ad9ca3..0d9aff6a4fc84aeeac7a0636199f475bb20c15e1 100644 (file)
@@ -1014,7 +1014,7 @@ struct ieee80211_link_data {
        int ap_power_level; /* in dBm */
 
        bool radar_required;
-       struct delayed_work dfs_cac_timer_work;
+       struct wiphy_delayed_work dfs_cac_timer_work;
 
        union {
                struct ieee80211_link_data_managed mgd;
@@ -2569,7 +2569,7 @@ void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local,
                                      struct ieee80211_link_data *rsvd_for);
 bool ieee80211_is_radar_required(struct ieee80211_local *local);
 
-void ieee80211_dfs_cac_timer_work(struct work_struct *work);
+void ieee80211_dfs_cac_timer_work(struct wiphy *wiphy, struct wiphy_work *work);
 void ieee80211_dfs_cac_cancel(struct ieee80211_local *local);
 void ieee80211_dfs_radar_detected_work(struct work_struct *work);
 int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata,
index 4beab027e0f95dcdc41d377130808c9b3bec8362..a8c08424c01504a444e4cee0904e5e1098d435b9 100644 (file)
@@ -538,7 +538,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do
        cancel_work_sync(&sdata->deflink.csa_finalize_work);
        cancel_work_sync(&sdata->deflink.color_change_finalize_work);
 
-       cancel_delayed_work_sync(&sdata->deflink.dfs_cac_timer_work);
+       wiphy_delayed_work_cancel(local->hw.wiphy,
+                                 &sdata->deflink.dfs_cac_timer_work);
 
        if (sdata->wdev.cac_started) {
                chandef = sdata->vif.bss_conf.chandef;
index 6148208b320e3b68f7975c7a2e7a9840bb7f6ff4..748d222e8d3dd8b25aa76cba39c5cddefae2375b 100644 (file)
@@ -45,8 +45,8 @@ void ieee80211_link_init(struct ieee80211_sub_if_data *sdata,
                          ieee80211_color_collision_detection_work);
        INIT_LIST_HEAD(&link->assigned_chanctx_list);
        INIT_LIST_HEAD(&link->reserved_chanctx_list);
-       INIT_DELAYED_WORK(&link->dfs_cac_timer_work,
-                         ieee80211_dfs_cac_timer_work);
+       wiphy_delayed_work_init(&link->dfs_cac_timer_work,
+                               ieee80211_dfs_cac_timer_work);
 
        if (!deflink) {
                switch (sdata->vif.type) {
index 65d3e167132cead5cc9f035407a30d50e331ccd9..5644e25ec5fe84af6380d2a917246c6ef7f2a468 100644 (file)
@@ -2401,12 +2401,11 @@ void ieee80211_dynamic_ps_timer(struct timer_list *t)
        ieee80211_queue_work(&local->hw, &local->dynamic_ps_enable_work);
 }
 
-void ieee80211_dfs_cac_timer_work(struct work_struct *work)
+void ieee80211_dfs_cac_timer_work(struct wiphy *wiphy, struct wiphy_work *work)
 {
-       struct delayed_work *delayed_work = to_delayed_work(work);
        struct ieee80211_link_data *link =
-               container_of(delayed_work, struct ieee80211_link_data,
-                            dfs_cac_timer_work);
+               container_of(work, struct ieee80211_link_data,
+                            dfs_cac_timer_work.work);
        struct cfg80211_chan_def chandef = link->conf->chandef;
        struct ieee80211_sub_if_data *sdata = link->sdata;
 
index 6d8b73796dc5234f2f1f1054f4b6e9d7bf888579..ff99aee46656502364de85d269faedcfc5416261 100644 (file)
@@ -4343,7 +4343,8 @@ void ieee80211_dfs_cac_cancel(struct ieee80211_local *local)
                 * by the time it gets it, sdata->wdev.cac_started
                 * will no longer be true
                 */
-               cancel_delayed_work(&sdata->deflink.dfs_cac_timer_work);
+               wiphy_delayed_work_cancel(local->hw.wiphy,
+                                         &sdata->deflink.dfs_cac_timer_work);
 
                if (sdata->wdev.cac_started) {
                        chandef = sdata->vif.bss_conf.chandef;