Messages in this thread Patch in this message | | | From | Yazen Ghannam <> | Subject | [PATCH 06/18] EDAC/amd64: Add prep_chip_selects() into pvt->ops | Date | Mon, 9 May 2022 14:55:22 +0000 |
| |
From: Muralidhara M K <muralidhara.mk@amd.com>
GPU Nodes will need to set the number of available Chip Selects, i.e. Base and Mask values, differently than existing systems. A function pointer should be used rather than introduce another branching condition.
Prepare for this by adding prep_chip_selects() to pvt->ops and set it as needed based on currently supported systems.
Use a "umc" prefix for modern systems, since these use Unified Memory Controllers (UMCs).
Use a "dct" prefix for newly-defined legacy functions, since these systems use DRAM Controllers (DCTs).
Signed-off-by: Muralidhara M K <muralidhara.mk@amd.com> Signed-off-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com> [Rebased/reworked patch and reworded commit message] Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com> --- drivers/edac/amd64_edac.c | 26 +++++++++++++++----------- drivers/edac/amd64_edac.h | 1 + 2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 3d569290d4cf..f8cd89278753 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -1483,7 +1483,7 @@ static void dump_misc_regs(struct amd64_pvt *pvt) /* * See BKDG, F2x[1,0][5C:40], F2[1,0][6C:60] */ -static void prep_chip_selects(struct amd64_pvt *pvt) +static void dct_prep_chip_selects(struct amd64_pvt *pvt) { if (pvt->fam == 0xf && pvt->ext_model < K8_REV_F) { pvt->csels[0].b_cnt = pvt->csels[1].b_cnt = 8; @@ -1491,20 +1491,22 @@ static void prep_chip_selects(struct amd64_pvt *pvt) } else if (pvt->fam == 0x15 && pvt->model == 0x30) { pvt->csels[0].b_cnt = pvt->csels[1].b_cnt = 4; pvt->csels[0].m_cnt = pvt->csels[1].m_cnt = 2; - } else if (pvt->fam >= 0x17) { - int umc; - - for_each_umc(umc) { - pvt->csels[umc].b_cnt = 4; - pvt->csels[umc].m_cnt = pvt->flags.zn_regs_v2 ? 4 : 2; - } - } else { pvt->csels[0].b_cnt = pvt->csels[1].b_cnt = 8; pvt->csels[0].m_cnt = pvt->csels[1].m_cnt = 4; } } +static void umc_prep_chip_selects(struct amd64_pvt *pvt) +{ + int umc; + + for_each_umc(umc) { + pvt->csels[umc].b_cnt = 4; + pvt->csels[umc].m_cnt = pvt->flags.zn_regs_v2 ? 4 : 2; + } +} + static void read_umc_base_mask(struct amd64_pvt *pvt) { u32 umc_base_reg, umc_base_reg_sec; @@ -1563,8 +1565,6 @@ static void read_dct_base_mask(struct amd64_pvt *pvt) { int cs; - prep_chip_selects(pvt); - if (pvt->umc) return read_umc_base_mask(pvt); @@ -3301,6 +3301,8 @@ static void read_mc_regs(struct amd64_pvt *pvt) } skip: + pvt->ops->prep_chip_selects(pvt); + read_dct_base_mask(pvt); determine_memory_type(pvt); @@ -3762,6 +3764,7 @@ static void setup_mci_misc_attrs(struct mem_ctl_info *mci) static struct low_ops umc_ops = { .early_channel_count = umc_early_channel_count, .dbam_to_cs = umc_addr_mask_to_cs_size, + .prep_chip_selects = umc_prep_chip_selects, }; /* Use Family 16h versions for defaults and adjust as needed below. */ @@ -3769,6 +3772,7 @@ static struct low_ops dct_ops = { .early_channel_count = f1x_early_channel_count, .map_sysaddr_to_csrow = f1x_map_sysaddr_to_csrow, .dbam_to_cs = f16_dbam_to_chip_select, + .prep_chip_selects = dct_prep_chip_selects, }; static int per_family_init(struct amd64_pvt *pvt) diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h index a4a27208532c..0a7738df396f 100644 --- a/drivers/edac/amd64_edac.h +++ b/drivers/edac/amd64_edac.h @@ -468,6 +468,7 @@ struct low_ops { struct err_info *err); int (*dbam_to_cs)(struct amd64_pvt *pvt, u8 dct, unsigned int cs_mode, int cs_mask_nr); + void (*prep_chip_selects)(struct amd64_pvt *pvt); }; int __amd64_read_pci_cfg_dword(struct pci_dev *pdev, int offset, -- 2.25.1
| |