* [PATCH 0/2] brcmfmac: resolve atomic_set_mask() issues
@ 2014-03-06 9:16 Arend van Spriel
2014-03-06 9:16 ` [PATCH 1/2] Revert "brcmfmac: Use atomic functions for intstatus update." Arend van Spriel
2014-03-06 9:16 ` [PATCH 2/2] brcmfmac: Use atomic functions for intstatus update Arend van Spriel
0 siblings, 2 replies; 3+ messages in thread
From: Arend van Spriel @ 2014-03-06 9:16 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless, Arend van Spriel
Tiny series resolving build issues on several platforms as reported
by Fengguang Wu and Stephen Rothwell.
These patches apply to the master branch of the wireless-next
repository.
Arend van Spriel (1):
Revert "brcmfmac: Use atomic functions for intstatus update."
Hante Meuleman (1):
brcmfmac: Use atomic functions for intstatus update.
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
--
1.7.10.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] Revert "brcmfmac: Use atomic functions for intstatus update."
2014-03-06 9:16 [PATCH 0/2] brcmfmac: resolve atomic_set_mask() issues Arend van Spriel
@ 2014-03-06 9:16 ` Arend van Spriel
2014-03-06 9:16 ` [PATCH 2/2] brcmfmac: Use atomic functions for intstatus update Arend van Spriel
1 sibling, 0 replies; 3+ messages in thread
From: Arend van Spriel @ 2014-03-06 9:16 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless, Arend van Spriel
This reverts commit c98db0bec72ac7ef127119c1ed962d6f56802b12.
The function atomic_set_mask() is not architecture independent
so it can not be used in the driver as is.
Signed-off-by: Arend van Spriel <arend@broadcom.com>
---
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index 5c2706e..70bab5e 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -2444,7 +2444,7 @@ static int brcmf_sdio_intr_rstatus(struct brcmf_sdio *bus)
struct brcmf_core *buscore;
u32 addr;
unsigned long val;
- int ret;
+ int n, ret;
buscore = brcmf_chip_get_core(bus->ci, BCMA_CORE_SDIO_DEV);
addr = buscore->base + offsetof(struct sdpcmd_regs, intstatus);
@@ -2452,7 +2452,7 @@ static int brcmf_sdio_intr_rstatus(struct brcmf_sdio *bus)
val = brcmf_sdiod_regrl(bus->sdiodev, addr, &ret);
bus->sdcnt.f1regdata++;
if (ret != 0)
- return ret;
+ val = 0;
val &= bus->hostintmask;
atomic_set(&bus->fcstate, !!(val & I_HMB_FC_STATE));
@@ -2461,7 +2461,13 @@ static int brcmf_sdio_intr_rstatus(struct brcmf_sdio *bus)
if (val) {
brcmf_sdiod_regwl(bus->sdiodev, addr, val, &ret);
bus->sdcnt.f1regdata++;
- atomic_set_mask(val, &bus->intstatus);
+ }
+
+ if (ret) {
+ atomic_set(&bus->intstatus, 0);
+ } else if (val) {
+ for_each_set_bit(n, &val, 32)
+ set_bit(n, (unsigned long *)&bus->intstatus.counter);
}
return ret;
@@ -2473,7 +2479,7 @@ static void brcmf_sdio_dpc(struct brcmf_sdio *bus)
unsigned long intstatus;
uint txlimit = bus->txbound; /* Tx frames to send before resched */
uint framecnt; /* Temporary counter of tx/rx frames */
- int err = 0;
+ int err = 0, n;
brcmf_dbg(TRACE, "Enter\n");
@@ -2577,8 +2583,10 @@ static void brcmf_sdio_dpc(struct brcmf_sdio *bus)
}
/* Keep still-pending events for next scheduling */
- if (intstatus)
- atomic_set_mask(intstatus, &bus->intstatus);
+ if (intstatus) {
+ for_each_set_bit(n, &intstatus, 32)
+ set_bit(n, (unsigned long *)&bus->intstatus.counter);
+ }
brcmf_sdio_clrintr(bus);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] brcmfmac: Use atomic functions for intstatus update.
2014-03-06 9:16 [PATCH 0/2] brcmfmac: resolve atomic_set_mask() issues Arend van Spriel
2014-03-06 9:16 ` [PATCH 1/2] Revert "brcmfmac: Use atomic functions for intstatus update." Arend van Spriel
@ 2014-03-06 9:16 ` Arend van Spriel
1 sibling, 0 replies; 3+ messages in thread
From: Arend van Spriel @ 2014-03-06 9:16 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless, Hante Meuleman, Arend van Spriel
From: Hante Meuleman <meuleman@broadcom.com>
The intstatus in sdio code can be updated from different
threads. To protect intstatus access, atomic functions are
used. One of them is set_bit, but this function is not
guaranteed atomic on all platforms. The loop was replaced
with local created OR function.
Reviewed-by: Arend Van Spriel <arend@broadcom.com>
Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: Daniel (Deognyoun) Kim <dekim@broadcom.com>
Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
---
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 29 ++++++++++----------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index 70bab5e..a111b6f 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -2439,12 +2439,21 @@ static inline void brcmf_sdio_clrintr(struct brcmf_sdio *bus)
}
}
+static void atomic_orr(int val, atomic_t *v)
+{
+ int old_val;
+
+ old_val = atomic_read(v);
+ while (atomic_cmpxchg(v, old_val, val | old_val) != old_val)
+ old_val = atomic_read(v);
+}
+
static int brcmf_sdio_intr_rstatus(struct brcmf_sdio *bus)
{
struct brcmf_core *buscore;
u32 addr;
unsigned long val;
- int n, ret;
+ int ret;
buscore = brcmf_chip_get_core(bus->ci, BCMA_CORE_SDIO_DEV);
addr = buscore->base + offsetof(struct sdpcmd_regs, intstatus);
@@ -2452,7 +2461,7 @@ static int brcmf_sdio_intr_rstatus(struct brcmf_sdio *bus)
val = brcmf_sdiod_regrl(bus->sdiodev, addr, &ret);
bus->sdcnt.f1regdata++;
if (ret != 0)
- val = 0;
+ return ret;
val &= bus->hostintmask;
atomic_set(&bus->fcstate, !!(val & I_HMB_FC_STATE));
@@ -2461,13 +2470,7 @@ static int brcmf_sdio_intr_rstatus(struct brcmf_sdio *bus)
if (val) {
brcmf_sdiod_regwl(bus->sdiodev, addr, val, &ret);
bus->sdcnt.f1regdata++;
- }
-
- if (ret) {
- atomic_set(&bus->intstatus, 0);
- } else if (val) {
- for_each_set_bit(n, &val, 32)
- set_bit(n, (unsigned long *)&bus->intstatus.counter);
+ atomic_orr(val, &bus->intstatus);
}
return ret;
@@ -2479,7 +2482,7 @@ static void brcmf_sdio_dpc(struct brcmf_sdio *bus)
unsigned long intstatus;
uint txlimit = bus->txbound; /* Tx frames to send before resched */
uint framecnt; /* Temporary counter of tx/rx frames */
- int err = 0, n;
+ int err = 0;
brcmf_dbg(TRACE, "Enter\n");
@@ -2583,10 +2586,8 @@ static void brcmf_sdio_dpc(struct brcmf_sdio *bus)
}
/* Keep still-pending events for next scheduling */
- if (intstatus) {
- for_each_set_bit(n, &intstatus, 32)
- set_bit(n, (unsigned long *)&bus->intstatus.counter);
- }
+ if (intstatus)
+ atomic_orr(intstatus, &bus->intstatus);
brcmf_sdio_clrintr(bus);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-03-06 9:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-06 9:16 [PATCH 0/2] brcmfmac: resolve atomic_set_mask() issues Arend van Spriel
2014-03-06 9:16 ` [PATCH 1/2] Revert "brcmfmac: Use atomic functions for intstatus update." Arend van Spriel
2014-03-06 9:16 ` [PATCH 2/2] brcmfmac: Use atomic functions for intstatus update Arend van Spriel
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).