wifi: mac80211: move key tailroom work to wiphy work
authorJohannes Berg <johannes.berg@intel.com>
Mon, 28 Aug 2023 11:59:47 +0000 (13:59 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 11 Sep 2023 09:27:20 +0000 (11:27 +0200)
This way we hold the wiphy mutex there, as a step towards
removing some of the additional locks we have.

Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/ieee80211_i.h
net/mac80211/iface.c
net/mac80211/key.c
net/mac80211/key.h
net/mac80211/main.c
net/mac80211/pm.c

index 1dc49bbd35bfa95dabbcc4dbd03bb0507d7bda50..c5a414b1fd0a14f8c4092e0e31bbc675810a3c25 100644 (file)
@@ -1041,7 +1041,7 @@ struct ieee80211_sub_if_data {
        /* count for keys needing tailroom space allocation */
        int crypto_tx_tailroom_needed_cnt;
        int crypto_tx_tailroom_pending_dec;
-       struct delayed_work dec_tailroom_needed_wk;
+       struct wiphy_delayed_work dec_tailroom_needed_wk;
 
        struct net_device *dev;
        struct ieee80211_local *local;
index 6dc6cdc1cd37859b73060b1b77dbf4d6373d4641..fbfb9037b5239b0844869b7094c72c90653152ac 100644 (file)
@@ -2149,8 +2149,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
 
        INIT_LIST_HEAD(&sdata->key_list);
 
-       INIT_DELAYED_WORK(&sdata->dec_tailroom_needed_wk,
-                         ieee80211_delayed_tailroom_dec);
+       wiphy_delayed_work_init(&sdata->dec_tailroom_needed_wk,
+                               ieee80211_delayed_tailroom_dec);
 
        for (i = 0; i < NUM_NL80211_BANDS; i++) {
                struct ieee80211_supported_band *sband;
index 13050dc9321f197d6aaa1c55235302bfa2ecf6f1..fbd9f9a9001cd2f2a97c733773af38e44a4512cd 100644 (file)
@@ -775,8 +775,9 @@ static void __ieee80211_key_destroy(struct ieee80211_key *key,
                if (delay_tailroom) {
                        /* see ieee80211_delayed_tailroom_dec */
                        sdata->crypto_tx_tailroom_pending_dec++;
-                       schedule_delayed_work(&sdata->dec_tailroom_needed_wk,
-                                             HZ/2);
+                       wiphy_delayed_work_queue(sdata->local->hw.wiphy,
+                                                &sdata->dec_tailroom_needed_wk,
+                                                HZ / 2);
                } else {
                        decrease_tailroom_need_count(sdata, 1);
                }
@@ -1122,7 +1123,8 @@ void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata,
        struct ieee80211_key *key, *tmp;
        LIST_HEAD(keys);
 
-       cancel_delayed_work_sync(&sdata->dec_tailroom_needed_wk);
+       wiphy_delayed_work_cancel(local->hw.wiphy,
+                                 &sdata->dec_tailroom_needed_wk);
 
        mutex_lock(&local->key_mtx);
 
@@ -1193,7 +1195,8 @@ void ieee80211_free_sta_keys(struct ieee80211_local *local,
        mutex_unlock(&local->key_mtx);
 }
 
-void ieee80211_delayed_tailroom_dec(struct work_struct *wk)
+void ieee80211_delayed_tailroom_dec(struct wiphy *wiphy,
+                                   struct wiphy_work *wk)
 {
        struct ieee80211_sub_if_data *sdata;
 
index f3df97df4b72b7b9e6b46907fa91bef64e186d55..231a069d2975c269f802bba90ed5e7820c057468 100644 (file)
@@ -2,7 +2,7 @@
 /*
  * Copyright 2002-2004, Instant802 Networks, Inc.
  * Copyright 2005, Devicescape Software, Inc.
- * Copyright (C) 2019, 2022 Intel Corporation
+ * Copyright (C) 2019, 2022-2023 Intel Corporation
  */
 
 #ifndef IEEE80211_KEY_H
@@ -174,6 +174,7 @@ int ieee80211_key_switch_links(struct ieee80211_sub_if_data *sdata,
 #define rcu_dereference_check_key_mtx(local, ref) \
        rcu_dereference_check(ref, lockdep_is_held(&((local)->key_mtx)))
 
-void ieee80211_delayed_tailroom_dec(struct work_struct *wk);
+void ieee80211_delayed_tailroom_dec(struct wiphy *wiphy,
+                                   struct wiphy_work *wk);
 
 #endif /* IEEE80211_KEY_H */
index ba5382efa950ce79d0fe0336d2ff12eb616ac82d..a66cfdca42efefffd6828b689597d3b9354347c3 100644 (file)
@@ -372,7 +372,8 @@ static void ieee80211_restart_work(struct work_struct *work)
                                sdata_unlock(sdata);
                        }
                }
-               flush_delayed_work(&sdata->dec_tailroom_needed_wk);
+               wiphy_delayed_work_flush(local->hw.wiphy,
+                                        &sdata->dec_tailroom_needed_wk);
        }
        ieee80211_scan_cancel(local);
 
index 10eb72b9b994e070a61161e7b143844cf3ff6625..e52dbf7d14fbed0853e405b5e045185e389b476f 100644 (file)
@@ -161,7 +161,8 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
                        break;
                }
 
-               flush_delayed_work(&sdata->dec_tailroom_needed_wk);
+               wiphy_delayed_work_flush(local->hw.wiphy,
+                                        &sdata->dec_tailroom_needed_wk);
                drv_remove_interface(local, sdata);
        }