linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv3] wlcore: clean-up clearing of WL1271_FLAG_IRQ_RUNNING
@ 2019-10-09 16:50 Tony Lindgren
  2019-10-11  8:56 ` Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Tony Lindgren @ 2019-10-09 16:50 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Eyal Reizer, Kishon Vijay Abraham I, Guy Mishol, linux-wireless,
	linux-omap, Anders Roxell, John Stultz, Ulf Hansson

We set WL1271_FLAG_IRQ_RUNNING in the beginning of wlcore_irq(), but clear
it before interrupt handling is done in wlcore_irq_locked().

Let's move the clearing to the end of wlcore_irq() where it gets set,
and remove the old comments about hardirq. That's no longer the case as
we're using request_threaded_irq().

Note that the WL1271_FLAG_IRQ_RUNNING should never race between the
interrupt handler and wlcore_runtime_resume() as because of autosuspend
timeout we cannot enter idle between wlcore_irq_locked() and the end of
wlcore_irq().

Cc: Anders Roxell <anders.roxell@linaro.org>
Cc: Eyal Reizer <eyalr@ti.com>
Cc: Guy Mishol <guym@ti.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>

Changes since v2:

- Downgraded to clean-up from a fix as the race should never happen

Changes since v1:

- Add locking around clear_bit like we do elsewhere in the driver

---
 drivers/net/wireless/ti/wlcore/main.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 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
@@ -544,11 +544,6 @@ static int wlcore_irq_locked(struct wl1271 *wl)
 	}
 
 	while (!done && loopcount--) {
-		/*
-		 * In order to avoid a race with the hardirq, clear the flag
-		 * before acknowledging the chip.
-		 */
-		clear_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags);
 		smp_mb__after_atomic();
 
 		ret = wlcore_fw_status(wl, wl->fw_status);
@@ -668,7 +663,7 @@ static irqreturn_t wlcore_irq(int irq, void *cookie)
 		disable_irq_nosync(wl->irq);
 		pm_wakeup_event(wl->dev, 0);
 		spin_unlock_irqrestore(&wl->wl_lock, flags);
-		return IRQ_HANDLED;
+		goto out_handled;
 	}
 	spin_unlock_irqrestore(&wl->wl_lock, flags);
 
@@ -692,6 +687,11 @@ static irqreturn_t wlcore_irq(int irq, void *cookie)
 
 	mutex_unlock(&wl->mutex);
 
+out_handled:
+	spin_lock_irqsave(&wl->wl_lock, flags);
+	clear_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags);
+	spin_unlock_irqrestore(&wl->wl_lock, flags);
+
 	return IRQ_HANDLED;
 }
 
-- 
2.23.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCHv3] wlcore: clean-up clearing of WL1271_FLAG_IRQ_RUNNING
  2019-10-09 16:50 [PATCHv3] wlcore: clean-up clearing of WL1271_FLAG_IRQ_RUNNING Tony Lindgren
@ 2019-10-11  8:56 ` Kalle Valo
  0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2019-10-11  8:56 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Eyal Reizer, Kishon Vijay Abraham I, Guy Mishol, linux-wireless,
	linux-omap, Anders Roxell, John Stultz, Ulf Hansson

Tony Lindgren <tony@atomide.com> wrote:

> We set WL1271_FLAG_IRQ_RUNNING in the beginning of wlcore_irq(), but clear
> it before interrupt handling is done in wlcore_irq_locked().
> 
> Let's move the clearing to the end of wlcore_irq() where it gets set,
> and remove the old comments about hardirq. That's no longer the case as
> we're using request_threaded_irq().
> 
> Note that the WL1271_FLAG_IRQ_RUNNING should never race between the
> interrupt handler and wlcore_runtime_resume() as because of autosuspend
> timeout we cannot enter idle between wlcore_irq_locked() and the end of
> wlcore_irq().
> 
> Cc: Anders Roxell <anders.roxell@linaro.org>
> Cc: Eyal Reizer <eyalr@ti.com>
> Cc: Guy Mishol <guym@ti.com>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>

Patch applied to wireless-drivers-next.git, thanks.

4633d30b61ac wlcore: clean-up clearing of WL1271_FLAG_IRQ_RUNNING

-- 
https://patchwork.kernel.org/patch/11181621/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-11  8:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-09 16:50 [PATCHv3] wlcore: clean-up clearing of WL1271_FLAG_IRQ_RUNNING Tony Lindgren
2019-10-11  8:56 ` Kalle Valo

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).