diff options
Diffstat (limited to 'drivers/edac/octeon_edac-pc.c')
-rw-r--r-- | drivers/edac/octeon_edac-pc.c | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/drivers/edac/octeon_edac-pc.c b/drivers/edac/octeon_edac-pc.c new file mode 100644 index 000000000000..9d13061744e4 --- /dev/null +++ b/drivers/edac/octeon_edac-pc.c | |||
@@ -0,0 +1,140 @@ | |||
1 | /* | ||
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright (C) 2009 Wind River Systems, | ||
7 | * written by Ralf Baechle <ralf@linux-mips.org> | ||
8 | */ | ||
9 | #include <linux/module.h> | ||
10 | #include <linux/init.h> | ||
11 | #include <linux/slab.h> | ||
12 | #include <linux/interrupt.h> | ||
13 | #include <linux/io.h> | ||
14 | #include <linux/edac.h> | ||
15 | |||
16 | #include "edac_core.h" | ||
17 | #include "edac_module.h" | ||
18 | |||
19 | #include <asm/octeon/cvmx.h> | ||
20 | #include <asm/mipsregs.h> | ||
21 | |||
22 | #define EDAC_MOD_STR "octeon" | ||
23 | |||
24 | extern int register_co_cache_error_notifier(struct notifier_block *nb); | ||
25 | extern int unregister_co_cache_error_notifier(struct notifier_block *nb); | ||
26 | |||
27 | extern unsigned long long cache_err_dcache[NR_CPUS]; | ||
28 | |||
29 | static struct edac_device_ctl_info *ed_cavium; | ||
30 | |||
31 | /* | ||
32 | * EDAC CPU cache error callback | ||
33 | * | ||
34 | */ | ||
35 | |||
36 | static int co_cache_error_event(struct notifier_block *this, | ||
37 | unsigned long event, void *ptr) | ||
38 | { | ||
39 | unsigned int core = cvmx_get_core_num(); | ||
40 | unsigned int cpu = smp_processor_id(); | ||
41 | uint64_t icache_err = read_octeon_c0_icacheerr(); | ||
42 | struct edac_device_ctl_info *ed = ed_cavium; | ||
43 | |||
44 | edac_device_printk(ed, KERN_ERR, | ||
45 | "Cache error exception on core %d / processor %d:\n", | ||
46 | core, cpu); | ||
47 | edac_device_printk(ed, KERN_ERR, | ||
48 | "cp0_errorepc == %lx\n", read_c0_errorepc()); | ||
49 | if (icache_err & 1) { | ||
50 | edac_device_printk(ed, KERN_ERR, "CacheErr (Icache) == %llx\n", | ||
51 | (unsigned long long)icache_err); | ||
52 | write_octeon_c0_icacheerr(0); | ||
53 | edac_device_handle_ce(ed, 0, 0, ed->ctl_name); | ||
54 | } | ||
55 | if (cache_err_dcache[core] & 1) { | ||
56 | edac_device_printk(ed, KERN_ERR, "CacheErr (Dcache) == %llx\n", | ||
57 | (unsigned long long)cache_err_dcache[core]); | ||
58 | cache_err_dcache[core] = 0; | ||
59 | edac_device_handle_ue(ed, 0, 0, ed->ctl_name); | ||
60 | } | ||
61 | |||
62 | return NOTIFY_DONE; | ||
63 | } | ||
64 | |||
65 | static struct notifier_block co_cache_error_notifier = { | ||
66 | .notifier_call = co_cache_error_event, | ||
67 | }; | ||
68 | |||
69 | static int __devinit co_cache_error_probe(struct platform_device *pdev) | ||
70 | { | ||
71 | struct edac_device_ctl_info *ed; | ||
72 | int res = 0; | ||
73 | |||
74 | ed = edac_device_alloc_ctl_info(0, "cpu", 1, NULL, 0, 0, NULL, 0, | ||
75 | edac_device_alloc_index()); | ||
76 | |||
77 | ed->dev = &pdev->dev; | ||
78 | platform_set_drvdata(pdev, ed); | ||
79 | ed->dev_name = dev_name(&pdev->dev); | ||
80 | |||
81 | ed->mod_name = "octeon-cpu"; | ||
82 | ed->ctl_name = "co_cpu_err"; | ||
83 | |||
84 | if (edac_device_add_device(ed) > 0) { | ||
85 | pr_err("%s: edac_device_add_device() failed\n", __func__); | ||
86 | goto err; | ||
87 | } | ||
88 | |||
89 | register_co_cache_error_notifier(&co_cache_error_notifier); | ||
90 | ed_cavium = ed; | ||
91 | |||
92 | return 0; | ||
93 | |||
94 | err: | ||
95 | edac_device_free_ctl_info(ed); | ||
96 | |||
97 | return res; | ||
98 | } | ||
99 | |||
100 | static int co_cache_error_remove(struct platform_device *pdev) | ||
101 | { | ||
102 | struct edac_device_ctl_info *ed = platform_get_drvdata(pdev); | ||
103 | |||
104 | unregister_co_cache_error_notifier(&co_cache_error_notifier); | ||
105 | ed_cavium = NULL; | ||
106 | edac_device_del_device(&pdev->dev); | ||
107 | edac_device_free_ctl_info(ed); | ||
108 | |||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | static struct platform_driver co_cache_error_driver = { | ||
113 | .probe = co_cache_error_probe, | ||
114 | .remove = co_cache_error_remove, | ||
115 | .driver = { | ||
116 | .name = "co_pc_edac", | ||
117 | } | ||
118 | }; | ||
119 | |||
120 | static int __init co_edac_init(void) | ||
121 | { | ||
122 | int ret; | ||
123 | |||
124 | ret = platform_driver_register(&co_cache_error_driver); | ||
125 | if (ret) | ||
126 | pr_warning(EDAC_MOD_STR "CPU err failed to register\n"); | ||
127 | |||
128 | return ret; | ||
129 | } | ||
130 | |||
131 | static void __exit co_edac_exit(void) | ||
132 | { | ||
133 | platform_driver_unregister(&co_cache_error_driver); | ||
134 | } | ||
135 | |||
136 | module_init(co_edac_init); | ||
137 | module_exit(co_edac_exit); | ||
138 | |||
139 | MODULE_LICENSE("GPL"); | ||
140 | MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>"); | ||