Skip to content

atomic_or() related changes

Vineet Gupta linux-arch linux-wireless lkml netdev 1 version Applied

Status from this message: Thanks, applied to wireless-drivers-next.git.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 14 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/3asm-generic/atomic.h: ARCH_HAS_ATOMIC_OR -> CONFIG_ARCH_HAS_ATOMIC_ORinclude/asm-generic/atomic.h include/linux/atomic.h+3 -30 replies
2/3brcmfmac: dhd_sdio.c: use existing atomic_or primitivedrivers/net/wireless/brcm80211/brcmfmac/sdio.c+2 -1111 replies
3/3ARC: provide atomic_or() and define ARCH_HAS_ATOMIC_ORarch/arc/include/asm/atomic.h+9 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] atomic_or() related changes

Hi,

This started off as an effort to convert a cmpxchg based loop in arc/kernel/smp.c to an API which is more LLOCK/SCOND friendly.

e.g.

        do {
                new = old = ACCESS_ONCE(*ipi_data_ptr);
                new |= 1U << msg;
        } while (cmpxchg(ipi_data_ptr, old, new) != old);

The generated code is horrible. There are 2 useless branches here and a LD/LLOCK to same address all inside a loop.

8015cefc:	ld_s       r2,[r3,0]
8015cefe:	or         r5,r2,r1
8015cf02:	llock      r4,[r3]
8015cf06:	brne       r4,r2,8015cf12
8015cf0a:	scond      r5,[r3]
8015cf0e:	bnz        8015cf02
8015cf12:	brne       r2,r4,8015cefc

An atomic_or() kind of API is better suited to generate something like below

8015cf02:	llock      r4,[r3]
8015cf06:	or         r5,r2,r1
8015cf0a:	scond      r5,[r3]
8015cf0e:	bnz        8015cf02

Although this doesn't work for the specific instance I wanted to fix as ipi_data_ptr is not atomic_t, I did run into a few things which could be improved, hence this series.

Compile tested on ARC, ARM, x86.

I do have some concern about mixing long and int on 64 bit arch, which I've captured inline in patch 2/3. It is most likely a lack of understand on my part, but worth asking..

Thx,
-Vineet

Vineet Gupta (3):
asm-generic/atomic.h: ARCH_HAS_ATOMIC_OR -> CONFIG_ARCH_HAS_ATOMIC_OR
brcmfmac: dhd_sdio.c: use existing atomic_or primitive
ARC: provide atomic_or() and define ARCH_HAS_ATOMIC_OR

 arch/arc/include/asm/atomic.h                  |  9 +++++++++
 drivers/net/wireless/brcm80211/brcmfmac/sdio.c | 13 ++-----------
 include/asm-generic/atomic.h                   |  2 +-
 include/linux/atomic.h                         |  4 ++--
 4 files changed, 14 insertions(+), 14 deletions(-)
Signature · 1 line
1.9.1