Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

EDAC: Cleanup atomic_scrub mess

So first of all, this atomic_scrub() function's naming is bad. It looks
like an atomic_t helper. Change it to edac_atomic_scrub().

The bigger problem is that this function is arch-specific and every new
arch which doesn't necessarily need that functionality still needs to
define it, otherwise EDAC doesn't compile.

So instead of doing that and including arch-specific headers, have each
arch define an EDAC_ATOMIC_SCRUB symbol which can be used in edac_mc.c
for ifdeffery. Much cleaner.

And we already are doing this with another symbol - EDAC_SUPPORT. This
is also much cleaner than having CONFIG_EDAC enumerate all the arches
which need/have EDAC support and drivers.

This way I can kill the useless edac.h header in tile too.

Acked-by: Ralf Baechle <ralf@linux-mips.org>
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
Acked-by: Chris Metcalf <cmetcalf@ezchip.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-edac@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: "Maciej W. Rozycki" <macro@codesourcery.com>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: "Steven J. Hill" <Steven.Hill@imgtec.com>
Cc: x86@kernel.org
Signed-off-by: Borislav Petkov <bp@suse.de>

+27 -41
+2
arch/arm/Kconfig
··· 15 15 select CLONE_BACKWARDS 16 16 select CPU_PM if (SUSPEND || CPU_IDLE) 17 17 select DCACHE_WORD_ACCESS if HAVE_EFFICIENT_UNALIGNED_ACCESS 18 + select EDAC_SUPPORT 19 + select EDAC_ATOMIC_SCRUB 18 20 select GENERIC_ALLOCATOR 19 21 select GENERIC_ATOMIC64 if (CPU_V7M || CPU_V6 || !CPU_32v6K || !AEABI) 20 22 select GENERIC_CLOCKEVENTS_BROADCAST if SMP
+3 -2
arch/arm/include/asm/edac.h
··· 18 18 #define ASM_EDAC_H 19 19 /* 20 20 * ECC atomic, DMA, SMP and interrupt safe scrub function. 21 - * Implements the per arch atomic_scrub() that EDAC use for software 21 + * Implements the per arch edac_atomic_scrub() that EDAC use for software 22 22 * ECC scrubbing. It reads memory and then writes back the original 23 23 * value, allowing the hardware to detect and correct memory errors. 24 24 */ 25 - static inline void atomic_scrub(void *va, u32 size) 25 + 26 + static inline void edac_atomic_scrub(void *va, u32 size) 26 27 { 27 28 #if __LINUX_ARM_ARCH__ >= 6 28 29 unsigned int *virt_addr = va;
+1
arch/mips/Kconfig
··· 819 819 select SYS_SUPPORTS_64BIT_KERNEL 820 820 select SYS_SUPPORTS_BIG_ENDIAN 821 821 select EDAC_SUPPORT 822 + select EDAC_ATOMIC_SCRUB 822 823 select SYS_SUPPORTS_LITTLE_ENDIAN 823 824 select SYS_SUPPORTS_HOTPLUG_CPU if CPU_BIG_ENDIAN 824 825 select SYS_HAS_EARLY_PRINTK
+2 -2
arch/mips/include/asm/edac.h
··· 5 5 6 6 /* ECC atomic, DMA, SMP and interrupt safe scrub function */ 7 7 8 - static inline void atomic_scrub(void *va, u32 size) 8 + static inline void edac_atomic_scrub(void *va, u32 size) 9 9 { 10 10 unsigned long *virt_addr = va; 11 11 unsigned long temp; ··· 21 21 22 22 __asm__ __volatile__ ( 23 23 " .set mips2 \n" 24 - "1: ll %0, %1 # atomic_scrub \n" 24 + "1: ll %0, %1 # edac_atomic_scrub \n" 25 25 " addu %0, $0 \n" 26 26 " sc %0, %1 \n" 27 27 " beqz %0, 1b \n"
+2
arch/powerpc/Kconfig
··· 153 153 select NO_BOOTMEM 154 154 select HAVE_GENERIC_RCU_GUP 155 155 select HAVE_PERF_EVENTS_NMI if PPC64 156 + select EDAC_SUPPORT 157 + select EDAC_ATOMIC_SCRUB 156 158 157 159 config GENERIC_CSUM 158 160 def_bool CPU_LITTLE_ENDIAN
+2 -2
arch/powerpc/include/asm/edac.h
··· 12 12 #define ASM_EDAC_H 13 13 /* 14 14 * ECC atomic, DMA, SMP and interrupt safe scrub function. 15 - * Implements the per arch atomic_scrub() that EDAC use for software 15 + * Implements the per arch edac_atomic_scrub() that EDAC use for software 16 16 * ECC scrubbing. It reads memory and then writes back the original 17 17 * value, allowing the hardware to detect and correct memory errors. 18 18 */ 19 - static __inline__ void atomic_scrub(void *va, u32 size) 19 + static __inline__ void edac_atomic_scrub(void *va, u32 size) 20 20 { 21 21 unsigned int *virt_addr = va; 22 22 unsigned int temp;
+1
arch/tile/Kconfig
··· 28 28 select HAVE_DEBUG_STACKOVERFLOW 29 29 select ARCH_WANT_FRAME_POINTERS 30 30 select HAVE_CONTEXT_TRACKING 31 + select EDAC_SUPPORT 31 32 32 33 # FIXME: investigate whether we need/want these options. 33 34 # select HAVE_IOREMAP_PROT
-29
arch/tile/include/asm/edac.h
··· 1 - /* 2 - * Copyright 2011 Tilera Corporation. All Rights Reserved. 3 - * 4 - * This program is free software; you can redistribute it and/or 5 - * modify it under the terms of the GNU General Public License 6 - * as published by the Free Software Foundation, version 2. 7 - * 8 - * This program is distributed in the hope that it will be useful, but 9 - * WITHOUT ANY WARRANTY; without even the implied warranty of 10 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 11 - * NON INFRINGEMENT. See the GNU General Public License for 12 - * more details. 13 - */ 14 - 15 - #ifndef _ASM_TILE_EDAC_H 16 - #define _ASM_TILE_EDAC_H 17 - 18 - /* ECC atomic, DMA, SMP and interrupt safe scrub function */ 19 - 20 - static inline void atomic_scrub(void *va, u32 size) 21 - { 22 - /* 23 - * These is nothing to be done here because CE is 24 - * corrected by the mshim. 25 - */ 26 - return; 27 - } 28 - 29 - #endif /* _ASM_TILE_EDAC_H */
+2
arch/x86/Kconfig
··· 143 143 select ACPI_LEGACY_TABLES_LOOKUP if ACPI 144 144 select X86_FEATURE_NAMES if PROC_FS 145 145 select SRCU 146 + select EDAC_SUPPORT 147 + select EDAC_ATOMIC_SCRUB 146 148 147 149 config INSTRUCTION_DECODER 148 150 def_bool y
+1 -1
arch/x86/include/asm/edac.h
··· 3 3 4 4 /* ECC atomic, DMA, SMP and interrupt safe scrub function */ 5 5 6 - static inline void atomic_scrub(void *va, u32 size) 6 + static inline void edac_atomic_scrub(void *va, u32 size) 7 7 { 8 8 u32 i, *virt_addr = va; 9 9
+4 -3
drivers/edac/Kconfig
··· 2 2 # EDAC Kconfig 3 3 # Copyright (c) 2008 Doug Thompson www.softwarebitmaker.com 4 4 # Licensed and distributed under the GPL 5 - # 5 + 6 + config EDAC_ATOMIC_SCRUB 7 + bool 6 8 7 9 config EDAC_SUPPORT 8 10 bool 9 11 10 12 menuconfig EDAC 11 13 bool "EDAC (Error Detection And Correction) reporting" 12 - depends on HAS_IOMEM 13 - depends on X86 || PPC || TILE || ARM || EDAC_SUPPORT 14 + depends on HAS_IOMEM && EDAC_SUPPORT 14 15 help 15 16 EDAC is designed to report errors in the core system. 16 17 These are low-level errors that are reported in the CPU or
+7 -2
drivers/edac/edac_mc.c
··· 30 30 #include <linux/bitops.h> 31 31 #include <asm/uaccess.h> 32 32 #include <asm/page.h> 33 - #include <asm/edac.h> 34 33 #include "edac_core.h" 35 34 #include "edac_module.h" 36 35 #include <ras/ras_event.h> 36 + 37 + #ifdef CONFIG_EDAC_ATOMIC_SCRUB 38 + #include <asm/edac.h> 39 + #else 40 + #define edac_atomic_scrub(va, size) do { } while (0) 41 + #endif 37 42 38 43 /* lock to memory controller's control array */ 39 44 static DEFINE_MUTEX(mem_ctls_mutex); ··· 879 874 virt_addr = kmap_atomic(pg); 880 875 881 876 /* Perform architecture specific atomic scrub operation */ 882 - atomic_scrub(virt_addr + offset, size); 877 + edac_atomic_scrub(virt_addr + offset, size); 883 878 884 879 /* Unmap and complete */ 885 880 kunmap_atomic(virt_addr);