aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2012-10-16 18:39:09 -0400
committerRalf Baechle <ralf@linux-mips.org>2012-12-12 10:48:49 -0500
commitf65aad41772f6a0022e9763fe06f47604449964c (patch)
tree701d6ea74ac0c41f008c5554d876945fe4caf512 /arch/mips
parentaa1762f49c81a14d0453e4f67f922e4f155510a3 (diff)
MIPS: Cavium: Add EDAC support.
Drivers for EDAC on Cavium. Supported subsystems are: o CPU primary caches. These are parity protected only, so only error reporting. o Second level cache - ECC protected, provides SECDED. o Memory: ECC / SECDEC if used with suitable DRAM modules. The driver will will only initialize if ECC is enabled on a system so is safe to run on non-ECC memory. o PCI: Parity error reporting Since it is very hard to test this sort of code the implementation is very conservative and uses polling where possible for now. Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Reviewed-by: Borislav Petkov <borislav.petkov@amd.com>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/Kconfig1
-rw-r--r--arch/mips/cavium-octeon/setup.c30
-rw-r--r--arch/mips/mm/c-octeon.c46
-rw-r--r--arch/mips/pci/pci-octeon.c4
4 files changed, 58 insertions, 23 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 397194a263ce..b47d591c03dd 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -774,6 +774,7 @@ config CAVIUM_OCTEON_REFERENCE_BOARD
774 select DMA_COHERENT 774 select DMA_COHERENT
775 select SYS_SUPPORTS_64BIT_KERNEL 775 select SYS_SUPPORTS_64BIT_KERNEL
776 select SYS_SUPPORTS_BIG_ENDIAN 776 select SYS_SUPPORTS_BIG_ENDIAN
777 select EDAC_SUPPORT
777 select SYS_SUPPORTS_HOTPLUG_CPU 778 select SYS_SUPPORTS_HOTPLUG_CPU
778 select SYS_HAS_EARLY_PRINTK 779 select SYS_HAS_EARLY_PRINTK
779 select SYS_HAS_CPU_CAVIUM_OCTEON 780 select SYS_HAS_CPU_CAVIUM_OCTEON
diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
index 04dd8ff0e0d8..60ed700a956d 100644
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -4,9 +4,11 @@
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2004-2007 Cavium Networks 6 * Copyright (C) 2004-2007 Cavium Networks
7 * Copyright (C) 2008 Wind River Systems 7 * Copyright (C) 2008, 2009 Wind River Systems
8 * written by Ralf Baechle <ralf@linux-mips.org>
8 */ 9 */
9#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/kernel.h>
10#include <linux/console.h> 12#include <linux/console.h>
11#include <linux/delay.h> 13#include <linux/delay.h>
12#include <linux/export.h> 14#include <linux/export.h>
@@ -821,3 +823,29 @@ void __init device_tree_init(void)
821 } 823 }
822 unflatten_device_tree(); 824 unflatten_device_tree();
823} 825}
826
827static char *edac_device_names[] = {
828 "co_l2c_edac",
829 "co_lmc_edac",
830 "co_pc_edac",
831};
832
833static int __init edac_devinit(void)
834{
835 struct platform_device *dev;
836 int i, err = 0;
837 char *name;
838
839 for (i = 0; i < ARRAY_SIZE(edac_device_names); i++) {
840 name = edac_device_names[i];
841 dev = platform_device_register_simple(name, -1, NULL, 0);
842 if (IS_ERR(dev)) {
843 pr_err("Registation of %s failed!\n", name);
844 err = PTR_ERR(dev);
845 }
846 }
847
848 return err;
849}
850
851device_initcall(edac_devinit);
diff --git a/arch/mips/mm/c-octeon.c b/arch/mips/mm/c-octeon.c
index 44e69e7a4519..9f67553762d5 100644
--- a/arch/mips/mm/c-octeon.c
+++ b/arch/mips/mm/c-octeon.c
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (C) 2005-2007 Cavium Networks 6 * Copyright (C) 2005-2007 Cavium Networks
7 */ 7 */
8#include <linux/export.h>
8#include <linux/init.h> 9#include <linux/init.h>
9#include <linux/kernel.h> 10#include <linux/kernel.h>
10#include <linux/sched.h> 11#include <linux/sched.h>
@@ -28,6 +29,7 @@
28#include <asm/octeon/octeon.h> 29#include <asm/octeon/octeon.h>
29 30
30unsigned long long cache_err_dcache[NR_CPUS]; 31unsigned long long cache_err_dcache[NR_CPUS];
32EXPORT_SYMBOL_GPL(cache_err_dcache);
31 33
32/** 34/**
33 * Octeon automatically flushes the dcache on tlb changes, so 35 * Octeon automatically flushes the dcache on tlb changes, so
@@ -288,42 +290,42 @@ void __cpuinit octeon_cache_init(void)
288 * Handle a cache error exception 290 * Handle a cache error exception
289 */ 291 */
290 292
291static void cache_parity_error_octeon(int non_recoverable) 293static RAW_NOTIFIER_HEAD(co_cache_error_chain);
294
295int register_co_cache_error_notifier(struct notifier_block *nb)
292{ 296{
293 unsigned long coreid = cvmx_get_core_num(); 297 return raw_notifier_chain_register(&co_cache_error_chain, nb);
294 uint64_t icache_err = read_octeon_c0_icacheerr(); 298}
295 299EXPORT_SYMBOL_GPL(register_co_cache_error_notifier);
296 pr_err("Cache error exception:\n");
297 pr_err("cp0_errorepc == %lx\n", read_c0_errorepc());
298 if (icache_err & 1) {
299 pr_err("CacheErr (Icache) == %llx\n",
300 (unsigned long long)icache_err);
301 write_octeon_c0_icacheerr(0);
302 }
303 if (cache_err_dcache[coreid] & 1) {
304 pr_err("CacheErr (Dcache) == %llx\n",
305 (unsigned long long)cache_err_dcache[coreid]);
306 cache_err_dcache[coreid] = 0;
307 }
308 300
309 if (non_recoverable) 301int unregister_co_cache_error_notifier(struct notifier_block *nb)
310 panic("Can't handle cache error: nested exception"); 302{
303 return raw_notifier_chain_unregister(&co_cache_error_chain, nb);
304}
305EXPORT_SYMBOL_GPL(unregister_co_cache_error_notifier);
306
307static inline int co_cache_error_call_notifiers(unsigned long val)
308{
309 return raw_notifier_call_chain(&co_cache_error_chain, val, NULL);
311} 310}
312 311
313/** 312/**
314 * Called when the the exception is recoverable 313 * Called when the the exception is recoverable
315 */ 314 */
316
317asmlinkage void cache_parity_error_octeon_recoverable(void) 315asmlinkage void cache_parity_error_octeon_recoverable(void)
318{ 316{
319 cache_parity_error_octeon(0); 317 co_cache_error_call_notifiers(0);
320} 318}
321 319
322/** 320/**
323 * Called when the the exception is not recoverable 321 * Called when the the exception is not recoverable
322 *
323 * The issue not that the cache error exception itself was non-recoverable
324 * but that due to nesting of exception may have lost some state so can't
325 * continue.
324 */ 326 */
325
326asmlinkage void cache_parity_error_octeon_non_recoverable(void) 327asmlinkage void cache_parity_error_octeon_non_recoverable(void)
327{ 328{
328 cache_parity_error_octeon(1); 329 co_cache_error_call_notifiers(1);
330 panic("Can't handle cache error: nested exception");
329} 331}
diff --git a/arch/mips/pci/pci-octeon.c b/arch/mips/pci/pci-octeon.c
index 4b0c347d7a82..8eb2ee345d03 100644
--- a/arch/mips/pci/pci-octeon.c
+++ b/arch/mips/pci/pci-octeon.c
@@ -11,6 +11,7 @@
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <linux/time.h> 12#include <linux/time.h>
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/platform_device.h>
14#include <linux/swiotlb.h> 15#include <linux/swiotlb.h>
15 16
16#include <asm/time.h> 17#include <asm/time.h>
@@ -704,6 +705,9 @@ static int __init octeon_pci_setup(void)
704 */ 705 */
705 cvmx_write_csr(CVMX_NPI_PCI_INT_SUM2, -1); 706 cvmx_write_csr(CVMX_NPI_PCI_INT_SUM2, -1);
706 707
708 if (IS_ERR(platform_device_register_simple("co_pci_edac", 0, NULL, 0)))
709 pr_err("Registation of co_pci_edac failed!\n");
710
707 octeon_pci_dma_init(); 711 octeon_pci_dma_init();
708 712
709 return 0; 713 return 0;