diff mbox series

[1/4] wifi: wilc1000: split deeply nested RCU list traversal in dedicated helper

Message ID 20240215-wilc_fix_rcu_usage-v1-1-f610e46c6f82@bootlin.com (mailing list archive)
State Accepted
Commit 5d2dbccc2b3cec2db5af6b7305ca144b35200024
Delegated to: Kalle Valo
Headers show
Series wifi: wilc1000: fix RCU usage | expand

Commit Message

Alexis Lothoré Feb. 15, 2024, 3:36 p.m. UTC
Move netif_wake_queue and its surrounding RCU operations in a dedicated
function to clarify wilc_txq_task and ease refactoring

Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
---
 drivers/net/wireless/microchip/wilc1000/netdev.c | 25 +++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

Comments

Kalle Valo Feb. 19, 2024, 4:21 p.m. UTC | #1
Alexis Lothoré <alexis.lothore@bootlin.com> wrote:

> Move netif_wake_queue and its surrounding RCU operations in a dedicated
> function to clarify wilc_txq_task and ease refactoring
> 
> Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>

4 patches applied to wireless-next.git, thanks.

5d2dbccc2b3c wifi: wilc1000: split deeply nested RCU list traversal in dedicated helper
059d0e3876ab wifi: wilc1000: use SRCU instead of RCU for vif list traversal
51e4aa8c449b wifi: wilc1000: fix declarations ordering
dd66185c23f7 wifi: wilc1000: add missing read critical sections around vif list traversal
diff mbox series

Patch

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c
index 22f461f477f1..62414ab8846e 100644
--- a/drivers/net/wireless/microchip/wilc1000/netdev.c
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.c
@@ -140,6 +140,19 @@  int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc)
 	return ret_val;
 }
 
+static void wilc_wake_tx_queues(struct wilc *wl)
+{
+	int srcu_idx;
+	struct wilc_vif *ifc;
+
+	srcu_idx = srcu_read_lock(&wl->srcu);
+	list_for_each_entry_rcu(ifc, &wl->vif_list, list) {
+		if (ifc->mac_opened && netif_queue_stopped(ifc->ndev))
+			netif_wake_queue(ifc->ndev);
+	}
+	srcu_read_unlock(&wl->srcu, srcu_idx);
+}
+
 static int wilc_txq_task(void *vp)
 {
 	int ret;
@@ -160,17 +173,7 @@  static int wilc_txq_task(void *vp)
 		do {
 			ret = wilc_wlan_handle_txq(wl, &txq_count);
 			if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD) {
-				int srcu_idx;
-				struct wilc_vif *ifc;
-
-				srcu_idx = srcu_read_lock(&wl->srcu);
-				list_for_each_entry_rcu(ifc, &wl->vif_list,
-							list) {
-					if (ifc->mac_opened &&
-					    netif_queue_stopped(ifc->ndev))
-						netif_wake_queue(ifc->ndev);
-				}
-				srcu_read_unlock(&wl->srcu, srcu_idx);
+				wilc_wake_tx_queues(wl);
 			}
 			if (ret != WILC_VMM_ENTRY_FULL_RETRY)
 				break;