linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Mosberger-Tang <davidm@egauge.net>
To: Ajay Singh <ajay.kathat@microchip.com>
Cc: Claudiu Beznea <claudiu.beznea@microchip.com>,
	Kalle Valo <kvalo@codeaurora.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	David Mosberger-Tang <davidm@egauge.net>
Subject: [PATCH 01/23] wilc1000: don't hold txq_spinlock while initializing AC queue limits
Date: Sat, 18 Dec 2021 23:54:16 +0000 (UTC)	[thread overview]
Message-ID: <20211218235404.3963475-2-davidm@egauge.net> (raw)
In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net>

The wilc_tx_queue_status queue is relatively large and there is
absolutely no need to initialize it while holding a spinlock.

Signed-off-by: David Mosberger-Tang <davidm@egauge.net>
---
 .../net/wireless/microchip/wilc1000/netdev.h  |  1 -
 .../net/wireless/microchip/wilc1000/wlan.c    | 32 +++++++++++--------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h
index b9a88b3e322f1..fd0cb01e538a2 100644
--- a/drivers/net/wireless/microchip/wilc1000/netdev.h
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.h
@@ -202,7 +202,6 @@ struct wilc_tx_queue_status {
 	u16 end_index;
 	u16 cnt[NQUEUES];
 	u16 sum;
-	bool initialized;
 };
 
 struct wilc {
diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
index 1aa4236a2fe41..721e6131125e8 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.c
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -12,6 +12,8 @@
 
 #define WAKE_UP_TRIAL_RETRY		10000
 
+static const u8 factors[NQUEUES] = {1, 1, 1, 1};
+
 static inline bool is_wilc1000(u32 id)
 {
 	return (id & (~WILC_CHIP_REV_FIELD)) == WILC_1000_BASE_ID;
@@ -283,10 +285,23 @@ static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, u8 *buffer,
 	return 1;
 }
 
+static void init_q_limits(struct wilc *wl)
+{
+	struct wilc_tx_queue_status *q = &wl->tx_q_limit;
+	int i;
+
+	for (i = 0; i < AC_BUFFER_SIZE; i++)
+		q->buffer[i] = i % NQUEUES;
+
+	for (i = 0; i < NQUEUES; i++) {
+		q->cnt[i] = AC_BUFFER_SIZE * factors[i] / NQUEUES;
+		q->sum += q->cnt[i];
+	}
+	q->end_index = AC_BUFFER_SIZE - 1;
+}
+
 static bool is_ac_q_limit(struct wilc *wl, u8 q_num)
 {
-	u8 factors[NQUEUES] = {1, 1, 1, 1};
-	u16 i;
 	unsigned long flags;
 	struct wilc_tx_queue_status *q = &wl->tx_q_limit;
 	u8 end_index;
@@ -294,17 +309,6 @@ static bool is_ac_q_limit(struct wilc *wl, u8 q_num)
 	bool ret = false;
 
 	spin_lock_irqsave(&wl->txq_spinlock, flags);
-	if (!q->initialized) {
-		for (i = 0; i < AC_BUFFER_SIZE; i++)
-			q->buffer[i] = i % NQUEUES;
-
-		for (i = 0; i < NQUEUES; i++) {
-			q->cnt[i] = AC_BUFFER_SIZE * factors[i] / NQUEUES;
-			q->sum += q->cnt[i];
-		}
-		q->end_index = AC_BUFFER_SIZE - 1;
-		q->initialized = 1;
-	}
 
 	end_index = q->end_index;
 	q->cnt[q->buffer[end_index]] -= factors[q->buffer[end_index]];
@@ -1485,6 +1489,8 @@ int wilc_wlan_init(struct net_device *dev)
 		goto fail;
 	}
 
+	init_q_limits(wilc);
+
 	if (!wilc->tx_buffer)
 		wilc->tx_buffer = kmalloc(WILC_TX_BUFF_SIZE, GFP_KERNEL);
 
-- 
2.25.1


  parent reply	other threads:[~2021-12-18 23:54 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-18 23:54 [PATCH 00/23] wilc1000: rework tx path to use sk_buffs throughout David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 02/23] wilc1000: switch txq_event from completion to waitqueue David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 03/23] wilc1000: move receive-queue stats from txq to wilc structure David Mosberger-Tang
2021-12-18 23:54 ` David Mosberger-Tang [this message]
2021-12-18 23:54 ` [PATCH 05/23] wilc1000: add wilc_wlan_tx_packet_done() function David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 07/23] wilc1000: increment tx_dropped stat counter on tx packet drop David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 06/23] wilc1000: move tx packet drop code into its own function David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 04/23] wilc1000: factor common code in wilc_wlan_cfg_set() and wilc_wlan_cfg_get() David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 19/23] wilc1000: don't tell the chip to go to sleep while copying tx packets David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 11/23] wilc1000: convert tqx_entries from "int" to "atomic_t" David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 17/23] wilc1000: remove no longer used "vif" argument from init_txq_entry() David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 22/23] wilc1000: minor syntax cleanup David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 16/23] wilc1000: switch tx queue to normal sk_buff entries David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 18/23] wilc1000: split huge tx handler into subfunctions David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 21/23] wilc1000: declare read-only ac_preserve_ratio as static and const David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 14/23] wilc1000: if there is no tx packet, don't increment packets-sent counter David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 09/23] wilc1000: prepare wilc_wlan_tx_packet_done() for sk_buff changes David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 23/23] wilc1000: introduce symbolic names for two tx-related control bits David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 13/23] wilc1000: sanitize config packet sequence number management a bit David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 12/23] wilc1000: refactor wilc_wlan_cfg_commit() " David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 08/23] wilc1000: fix management packet type inconsistency David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 10/23] wilc1000: factor initialization of tx queue-specific packet fields David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 20/23] wilc1000: eliminate "max_size_over" variable in fill_vmm_table David Mosberger-Tang
2021-12-18 23:54 ` [PATCH 15/23] wilc1000: Add struct wilc_skb_tx_cb as an alias of struct txq_entry_t David Mosberger-Tang

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=20211218235404.3963475-2-davidm@egauge.net \
    --to=davidm@egauge.net \
    --cc=ajay.kathat@microchip.com \
    --cc=claudiu.beznea@microchip.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@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).