diff mbox series

[v2,11/50] wilc1000: convert tqx_entries from "int" to "atomic_t"

Message ID 20211223011358.4031459-12-davidm@egauge.net
State New
Headers show
Series wilc1000: rework tx path to use sk_buffs throughout | expand

Commit Message

David Mosberger-Tang Dec. 23, 2021, 1:14 a.m. UTC
This is in preparation of converting the tx queue to struct sk_buffs
entries.  atomic_t isn't necessary for the current code, but it is a
safe change.

Signed-off-by: David Mosberger-Tang <davidm@egauge.net>
---
 drivers/net/wireless/microchip/wilc1000/netdev.c |  3 ++-
 drivers/net/wireless/microchip/wilc1000/netdev.h |  2 +-
 drivers/net/wireless/microchip/wilc1000/wlan.c   | 12 ++++++------
 3 files changed, 9 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c
index d5969f2e369c4..486091a4cb993 100644
--- a/drivers/net/wireless/microchip/wilc1000/netdev.c
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.c
@@ -149,7 +149,8 @@  static int wilc_txq_task(void *vp)
 	complete(&wl->txq_thread_started);
 	while (1) {
 		wait_event_interruptible(wl->txq_event,
-					 (wl->txq_entries > 0 || wl->close));
+					 (atomic_read(&wl->txq_entries) > 0 ||
+					  wl->close));
 
 		if (wl->close) {
 			complete(&wl->txq_thread_started);
diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h
index d88fee8f9a6b0..60f4871a7d579 100644
--- a/drivers/net/wireless/microchip/wilc1000/netdev.h
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.h
@@ -255,7 +255,7 @@  struct wilc {
 	u8 *tx_buffer;
 
 	struct txq_handle txq[NQUEUES];
-	int txq_entries;
+	atomic_t txq_entries;
 	struct txq_fw_recv_queue_stat fw[NQUEUES];
 
 	struct wilc_tx_queue_status tx_q_limit;
diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
index 781c40f2c930c..26b7d219ecbbb 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.c
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -41,7 +41,7 @@  static void wilc_wlan_txq_remove(struct wilc *wilc, u8 q_num,
 				 struct txq_entry_t *tqe)
 {
 	list_del(&tqe->list);
-	wilc->txq_entries -= 1;
+	atomic_dec(&wilc->txq_entries);
 	wilc->txq[q_num].count--;
 }
 
@@ -57,7 +57,7 @@  wilc_wlan_txq_remove_from_head(struct wilc *wilc, u8 q_num)
 		tqe = list_first_entry(&wilc->txq[q_num].txq_head.list,
 				       struct txq_entry_t, list);
 		list_del(&tqe->list);
-		wilc->txq_entries -= 1;
+		atomic_dec(&wilc->txq_entries);
 		wilc->txq[q_num].count--;
 	}
 	spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
@@ -87,7 +87,7 @@  static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 type, u8 q_num,
 	spin_lock_irqsave(&wilc->txq_spinlock, flags);
 
 	list_add_tail(&tqe->list, &wilc->txq[q_num].txq_head.list);
-	wilc->txq_entries += 1;
+	atomic_inc(&wilc->txq_entries);
 	wilc->txq[q_num].count++;
 
 	spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
@@ -108,7 +108,7 @@  static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 type, u8 q_num,
 	spin_lock_irqsave(&wilc->txq_spinlock, flags);
 
 	list_add(&tqe->list, &wilc->txq[q_num].txq_head.list);
-	wilc->txq_entries += 1;
+	atomic_inc(&wilc->txq_entries);
 	wilc->txq[q_num].count++;
 
 	spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
@@ -484,7 +484,7 @@  int wilc_wlan_txq_add_net_pkt(struct net_device *dev,
 		kfree(tqe);
 	}
 
-	return wilc->txq_entries;
+	return atomic_read(&wilc->txq_entries);
 }
 
 int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer,
@@ -952,7 +952,7 @@  int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
 	mutex_unlock(&wilc->txq_add_to_head_cs);
 
 out_update_cnt:
-	*txq_count = wilc->txq_entries;
+	*txq_count = atomic_read(&wilc->txq_entries);
 	return ret;
 }