summaryrefslogtreecommitdiffstats
path: root/drivers/edac/octeon_edac-pc.c
diff options
context:
space:
mode:
authorDavid Daney <david.daney@cavium.com>2012-11-15 13:58:59 -0800
committerRalf Baechle <ralf@linux-mips.org>2012-12-13 18:15:26 +0100
commite1ced09797776dfd4a2a7b04b9ee7e97ab1e64be (patch)
tree473934ca424e0e10f235bcd9ae97781349af5495 /drivers/edac/octeon_edac-pc.c
parentabe105a4d8c5ee2aa2acef33c5d163e5d187598f (diff)
MIPS/EDAC: Improve OCTEON EDAC support.
Some initialization errors are reported with the existing OCTEON EDAC support patch. Also some parts have more than one memory controller. Fix the errors and add multiple controllers if present. Signed-off-by: David Daney <david.daney@cavium.com>
Diffstat (limited to 'drivers/edac/octeon_edac-pc.c')
-rw-r--r--drivers/edac/octeon_edac-pc.c137
1 files changed, 70 insertions, 67 deletions
diff --git a/drivers/edac/octeon_edac-pc.c b/drivers/edac/octeon_edac-pc.c
index 9d13061744e..14a5e57f2b3 100644
--- a/drivers/edac/octeon_edac-pc.c
+++ b/drivers/edac/octeon_edac-pc.c
@@ -3,6 +3,8 @@
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
+ * Copyright (C) 2012 Cavium, Inc.
+ *
* Copyright (C) 2009 Wind River Systems,
* written by Ralf Baechle <ralf@linux-mips.org>
*/
@@ -19,93 +21,112 @@
#include <asm/octeon/cvmx.h>
#include <asm/mipsregs.h>
-#define EDAC_MOD_STR "octeon"
-
extern int register_co_cache_error_notifier(struct notifier_block *nb);
extern int unregister_co_cache_error_notifier(struct notifier_block *nb);
extern unsigned long long cache_err_dcache[NR_CPUS];
-static struct edac_device_ctl_info *ed_cavium;
+struct co_cache_error {
+ struct notifier_block notifier;
+ struct edac_device_ctl_info *ed;
+};
-/*
+/**
* EDAC CPU cache error callback
*
+ * @event: non-zero if unrecoverable.
*/
-
static int co_cache_error_event(struct notifier_block *this,
unsigned long event, void *ptr)
{
+ struct co_cache_error *p = container_of(this, struct co_cache_error,
+ notifier);
+
unsigned int core = cvmx_get_core_num();
unsigned int cpu = smp_processor_id();
- uint64_t icache_err = read_octeon_c0_icacheerr();
- struct edac_device_ctl_info *ed = ed_cavium;
-
- edac_device_printk(ed, KERN_ERR,
- "Cache error exception on core %d / processor %d:\n",
- core, cpu);
- edac_device_printk(ed, KERN_ERR,
- "cp0_errorepc == %lx\n", read_c0_errorepc());
+ u64 icache_err = read_octeon_c0_icacheerr();
+ u64 dcache_err;
+
+ if (event) {
+ dcache_err = cache_err_dcache[core];
+ cache_err_dcache[core] = 0;
+ } else {
+ dcache_err = read_octeon_c0_dcacheerr();
+ }
+
if (icache_err & 1) {
- edac_device_printk(ed, KERN_ERR, "CacheErr (Icache) == %llx\n",
- (unsigned long long)icache_err);
+ edac_device_printk(p->ed, KERN_ERR,
+ "CacheErr (Icache):%llx, core %d/cpu %d, cp0_errorepc == %lx\n",
+ (unsigned long long)icache_err, core, cpu,
+ read_c0_errorepc());
write_octeon_c0_icacheerr(0);
- edac_device_handle_ce(ed, 0, 0, ed->ctl_name);
+ edac_device_handle_ce(p->ed, cpu, 1, "icache");
}
- if (cache_err_dcache[core] & 1) {
- edac_device_printk(ed, KERN_ERR, "CacheErr (Dcache) == %llx\n",
- (unsigned long long)cache_err_dcache[core]);
- cache_err_dcache[core] = 0;
- edac_device_handle_ue(ed, 0, 0, ed->ctl_name);
+ if (dcache_err & 1) {
+ edac_device_printk(p->ed, KERN_ERR,
+ "CacheErr (Dcache):%llx, core %d/cpu %d, cp0_errorepc == %lx\n",
+ (unsigned long long)dcache_err, core, cpu,
+ read_c0_errorepc());
+ if (event)
+ edac_device_handle_ue(p->ed, cpu, 0, "dcache");
+ else
+ edac_device_handle_ce(p->ed, cpu, 0, "dcache");
+
+ /* Clear the error indication */
+ if (OCTEON_IS_MODEL(OCTEON_FAM_2))
+ write_octeon_c0_dcacheerr(1);
+ else
+ write_octeon_c0_dcacheerr(0);
}
- return NOTIFY_DONE;
+ return NOTIFY_STOP;
}
-static struct notifier_block co_cache_error_notifier = {
- .notifier_call = co_cache_error_event,
-};
-
static int __devinit co_cache_error_probe(struct platform_device *pdev)
{
- struct edac_device_ctl_info *ed;
- int res = 0;
+ struct co_cache_error *p = devm_kzalloc(&pdev->dev, sizeof(*p),
+ GFP_KERNEL);
+ if (!p)
+ return -ENOMEM;
+
+ p->notifier.notifier_call = co_cache_error_event;
+ platform_set_drvdata(pdev, p);
+
+ p->ed = edac_device_alloc_ctl_info(0, "cpu", num_possible_cpus(),
+ "cache", 2, 0, NULL, 0,
+ edac_device_alloc_index());
+ if (!p->ed)
+ goto err;
- ed = edac_device_alloc_ctl_info(0, "cpu", 1, NULL, 0, 0, NULL, 0,
- edac_device_alloc_index());
+ p->ed->dev = &pdev->dev;
- ed->dev = &pdev->dev;
- platform_set_drvdata(pdev, ed);
- ed->dev_name = dev_name(&pdev->dev);
+ p->ed->dev_name = dev_name(&pdev->dev);
- ed->mod_name = "octeon-cpu";
- ed->ctl_name = "co_cpu_err";
+ p->ed->mod_name = "octeon-cpu";
+ p->ed->ctl_name = "cache";
- if (edac_device_add_device(ed) > 0) {
+ if (edac_device_add_device(p->ed)) {
pr_err("%s: edac_device_add_device() failed\n", __func__);
- goto err;
+ goto err1;
}
- register_co_cache_error_notifier(&co_cache_error_notifier);
- ed_cavium = ed;
+ register_co_cache_error_notifier(&p->notifier);
return 0;
+err1:
+ edac_device_free_ctl_info(p->ed);
err:
- edac_device_free_ctl_info(ed);
-
- return res;
+ return -ENXIO;
}
static int co_cache_error_remove(struct platform_device *pdev)
{
- struct edac_device_ctl_info *ed = platform_get_drvdata(pdev);
+ struct co_cache_error *p = platform_get_drvdata(pdev);
- unregister_co_cache_error_notifier(&co_cache_error_notifier);
- ed_cavium = NULL;
+ unregister_co_cache_error_notifier(&p->notifier);
edac_device_del_device(&pdev->dev);
- edac_device_free_ctl_info(ed);
-
+ edac_device_free_ctl_info(p->ed);
return 0;
}
@@ -113,28 +134,10 @@ static struct platform_driver co_cache_error_driver = {
.probe = co_cache_error_probe,
.remove = co_cache_error_remove,
.driver = {
- .name = "co_pc_edac",
+ .name = "octeon_pc_edac",
}
};
-
-static int __init co_edac_init(void)
-{
- int ret;
-
- ret = platform_driver_register(&co_cache_error_driver);
- if (ret)
- pr_warning(EDAC_MOD_STR "CPU err failed to register\n");
-
- return ret;
-}
-
-static void __exit co_edac_exit(void)
-{
- platform_driver_unregister(&co_cache_error_driver);
-}
-
-module_init(co_edac_init);
-module_exit(co_edac_exit);
+module_platform_driver(co_cache_error_driver);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>");