diff mbox series

[2/4] wlcore: Use spin_trylock in wlcore_irq() to see if we need to queue tx

Message ID 20200617212505.62519-3-tony@atomide.com (mailing list archive)
State New, archived
Headers show
Series Improvments for wlcore irq and resume for v5.9 | expand

Commit Message

Tony Lindgren June 17, 2020, 9:25 p.m. UTC
We need the spinlock to check if we need to queue tx in wlcore_irq().
Let's use spin_trylock instead and always queue tx unless we know there's
nothing to do.

Let's also update the comment a bit while at it.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/net/wireless/ti/wlcore/main.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

Comments

Kalle Valo June 22, 2020, 2:16 p.m. UTC | #1
Tony Lindgren <tony@atomide.com> writes:

> We need the spinlock to check if we need to queue tx in wlcore_irq().
> Let's use spin_trylock instead and always queue tx unless we know there's
> nothing to do.
>
> Let's also update the comment a bit while at it.
>
> Signed-off-by: Tony Lindgren <tony@atomide.com>

Same question as in patch 1, the background for this is not clear.
diff mbox series

Patch

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
@@ -652,6 +652,7 @@  static irqreturn_t wlcore_irq(int irq, void *cookie)
 	int ret;
 	unsigned long flags;
 	struct wl1271 *wl = cookie;
+	bool queue_tx_work = true;
 
 	/* complete the ELP completion */
 	spin_lock_irqsave(&wl->wl_lock, flags);
@@ -682,13 +683,17 @@  static irqreturn_t wlcore_irq(int irq, void *cookie)
 	if (ret)
 		wl12xx_queue_recovery_work(wl);
 
-	spin_lock_irqsave(&wl->wl_lock, flags);
-	/* In case TX was not handled here, queue TX work */
+	/* In case TX was not handled in wlcore_irq_locked(), queue TX work */
 	clear_bit(WL1271_FLAG_TX_PENDING, &wl->flags);
-	if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) &&
-	    wl1271_tx_total_queue_count(wl) > 0)
-		ieee80211_queue_work(wl->hw, &wl->tx_work);
-	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))
+				queue_tx_work = false;
+			spin_unlock_irqrestore(&wl->wl_lock, flags);
+		}
+		if (queue_tx_work)
+			ieee80211_queue_work(wl->hw, &wl->tx_work);
+	}
 
 	mutex_unlock(&wl->mutex);