linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Arend van Spriel" <arend@broadcom.com>
To: "John W. Linville" <linville@tuxdriver.com>
Cc: "Linux Wireless List" <linux-wireless@vger.kernel.org>,
	"Franky Lin" <frankyl@broadcom.com>,
	"Arend van Spriel" <arend@broadcom.com>
Subject: [PATCH 03/10] brcmfmac: use atomic variable for interrupt pending flag
Date: Thu, 13 Sep 2012 21:11:59 +0200	[thread overview]
Message-ID: <1347563526-12513-4-git-send-email-arend@broadcom.com> (raw)
In-Reply-To: <1347563526-12513-1-git-send-email-arend@broadcom.com>

From: Franky Lin <frankyl@broadcom.com>

Interrupt pending flag used in SDIO bus layer could be used in
multiple processes in different context. Use atomic_t make sure
every interrupt is handled.

Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Franky Lin <frankyl@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index 2ca9e8c..b0794e8 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -531,7 +531,7 @@ struct brcmf_sdio {
 
 	bool intr;		/* Use interrupts */
 	bool poll;		/* Use polling */
-	bool ipend;		/* Device interrupt is pending */
+	atomic_t ipend;		/* Device interrupt is pending */
 	uint spurious;		/* Count of spurious interrupts */
 	uint pollrate;		/* Ticks between device polls */
 	uint polltick;		/* Tick counter */
@@ -2151,7 +2151,7 @@ static uint brcmf_sdbrcm_sendfromq(struct brcmf_sdio *bus, uint maxframes)
 			if (ret != 0)
 				break;
 			if (intstatus & bus->hostintmask)
-				bus->ipend = true;
+				atomic_set(&bus->ipend, 1);
 		}
 	}
 
@@ -2249,7 +2249,7 @@ static inline void brcmf_sdbrcm_clrintr(struct brcmf_sdio *bus)
 	unsigned long flags;
 
 	spin_lock_irqsave(&bus->sdiodev->irq_en_lock, flags);
-	if (!bus->sdiodev->irq_en && !bus->ipend) {
+	if (!bus->sdiodev->irq_en && !atomic_read(&bus->ipend)) {
 		enable_irq(bus->sdiodev->irq);
 		bus->sdiodev->irq_en = true;
 	}
@@ -2332,8 +2332,8 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus)
 		goto clkwait;
 
 	/* Pending interrupt indicates new device status */
-	if (bus->ipend) {
-		bus->ipend = false;
+	if (atomic_read(&bus->ipend) > 0) {
+		atomic_set(&bus->ipend, 0);
 		err = r_sdreg32(bus, &newstatus,
 				offsetof(struct sdpcmd_regs, intstatus));
 		bus->sdcnt.f1regdata++;
@@ -2478,7 +2478,7 @@ clkwait:
 	} else if (bus->clkstate == CLK_PENDING) {
 		brcmf_dbg(INFO, "rescheduled due to CLK_PENDING awaiting I_CHIPACTIVE interrupt\n");
 		resched = true;
-	} else if (bus->intstatus || bus->ipend ||
+	} else if (bus->intstatus || atomic_read(&bus->ipend) > 0 ||
 		(!bus->fcstate && brcmu_pktq_mlen(&bus->txq, ~bus->flowcontrol)
 		 && data_ok(bus)) || PKT_AVAILABLE()) {
 		resched = true;
@@ -3692,7 +3692,7 @@ void brcmf_sdbrcm_isr(void *arg)
 	}
 	/* Count the interrupt call */
 	bus->sdcnt.intrcount++;
-	bus->ipend = true;
+	atomic_set(&bus->ipend, 1);
 
 	/* Disable additional interrupts (is this needed now)? */
 	if (!bus->intr)
@@ -3740,7 +3740,7 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus)
 				 schedule the DPC */
 			if (intstatus) {
 				bus->sdcnt.pollcnt++;
-				bus->ipend = true;
+				atomic_set(&bus->ipend, 1);
 
 				bus->dpc_sched = true;
 				if (bus->dpc_tsk) {
@@ -3784,7 +3784,7 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus)
 
 	up(&bus->sdsem);
 
-	return bus->ipend;
+	return (atomic_read(&bus->ipend) > 0);
 }
 
 static bool brcmf_sdbrcm_chipmatch(u16 chipid)
-- 
1.7.9.5



  parent reply	other threads:[~2012-09-13 19:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-13 19:11 [PATCH 00/10] brcmfmac: sdio dpc restructuring and cleanup Arend van Spriel
2012-09-13 19:11 ` [PATCH 01/10] brcmfmac: absorb brcmf_sendpkt into brcmf_netdev_start_xmit Arend van Spriel
2012-09-13 19:11 ` [PATCH 02/10] brcmfmac: remove obsolete sdio bus sleep mechanism Arend van Spriel
2012-09-13 19:11 ` Arend van Spriel [this message]
2012-09-13 19:12 ` [PATCH 04/10] brcmfmac: convert SDIO dpc implementation to workqueue Arend van Spriel
2012-09-13 19:12 ` [PATCH 05/10] brcmfmac: streamline SDIO dpc Arend van Spriel
2012-09-13 19:12 ` [PATCH 06/10] brcmfmac: raise SDIO host lock to higher level Arend van Spriel
2012-09-13 19:12 ` [PATCH 07/10] brcmfmac: clear status for in-band interrupt in brcmf_sdbrcm_isr Arend van Spriel
2012-09-14 21:53   ` Stephen Warren
2012-09-15  9:19     ` Arend van Spriel
2012-09-15 17:12       ` Stephen Warren
2012-09-17 17:37         ` Stephen Warren
2012-09-13 19:12 ` [PATCH 08/10] brcmfmac: fix bug causing errorneous free on exception Arend van Spriel
2012-09-13 19:12 ` [PATCH 09/10] brcmfmac: add parameter check in brcmf_c_mkiovar() Arend van Spriel
2012-09-13 19:12 ` [PATCH 10/10] brcmfmac: simplify handling e-scan result firmware event Arend van Spriel

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=1347563526-12513-4-git-send-email-arend@broadcom.com \
    --to=arend@broadcom.com \
    --cc=frankyl@broadcom.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /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).