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>
Цей коміт міститься в:
David Daney
2012-11-15 13:58:59 -08:00
зафіксовано Ralf Baechle
джерело abe105a4d8
коміт e1ced09797
8 змінених файлів з 408 додано та 337 видалено

Переглянути файл

@@ -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;
u64 icache_err = read_octeon_c0_icacheerr();
u64 dcache_err;
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());
if (icache_err & 1) {
edac_device_printk(ed, KERN_ERR, "CacheErr (Icache) == %llx\n",
(unsigned long long)icache_err);
write_octeon_c0_icacheerr(0);
edac_device_handle_ce(ed, 0, 0, ed->ctl_name);
}
if (cache_err_dcache[core] & 1) {
edac_device_printk(ed, KERN_ERR, "CacheErr (Dcache) == %llx\n",
(unsigned long long)cache_err_dcache[core]);
if (event) {
dcache_err = cache_err_dcache[core];
cache_err_dcache[core] = 0;
edac_device_handle_ue(ed, 0, 0, ed->ctl_name);
} else {
dcache_err = read_octeon_c0_dcacheerr();
}
return NOTIFY_DONE;
}
if (icache_err & 1) {
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(p->ed, cpu, 1, "icache");
}
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");
static struct notifier_block co_cache_error_notifier = {
.notifier_call = co_cache_error_event,
};
/* Clear the error indication */
if (OCTEON_IS_MODEL(OCTEON_FAM_2))
write_octeon_c0_dcacheerr(1);
else
write_octeon_c0_dcacheerr(0);
}
return NOTIFY_STOP;
}
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;
ed = edac_device_alloc_ctl_info(0, "cpu", 1, NULL, 0, 0, NULL, 0,
edac_device_alloc_index());
p->notifier.notifier_call = co_cache_error_event;
platform_set_drvdata(pdev, p);
ed->dev = &pdev->dev;
platform_set_drvdata(pdev, ed);
ed->dev_name = dev_name(&pdev->dev);
ed->mod_name = "octeon-cpu";
ed->ctl_name = "co_cpu_err";
if (edac_device_add_device(ed) > 0) {
pr_err("%s: edac_device_add_device() failed\n", __func__);
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;
p->ed->dev = &pdev->dev;
p->ed->dev_name = dev_name(&pdev->dev);
p->ed->mod_name = "octeon-cpu";
p->ed->ctl_name = "cache";
if (edac_device_add_device(p->ed)) {
pr_err("%s: edac_device_add_device() failed\n", __func__);
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>");