Skip to content

Commit

Permalink
MIPS/EDAC: Improve OCTEON EDAC support.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Daney authored and Ralf Baechle committed Dec 13, 2012
1 parent abe105a commit e1ced09
Show file tree
Hide file tree
Showing 8 changed files with 406 additions and 335 deletions.
30 changes: 26 additions & 4 deletions arch/mips/cavium-octeon/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,18 +1112,30 @@ void __init device_tree_init(void)
unflatten_device_tree();
}

static int __initdata disable_octeon_edac_p;

static int __init disable_octeon_edac(char *str)
{
disable_octeon_edac_p = 1;
return 0;
}
early_param("disable_octeon_edac", disable_octeon_edac);

static char *edac_device_names[] = {
"co_l2c_edac",
"co_lmc_edac",
"co_pc_edac",
"octeon_l2c_edac",
"octeon_pc_edac",
};

static int __init edac_devinit(void)
{
struct platform_device *dev;
int i, err = 0;
int num_lmc;
char *name;

if (disable_octeon_edac_p)
return 0;

for (i = 0; i < ARRAY_SIZE(edac_device_names); i++) {
name = edac_device_names[i];
dev = platform_device_register_simple(name, -1, NULL, 0);
Expand All @@ -1133,7 +1145,17 @@ static int __init edac_devinit(void)
}
}

num_lmc = OCTEON_IS_MODEL(OCTEON_CN68XX) ? 4 :
(OCTEON_IS_MODEL(OCTEON_CN56XX) ? 2 : 1);
for (i = 0; i < num_lmc; i++) {
dev = platform_device_register_simple("octeon_lmc_edac",
i, NULL, 0);
if (IS_ERR(dev)) {
pr_err("Registation of octeon_lmc_edac %d failed!\n", i);
err = PTR_ERR(dev);
}
}

return err;
}

device_initcall(edac_devinit);
39 changes: 30 additions & 9 deletions arch/mips/mm/c-octeon.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,9 @@ void __cpuinit octeon_cache_init(void)
board_cache_error_setup = octeon_cache_error_setup;
}

/**
/*
* Handle a cache error exception
*/

static RAW_NOTIFIER_HEAD(co_cache_error_chain);

int register_co_cache_error_notifier(struct notifier_block *nb)
Expand All @@ -304,26 +303,48 @@ int unregister_co_cache_error_notifier(struct notifier_block *nb)
}
EXPORT_SYMBOL_GPL(unregister_co_cache_error_notifier);

static inline int co_cache_error_call_notifiers(unsigned long val)
static void co_cache_error_call_notifiers(unsigned long val)
{
return raw_notifier_call_chain(&co_cache_error_chain, val, NULL);
int rv = raw_notifier_call_chain(&co_cache_error_chain, val, NULL);
if ((rv & ~NOTIFY_STOP_MASK) != NOTIFY_OK) {
u64 dcache_err;
unsigned long coreid = cvmx_get_core_num();
u64 icache_err = read_octeon_c0_icacheerr();

if (val) {
dcache_err = cache_err_dcache[coreid];
cache_err_dcache[coreid] = 0;
} else {
dcache_err = read_octeon_c0_dcacheerr();
}

pr_err("Core%lu: Cache error exception:\n", coreid);
pr_err("cp0_errorepc == %lx\n", read_c0_errorepc());
if (icache_err & 1) {
pr_err("CacheErr (Icache) == %llx\n",
(unsigned long long)icache_err);
write_octeon_c0_icacheerr(0);
}
if (dcache_err & 1) {
pr_err("CacheErr (Dcache) == %llx\n",
(unsigned long long)dcache_err);
}
}
}

/**
/*
* Called when the the exception is recoverable
*/

asmlinkage void cache_parity_error_octeon_recoverable(void)
{
co_cache_error_call_notifiers(0);
}

/**
* Called when the the exception is not recoverable
*
* The issue not that the cache error exception itself was non-recoverable
* but that due to nesting of exception may have lost some state so can't
* continue.
*/

asmlinkage void cache_parity_error_octeon_non_recoverable(void)
{
co_cache_error_call_notifiers(1);
Expand Down
3 changes: 2 additions & 1 deletion arch/mips/pci/pci-octeon.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ static int __init octeon_pci_setup(void)
*/
cvmx_write_csr(CVMX_NPI_PCI_INT_SUM2, -1);

if (IS_ERR(platform_device_register_simple("co_pci_edac", 0, NULL, 0)))
if (IS_ERR(platform_device_register_simple("octeon_pci_edac",
-1, NULL, 0)))
pr_err("Registation of co_pci_edac failed!\n");

octeon_pci_dma_init();
Expand Down
178 changes: 134 additions & 44 deletions drivers/edac/octeon_edac-l2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
*/
Expand All @@ -19,32 +21,124 @@

#define EDAC_MOD_STR "octeon-l2c"

static void co_l2c_poll(struct edac_device_ctl_info *l2c)
static void octeon_l2c_poll_oct1(struct edac_device_ctl_info *l2c)
{
union cvmx_l2t_err l2t_err;
union cvmx_l2t_err l2t_err, l2t_err_reset;
union cvmx_l2d_err l2d_err, l2d_err_reset;

l2t_err_reset.u64 = 0;
l2t_err.u64 = cvmx_read_csr(CVMX_L2T_ERR);
if (l2t_err.s.sec_err) {
edac_device_handle_ce(l2c, 0, 0,
"Single bit error (corrected)");
l2t_err.s.sec_err = 1; /* Reset */
cvmx_write_csr(CVMX_L2T_ERR, l2t_err.u64);
"Tag Single bit error (corrected)");
l2t_err_reset.s.sec_err = 1;
}
if (l2t_err.s.ded_err) {
edac_device_handle_ue(l2c, 0, 0,
"Double bit error (corrected)");
l2t_err.s.ded_err = 1; /* Reset */
cvmx_write_csr(CVMX_L2T_ERR, l2t_err.u64);
"Tag Double bit error (detected)");
l2t_err_reset.s.ded_err = 1;
}
if (l2t_err_reset.u64)
cvmx_write_csr(CVMX_L2T_ERR, l2t_err_reset.u64);

l2d_err_reset.u64 = 0;
l2d_err.u64 = cvmx_read_csr(CVMX_L2D_ERR);
if (l2d_err.s.sec_err) {
edac_device_handle_ce(l2c, 0, 1,
"Data Single bit error (corrected)");
l2d_err_reset.s.sec_err = 1;
}
if (l2d_err.s.ded_err) {
edac_device_handle_ue(l2c, 0, 1,
"Data Double bit error (detected)");
l2d_err_reset.s.ded_err = 1;
}
if (l2d_err_reset.u64)
cvmx_write_csr(CVMX_L2D_ERR, l2d_err_reset.u64);

}

static void _octeon_l2c_poll_oct2(struct edac_device_ctl_info *l2c, int tad)
{
union cvmx_l2c_err_tdtx err_tdtx, err_tdtx_reset;
union cvmx_l2c_err_ttgx err_ttgx, err_ttgx_reset;
char buf1[64];
char buf2[80];

err_tdtx_reset.u64 = 0;
err_tdtx.u64 = cvmx_read_csr(CVMX_L2C_ERR_TDTX(tad));
if (err_tdtx.s.dbe || err_tdtx.s.sbe ||
err_tdtx.s.vdbe || err_tdtx.s.vsbe)
snprintf(buf1, sizeof(buf1),
"type:%d, syn:0x%x, way:%d",
err_tdtx.s.type, err_tdtx.s.syn, err_tdtx.s.wayidx);

if (err_tdtx.s.dbe) {
snprintf(buf2, sizeof(buf2),
"L2D Double bit error (detected):%s", buf1);
err_tdtx_reset.s.dbe = 1;
edac_device_handle_ue(l2c, tad, 1, buf2);
}
if (err_tdtx.s.sbe) {
snprintf(buf2, sizeof(buf2),
"L2D Single bit error (corrected):%s", buf1);
err_tdtx_reset.s.sbe = 1;
edac_device_handle_ce(l2c, tad, 1, buf2);
}
if (err_tdtx.s.vdbe) {
snprintf(buf2, sizeof(buf2),
"VBF Double bit error (detected):%s", buf1);
err_tdtx_reset.s.vdbe = 1;
edac_device_handle_ue(l2c, tad, 1, buf2);
}
if (err_tdtx.s.vsbe) {
snprintf(buf2, sizeof(buf2),
"VBF Single bit error (corrected):%s", buf1);
err_tdtx_reset.s.vsbe = 1;
edac_device_handle_ce(l2c, tad, 1, buf2);
}
if (err_tdtx_reset.u64)
cvmx_write_csr(CVMX_L2C_ERR_TDTX(tad), err_tdtx_reset.u64);

err_ttgx_reset.u64 = 0;
err_ttgx.u64 = cvmx_read_csr(CVMX_L2C_ERR_TTGX(tad));

if (err_ttgx.s.dbe || err_ttgx.s.sbe)
snprintf(buf1, sizeof(buf1),
"type:%d, syn:0x%x, way:%d",
err_ttgx.s.type, err_ttgx.s.syn, err_ttgx.s.wayidx);

if (err_ttgx.s.dbe) {
snprintf(buf2, sizeof(buf2),
"Tag Double bit error (detected):%s", buf1);
err_ttgx_reset.s.dbe = 1;
edac_device_handle_ue(l2c, tad, 0, buf2);
}
if (err_ttgx.s.sbe) {
snprintf(buf2, sizeof(buf2),
"Tag Single bit error (corrected):%s", buf1);
err_ttgx_reset.s.sbe = 1;
edac_device_handle_ce(l2c, tad, 0, buf2);
}
if (err_ttgx_reset.u64)
cvmx_write_csr(CVMX_L2C_ERR_TTGX(tad), err_ttgx_reset.u64);
}

static void octeon_l2c_poll_oct2(struct edac_device_ctl_info *l2c)
{
int i;
for (i = 0; i < l2c->nr_instances; i++)
_octeon_l2c_poll_oct2(l2c, i);
}

static int __devinit co_l2c_probe(struct platform_device *pdev)
static int __devinit octeon_l2c_probe(struct platform_device *pdev)
{
struct edac_device_ctl_info *l2c;
union cvmx_l2t_err l2t_err;
int res = 0;

l2c = edac_device_alloc_ctl_info(0, "l2c", 1, NULL, 0, 0,
int num_tads = OCTEON_IS_MODEL(OCTEON_CN68XX) ? 4 : 1;

/* 'Tags' are block 0, 'Data' is block 1*/
l2c = edac_device_alloc_ctl_info(0, "l2c", num_tads, "l2c", 2, 0,
NULL, 0, edac_device_alloc_index());
if (!l2c)
return -ENOMEM;
Expand All @@ -55,29 +149,43 @@ static int __devinit co_l2c_probe(struct platform_device *pdev)

l2c->mod_name = "octeon-l2c";
l2c->ctl_name = "octeon_l2c_err";
l2c->edac_check = co_l2c_poll;


if (OCTEON_IS_MODEL(OCTEON_FAM_1_PLUS)) {
union cvmx_l2t_err l2t_err;
union cvmx_l2d_err l2d_err;

l2t_err.u64 = cvmx_read_csr(CVMX_L2T_ERR);
l2t_err.s.sec_intena = 0; /* We poll */
l2t_err.s.ded_intena = 0;
cvmx_write_csr(CVMX_L2T_ERR, l2t_err.u64);

l2d_err.u64 = cvmx_read_csr(CVMX_L2D_ERR);
l2d_err.s.sec_intena = 0; /* We poll */
l2d_err.s.ded_intena = 0;
cvmx_write_csr(CVMX_L2T_ERR, l2d_err.u64);

l2c->edac_check = octeon_l2c_poll_oct1;
} else {
/* OCTEON II */
l2c->edac_check = octeon_l2c_poll_oct2;
}

if (edac_device_add_device(l2c) > 0) {
pr_err("%s: edac_device_add_device() failed\n", __func__);
goto err;
}

l2t_err.u64 = cvmx_read_csr(CVMX_L2T_ERR);
l2t_err.s.sec_intena = 0; /* We poll */
l2t_err.s.ded_intena = 0;
l2t_err.s.sec_err = 1; /* Clear, just in case */
l2t_err.s.ded_err = 1;
cvmx_write_csr(CVMX_L2T_ERR, l2t_err.u64);

return 0;

err:
edac_device_free_ctl_info(l2c);

return res;
return -ENXIO;
}

static int co_l2c_remove(struct platform_device *pdev)
static int octeon_l2c_remove(struct platform_device *pdev)
{
struct edac_device_ctl_info *l2c = platform_get_drvdata(pdev);

Expand All @@ -87,32 +195,14 @@ static int co_l2c_remove(struct platform_device *pdev)
return 0;
}

static struct platform_driver co_l2c_driver = {
.probe = co_l2c_probe,
.remove = co_l2c_remove,
static struct platform_driver octeon_l2c_driver = {
.probe = octeon_l2c_probe,
.remove = octeon_l2c_remove,
.driver = {
.name = "co_l2c_edac",
.name = "octeon_l2c_edac",
}
};

static int __init co_edac_init(void)
{
int ret;

ret = platform_driver_register(&co_l2c_driver);
if (ret)
pr_warning(EDAC_MOD_STR " EDAC failed to register\n");

return ret;
}

static void __exit co_edac_exit(void)
{
platform_driver_unregister(&co_l2c_driver);
}

module_init(co_edac_init);
module_exit(co_edac_exit);
module_platform_driver(octeon_l2c_driver);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>");
Loading

0 comments on commit e1ced09

Please sign in to comment.