Lines Matching full:pvt

86 static void f15h_select_dct(struct amd64_pvt *pvt, u8 dct)  in f15h_select_dct()  argument
90 amd64_read_pci_cfg(pvt->F1, DCT_CFG_SEL, &reg); in f15h_select_dct()
91 reg &= (pvt->model == 0x30) ? ~3 : ~1; in f15h_select_dct()
93 amd64_write_pci_cfg(pvt->F1, DCT_CFG_SEL, reg); in f15h_select_dct()
110 static inline int amd64_read_dct_pci_cfg(struct amd64_pvt *pvt, u8 dct, in amd64_read_dct_pci_cfg() argument
113 switch (pvt->fam) { in amd64_read_dct_pci_cfg()
126 if (dct_ganging_enabled(pvt)) in amd64_read_dct_pci_cfg()
138 dct = (dct && pvt->model == 0x30) ? 3 : dct; in amd64_read_dct_pci_cfg()
139 f15h_select_dct(pvt, dct); in amd64_read_dct_pci_cfg()
150 return amd64_read_pci_cfg(pvt->F2, offset, val); in amd64_read_dct_pci_cfg()
167 static inline void __f17h_set_scrubval(struct amd64_pvt *pvt, u32 scrubval) in __f17h_set_scrubval() argument
176 pci_write_bits32(pvt->F6, F17H_SCR_LIMIT_ADDR, scrubval, 0xF); in __f17h_set_scrubval()
177 pci_write_bits32(pvt->F6, F17H_SCR_BASE_ADDR, 1, 0x1); in __f17h_set_scrubval()
179 pci_write_bits32(pvt->F6, F17H_SCR_BASE_ADDR, 0, 0x1); in __f17h_set_scrubval()
186 static int __set_scrub_rate(struct amd64_pvt *pvt, u32 new_bw, u32 min_rate) in __set_scrub_rate() argument
214 if (pvt->umc) { in __set_scrub_rate()
215 __f17h_set_scrubval(pvt, scrubval); in __set_scrub_rate()
216 } else if (pvt->fam == 0x15 && pvt->model == 0x60) { in __set_scrub_rate()
217 f15h_select_dct(pvt, 0); in __set_scrub_rate()
218 pci_write_bits32(pvt->F2, F15H_M60H_SCRCTRL, scrubval, 0x001F); in __set_scrub_rate()
219 f15h_select_dct(pvt, 1); in __set_scrub_rate()
220 pci_write_bits32(pvt->F2, F15H_M60H_SCRCTRL, scrubval, 0x001F); in __set_scrub_rate()
222 pci_write_bits32(pvt->F3, SCRCTRL, scrubval, 0x001F); in __set_scrub_rate()
233 struct amd64_pvt *pvt = mci->pvt_info; in set_scrub_rate() local
236 if (pvt->fam == 0xf) in set_scrub_rate()
239 if (pvt->fam == 0x15) { in set_scrub_rate()
241 if (pvt->model < 0x10) in set_scrub_rate()
242 f15h_select_dct(pvt, 0); in set_scrub_rate()
244 if (pvt->model == 0x60) in set_scrub_rate()
247 return __set_scrub_rate(pvt, bw, min_scrubrate); in set_scrub_rate()
252 struct amd64_pvt *pvt = mci->pvt_info; in get_scrub_rate() local
256 if (pvt->umc) { in get_scrub_rate()
257 amd64_read_pci_cfg(pvt->F6, F17H_SCR_BASE_ADDR, &scrubval); in get_scrub_rate()
259 amd64_read_pci_cfg(pvt->F6, F17H_SCR_LIMIT_ADDR, &scrubval); in get_scrub_rate()
265 } else if (pvt->fam == 0x15) { in get_scrub_rate()
267 if (pvt->model < 0x10) in get_scrub_rate()
268 f15h_select_dct(pvt, 0); in get_scrub_rate()
270 if (pvt->model == 0x60) in get_scrub_rate()
271 amd64_read_pci_cfg(pvt->F2, F15H_M60H_SCRCTRL, &scrubval); in get_scrub_rate()
273 amd64_read_pci_cfg(pvt->F3, SCRCTRL, &scrubval); in get_scrub_rate()
275 amd64_read_pci_cfg(pvt->F3, SCRCTRL, &scrubval); in get_scrub_rate()
293 static bool base_limit_match(struct amd64_pvt *pvt, u64 sys_addr, u8 nid) in base_limit_match() argument
305 return ((addr >= get_dram_base(pvt, nid)) && in base_limit_match()
306 (addr <= get_dram_limit(pvt, nid))); in base_limit_match()
318 struct amd64_pvt *pvt; in find_mc_by_sys_addr() local
326 pvt = mci->pvt_info; in find_mc_by_sys_addr()
333 intlv_en = dram_intlv_en(pvt, 0); in find_mc_by_sys_addr()
337 if (base_limit_match(pvt, sys_addr, node_id)) in find_mc_by_sys_addr()
353 if ((dram_intlv_sel(pvt, node_id) & intlv_en) == bits) in find_mc_by_sys_addr()
361 if (unlikely(!base_limit_match(pvt, sys_addr, node_id))) { in find_mc_by_sys_addr()
382 static void get_cs_base_and_mask(struct amd64_pvt *pvt, int csrow, u8 dct, in get_cs_base_and_mask() argument
388 if (pvt->fam == 0xf && pvt->ext_model < K8_REV_F) { in get_cs_base_and_mask()
389 csbase = pvt->csels[dct].csbases[csrow]; in get_cs_base_and_mask()
390 csmask = pvt->csels[dct].csmasks[csrow]; in get_cs_base_and_mask()
399 } else if (pvt->fam == 0x16 || in get_cs_base_and_mask()
400 (pvt->fam == 0x15 && pvt->model >= 0x30)) { in get_cs_base_and_mask()
401 csbase = pvt->csels[dct].csbases[csrow]; in get_cs_base_and_mask()
402 csmask = pvt->csels[dct].csmasks[csrow >> 1]; in get_cs_base_and_mask()
417 csbase = pvt->csels[dct].csbases[csrow]; in get_cs_base_and_mask()
418 csmask = pvt->csels[dct].csmasks[csrow >> 1]; in get_cs_base_and_mask()
421 if (pvt->fam == 0x15) in get_cs_base_and_mask()
438 #define for_each_chip_select(i, dct, pvt) \ argument
439 for (i = 0; i < pvt->csels[dct].b_cnt; i++)
441 #define chip_select_base(i, dct, pvt) \ argument
442 pvt->csels[dct].csbases[i]
444 #define for_each_chip_select_mask(i, dct, pvt) \ argument
445 for (i = 0; i < pvt->csels[dct].m_cnt; i++)
456 struct amd64_pvt *pvt; in input_addr_to_csrow() local
460 pvt = mci->pvt_info; in input_addr_to_csrow()
462 for_each_chip_select(csrow, 0, pvt) { in input_addr_to_csrow()
463 if (!csrow_enabled(csrow, 0, pvt)) in input_addr_to_csrow()
466 get_cs_base_and_mask(pvt, csrow, 0, &base, &mask); in input_addr_to_csrow()
473 pvt->mc_node_id); in input_addr_to_csrow()
479 (unsigned long)input_addr, pvt->mc_node_id); in input_addr_to_csrow()
503 struct amd64_pvt *pvt = mci->pvt_info; in amd64_get_dram_hole_info() local
506 if (pvt->fam == 0xf && pvt->ext_model < K8_REV_E) { in amd64_get_dram_hole_info()
508 pvt->ext_model, pvt->mc_node_id); in amd64_get_dram_hole_info()
513 if (pvt->fam >= 0x10 && !dhar_mem_hoist_valid(pvt)) { in amd64_get_dram_hole_info()
518 if (!dhar_valid(pvt)) { in amd64_get_dram_hole_info()
520 pvt->mc_node_id); in amd64_get_dram_hole_info()
542 *hole_base = dhar_base(pvt); in amd64_get_dram_hole_info()
545 *hole_offset = (pvt->fam > 0xf) ? f10_dhar_offset(pvt) in amd64_get_dram_hole_info()
546 : k8_dhar_offset(pvt); in amd64_get_dram_hole_info()
549 pvt->mc_node_id, (unsigned long)*hole_base, in amd64_get_dram_hole_info()
587 struct amd64_pvt *pvt = mci->pvt_info; in sys_addr_to_dram_addr() local
591 dram_base = get_dram_base(pvt, pvt->mc_node_id); in sys_addr_to_dram_addr()
643 struct amd64_pvt *pvt; in dram_addr_to_input_addr() local
647 pvt = mci->pvt_info; in dram_addr_to_input_addr()
653 intlv_shift = num_node_interleave_bits(dram_intlv_en(pvt, 0)); in dram_addr_to_input_addr()
715 static unsigned long determine_edac_cap(struct amd64_pvt *pvt) in determine_edac_cap() argument
720 if (pvt->umc) { in determine_edac_cap()
724 if (!(pvt->umc[i].sdp_ctrl & UMC_SDP_INIT)) in determine_edac_cap()
730 if (pvt->umc[i].umc_cfg & BIT(12)) in determine_edac_cap()
737 bit = (pvt->fam > 0xf || pvt->ext_model >= K8_REV_F) in determine_edac_cap()
741 if (pvt->dclr0 & BIT(bit)) in determine_edac_cap()
750 static void debug_dump_dramcfg_low(struct amd64_pvt *pvt, u32 dclr, int chan) in debug_dump_dramcfg_low() argument
754 if (pvt->dram_type == MEM_LRDDR3) { in debug_dump_dramcfg_low()
755 u32 dcsm = pvt->csels[chan].csmasks[0]; in debug_dump_dramcfg_low()
771 if (pvt->fam == 0x10) in debug_dump_dramcfg_low()
790 static int f17_get_cs_mode(int dimm, u8 ctrl, struct amd64_pvt *pvt) in f17_get_cs_mode() argument
794 if (csrow_enabled(2 * dimm, ctrl, pvt)) in f17_get_cs_mode()
797 if (csrow_enabled(2 * dimm + 1, ctrl, pvt)) in f17_get_cs_mode()
801 if (csrow_sec_enabled(2 * dimm + 1, ctrl, pvt)) in f17_get_cs_mode()
807 static void debug_display_dimm_sizes_df(struct amd64_pvt *pvt, u8 ctrl) in debug_display_dimm_sizes_df() argument
817 cs_mode = f17_get_cs_mode(dimm, ctrl, pvt); in debug_display_dimm_sizes_df()
819 size0 = pvt->ops->dbam_to_cs(pvt, ctrl, cs_mode, cs0); in debug_display_dimm_sizes_df()
820 size1 = pvt->ops->dbam_to_cs(pvt, ctrl, cs_mode, cs1); in debug_display_dimm_sizes_df()
828 static void __dump_misc_regs_df(struct amd64_pvt *pvt) in __dump_misc_regs_df() argument
835 umc = &pvt->umc[i]; in __dump_misc_regs_df()
842 amd_smn_read(pvt->mc_node_id, umc_base + UMCCH_ECC_BAD_SYMBOL, &tmp); in __dump_misc_regs_df()
845 amd_smn_read(pvt->mc_node_id, umc_base + UMCCH_UMC_CAP, &tmp); in __dump_misc_regs_df()
859 if (pvt->dram_type == MEM_LRDDR4) { in __dump_misc_regs_df()
860 amd_smn_read(pvt->mc_node_id, umc_base + UMCCH_ADDR_CFG, &tmp); in __dump_misc_regs_df()
865 debug_display_dimm_sizes_df(pvt, i); in __dump_misc_regs_df()
869 pvt->dhar, dhar_base(pvt)); in __dump_misc_regs_df()
873 static void __dump_misc_regs(struct amd64_pvt *pvt) in __dump_misc_regs() argument
875 edac_dbg(1, "F3xE8 (NB Cap): 0x%08x\n", pvt->nbcap); in __dump_misc_regs()
878 (pvt->nbcap & NBCAP_DCT_DUAL) ? "yes" : "no"); in __dump_misc_regs()
881 (pvt->nbcap & NBCAP_SECDED) ? "yes" : "no", in __dump_misc_regs()
882 (pvt->nbcap & NBCAP_CHIPKILL) ? "yes" : "no"); in __dump_misc_regs()
884 debug_dump_dramcfg_low(pvt, pvt->dclr0, 0); in __dump_misc_regs()
886 edac_dbg(1, "F3xB0 (Online Spare): 0x%08x\n", pvt->online_spare); in __dump_misc_regs()
889 pvt->dhar, dhar_base(pvt), in __dump_misc_regs()
890 (pvt->fam == 0xf) ? k8_dhar_offset(pvt) in __dump_misc_regs()
891 : f10_dhar_offset(pvt)); in __dump_misc_regs()
893 debug_display_dimm_sizes(pvt, 0); in __dump_misc_regs()
896 if (pvt->fam == 0xf) in __dump_misc_regs()
899 debug_display_dimm_sizes(pvt, 1); in __dump_misc_regs()
902 if (!dct_ganging_enabled(pvt)) in __dump_misc_regs()
903 debug_dump_dramcfg_low(pvt, pvt->dclr1, 1); in __dump_misc_regs()
907 static void dump_misc_regs(struct amd64_pvt *pvt) in dump_misc_regs() argument
909 if (pvt->umc) in dump_misc_regs()
910 __dump_misc_regs_df(pvt); in dump_misc_regs()
912 __dump_misc_regs(pvt); in dump_misc_regs()
914 edac_dbg(1, " DramHoleValid: %s\n", dhar_valid(pvt) ? "yes" : "no"); in dump_misc_regs()
916 amd64_info("using x%u syndromes.\n", pvt->ecc_sym_sz); in dump_misc_regs()
922 static void prep_chip_selects(struct amd64_pvt *pvt) in prep_chip_selects() argument
924 if (pvt->fam == 0xf && pvt->ext_model < K8_REV_F) { in prep_chip_selects()
925 pvt->csels[0].b_cnt = pvt->csels[1].b_cnt = 8; in prep_chip_selects()
926 pvt->csels[0].m_cnt = pvt->csels[1].m_cnt = 8; in prep_chip_selects()
927 } else if (pvt->fam == 0x15 && pvt->model == 0x30) { in prep_chip_selects()
928 pvt->csels[0].b_cnt = pvt->csels[1].b_cnt = 4; in prep_chip_selects()
929 pvt->csels[0].m_cnt = pvt->csels[1].m_cnt = 2; in prep_chip_selects()
930 } else if (pvt->fam >= 0x17) { in prep_chip_selects()
934 pvt->csels[umc].b_cnt = 4; in prep_chip_selects()
935 pvt->csels[umc].m_cnt = 2; in prep_chip_selects()
939 pvt->csels[0].b_cnt = pvt->csels[1].b_cnt = 8; in prep_chip_selects()
940 pvt->csels[0].m_cnt = pvt->csels[1].m_cnt = 4; in prep_chip_selects()
944 static void read_umc_base_mask(struct amd64_pvt *pvt) in read_umc_base_mask() argument
958 for_each_chip_select(cs, umc, pvt) { in read_umc_base_mask()
959 base = &pvt->csels[umc].csbases[cs]; in read_umc_base_mask()
960 base_sec = &pvt->csels[umc].csbases_sec[cs]; in read_umc_base_mask()
965 if (!amd_smn_read(pvt->mc_node_id, base_reg, base)) in read_umc_base_mask()
969 if (!amd_smn_read(pvt->mc_node_id, base_reg_sec, base_sec)) in read_umc_base_mask()
977 for_each_chip_select_mask(cs, umc, pvt) { in read_umc_base_mask()
978 mask = &pvt->csels[umc].csmasks[cs]; in read_umc_base_mask()
979 mask_sec = &pvt->csels[umc].csmasks_sec[cs]; in read_umc_base_mask()
984 if (!amd_smn_read(pvt->mc_node_id, mask_reg, mask)) in read_umc_base_mask()
988 if (!amd_smn_read(pvt->mc_node_id, mask_reg_sec, mask_sec)) in read_umc_base_mask()
998 static void read_dct_base_mask(struct amd64_pvt *pvt) in read_dct_base_mask() argument
1002 prep_chip_selects(pvt); in read_dct_base_mask()
1004 if (pvt->umc) in read_dct_base_mask()
1005 return read_umc_base_mask(pvt); in read_dct_base_mask()
1007 for_each_chip_select(cs, 0, pvt) { in read_dct_base_mask()
1010 u32 *base0 = &pvt->csels[0].csbases[cs]; in read_dct_base_mask()
1011 u32 *base1 = &pvt->csels[1].csbases[cs]; in read_dct_base_mask()
1013 if (!amd64_read_dct_pci_cfg(pvt, 0, reg0, base0)) in read_dct_base_mask()
1017 if (pvt->fam == 0xf) in read_dct_base_mask()
1020 if (!amd64_read_dct_pci_cfg(pvt, 1, reg0, base1)) in read_dct_base_mask()
1022 cs, *base1, (pvt->fam == 0x10) ? reg1 in read_dct_base_mask()
1026 for_each_chip_select_mask(cs, 0, pvt) { in read_dct_base_mask()
1029 u32 *mask0 = &pvt->csels[0].csmasks[cs]; in read_dct_base_mask()
1030 u32 *mask1 = &pvt->csels[1].csmasks[cs]; in read_dct_base_mask()
1032 if (!amd64_read_dct_pci_cfg(pvt, 0, reg0, mask0)) in read_dct_base_mask()
1036 if (pvt->fam == 0xf) in read_dct_base_mask()
1039 if (!amd64_read_dct_pci_cfg(pvt, 1, reg0, mask1)) in read_dct_base_mask()
1041 cs, *mask1, (pvt->fam == 0x10) ? reg1 in read_dct_base_mask()
1046 static void determine_memory_type(struct amd64_pvt *pvt) in determine_memory_type() argument
1050 if (pvt->umc) { in determine_memory_type()
1051 if ((pvt->umc[0].dimm_cfg | pvt->umc[1].dimm_cfg) & BIT(5)) in determine_memory_type()
1052 pvt->dram_type = MEM_LRDDR4; in determine_memory_type()
1053 else if ((pvt->umc[0].dimm_cfg | pvt->umc[1].dimm_cfg) & BIT(4)) in determine_memory_type()
1054 pvt->dram_type = MEM_RDDR4; in determine_memory_type()
1056 pvt->dram_type = MEM_DDR4; in determine_memory_type()
1060 switch (pvt->fam) { in determine_memory_type()
1062 if (pvt->ext_model >= K8_REV_F) in determine_memory_type()
1065 pvt->dram_type = (pvt->dclr0 & BIT(18)) ? MEM_DDR : MEM_RDDR; in determine_memory_type()
1069 if (pvt->dchr0 & DDR3_MODE) in determine_memory_type()
1072 pvt->dram_type = (pvt->dclr0 & BIT(16)) ? MEM_DDR2 : MEM_RDDR2; in determine_memory_type()
1076 if (pvt->model < 0x60) in determine_memory_type()
1088 amd64_read_dct_pci_cfg(pvt, 0, DRAM_CONTROL, &dram_ctrl); in determine_memory_type()
1089 dcsm = pvt->csels[0].csmasks[0]; in determine_memory_type()
1092 pvt->dram_type = MEM_DDR4; in determine_memory_type()
1093 else if (pvt->dclr0 & BIT(16)) in determine_memory_type()
1094 pvt->dram_type = MEM_DDR3; in determine_memory_type()
1096 pvt->dram_type = MEM_LRDDR3; in determine_memory_type()
1098 pvt->dram_type = MEM_RDDR3; in determine_memory_type()
1106 WARN(1, KERN_ERR "%s: Family??? 0x%x\n", __func__, pvt->fam); in determine_memory_type()
1107 pvt->dram_type = MEM_EMPTY; in determine_memory_type()
1112 pvt->dram_type = (pvt->dclr0 & BIT(16)) ? MEM_DDR3 : MEM_RDDR3; in determine_memory_type()
1116 static int k8_early_channel_count(struct amd64_pvt *pvt) in k8_early_channel_count() argument
1120 if (pvt->ext_model >= K8_REV_F) in k8_early_channel_count()
1122 flag = pvt->dclr0 & WIDTH_128; in k8_early_channel_count()
1125 flag = pvt->dclr0 & REVE_WIDTH_128; in k8_early_channel_count()
1128 pvt->dclr1 = 0; in k8_early_channel_count()
1134 static u64 get_error_address(struct amd64_pvt *pvt, struct mce *m) in get_error_address() argument
1146 pvt = mci->pvt_info; in get_error_address()
1148 if (pvt->fam == 0xf) { in get_error_address()
1158 if (pvt->fam == 0x15) { in get_error_address()
1167 amd64_read_pci_cfg(pvt->F1, DRAM_LOCAL_NODE_LIM, &tmp); in get_error_address()
1182 amd64_read_pci_cfg(pvt->F1, DRAM_LOCAL_NODE_BASE, &tmp); in get_error_address()
1215 static void read_dram_base_limit_regs(struct amd64_pvt *pvt, unsigned range) in read_dram_base_limit_regs() argument
1223 amd64_read_pci_cfg(pvt->F1, DRAM_BASE_LO + off, &pvt->ranges[range].base.lo); in read_dram_base_limit_regs()
1224 amd64_read_pci_cfg(pvt->F1, DRAM_LIMIT_LO + off, &pvt->ranges[range].lim.lo); in read_dram_base_limit_regs()
1226 if (pvt->fam == 0xf) in read_dram_base_limit_regs()
1229 if (!dram_rw(pvt, range)) in read_dram_base_limit_regs()
1232 amd64_read_pci_cfg(pvt->F1, DRAM_BASE_HI + off, &pvt->ranges[range].base.hi); in read_dram_base_limit_regs()
1233 amd64_read_pci_cfg(pvt->F1, DRAM_LIMIT_HI + off, &pvt->ranges[range].lim.hi); in read_dram_base_limit_regs()
1236 if (pvt->fam != 0x15) in read_dram_base_limit_regs()
1239 nb = node_to_amd_nb(dram_dst_node(pvt, range)); in read_dram_base_limit_regs()
1243 if (pvt->model == 0x60) in read_dram_base_limit_regs()
1245 else if (pvt->model == 0x30) in read_dram_base_limit_regs()
1256 pvt->ranges[range].lim.lo &= GENMASK_ULL(15, 0); in read_dram_base_limit_regs()
1259 pvt->ranges[range].lim.lo |= ((llim & 0x1fff) << 3 | 0x7) << 16; in read_dram_base_limit_regs()
1261 pvt->ranges[range].lim.hi &= GENMASK_ULL(7, 0); in read_dram_base_limit_regs()
1264 pvt->ranges[range].lim.hi |= llim >> 13; in read_dram_base_limit_regs()
1272 struct amd64_pvt *pvt = mci->pvt_info; in k8_map_sysaddr_to_csrow() local
1296 if (pvt->nbcfg & NBCFG_CHIPKILL) { in k8_map_sysaddr_to_csrow()
1337 static int k8_dbam_to_chip_select(struct amd64_pvt *pvt, u8 dct, in k8_dbam_to_chip_select() argument
1340 u32 dclr = dct ? pvt->dclr1 : pvt->dclr0; in k8_dbam_to_chip_select()
1342 if (pvt->ext_model >= K8_REV_F) { in k8_dbam_to_chip_select()
1346 else if (pvt->ext_model >= K8_REV_D) { in k8_dbam_to_chip_select()
1392 static int f1x_early_channel_count(struct amd64_pvt *pvt) in f1x_early_channel_count() argument
1397 if (pvt->fam == 0x10 && (pvt->dclr0 & WIDTH_128)) in f1x_early_channel_count()
1416 u32 dbam = (i ? pvt->dbam1 : pvt->dbam0); in f1x_early_channel_count()
1434 static int f17_early_channel_count(struct amd64_pvt *pvt) in f17_early_channel_count() argument
1440 channels += !!(pvt->umc[i].sdp_ctrl & UMC_SDP_INIT); in f17_early_channel_count()
1504 static int f10_dbam_to_chip_select(struct amd64_pvt *pvt, u8 dct, in f10_dbam_to_chip_select() argument
1507 u32 dclr = dct ? pvt->dclr1 : pvt->dclr0; in f10_dbam_to_chip_select()
1511 if (pvt->dchr0 & DDR3_MODE || pvt->dchr1 & DDR3_MODE) in f10_dbam_to_chip_select()
1520 static int f15_dbam_to_chip_select(struct amd64_pvt *pvt, u8 dct, in f15_dbam_to_chip_select() argument
1529 static int f15_m60h_dbam_to_chip_select(struct amd64_pvt *pvt, u8 dct, in f15_m60h_dbam_to_chip_select() argument
1533 u32 dcsm = pvt->csels[dct].csmasks[cs_mask_nr]; in f15_m60h_dbam_to_chip_select()
1537 if (pvt->dram_type == MEM_DDR4) { in f15_m60h_dbam_to_chip_select()
1542 } else if (pvt->dram_type == MEM_LRDDR3) { in f15_m60h_dbam_to_chip_select()
1562 static int f16_dbam_to_chip_select(struct amd64_pvt *pvt, u8 dct, in f16_dbam_to_chip_select() argument
1574 static int f17_addr_mask_to_cs_size(struct amd64_pvt *pvt, u8 umc, in f17_addr_mask_to_cs_size() argument
1602 addr_mask_orig = pvt->csels[umc].csmasks_sec[dimm]; in f17_addr_mask_to_cs_size()
1604 addr_mask_orig = pvt->csels[umc].csmasks[dimm]; in f17_addr_mask_to_cs_size()
1631 static void read_dram_ctl_register(struct amd64_pvt *pvt) in read_dram_ctl_register() argument
1634 if (pvt->fam == 0xf) in read_dram_ctl_register()
1637 if (!amd64_read_pci_cfg(pvt->F2, DCT_SEL_LO, &pvt->dct_sel_lo)) { in read_dram_ctl_register()
1639 pvt->dct_sel_lo, dct_sel_baseaddr(pvt)); in read_dram_ctl_register()
1642 (dct_ganging_enabled(pvt) ? "ganged" : "unganged")); in read_dram_ctl_register()
1644 if (!dct_ganging_enabled(pvt)) in read_dram_ctl_register()
1646 (dct_high_range_enabled(pvt) ? "yes" : "no")); in read_dram_ctl_register()
1649 (dct_data_intlv_enabled(pvt) ? "enabled" : "disabled"), in read_dram_ctl_register()
1650 (dct_memory_cleared(pvt) ? "yes" : "no")); in read_dram_ctl_register()
1654 (dct_interleave_enabled(pvt) ? "enabled" : "disabled"), in read_dram_ctl_register()
1655 dct_sel_interleave_addr(pvt)); in read_dram_ctl_register()
1658 amd64_read_pci_cfg(pvt->F2, DCT_SEL_HI, &pvt->dct_sel_hi); in read_dram_ctl_register()
1665 static u8 f15_m30h_determine_channel(struct amd64_pvt *pvt, u64 sys_addr, in f15_m30h_determine_channel() argument
1679 u8 intlv_addr = dct_sel_interleave_addr(pvt); in f15_m30h_determine_channel()
1696 static u8 f1x_determine_channel(struct amd64_pvt *pvt, u64 sys_addr, in f1x_determine_channel() argument
1699 u8 dct_sel_high = (pvt->dct_sel_lo >> 1) & 1; in f1x_determine_channel()
1701 if (dct_ganging_enabled(pvt)) in f1x_determine_channel()
1710 if (dct_interleave_enabled(pvt)) { in f1x_determine_channel()
1711 u8 intlv_addr = dct_sel_interleave_addr(pvt); in f1x_determine_channel()
1733 if (dct_high_range_enabled(pvt)) in f1x_determine_channel()
1740 static u64 f1x_get_norm_dct_addr(struct amd64_pvt *pvt, u8 range, in f1x_get_norm_dct_addr() argument
1745 u64 dram_base = get_dram_base(pvt, range); in f1x_get_norm_dct_addr()
1746 u64 hole_off = f10_dhar_offset(pvt); in f1x_get_norm_dct_addr()
1747 u64 dct_sel_base_off = (u64)(pvt->dct_sel_hi & 0xFFFFFC00) << 16; in f1x_get_norm_dct_addr()
1762 dct_sel_base_addr < dhar_base(pvt)) && in f1x_get_norm_dct_addr()
1763 dhar_valid(pvt) && in f1x_get_norm_dct_addr()
1778 if (dhar_valid(pvt) && (sys_addr >= BIT_64(32))) in f1x_get_norm_dct_addr()
1791 static int f10_process_possible_spare(struct amd64_pvt *pvt, u8 dct, int csrow) in f10_process_possible_spare() argument
1795 if (online_spare_swap_done(pvt, dct) && in f10_process_possible_spare()
1796 csrow == online_spare_bad_dramcs(pvt, dct)) { in f10_process_possible_spare()
1798 for_each_chip_select(tmp_cs, dct, pvt) { in f10_process_possible_spare()
1799 if (chip_select_base(tmp_cs, dct, pvt) & 0x2) { in f10_process_possible_spare()
1819 struct amd64_pvt *pvt; in f1x_lookup_addr_in_dct() local
1828 pvt = mci->pvt_info; in f1x_lookup_addr_in_dct()
1832 for_each_chip_select(csrow, dct, pvt) { in f1x_lookup_addr_in_dct()
1833 if (!csrow_enabled(csrow, dct, pvt)) in f1x_lookup_addr_in_dct()
1836 get_cs_base_and_mask(pvt, csrow, dct, &cs_base, &cs_mask); in f1x_lookup_addr_in_dct()
1847 if (pvt->fam == 0x15 && pvt->model >= 0x30) { in f1x_lookup_addr_in_dct()
1851 cs_found = f10_process_possible_spare(pvt, dct, csrow); in f1x_lookup_addr_in_dct()
1865 static u64 f1x_swap_interleaved_region(struct amd64_pvt *pvt, u64 sys_addr) in f1x_swap_interleaved_region() argument
1869 if (pvt->fam == 0x10) { in f1x_swap_interleaved_region()
1871 if (pvt->model < 4 || (pvt->model < 0xa && pvt->stepping < 3)) in f1x_swap_interleaved_region()
1875 amd64_read_pci_cfg(pvt->F2, SWAP_INTLV_REG, &swap_reg); in f1x_swap_interleaved_region()
1895 static int f1x_match_to_this_node(struct amd64_pvt *pvt, unsigned range, in f1x_match_to_this_node() argument
1904 u8 node_id = dram_dst_node(pvt, range); in f1x_match_to_this_node()
1905 u8 intlv_en = dram_intlv_en(pvt, range); in f1x_match_to_this_node()
1906 u32 intlv_sel = dram_intlv_sel(pvt, range); in f1x_match_to_this_node()
1909 range, sys_addr, get_dram_limit(pvt, range)); in f1x_match_to_this_node()
1911 if (dhar_valid(pvt) && in f1x_match_to_this_node()
1912 dhar_base(pvt) <= sys_addr && in f1x_match_to_this_node()
1922 sys_addr = f1x_swap_interleaved_region(pvt, sys_addr); in f1x_match_to_this_node()
1924 dct_sel_base = dct_sel_baseaddr(pvt); in f1x_match_to_this_node()
1930 if (dct_high_range_enabled(pvt) && in f1x_match_to_this_node()
1931 !dct_ganging_enabled(pvt) && in f1x_match_to_this_node()
1935 channel = f1x_determine_channel(pvt, sys_addr, high_range, intlv_en); in f1x_match_to_this_node()
1937 chan_addr = f1x_get_norm_dct_addr(pvt, range, sys_addr, in f1x_match_to_this_node()
1946 if (dct_interleave_enabled(pvt) && in f1x_match_to_this_node()
1947 !dct_high_range_enabled(pvt) && in f1x_match_to_this_node()
1948 !dct_ganging_enabled(pvt)) { in f1x_match_to_this_node()
1950 if (dct_sel_interleave_addr(pvt) != 1) { in f1x_match_to_this_node()
1951 if (dct_sel_interleave_addr(pvt) == 0x3) in f1x_match_to_this_node()
1975 static int f15_m30h_match_to_this_node(struct amd64_pvt *pvt, unsigned range, in f15_m30h_match_to_this_node() argument
1985 u64 dhar_offset = f10_dhar_offset(pvt); in f15_m30h_match_to_this_node()
1986 u8 intlv_addr = dct_sel_interleave_addr(pvt); in f15_m30h_match_to_this_node()
1987 u8 node_id = dram_dst_node(pvt, range); in f15_m30h_match_to_this_node()
1988 u8 intlv_en = dram_intlv_en(pvt, range); in f15_m30h_match_to_this_node()
1990 amd64_read_pci_cfg(pvt->F1, DRAM_CONT_BASE, &dct_cont_base_reg); in f15_m30h_match_to_this_node()
1991 amd64_read_pci_cfg(pvt->F1, DRAM_CONT_LIMIT, &dct_cont_limit_reg); in f15_m30h_match_to_this_node()
1997 range, sys_addr, get_dram_limit(pvt, range)); in f15_m30h_match_to_this_node()
1999 if (!(get_dram_base(pvt, range) <= sys_addr) && in f15_m30h_match_to_this_node()
2000 !(get_dram_limit(pvt, range) >= sys_addr)) in f15_m30h_match_to_this_node()
2003 if (dhar_valid(pvt) && in f15_m30h_match_to_this_node()
2004 dhar_base(pvt) <= sys_addr && in f15_m30h_match_to_this_node()
2012 dct_base = (u64) dct_sel_baseaddr(pvt); in f15_m30h_match_to_this_node()
2026 if (pvt->model >= 0x60) in f15_m30h_match_to_this_node()
2027 channel = f1x_determine_channel(pvt, sys_addr, false, intlv_en); in f15_m30h_match_to_this_node()
2029 channel = f15_m30h_determine_channel(pvt, sys_addr, intlv_en, in f15_m30h_match_to_this_node()
2069 amd64_read_pci_cfg(pvt->F1, in f15_m30h_match_to_this_node()
2075 f15h_select_dct(pvt, channel); in f15_m30h_match_to_this_node()
2084 * pvt->csels[1]. So we need to use '1' here to get correct info. in f15_m30h_match_to_this_node()
2097 static int f1x_translate_sysaddr_to_cs(struct amd64_pvt *pvt, in f1x_translate_sysaddr_to_cs() argument
2105 if (!dram_rw(pvt, range)) in f1x_translate_sysaddr_to_cs()
2108 if (pvt->fam == 0x15 && pvt->model >= 0x30) in f1x_translate_sysaddr_to_cs()
2109 cs_found = f15_m30h_match_to_this_node(pvt, range, in f1x_translate_sysaddr_to_cs()
2113 else if ((get_dram_base(pvt, range) <= sys_addr) && in f1x_translate_sysaddr_to_cs()
2114 (get_dram_limit(pvt, range) >= sys_addr)) { in f1x_translate_sysaddr_to_cs()
2115 cs_found = f1x_match_to_this_node(pvt, range, in f1x_translate_sysaddr_to_cs()
2134 struct amd64_pvt *pvt = mci->pvt_info; in f1x_map_sysaddr_to_csrow() local
2138 err->csrow = f1x_translate_sysaddr_to_cs(pvt, sys_addr, &err->channel); in f1x_map_sysaddr_to_csrow()
2149 if (dct_ganging_enabled(pvt)) in f1x_map_sysaddr_to_csrow()
2157 static void debug_display_dimm_sizes(struct amd64_pvt *pvt, u8 ctrl) in debug_display_dimm_sizes() argument
2160 u32 *dcsb = ctrl ? pvt->csels[1].csbases : pvt->csels[0].csbases; in debug_display_dimm_sizes()
2161 u32 dbam = ctrl ? pvt->dbam1 : pvt->dbam0; in debug_display_dimm_sizes()
2163 if (pvt->fam == 0xf) { in debug_display_dimm_sizes()
2165 if (pvt->ext_model < K8_REV_F) in debug_display_dimm_sizes()
2171 if (pvt->fam == 0x10) { in debug_display_dimm_sizes()
2172 dbam = (ctrl && !dct_ganging_enabled(pvt)) ? pvt->dbam1 in debug_display_dimm_sizes()
2173 : pvt->dbam0; in debug_display_dimm_sizes()
2174 dcsb = (ctrl && !dct_ganging_enabled(pvt)) ? in debug_display_dimm_sizes()
2175 pvt->csels[1].csbases : in debug_display_dimm_sizes()
2176 pvt->csels[0].csbases; in debug_display_dimm_sizes()
2178 dbam = pvt->dbam0; in debug_display_dimm_sizes()
2179 dcsb = pvt->csels[1].csbases; in debug_display_dimm_sizes()
2197 size0 = pvt->ops->dbam_to_cs(pvt, ctrl, in debug_display_dimm_sizes()
2203 size1 = pvt->ops->dbam_to_cs(pvt, ctrl, in debug_display_dimm_sizes()
2498 struct amd64_pvt *pvt = mci->pvt_info; in get_channel_from_ecc_syndrome() local
2501 if (pvt->ecc_sym_sz == 8) in get_channel_from_ecc_syndrome()
2504 pvt->ecc_sym_sz); in get_channel_from_ecc_syndrome()
2505 else if (pvt->ecc_sym_sz == 4) in get_channel_from_ecc_syndrome()
2508 pvt->ecc_sym_sz); in get_channel_from_ecc_syndrome()
2510 amd64_warn("Illegal syndrome type: %u\n", pvt->ecc_sym_sz); in get_channel_from_ecc_syndrome()
2514 return map_err_sym_to_channel(err_sym, pvt->ecc_sym_sz); in get_channel_from_ecc_syndrome()
2567 struct amd64_pvt *pvt; in decode_bus_error() local
2578 pvt = mci->pvt_info; in decode_bus_error()
2590 sys_addr = get_error_address(pvt, m); in decode_bus_error()
2595 pvt->ops->map_sysaddr_to_csrow(mci, sys_addr, &err); in decode_bus_error()
2618 struct amd64_pvt *pvt; in decode_umc_error() local
2626 pvt = mci->pvt_info; in decode_umc_error()
2651 if (umc_normaddr_to_sysaddr(m->addr, pvt->mc_node_id, err.channel, &sys_addr)) { in decode_umc_error()
2663 * Use pvt->F3 which contains the F3 CPU PCI device to get the related
2668 reserve_mc_sibling_devs(struct amd64_pvt *pvt, u16 pci_id1, u16 pci_id2) in reserve_mc_sibling_devs() argument
2670 if (pvt->umc) { in reserve_mc_sibling_devs()
2671 pvt->F0 = pci_get_related_function(pvt->F3->vendor, pci_id1, pvt->F3); in reserve_mc_sibling_devs()
2672 if (!pvt->F0) { in reserve_mc_sibling_devs()
2677 pvt->F6 = pci_get_related_function(pvt->F3->vendor, pci_id2, pvt->F3); in reserve_mc_sibling_devs()
2678 if (!pvt->F6) { in reserve_mc_sibling_devs()
2679 pci_dev_put(pvt->F0); in reserve_mc_sibling_devs()
2680 pvt->F0 = NULL; in reserve_mc_sibling_devs()
2686 edac_dbg(1, "F0: %s\n", pci_name(pvt->F0)); in reserve_mc_sibling_devs()
2687 edac_dbg(1, "F3: %s\n", pci_name(pvt->F3)); in reserve_mc_sibling_devs()
2688 edac_dbg(1, "F6: %s\n", pci_name(pvt->F6)); in reserve_mc_sibling_devs()
2694 pvt->F1 = pci_get_related_function(pvt->F3->vendor, pci_id1, pvt->F3); in reserve_mc_sibling_devs()
2695 if (!pvt->F1) { in reserve_mc_sibling_devs()
2701 pvt->F2 = pci_get_related_function(pvt->F3->vendor, pci_id2, pvt->F3); in reserve_mc_sibling_devs()
2702 if (!pvt->F2) { in reserve_mc_sibling_devs()
2703 pci_dev_put(pvt->F1); in reserve_mc_sibling_devs()
2704 pvt->F1 = NULL; in reserve_mc_sibling_devs()
2710 edac_dbg(1, "F1: %s\n", pci_name(pvt->F1)); in reserve_mc_sibling_devs()
2711 edac_dbg(1, "F2: %s\n", pci_name(pvt->F2)); in reserve_mc_sibling_devs()
2712 edac_dbg(1, "F3: %s\n", pci_name(pvt->F3)); in reserve_mc_sibling_devs()
2717 static void free_mc_sibling_devs(struct amd64_pvt *pvt) in free_mc_sibling_devs() argument
2719 if (pvt->umc) { in free_mc_sibling_devs()
2720 pci_dev_put(pvt->F0); in free_mc_sibling_devs()
2721 pci_dev_put(pvt->F6); in free_mc_sibling_devs()
2723 pci_dev_put(pvt->F1); in free_mc_sibling_devs()
2724 pci_dev_put(pvt->F2); in free_mc_sibling_devs()
2728 static void determine_ecc_sym_sz(struct amd64_pvt *pvt) in determine_ecc_sym_sz() argument
2730 pvt->ecc_sym_sz = 4; in determine_ecc_sym_sz()
2732 if (pvt->umc) { in determine_ecc_sym_sz()
2737 if (pvt->umc[i].sdp_ctrl & UMC_SDP_INIT) { in determine_ecc_sym_sz()
2738 if (pvt->umc[i].ecc_ctrl & BIT(9)) { in determine_ecc_sym_sz()
2739 pvt->ecc_sym_sz = 16; in determine_ecc_sym_sz()
2741 } else if (pvt->umc[i].ecc_ctrl & BIT(7)) { in determine_ecc_sym_sz()
2742 pvt->ecc_sym_sz = 8; in determine_ecc_sym_sz()
2747 } else if (pvt->fam >= 0x10) { in determine_ecc_sym_sz()
2750 amd64_read_pci_cfg(pvt->F3, EXT_NB_MCA_CFG, &tmp); in determine_ecc_sym_sz()
2752 if (pvt->fam != 0x16) in determine_ecc_sym_sz()
2753 amd64_read_dct_pci_cfg(pvt, 1, DBAM0, &pvt->dbam1); in determine_ecc_sym_sz()
2756 if ((pvt->fam > 0x10 || pvt->model > 7) && tmp & BIT(25)) in determine_ecc_sym_sz()
2757 pvt->ecc_sym_sz = 8; in determine_ecc_sym_sz()
2764 static void __read_mc_regs_df(struct amd64_pvt *pvt) in __read_mc_regs_df() argument
2766 u8 nid = pvt->mc_node_id; in __read_mc_regs_df()
2774 umc = &pvt->umc[i]; in __read_mc_regs_df()
2788 static void read_mc_regs(struct amd64_pvt *pvt) in read_mc_regs() argument
2797 rdmsrl(MSR_K8_TOP_MEM1, pvt->top_mem); in read_mc_regs()
2798 edac_dbg(0, " TOP_MEM: 0x%016llx\n", pvt->top_mem); in read_mc_regs()
2803 rdmsrl(MSR_K8_TOP_MEM2, pvt->top_mem2); in read_mc_regs()
2804 edac_dbg(0, " TOP_MEM2: 0x%016llx\n", pvt->top_mem2); in read_mc_regs()
2809 if (pvt->umc) { in read_mc_regs()
2810 __read_mc_regs_df(pvt); in read_mc_regs()
2811 amd64_read_pci_cfg(pvt->F0, DF_DHAR, &pvt->dhar); in read_mc_regs()
2816 amd64_read_pci_cfg(pvt->F3, NBCAP, &pvt->nbcap); in read_mc_regs()
2818 read_dram_ctl_register(pvt); in read_mc_regs()
2824 read_dram_base_limit_regs(pvt, range); in read_mc_regs()
2826 rw = dram_rw(pvt, range); in read_mc_regs()
2832 get_dram_base(pvt, range), in read_mc_regs()
2833 get_dram_limit(pvt, range)); in read_mc_regs()
2836 dram_intlv_en(pvt, range) ? "Enabled" : "Disabled", in read_mc_regs()
2839 dram_intlv_sel(pvt, range), in read_mc_regs()
2840 dram_dst_node(pvt, range)); in read_mc_regs()
2843 amd64_read_pci_cfg(pvt->F1, DHAR, &pvt->dhar); in read_mc_regs()
2844 amd64_read_dct_pci_cfg(pvt, 0, DBAM0, &pvt->dbam0); in read_mc_regs()
2846 amd64_read_pci_cfg(pvt->F3, F10_ONLINE_SPARE, &pvt->online_spare); in read_mc_regs()
2848 amd64_read_dct_pci_cfg(pvt, 0, DCLR0, &pvt->dclr0); in read_mc_regs()
2849 amd64_read_dct_pci_cfg(pvt, 0, DCHR0, &pvt->dchr0); in read_mc_regs()
2851 if (!dct_ganging_enabled(pvt)) { in read_mc_regs()
2852 amd64_read_dct_pci_cfg(pvt, 1, DCLR0, &pvt->dclr1); in read_mc_regs()
2853 amd64_read_dct_pci_cfg(pvt, 1, DCHR0, &pvt->dchr1); in read_mc_regs()
2857 read_dct_base_mask(pvt); in read_mc_regs()
2859 determine_memory_type(pvt); in read_mc_regs()
2860 edac_dbg(1, " DIMM type: %s\n", edac_mem_types[pvt->dram_type]); in read_mc_regs()
2862 determine_ecc_sym_sz(pvt); in read_mc_regs()
2899 static u32 get_csrow_nr_pages(struct amd64_pvt *pvt, u8 dct, int csrow_nr_orig) in get_csrow_nr_pages() argument
2901 u32 dbam = dct ? pvt->dbam1 : pvt->dbam0; in get_csrow_nr_pages()
2905 if (!pvt->umc) { in get_csrow_nr_pages()
2909 cs_mode = f17_get_cs_mode(csrow_nr >> 1, dct, pvt); in get_csrow_nr_pages()
2912 nr_pages = pvt->ops->dbam_to_cs(pvt, dct, cs_mode, csrow_nr); in get_csrow_nr_pages()
2924 struct amd64_pvt *pvt = mci->pvt_info; in init_csrows_df() local
2945 for_each_chip_select(cs, umc, pvt) { in init_csrows_df()
2946 if (!csrow_enabled(cs, umc, pvt)) in init_csrows_df()
2953 pvt->mc_node_id, cs); in init_csrows_df()
2955 dimm->nr_pages = get_csrow_nr_pages(pvt, umc, cs); in init_csrows_df()
2956 dimm->mtype = pvt->dram_type; in init_csrows_df()
2972 struct amd64_pvt *pvt = mci->pvt_info; in init_csrows() local
2980 if (pvt->umc) in init_csrows()
2983 amd64_read_pci_cfg(pvt->F3, NBCFG, &val); in init_csrows()
2985 pvt->nbcfg = val; in init_csrows()
2988 pvt->mc_node_id, val, in init_csrows()
2994 for_each_chip_select(i, 0, pvt) { in init_csrows()
2995 bool row_dct0 = !!csrow_enabled(i, 0, pvt); in init_csrows()
2998 if (pvt->fam != 0xf) in init_csrows()
2999 row_dct1 = !!csrow_enabled(i, 1, pvt); in init_csrows()
3008 pvt->mc_node_id, i); in init_csrows()
3011 nr_pages = get_csrow_nr_pages(pvt, 0, i); in init_csrows()
3016 if (pvt->fam != 0xf && row_dct1) { in init_csrows()
3017 int row_dct1_pages = get_csrow_nr_pages(pvt, 1, i); in init_csrows()
3026 if (pvt->nbcfg & NBCFG_ECC_ENABLE) { in init_csrows()
3027 edac_mode = (pvt->nbcfg & NBCFG_CHIPKILL) in init_csrows()
3032 for (j = 0; j < pvt->channel_count; j++) { in init_csrows()
3034 dimm->mtype = pvt->dram_type; in init_csrows()
3203 static bool ecc_enabled(struct amd64_pvt *pvt) in ecc_enabled() argument
3205 u16 nid = pvt->mc_node_id; in ecc_enabled()
3215 umc = &pvt->umc[i]; in ecc_enabled()
3236 amd64_read_pci_cfg(pvt->F3, NBCFG, &value); in ecc_enabled()
3256 f17h_determine_edac_ctl_cap(struct mem_ctl_info *mci, struct amd64_pvt *pvt) in f17h_determine_edac_ctl_cap() argument
3261 if (pvt->umc[i].sdp_ctrl & UMC_SDP_INIT) { in f17h_determine_edac_ctl_cap()
3262 ecc_en &= !!(pvt->umc[i].umc_cap_hi & UMC_ECC_ENABLED); in f17h_determine_edac_ctl_cap()
3263 cpk_en &= !!(pvt->umc[i].umc_cap_hi & UMC_ECC_CHIPKILL_CAP); in f17h_determine_edac_ctl_cap()
3265 dev_x4 &= !!(pvt->umc[i].dimm_cfg & BIT(6)); in f17h_determine_edac_ctl_cap()
3266 dev_x16 &= !!(pvt->umc[i].dimm_cfg & BIT(7)); in f17h_determine_edac_ctl_cap()
3288 struct amd64_pvt *pvt = mci->pvt_info; in setup_mci_misc_attrs() local
3293 if (pvt->umc) { in setup_mci_misc_attrs()
3294 f17h_determine_edac_ctl_cap(mci, pvt); in setup_mci_misc_attrs()
3296 if (pvt->nbcap & NBCAP_SECDED) in setup_mci_misc_attrs()
3299 if (pvt->nbcap & NBCAP_CHIPKILL) in setup_mci_misc_attrs()
3303 mci->edac_cap = determine_edac_cap(pvt); in setup_mci_misc_attrs()
3306 mci->dev_name = pci_name(pvt->F3); in setup_mci_misc_attrs()
3317 static struct amd64_family_type *per_family_init(struct amd64_pvt *pvt) in per_family_init() argument
3319 pvt->ext_model = boot_cpu_data.x86_model >> 4; in per_family_init()
3320 pvt->stepping = boot_cpu_data.x86_stepping; in per_family_init()
3321 pvt->model = boot_cpu_data.x86_model; in per_family_init()
3322 pvt->fam = boot_cpu_data.x86; in per_family_init()
3324 switch (pvt->fam) { in per_family_init()
3327 pvt->ops = &family_types[K8_CPUS].ops; in per_family_init()
3332 pvt->ops = &family_types[F10_CPUS].ops; in per_family_init()
3336 if (pvt->model == 0x30) { in per_family_init()
3338 pvt->ops = &family_types[F15_M30H_CPUS].ops; in per_family_init()
3340 } else if (pvt->model == 0x60) { in per_family_init()
3342 pvt->ops = &family_types[F15_M60H_CPUS].ops; in per_family_init()
3347 pvt->ops = &family_types[F15_CPUS].ops; in per_family_init()
3351 if (pvt->model == 0x30) { in per_family_init()
3353 pvt->ops = &family_types[F16_M30H_CPUS].ops; in per_family_init()
3357 pvt->ops = &family_types[F16_CPUS].ops; in per_family_init()
3361 if (pvt->model >= 0x10 && pvt->model <= 0x2f) { in per_family_init()
3363 pvt->ops = &family_types[F17_M10H_CPUS].ops; in per_family_init()
3365 } else if (pvt->model >= 0x30 && pvt->model <= 0x3f) { in per_family_init()
3367 pvt->ops = &family_types[F17_M30H_CPUS].ops; in per_family_init()
3369 } else if (pvt->model >= 0x60 && pvt->model <= 0x6f) { in per_family_init()
3371 pvt->ops = &family_types[F17_M60H_CPUS].ops; in per_family_init()
3373 } else if (pvt->model >= 0x70 && pvt->model <= 0x7f) { in per_family_init()
3375 pvt->ops = &family_types[F17_M70H_CPUS].ops; in per_family_init()
3381 pvt->ops = &family_types[F17_CPUS].ops; in per_family_init()
3383 if (pvt->fam == 0x18) in per_family_init()
3388 if (pvt->model >= 0x20 && pvt->model <= 0x2f) { in per_family_init()
3390 pvt->ops = &family_types[F17_M70H_CPUS].ops; in per_family_init()
3395 pvt->ops = &family_types[F19_CPUS].ops; in per_family_init()
3405 (pvt->fam == 0xf ? in per_family_init()
3406 (pvt->ext_model >= K8_REV_F ? "revF or later " in per_family_init()
3408 : ""), pvt->mc_node_id); in per_family_init()
3422 static int hw_info_get(struct amd64_pvt *pvt) in hw_info_get() argument
3427 if (pvt->fam >= 0x17) { in hw_info_get()
3428 pvt->umc = kcalloc(fam_type->max_mcs, sizeof(struct amd64_umc), GFP_KERNEL); in hw_info_get()
3429 if (!pvt->umc) in hw_info_get()
3439 ret = reserve_mc_sibling_devs(pvt, pci_id1, pci_id2); in hw_info_get()
3443 read_mc_regs(pvt); in hw_info_get()
3448 static void hw_info_put(struct amd64_pvt *pvt) in hw_info_put() argument
3450 if (pvt->F0 || pvt->F1) in hw_info_put()
3451 free_mc_sibling_devs(pvt); in hw_info_put()
3453 kfree(pvt->umc); in hw_info_put()
3456 static int init_one_instance(struct amd64_pvt *pvt) in init_one_instance() argument
3467 pvt->channel_count = pvt->ops->early_channel_count(pvt); in init_one_instance()
3468 if (pvt->channel_count < 0) in init_one_instance()
3473 layers[0].size = pvt->csels[0].b_cnt; in init_one_instance()
3485 mci = edac_mc_alloc(pvt->mc_node_id, ARRAY_SIZE(layers), layers, 0); in init_one_instance()
3489 mci->pvt_info = pvt; in init_one_instance()
3490 mci->pdev = &pvt->F3->dev; in init_one_instance()
3507 static bool instance_has_memory(struct amd64_pvt *pvt) in instance_has_memory() argument
3513 for_each_chip_select(cs, dct, pvt) in instance_has_memory()
3514 cs_enabled |= csrow_enabled(cs, dct, pvt); in instance_has_memory()
3523 struct amd64_pvt *pvt = NULL; in probe_one_instance() local
3534 pvt = kzalloc(sizeof(struct amd64_pvt), GFP_KERNEL); in probe_one_instance()
3535 if (!pvt) in probe_one_instance()
3538 pvt->mc_node_id = nid; in probe_one_instance()
3539 pvt->F3 = F3; in probe_one_instance()
3541 fam_type = per_family_init(pvt); in probe_one_instance()
3545 ret = hw_info_get(pvt); in probe_one_instance()
3550 if (!instance_has_memory(pvt)) { in probe_one_instance()
3555 if (!ecc_enabled(pvt)) { in probe_one_instance()
3571 ret = init_one_instance(pvt); in probe_one_instance()
3581 dump_misc_regs(pvt); in probe_one_instance()
3586 hw_info_put(pvt); in probe_one_instance()
3587 kfree(pvt); in probe_one_instance()
3602 struct amd64_pvt *pvt; in remove_one_instance() local
3609 pvt = mci->pvt_info; in remove_one_instance()
3619 hw_info_put(pvt); in remove_one_instance()
3620 kfree(pvt); in remove_one_instance()
3627 struct amd64_pvt *pvt; in setup_pci_device() local
3636 pvt = mci->pvt_info; in setup_pci_device()
3637 if (pvt->umc) in setup_pci_device()
3638 pci_ctl = edac_pci_create_generic_ctl(&pvt->F0->dev, EDAC_MOD_STR); in setup_pci_device()
3640 pci_ctl = edac_pci_create_generic_ctl(&pvt->F2->dev, EDAC_MOD_STR); in setup_pci_device()