Lines Matching refs:pvt
16 static inline u32 get_umc_reg(struct amd64_pvt *pvt, u32 reg) in get_umc_reg() argument
18 if (!pvt->flags.zn_regs_v2) in get_umc_reg()
102 static void f15h_select_dct(struct amd64_pvt *pvt, u8 dct) in f15h_select_dct() argument
106 amd64_read_pci_cfg(pvt->F1, DCT_CFG_SEL, ®); 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()
126 static inline int amd64_read_dct_pci_cfg(struct amd64_pvt *pvt, u8 dct, in amd64_read_dct_pci_cfg() argument
129 switch (pvt->fam) { in amd64_read_dct_pci_cfg()
142 if (dct_ganging_enabled(pvt)) in amd64_read_dct_pci_cfg()
154 dct = (dct && pvt->model == 0x30) ? 3 : dct; in amd64_read_dct_pci_cfg()
155 f15h_select_dct(pvt, dct); in amd64_read_dct_pci_cfg()
166 return amd64_read_pci_cfg(pvt->F2, offset, val); in amd64_read_dct_pci_cfg()
187 static int __set_scrub_rate(struct amd64_pvt *pvt, u32 new_bw, u32 min_rate) in __set_scrub_rate() argument
215 if (pvt->fam == 0x15 && pvt->model == 0x60) { in __set_scrub_rate()
216 f15h_select_dct(pvt, 0); in __set_scrub_rate()
217 pci_write_bits32(pvt->F2, F15H_M60H_SCRCTRL, scrubval, 0x001F); in __set_scrub_rate()
218 f15h_select_dct(pvt, 1); 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() local
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()
241 f15h_select_dct(pvt, 0); in set_scrub_rate()
243 if (pvt->model == 0x60) in set_scrub_rate()
246 return __set_scrub_rate(pvt, bw, min_scrubrate); in set_scrub_rate()
251 struct amd64_pvt *pvt = mci->pvt_info; in get_scrub_rate() local
255 if (pvt->fam == 0x15) { in get_scrub_rate()
257 if (pvt->model < 0x10) in get_scrub_rate()
258 f15h_select_dct(pvt, 0); 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()
283 static bool base_limit_match(struct amd64_pvt *pvt, u64 sys_addr, u8 nid) in base_limit_match() argument
295 return ((addr >= get_dram_base(pvt, nid)) && in base_limit_match()
296 (addr <= get_dram_limit(pvt, nid))); in base_limit_match()
308 struct amd64_pvt *pvt; in find_mc_by_sys_addr() local
316 pvt = mci->pvt_info; in find_mc_by_sys_addr()
323 intlv_en = dram_intlv_en(pvt, 0); in find_mc_by_sys_addr()
327 if (base_limit_match(pvt, sys_addr, node_id)) in find_mc_by_sys_addr()
343 if ((dram_intlv_sel(pvt, node_id) & intlv_en) == bits) in find_mc_by_sys_addr()
351 if (unlikely(!base_limit_match(pvt, sys_addr, node_id))) { in find_mc_by_sys_addr()
372 static void get_cs_base_and_mask(struct amd64_pvt *pvt, int csrow, u8 dct, in get_cs_base_and_mask() argument
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()
428 #define for_each_chip_select(i, dct, pvt) \ argument
429 for (i = 0; i < pvt->csels[dct].b_cnt; i++)
431 #define chip_select_base(i, dct, pvt) \ argument
432 pvt->csels[dct].csbases[i]
434 #define for_each_chip_select_mask(i, dct, pvt) \ argument
435 for (i = 0; i < pvt->csels[dct].m_cnt; i++)
438 for (i = 0; i < pvt->max_mcs; i++)
446 struct amd64_pvt *pvt; in input_addr_to_csrow() local
450 pvt = mci->pvt_info; in input_addr_to_csrow()
452 for_each_chip_select(csrow, 0, pvt) { in input_addr_to_csrow()
453 if (!csrow_enabled(csrow, 0, pvt)) in input_addr_to_csrow()
456 get_cs_base_and_mask(pvt, csrow, 0, &base, &mask); 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()
493 struct amd64_pvt *pvt = mci->pvt_info; in get_dram_hole_info() local
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()
508 if (!dhar_valid(pvt)) { in get_dram_hole_info()
510 pvt->mc_node_id); in get_dram_hole_info()
532 *hole_base = dhar_base(pvt); in get_dram_hole_info()
535 *hole_offset = (pvt->fam > 0xf) ? f10_dhar_offset(pvt) in get_dram_hole_info()
536 : k8_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() local
603 return sprintf(buf, "0x%x\n", pvt->injection.section); in inject_section_show()
617 struct amd64_pvt *pvt = mci->pvt_info; in inject_section_store() local
630 pvt->injection.section = (u32) value; in inject_section_store()
638 struct amd64_pvt *pvt = mci->pvt_info; in inject_word_show() local
639 return sprintf(buf, "0x%x\n", pvt->injection.word); in inject_word_show()
653 struct amd64_pvt *pvt = mci->pvt_info; in inject_word_store() local
666 pvt->injection.word = (u32) value; in inject_word_store()
675 struct amd64_pvt *pvt = mci->pvt_info; in inject_ecc_vector_show() local
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() local
702 pvt->injection.bit_map = (u32) value; in inject_ecc_vector_store()
715 struct amd64_pvt *pvt = mci->pvt_info; in inject_read_store() local
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() local
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() local
814 if (pvt->fam >= 0x10 && pvt->fam <= 0x16) in inj_is_visible()
857 struct amd64_pvt *pvt = mci->pvt_info; in sys_addr_to_dram_addr() local
861 dram_base = get_dram_base(pvt, pvt->mc_node_id); in sys_addr_to_dram_addr()
912 struct amd64_pvt *pvt; in dram_addr_to_input_addr() local
916 pvt = mci->pvt_info; in dram_addr_to_input_addr()
922 intlv_shift = num_node_interleave_bits(dram_intlv_en(pvt, 0)); in dram_addr_to_input_addr()
1327 static unsigned long dct_determine_edac_cap(struct amd64_pvt *pvt) in dct_determine_edac_cap() argument
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()
1342 static unsigned long umc_determine_edac_cap(struct amd64_pvt *pvt) in umc_determine_edac_cap() argument
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()
1368 static void dct_debug_display_dimm_sizes(struct amd64_pvt *pvt, u8 ctrl) in dct_debug_display_dimm_sizes() argument
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()
1385 dcsb = (ctrl && !dct_ganging_enabled(pvt)) ? 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()
1424 static void debug_dump_dramcfg_low(struct amd64_pvt *pvt, u32 dclr, int chan) in debug_dump_dramcfg_low() argument
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()
1465 static int umc_get_cs_mode(int dimm, u8 ctrl, struct amd64_pvt *pvt) in umc_get_cs_mode() argument
1470 if (csrow_enabled(2 * dimm, ctrl, pvt)) in umc_get_cs_mode()
1473 if (csrow_enabled(2 * dimm + 1, ctrl, pvt)) in umc_get_cs_mode()
1477 if (csrow_sec_enabled(2 * dimm + 1, ctrl, pvt)) in umc_get_cs_mode()
1485 for_each_chip_select(base, ctrl, pvt) in umc_get_cs_mode()
1486 count += csrow_enabled(base, ctrl, pvt); in umc_get_cs_mode()
1489 pvt->csels[ctrl].csmasks[0] == pvt->csels[ctrl].csmasks[1]) { in umc_get_cs_mode()
1533 static int umc_addr_mask_to_cs_size(struct amd64_pvt *pvt, u8 umc, in umc_addr_mask_to_cs_size() argument
1572 if (!pvt->flags.zn_regs_v2) 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()
1584 static void umc_debug_display_dimm_sizes(struct amd64_pvt *pvt, u8 ctrl) in umc_debug_display_dimm_sizes() argument
1594 cs_mode = umc_get_cs_mode(dimm, ctrl, pvt); in umc_debug_display_dimm_sizes()
1596 size0 = umc_addr_mask_to_cs_size(pvt, ctrl, cs_mode, cs0); in umc_debug_display_dimm_sizes()
1597 size1 = umc_addr_mask_to_cs_size(pvt, ctrl, cs_mode, cs1); in umc_debug_display_dimm_sizes()
1605 static void umc_dump_misc_regs(struct amd64_pvt *pvt) in umc_dump_misc_regs() argument
1612 umc = &pvt->umc[i]; 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()
1637 amd_smn_read(pvt->mc_node_id, in umc_dump_misc_regs()
1638 umc_base + get_umc_reg(pvt, UMCCH_ADDR_CFG), in umc_dump_misc_regs()
1644 umc_debug_display_dimm_sizes(pvt, i); in umc_dump_misc_regs()
1648 static void dct_dump_misc_regs(struct amd64_pvt *pvt) in dct_dump_misc_regs() argument
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()
1666 : f10_dhar_offset(pvt)); in dct_dump_misc_regs()
1668 dct_debug_display_dimm_sizes(pvt, 0); in dct_dump_misc_regs()
1671 if (pvt->fam == 0xf) in dct_dump_misc_regs()
1674 dct_debug_display_dimm_sizes(pvt, 1); in dct_dump_misc_regs()
1677 if (!dct_ganging_enabled(pvt)) in dct_dump_misc_regs()
1678 debug_dump_dramcfg_low(pvt, pvt->dclr1, 1); in dct_dump_misc_regs()
1680 edac_dbg(1, " DramHoleValid: %s\n", dhar_valid(pvt) ? "yes" : "no"); in dct_dump_misc_regs()
1682 amd64_info("using x%u syndromes.\n", pvt->ecc_sym_sz); in dct_dump_misc_regs()
1688 static void dct_prep_chip_selects(struct amd64_pvt *pvt) in dct_prep_chip_selects() argument
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()
1702 static void umc_prep_chip_selects(struct amd64_pvt *pvt) in umc_prep_chip_selects() argument
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()
1712 static void umc_read_base_mask(struct amd64_pvt *pvt) in umc_read_base_mask() argument
1726 for_each_chip_select(cs, umc, pvt) { in umc_read_base_mask()
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()
1743 umc_mask_reg_sec = get_umc_base(umc) + get_umc_reg(pvt, UMCCH_ADDR_MASK_SEC); in umc_read_base_mask()
1745 for_each_chip_select_mask(cs, umc, pvt) { 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()
1766 static void dct_read_base_mask(struct amd64_pvt *pvt) in dct_read_base_mask() argument
1770 for_each_chip_select(cs, 0, pvt) { in dct_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()
1776 if (!amd64_read_dct_pci_cfg(pvt, 0, reg0, base0)) in dct_read_base_mask()
1780 if (pvt->fam == 0xf) in dct_read_base_mask()
1783 if (!amd64_read_dct_pci_cfg(pvt, 1, reg0, base1)) in dct_read_base_mask()
1785 cs, *base1, (pvt->fam == 0x10) ? reg1 in dct_read_base_mask()
1789 for_each_chip_select_mask(cs, 0, pvt) { 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()
1795 if (!amd64_read_dct_pci_cfg(pvt, 0, reg0, mask0)) in dct_read_base_mask()
1799 if (pvt->fam == 0xf) in dct_read_base_mask()
1802 if (!amd64_read_dct_pci_cfg(pvt, 1, reg0, mask1)) in dct_read_base_mask()
1804 cs, *mask1, (pvt->fam == 0x10) ? reg1 in dct_read_base_mask()
1809 static void umc_determine_memory_type(struct amd64_pvt *pvt) in umc_determine_memory_type() argument
1815 umc = &pvt->umc[i]; in umc_determine_memory_type()
1826 if (pvt->flags.zn_regs_v2 && ((umc->umc_cfg & GENMASK(2, 0)) == 0x1)) { in umc_determine_memory_type()
1846 static void dct_determine_memory_type(struct amd64_pvt *pvt) in dct_determine_memory_type() argument
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()
1878 amd64_read_dct_pci_cfg(pvt, 0, DRAM_CONTROL, &dram_ctrl); 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()
1908 static u64 get_error_address(struct amd64_pvt *pvt, struct mce *m) in get_error_address() argument
1920 pvt = mci->pvt_info; in get_error_address()
1922 if (pvt->fam == 0xf) { 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()
1989 static void read_dram_base_limit_regs(struct amd64_pvt *pvt, unsigned range) in read_dram_base_limit_regs() argument
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()
2003 if (!dram_rw(pvt, range)) 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()
2013 nb = node_to_amd_nb(dram_dst_node(pvt, range)); 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()
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() local
2070 if (pvt->nbcfg & NBCFG_CHIPKILL) { in k8_map_sysaddr_to_csrow()
2111 static int k8_dbam_to_chip_select(struct amd64_pvt *pvt, u8 dct, in k8_dbam_to_chip_select() argument
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()
2215 static int f10_dbam_to_chip_select(struct amd64_pvt *pvt, u8 dct, in f10_dbam_to_chip_select() argument
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()
2231 static int f15_dbam_to_chip_select(struct amd64_pvt *pvt, u8 dct, in f15_dbam_to_chip_select() argument
2240 static int f15_m60h_dbam_to_chip_select(struct amd64_pvt *pvt, u8 dct, in f15_m60h_dbam_to_chip_select() argument
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()
2253 } else if (pvt->dram_type == MEM_LRDDR3) { in f15_m60h_dbam_to_chip_select()
2273 static int f16_dbam_to_chip_select(struct amd64_pvt *pvt, u8 dct, in f16_dbam_to_chip_select() argument
2285 static void read_dram_ctl_register(struct amd64_pvt *pvt) in read_dram_ctl_register() argument
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()
2296 (dct_ganging_enabled(pvt) ? "ganged" : "unganged")); in read_dram_ctl_register()
2298 if (!dct_ganging_enabled(pvt)) in read_dram_ctl_register()
2300 (dct_high_range_enabled(pvt) ? "yes" : "no")); in read_dram_ctl_register()
2303 (dct_data_intlv_enabled(pvt) ? "enabled" : "disabled"), in read_dram_ctl_register()
2304 (dct_memory_cleared(pvt) ? "yes" : "no")); in read_dram_ctl_register()
2308 (dct_interleave_enabled(pvt) ? "enabled" : "disabled"), in read_dram_ctl_register()
2309 dct_sel_interleave_addr(pvt)); in read_dram_ctl_register()
2312 amd64_read_pci_cfg(pvt->F2, DCT_SEL_HI, &pvt->dct_sel_hi); in read_dram_ctl_register()
2319 static u8 f15_m30h_determine_channel(struct amd64_pvt *pvt, u64 sys_addr, in f15_m30h_determine_channel() argument
2333 u8 intlv_addr = dct_sel_interleave_addr(pvt); in f15_m30h_determine_channel()
2350 static u8 f1x_determine_channel(struct amd64_pvt *pvt, u64 sys_addr, in f1x_determine_channel() argument
2353 u8 dct_sel_high = (pvt->dct_sel_lo >> 1) & 1; in f1x_determine_channel()
2355 if (dct_ganging_enabled(pvt)) in f1x_determine_channel()
2364 if (dct_interleave_enabled(pvt)) { in f1x_determine_channel()
2365 u8 intlv_addr = dct_sel_interleave_addr(pvt); in f1x_determine_channel()
2387 if (dct_high_range_enabled(pvt)) in f1x_determine_channel()
2394 static u64 f1x_get_norm_dct_addr(struct amd64_pvt *pvt, u8 range, in f1x_get_norm_dct_addr() argument
2399 u64 dram_base = get_dram_base(pvt, range); in f1x_get_norm_dct_addr()
2400 u64 hole_off = f10_dhar_offset(pvt); in f1x_get_norm_dct_addr()
2401 u64 dct_sel_base_off = (u64)(pvt->dct_sel_hi & 0xFFFFFC00) << 16; in f1x_get_norm_dct_addr()
2416 dct_sel_base_addr < dhar_base(pvt)) && in f1x_get_norm_dct_addr()
2417 dhar_valid(pvt) && in f1x_get_norm_dct_addr()
2432 if (dhar_valid(pvt) && (sys_addr >= BIT_64(32))) in f1x_get_norm_dct_addr()
2445 static int f10_process_possible_spare(struct amd64_pvt *pvt, u8 dct, int csrow) in f10_process_possible_spare() argument
2449 if (online_spare_swap_done(pvt, dct) && in f10_process_possible_spare()
2450 csrow == online_spare_bad_dramcs(pvt, dct)) { in f10_process_possible_spare()
2452 for_each_chip_select(tmp_cs, dct, pvt) { in f10_process_possible_spare()
2453 if (chip_select_base(tmp_cs, dct, pvt) & 0x2) { in f10_process_possible_spare()
2473 struct amd64_pvt *pvt; in f1x_lookup_addr_in_dct() local
2482 pvt = mci->pvt_info; in f1x_lookup_addr_in_dct()
2486 for_each_chip_select(csrow, dct, pvt) { in f1x_lookup_addr_in_dct()
2487 if (!csrow_enabled(csrow, dct, pvt)) in f1x_lookup_addr_in_dct()
2490 get_cs_base_and_mask(pvt, csrow, dct, &cs_base, &cs_mask); in f1x_lookup_addr_in_dct()
2501 if (pvt->fam == 0x15 && pvt->model >= 0x30) { in f1x_lookup_addr_in_dct()
2505 cs_found = f10_process_possible_spare(pvt, dct, csrow); in f1x_lookup_addr_in_dct()
2519 static u64 f1x_swap_interleaved_region(struct amd64_pvt *pvt, u64 sys_addr) in f1x_swap_interleaved_region() argument
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()
2549 static int f1x_match_to_this_node(struct amd64_pvt *pvt, unsigned range, in f1x_match_to_this_node() argument
2558 u8 node_id = dram_dst_node(pvt, range); in f1x_match_to_this_node()
2559 u8 intlv_en = dram_intlv_en(pvt, range); in f1x_match_to_this_node()
2560 u32 intlv_sel = dram_intlv_sel(pvt, range); in f1x_match_to_this_node()
2563 range, sys_addr, get_dram_limit(pvt, range)); in f1x_match_to_this_node()
2565 if (dhar_valid(pvt) && in f1x_match_to_this_node()
2566 dhar_base(pvt) <= sys_addr && in f1x_match_to_this_node()
2576 sys_addr = f1x_swap_interleaved_region(pvt, sys_addr); in f1x_match_to_this_node()
2578 dct_sel_base = dct_sel_baseaddr(pvt); in f1x_match_to_this_node()
2584 if (dct_high_range_enabled(pvt) && in f1x_match_to_this_node()
2585 !dct_ganging_enabled(pvt) && in f1x_match_to_this_node()
2589 channel = f1x_determine_channel(pvt, sys_addr, high_range, intlv_en); in f1x_match_to_this_node()
2591 chan_addr = f1x_get_norm_dct_addr(pvt, range, sys_addr, in f1x_match_to_this_node()
2600 if (dct_interleave_enabled(pvt) && in f1x_match_to_this_node()
2601 !dct_high_range_enabled(pvt) && in f1x_match_to_this_node()
2602 !dct_ganging_enabled(pvt)) { in f1x_match_to_this_node()
2604 if (dct_sel_interleave_addr(pvt) != 1) { in f1x_match_to_this_node()
2605 if (dct_sel_interleave_addr(pvt) == 0x3) in f1x_match_to_this_node()
2629 static int f15_m30h_match_to_this_node(struct amd64_pvt *pvt, unsigned range, in f15_m30h_match_to_this_node() argument
2639 u64 dhar_offset = f10_dhar_offset(pvt); in f15_m30h_match_to_this_node()
2640 u8 intlv_addr = dct_sel_interleave_addr(pvt); in f15_m30h_match_to_this_node()
2641 u8 node_id = dram_dst_node(pvt, range); in f15_m30h_match_to_this_node()
2642 u8 intlv_en = dram_intlv_en(pvt, range); 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()
2651 range, sys_addr, get_dram_limit(pvt, range)); in f15_m30h_match_to_this_node()
2653 if (!(get_dram_base(pvt, range) <= sys_addr) && in f15_m30h_match_to_this_node()
2654 !(get_dram_limit(pvt, range) >= sys_addr)) in f15_m30h_match_to_this_node()
2657 if (dhar_valid(pvt) && in f15_m30h_match_to_this_node()
2658 dhar_base(pvt) <= sys_addr && in f15_m30h_match_to_this_node()
2666 dct_base = (u64) dct_sel_baseaddr(pvt); in f15_m30h_match_to_this_node()
2680 if (pvt->model >= 0x60) in f15_m30h_match_to_this_node()
2681 channel = f1x_determine_channel(pvt, sys_addr, false, intlv_en); in f15_m30h_match_to_this_node()
2683 channel = f15_m30h_determine_channel(pvt, sys_addr, intlv_en, in f15_m30h_match_to_this_node()
2723 amd64_read_pci_cfg(pvt->F1, in f15_m30h_match_to_this_node()
2729 f15h_select_dct(pvt, channel); in f15_m30h_match_to_this_node()
2751 static int f1x_translate_sysaddr_to_cs(struct amd64_pvt *pvt, in f1x_translate_sysaddr_to_cs() argument
2759 if (!dram_rw(pvt, range)) in f1x_translate_sysaddr_to_cs()
2762 if (pvt->fam == 0x15 && pvt->model >= 0x30) in f1x_translate_sysaddr_to_cs()
2763 cs_found = f15_m30h_match_to_this_node(pvt, range, in f1x_translate_sysaddr_to_cs()
2767 else if ((get_dram_base(pvt, range) <= sys_addr) && in f1x_translate_sysaddr_to_cs()
2768 (get_dram_limit(pvt, range) >= sys_addr)) { in f1x_translate_sysaddr_to_cs()
2769 cs_found = f1x_match_to_this_node(pvt, range, in f1x_translate_sysaddr_to_cs()
2788 struct amd64_pvt *pvt = mci->pvt_info; in f1x_map_sysaddr_to_csrow() local
2792 err->csrow = f1x_translate_sysaddr_to_cs(pvt, sys_addr, &err->channel); in f1x_map_sysaddr_to_csrow()
2803 if (dct_ganging_enabled(pvt)) in f1x_map_sysaddr_to_csrow()
2944 struct amd64_pvt *pvt = mci->pvt_info; in get_channel_from_ecc_syndrome() local
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()
3013 struct amd64_pvt *pvt; in decode_bus_error() local
3024 pvt = mci->pvt_info; in decode_bus_error()
3036 sys_addr = get_error_address(pvt, m); in decode_bus_error()
3041 pvt->ops->map_sysaddr_to_csrow(mci, sys_addr, &err); in decode_bus_error()
3068 struct amd64_pvt *pvt; in decode_umc_error() local
3078 pvt = mci->pvt_info; 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()
3117 reserve_mc_sibling_devs(struct amd64_pvt *pvt, u16 pci_id1, u16 pci_id2) in reserve_mc_sibling_devs() argument
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()
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()
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()
3146 static void determine_ecc_sym_sz(struct amd64_pvt *pvt) in determine_ecc_sym_sz() argument
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()
3167 static void umc_read_mc_regs(struct amd64_pvt *pvt) in umc_read_mc_regs() argument
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()
3191 static void dct_read_mc_regs(struct amd64_pvt *pvt) in dct_read_mc_regs() argument
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()
3214 read_dram_ctl_register(pvt); in dct_read_mc_regs()
3220 read_dram_base_limit_regs(pvt, range); in dct_read_mc_regs()
3222 rw = dram_rw(pvt, range); in dct_read_mc_regs()
3228 get_dram_base(pvt, range), in dct_read_mc_regs()
3229 get_dram_limit(pvt, range)); in dct_read_mc_regs()
3232 dram_intlv_en(pvt, range) ? "Enabled" : "Disabled", in dct_read_mc_regs()
3235 dram_intlv_sel(pvt, range), in dct_read_mc_regs()
3236 dram_dst_node(pvt, range)); 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()
3247 if (!dct_ganging_enabled(pvt)) { 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()
3252 determine_ecc_sym_sz(pvt); in dct_read_mc_regs()
3289 static u32 dct_get_csrow_nr_pages(struct amd64_pvt *pvt, u8 dct, int csrow_nr) in dct_get_csrow_nr_pages() argument
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()
3307 static u32 umc_get_csrow_nr_pages(struct amd64_pvt *pvt, u8 dct, int csrow_nr_orig) in umc_get_csrow_nr_pages() argument
3312 cs_mode = umc_get_cs_mode(csrow_nr >> 1, dct, pvt); in umc_get_csrow_nr_pages()
3314 nr_pages = umc_addr_mask_to_cs_size(pvt, dct, cs_mode, csrow_nr); in umc_get_csrow_nr_pages()
3326 struct amd64_pvt *pvt = mci->pvt_info; in umc_init_csrows() local
3346 for_each_chip_select(cs, umc, pvt) { in umc_init_csrows()
3347 if (!csrow_enabled(cs, umc, pvt)) 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()
3370 struct amd64_pvt *pvt = mci->pvt_info; in dct_init_csrows() local
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()
3389 for_each_chip_select(i, 0, pvt) { in dct_init_csrows()
3390 bool row_dct0 = !!csrow_enabled(i, 0, pvt); in dct_init_csrows()
3393 if (pvt->fam != 0xf) in dct_init_csrows()
3394 row_dct1 = !!csrow_enabled(i, 1, pvt); in dct_init_csrows()
3402 pvt->mc_node_id, i); in dct_init_csrows()
3405 nr_pages = dct_get_csrow_nr_pages(pvt, 0, i); in dct_init_csrows()
3410 if (pvt->fam != 0xf && row_dct1) { in dct_init_csrows()
3411 int row_dct1_pages = dct_get_csrow_nr_pages(pvt, 1, i); 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()
3428 dimm->mtype = pvt->dram_type; in dct_init_csrows()
3595 static bool dct_ecc_enabled(struct amd64_pvt *pvt) in dct_ecc_enabled() argument
3597 u16 nid = pvt->mc_node_id; in dct_ecc_enabled()
3602 amd64_read_pci_cfg(pvt->F3, NBCFG, &value); in dct_ecc_enabled()
3619 static bool umc_ecc_enabled(struct amd64_pvt *pvt) in umc_ecc_enabled() argument
3622 u16 nid = pvt->mc_node_id; in umc_ecc_enabled()
3627 umc = &pvt->umc[i]; in umc_ecc_enabled()
3654 umc_determine_edac_ctl_cap(struct mem_ctl_info *mci, struct amd64_pvt *pvt) in umc_determine_edac_ctl_cap() argument
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()
3686 struct amd64_pvt *pvt = mci->pvt_info; in dct_setup_mci_misc_attrs() local
3691 if (pvt->nbcap & NBCAP_SECDED) in dct_setup_mci_misc_attrs()
3694 if (pvt->nbcap & NBCAP_CHIPKILL) in dct_setup_mci_misc_attrs()
3697 mci->edac_cap = dct_determine_edac_cap(pvt); 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()
3712 struct amd64_pvt *pvt = mci->pvt_info; in umc_setup_mci_misc_attrs() local
3717 umc_determine_edac_ctl_cap(mci, pvt); in umc_setup_mci_misc_attrs()
3719 mci->edac_cap = umc_determine_edac_cap(pvt); 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()
3728 static int dct_hw_info_get(struct amd64_pvt *pvt) in dct_hw_info_get() argument
3730 int ret = reserve_mc_sibling_devs(pvt, pvt->f1_id, pvt->f2_id); in dct_hw_info_get()
3735 dct_prep_chip_selects(pvt); in dct_hw_info_get()
3736 dct_read_base_mask(pvt); in dct_hw_info_get()
3737 dct_read_mc_regs(pvt); in dct_hw_info_get()
3738 dct_determine_memory_type(pvt); in dct_hw_info_get()
3743 static int umc_hw_info_get(struct amd64_pvt *pvt) in umc_hw_info_get() argument
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()
3749 umc_prep_chip_selects(pvt); in umc_hw_info_get()
3750 umc_read_base_mask(pvt); in umc_hw_info_get()
3751 umc_read_mc_regs(pvt); in umc_hw_info_get()
3752 umc_determine_memory_type(pvt); in umc_hw_info_get()
3783 static int gpu_addr_mask_to_cs_size(struct amd64_pvt *pvt, u8 umc, in gpu_addr_mask_to_cs_size() argument
3786 u32 addr_mask_orig = pvt->csels[umc].csmasks[csrow_nr]; in gpu_addr_mask_to_cs_size()
3791 static void gpu_debug_display_dimm_sizes(struct amd64_pvt *pvt, u8 ctrl) in gpu_debug_display_dimm_sizes() argument
3799 for_each_chip_select(cs, ctrl, pvt) { in gpu_debug_display_dimm_sizes()
3800 size = gpu_addr_mask_to_cs_size(pvt, ctrl, cs_mode, cs); in gpu_debug_display_dimm_sizes()
3805 static void gpu_dump_misc_regs(struct amd64_pvt *pvt) in gpu_dump_misc_regs() argument
3811 umc = &pvt->umc[i]; in gpu_dump_misc_regs()
3818 gpu_debug_display_dimm_sizes(pvt, i); in gpu_dump_misc_regs()
3822 static u32 gpu_get_csrow_nr_pages(struct amd64_pvt *pvt, u8 dct, int csrow_nr) in gpu_get_csrow_nr_pages() argument
3827 nr_pages = gpu_addr_mask_to_cs_size(pvt, dct, cs_mode, csrow_nr); in gpu_get_csrow_nr_pages()
3838 struct amd64_pvt *pvt = mci->pvt_info; in gpu_init_csrows() local
3843 for_each_chip_select(cs, umc, pvt) { in gpu_init_csrows()
3844 if (!csrow_enabled(cs, umc, pvt)) 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()
3863 struct amd64_pvt *pvt = mci->pvt_info; in gpu_setup_mci_misc_attrs() local
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()
3878 static bool gpu_ecc_enabled(struct amd64_pvt *pvt) in gpu_ecc_enabled() argument
3905 static void gpu_read_mc_regs(struct amd64_pvt *pvt) in gpu_read_mc_regs() argument
3907 u8 nid = pvt->mc_node_id; in gpu_read_mc_regs()
3914 umc = &pvt->umc[i]; in gpu_read_mc_regs()
3922 static void gpu_read_base_mask(struct amd64_pvt *pvt) in gpu_read_base_mask() argument
3929 for_each_chip_select(cs, umc, pvt) { in gpu_read_base_mask()
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()
3949 static void gpu_prep_chip_selects(struct amd64_pvt *pvt) in gpu_prep_chip_selects() argument
3954 pvt->csels[umc].b_cnt = 8; in gpu_prep_chip_selects()
3955 pvt->csels[umc].m_cnt = 8; in gpu_prep_chip_selects()
3959 static int gpu_hw_info_get(struct amd64_pvt *pvt) in gpu_hw_info_get() argument
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()
3971 gpu_prep_chip_selects(pvt); in gpu_hw_info_get()
3972 gpu_read_base_mask(pvt); in gpu_hw_info_get()
3973 gpu_read_mc_regs(pvt); in gpu_hw_info_get()
3978 static void hw_info_put(struct amd64_pvt *pvt) in hw_info_put() argument
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()
4011 static int per_family_init(struct amd64_pvt *pvt) in per_family_init() argument
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()
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()
4183 static int init_one_instance(struct amd64_pvt *pvt) in init_one_instance() argument
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()
4221 static bool instance_has_memory(struct amd64_pvt *pvt) in instance_has_memory() argument
4226 for (dct = 0; dct < pvt->max_mcs; dct++) { in instance_has_memory()
4227 for_each_chip_select(cs, dct, pvt) in instance_has_memory()
4228 cs_enabled |= csrow_enabled(cs, dct, pvt); in instance_has_memory()
4237 struct amd64_pvt *pvt = NULL; in probe_one_instance() local
4248 pvt = kzalloc(sizeof(struct amd64_pvt), GFP_KERNEL); in probe_one_instance()
4249 if (!pvt) in probe_one_instance()
4252 pvt->mc_node_id = nid; in probe_one_instance()
4253 pvt->F3 = F3; in probe_one_instance()
4255 ret = per_family_init(pvt); in probe_one_instance()
4259 ret = pvt->ops->hw_info_get(pvt); in probe_one_instance()
4264 if (!instance_has_memory(pvt)) { in probe_one_instance()
4269 if (!pvt->ops->ecc_enabled(pvt)) { in probe_one_instance()
4285 ret = init_one_instance(pvt); 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()
4303 hw_info_put(pvt); in probe_one_instance()
4304 kfree(pvt); in probe_one_instance()
4319 struct amd64_pvt *pvt; in remove_one_instance() local
4326 pvt = mci->pvt_info; in remove_one_instance()
4336 hw_info_put(pvt); in remove_one_instance()
4337 kfree(pvt); in remove_one_instance()