Lines Matching +full:ganged +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0-only
9 * cleared to prevent re-enabling the hardware by this driver.
18 if (!pvt->flags.zn_regs_v2) in get_umc_reg()
31 /* Per-node stuff */
39 * bandwidth to a valid bit pattern. The 'set' operation finds the 'matching-
81 func, PCI_FUNC(pdev->devfn), offset); in __amd64_read_pci_cfg_dword()
94 func, PCI_FUNC(pdev->devfn), offset); in __amd64_write_pci_cfg_dword()
106 amd64_read_pci_cfg(pvt->F1, DCT_CFG_SEL, &reg); in f15h_select_dct()
107 reg &= (pvt->model == 0x30) ? ~3 : ~1; in f15h_select_dct()
109 amd64_write_pci_cfg(pvt->F1, DCT_CFG_SEL, reg); in f15h_select_dct()
119 * DCT0 -> F2x040..
120 * DCT1 -> F2x140..
129 switch (pvt->fam) { in amd64_read_dct_pci_cfg()
132 return -EINVAL; in amd64_read_dct_pci_cfg()
154 dct = (dct && pvt->model == 0x30) ? 3 : dct; in amd64_read_dct_pci_cfg()
160 return -EINVAL; in amd64_read_dct_pci_cfg()
166 return amd64_read_pci_cfg(pvt->F2, offset, val); in amd64_read_dct_pci_cfg()
201 for (i = 0; i < ARRAY_SIZE(scrubrates) - 1; i++) { in __set_scrub_rate()
215 if (pvt->fam == 0x15 && pvt->model == 0x60) { in __set_scrub_rate()
217 pci_write_bits32(pvt->F2, F15H_M60H_SCRCTRL, scrubval, 0x001F); in __set_scrub_rate()
219 pci_write_bits32(pvt->F2, F15H_M60H_SCRCTRL, scrubval, 0x001F); in __set_scrub_rate()
221 pci_write_bits32(pvt->F3, SCRCTRL, scrubval, 0x001F); in __set_scrub_rate()
232 struct amd64_pvt *pvt = mci->pvt_info; in set_scrub_rate()
235 if (pvt->fam == 0xf) in set_scrub_rate()
238 if (pvt->fam == 0x15) { in set_scrub_rate()
240 if (pvt->model < 0x10) in set_scrub_rate()
243 if (pvt->model == 0x60) in set_scrub_rate()
251 struct amd64_pvt *pvt = mci->pvt_info; in get_scrub_rate()
252 int i, retval = -EINVAL; in get_scrub_rate()
255 if (pvt->fam == 0x15) { in get_scrub_rate()
257 if (pvt->model < 0x10) in get_scrub_rate()
260 if (pvt->model == 0x60) in get_scrub_rate()
261 amd64_read_pci_cfg(pvt->F2, F15H_M60H_SCRCTRL, &scrubval); in get_scrub_rate()
263 amd64_read_pci_cfg(pvt->F3, SCRCTRL, &scrubval); in get_scrub_rate()
265 amd64_read_pci_cfg(pvt->F3, SCRCTRL, &scrubval); in get_scrub_rate()
287 /* The K8 treats this as a 40-bit value. However, bits 63-40 will be in base_limit_match()
289 * Here we discard bits 63-40. See section 3.4.2 of AMD publication in base_limit_match()
290 * 24592: AMD x86-64 Architecture Programmer's Manual Volume 1 in base_limit_match()
316 pvt = mci->pvt_info; in find_mc_by_sys_addr()
378 if (pvt->fam == 0xf && pvt->ext_model < K8_REV_F) { in get_cs_base_and_mask()
379 csbase = pvt->csels[dct].csbases[csrow]; in get_cs_base_and_mask()
380 csmask = pvt->csels[dct].csmasks[csrow]; in get_cs_base_and_mask()
389 } else if (pvt->fam == 0x16 || in get_cs_base_and_mask()
390 (pvt->fam == 0x15 && pvt->model >= 0x30)) { in get_cs_base_and_mask()
391 csbase = pvt->csels[dct].csbases[csrow]; in get_cs_base_and_mask()
392 csmask = pvt->csels[dct].csmasks[csrow >> 1]; in get_cs_base_and_mask()
407 csbase = pvt->csels[dct].csbases[csrow]; in get_cs_base_and_mask()
408 csmask = pvt->csels[dct].csmasks[csrow >> 1]; in get_cs_base_and_mask()
411 if (pvt->fam == 0x15) in get_cs_base_and_mask()
429 for (i = 0; i < pvt->csels[dct].b_cnt; i++)
432 pvt->csels[dct].csbases[i]
435 for (i = 0; i < pvt->csels[dct].m_cnt; i++)
438 for (i = 0; i < pvt->max_mcs; i++)
442 * csrow that input_addr maps to, or -1 on failure (no csrow claims input_addr).
450 pvt = mci->pvt_info; in input_addr_to_csrow()
463 pvt->mc_node_id); in input_addr_to_csrow()
469 (unsigned long)input_addr, pvt->mc_node_id); in input_addr_to_csrow()
471 return -1; in input_addr_to_csrow()
480 * - The revision of the node is not E or greater. In this case, the DRAM Hole
483 * - The DramHoleValid bit is cleared in the DRAM Hole Address Register,
487 * complete 32-bit values despite the fact that the bitfields in the DHAR
488 * only represent bits 31-24 of the base and offset values.
493 struct amd64_pvt *pvt = mci->pvt_info; in get_dram_hole_info()
496 if (pvt->fam == 0xf && pvt->ext_model < K8_REV_E) { in get_dram_hole_info()
498 pvt->ext_model, pvt->mc_node_id); in get_dram_hole_info()
503 if (pvt->fam >= 0x10 && !dhar_mem_hoist_valid(pvt)) { in get_dram_hole_info()
510 pvt->mc_node_id); in get_dram_hole_info()
516 /* +------------------+--------------------+--------------------+----- in get_dram_hole_info()
518 * | [0, (x - 1)] | [x, 0xffffffff] | addresses from | in get_dram_hole_info()
522 * | | | (0xffffffff-x))] | in get_dram_hole_info()
523 * +------------------+--------------------+--------------------+----- in get_dram_hole_info()
533 *hole_size = (1ULL << 32) - *hole_base; in get_dram_hole_info()
535 *hole_offset = (pvt->fam > 0xf) ? f10_dhar_offset(pvt) in get_dram_hole_info()
539 pvt->mc_node_id, (unsigned long)*hole_base, in get_dram_hole_info()
551 struct amd64_pvt *pvt = mci->pvt_info; \
553 return sprintf(data, "0x%016llx\n", (u64)pvt->reg); \
602 struct amd64_pvt *pvt = mci->pvt_info; in inject_section_show()
603 return sprintf(buf, "0x%x\n", pvt->injection.section); in inject_section_show()
607 * store error injection section value which refers to one of 4 16-byte sections
608 * within a 64-byte cacheline
617 struct amd64_pvt *pvt = mci->pvt_info; in inject_section_store()
627 return -EINVAL; in inject_section_store()
630 pvt->injection.section = (u32) value; in inject_section_store()
638 struct amd64_pvt *pvt = mci->pvt_info; in inject_word_show()
639 return sprintf(buf, "0x%x\n", pvt->injection.word); in inject_word_show()
643 * store error injection word value which refers to one of 9 16-bit word of the
644 * 16-byte (128-bit + ECC bits) section
653 struct amd64_pvt *pvt = mci->pvt_info; in inject_word_store()
663 return -EINVAL; in inject_word_store()
666 pvt->injection.word = (u32) value; in inject_word_store()
675 struct amd64_pvt *pvt = mci->pvt_info; in inject_ecc_vector_show()
676 return sprintf(buf, "0x%x\n", pvt->injection.bit_map); in inject_ecc_vector_show()
689 struct amd64_pvt *pvt = mci->pvt_info; in inject_ecc_vector_store()
699 return -EINVAL; in inject_ecc_vector_store()
702 pvt->injection.bit_map = (u32) value; in inject_ecc_vector_store()
715 struct amd64_pvt *pvt = mci->pvt_info; in inject_read_store()
724 /* Form value to choose 16-byte section of cacheline */ in inject_read_store()
725 section = F10_NB_ARRAY_DRAM | SET_NB_ARRAY_ADDR(pvt->injection.section); in inject_read_store()
727 amd64_write_pci_cfg(pvt->F3, F10_NB_ARRAY_ADDR, section); in inject_read_store()
729 word_bits = SET_NB_DRAM_INJECTION_READ(pvt->injection); in inject_read_store()
732 amd64_write_pci_cfg(pvt->F3, F10_NB_ARRAY_DATA, word_bits); in inject_read_store()
748 struct amd64_pvt *pvt = mci->pvt_info; in inject_write_store()
757 /* Form value to choose 16-byte section of cacheline */ in inject_write_store()
758 section = F10_NB_ARRAY_DRAM | SET_NB_ARRAY_ADDR(pvt->injection.section); in inject_write_store()
760 amd64_write_pci_cfg(pvt->F3, F10_NB_ARRAY_ADDR, section); in inject_write_store()
762 word_bits = SET_NB_DRAM_INJECTION_WRITE(pvt->injection); in inject_write_store()
771 amd64_write_pci_cfg(pvt->F3, F10_NB_ARRAY_DATA, word_bits); in inject_write_store()
775 amd64_read_pci_cfg(pvt->F3, F10_NB_ARRAY_DATA, &tmp); in inject_write_store()
811 struct amd64_pvt *pvt = mci->pvt_info; in inj_is_visible()
814 if (pvt->fam >= 0x10 && pvt->fam <= 0x16) in inj_is_visible()
815 return attr->mode; in inj_is_visible()
857 struct amd64_pvt *pvt = mci->pvt_info; in sys_addr_to_dram_addr()
861 dram_base = get_dram_base(pvt, pvt->mc_node_id); in sys_addr_to_dram_addr()
868 dram_addr = sys_addr - hole_offset; in sys_addr_to_dram_addr()
880 * section 3.4.4 (p. 70). Although sys_addr is a 64-bit value, the k8 in sys_addr_to_dram_addr()
881 * only deals with 40-bit values. Therefore we discard bits 63-40 of in sys_addr_to_dram_addr()
884 * section 3.4.2 of AMD publication 24592: AMD x86-64 Architecture in sys_addr_to_dram_addr()
887 dram_addr = (sys_addr & GENMASK_ULL(39, 0)) - dram_base; in sys_addr_to_dram_addr()
916 pvt = mci->pvt_info; in dram_addr_to_input_addr()
919 * See the start of section 3.4.4 (p. 70, BKDG #26094, K8, revA-E) in dram_addr_to_input_addr()
954 err->page = (u32) (error_address >> PAGE_SHIFT); in error_address_to_page_and_offset()
955 err->offset = ((u32) error_address) & ~PAGE_MASK; in error_address_to_page_and_offset()
963 * the error). Return the number of the csrow that sys_addr maps to, or -1 on
972 if (csrow == -1) in sys_addr_to_csrow()
1007 * Therefore, a non-zero Node ID means we've already cached the values. in gpu_get_node_map()
1014 ret = -ENODEV; in gpu_get_node_map()
1033 u8 nid = (m->ipid >> 44) & 0xF; in fixup_node_id()
1035 if (smca_get_bank_type(m->extcpu, m->bank) != SMCA_UMC_V2) in fixup_node_id()
1042 /* Convert the hardware-provided AMD Node ID to a Linux logical one. */ in fixup_node_id()
1043 return nid - gpu_node_map.base_node_id + 1; in fixup_node_id()
1066 int err = -ENODEV; in __df_indirect_read()
1071 F4 = node_to_amd_nb(node)->link; in __df_indirect_read()
1147 ctx.ret_addr -= hi_addr_offset; in umc_normaddr_to_sysaddr()
1185 /* Re-use intlv_num_chan by setting it equal to log2(#channels) */ in umc_normaddr_to_sysaddr()
1241 cs_mask = (1 << die_id_bit) - 1; in umc_normaddr_to_sysaddr()
1270 * The pre-interleaved address consists of XXXXXXIIIYYYYY in umc_normaddr_to_sysaddr()
1272 * address bits from the post-interleaved address. in umc_normaddr_to_sysaddr()
1277 temp_addr_y = ctx.ret_addr & GENMASK_ULL(intlv_addr_bit - 1, 0); in umc_normaddr_to_sysaddr()
1293 ctx.ret_addr += (BIT_ULL(32) - dram_hole_base); in umc_normaddr_to_sysaddr()
1297 /* Save some parentheses and grab ls-bit at the end. */ in umc_normaddr_to_sysaddr()
1318 return -EINVAL; in umc_normaddr_to_sysaddr()
1332 bit = (pvt->fam > 0xf || pvt->ext_model >= K8_REV_F) in dct_determine_edac_cap()
1336 if (pvt->dclr0 & BIT(bit)) in dct_determine_edac_cap()
1348 if (!(pvt->umc[i].sdp_ctrl & UMC_SDP_INIT)) in umc_determine_edac_cap()
1354 if (pvt->umc[i].umc_cfg & BIT(12)) in umc_determine_edac_cap()
1370 u32 *dcsb = ctrl ? pvt->csels[1].csbases : pvt->csels[0].csbases; in dct_debug_display_dimm_sizes()
1371 u32 dbam = ctrl ? pvt->dbam1 : pvt->dbam0; in dct_debug_display_dimm_sizes()
1374 if (pvt->fam == 0xf) { in dct_debug_display_dimm_sizes()
1376 if (pvt->ext_model < K8_REV_F) in dct_debug_display_dimm_sizes()
1382 if (pvt->fam == 0x10) { in dct_debug_display_dimm_sizes()
1383 dbam = (ctrl && !dct_ganging_enabled(pvt)) ? pvt->dbam1 in dct_debug_display_dimm_sizes()
1384 : pvt->dbam0; in dct_debug_display_dimm_sizes()
1386 pvt->csels[1].csbases : in dct_debug_display_dimm_sizes()
1387 pvt->csels[0].csbases; in dct_debug_display_dimm_sizes()
1389 dbam = pvt->dbam0; in dct_debug_display_dimm_sizes()
1390 dcsb = pvt->csels[1].csbases; in dct_debug_display_dimm_sizes()
1407 size0 = pvt->ops->dbam_to_cs(pvt, ctrl, in dct_debug_display_dimm_sizes()
1413 size1 = pvt->ops->dbam_to_cs(pvt, ctrl, in dct_debug_display_dimm_sizes()
1428 if (pvt->dram_type == MEM_LRDDR3) { in debug_dump_dramcfg_low()
1429 u32 dcsm = pvt->csels[chan].csmasks[0]; in debug_dump_dramcfg_low()
1445 if (pvt->fam == 0x10) in debug_dump_dramcfg_low()
1446 edac_dbg(1, " DCT 128bit mode width: %s\n", in debug_dump_dramcfg_low()
1476 /* Asymmetric dual-rank DIMM support. */ in umc_get_cs_mode()
1489 pvt->csels[ctrl].csmasks[0] == pvt->csels[ctrl].csmasks[1]) { in umc_get_cs_mode()
1515 msb = fls(addr_mask_orig) - 1; in __addr_mask_to_cs_size()
1517 num_zero_bits = msb - weight - !!(cs_mode & CS_3R_INTERLEAVE); in __addr_mask_to_cs_size()
1520 addr_mask_deinterleaved = GENMASK_ULL(msb - num_zero_bits, 1); in __addr_mask_to_cs_size()
1556 * CS0 and CS1 -> MASK0 / DIMM0 in umc_addr_mask_to_cs_size()
1557 * CS2 and CS3 -> MASK1 / DIMM1 in umc_addr_mask_to_cs_size()
1562 * CS0 -> MASK0 -> DIMM0 in umc_addr_mask_to_cs_size()
1563 * CS1 -> MASK1 -> DIMM0 in umc_addr_mask_to_cs_size()
1564 * CS2 -> MASK2 -> DIMM1 in umc_addr_mask_to_cs_size()
1565 * CS3 -> MASK3 -> DIMM1 in umc_addr_mask_to_cs_size()
1572 if (!pvt->flags.zn_regs_v2) in umc_addr_mask_to_cs_size()
1575 /* Asymmetric dual-rank DIMM support. */ in umc_addr_mask_to_cs_size()
1577 addr_mask_orig = pvt->csels[umc].csmasks_sec[cs_mask_nr]; in umc_addr_mask_to_cs_size()
1579 addr_mask_orig = pvt->csels[umc].csmasks[cs_mask_nr]; in umc_addr_mask_to_cs_size()
1612 umc = &pvt->umc[i]; in umc_dump_misc_regs()
1614 edac_dbg(1, "UMC%d DIMM cfg: 0x%x\n", i, umc->dimm_cfg); in umc_dump_misc_regs()
1615 edac_dbg(1, "UMC%d UMC cfg: 0x%x\n", i, umc->umc_cfg); in umc_dump_misc_regs()
1616 edac_dbg(1, "UMC%d SDP ctrl: 0x%x\n", i, umc->sdp_ctrl); in umc_dump_misc_regs()
1617 edac_dbg(1, "UMC%d ECC ctrl: 0x%x\n", i, umc->ecc_ctrl); in umc_dump_misc_regs()
1619 amd_smn_read(pvt->mc_node_id, umc_base + UMCCH_ECC_BAD_SYMBOL, &tmp); in umc_dump_misc_regs()
1622 amd_smn_read(pvt->mc_node_id, umc_base + UMCCH_UMC_CAP, &tmp); in umc_dump_misc_regs()
1624 edac_dbg(1, "UMC%d UMC cap high: 0x%x\n", i, umc->umc_cap_hi); in umc_dump_misc_regs()
1627 i, (umc->umc_cap_hi & BIT(30)) ? "yes" : "no", in umc_dump_misc_regs()
1628 (umc->umc_cap_hi & BIT(31)) ? "yes" : "no"); in umc_dump_misc_regs()
1630 i, (umc->umc_cfg & BIT(12)) ? "yes" : "no"); in umc_dump_misc_regs()
1632 i, (umc->dimm_cfg & BIT(6)) ? "yes" : "no"); in umc_dump_misc_regs()
1634 i, (umc->dimm_cfg & BIT(7)) ? "yes" : "no"); in umc_dump_misc_regs()
1636 if (umc->dram_type == MEM_LRDDR4 || umc->dram_type == MEM_LRDDR5) { in umc_dump_misc_regs()
1637 amd_smn_read(pvt->mc_node_id, in umc_dump_misc_regs()
1650 edac_dbg(1, "F3xE8 (NB Cap): 0x%08x\n", pvt->nbcap); in dct_dump_misc_regs()
1653 (pvt->nbcap & NBCAP_DCT_DUAL) ? "yes" : "no"); in dct_dump_misc_regs()
1656 (pvt->nbcap & NBCAP_SECDED) ? "yes" : "no", in dct_dump_misc_regs()
1657 (pvt->nbcap & NBCAP_CHIPKILL) ? "yes" : "no"); in dct_dump_misc_regs()
1659 debug_dump_dramcfg_low(pvt, pvt->dclr0, 0); in dct_dump_misc_regs()
1661 edac_dbg(1, "F3xB0 (Online Spare): 0x%08x\n", pvt->online_spare); in dct_dump_misc_regs()
1664 pvt->dhar, dhar_base(pvt), in dct_dump_misc_regs()
1665 (pvt->fam == 0xf) ? k8_dhar_offset(pvt) in dct_dump_misc_regs()
1671 if (pvt->fam == 0xf) in dct_dump_misc_regs()
1676 /* Only if NOT ganged does dclr1 have valid info */ in dct_dump_misc_regs()
1678 debug_dump_dramcfg_low(pvt, pvt->dclr1, 1); in dct_dump_misc_regs()
1682 amd64_info("using x%u syndromes.\n", pvt->ecc_sym_sz); in dct_dump_misc_regs()
1690 if (pvt->fam == 0xf && pvt->ext_model < K8_REV_F) { in dct_prep_chip_selects()
1691 pvt->csels[0].b_cnt = pvt->csels[1].b_cnt = 8; in dct_prep_chip_selects()
1692 pvt->csels[0].m_cnt = pvt->csels[1].m_cnt = 8; in dct_prep_chip_selects()
1693 } else if (pvt->fam == 0x15 && pvt->model == 0x30) { in dct_prep_chip_selects()
1694 pvt->csels[0].b_cnt = pvt->csels[1].b_cnt = 4; in dct_prep_chip_selects()
1695 pvt->csels[0].m_cnt = pvt->csels[1].m_cnt = 2; in dct_prep_chip_selects()
1697 pvt->csels[0].b_cnt = pvt->csels[1].b_cnt = 8; in dct_prep_chip_selects()
1698 pvt->csels[0].m_cnt = pvt->csels[1].m_cnt = 4; in dct_prep_chip_selects()
1707 pvt->csels[umc].b_cnt = 4; in umc_prep_chip_selects()
1708 pvt->csels[umc].m_cnt = pvt->flags.zn_regs_v2 ? 4 : 2; in umc_prep_chip_selects()
1727 base = &pvt->csels[umc].csbases[cs]; in umc_read_base_mask()
1728 base_sec = &pvt->csels[umc].csbases_sec[cs]; in umc_read_base_mask()
1733 if (!amd_smn_read(pvt->mc_node_id, base_reg, base)) in umc_read_base_mask()
1737 if (!amd_smn_read(pvt->mc_node_id, base_reg_sec, base_sec)) in umc_read_base_mask()
1746 mask = &pvt->csels[umc].csmasks[cs]; in umc_read_base_mask()
1747 mask_sec = &pvt->csels[umc].csmasks_sec[cs]; in umc_read_base_mask()
1752 if (!amd_smn_read(pvt->mc_node_id, mask_reg, mask)) in umc_read_base_mask()
1756 if (!amd_smn_read(pvt->mc_node_id, mask_reg_sec, mask_sec)) in umc_read_base_mask()
1773 u32 *base0 = &pvt->csels[0].csbases[cs]; in dct_read_base_mask()
1774 u32 *base1 = &pvt->csels[1].csbases[cs]; in dct_read_base_mask()
1780 if (pvt->fam == 0xf) in dct_read_base_mask()
1785 cs, *base1, (pvt->fam == 0x10) ? reg1 in dct_read_base_mask()
1792 u32 *mask0 = &pvt->csels[0].csmasks[cs]; in dct_read_base_mask()
1793 u32 *mask1 = &pvt->csels[1].csmasks[cs]; in dct_read_base_mask()
1799 if (pvt->fam == 0xf) in dct_read_base_mask()
1804 cs, *mask1, (pvt->fam == 0x10) ? reg1 in dct_read_base_mask()
1815 umc = &pvt->umc[i]; in umc_determine_memory_type()
1817 if (!(umc->sdp_ctrl & UMC_SDP_INIT)) { in umc_determine_memory_type()
1818 umc->dram_type = MEM_EMPTY; in umc_determine_memory_type()
1826 if (pvt->flags.zn_regs_v2 && ((umc->umc_cfg & GENMASK(2, 0)) == 0x1)) { in umc_determine_memory_type()
1827 if (umc->dimm_cfg & BIT(5)) in umc_determine_memory_type()
1828 umc->dram_type = MEM_LRDDR5; in umc_determine_memory_type()
1829 else if (umc->dimm_cfg & BIT(4)) in umc_determine_memory_type()
1830 umc->dram_type = MEM_RDDR5; in umc_determine_memory_type()
1832 umc->dram_type = MEM_DDR5; in umc_determine_memory_type()
1834 if (umc->dimm_cfg & BIT(5)) in umc_determine_memory_type()
1835 umc->dram_type = MEM_LRDDR4; in umc_determine_memory_type()
1836 else if (umc->dimm_cfg & BIT(4)) in umc_determine_memory_type()
1837 umc->dram_type = MEM_RDDR4; in umc_determine_memory_type()
1839 umc->dram_type = MEM_DDR4; in umc_determine_memory_type()
1842 edac_dbg(1, " UMC%d DIMM type: %s\n", i, edac_mem_types[umc->dram_type]); in umc_determine_memory_type()
1850 switch (pvt->fam) { in dct_determine_memory_type()
1852 if (pvt->ext_model >= K8_REV_F) in dct_determine_memory_type()
1855 pvt->dram_type = (pvt->dclr0 & BIT(18)) ? MEM_DDR : MEM_RDDR; in dct_determine_memory_type()
1859 if (pvt->dchr0 & DDR3_MODE) in dct_determine_memory_type()
1862 pvt->dram_type = (pvt->dclr0 & BIT(16)) ? MEM_DDR2 : MEM_RDDR2; in dct_determine_memory_type()
1866 if (pvt->model < 0x60) in dct_determine_memory_type()
1879 dcsm = pvt->csels[0].csmasks[0]; in dct_determine_memory_type()
1882 pvt->dram_type = MEM_DDR4; in dct_determine_memory_type()
1883 else if (pvt->dclr0 & BIT(16)) in dct_determine_memory_type()
1884 pvt->dram_type = MEM_DDR3; in dct_determine_memory_type()
1886 pvt->dram_type = MEM_LRDDR3; in dct_determine_memory_type()
1888 pvt->dram_type = MEM_RDDR3; in dct_determine_memory_type()
1896 WARN(1, KERN_ERR "%s: Family??? 0x%x\n", __func__, pvt->fam); in dct_determine_memory_type()
1897 pvt->dram_type = MEM_EMPTY; in dct_determine_memory_type()
1900 edac_dbg(1, " DIMM type: %s\n", edac_mem_types[pvt->dram_type]); in dct_determine_memory_type()
1904 pvt->dram_type = (pvt->dclr0 & BIT(16)) ? MEM_DDR3 : MEM_RDDR3; in dct_determine_memory_type()
1910 u16 mce_nid = topology_die_id(m->extcpu); in get_error_address()
1920 pvt = mci->pvt_info; in get_error_address()
1922 if (pvt->fam == 0xf) { in get_error_address()
1927 addr = m->addr & GENMASK_ULL(end_bit, start_bit); in get_error_address()
1932 if (pvt->fam == 0x15) { in get_error_address()
1941 amd64_read_pci_cfg(pvt->F1, DRAM_LOCAL_NODE_LIM, &tmp); in get_error_address()
1956 amd64_read_pci_cfg(pvt->F1, DRAM_LOCAL_NODE_BASE, &tmp); in get_error_address()
1980 if (pci_domain_nr(dev->bus) == pci_domain_nr(related->bus) && in pci_get_related_function()
1981 (dev->bus->number == related->bus->number) && in pci_get_related_function()
1982 (PCI_SLOT(dev->devfn) == PCI_SLOT(related->devfn))) in pci_get_related_function()
1997 amd64_read_pci_cfg(pvt->F1, DRAM_BASE_LO + off, &pvt->ranges[range].base.lo); in read_dram_base_limit_regs()
1998 amd64_read_pci_cfg(pvt->F1, DRAM_LIMIT_LO + off, &pvt->ranges[range].lim.lo); in read_dram_base_limit_regs()
2000 if (pvt->fam == 0xf) in read_dram_base_limit_regs()
2006 amd64_read_pci_cfg(pvt->F1, DRAM_BASE_HI + off, &pvt->ranges[range].base.hi); in read_dram_base_limit_regs()
2007 amd64_read_pci_cfg(pvt->F1, DRAM_LIMIT_HI + off, &pvt->ranges[range].lim.hi); in read_dram_base_limit_regs()
2010 if (pvt->fam != 0x15) in read_dram_base_limit_regs()
2017 if (pvt->model == 0x60) in read_dram_base_limit_regs()
2019 else if (pvt->model == 0x30) in read_dram_base_limit_regs()
2024 f1 = pci_get_related_function(nb->misc->vendor, pci_func, nb->misc); in read_dram_base_limit_regs()
2030 pvt->ranges[range].lim.lo &= GENMASK_ULL(15, 0); in read_dram_base_limit_regs()
2033 pvt->ranges[range].lim.lo |= ((llim & 0x1fff) << 3 | 0x7) << 16; in read_dram_base_limit_regs()
2035 pvt->ranges[range].lim.hi &= GENMASK_ULL(7, 0); in read_dram_base_limit_regs()
2038 pvt->ranges[range].lim.hi |= llim >> 13; in read_dram_base_limit_regs()
2046 struct amd64_pvt *pvt = mci->pvt_info; in k8_map_sysaddr_to_csrow()
2054 err->src_mci = find_mc_by_sys_addr(mci, sys_addr); in k8_map_sysaddr_to_csrow()
2055 if (!err->src_mci) { in k8_map_sysaddr_to_csrow()
2058 err->err_code = ERR_NODE; in k8_map_sysaddr_to_csrow()
2063 err->csrow = sys_addr_to_csrow(err->src_mci, sys_addr); in k8_map_sysaddr_to_csrow()
2064 if (err->csrow < 0) { in k8_map_sysaddr_to_csrow()
2065 err->err_code = ERR_CSROW; in k8_map_sysaddr_to_csrow()
2070 if (pvt->nbcfg & NBCFG_CHIPKILL) { in k8_map_sysaddr_to_csrow()
2071 err->channel = get_channel_from_ecc_syndrome(mci, err->syndrome); in k8_map_sysaddr_to_csrow()
2072 if (err->channel < 0) { in k8_map_sysaddr_to_csrow()
2078 amd64_mc_warn(err->src_mci, "unknown syndrome 0x%04x - " in k8_map_sysaddr_to_csrow()
2080 err->syndrome); in k8_map_sysaddr_to_csrow()
2081 err->err_code = ERR_CHANNEL; in k8_map_sysaddr_to_csrow()
2086 * non-chipkill ecc mode in k8_map_sysaddr_to_csrow()
2089 * channel number when using non-chipkill memory. This method in k8_map_sysaddr_to_csrow()
2091 * (Wish the email was placed in this comment - norsk) in k8_map_sysaddr_to_csrow()
2093 err->channel = ((sys_addr & BIT(3)) != 0); in k8_map_sysaddr_to_csrow()
2114 u32 dclr = dct ? pvt->dclr1 : pvt->dclr0; in k8_dbam_to_chip_select()
2116 if (pvt->ext_model >= K8_REV_F) { in k8_dbam_to_chip_select()
2120 else if (pvt->ext_model >= K8_REV_D) { in k8_dbam_to_chip_select()
2150 return 32 << (cs_mode - diff); in k8_dbam_to_chip_select()
2164 cs_size = -1; in ddr3_cs_size()
2174 if (cs_size != -1) in ddr3_cs_size()
2186 cs_size = -1; in ddr3_lrdimm_cs_size()
2194 if (cs_size != -1) in ddr3_lrdimm_cs_size()
2205 cs_size = -1; in ddr4_cs_size()
2218 u32 dclr = dct ? pvt->dclr1 : pvt->dclr0; in f10_dbam_to_chip_select()
2222 if (pvt->dchr0 & DDR3_MODE || pvt->dchr1 & DDR3_MODE) in f10_dbam_to_chip_select()
2244 u32 dcsm = pvt->csels[dct].csmasks[cs_mask_nr]; in f15_m60h_dbam_to_chip_select()
2248 if (pvt->dram_type == MEM_DDR4) { in f15_m60h_dbam_to_chip_select()
2250 return -1; in f15_m60h_dbam_to_chip_select()
2253 } else if (pvt->dram_type == MEM_LRDDR3) { in f15_m60h_dbam_to_chip_select()
2262 return -1; in f15_m60h_dbam_to_chip_select()
2280 return -1; in f16_dbam_to_chip_select()
2288 if (pvt->fam == 0xf) in read_dram_ctl_register()
2291 if (!amd64_read_pci_cfg(pvt->F2, DCT_SEL_LO, &pvt->dct_sel_lo)) { in read_dram_ctl_register()
2293 pvt->dct_sel_lo, dct_sel_baseaddr(pvt)); in read_dram_ctl_register()
2295 edac_dbg(0, " DCTs operate in %s mode\n", in read_dram_ctl_register()
2296 (dct_ganging_enabled(pvt) ? "ganged" : "unganged")); in read_dram_ctl_register()
2312 amd64_read_pci_cfg(pvt->F2, DCT_SEL_HI, &pvt->dct_sel_hi); in read_dram_ctl_register()
2316 * Determine channel (DCT) based on the interleaving mode (see F15h M30h BKDG,
2347 * Determine channel (DCT) based on the interleaving mode: F10h BKDG, 2.8.9 Memory
2353 u8 dct_sel_high = (pvt->dct_sel_lo >> 1) & 1; in f1x_determine_channel()
2362 * see F2x110[DctSelIntLvAddr] - channel interleave mode in f1x_determine_channel()
2401 u64 dct_sel_base_off = (u64)(pvt->dct_sel_hi & 0xFFFFFC00) << 16; in f1x_get_norm_dct_addr()
2438 return (sys_addr & GENMASK_ULL(47,6)) - (chan_off & GENMASK_ULL(47,23)); in f1x_get_norm_dct_addr()
2467 * -EINVAL: NOT FOUND
2468 * 0..csrow = Chip-Select Row
2475 int cs_found = -EINVAL; in f1x_lookup_addr_in_dct()
2482 pvt = mci->pvt_info; in f1x_lookup_addr_in_dct()
2501 if (pvt->fam == 0x15 && pvt->model >= 0x30) { in f1x_lookup_addr_in_dct()
2515 * See F2x10C. Non-interleaved graphics framebuffer memory under the 16G is
2523 if (pvt->fam == 0x10) { in f1x_swap_interleaved_region()
2525 if (pvt->model < 4 || (pvt->model < 0xa && pvt->stepping < 3)) in f1x_swap_interleaved_region()
2529 amd64_read_pci_cfg(pvt->F2, SWAP_INTLV_REG, &swap_reg); in f1x_swap_interleaved_region()
2552 int cs_found = -EINVAL; in f1x_match_to_this_node()
2570 return -EINVAL; in f1x_match_to_this_node()
2574 return -EINVAL; in f1x_match_to_this_node()
2632 int cs_found = -EINVAL; in f15_m30h_match_to_this_node()
2644 amd64_read_pci_cfg(pvt->F1, DRAM_CONT_BASE, &dct_cont_base_reg); in f15_m30h_match_to_this_node()
2645 amd64_read_pci_cfg(pvt->F1, DRAM_CONT_LIMIT, &dct_cont_limit_reg); in f15_m30h_match_to_this_node()
2655 return -EINVAL; in f15_m30h_match_to_this_node()
2662 return -EINVAL; in f15_m30h_match_to_this_node()
2672 return -EINVAL; in f15_m30h_match_to_this_node()
2678 return -EINVAL; in f15_m30h_match_to_this_node()
2680 if (pvt->model >= 0x60) in f15_m30h_match_to_this_node()
2688 return -EINVAL; in f15_m30h_match_to_this_node()
2698 chan_addr = sys_addr - chan_offset; in f15_m30h_match_to_this_node()
2709 return -EINVAL; in f15_m30h_match_to_this_node()
2719 return -EINVAL; in f15_m30h_match_to_this_node()
2723 amd64_read_pci_cfg(pvt->F1, in f15_m30h_match_to_this_node()
2738 * pvt->csels[1]. So we need to use '1' here to get correct info. in f15_m30h_match_to_this_node()
2755 int cs_found = -EINVAL; in f1x_translate_sysaddr_to_cs()
2762 if (pvt->fam == 0x15 && pvt->model >= 0x30) in f1x_translate_sysaddr_to_cs()
2788 struct amd64_pvt *pvt = mci->pvt_info; in f1x_map_sysaddr_to_csrow()
2792 err->csrow = f1x_translate_sysaddr_to_cs(pvt, sys_addr, &err->channel); in f1x_map_sysaddr_to_csrow()
2793 if (err->csrow < 0) { in f1x_map_sysaddr_to_csrow()
2794 err->err_code = ERR_CSROW; in f1x_map_sysaddr_to_csrow()
2800 * ganged. Otherwise @chan should already contain the channel at in f1x_map_sysaddr_to_csrow()
2804 err->channel = get_channel_from_ecc_syndrome(mci, err->syndrome); in f1x_map_sysaddr_to_csrow()
2908 return -1; in decode_syndrome()
2931 return -1; in map_err_sym_to_channel()
2939 return -1; in map_err_sym_to_channel()
2944 struct amd64_pvt *pvt = mci->pvt_info; in get_channel_from_ecc_syndrome()
2945 int err_sym = -1; in get_channel_from_ecc_syndrome()
2947 if (pvt->ecc_sym_sz == 8) in get_channel_from_ecc_syndrome()
2950 pvt->ecc_sym_sz); in get_channel_from_ecc_syndrome()
2951 else if (pvt->ecc_sym_sz == 4) in get_channel_from_ecc_syndrome()
2954 pvt->ecc_sym_sz); in get_channel_from_ecc_syndrome()
2956 amd64_warn("Illegal syndrome type: %u\n", pvt->ecc_sym_sz); in get_channel_from_ecc_syndrome()
2960 return map_err_sym_to_channel(err_sym, pvt->ecc_sym_sz); in get_channel_from_ecc_syndrome()
2980 switch (err->err_code) { in __log_ecc_error()
2991 string = "Unknown syndrome - possible error reporting race"; in __log_ecc_error()
2994 string = "MCA_SYND not valid - unknown syndrome and csrow"; in __log_ecc_error()
3005 err->page, err->offset, err->syndrome, in __log_ecc_error()
3006 err->csrow, err->channel, -1, in __log_ecc_error()
3014 u8 ecc_type = (m->status >> 45) & 0x3; in decode_bus_error()
3015 u8 xec = XEC(m->status, 0x1f); in decode_bus_error()
3016 u16 ec = EC(m->status); in decode_bus_error()
3024 pvt = mci->pvt_info; in decode_bus_error()
3039 err.syndrome = extract_syndrome(m->status); in decode_bus_error()
3041 pvt->ops->map_sysaddr_to_csrow(mci, sys_addr, &err); in decode_bus_error()
3060 err->channel = (m->ipid & GENMASK(31, 0)) >> 20; in umc_get_err_info()
3061 err->csrow = m->synd & 0x7; in umc_get_err_info()
3066 u8 ecc_type = (m->status >> 45) & 0x3; in decode_umc_error()
3078 pvt = mci->pvt_info; in decode_umc_error()
3082 if (m->status & MCI_STATUS_DEFERRED) in decode_umc_error()
3085 if (!(m->status & MCI_STATUS_SYNDV)) { in decode_umc_error()
3091 u8 length = (m->synd >> 18) & 0x3f; in decode_umc_error()
3094 err.syndrome = (m->synd >> 32) & GENMASK(length - 1, 0); in decode_umc_error()
3099 pvt->ops->get_err_info(m, &err); in decode_umc_error()
3101 if (umc_normaddr_to_sysaddr(m->addr, pvt->mc_node_id, err.channel, &sys_addr)) { in decode_umc_error()
3113 * Use pvt->F3 which contains the F3 CPU PCI device to get the related
3120 pvt->F1 = pci_get_related_function(pvt->F3->vendor, pci_id1, pvt->F3); in reserve_mc_sibling_devs()
3121 if (!pvt->F1) { in reserve_mc_sibling_devs()
3123 return -ENODEV; in reserve_mc_sibling_devs()
3127 pvt->F2 = pci_get_related_function(pvt->F3->vendor, pci_id2, pvt->F3); in reserve_mc_sibling_devs()
3128 if (!pvt->F2) { in reserve_mc_sibling_devs()
3129 pci_dev_put(pvt->F1); in reserve_mc_sibling_devs()
3130 pvt->F1 = NULL; in reserve_mc_sibling_devs()
3133 return -ENODEV; in reserve_mc_sibling_devs()
3137 pci_ctl_dev = &pvt->F2->dev; in reserve_mc_sibling_devs()
3139 edac_dbg(1, "F1: %s\n", pci_name(pvt->F1)); in reserve_mc_sibling_devs()
3140 edac_dbg(1, "F2: %s\n", pci_name(pvt->F2)); in reserve_mc_sibling_devs()
3141 edac_dbg(1, "F3: %s\n", pci_name(pvt->F3)); in reserve_mc_sibling_devs()
3148 pvt->ecc_sym_sz = 4; in determine_ecc_sym_sz()
3150 if (pvt->fam >= 0x10) { in determine_ecc_sym_sz()
3153 amd64_read_pci_cfg(pvt->F3, EXT_NB_MCA_CFG, &tmp); in determine_ecc_sym_sz()
3155 if (pvt->fam != 0x16) in determine_ecc_sym_sz()
3156 amd64_read_dct_pci_cfg(pvt, 1, DBAM0, &pvt->dbam1); in determine_ecc_sym_sz()
3159 if ((pvt->fam > 0x10 || pvt->model > 7) && tmp & BIT(25)) in determine_ecc_sym_sz()
3160 pvt->ecc_sym_sz = 8; in determine_ecc_sym_sz()
3169 u8 nid = pvt->mc_node_id; in umc_read_mc_regs()
3177 umc = &pvt->umc[i]; in umc_read_mc_regs()
3179 amd_smn_read(nid, umc_base + get_umc_reg(pvt, UMCCH_DIMM_CFG), &umc->dimm_cfg); in umc_read_mc_regs()
3180 amd_smn_read(nid, umc_base + UMCCH_UMC_CFG, &umc->umc_cfg); in umc_read_mc_regs()
3181 amd_smn_read(nid, umc_base + UMCCH_SDP_CTRL, &umc->sdp_ctrl); in umc_read_mc_regs()
3182 amd_smn_read(nid, umc_base + UMCCH_ECC_CTRL, &umc->ecc_ctrl); in umc_read_mc_regs()
3183 amd_smn_read(nid, umc_base + UMCCH_UMC_CAP_HI, &umc->umc_cap_hi); in umc_read_mc_regs()
3198 * those are Read-As-Zero. in dct_read_mc_regs()
3200 rdmsrl(MSR_K8_TOP_MEM1, pvt->top_mem); in dct_read_mc_regs()
3201 edac_dbg(0, " TOP_MEM: 0x%016llx\n", pvt->top_mem); in dct_read_mc_regs()
3206 rdmsrl(MSR_K8_TOP_MEM2, pvt->top_mem2); in dct_read_mc_regs()
3207 edac_dbg(0, " TOP_MEM2: 0x%016llx\n", pvt->top_mem2); in dct_read_mc_regs()
3212 amd64_read_pci_cfg(pvt->F3, NBCAP, &pvt->nbcap); in dct_read_mc_regs()
3233 (rw & 0x1) ? "R" : "-", in dct_read_mc_regs()
3234 (rw & 0x2) ? "W" : "-", in dct_read_mc_regs()
3239 amd64_read_pci_cfg(pvt->F1, DHAR, &pvt->dhar); in dct_read_mc_regs()
3240 amd64_read_dct_pci_cfg(pvt, 0, DBAM0, &pvt->dbam0); in dct_read_mc_regs()
3242 amd64_read_pci_cfg(pvt->F3, F10_ONLINE_SPARE, &pvt->online_spare); in dct_read_mc_regs()
3244 amd64_read_dct_pci_cfg(pvt, 0, DCLR0, &pvt->dclr0); in dct_read_mc_regs()
3245 amd64_read_dct_pci_cfg(pvt, 0, DCHR0, &pvt->dchr0); in dct_read_mc_regs()
3248 amd64_read_dct_pci_cfg(pvt, 1, DCLR0, &pvt->dclr1); in dct_read_mc_regs()
3249 amd64_read_dct_pci_cfg(pvt, 1, DCHR0, &pvt->dchr1); in dct_read_mc_regs()
3259 * @csrow_nr ChipSelect Row Number (0..NUM_CHIPSELECTS-1)
3260 * k8 private pointer to -->
3268 * 0-3 CSROWs 0 and 1
3269 * 4-7 CSROWs 2 and 3
3270 * 8-11 CSROWs 4 and 5
3271 * 12-15 CSROWs 6 and 7
3274 * The meaning of the values depends on CPU revision and dual-channel state,
3279 * single channel or two (2) DIMMs in dual channel mode.
3291 u32 dbam = dct ? pvt->dbam1 : pvt->dbam0; in dct_get_csrow_nr_pages()
3297 nr_pages = pvt->ops->dbam_to_cs(pvt, dct, cs_mode, csrow_nr); in dct_get_csrow_nr_pages()
3298 nr_pages <<= 20 - PAGE_SHIFT; in dct_get_csrow_nr_pages()
3315 nr_pages <<= 20 - PAGE_SHIFT; in umc_get_csrow_nr_pages()
3326 struct amd64_pvt *pvt = mci->pvt_info; in umc_init_csrows()
3332 if (mci->edac_ctl_cap & EDAC_FLAG_S16ECD16ED) { in umc_init_csrows()
3335 } else if (mci->edac_ctl_cap & EDAC_FLAG_S8ECD8ED) { in umc_init_csrows()
3338 } else if (mci->edac_ctl_cap & EDAC_FLAG_S4ECD4ED) { in umc_init_csrows()
3341 } else if (mci->edac_ctl_cap & EDAC_FLAG_SECDED) { in umc_init_csrows()
3350 dimm = mci->csrows[cs]->channels[umc]->dimm; in umc_init_csrows()
3353 pvt->mc_node_id, cs); in umc_init_csrows()
3355 dimm->nr_pages = umc_get_csrow_nr_pages(pvt, umc, cs); in umc_init_csrows()
3356 dimm->mtype = pvt->umc[umc].dram_type; in umc_init_csrows()
3357 dimm->edac_mode = edac_mode; in umc_init_csrows()
3358 dimm->dtype = dev_type; in umc_init_csrows()
3359 dimm->grain = 64; in umc_init_csrows()
3370 struct amd64_pvt *pvt = mci->pvt_info; in dct_init_csrows()
3378 amd64_read_pci_cfg(pvt->F3, NBCFG, &val); in dct_init_csrows()
3380 pvt->nbcfg = val; in dct_init_csrows()
3383 pvt->mc_node_id, val, in dct_init_csrows()
3393 if (pvt->fam != 0xf) in dct_init_csrows()
3399 csrow = mci->csrows[i]; in dct_init_csrows()
3402 pvt->mc_node_id, i); in dct_init_csrows()
3406 csrow->channels[0]->dimm->nr_pages = nr_pages; in dct_init_csrows()
3410 if (pvt->fam != 0xf && row_dct1) { in dct_init_csrows()
3413 csrow->channels[1]->dimm->nr_pages = row_dct1_pages; in dct_init_csrows()
3419 /* Determine DIMM ECC mode: */ in dct_init_csrows()
3420 if (pvt->nbcfg & NBCFG_ECC_ENABLE) { in dct_init_csrows()
3421 edac_mode = (pvt->nbcfg & NBCFG_CHIPKILL) in dct_init_csrows()
3426 for (j = 0; j < pvt->max_mcs; j++) { in dct_init_csrows()
3427 dimm = csrow->channels[j]->dimm; in dct_init_csrows()
3428 dimm->mtype = pvt->dram_type; in dct_init_csrows()
3429 dimm->edac_mode = edac_mode; in dct_init_csrows()
3430 dimm->grain = 64; in dct_init_csrows()
3463 nbe = reg->l & MSR_MCGCTL_NBE; in nb_mce_bank_enabled_on_node()
3466 cpu, reg->q, in nb_mce_bank_enabled_on_node()
3486 return -ENOMEM; in toggle_ecc_err_reporting()
3498 if (reg->l & MSR_MCGCTL_NBE) in toggle_ecc_err_reporting()
3499 s->flags.nb_mce_enable = 1; in toggle_ecc_err_reporting()
3501 reg->l |= MSR_MCGCTL_NBE; in toggle_ecc_err_reporting()
3506 if (!s->flags.nb_mce_enable) in toggle_ecc_err_reporting()
3507 reg->l &= ~MSR_MCGCTL_NBE; in toggle_ecc_err_reporting()
3530 s->old_nbctl = value & mask; in enable_ecc_error_reporting()
3531 s->nbctl_valid = true; in enable_ecc_error_reporting()
3544 s->flags.nb_ecc_prev = 0; in enable_ecc_error_reporting()
3560 s->flags.nb_ecc_prev = 1; in enable_ecc_error_reporting()
3574 if (!s->nbctl_valid) in restore_ecc_error_reporting()
3579 value |= s->old_nbctl; in restore_ecc_error_reporting()
3583 /* restore previous BIOS DRAM ECC "off" setting we force-enabled */ in restore_ecc_error_reporting()
3584 if (!s->flags.nb_ecc_prev) { in restore_ecc_error_reporting()
3597 u16 nid = pvt->mc_node_id; in dct_ecc_enabled()
3602 amd64_read_pci_cfg(pvt->F3, NBCFG, &value); in dct_ecc_enabled()
3622 u16 nid = pvt->mc_node_id; in umc_ecc_enabled()
3627 umc = &pvt->umc[i]; in umc_ecc_enabled()
3630 if (!(umc->sdp_ctrl & UMC_SDP_INIT)) in umc_ecc_enabled()
3635 if (umc->umc_cap_hi & UMC_ECC_ENABLED) in umc_ecc_enabled()
3659 if (pvt->umc[i].sdp_ctrl & UMC_SDP_INIT) { in umc_determine_edac_ctl_cap()
3660 ecc_en &= !!(pvt->umc[i].umc_cap_hi & UMC_ECC_ENABLED); in umc_determine_edac_ctl_cap()
3661 cpk_en &= !!(pvt->umc[i].umc_cap_hi & UMC_ECC_CHIPKILL_CAP); in umc_determine_edac_ctl_cap()
3663 dev_x4 &= !!(pvt->umc[i].dimm_cfg & BIT(6)); in umc_determine_edac_ctl_cap()
3664 dev_x16 &= !!(pvt->umc[i].dimm_cfg & BIT(7)); in umc_determine_edac_ctl_cap()
3670 mci->edac_ctl_cap |= EDAC_FLAG_SECDED; in umc_determine_edac_ctl_cap()
3676 mci->edac_ctl_cap |= EDAC_FLAG_S4ECD4ED; in umc_determine_edac_ctl_cap()
3678 mci->edac_ctl_cap |= EDAC_FLAG_S16ECD16ED; in umc_determine_edac_ctl_cap()
3680 mci->edac_ctl_cap |= EDAC_FLAG_S8ECD8ED; in umc_determine_edac_ctl_cap()
3686 struct amd64_pvt *pvt = mci->pvt_info; in dct_setup_mci_misc_attrs()
3688 mci->mtype_cap = MEM_FLAG_DDR2 | MEM_FLAG_RDDR2; in dct_setup_mci_misc_attrs()
3689 mci->edac_ctl_cap = EDAC_FLAG_NONE; in dct_setup_mci_misc_attrs()
3691 if (pvt->nbcap & NBCAP_SECDED) in dct_setup_mci_misc_attrs()
3692 mci->edac_ctl_cap |= EDAC_FLAG_SECDED; in dct_setup_mci_misc_attrs()
3694 if (pvt->nbcap & NBCAP_CHIPKILL) in dct_setup_mci_misc_attrs()
3695 mci->edac_ctl_cap |= EDAC_FLAG_S4ECD4ED; in dct_setup_mci_misc_attrs()
3697 mci->edac_cap = dct_determine_edac_cap(pvt); in dct_setup_mci_misc_attrs()
3698 mci->mod_name = EDAC_MOD_STR; in dct_setup_mci_misc_attrs()
3699 mci->ctl_name = pvt->ctl_name; in dct_setup_mci_misc_attrs()
3700 mci->dev_name = pci_name(pvt->F3); in dct_setup_mci_misc_attrs()
3701 mci->ctl_page_to_phys = NULL; in dct_setup_mci_misc_attrs()
3704 mci->set_sdram_scrub_rate = set_scrub_rate; in dct_setup_mci_misc_attrs()
3705 mci->get_sdram_scrub_rate = get_scrub_rate; in dct_setup_mci_misc_attrs()
3712 struct amd64_pvt *pvt = mci->pvt_info; in umc_setup_mci_misc_attrs()
3714 mci->mtype_cap = MEM_FLAG_DDR4 | MEM_FLAG_RDDR4; in umc_setup_mci_misc_attrs()
3715 mci->edac_ctl_cap = EDAC_FLAG_NONE; in umc_setup_mci_misc_attrs()
3719 mci->edac_cap = umc_determine_edac_cap(pvt); in umc_setup_mci_misc_attrs()
3720 mci->mod_name = EDAC_MOD_STR; in umc_setup_mci_misc_attrs()
3721 mci->ctl_name = pvt->ctl_name; in umc_setup_mci_misc_attrs()
3722 mci->dev_name = pci_name(pvt->F3); in umc_setup_mci_misc_attrs()
3723 mci->ctl_page_to_phys = NULL; in umc_setup_mci_misc_attrs()
3730 int ret = reserve_mc_sibling_devs(pvt, pvt->f1_id, pvt->f2_id); in dct_hw_info_get()
3745 pvt->umc = kcalloc(pvt->max_mcs, sizeof(struct amd64_umc), GFP_KERNEL); in umc_hw_info_get()
3746 if (!pvt->umc) in umc_hw_info_get()
3747 return -ENOMEM; in umc_hw_info_get()
3776 u8 ch = (m->ipid & GENMASK(31, 0)) >> 20; in gpu_get_err_info()
3777 u8 phy = ((m->ipid >> 12) & 0xf); in gpu_get_err_info()
3779 err->channel = ch % 2 ? phy + 4 : phy; in gpu_get_err_info()
3780 err->csrow = phy; in gpu_get_err_info()
3786 u32 addr_mask_orig = pvt->csels[umc].csmasks[csrow_nr]; in gpu_addr_mask_to_cs_size()
3811 umc = &pvt->umc[i]; in gpu_dump_misc_regs()
3813 edac_dbg(1, "UMC%d UMC cfg: 0x%x\n", i, umc->umc_cfg); in gpu_dump_misc_regs()
3814 edac_dbg(1, "UMC%d SDP ctrl: 0x%x\n", i, umc->sdp_ctrl); in gpu_dump_misc_regs()
3815 edac_dbg(1, "UMC%d ECC ctrl: 0x%x\n", i, umc->ecc_ctrl); in gpu_dump_misc_regs()
3828 nr_pages <<= 20 - PAGE_SHIFT; in gpu_get_csrow_nr_pages()
3838 struct amd64_pvt *pvt = mci->pvt_info; in gpu_init_csrows()
3847 dimm = mci->csrows[umc]->channels[cs]->dimm; in gpu_init_csrows()
3850 pvt->mc_node_id, cs); in gpu_init_csrows()
3852 dimm->nr_pages = gpu_get_csrow_nr_pages(pvt, umc, cs); in gpu_init_csrows()
3853 dimm->edac_mode = EDAC_SECDED; in gpu_init_csrows()
3854 dimm->mtype = MEM_HBM2; in gpu_init_csrows()
3855 dimm->dtype = DEV_X16; in gpu_init_csrows()
3856 dimm->grain = 64; in gpu_init_csrows()
3863 struct amd64_pvt *pvt = mci->pvt_info; in gpu_setup_mci_misc_attrs()
3865 mci->mtype_cap = MEM_FLAG_HBM2; in gpu_setup_mci_misc_attrs()
3866 mci->edac_ctl_cap = EDAC_FLAG_SECDED; in gpu_setup_mci_misc_attrs()
3868 mci->edac_cap = EDAC_FLAG_EC; in gpu_setup_mci_misc_attrs()
3869 mci->mod_name = EDAC_MOD_STR; in gpu_setup_mci_misc_attrs()
3870 mci->ctl_name = pvt->ctl_name; in gpu_setup_mci_misc_attrs()
3871 mci->dev_name = pci_name(pvt->F3); in gpu_setup_mci_misc_attrs()
3872 mci->ctl_page_to_phys = NULL; in gpu_setup_mci_misc_attrs()
3907 u8 nid = pvt->mc_node_id; in gpu_read_mc_regs()
3914 umc = &pvt->umc[i]; in gpu_read_mc_regs()
3916 amd_smn_read(nid, umc_base + UMCCH_UMC_CFG, &umc->umc_cfg); in gpu_read_mc_regs()
3917 amd_smn_read(nid, umc_base + UMCCH_SDP_CTRL, &umc->sdp_ctrl); in gpu_read_mc_regs()
3918 amd_smn_read(nid, umc_base + UMCCH_ECC_CTRL, &umc->ecc_ctrl); in gpu_read_mc_regs()
3931 base = &pvt->csels[umc].csbases[cs]; in gpu_read_base_mask()
3933 if (!amd_smn_read(pvt->mc_node_id, base_reg, base)) { in gpu_read_base_mask()
3939 mask = &pvt->csels[umc].csmasks[cs]; in gpu_read_base_mask()
3941 if (!amd_smn_read(pvt->mc_node_id, mask_reg, mask)) { in gpu_read_base_mask()
3954 pvt->csels[umc].b_cnt = 8; in gpu_prep_chip_selects()
3955 pvt->csels[umc].m_cnt = 8; in gpu_prep_chip_selects()
3967 pvt->umc = kcalloc(pvt->max_mcs, sizeof(struct amd64_umc), GFP_KERNEL); in gpu_hw_info_get()
3968 if (!pvt->umc) in gpu_hw_info_get()
3969 return -ENOMEM; in gpu_hw_info_get()
3980 pci_dev_put(pvt->F1); in hw_info_put()
3981 pci_dev_put(pvt->F2); in hw_info_put()
3982 kfree(pvt->umc); in hw_info_put()
4013 pvt->ext_model = boot_cpu_data.x86_model >> 4; in per_family_init()
4014 pvt->stepping = boot_cpu_data.x86_stepping; in per_family_init()
4015 pvt->model = boot_cpu_data.x86_model; in per_family_init()
4016 pvt->fam = boot_cpu_data.x86; in per_family_init()
4017 pvt->max_mcs = 2; in per_family_init()
4023 if (pvt->fam >= 0x17) in per_family_init()
4024 pvt->ops = &umc_ops; in per_family_init()
4026 pvt->ops = &dct_ops; in per_family_init()
4028 switch (pvt->fam) { in per_family_init()
4030 pvt->ctl_name = (pvt->ext_model >= K8_REV_F) ? in per_family_init()
4032 pvt->f1_id = PCI_DEVICE_ID_AMD_K8_NB_ADDRMAP; in per_family_init()
4033 pvt->f2_id = PCI_DEVICE_ID_AMD_K8_NB_MEMCTL; in per_family_init()
4034 pvt->ops->map_sysaddr_to_csrow = k8_map_sysaddr_to_csrow; in per_family_init()
4035 pvt->ops->dbam_to_cs = k8_dbam_to_chip_select; in per_family_init()
4039 pvt->ctl_name = "F10h"; in per_family_init()
4040 pvt->f1_id = PCI_DEVICE_ID_AMD_10H_NB_MAP; in per_family_init()
4041 pvt->f2_id = PCI_DEVICE_ID_AMD_10H_NB_DRAM; in per_family_init()
4042 pvt->ops->dbam_to_cs = f10_dbam_to_chip_select; in per_family_init()
4046 switch (pvt->model) { in per_family_init()
4048 pvt->ctl_name = "F15h_M30h"; in per_family_init()
4049 pvt->f1_id = PCI_DEVICE_ID_AMD_15H_M30H_NB_F1; in per_family_init()
4050 pvt->f2_id = PCI_DEVICE_ID_AMD_15H_M30H_NB_F2; in per_family_init()
4053 pvt->ctl_name = "F15h_M60h"; in per_family_init()
4054 pvt->f1_id = PCI_DEVICE_ID_AMD_15H_M60H_NB_F1; in per_family_init()
4055 pvt->f2_id = PCI_DEVICE_ID_AMD_15H_M60H_NB_F2; in per_family_init()
4056 pvt->ops->dbam_to_cs = f15_m60h_dbam_to_chip_select; in per_family_init()
4060 return -ENODEV; in per_family_init()
4062 pvt->ctl_name = "F15h"; in per_family_init()
4063 pvt->f1_id = PCI_DEVICE_ID_AMD_15H_NB_F1; in per_family_init()
4064 pvt->f2_id = PCI_DEVICE_ID_AMD_15H_NB_F2; in per_family_init()
4065 pvt->ops->dbam_to_cs = f15_dbam_to_chip_select; in per_family_init()
4071 switch (pvt->model) { in per_family_init()
4073 pvt->ctl_name = "F16h_M30h"; in per_family_init()
4074 pvt->f1_id = PCI_DEVICE_ID_AMD_16H_M30H_NB_F1; in per_family_init()
4075 pvt->f2_id = PCI_DEVICE_ID_AMD_16H_M30H_NB_F2; in per_family_init()
4078 pvt->ctl_name = "F16h"; in per_family_init()
4079 pvt->f1_id = PCI_DEVICE_ID_AMD_16H_NB_F1; in per_family_init()
4080 pvt->f2_id = PCI_DEVICE_ID_AMD_16H_NB_F2; in per_family_init()
4086 switch (pvt->model) { in per_family_init()
4088 pvt->ctl_name = "F17h_M10h"; in per_family_init()
4091 pvt->ctl_name = "F17h_M30h"; in per_family_init()
4092 pvt->max_mcs = 8; in per_family_init()
4095 pvt->ctl_name = "F17h_M60h"; in per_family_init()
4098 pvt->ctl_name = "F17h_M70h"; in per_family_init()
4101 pvt->ctl_name = "F17h"; in per_family_init()
4107 pvt->ctl_name = "F18h"; in per_family_init()
4111 switch (pvt->model) { in per_family_init()
4113 pvt->ctl_name = "F19h"; in per_family_init()
4114 pvt->max_mcs = 8; in per_family_init()
4117 pvt->ctl_name = "F19h_M10h"; in per_family_init()
4118 pvt->max_mcs = 12; in per_family_init()
4119 pvt->flags.zn_regs_v2 = 1; in per_family_init()
4122 pvt->ctl_name = "F19h_M20h"; in per_family_init()
4125 if (pvt->F3->device == PCI_DEVICE_ID_AMD_MI200_DF_F3) { in per_family_init()
4126 pvt->ctl_name = "MI200"; in per_family_init()
4127 pvt->max_mcs = 4; in per_family_init()
4128 pvt->ops = &gpu_ops; in per_family_init()
4130 pvt->ctl_name = "F19h_M30h"; in per_family_init()
4131 pvt->max_mcs = 8; in per_family_init()
4135 pvt->ctl_name = "F19h_M50h"; in per_family_init()
4138 pvt->ctl_name = "F19h_M60h"; in per_family_init()
4139 pvt->flags.zn_regs_v2 = 1; in per_family_init()
4142 pvt->ctl_name = "F19h_M70h"; in per_family_init()
4143 pvt->flags.zn_regs_v2 = 1; in per_family_init()
4146 pvt->ctl_name = "F19h_MA0h"; in per_family_init()
4147 pvt->max_mcs = 12; in per_family_init()
4148 pvt->flags.zn_regs_v2 = 1; in per_family_init()
4154 switch (pvt->model) { in per_family_init()
4156 pvt->ctl_name = "F1Ah"; in per_family_init()
4157 pvt->max_mcs = 12; in per_family_init()
4158 pvt->flags.zn_regs_v2 = 1; in per_family_init()
4161 pvt->ctl_name = "F1Ah_M40h"; in per_family_init()
4162 pvt->flags.zn_regs_v2 = 1; in per_family_init()
4169 return -ENODEV; in per_family_init()
4187 int ret = -ENOMEM; in init_one_instance()
4194 layers[0].size = (pvt->F3->device == PCI_DEVICE_ID_AMD_MI200_DF_F3) ? in init_one_instance()
4195 pvt->max_mcs : pvt->csels[0].b_cnt; in init_one_instance()
4198 layers[1].size = (pvt->F3->device == PCI_DEVICE_ID_AMD_MI200_DF_F3) ? in init_one_instance()
4199 pvt->csels[0].b_cnt : pvt->max_mcs; in init_one_instance()
4202 mci = edac_mc_alloc(pvt->mc_node_id, ARRAY_SIZE(layers), layers, 0); in init_one_instance()
4206 mci->pvt_info = pvt; in init_one_instance()
4207 mci->pdev = &pvt->F3->dev; in init_one_instance()
4209 pvt->ops->setup_mci_misc_attrs(mci); in init_one_instance()
4211 ret = -ENODEV; in init_one_instance()
4226 for (dct = 0; dct < pvt->max_mcs; dct++) { in instance_has_memory()
4236 struct pci_dev *F3 = node_to_amd_nb(nid)->misc; in probe_one_instance()
4241 ret = -ENOMEM; in probe_one_instance()
4252 pvt->mc_node_id = nid; in probe_one_instance()
4253 pvt->F3 = F3; in probe_one_instance()
4259 ret = pvt->ops->hw_info_get(pvt); in probe_one_instance()
4269 if (!pvt->ops->ecc_enabled(pvt)) { in probe_one_instance()
4270 ret = -ENODEV; in probe_one_instance()
4295 amd64_info("%s detected (node %d).\n", pvt->ctl_name, pvt->mc_node_id); in probe_one_instance()
4298 pvt->ops->dump_misc_regs(pvt); in probe_one_instance()
4316 struct pci_dev *F3 = node_to_amd_nb(nid)->misc; in remove_one_instance()
4322 mci = edac_mc_del_mc(&F3->dev); in remove_one_instance()
4326 pvt = mci->pvt_info; in remove_one_instance()
4334 mci->pvt_info = NULL; in remove_one_instance()
4369 int err = -ENODEV; in amd64_edac_init()
4373 return -EBUSY; in amd64_edac_init()
4377 return -EBUSY; in amd64_edac_init()
4380 return -ENODEV; in amd64_edac_init()
4383 return -ENODEV; in amd64_edac_init()
4387 err = -ENOMEM; in amd64_edac_init()
4400 while (--i >= 0) in amd64_edac_init()
4408 err = -ENODEV; in amd64_edac_init()
4421 amd64_err("%s on 32-bit is unsupported. USE AT YOUR OWN RISK!\n", EDAC_MOD_STR); in amd64_edac_init()