wlcore: Use spin_trylock in wlcore_irq() to see if we need to queue tx
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 we only need the spinlock to see if we need to queue tx work or not. And wlcore_irq() holds the mutex. To simplify the locking, we can use spin_trylock and always queue tx work 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> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200702162951.45392-4-tony@atomide.com
This commit is contained in:
committed by
Kalle Valo
parent
f0325e38ab
commit
35fba0f0fd
@@ -652,6 +652,7 @@ static irqreturn_t wlcore_irq(int irq, void *cookie)
|
|||||||
int ret;
|
int ret;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct wl1271 *wl = cookie;
|
struct wl1271 *wl = cookie;
|
||||||
|
bool queue_tx_work = true;
|
||||||
|
|
||||||
set_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags);
|
set_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags);
|
||||||
|
|
||||||
@@ -684,13 +685,17 @@ static irqreturn_t wlcore_irq(int irq, void *cookie)
|
|||||||
if (ret)
|
if (ret)
|
||||||
wl12xx_queue_recovery_work(wl);
|
wl12xx_queue_recovery_work(wl);
|
||||||
|
|
||||||
spin_lock_irqsave(&wl->wl_lock, flags);
|
/* In case TX was not handled in wlcore_irq_locked(), queue TX work */
|
||||||
/* In case TX was not handled here, queue TX work */
|
|
||||||
clear_bit(WL1271_FLAG_TX_PENDING, &wl->flags);
|
clear_bit(WL1271_FLAG_TX_PENDING, &wl->flags);
|
||||||
if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) &&
|
if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags)) {
|
||||||
wl1271_tx_total_queue_count(wl) > 0)
|
if (spin_trylock_irqsave(&wl->wl_lock, flags)) {
|
||||||
ieee80211_queue_work(wl->hw, &wl->tx_work);
|
if (!wl1271_tx_total_queue_count(wl))
|
||||||
spin_unlock_irqrestore(&wl->wl_lock, flags);
|
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);
|
mutex_unlock(&wl->mutex);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user