Lines Matching +full:lane +full:- +full:count
8 * Copyright Cavium, Inc. (C) 2015-2017. All rights reserved.
50 while (descr->type && descr->mask && descr->descr) { in decode_register()
51 if (reg & descr->mask) { in decode_register()
53 descr->type == ERR_CORRECTED ? in decode_register()
55 descr->descr); in decode_register()
57 size -= ret; in decode_register()
65 return (data >> pos) & ((1 << width) - 1); in get_bits()
121 .descr = "Single-bit ECC error",
131 .descr = "Double-bit ECC error",
136 .descr = "Non-existent memory write",
208 #define ring_pos(pos, size) ((pos) & (size - 1))
225 size_t count, loff_t *ppos) \
227 struct thunderx_##_type *pdata = file->private_data; \
230 snprintf(buf, count, "0x%016llx", pdata->_field); \
231 return simple_read_from_buffer(data, count, ppos, \
237 size_t count, loff_t *ppos) \
239 struct thunderx_##_type *pdata = file->private_data; \
242 res = kstrtoull_from_user(data, count, 0, &pdata->_field); \
244 return res ? res : count; \
254 size_t count, loff_t *ppos) \
256 struct thunderx_##_type *pdata = file->private_data; \
259 sprintf(buf, "0x%016llx", readq(pdata->regs + _reg)); \
260 return simple_read_from_buffer(data, count, ppos, \
266 size_t count, loff_t *ppos) \
268 struct thunderx_##_type *pdata = file->private_data; \
272 res = kstrtoull_from_user(data, count, 0, &val); \
275 writeq(val, pdata->regs + _reg); \
276 res = count; \
290 * - Setup the ECC injection by writing the appropriate parameters:
294 * - Do the actual injection:
299 size_t count, loff_t *ppos) in thunderx_lmc_inject_int_write() argument
301 struct thunderx_lmc *lmc = file->private_data; in thunderx_lmc_inject_int_write()
305 res = kstrtoull_from_user(data, count, 0, &val); in thunderx_lmc_inject_int_write()
309 writeq(val, lmc->regs + LMC_INT_W1S); in thunderx_lmc_inject_int_write()
310 res = count; in thunderx_lmc_inject_int_write()
318 size_t count, loff_t *ppos) in thunderx_lmc_int_read() argument
320 struct thunderx_lmc *lmc = file->private_data; in thunderx_lmc_int_read()
322 u64 lmc_int = readq(lmc->regs + LMC_INT); in thunderx_lmc_int_read()
325 return simple_read_from_buffer(data, count, ppos, buf, sizeof(buf)); in thunderx_lmc_int_read()
338 addr = (uintptr_t)page_address(lmc->mem); in inject_ecc_fn()
339 phys = (uintptr_t)page_to_phys(lmc->mem); in inject_ecc_fn()
342 lmc->parity_test &= ~(7ULL << 8); in inject_ecc_fn()
343 lmc->parity_test |= (cl_idx << 8); in inject_ecc_fn()
345 writeq(lmc->mask0, lmc->regs + LMC_CHAR_MASK0); in inject_ecc_fn()
346 writeq(lmc->mask2, lmc->regs + LMC_CHAR_MASK2); in inject_ecc_fn()
347 writeq(lmc->parity_test, lmc->regs + LMC_ECC_PARITY_TEST); in inject_ecc_fn()
349 readq(lmc->regs + LMC_CHAR_MASK0); in inject_ecc_fn()
350 readq(lmc->regs + LMC_CHAR_MASK2); in inject_ecc_fn()
351 readq(lmc->regs + LMC_ECC_PARITY_TEST); in inject_ecc_fn()
402 size_t count, loff_t *ppos) in thunderx_lmc_inject_ecc_write() argument
404 struct thunderx_lmc *lmc = file->private_data; in thunderx_lmc_inject_ecc_write()
410 atomic_set(&lmc->ecc_int, 0); in thunderx_lmc_inject_ecc_write()
412 lmc->mem = alloc_pages_node(lmc->node, GFP_KERNEL, 0); in thunderx_lmc_inject_ecc_write()
413 if (!lmc->mem) in thunderx_lmc_inject_ecc_write()
414 return -ENOMEM; in thunderx_lmc_inject_ecc_write()
418 __free_pages(lmc->mem, 0); in thunderx_lmc_inject_ecc_write()
419 return -ENOMEM; in thunderx_lmc_inject_ecc_write()
422 addr = page_address(lmc->mem); in thunderx_lmc_inject_ecc_write()
424 while (!atomic_read(&lmc->ecc_int) && timeout--) { in thunderx_lmc_inject_ecc_write()
438 __free_pages(lmc->mem, 0); in thunderx_lmc_inject_ecc_write()
440 return count; in thunderx_lmc_inject_ecc_write()
472 return -ENOENT; in thunderx_create_debugfs_nodes()
475 ent = edac_debugfs_create_file(attrs[i]->name, attrs[i]->mode, in thunderx_create_debugfs_nodes()
476 parent, data, &attrs[i]->fops); in thunderx_create_debugfs_nodes()
490 addr |= lmc->node << 40; in thunderx_faddr_to_phys()
491 addr |= LMC_FADR_FDIMM(faddr) << lmc->dimm_lsb; in thunderx_faddr_to_phys()
492 addr |= LMC_FADR_FBUNK(faddr) << lmc->rank_lsb; in thunderx_faddr_to_phys()
493 addr |= LMC_FADR_FROW(faddr) << lmc->row_lsb; in thunderx_faddr_to_phys()
494 addr |= (LMC_FADR_FCOL(faddr) >> 4) << lmc->col_hi_lsb; in thunderx_faddr_to_phys()
496 bank = LMC_FADR_FBANK(faddr) << lmc->bank_lsb; in thunderx_faddr_to_phys()
498 if (lmc->xor_bank) in thunderx_faddr_to_phys()
499 bank ^= get_bits(addr, 12 + lmc->xbits, lmc->bank_width); in thunderx_faddr_to_phys()
501 addr |= bank << lmc->bank_lsb; in thunderx_faddr_to_phys()
503 xbits = PCI_FUNC(lmc->pdev->devfn); in thunderx_faddr_to_phys()
505 if (lmc->l2c_alias) in thunderx_faddr_to_phys()
506 xbits ^= get_bits(addr, 20, lmc->xbits) ^ in thunderx_faddr_to_phys()
507 get_bits(addr, 12, lmc->xbits); in thunderx_faddr_to_phys()
525 if (pdev->dev.numa_node == node) in thunderx_get_num_lmcs()
542 struct thunderx_lmc *lmc = mci->pvt_info; in thunderx_lmc_err_isr()
544 unsigned long head = ring_pos(lmc->ring_head, ARRAY_SIZE(lmc->err_ctx)); in thunderx_lmc_err_isr()
545 struct lmc_err_ctx *ctx = &lmc->err_ctx[head]; in thunderx_lmc_err_isr()
547 writeq(0, lmc->regs + LMC_CHAR_MASK0); in thunderx_lmc_err_isr()
548 writeq(0, lmc->regs + LMC_CHAR_MASK2); in thunderx_lmc_err_isr()
549 writeq(0x2, lmc->regs + LMC_ECC_PARITY_TEST); in thunderx_lmc_err_isr()
551 ctx->reg_int = readq(lmc->regs + LMC_INT); in thunderx_lmc_err_isr()
552 ctx->reg_fadr = readq(lmc->regs + LMC_FADR); in thunderx_lmc_err_isr()
553 ctx->reg_nxm_fadr = readq(lmc->regs + LMC_NXM_FADR); in thunderx_lmc_err_isr()
554 ctx->reg_scram_fadr = readq(lmc->regs + LMC_SCRAM_FADR); in thunderx_lmc_err_isr()
555 ctx->reg_ecc_synd = readq(lmc->regs + LMC_ECC_SYND); in thunderx_lmc_err_isr()
557 lmc->ring_head++; in thunderx_lmc_err_isr()
559 atomic_set(&lmc->ecc_int, 1); in thunderx_lmc_err_isr()
562 writeq(ctx->reg_int, lmc->regs + LMC_INT); in thunderx_lmc_err_isr()
570 struct thunderx_lmc *lmc = mci->pvt_info; in thunderx_lmc_threaded_isr()
587 while (CIRC_CNT(lmc->ring_head, lmc->ring_tail, in thunderx_lmc_threaded_isr()
588 ARRAY_SIZE(lmc->err_ctx))) { in thunderx_lmc_threaded_isr()
589 tail = ring_pos(lmc->ring_tail, ARRAY_SIZE(lmc->err_ctx)); in thunderx_lmc_threaded_isr()
591 ctx = &lmc->err_ctx[tail]; in thunderx_lmc_threaded_isr()
593 dev_dbg(&lmc->pdev->dev, "LMC_INT: %016llx\n", in thunderx_lmc_threaded_isr()
594 ctx->reg_int); in thunderx_lmc_threaded_isr()
595 dev_dbg(&lmc->pdev->dev, "LMC_FADR: %016llx\n", in thunderx_lmc_threaded_isr()
596 ctx->reg_fadr); in thunderx_lmc_threaded_isr()
597 dev_dbg(&lmc->pdev->dev, "LMC_NXM_FADR: %016llx\n", in thunderx_lmc_threaded_isr()
598 ctx->reg_nxm_fadr); in thunderx_lmc_threaded_isr()
599 dev_dbg(&lmc->pdev->dev, "LMC_SCRAM_FADR: %016llx\n", in thunderx_lmc_threaded_isr()
600 ctx->reg_scram_fadr); in thunderx_lmc_threaded_isr()
601 dev_dbg(&lmc->pdev->dev, "LMC_ECC_SYND: %016llx\n", in thunderx_lmc_threaded_isr()
602 ctx->reg_ecc_synd); in thunderx_lmc_threaded_isr()
606 LMC_FADR_FDIMM(ctx->reg_scram_fadr), in thunderx_lmc_threaded_isr()
607 LMC_FADR_FBUNK(ctx->reg_scram_fadr), in thunderx_lmc_threaded_isr()
608 LMC_FADR_FBANK(ctx->reg_scram_fadr), in thunderx_lmc_threaded_isr()
609 LMC_FADR_FROW(ctx->reg_scram_fadr), in thunderx_lmc_threaded_isr()
610 LMC_FADR_FCOL(ctx->reg_scram_fadr)); in thunderx_lmc_threaded_isr()
613 ctx->reg_int); in thunderx_lmc_threaded_isr()
615 phys_addr = thunderx_faddr_to_phys(ctx->reg_fadr, lmc); in thunderx_lmc_threaded_isr()
617 if (ctx->reg_int & LMC_INT_UE) in thunderx_lmc_threaded_isr()
621 0, -1, -1, -1, msg, other); in thunderx_lmc_threaded_isr()
622 else if (ctx->reg_int & LMC_INT_CE) in thunderx_lmc_threaded_isr()
626 0, -1, -1, -1, msg, other); in thunderx_lmc_threaded_isr()
628 lmc->ring_tail++; in thunderx_lmc_threaded_isr()
647 int node = dev_to_node(&pdev->dev); in pci_dev_to_mc_idx()
648 int ret = PCI_FUNC(pdev->devfn); in pci_dev_to_mc_idx()
672 dev_err(&pdev->dev, "Cannot enable PCI device: %d\n", ret); in thunderx_lmc_probe()
678 dev_err(&pdev->dev, "Cannot map PCI resources: %d\n", ret); in thunderx_lmc_probe()
685 return -ENOMEM; in thunderx_lmc_probe()
687 mci->pdev = &pdev->dev; in thunderx_lmc_probe()
688 lmc = mci->pvt_info; in thunderx_lmc_probe()
692 lmc->regs = pcim_iomap_table(pdev)[0]; in thunderx_lmc_probe()
694 lmc_control = readq(lmc->regs + LMC_CONTROL); in thunderx_lmc_probe()
695 lmc_ddr_pll_ctl = readq(lmc->regs + LMC_DDR_PLL_CTL); in thunderx_lmc_probe()
696 lmc_config = readq(lmc->regs + LMC_CONFIG); in thunderx_lmc_probe()
699 mci->mtype_cap = FIELD_GET(LMC_DDR_PLL_CTL_DDR4, in thunderx_lmc_probe()
703 mci->mtype_cap = FIELD_GET(LMC_DDR_PLL_CTL_DDR4, in thunderx_lmc_probe()
708 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; in thunderx_lmc_probe()
709 mci->edac_cap = EDAC_FLAG_SECDED; in thunderx_lmc_probe()
711 mci->mod_name = "thunderx-lmc"; in thunderx_lmc_probe()
712 mci->ctl_name = "thunderx-lmc"; in thunderx_lmc_probe()
713 mci->dev_name = dev_name(&pdev->dev); in thunderx_lmc_probe()
714 mci->scrub_mode = SCRUB_NONE; in thunderx_lmc_probe()
716 lmc->pdev = pdev; in thunderx_lmc_probe()
717 lmc->msix_ent.entry = 0; in thunderx_lmc_probe()
719 lmc->ring_head = 0; in thunderx_lmc_probe()
720 lmc->ring_tail = 0; in thunderx_lmc_probe()
722 ret = pci_enable_msix_exact(pdev, &lmc->msix_ent, 1); in thunderx_lmc_probe()
724 dev_err(&pdev->dev, "Cannot enable interrupt: %d\n", ret); in thunderx_lmc_probe()
728 ret = devm_request_threaded_irq(&pdev->dev, lmc->msix_ent.vector, in thunderx_lmc_probe()
733 dev_err(&pdev->dev, "Cannot set ISR: %d\n", ret); in thunderx_lmc_probe()
737 lmc->node = FIELD_GET(THUNDERX_NODE, pci_resource_start(pdev, 0)); in thunderx_lmc_probe()
739 lmc->xbits = thunderx_get_num_lmcs(lmc->node) >> 1; in thunderx_lmc_probe()
740 lmc->bank_width = (FIELD_GET(LMC_DDR_PLL_CTL_DDR4, lmc_ddr_pll_ctl) && in thunderx_lmc_probe()
743 lmc->pbank_lsb = (lmc_config >> 5) & 0xf; in thunderx_lmc_probe()
744 lmc->dimm_lsb = 28 + lmc->pbank_lsb + lmc->xbits; in thunderx_lmc_probe()
745 lmc->rank_lsb = lmc->dimm_lsb; in thunderx_lmc_probe()
746 lmc->rank_lsb -= FIELD_GET(LMC_CONFIG_RANK_ENA, lmc_config) ? 1 : 0; in thunderx_lmc_probe()
747 lmc->bank_lsb = 7 + lmc->xbits; in thunderx_lmc_probe()
748 lmc->row_lsb = 14 + LMC_CONFIG_ROW_LSB(lmc_config) + lmc->xbits; in thunderx_lmc_probe()
750 lmc->col_hi_lsb = lmc->bank_lsb + lmc->bank_width; in thunderx_lmc_probe()
752 lmc->xor_bank = lmc_control & LMC_CONTROL_XOR_BANK; in thunderx_lmc_probe()
754 l2c_ioaddr = ioremap(L2C_CTL | FIELD_PREP(THUNDERX_NODE, lmc->node), PAGE_SIZE); in thunderx_lmc_probe()
756 dev_err(&pdev->dev, "Cannot map L2C_CTL\n"); in thunderx_lmc_probe()
757 ret = -ENOMEM; in thunderx_lmc_probe()
761 lmc->l2c_alias = !(readq(l2c_ioaddr) & L2C_CTL_DISIDXALIAS); in thunderx_lmc_probe()
767 dev_err(&pdev->dev, "Cannot add the MC: %d\n", ret); in thunderx_lmc_probe()
771 lmc_int = readq(lmc->regs + LMC_INT); in thunderx_lmc_probe()
772 writeq(lmc_int, lmc->regs + LMC_INT); in thunderx_lmc_probe()
774 writeq(LMC_INT_ENA_ALL, lmc->regs + LMC_INT_ENA_W1S); in thunderx_lmc_probe()
777 ret = thunderx_create_debugfs_nodes(mci->debugfs, in thunderx_lmc_probe()
783 dev_warn(&pdev->dev, "Error creating debugfs entries: %d%s\n", in thunderx_lmc_probe()
800 struct thunderx_lmc *lmc = mci->pvt_info; in thunderx_lmc_remove()
802 writeq(LMC_INT_ENA_ALL, lmc->regs + LMC_INT_ENA_W1C); in thunderx_lmc_remove()
804 edac_mc_del_mc(&pdev->dev); in thunderx_lmc_remove()
817 /*---------------------- OCX driver ---------------------------------*/
897 .descr = "Replay buffer single-bit error",
902 .descr = "TX FIFO single-bit error",
907 .descr = "RX FIFO single-bit error",
927 .descr = "Replay buffer double-bit error",
932 .descr = "TX FIFO double-bit error",
937 .descr = "RX FIFO double-bit error",
1073 msix_ent[msix->entry]); in thunderx_ocx_com_isr()
1075 int lane; in thunderx_ocx_com_isr() local
1076 unsigned long head = ring_pos(ocx->com_ring_head, in thunderx_ocx_com_isr()
1077 ARRAY_SIZE(ocx->com_err_ctx)); in thunderx_ocx_com_isr()
1078 struct ocx_com_err_ctx *ctx = &ocx->com_err_ctx[head]; in thunderx_ocx_com_isr()
1080 ctx->reg_com_int = readq(ocx->regs + OCX_COM_INT); in thunderx_ocx_com_isr()
1082 for (lane = 0; lane < OCX_RX_LANES; lane++) { in thunderx_ocx_com_isr()
1083 ctx->reg_lane_int[lane] = in thunderx_ocx_com_isr()
1084 readq(ocx->regs + OCX_LNE_INT(lane)); in thunderx_ocx_com_isr()
1085 ctx->reg_lane_stat11[lane] = in thunderx_ocx_com_isr()
1086 readq(ocx->regs + OCX_LNE_STAT(lane, 11)); in thunderx_ocx_com_isr()
1088 writeq(ctx->reg_lane_int[lane], ocx->regs + OCX_LNE_INT(lane)); in thunderx_ocx_com_isr()
1091 writeq(ctx->reg_com_int, ocx->regs + OCX_COM_INT); in thunderx_ocx_com_isr()
1093 ocx->com_ring_head++; in thunderx_ocx_com_isr()
1102 msix_ent[msix->entry]); in thunderx_ocx_com_threaded_isr()
1108 int lane; in thunderx_ocx_com_threaded_isr() local
1118 while (CIRC_CNT(ocx->com_ring_head, ocx->com_ring_tail, in thunderx_ocx_com_threaded_isr()
1119 ARRAY_SIZE(ocx->com_err_ctx))) { in thunderx_ocx_com_threaded_isr()
1120 tail = ring_pos(ocx->com_ring_tail, in thunderx_ocx_com_threaded_isr()
1121 ARRAY_SIZE(ocx->com_err_ctx)); in thunderx_ocx_com_threaded_isr()
1122 ctx = &ocx->com_err_ctx[tail]; in thunderx_ocx_com_threaded_isr()
1125 ocx->edac_dev->ctl_name, ctx->reg_com_int); in thunderx_ocx_com_threaded_isr()
1128 ocx_com_errors, ctx->reg_com_int); in thunderx_ocx_com_threaded_isr()
1132 for (lane = 0; lane < OCX_RX_LANES; lane++) in thunderx_ocx_com_threaded_isr()
1133 if (ctx->reg_com_int & BIT(lane)) { in thunderx_ocx_com_threaded_isr()
1136 lane, ctx->reg_lane_int[lane], in thunderx_ocx_com_threaded_isr()
1137 lane, ctx->reg_lane_stat11[lane]); in thunderx_ocx_com_threaded_isr()
1143 ctx->reg_lane_int[lane]); in thunderx_ocx_com_threaded_isr()
1147 if (ctx->reg_com_int & OCX_COM_INT_CE) in thunderx_ocx_com_threaded_isr()
1148 edac_device_handle_ce(ocx->edac_dev, 0, 0, msg); in thunderx_ocx_com_threaded_isr()
1150 ocx->com_ring_tail++; in thunderx_ocx_com_threaded_isr()
1166 msix_ent[msix->entry]); in thunderx_ocx_lnk_isr()
1167 unsigned long head = ring_pos(ocx->link_ring_head, in thunderx_ocx_lnk_isr()
1168 ARRAY_SIZE(ocx->link_err_ctx)); in thunderx_ocx_lnk_isr()
1169 struct ocx_link_err_ctx *ctx = &ocx->link_err_ctx[head]; in thunderx_ocx_lnk_isr()
1171 ctx->link = msix->entry; in thunderx_ocx_lnk_isr()
1172 ctx->reg_com_link_int = readq(ocx->regs + OCX_COM_LINKX_INT(ctx->link)); in thunderx_ocx_lnk_isr()
1174 writeq(ctx->reg_com_link_int, ocx->regs + OCX_COM_LINKX_INT(ctx->link)); in thunderx_ocx_lnk_isr()
1176 ocx->link_ring_head++; in thunderx_ocx_lnk_isr()
1185 msix_ent[msix->entry]); in thunderx_ocx_lnk_threaded_isr()
1199 while (CIRC_CNT(ocx->link_ring_head, ocx->link_ring_tail, in thunderx_ocx_lnk_threaded_isr()
1200 ARRAY_SIZE(ocx->link_err_ctx))) { in thunderx_ocx_lnk_threaded_isr()
1201 tail = ring_pos(ocx->link_ring_head, in thunderx_ocx_lnk_threaded_isr()
1202 ARRAY_SIZE(ocx->link_err_ctx)); in thunderx_ocx_lnk_threaded_isr()
1204 ctx = &ocx->link_err_ctx[tail]; in thunderx_ocx_lnk_threaded_isr()
1208 ocx->edac_dev->ctl_name, in thunderx_ocx_lnk_threaded_isr()
1209 ctx->link, ctx->reg_com_link_int); in thunderx_ocx_lnk_threaded_isr()
1212 ocx_com_link_errors, ctx->reg_com_link_int); in thunderx_ocx_lnk_threaded_isr()
1216 if (ctx->reg_com_link_int & OCX_COM_LINK_INT_UE) in thunderx_ocx_lnk_threaded_isr()
1217 edac_device_handle_ue(ocx->edac_dev, 0, 0, msg); in thunderx_ocx_lnk_threaded_isr()
1218 else if (ctx->reg_com_link_int & OCX_COM_LINK_INT_CE) in thunderx_ocx_lnk_threaded_isr()
1219 edac_device_handle_ce(ocx->edac_dev, 0, 0, msg); in thunderx_ocx_lnk_threaded_isr()
1221 ocx->link_ring_tail++; in thunderx_ocx_lnk_threaded_isr()
1323 int lane, stat, cfg; in thunderx_ocx_clearstats() local
1325 for (lane = 0; lane < OCX_RX_LANES; lane++) { in thunderx_ocx_clearstats()
1326 cfg = readq(ocx->regs + OCX_LNE_CFG(lane)); in thunderx_ocx_clearstats()
1329 writeq(cfg, ocx->regs + OCX_LNE_CFG(lane)); in thunderx_ocx_clearstats()
1332 readq(ocx->regs + OCX_LNE_STAT(lane, stat)); in thunderx_ocx_clearstats()
1349 dev_err(&pdev->dev, "Cannot enable PCI device: %d\n", ret); in thunderx_ocx_probe()
1355 dev_err(&pdev->dev, "Cannot map PCI resources: %d\n", ret); in thunderx_ocx_probe()
1364 dev_err(&pdev->dev, "Cannot allocate EDAC device\n"); in thunderx_ocx_probe()
1365 return -ENOMEM; in thunderx_ocx_probe()
1367 ocx = edac_dev->pvt_info; in thunderx_ocx_probe()
1368 ocx->edac_dev = edac_dev; in thunderx_ocx_probe()
1369 ocx->com_ring_head = 0; in thunderx_ocx_probe()
1370 ocx->com_ring_tail = 0; in thunderx_ocx_probe()
1371 ocx->link_ring_head = 0; in thunderx_ocx_probe()
1372 ocx->link_ring_tail = 0; in thunderx_ocx_probe()
1374 ocx->regs = pcim_iomap_table(pdev)[0]; in thunderx_ocx_probe()
1375 if (!ocx->regs) { in thunderx_ocx_probe()
1376 dev_err(&pdev->dev, "Cannot map PCI resources\n"); in thunderx_ocx_probe()
1377 ret = -ENODEV; in thunderx_ocx_probe()
1381 ocx->pdev = pdev; in thunderx_ocx_probe()
1384 ocx->msix_ent[i].entry = i; in thunderx_ocx_probe()
1385 ocx->msix_ent[i].vector = 0; in thunderx_ocx_probe()
1388 ret = pci_enable_msix_exact(pdev, ocx->msix_ent, OCX_INTS); in thunderx_ocx_probe()
1390 dev_err(&pdev->dev, "Cannot enable interrupt: %d\n", ret); in thunderx_ocx_probe()
1395 ret = devm_request_threaded_irq(&pdev->dev, in thunderx_ocx_probe()
1396 ocx->msix_ent[i].vector, in thunderx_ocx_probe()
1404 &ocx->msix_ent[i]); in thunderx_ocx_probe()
1409 edac_dev->dev = &pdev->dev; in thunderx_ocx_probe()
1410 edac_dev->dev_name = dev_name(&pdev->dev); in thunderx_ocx_probe()
1411 edac_dev->mod_name = "thunderx-ocx"; in thunderx_ocx_probe()
1412 edac_dev->ctl_name = "thunderx-ocx"; in thunderx_ocx_probe()
1416 dev_err(&pdev->dev, "Cannot add EDAC device: %d\n", ret); in thunderx_ocx_probe()
1421 ocx->debugfs = edac_debugfs_create_dir(pdev->dev.kobj.name); in thunderx_ocx_probe()
1423 ret = thunderx_create_debugfs_nodes(ocx->debugfs, in thunderx_ocx_probe()
1428 dev_warn(&pdev->dev, "Error creating debugfs entries: %d%s\n", in thunderx_ocx_probe()
1439 ocx->regs + OCX_LNE_INT_EN(i)); in thunderx_ocx_probe()
1441 reg = readq(ocx->regs + OCX_LNE_INT(i)); in thunderx_ocx_probe()
1442 writeq(reg, ocx->regs + OCX_LNE_INT(i)); in thunderx_ocx_probe()
1447 reg = readq(ocx->regs + OCX_COM_LINKX_INT(i)); in thunderx_ocx_probe()
1448 writeq(reg, ocx->regs + OCX_COM_LINKX_INT(i)); in thunderx_ocx_probe()
1451 ocx->regs + OCX_COM_LINKX_INT_ENA_W1S(i)); in thunderx_ocx_probe()
1454 reg = readq(ocx->regs + OCX_COM_INT); in thunderx_ocx_probe()
1455 writeq(reg, ocx->regs + OCX_COM_INT); in thunderx_ocx_probe()
1457 writeq(OCX_COM_INT_ENA_ALL, ocx->regs + OCX_COM_INT_ENA_W1S); in thunderx_ocx_probe()
1469 struct thunderx_ocx *ocx = edac_dev->pvt_info; in thunderx_ocx_remove()
1472 writeq(OCX_COM_INT_ENA_ALL, ocx->regs + OCX_COM_INT_ENA_W1C); in thunderx_ocx_remove()
1476 ocx->regs + OCX_COM_LINKX_INT_ENA_W1C(i)); in thunderx_ocx_remove()
1479 edac_debugfs_remove_recursive(ocx->debugfs); in thunderx_ocx_remove()
1481 edac_device_del_device(&pdev->dev); in thunderx_ocx_remove()
1494 /*---------------------- L2C driver ---------------------------------*/
1545 .descr = "SBF single-bit error",
1550 .descr = "FBF single-bit error",
1555 .descr = "L2D double-bit error",
1560 .descr = "SBF double-bit error",
1565 .descr = "FBF double-bit error",
1570 .descr = "TAG double-bit error",
1575 .descr = "RTG double-bit error",
1656 .descr = "RSD single-bit error",
1661 .descr = "MIB single-bit error",
1666 .descr = "RSD double-bit error",
1671 .descr = "MIB double-bit error",
1709 .descr = "VBF single-bit error",
1714 .descr = "VBF double-bit error",
1759 unsigned long head = ring_pos(tad->ring_head, ARRAY_SIZE(tad->err_ctx)); in thunderx_l2c_tad_isr()
1760 struct l2c_err_ctx *ctx = &tad->err_ctx[head]; in thunderx_l2c_tad_isr()
1762 ctx->reg_int = readq(tad->regs + L2C_TAD_INT_W1C); in thunderx_l2c_tad_isr()
1764 if (ctx->reg_int & L2C_TAD_INT_ECC) { in thunderx_l2c_tad_isr()
1765 ctx->reg_ext_name = "TQD_ERR"; in thunderx_l2c_tad_isr()
1766 ctx->reg_ext = readq(tad->regs + L2C_TAD_TQD_ERR); in thunderx_l2c_tad_isr()
1767 } else if (ctx->reg_int & L2C_TAD_INT_TAG) { in thunderx_l2c_tad_isr()
1768 ctx->reg_ext_name = "TTG_ERR"; in thunderx_l2c_tad_isr()
1769 ctx->reg_ext = readq(tad->regs + L2C_TAD_TTG_ERR); in thunderx_l2c_tad_isr()
1770 } else if (ctx->reg_int & L2C_TAD_INT_LFBTO) { in thunderx_l2c_tad_isr()
1771 ctx->reg_ext_name = "TIMEOUT"; in thunderx_l2c_tad_isr()
1772 ctx->reg_ext = readq(tad->regs + L2C_TAD_TIMEOUT); in thunderx_l2c_tad_isr()
1773 } else if (ctx->reg_int & L2C_TAD_INT_DISOCI) { in thunderx_l2c_tad_isr()
1774 ctx->reg_ext_name = "ERR"; in thunderx_l2c_tad_isr()
1775 ctx->reg_ext = readq(tad->regs + L2C_TAD_ERR); in thunderx_l2c_tad_isr()
1778 writeq(ctx->reg_int, tad->regs + L2C_TAD_INT_W1C); in thunderx_l2c_tad_isr()
1780 tad->ring_head++; in thunderx_l2c_tad_isr()
1791 unsigned long head = ring_pos(cbc->ring_head, ARRAY_SIZE(cbc->err_ctx)); in thunderx_l2c_cbc_isr()
1792 struct l2c_err_ctx *ctx = &cbc->err_ctx[head]; in thunderx_l2c_cbc_isr()
1794 ctx->reg_int = readq(cbc->regs + L2C_CBC_INT_W1C); in thunderx_l2c_cbc_isr()
1796 if (ctx->reg_int & L2C_CBC_INT_RSD) { in thunderx_l2c_cbc_isr()
1797 ctx->reg_ext_name = "RSDERR"; in thunderx_l2c_cbc_isr()
1798 ctx->reg_ext = readq(cbc->regs + L2C_CBC_RSDERR); in thunderx_l2c_cbc_isr()
1799 } else if (ctx->reg_int & L2C_CBC_INT_MIB) { in thunderx_l2c_cbc_isr()
1800 ctx->reg_ext_name = "MIBERR"; in thunderx_l2c_cbc_isr()
1801 ctx->reg_ext = readq(cbc->regs + L2C_CBC_MIBERR); in thunderx_l2c_cbc_isr()
1802 } else if (ctx->reg_int & L2C_CBC_INT_IODISOCI) { in thunderx_l2c_cbc_isr()
1803 ctx->reg_ext_name = "IODISOCIERR"; in thunderx_l2c_cbc_isr()
1804 ctx->reg_ext = readq(cbc->regs + L2C_CBC_IODISOCIERR); in thunderx_l2c_cbc_isr()
1807 writeq(ctx->reg_int, cbc->regs + L2C_CBC_INT_W1C); in thunderx_l2c_cbc_isr()
1809 cbc->ring_head++; in thunderx_l2c_cbc_isr()
1820 unsigned long head = ring_pos(mci->ring_head, ARRAY_SIZE(mci->err_ctx)); in thunderx_l2c_mci_isr()
1821 struct l2c_err_ctx *ctx = &mci->err_ctx[head]; in thunderx_l2c_mci_isr()
1823 ctx->reg_int = readq(mci->regs + L2C_MCI_INT_W1C); in thunderx_l2c_mci_isr()
1824 ctx->reg_ext = readq(mci->regs + L2C_MCI_ERR); in thunderx_l2c_mci_isr()
1826 writeq(ctx->reg_int, mci->regs + L2C_MCI_INT_W1C); in thunderx_l2c_mci_isr()
1828 ctx->reg_ext_name = "ERR"; in thunderx_l2c_mci_isr()
1830 mci->ring_head++; in thunderx_l2c_mci_isr()
1841 unsigned long tail = ring_pos(l2c->ring_tail, ARRAY_SIZE(l2c->err_ctx)); in thunderx_l2c_threaded_isr()
1842 struct l2c_err_ctx *ctx = &l2c->err_ctx[tail]; in thunderx_l2c_threaded_isr()
1858 switch (l2c->pdev->device) { in thunderx_l2c_threaded_isr()
1878 dev_err(&l2c->pdev->dev, "Unsupported device: %04x\n", in thunderx_l2c_threaded_isr()
1879 l2c->pdev->device); in thunderx_l2c_threaded_isr()
1883 while (CIRC_CNT(l2c->ring_head, l2c->ring_tail, in thunderx_l2c_threaded_isr()
1884 ARRAY_SIZE(l2c->err_ctx))) { in thunderx_l2c_threaded_isr()
1887 l2c->edac_dev->ctl_name, reg_int_name, ctx->reg_int, in thunderx_l2c_threaded_isr()
1888 ctx->reg_ext_name, ctx->reg_ext); in thunderx_l2c_threaded_isr()
1890 decode_register(other, L2C_OTHER_SIZE, l2_errors, ctx->reg_int); in thunderx_l2c_threaded_isr()
1894 if (ctx->reg_int & mask_ue) in thunderx_l2c_threaded_isr()
1895 edac_device_handle_ue(l2c->edac_dev, 0, 0, msg); in thunderx_l2c_threaded_isr()
1896 else if (ctx->reg_int & mask_ce) in thunderx_l2c_threaded_isr()
1897 edac_device_handle_ce(l2c->edac_dev, 0, 0, msg); in thunderx_l2c_threaded_isr()
1899 l2c->ring_tail++; in thunderx_l2c_threaded_isr()
1954 dev_err(&pdev->dev, "Cannot enable PCI device: %d\n", ret); in thunderx_l2c_probe()
1960 dev_err(&pdev->dev, "Cannot map PCI resources: %d\n", ret); in thunderx_l2c_probe()
1964 switch (pdev->device) { in thunderx_l2c_probe()
1969 fmt = "L2C-TAD%d"; in thunderx_l2c_probe()
1977 fmt = "L2C-CBC%d"; in thunderx_l2c_probe()
1985 fmt = "L2C-MCI%d"; in thunderx_l2c_probe()
1991 dev_err(&pdev->dev, "Unsupported PCI device: %04x\n", in thunderx_l2c_probe()
1992 pdev->device); in thunderx_l2c_probe()
1993 return -EINVAL; in thunderx_l2c_probe()
2002 dev_err(&pdev->dev, "Cannot allocate EDAC device\n"); in thunderx_l2c_probe()
2003 return -ENOMEM; in thunderx_l2c_probe()
2006 l2c = edac_dev->pvt_info; in thunderx_l2c_probe()
2007 l2c->edac_dev = edac_dev; in thunderx_l2c_probe()
2009 l2c->regs = pcim_iomap_table(pdev)[0]; in thunderx_l2c_probe()
2010 if (!l2c->regs) { in thunderx_l2c_probe()
2011 dev_err(&pdev->dev, "Cannot map PCI resources\n"); in thunderx_l2c_probe()
2012 ret = -ENODEV; in thunderx_l2c_probe()
2016 l2c->pdev = pdev; in thunderx_l2c_probe()
2018 l2c->ring_head = 0; in thunderx_l2c_probe()
2019 l2c->ring_tail = 0; in thunderx_l2c_probe()
2021 l2c->msix_ent.entry = 0; in thunderx_l2c_probe()
2022 l2c->msix_ent.vector = 0; in thunderx_l2c_probe()
2024 ret = pci_enable_msix_exact(pdev, &l2c->msix_ent, 1); in thunderx_l2c_probe()
2026 dev_err(&pdev->dev, "Cannot enable interrupt: %d\n", ret); in thunderx_l2c_probe()
2030 ret = devm_request_threaded_irq(&pdev->dev, l2c->msix_ent.vector, in thunderx_l2c_probe()
2034 &l2c->msix_ent); in thunderx_l2c_probe()
2038 edac_dev->dev = &pdev->dev; in thunderx_l2c_probe()
2039 edac_dev->dev_name = dev_name(&pdev->dev); in thunderx_l2c_probe()
2040 edac_dev->mod_name = "thunderx-l2c"; in thunderx_l2c_probe()
2041 edac_dev->ctl_name = "thunderx-l2c"; in thunderx_l2c_probe()
2045 dev_err(&pdev->dev, "Cannot add EDAC device: %d\n", ret); in thunderx_l2c_probe()
2050 l2c->debugfs = edac_debugfs_create_dir(pdev->dev.kobj.name); in thunderx_l2c_probe()
2052 ret = thunderx_create_debugfs_nodes(l2c->debugfs, l2c_devattr, in thunderx_l2c_probe()
2056 dev_warn(&pdev->dev, "Error creating debugfs entries: %d%s\n", in thunderx_l2c_probe()
2063 writeq(reg_en_mask, l2c->regs + reg_en_offs); in thunderx_l2c_probe()
2076 struct thunderx_l2c *l2c = edac_dev->pvt_info; in thunderx_l2c_remove()
2078 switch (pdev->device) { in thunderx_l2c_remove()
2080 writeq(L2C_TAD_INT_ENA_ALL, l2c->regs + L2C_TAD_INT_ENA_W1C); in thunderx_l2c_remove()
2083 writeq(L2C_CBC_INT_ENA_ALL, l2c->regs + L2C_CBC_INT_ENA_W1C); in thunderx_l2c_remove()
2086 writeq(L2C_MCI_INT_ENA_ALL, l2c->regs + L2C_MCI_INT_ENA_W1C); in thunderx_l2c_remove()
2090 edac_debugfs_remove_recursive(l2c->debugfs); in thunderx_l2c_remove()
2092 edac_device_del_device(&pdev->dev); in thunderx_l2c_remove()
2110 return -EBUSY; in thunderx_edac_init()