From: Tony Lindgren <tony@atomide.com>
To: Kalle Valo <kvalo@codeaurora.org>
Cc: Eyal Reizer <eyalr@ti.com>, Guy Mishol <guym@ti.com>,
linux-wireless@vger.kernel.org, linux-omap@vger.kernel.org
Subject: [PATCH 2/4] wlcore: Use spin_trylock in wlcore_irq_locked() for running the queue
Date: Thu, 2 Jul 2020 09:29:49 -0700 [thread overview]
Message-ID: <20200702162951.45392-3-tony@atomide.com> (raw)
In-Reply-To: <20200702162951.45392-1-tony@atomide.com>
We currently have a collection of flags and locking between the
threaded irq and tx work:
- wl->flags bitops
- wl->mutex
- wl->wl_lock spinlock
The bitops flags do not need a spinlock around them, and
wlcore_irq() already holds the mutex calling wlcore_irq_locked().
And we only need the spinlock to see if we need to run the queue
or not.
To simplify the locking, we can use spin_trylock and always run the
tx queue unless we know there's nothing to do.
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/net/wireless/ti/wlcore/main.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -521,6 +521,7 @@ static int wlcore_irq_locked(struct wl1271 *wl)
int ret = 0;
u32 intr;
int loopcount = WL1271_IRQ_MAX_LOOPS;
+ bool run_tx_queue = true;
bool done = false;
unsigned int defer_count;
unsigned long flags;
@@ -586,19 +587,22 @@ static int wlcore_irq_locked(struct wl1271 *wl)
goto err_ret;
/* Check if any tx blocks were freed */
- spin_lock_irqsave(&wl->wl_lock, flags);
- if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) &&
- wl1271_tx_total_queue_count(wl) > 0) {
- spin_unlock_irqrestore(&wl->wl_lock, flags);
+ if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags)) {
+ if (spin_trylock_irqsave(&wl->wl_lock, flags)) {
+ if (!wl1271_tx_total_queue_count(wl))
+ run_tx_queue = false;
+ spin_unlock_irqrestore(&wl->wl_lock, flags);
+ }
+
/*
* In order to avoid starvation of the TX path,
* call the work function directly.
*/
- ret = wlcore_tx_work_locked(wl);
- if (ret < 0)
- goto err_ret;
- } else {
- spin_unlock_irqrestore(&wl->wl_lock, flags);
+ if (run_tx_queue) {
+ ret = wlcore_tx_work_locked(wl);
+ if (ret < 0)
+ goto err_ret;
+ }
}
/* check for tx results */
--
2.27.0
next prev parent reply other threads:[~2020-07-02 16:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 16:29 [PATCHv2 0/4] Improvments for wlcore irq and resume for v5.9 Tony Lindgren
2020-07-02 16:29 ` [PATCH 1/4] wlcore: Simplify runtime resume ELP path Tony Lindgren
2020-07-15 9:12 ` Kalle Valo
2020-07-02 16:29 ` Tony Lindgren [this message]
2020-07-02 16:29 ` [PATCH 3/4] wlcore: Use spin_trylock in wlcore_irq() to see if we need to queue tx Tony Lindgren
2020-07-02 16:29 ` [PATCH 4/4] wlcore: Remove pointless spinlock Tony Lindgren
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=20200702162951.45392-3-tony@atomide.com \
--to=tony@atomide.com \
--cc=eyalr@ti.com \
--cc=guym@ti.com \
--cc=kvalo@codeaurora.org \
--cc=linux-omap@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;
as well as URLs for NNTP newsgroup(s).