Skip to contentSkip to conversation

arm64: enable EDAC on arm64

PATCH New Rob Herring 3 participants 6 messages Nov 6, 2013 – Nov 7, 2013 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: enable EDAC on arm64

From: Rob Herring <[email protected]>

Implement atomic_scrub and enable EDAC for arm64.

Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
---
 arch/arm64/Kconfig            |  1 +
 arch/arm64/include/asm/edac.h | 44 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 arch/arm64/include/asm/edac.h
arch/arm64/Kconfig +1 -0
index 7d70404..611f5f6 100644
@@ -11,6 +11,7 @@ config ARM64
 	select BUILDTIME_EXTABLE_SORT
 	select CLONE_BACKWARDS
 	select COMMON_CLK
+	select EDAC_SUPPORT
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_IOMAP
 	select GENERIC_IRQ_PROBE
arch/arm64/include/asm/edac.h new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
1.8.1.2
maintainer
#1 lore raw

PATCH 1/1 arm64: enable EDAC on arm64

Quoted 6 lines · Rob Herring
arch/arm64/include/asm/edac.h new file +6 -0
+static inline void atomic_scrub(void *va, u32 size)
+{
+	unsigned int *virt_addr = va;
+	unsigned int temp, temp2;
+	unsigned int i;
+

arch/arm64/include/asm/edac.h line 40

Quoted 10 lines
arch/arm64/include/asm/edac.h new file +10 -0
+	for (i = 0; i < size / sizeof(*virt_addr); i++, virt_addr++) {
+		/*
+		 * No need to check for store failure, another write means
+		 * the scrubbing has effectively already been done for us.
+		 */
+		asm volatile("\n"
+			"	ldxr	%0, %2\n"
+			"	stxr	%w1, %0, %2\n"
+			: "=&r" (temp), "=&r" (temp2), "+Q" (virt_addr)
+			: : "cc");

But failure of stxr does not necessarily mean another write. It can be an interrupt, cache line migration etc. The exclusive monitor can be emulated in many ways.

BTW, can you not use 64-bit loads/stores?

Signature · 1 line
Catalin
#2 lore raw

PATCH 1/1 arm64: enable EDAC on arm64

Quoted 13 lines · Catalin Marinas
Quoted 12 lines · Rob Herring
arch/arm64/include/asm/edac.h new file +12 -0
+static inline void atomic_scrub(void *va, u32 size)
+{
+     unsigned int *virt_addr = va;
+     unsigned int temp, temp2;
+     unsigned int i;
+
+     for (i = 0; i < size / sizeof(*virt_addr); i++, virt_addr++) {
+             /*
+              * No need to check for store failure, another write means
+              * the scrubbing has effectively already been done for us.
+              */
+             asm volatile("\n"
Quoted 8 lines

arch/arm64/include/asm/edac.h line 40

Quoted 4 lines
arch/arm64/include/asm/edac.h new file +4 -0
+                     "       ldxr    %0, %2\n"
+                     "       stxr    %w1, %0, %2\n"
+                     : "=&r" (temp), "=&r" (temp2), "+Q" (virt_addr)
+                     : : "cc");

But failure of stxr does not necessarily mean another write. It can be an interrupt, cache line migration etc. The exclusive monitor can be emulated in many ways.

Right, I was thinking I could simplify things.

In that case, I could implement this with just "atomic64_add(0, virt_addr)", but is there any guarantee that atomic64_t has a size of 8 bytes and that I can simply increment an atomic64_t ptr?

Quoted 1 line

BTW, can you not use 64-bit loads/stores?

Correct, that should be a long instead of int.

Rob

maintainer
#3 lore raw

PATCH 1/1 arm64: enable EDAC on arm64

Quoted 23 lines · Rob Herring
Quoted 13 lines · Catalin Marinas
Quoted 12 lines · Rob Herring
arch/arm64/include/asm/edac.h new file +12 -0
+static inline void atomic_scrub(void *va, u32 size)
+{
+     unsigned int *virt_addr = va;
+     unsigned int temp, temp2;
+     unsigned int i;
+
+     for (i = 0; i < size / sizeof(*virt_addr); i++, virt_addr++) {
+             /*
+              * No need to check for store failure, another write means
+              * the scrubbing has effectively already been done for us.
+              */
+             asm volatile("\n"
Quoted 8 lines

arch/arm64/include/asm/edac.h line 40

Quoted 4 lines
arch/arm64/include/asm/edac.h new file +4 -0
+                     "       ldxr    %0, %2\n"
+                     "       stxr    %w1, %0, %2\n"
+                     : "=&r" (temp), "=&r" (temp2), "+Q" (virt_addr)
+                     : : "cc");

But failure of stxr does not necessarily mean another write. It can be an interrupt, cache line migration etc. The exclusive monitor can be emulated in many ways.

Quoted 5 lines

Right, I was thinking I could simplify things.

In that case, I could implement this with just "atomic64_add(0, virt_addr)", but is there any guarantee that atomic64_t has a size of 8 bytes and that I can simply increment an atomic64_t ptr?

I would rather add just an asm volatile (as you've done) to avoid the 'add' inside the loop and force casting to atomic64_t.

Signature · 1 line
Catalin
#4 lore raw

PATCH 1/1 arm64: enable EDAC on arm64

In reply to Rob Herring
Quoted 25 lines · Rob Herring
Quoted 13 lines · Catalin Marinas
Quoted 12 lines · Rob Herring
arch/arm64/include/asm/edac.h new file +12 -0
+static inline void atomic_scrub(void *va, u32 size)
+{
+     unsigned int *virt_addr = va;
+     unsigned int temp, temp2;
+     unsigned int i;
+
+     for (i = 0; i < size / sizeof(*virt_addr); i++, virt_addr++) {
+             /*
+              * No need to check for store failure, another write means
+              * the scrubbing has effectively already been done for us.
+              */
+             asm volatile("\n"
Quoted 8 lines

arch/arm64/include/asm/edac.h line 40

Quoted 4 lines
arch/arm64/include/asm/edac.h new file +4 -0
+                     "       ldxr    %0, %2\n"
+                     "       stxr    %w1, %0, %2\n"
+                     : "=&r" (temp), "=&r" (temp2), "+Q" (virt_addr)
+                     : : "cc");

But failure of stxr does not necessarily mean another write. It can be an interrupt, cache line migration etc. The exclusive monitor can be emulated in many ways.

Right, I was thinking I could simplify things.

Quoted 7 lines

In that case, I could implement this with just "atomic64_add(0, virt_addr)", but is there any guarantee that atomic64_t has a size of 8 bytes and that I can simply increment an atomic64_t ptr?

Quoted 1 line

BTW, can you not use 64-bit loads/stores?

Correct, that should be a long instead of int.

Are we guaranteed that va is a 64-bit aligned pointer? Also, usual comment about the "cc" clobber.

Will

#5 lore raw

PATCH 1/1 arm64: enable EDAC on arm64

Quoted 30 lines · Will Deacon
Quoted 29 lines · Rob Herring
Quoted 13 lines · Catalin Marinas
Quoted 12 lines · Rob Herring
arch/arm64/include/asm/edac.h new file +12 -0
+static inline void atomic_scrub(void *va, u32 size)
+{
+     unsigned int *virt_addr = va;
+     unsigned int temp, temp2;
+     unsigned int i;
+
+     for (i = 0; i < size / sizeof(*virt_addr); i++, virt_addr++) {
+             /*
+              * No need to check for store failure, another write means
+              * the scrubbing has effectively already been done for us.
+              */
+             asm volatile("\n"
Quoted 8 lines

arch/arm64/include/asm/edac.h line 40

Quoted 4 lines
arch/arm64/include/asm/edac.h new file +4 -0
+                     "       ldxr    %0, %2\n"
+                     "       stxr    %w1, %0, %2\n"
+                     : "=&r" (temp), "=&r" (temp2), "+Q" (virt_addr)
+                     : : "cc");

But failure of stxr does not necessarily mean another write. It can be an interrupt, cache line migration etc. The exclusive monitor can be emulated in many ways.

Right, I was thinking I could simplify things.

In that case, I could implement this with just "atomic64_add(0, virt_addr)", but is there any guarantee that atomic64_t has a size of 8 bytes and that I can simply increment an atomic64_t ptr?

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

BTW, can you not use 64-bit loads/stores?

Correct, that should be a long instead of int.

Are we guaranteed that va is a 64-bit aligned pointer? Also, usual comment about the "cc" clobber.

I'll have to check if the EDAC framework provides any guarantee, but we can force the alignment widening the scrubbing range if needed. Normally, DDR ECC would always be done on 64-bit units for 72-bit DIMMs. I can't imagine you would ever have 32-bit wide DDR with ECC.

Rob