Skip to content

Commit ee5340a

Browse files
qzhuo2aegl
authored andcommitted
EDAC, {skx,i10nm}: Make some configurations CPU model specific
The device ID for configuration agent PCI device and the offset for bus number configuration register can be CPU model specific. So add a new structure res_config to make them configurable and pass res_config to {skx,i10nm}_init() and skx_get_all_bus_mappings() for use. Signed-off-by: Qiuxu Zhuo <[email protected]> Signed-off-by: Tony Luck <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8f3d9f3 commit ee5340a

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

drivers/edac/i10nm_base.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,16 @@ static int i10nm_get_all_munits(void)
122122
return 0;
123123
}
124124

125+
static struct res_config i10nm_cfg = {
126+
.type = I10NM,
127+
.decs_did = 0x3452,
128+
.busno_cfg_offset = 0xcc,
129+
};
130+
125131
static const struct x86_cpu_id i10nm_cpuids[] = {
126-
X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_D, NULL),
127-
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, NULL),
128-
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_D, NULL),
132+
X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_D, &i10nm_cfg),
133+
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, &i10nm_cfg),
134+
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_D, &i10nm_cfg),
129135
{}
130136
};
131137
MODULE_DEVICE_TABLE(x86cpu, i10nm_cpuids);
@@ -234,6 +240,7 @@ static int __init i10nm_init(void)
234240
{
235241
u8 mc = 0, src_id = 0, node_id = 0;
236242
const struct x86_cpu_id *id;
243+
struct res_config *cfg;
237244
const char *owner;
238245
struct skx_dev *d;
239246
int rc, i, off[3] = {0xd0, 0xc8, 0xcc};
@@ -249,11 +256,13 @@ static int __init i10nm_init(void)
249256
if (!id)
250257
return -ENODEV;
251258

259+
cfg = (struct res_config *)id->driver_data;
260+
252261
rc = skx_get_hi_lo(0x09a2, off, &tolm, &tohm);
253262
if (rc)
254263
return rc;
255264

256-
rc = skx_get_all_bus_mappings(0x3452, 0xcc, I10NM, &i10nm_edac_list);
265+
rc = skx_get_all_bus_mappings(cfg, &i10nm_edac_list);
257266
if (rc < 0)
258267
goto fail;
259268
if (rc == 0) {

drivers/edac/skx_base.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,14 @@ static int get_all_munits(const struct munit *m)
157157
return -ENODEV;
158158
}
159159

160+
static struct res_config skx_cfg = {
161+
.type = SKX,
162+
.decs_did = 0x2016,
163+
.busno_cfg_offset = 0xcc,
164+
};
165+
160166
static const struct x86_cpu_id skx_cpuids[] = {
161-
X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_X, NULL),
167+
X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_X, &skx_cfg),
162168
{ }
163169
};
164170
MODULE_DEVICE_TABLE(x86cpu, skx_cpuids);
@@ -641,6 +647,7 @@ static inline void teardown_skx_debug(void) {}
641647
static int __init skx_init(void)
642648
{
643649
const struct x86_cpu_id *id;
650+
struct res_config *cfg;
644651
const struct munit *m;
645652
const char *owner;
646653
int rc = 0, i, off[3] = {0xd0, 0xd4, 0xd8};
@@ -657,11 +664,13 @@ static int __init skx_init(void)
657664
if (!id)
658665
return -ENODEV;
659666

667+
cfg = (struct res_config *)id->driver_data;
668+
660669
rc = skx_get_hi_lo(0x2034, off, &skx_tolm, &skx_tohm);
661670
if (rc)
662671
return rc;
663672

664-
rc = skx_get_all_bus_mappings(0x2016, 0xcc, SKX, &skx_edac_list);
673+
rc = skx_get_all_bus_mappings(cfg, &skx_edac_list);
665674
if (rc < 0)
666675
goto fail;
667676
if (rc == 0) {

drivers/edac/skx_common.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,11 @@ static int get_width(u32 mtr)
197197
}
198198

199199
/*
200-
* We use the per-socket device @did to count how many sockets are present,
200+
* We use the per-socket device @cfg->did to count how many sockets are present,
201201
* and to detemine which PCI buses are associated with each socket. Allocate
202202
* and build the full list of all the skx_dev structures that we need here.
203203
*/
204-
int skx_get_all_bus_mappings(unsigned int did, int off, enum type type,
205-
struct list_head **list)
204+
int skx_get_all_bus_mappings(struct res_config *cfg, struct list_head **list)
206205
{
207206
struct pci_dev *pdev, *prev;
208207
struct skx_dev *d;
@@ -211,7 +210,7 @@ int skx_get_all_bus_mappings(unsigned int did, int off, enum type type,
211210

212211
prev = NULL;
213212
for (;;) {
214-
pdev = pci_get_device(PCI_VENDOR_ID_INTEL, did, prev);
213+
pdev = pci_get_device(PCI_VENDOR_ID_INTEL, cfg->decs_did, prev);
215214
if (!pdev)
216215
break;
217216
ndev++;
@@ -221,7 +220,7 @@ int skx_get_all_bus_mappings(unsigned int did, int off, enum type type,
221220
return -ENOMEM;
222221
}
223222

224-
if (pci_read_config_dword(pdev, off, &reg)) {
223+
if (pci_read_config_dword(pdev, cfg->busno_cfg_offset, &reg)) {
225224
kfree(d);
226225
pci_dev_put(pdev);
227226
skx_printk(KERN_ERR, "Failed to read bus idx\n");
@@ -230,7 +229,7 @@ int skx_get_all_bus_mappings(unsigned int did, int off, enum type type,
230229

231230
d->bus[0] = GET_BITFIELD(reg, 0, 7);
232231
d->bus[1] = GET_BITFIELD(reg, 8, 15);
233-
if (type == SKX) {
232+
if (cfg->type == SKX) {
234233
d->seg = pci_domain_nr(pdev->bus);
235234
d->bus[2] = GET_BITFIELD(reg, 16, 23);
236235
d->bus[3] = GET_BITFIELD(reg, 24, 31);

drivers/edac/skx_common.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ struct decoded_addr {
112112
int bank_group;
113113
};
114114

115+
struct res_config {
116+
enum type type;
117+
/* Configuration agent device ID */
118+
unsigned int decs_did;
119+
/* Default bus number configuration register offset */
120+
int busno_cfg_offset;
121+
};
122+
115123
typedef int (*get_dimm_config_f)(struct mem_ctl_info *mci);
116124
typedef bool (*skx_decode_f)(struct decoded_addr *res);
117125
typedef void (*skx_show_retry_log_f)(struct decoded_addr *res, char *msg, int len);
@@ -123,8 +131,7 @@ void skx_set_decode(skx_decode_f decode, skx_show_retry_log_f show_retry_log);
123131
int skx_get_src_id(struct skx_dev *d, int off, u8 *id);
124132
int skx_get_node_id(struct skx_dev *d, u8 *id);
125133

126-
int skx_get_all_bus_mappings(unsigned int did, int off, enum type,
127-
struct list_head **list);
134+
int skx_get_all_bus_mappings(struct res_config *cfg, struct list_head **list);
128135

129136
int skx_get_hi_lo(unsigned int did, int off[], u64 *tolm, u64 *tohm);
130137

0 commit comments

Comments
 (0)