^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * License. See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2012 Cavium, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Copyright (C) 2009 Wind River Systems,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * written by Ralf Baechle <ralf@linux-mips.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/edac.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <asm/octeon/cvmx.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "edac_module.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define EDAC_MOD_STR "octeon-l2c"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static void octeon_l2c_poll_oct1(struct edac_device_ctl_info *l2c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) union cvmx_l2t_err l2t_err, l2t_err_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) union cvmx_l2d_err l2d_err, l2d_err_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) l2t_err_reset.u64 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) l2t_err.u64 = cvmx_read_csr(CVMX_L2T_ERR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) if (l2t_err.s.sec_err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) edac_device_handle_ce(l2c, 0, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) "Tag Single bit error (corrected)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) l2t_err_reset.s.sec_err = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) if (l2t_err.s.ded_err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) edac_device_handle_ue(l2c, 0, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) "Tag Double bit error (detected)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) l2t_err_reset.s.ded_err = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) if (l2t_err_reset.u64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) cvmx_write_csr(CVMX_L2T_ERR, l2t_err_reset.u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) l2d_err_reset.u64 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) l2d_err.u64 = cvmx_read_csr(CVMX_L2D_ERR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) if (l2d_err.s.sec_err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) edac_device_handle_ce(l2c, 0, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) "Data Single bit error (corrected)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) l2d_err_reset.s.sec_err = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) if (l2d_err.s.ded_err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) edac_device_handle_ue(l2c, 0, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) "Data Double bit error (detected)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) l2d_err_reset.s.ded_err = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) if (l2d_err_reset.u64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) cvmx_write_csr(CVMX_L2D_ERR, l2d_err_reset.u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static void _octeon_l2c_poll_oct2(struct edac_device_ctl_info *l2c, int tad)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) union cvmx_l2c_err_tdtx err_tdtx, err_tdtx_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) union cvmx_l2c_err_ttgx err_ttgx, err_ttgx_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) char buf1[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) char buf2[80];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) err_tdtx_reset.u64 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) err_tdtx.u64 = cvmx_read_csr(CVMX_L2C_ERR_TDTX(tad));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) if (err_tdtx.s.dbe || err_tdtx.s.sbe ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) err_tdtx.s.vdbe || err_tdtx.s.vsbe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) snprintf(buf1, sizeof(buf1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) "type:%d, syn:0x%x, way:%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) err_tdtx.s.type, err_tdtx.s.syn, err_tdtx.s.wayidx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) if (err_tdtx.s.dbe) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) snprintf(buf2, sizeof(buf2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) "L2D Double bit error (detected):%s", buf1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) err_tdtx_reset.s.dbe = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) edac_device_handle_ue(l2c, tad, 1, buf2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) if (err_tdtx.s.sbe) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) snprintf(buf2, sizeof(buf2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) "L2D Single bit error (corrected):%s", buf1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) err_tdtx_reset.s.sbe = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) edac_device_handle_ce(l2c, tad, 1, buf2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) if (err_tdtx.s.vdbe) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) snprintf(buf2, sizeof(buf2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) "VBF Double bit error (detected):%s", buf1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) err_tdtx_reset.s.vdbe = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) edac_device_handle_ue(l2c, tad, 1, buf2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) if (err_tdtx.s.vsbe) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) snprintf(buf2, sizeof(buf2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) "VBF Single bit error (corrected):%s", buf1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) err_tdtx_reset.s.vsbe = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) edac_device_handle_ce(l2c, tad, 1, buf2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) if (err_tdtx_reset.u64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) cvmx_write_csr(CVMX_L2C_ERR_TDTX(tad), err_tdtx_reset.u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) err_ttgx_reset.u64 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) err_ttgx.u64 = cvmx_read_csr(CVMX_L2C_ERR_TTGX(tad));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) if (err_ttgx.s.dbe || err_ttgx.s.sbe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) snprintf(buf1, sizeof(buf1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) "type:%d, syn:0x%x, way:%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) err_ttgx.s.type, err_ttgx.s.syn, err_ttgx.s.wayidx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) if (err_ttgx.s.dbe) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) snprintf(buf2, sizeof(buf2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) "Tag Double bit error (detected):%s", buf1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) err_ttgx_reset.s.dbe = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) edac_device_handle_ue(l2c, tad, 0, buf2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) if (err_ttgx.s.sbe) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) snprintf(buf2, sizeof(buf2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) "Tag Single bit error (corrected):%s", buf1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) err_ttgx_reset.s.sbe = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) edac_device_handle_ce(l2c, tad, 0, buf2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) if (err_ttgx_reset.u64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) cvmx_write_csr(CVMX_L2C_ERR_TTGX(tad), err_ttgx_reset.u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static void octeon_l2c_poll_oct2(struct edac_device_ctl_info *l2c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) for (i = 0; i < l2c->nr_instances; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) _octeon_l2c_poll_oct2(l2c, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static int octeon_l2c_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct edac_device_ctl_info *l2c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) int num_tads = OCTEON_IS_MODEL(OCTEON_CN68XX) ? 4 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /* 'Tags' are block 0, 'Data' is block 1*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) l2c = edac_device_alloc_ctl_info(0, "l2c", num_tads, "l2c", 2, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) NULL, 0, edac_device_alloc_index());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) if (!l2c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) l2c->dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) platform_set_drvdata(pdev, l2c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) l2c->dev_name = dev_name(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) l2c->mod_name = "octeon-l2c";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) l2c->ctl_name = "octeon_l2c_err";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) if (OCTEON_IS_OCTEON1PLUS()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) union cvmx_l2t_err l2t_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) union cvmx_l2d_err l2d_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) l2t_err.u64 = cvmx_read_csr(CVMX_L2T_ERR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) l2t_err.s.sec_intena = 0; /* We poll */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) l2t_err.s.ded_intena = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) cvmx_write_csr(CVMX_L2T_ERR, l2t_err.u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) l2d_err.u64 = cvmx_read_csr(CVMX_L2D_ERR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) l2d_err.s.sec_intena = 0; /* We poll */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) l2d_err.s.ded_intena = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) cvmx_write_csr(CVMX_L2T_ERR, l2d_err.u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) l2c->edac_check = octeon_l2c_poll_oct1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /* OCTEON II */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) l2c->edac_check = octeon_l2c_poll_oct2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (edac_device_add_device(l2c) > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) pr_err("%s: edac_device_add_device() failed\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) edac_device_free_ctl_info(l2c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) static int octeon_l2c_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) struct edac_device_ctl_info *l2c = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) edac_device_del_device(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) edac_device_free_ctl_info(l2c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) static struct platform_driver octeon_l2c_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) .probe = octeon_l2c_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) .remove = octeon_l2c_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) .name = "octeon_l2c_edac",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) module_platform_driver(octeon_l2c_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>");