Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

EDAC/skx_common: Swap memory controller index mapping

The current mapping of memory controller indices is from physical index [1]
to logical index [2], as show below:

skx_dev->imc[pmc].mc_mapping = lmc

Since skx_dev->imc[] is an array of present memory controller instances,
mapping memory controller indices from logical index to physical index,
as show below, is more reasonable. This is also a preparatory step for
making skx_dev->imc[] a flexible array.

skx_dev->imc[lmc].mc_mapping = pmc

Both mappings are equivalent. No functional changes intended.

[1] Indices for memory controllers include both those present to the
OS and those disabled by BIOS.

[2] Indices for memory controllers present to the OS.

Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Link: https://lore.kernel.org/r/20250731145534.2759334-4-qiuxu.zhuo@intel.com

authored by

Qiuxu Zhuo and committed by
Tony Luck
30b47b71 59cfc06a

+20 -8
+20 -8
drivers/edac/skx_common.c
··· 130 130 * the logical indices of the memory controllers enumerated by the 131 131 * EDAC driver. 132 132 */ 133 - for (int i = 0; i < NUM_IMC; i++) 133 + for (int i = 0; i < d->num_imc; i++) 134 134 d->imc[i].mc_mapping = i; 135 135 } 136 136 ··· 139 139 edac_dbg(0, "Set the mapping of mc phy idx to logical idx: %02d -> %02d\n", 140 140 pmc, lmc); 141 141 142 - d->imc[pmc].mc_mapping = lmc; 142 + d->imc[lmc].mc_mapping = pmc; 143 143 } 144 144 EXPORT_SYMBOL_GPL(skx_set_mc_mapping); 145 145 146 - static u8 skx_get_mc_mapping(struct skx_dev *d, u8 pmc) 146 + static int skx_get_mc_mapping(struct skx_dev *d, u8 pmc) 147 147 { 148 - edac_dbg(0, "Get the mapping of mc phy idx to logical idx: %02d -> %02d\n", 149 - pmc, d->imc[pmc].mc_mapping); 148 + for (int lmc = 0; lmc < d->num_imc; lmc++) { 149 + if (d->imc[lmc].mc_mapping == pmc) { 150 + edac_dbg(0, "Get the mapping of mc phy idx to logical idx: %02d -> %02d\n", 151 + pmc, lmc); 150 152 151 - return d->imc[pmc].mc_mapping; 153 + return lmc; 154 + } 155 + } 156 + 157 + return -1; 152 158 } 153 159 154 160 static bool skx_adxl_decode(struct decoded_addr *res, enum error_source err_src) 155 161 { 162 + int i, lmc, len = 0; 156 163 struct skx_dev *d; 157 - int i, len = 0; 158 164 159 165 if (res->addr >= skx_tohm || (res->addr >= skx_tolm && 160 166 res->addr < BIT_ULL(32))) { ··· 224 218 return false; 225 219 } 226 220 227 - res->imc = skx_get_mc_mapping(d, res->imc); 221 + lmc = skx_get_mc_mapping(d, res->imc); 222 + if (lmc < 0) { 223 + skx_printk(KERN_ERR, "No lmc for imc %d\n", res->imc); 224 + return false; 225 + } 226 + 227 + res->imc = lmc; 228 228 229 229 for (i = 0; i < adxl_component_count; i++) { 230 230 if (adxl_values[i] == ~0x0ull)