linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org
Cc: Johannes Berg <johannes.berg@intel.com>
Subject: [PATCH 14/40] wifi: mac80211: move offchannel works to wiphy work
Date: Mon, 28 Aug 2023 13:59:42 +0200	[thread overview]
Message-ID: <20230828135927.14c989da9ed2.I2c1a380b5d47b5b4122ff3f0ceb9d5c82d37f587@changeid> (raw)
In-Reply-To: <20230828115927.116700-41-johannes@sipsolutions.net>

From: Johannes Berg <johannes.berg@intel.com>

Make the offchannel works wiphy works to have the
wiphy locked for executing them.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/mac80211/ieee80211_i.h |  4 ++--
 net/mac80211/main.c        |  6 +++---
 net/mac80211/offchannel.c  | 36 ++++++++++++++++++------------------
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 1cb29a67a2c7..6d789087b453 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1589,9 +1589,9 @@ struct ieee80211_local {
 	/*
 	 * Remain-on-channel support
 	 */
-	struct delayed_work roc_work;
+	struct wiphy_delayed_work roc_work;
 	struct list_head roc_list;
-	struct work_struct hw_roc_start, hw_roc_done;
+	struct wiphy_work hw_roc_start, hw_roc_done;
 	unsigned long hw_roc_start_time;
 	u64 roc_cookie_counter;
 
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index f6860889fbdd..e686b0cc2cd8 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -377,8 +377,8 @@ static void ieee80211_restart_work(struct work_struct *work)
 	ieee80211_scan_cancel(local);
 
 	/* make sure any new ROC will consider local->in_reconfig */
-	flush_delayed_work(&local->roc_work);
-	flush_work(&local->hw_roc_done);
+	wiphy_delayed_work_flush(local->hw.wiphy, &local->roc_work);
+	wiphy_work_flush(local->hw.wiphy, &local->hw_roc_done);
 
 	/* wait for all packet processing to be done */
 	synchronize_net();
@@ -1501,11 +1501,11 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)
 	ieee80211_remove_interfaces(local);
 
 	wiphy_lock(local->hw.wiphy);
+	wiphy_delayed_work_cancel(local->hw.wiphy, &local->roc_work);
 	wiphy_work_cancel(local->hw.wiphy, &local->radar_detected_work);
 	wiphy_unlock(local->hw.wiphy);
 	rtnl_unlock();
 
-	cancel_delayed_work_sync(&local->roc_work);
 	cancel_work_sync(&local->restart_work);
 	cancel_work_sync(&local->reconfig_filter);
 	flush_work(&local->sched_scan_stopped_work);
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
index cdf991e74ab9..5bedd9cef414 100644
--- a/net/mac80211/offchannel.c
+++ b/net/mac80211/offchannel.c
@@ -230,7 +230,7 @@ static bool ieee80211_recalc_sw_work(struct ieee80211_local *local,
 	if (dur == LONG_MAX)
 		return false;
 
-	mod_delayed_work(local->workqueue, &local->roc_work, dur);
+	wiphy_delayed_work_queue(local->hw.wiphy, &local->roc_work, dur);
 	return true;
 }
 
@@ -258,7 +258,7 @@ static void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc,
 	roc->notified = true;
 }
 
-static void ieee80211_hw_roc_start(struct work_struct *work)
+static void ieee80211_hw_roc_start(struct wiphy *wiphy, struct wiphy_work *work)
 {
 	struct ieee80211_local *local =
 		container_of(work, struct ieee80211_local, hw_roc_start);
@@ -285,7 +285,7 @@ void ieee80211_ready_on_channel(struct ieee80211_hw *hw)
 
 	trace_api_ready_on_channel(local);
 
-	ieee80211_queue_work(hw, &local->hw_roc_start);
+	wiphy_work_queue(hw->wiphy, &local->hw_roc_start);
 }
 EXPORT_SYMBOL_GPL(ieee80211_ready_on_channel);
 
@@ -338,7 +338,7 @@ static void _ieee80211_start_next_roc(struct ieee80211_local *local)
 				tmp->started = true;
 				tmp->abort = true;
 			}
-			ieee80211_queue_work(&local->hw, &local->hw_roc_done);
+			wiphy_work_queue(local->hw.wiphy, &local->hw_roc_done);
 			return;
 		}
 
@@ -368,8 +368,8 @@ static void _ieee80211_start_next_roc(struct ieee80211_local *local)
 			ieee80211_hw_config(local, 0);
 		}
 
-		ieee80211_queue_delayed_work(&local->hw, &local->roc_work,
-					     msecs_to_jiffies(min_dur));
+		wiphy_delayed_work_queue(local->hw.wiphy, &local->roc_work,
+					 msecs_to_jiffies(min_dur));
 
 		/* tell userspace or send frame(s) */
 		list_for_each_entry(tmp, &local->roc_list, list) {
@@ -407,8 +407,8 @@ void ieee80211_start_next_roc(struct ieee80211_local *local)
 		_ieee80211_start_next_roc(local);
 	} else {
 		/* delay it a bit */
-		ieee80211_queue_delayed_work(&local->hw, &local->roc_work,
-					     round_jiffies_relative(HZ/2));
+		wiphy_delayed_work_queue(local->hw.wiphy, &local->roc_work,
+					 round_jiffies_relative(HZ / 2));
 	}
 }
 
@@ -451,7 +451,7 @@ static void __ieee80211_roc_work(struct ieee80211_local *local)
 	}
 }
 
-static void ieee80211_roc_work(struct work_struct *work)
+static void ieee80211_roc_work(struct wiphy *wiphy, struct wiphy_work *work)
 {
 	struct ieee80211_local *local =
 		container_of(work, struct ieee80211_local, roc_work.work);
@@ -461,7 +461,7 @@ static void ieee80211_roc_work(struct work_struct *work)
 	mutex_unlock(&local->mtx);
 }
 
-static void ieee80211_hw_roc_done(struct work_struct *work)
+static void ieee80211_hw_roc_done(struct wiphy *wiphy, struct wiphy_work *work)
 {
 	struct ieee80211_local *local =
 		container_of(work, struct ieee80211_local, hw_roc_done);
@@ -482,7 +482,7 @@ void ieee80211_remain_on_channel_expired(struct ieee80211_hw *hw)
 
 	trace_api_remain_on_channel_expired(local);
 
-	ieee80211_queue_work(hw, &local->hw_roc_done);
+	wiphy_work_queue(hw->wiphy, &local->hw_roc_done);
 }
 EXPORT_SYMBOL_GPL(ieee80211_remain_on_channel_expired);
 
@@ -586,8 +586,8 @@ static int ieee80211_start_roc_work(struct ieee80211_local *local,
 		/* if not HW assist, just queue & schedule work */
 		if (!local->ops->remain_on_channel) {
 			list_add_tail(&roc->list, &local->roc_list);
-			ieee80211_queue_delayed_work(&local->hw,
-						     &local->roc_work, 0);
+			wiphy_delayed_work_queue(local->hw.wiphy,
+						 &local->roc_work, 0);
 		} else {
 			/* otherwise actually kick it off here
 			 * (for error handling)
@@ -695,7 +695,7 @@ static int ieee80211_cancel_roc(struct ieee80211_local *local,
 	if (!cookie)
 		return -ENOENT;
 
-	flush_work(&local->hw_roc_start);
+	wiphy_work_flush(local->hw.wiphy, &local->hw_roc_start);
 
 	mutex_lock(&local->mtx);
 	list_for_each_entry_safe(roc, tmp, &local->roc_list, list) {
@@ -745,7 +745,7 @@ static int ieee80211_cancel_roc(struct ieee80211_local *local,
 	} else {
 		/* go through work struct to return to the operating channel */
 		found->abort = true;
-		mod_delayed_work(local->workqueue, &local->roc_work, 0);
+		wiphy_delayed_work_queue(local->hw.wiphy, &local->roc_work, 0);
 	}
 
  out_unlock:
@@ -994,9 +994,9 @@ int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
 
 void ieee80211_roc_setup(struct ieee80211_local *local)
 {
-	INIT_WORK(&local->hw_roc_start, ieee80211_hw_roc_start);
-	INIT_WORK(&local->hw_roc_done, ieee80211_hw_roc_done);
-	INIT_DELAYED_WORK(&local->roc_work, ieee80211_roc_work);
+	wiphy_work_init(&local->hw_roc_start, ieee80211_hw_roc_start);
+	wiphy_work_init(&local->hw_roc_done, ieee80211_hw_roc_done);
+	wiphy_delayed_work_init(&local->roc_work, ieee80211_roc_work);
 	INIT_LIST_HEAD(&local->roc_list);
 }
 
-- 
2.41.0


  parent reply	other threads:[~2023-08-28 12:06 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-28 11:59 [PATCH 00/40] wifi: cfg80211/mac80211: locking cleanups Johannes Berg
2023-08-28 11:59 ` [PATCH 01/40] wifi: mac80211: debugfs: lock wiphy instead of RTNL Johannes Berg
2023-08-28 11:59 ` [PATCH 02/40] wifi: mac80211: hold wiphy lock in netdev/link debugfs Johannes Berg
2023-08-28 11:59 ` [PATCH 03/40] wifi: mac80211: lock wiphy for aggregation debugfs Johannes Berg
2023-08-28 11:59 ` [PATCH 04/40] wifi: cfg80211: check RTNL when iterating devices Johannes Berg
2023-08-28 11:59 ` [PATCH 05/40] wifi: cfg80211: add flush functions for wiphy work Johannes Berg
2023-08-28 11:59 ` [PATCH 06/40] wifi: mac80211: flush wiphy work where appropriate Johannes Berg
2023-08-28 11:59 ` [PATCH 07/40] wifi: mac80211: convert A-MPDU work to wiphy work Johannes Berg
2023-08-28 11:59 ` [PATCH 08/40] wifi: mac80211: add more ops assertions Johannes Berg
2023-08-28 11:59 ` [PATCH 09/40] wifi: mac80211: move DFS CAC work to wiphy work Johannes Berg
2023-08-28 11:59 ` [PATCH 10/40] wifi: mac80211: move radar detect " Johannes Berg
2023-08-28 11:59 ` [PATCH 11/40] wifi: mac80211: move scan " Johannes Berg
2023-08-28 11:59 ` [PATCH 12/40] wifi: mac80211: move monitor " Johannes Berg
2023-08-28 11:59 ` [PATCH 13/40] wifi: mac80211: lock wiphy in IP address notifier Johannes Berg
2023-08-28 11:59 ` Johannes Berg [this message]
2023-08-28 11:59 ` [PATCH 15/40] wifi: mac80211: move link activation work to wiphy work Johannes Berg
2023-08-28 11:59 ` [PATCH 16/40] wifi: mac80211: move dynamic PS " Johannes Berg
2023-08-28 11:59 ` [PATCH 17/40] wifi: mac80211: move sched-scan stop work " Johannes Berg
2023-08-28 11:59 ` [PATCH 18/40] wifi: mac80211: move TDLS " Johannes Berg
2023-08-28 11:59 ` [PATCH 19/40] wifi: mac80211: move key tailroom " Johannes Berg
2023-08-28 11:59 ` [PATCH 20/40] wifi: mac80211: move tspec " Johannes Berg
2023-08-28 11:59 ` [PATCH 21/40] wifi: mac80211: move filter reconfig " Johannes Berg
2023-08-28 11:59 ` [PATCH 22/40] wifi: mac80211: move CSA finalize " Johannes Berg
2023-08-28 11:59 ` [PATCH 23/40] wifi: mac80211: move color change " Johannes Berg
2023-08-28 11:59 ` [PATCH 24/40] wifi: mac80211: check wiphy mutex in ops Johannes Berg
2023-08-28 11:59 ` [PATCH 25/40] wifi: cfg80211: reg: hold wiphy mutex for wdev iteration Johannes Berg
2023-08-28 11:59 ` [PATCH 26/40] wifi: cfg80211: sme: hold wiphy lock " Johannes Berg
2023-08-28 11:59 ` [PATCH 27/40] wifi: cfg80211: hold wiphy lock in cfg80211_any_wiphy_oper_chan() Johannes Berg
2023-08-28 11:59 ` [PATCH 28/40] wifi: cfg80211: check wiphy mutex is held for wdev mutex Johannes Berg
2023-08-28 11:59 ` [PATCH 29/40] wifi: mac80211: ethtool: hold wiphy mutex Johannes Berg
2023-08-28 11:59 ` [PATCH 30/40] wifi: mac80211: hold wiphy_lock around concurrency checks Johannes Berg
2023-08-28 11:59 ` [PATCH 31/40] wifi: mac80211: extend wiphy lock in interface removal Johannes Berg
2023-08-28 12:00 ` [PATCH 32/40] wifi: mac80211: take wiphy lock for MAC addr change Johannes Berg
2023-08-28 12:00 ` [PATCH 33/40] wifi: mac80211: remove sta_mtx Johannes Berg
2023-08-28 12:00 ` [PATCH 34/40] wifi: mac80211: remove key_mtx Johannes Berg
2023-08-28 12:00 ` [PATCH 35/40] wifi: mac80211: remove chanctx_mtx Johannes Berg
2023-08-28 12:00 ` [PATCH 36/40] wifi: mac80211: remove ampdu_mlme.mtx Johannes Berg
2023-08-28 12:00 ` [PATCH 37/40] wifi: mac80211: remove local->mtx Johannes Berg
2023-08-28 12:00 ` [PATCH 38/40] wifi: mac80211: reduce iflist_mtx Johannes Berg
2023-08-28 12:00 ` [PATCH 39/40] wifi: mac80211: set wiphy for virtual monitors Johannes Berg
2023-08-28 12:00 ` [PATCH 40/40] wifi: cfg80211: remove wdev mutex Johannes Berg
2023-08-29 10:18   ` [PATCH v2 " Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230828135927.14c989da9ed2.I2c1a380b5d47b5b4122ff3f0ceb9d5c82d37f587@changeid \
    --to=johannes@sipsolutions.net \
    --cc=johannes.berg@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).