Skip to content

Commit 75aeaaf

Browse files
yghannamsuryasaimadhu
authored andcommitted
EDAC/amd64: Set memory type per DIMM
Current AMD systems allow mixing of DIMM types within a system. However, DIMMs within a channel, i.e. managed by a single Unified Memory Controller (UMC), must be of the same type. Handle this possible configuration by checking and setting the memory type for each individual "UMC" structure. Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: William Roche <william.roche@oracle.com> Link: https://lore.kernel.org/r/20220202144307.2678405-2-yazen.ghannam@amd.com
1 parent cfb9244 commit 75aeaaf

2 files changed

Lines changed: 40 additions & 13 deletions

File tree

drivers/edac/amd64_edac.c

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ static void __dump_misc_regs_df(struct amd64_pvt *pvt)
14291429
edac_dbg(1, "UMC%d x16 DIMMs present: %s\n",
14301430
i, (umc->dimm_cfg & BIT(7)) ? "yes" : "no");
14311431

1432-
if (pvt->dram_type == MEM_LRDDR4) {
1432+
if (umc->dram_type == MEM_LRDDR4) {
14331433
amd_smn_read(pvt->mc_node_id, umc_base + UMCCH_ADDR_CFG, &tmp);
14341434
edac_dbg(1, "UMC%d LRDIMM %dx rank multiply\n",
14351435
i, 1 << ((tmp >> 4) & 0x3));
@@ -1616,19 +1616,36 @@ static void read_dct_base_mask(struct amd64_pvt *pvt)
16161616
}
16171617
}
16181618

1619-
static void determine_memory_type(struct amd64_pvt *pvt)
1619+
static void determine_memory_type_df(struct amd64_pvt *pvt)
16201620
{
1621-
u32 dram_ctrl, dcsm;
1621+
struct amd64_umc *umc;
1622+
u32 i;
16221623

1623-
if (pvt->umc) {
1624-
if ((pvt->umc[0].dimm_cfg | pvt->umc[1].dimm_cfg) & BIT(5))
1625-
pvt->dram_type = MEM_LRDDR4;
1626-
else if ((pvt->umc[0].dimm_cfg | pvt->umc[1].dimm_cfg) & BIT(4))
1627-
pvt->dram_type = MEM_RDDR4;
1624+
for_each_umc(i) {
1625+
umc = &pvt->umc[i];
1626+
1627+
if (!(umc->sdp_ctrl & UMC_SDP_INIT)) {
1628+
umc->dram_type = MEM_EMPTY;
1629+
continue;
1630+
}
1631+
1632+
if (umc->dimm_cfg & BIT(5))
1633+
umc->dram_type = MEM_LRDDR4;
1634+
else if (umc->dimm_cfg & BIT(4))
1635+
umc->dram_type = MEM_RDDR4;
16281636
else
1629-
pvt->dram_type = MEM_DDR4;
1630-
return;
1637+
umc->dram_type = MEM_DDR4;
1638+
1639+
edac_dbg(1, " UMC%d DIMM type: %s\n", i, edac_mem_types[umc->dram_type]);
16311640
}
1641+
}
1642+
1643+
static void determine_memory_type(struct amd64_pvt *pvt)
1644+
{
1645+
u32 dram_ctrl, dcsm;
1646+
1647+
if (pvt->umc)
1648+
return determine_memory_type_df(pvt);
16321649

16331650
switch (pvt->fam) {
16341651
case 0xf:
@@ -3452,7 +3469,9 @@ static void read_mc_regs(struct amd64_pvt *pvt)
34523469
read_dct_base_mask(pvt);
34533470

34543471
determine_memory_type(pvt);
3455-
edac_dbg(1, " DIMM type: %s\n", edac_mem_types[pvt->dram_type]);
3472+
3473+
if (!pvt->umc)
3474+
edac_dbg(1, " DIMM type: %s\n", edac_mem_types[pvt->dram_type]);
34563475

34573476
determine_ecc_sym_sz(pvt);
34583477
}
@@ -3548,7 +3567,7 @@ static int init_csrows_df(struct mem_ctl_info *mci)
35483567
pvt->mc_node_id, cs);
35493568

35503569
dimm->nr_pages = get_csrow_nr_pages(pvt, umc, cs);
3551-
dimm->mtype = pvt->dram_type;
3570+
dimm->mtype = pvt->umc[umc].dram_type;
35523571
dimm->edac_mode = edac_mode;
35533572
dimm->dtype = dev_type;
35543573
dimm->grain = 64;

drivers/edac/amd64_edac.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ struct amd64_umc {
344344
u32 sdp_ctrl; /* SDP Control reg */
345345
u32 ecc_ctrl; /* DRAM ECC Control reg */
346346
u32 umc_cap_hi; /* Capabilities High reg */
347+
348+
/* cache the dram_type */
349+
enum mem_type dram_type;
347350
};
348351

349352
struct amd64_pvt {
@@ -391,7 +394,12 @@ struct amd64_pvt {
391394
/* place to store error injection parameters prior to issue */
392395
struct error_injection injection;
393396

394-
/* cache the dram_type */
397+
/*
398+
* cache the dram_type
399+
*
400+
* NOTE: Don't use this for Family 17h and later.
401+
* Use dram_type in struct amd64_umc instead.
402+
*/
395403
enum mem_type dram_type;
396404

397405
struct amd64_umc *umc; /* UMC registers */

0 commit comments

Comments
 (0)