Skip to contentSkip to conversation

ARM: Add atomic64 routines for ARMv6k and above.

PATCH New Will Deacon 5 participants 6 messages Dec 11, 2009 – Jan 8, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: Add atomic64 routines for ARMv6k and above.

In preparation for perf-events support, ARM needs to support atomic64_t operations. v6k and above support the ldrexd and strexd instructions to do just that.

This patch adds atomic64 support to the ARM architecture. v6k and above make use of new instructions whilst older cores fall back on the generic solution using spinlocks. If and when v7-M cores are supported by Linux, they will need to fall back on the spinlock implementation too.

---
 arch/arm/Kconfig              |    1 +
 arch/arm/include/asm/atomic.h |  228 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 229 insertions(+), 0 deletions(-)
arch/arm/Kconfig +1 -0
index 1c4119c..5fdc032 100644
@@ -18,6 +18,7 @@ config ARM
 	select HAVE_KRETPROBES if (HAVE_KPROBES)
 	select HAVE_FUNCTION_TRACER if (!XIP_KERNEL)
 	select HAVE_GENERIC_DMA_COHERENT
+	select GENERIC_ATOMIC64 if (!CPU_32v6K)
 	help
 	  The ARM series is a line of low-power-consumption RISC chip designs
 	  licensed by ARM Ltd and targeted at embedded applications and
arch/arm/include/asm/atomic.h +228 -0

234 lines not on this page · raw message

Signature · 1 line
1.6.5.2
#1 lore raw

PATCH 1/1 ARM: Add atomic64 routines for ARMv6k and above.

Quoted 8 lines · Will Deacon

In preparation for perf-events support, ARM needs to support atomic64_t operations. v6k and above support the ldrexd and strexd instructions to do just that.

This patch adds atomic64 support to the ARM architecture. v6k and above make use of new instructions whilst older cores fall back on the generic solution using spinlocks. If and when v7-M cores are supported by Linux, they will need to fall back on the spinlock implementation too.

Looks good! I've given this a go with the perf events code and it all looks fine to me. Platform used was an ARM1176JZ-S (with K extensions).

Jamie

#2 lore raw

PATCH 1/1 ARM: Add atomic64 routines for ARMv6k and above.

In reply to Will Deacon

Hello,

Quoted 22 lines · Will Deacon

In preparation for perf-events support, ARM needs to support atomic64_t operations. v6k and above support the ldrexd and strexd instructions to do just that.

This patch adds atomic64 support to the ARM architecture. v6k and above make use of new instructions whilst older cores fall back on the generic solution using spinlocks. If and when v7-M cores are supported by Linux, they will need to fall back on the spinlock implementation too.

---
 arch/arm/Kconfig              |    1 +
 arch/arm/include/asm/atomic.h |  228 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 229 insertions(+), 0 deletions(-)
arch/arm/Kconfig +0 -0
index 1c4119c..5fdc032 100644

arch/arm/Kconfig config ARM · line 21

Quoted 4 lines
arch/arm/Kconfig +1 -0
@@ -18,6 +18,7 @@ config ARM
 	select HAVE_KRETPROBES if (HAVE_KPROBES)
 	select HAVE_FUNCTION_TRACER if (!XIP_KERNEL)
 	select HAVE_GENERIC_DMA_COHERENT
+	select GENERIC_ATOMIC64 if (!CPU_32v6K)

If a kernel supports say a v5 and a v6 then IIRC CPU_32v6K is enabled, but GENERIC_ATOMIC64 is needed, too.

Maybe I missed something.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                              | Uwe Kleine-K?nig            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |
#3 lore raw

PATCH 1/1 ARM: Add atomic64 routines for ARMv6k and above.

Uwe,

Quoted 18 lines · Uwe Kleine-K?nig
Quoted 17 lines · Will Deacon

In preparation for perf-events support, ARM needs to support atomic64_t operations. v6k and above support the ldrexd and strexd instructions to do just that.

This patch adds atomic64 support to the ARM architecture. v6k and above make use of new instructions whilst older cores fall back on the generic solution using spinlocks. If and when v7-M cores are supported by Linux, they will need to fall back on the spinlock implementation too.

---
 arch/arm/Kconfig              |    1 +
 arch/arm/include/asm/atomic.h |  228 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 229 insertions(+), 0 deletions(-)
Quoted 12 lines

arch/arm/Kconfig config ARM · line 21

Quoted 9 lines
arch/arm/Kconfig +1 -0
index 1c4119c..5fdc032 100644
@@ -18,6 +18,7 @@ config ARM
      select HAVE_KRETPROBES if (HAVE_KPROBES)
      select HAVE_FUNCTION_TRACER if (!XIP_KERNEL)
      select HAVE_GENERIC_DMA_COHERENT
+     select GENERIC_ATOMIC64 if (!CPU_32v6K)

If a kernel supports say a v5 and a v6 then IIRC CPU_32v6K is enabled, but GENERIC_ATOMIC64 is needed, too.

CPU_32v6K is enabled by (v6 && SMP) || v7.

I doubt we would ever be able to compile a v5 kernel while having CPU_32v6K enabled. A lot o macros are conditionally defined at preprocessing time based on the architecture version (e.g. asm/system.h). Even if you get v5 and v6 in the same kernel to compile fine, you would miss some macros like dmb() or isb() which are needed on v6 so the kernel may not have the expected behaviour.

While you could fix this with some performance penalties, I'm not sure it's worth the effort.

Signature · 1 line
Catalin
#4 lore raw

PATCH 1/1 ARM: Add atomic64 routines for ARMv6k and above.

Hi Catalin,

Quoted 41 lines · Catalin Marinas
Quoted 18 lines · Uwe Kleine-K?nig
Quoted 17 lines · Will Deacon

In preparation for perf-events support, ARM needs to support atomic64_t operations. v6k and above support the ldrexd and strexd instructions to do just that.

This patch adds atomic64 support to the ARM architecture. v6k and above make use of new instructions whilst older cores fall back on the generic solution using spinlocks. If and when v7-M cores are supported by Linux, they will need to fall back on the spinlock implementation too.

---
 arch/arm/Kconfig              |    1 +
 arch/arm/include/asm/atomic.h |  228 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 229 insertions(+), 0 deletions(-)
Quoted 12 lines

arch/arm/Kconfig config ARM · line 21

Quoted 9 lines
arch/arm/Kconfig +1 -0
index 1c4119c..5fdc032 100644
@@ -18,6 +18,7 @@ config ARM
      select HAVE_KRETPROBES if (HAVE_KPROBES)
      select HAVE_FUNCTION_TRACER if (!XIP_KERNEL)
      select HAVE_GENERIC_DMA_COHERENT
+     select GENERIC_ATOMIC64 if (!CPU_32v6K)

If a kernel supports say a v5 and a v6 then IIRC CPU_32v6K is enabled, but GENERIC_ATOMIC64 is needed, too.

CPU_32v6K is enabled by (v6 && SMP) || v7.

I doubt we would ever be able to compile a v5 kernel while having CPU_32v6K enabled. A lot o macros are conditionally defined at preprocessing time based on the architecture version (e.g. asm/system.h). Even if you get v5 and v6 in the same kernel to compile fine, you would miss some macros like dmb() or isb() which are needed on v6 so the kernel may not have the expected behaviour.

Quoted 2 lines

While you could fix this with some performance penalties, I'm not sure it's worth the effort.

Maybe we should make that explicit somehow? E.g. let CPU_32v6K depend on !CPU_32v5? (I didn't check the symbol names.)

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                              | Uwe Kleine-K?nig            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |
#5 lore raw

PATCH 1/1 ARM: Add atomic64 routines for ARMv6k and above.

Quoted 2 lines · Uwe Kleine-K?nig

Maybe we should make that explicit somehow? E.g. let CPU_32v6K depend on !CPU_32v5? (I didn't check the symbol names.)

Doesn't work, select overrides dependencies.