From: "Jérôme Pouiller" <jerome.pouiller@silabs.com>
To: Kalle Valo <kvalo@kernel.org>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
"Jérôme Pouiller" <jerome.pouiller@silabs.com>
Subject: [PATCH 8/9] wifi: wfx: scan_lock is global to the device
Date: Mon, 7 Aug 2023 17:05:41 +0200 [thread overview]
Message-ID: <20230807150542.247801-9-jerome.pouiller@silabs.com> (raw)
In-Reply-To: <20230807150542.247801-1-jerome.pouiller@silabs.com>
Currently, one scan_lock is associated to each vif. However, concurrent
scan on vifs is explicitly prohibited by the device. Currently, scan_lock
is associated with conf_mutex that ensure that concurrent scan on vifs
cannot happen.
In the only case where conf_mutex is not associated to scan_lock, the
scan_lock is tested on all interfaces.
Short, this patch relocates scan_lock to the device and simplify the code.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
drivers/net/wireless/silabs/wfx/main.c | 2 ++
drivers/net/wireless/silabs/wfx/queue.c | 6 ++----
drivers/net/wireless/silabs/wfx/scan.c | 8 ++++----
drivers/net/wireless/silabs/wfx/sta.c | 15 ++++-----------
drivers/net/wireless/silabs/wfx/wfx.h | 3 +--
5 files changed, 13 insertions(+), 21 deletions(-)
diff --git a/drivers/net/wireless/silabs/wfx/main.c b/drivers/net/wireless/silabs/wfx/main.c
index a0906d7d026e0..32564f5c98e5c 100644
--- a/drivers/net/wireless/silabs/wfx/main.c
+++ b/drivers/net/wireless/silabs/wfx/main.c
@@ -248,6 +248,7 @@ static void wfx_free_common(void *data)
mutex_destroy(&wdev->tx_power_loop_info_lock);
mutex_destroy(&wdev->rx_stats_lock);
+ mutex_destroy(&wdev->scan_lock);
mutex_destroy(&wdev->conf_mutex);
ieee80211_free_hw(wdev->hw);
}
@@ -318,6 +319,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, const struct wfx_platform_da
gpiod_set_consumer_name(wdev->pdata.gpio_wakeup, "wfx wakeup");
mutex_init(&wdev->conf_mutex);
+ mutex_init(&wdev->scan_lock);
mutex_init(&wdev->rx_stats_lock);
mutex_init(&wdev->tx_power_loop_info_lock);
init_completion(&wdev->firmware_ready);
diff --git a/drivers/net/wireless/silabs/wfx/queue.c b/drivers/net/wireless/silabs/wfx/queue.c
index b5975d18f09b4..e61b86f211e53 100644
--- a/drivers/net/wireless/silabs/wfx/queue.c
+++ b/drivers/net/wireless/silabs/wfx/queue.c
@@ -267,10 +267,8 @@ static struct sk_buff *wfx_tx_queues_get_skb(struct wfx_dev *wdev)
}
}
- wvif = NULL;
- while ((wvif = wvif_iterate(wdev, wvif)) != NULL)
- if (mutex_is_locked(&wvif->scan_lock))
- return NULL;
+ if (mutex_is_locked(&wdev->scan_lock))
+ return NULL;
wvif = NULL;
while ((wvif = wvif_iterate(wdev, wvif)) != NULL) {
diff --git a/drivers/net/wireless/silabs/wfx/scan.c b/drivers/net/wireless/silabs/wfx/scan.c
index 817eeb3aa8bff..c3c103ff88cce 100644
--- a/drivers/net/wireless/silabs/wfx/scan.c
+++ b/drivers/net/wireless/silabs/wfx/scan.c
@@ -95,7 +95,7 @@ void wfx_hw_scan_work(struct work_struct *work)
int chan_cur, ret, err;
mutex_lock(&wvif->wdev->conf_mutex);
- mutex_lock(&wvif->scan_lock);
+ mutex_lock(&wvif->wdev->scan_lock);
if (wvif->join_in_progress) {
dev_info(wvif->wdev->dev, "abort in-progress REQ_JOIN");
wfx_reset(wvif);
@@ -116,7 +116,7 @@ void wfx_hw_scan_work(struct work_struct *work)
ret = -ETIMEDOUT;
}
} while (ret >= 0 && chan_cur < hw_req->req.n_channels);
- mutex_unlock(&wvif->scan_lock);
+ mutex_unlock(&wvif->wdev->scan_lock);
mutex_unlock(&wvif->wdev->conf_mutex);
wfx_ieee80211_scan_completed_compat(wvif->wdev->hw, ret < 0);
}
@@ -155,7 +155,7 @@ void wfx_remain_on_channel_work(struct work_struct *work)
/* Hijack scan request to implement Remain-On-Channel */
mutex_lock(&wvif->wdev->conf_mutex);
- mutex_lock(&wvif->scan_lock);
+ mutex_lock(&wvif->wdev->scan_lock);
if (wvif->join_in_progress) {
dev_info(wvif->wdev->dev, "abort in-progress REQ_JOIN");
wfx_reset(wvif);
@@ -178,7 +178,7 @@ void wfx_remain_on_channel_work(struct work_struct *work)
dev_err(wvif->wdev->dev, "roc didn't stop\n");
ieee80211_remain_on_channel_expired(wvif->wdev->hw);
end:
- mutex_unlock(&wvif->scan_lock);
+ mutex_unlock(&wvif->wdev->scan_lock);
mutex_unlock(&wvif->wdev->conf_mutex);
wfx_bh_request_tx(wvif->wdev);
}
diff --git a/drivers/net/wireless/silabs/wfx/sta.c b/drivers/net/wireless/silabs/wfx/sta.c
index f42341c2baffb..496b93de3ee58 100644
--- a/drivers/net/wireless/silabs/wfx/sta.c
+++ b/drivers/net/wireless/silabs/wfx/sta.c
@@ -97,9 +97,8 @@ void wfx_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags,
FIF_PROBE_REQ | FIF_PSPOLL;
mutex_lock(&wdev->conf_mutex);
+ mutex_lock(&wdev->scan_lock);
while ((wvif = wvif_iterate(wdev, wvif)) != NULL) {
- mutex_lock(&wvif->scan_lock);
-
/* Note: FIF_BCN_PRBRESP_PROMISC covers probe response and
* beacons from other BSS
*/
@@ -126,9 +125,8 @@ void wfx_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags,
else
filter_prbreq = true;
wfx_hif_set_rx_filter(wvif, filter_bssid, filter_prbreq);
-
- mutex_unlock(&wvif->scan_lock);
}
+ mutex_unlock(&wdev->scan_lock);
mutex_unlock(&wdev->conf_mutex);
}
@@ -621,18 +619,14 @@ int wfx_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, bool set)
void wfx_suspend_resume_mc(struct wfx_vif *wvif, enum sta_notify_cmd notify_cmd)
{
- struct wfx_vif *wvif_it;
-
if (notify_cmd != STA_NOTIFY_AWAKE)
return;
/* Device won't be able to honor CAB if a scan is in progress on any interface. Prefer to
* skip this DTIM and wait for the next one.
*/
- wvif_it = NULL;
- while ((wvif_it = wvif_iterate(wvif->wdev, wvif_it)) != NULL)
- if (mutex_is_locked(&wvif_it->scan_lock))
- return;
+ if (mutex_is_locked(&wvif->wdev->scan_lock))
+ return;
if (!wfx_tx_queues_has_cab(wvif) || wvif->after_dtim_tx_allowed)
dev_warn(wvif->wdev->dev, "incorrect sequence (%d CAB in queue)",
@@ -730,7 +724,6 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
complete(&wvif->set_pm_mode_complete);
INIT_WORK(&wvif->tx_policy_upload_work, wfx_tx_policy_upload_work);
- mutex_init(&wvif->scan_lock);
init_completion(&wvif->scan_complete);
INIT_WORK(&wvif->scan_work, wfx_hw_scan_work);
INIT_WORK(&wvif->remain_on_channel_work, wfx_remain_on_channel_work);
diff --git a/drivers/net/wireless/silabs/wfx/wfx.h b/drivers/net/wireless/silabs/wfx/wfx.h
index 5fd80c423d6f6..bd0df2e1ea990 100644
--- a/drivers/net/wireless/silabs/wfx/wfx.h
+++ b/drivers/net/wireless/silabs/wfx/wfx.h
@@ -43,6 +43,7 @@ struct wfx_dev {
struct delayed_work cooling_timeout_work;
bool poll_irq;
bool chip_frozen;
+ struct mutex scan_lock;
struct mutex conf_mutex;
struct wfx_hif_cmd hif_cmd;
@@ -81,8 +82,6 @@ struct wfx_vif {
unsigned long uapsd_mask;
- /* avoid some operations in parallel with scan */
- struct mutex scan_lock;
struct work_struct scan_work;
struct completion scan_complete;
int scan_nb_chan_done;
--
2.39.2
next prev parent reply other threads:[~2023-08-07 15:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-07 15:05 [PATCH 0/9] wfx: implement Remain On Channel Jérôme Pouiller
2023-08-07 15:05 ` [PATCH 1/9] wifi: wfx: fix power_save setting when AP is stopped Jérôme Pouiller
2023-08-07 15:05 ` [PATCH 2/9] wifi: wfx: relocate wfx_rate_mask_to_hw() Jérôme Pouiller
2023-08-07 15:05 ` [PATCH 3/9] wifi: wfx: move wfx_skb_*() out of the header file Jérôme Pouiller
2023-08-07 15:05 ` [PATCH 4/9] wifi: wfx: introduce hif_scan_uniq() Jérôme Pouiller
2023-08-07 15:05 ` [PATCH 5/9] wifi: wfx: add placeholders for remain_on_channel feature Jérôme Pouiller
2023-08-07 15:05 ` [PATCH 6/9] wifi: wfx: implement wfx_remain_on_channel() Jérôme Pouiller
2023-08-07 15:05 ` [PATCH 7/9] wifi: wfx: allow to send frames during ROC Jérôme Pouiller
2023-08-07 15:05 ` Jérôme Pouiller [this message]
2023-08-07 15:05 ` [PATCH 9/9] wifi: wfx: fix possible lock-up between scan and Rx filters Jérôme Pouiller
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=20230807150542.247801-9-jerome.pouiller@silabs.com \
--to=jerome.pouiller@silabs.com \
--cc=kvalo@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®