Skip to content

Commit f619613

Browse files
qzhuo2aegl
authored andcommitted
EDAC/{skx_comm,imh}: Detect 2-level memory configuration
Detect 2-level memory configurations and notify the 'skx_common' library to enable ADXL 2-level memory error decoding. Tested-by: Yi Lai <yi1.lai@intel.com> Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com> Signed-off-by: Tony Luck <tony.luck@intel.com> Link: https://patch.msgid.link/20251119134132.2389472-7-qiuxu.zhuo@intel.com
1 parent 39abdcb commit f619613

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

drivers/edac/imh_base.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
#define TOLM(reg) (((u64)GET_BITFIELD(reg, 16, 31)) << 16)
3636
#define TOHM(reg) (((u64)GET_BITFIELD(reg, 16, 51)) << 16)
3737

38+
/* Home Agent (HA) */
39+
#define NMCACHING(reg) GET_BITFIELD(reg, 8, 8)
40+
3841
/**
3942
* struct local_reg - A register as described in the local package view.
4043
*
@@ -346,6 +349,35 @@ static int imh_get_munits(struct res_config *cfg, struct list_head *edac_list)
346349
return 0;
347350
}
348351

352+
static bool check_2lm_enabled(struct res_config *cfg, struct skx_dev *d, int ha_idx)
353+
{
354+
DEFINE_LOCAL_REG(reg, cfg, d->pkg, true, ha, ha_idx, mode);
355+
356+
if (!read_local_reg(&reg))
357+
return false;
358+
359+
if (!NMCACHING(reg.val))
360+
return false;
361+
362+
edac_dbg(2, "2-level memory configuration (reg 0x%llx, ha idx %d)\n", reg.val, ha_idx);
363+
return true;
364+
}
365+
366+
/* Check whether the system has a 2-level memory configuration. */
367+
static bool imh_2lm_enabled(struct res_config *cfg, struct list_head *head)
368+
{
369+
struct skx_dev *d;
370+
int i;
371+
372+
list_for_each_entry(d, head, list) {
373+
for (i = 0; i < cfg->ddr_imc_num; i++)
374+
if (check_2lm_enabled(cfg, d, i))
375+
return true;
376+
}
377+
378+
return false;
379+
}
380+
349381
/* Helpers to read memory controller registers */
350382
static u64 read_imc_reg(struct skx_imc *imc, int chan, u32 offset, u8 width)
351383
{
@@ -467,6 +499,10 @@ static struct res_config dmr_cfg = {
467499
.sca_reg_tolm_width = 8,
468500
.sca_reg_tohm_offset = 0x2108,
469501
.sca_reg_tohm_width = 8,
502+
.ha_base = 0x3eb000,
503+
.ha_size = 0x1000,
504+
.ha_reg_mode_offset = 0x4a0,
505+
.ha_reg_mode_width = 4,
470506
};
471507

472508
static const struct x86_cpu_id imh_cpuids[] = {
@@ -526,6 +562,8 @@ static int __init imh_init(void)
526562
if (rc)
527563
goto fail;
528564

565+
skx_set_mem_cfg(imh_2lm_enabled(cfg, edac_list));
566+
529567
rc = imh_register_mci(cfg, edac_list);
530568
if (rc)
531569
goto fail;

drivers/edac/skx_common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ struct res_config {
313313
u8 sca_reg_tolm_width;
314314
u32 sca_reg_tohm_offset;
315315
u8 sca_reg_tohm_width;
316+
u64 ha_base;
317+
u32 ha_size;
318+
u32 ha_reg_mode_offset;
319+
u8 ha_reg_mode_width;
316320
};
317321
};
318322
};

0 commit comments

Comments
 (0)