EDAC, ghes: use CPER module handles to locate DIMMs
PATCH 1/1 EDAC, ghes: use CPER module handles to locate DIMMs
The current ghes_edac driver does not update per-dimm error counters when reporting memory errors, because there is no platform-independent way to find DIMMs based on the error information provided by firmware. This patch offers a solution for platforms whose firmwares provide valid module handles (SMBIOS type 17) in error records. In this case ghes_edac will use the module handles to locate DIMMs and thus makes per-dimm error reporting possible.
--- drivers/edac/ghes_edac.c | 36 +++++++++++++++++++++++++++++++++--- include/linux/edac.h | 2 ++ 2 files changed, 35 insertions(+), 3 deletions(-)
drivers/edac/ghes_edac.c +33 -3
@@ -81,6 +81,26 @@ static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) (*num_dimm)++; } +static int ghes_edac_dimm_index (u16 handle) +{ +struct mem_ctl_info *mci; +int i; + +if (!ghes_pvt) +return -1 ; + + mci = ghes_pvt->mci; + +if (!mci) +return -1 ; + +for (i =0 ; i < mci->tot_dimms; i++) { +if (mci->dimms[i]->smbios_handle == handle) +return i; + } +return -1 ; +} +static void ghes_edac_dmidecode (const struct dmi_header *dh,void *arg) {struct ghes_edac_dimm_fill *dimm_fill = arg;
@@ -177,6 +197,8 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) entry->total_width, entry->data_width); } + dimm->smbios_handle = entry->handle; + dimm_fill->count++; } }
@@ -327,12 +349,20 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) p +=sprintf (p,"bit_pos:%d " , mem_err->bit_pos);if (mem_err->validation_bits &CPER_MEM_VALID_MODULE_HANDLE ) {const char *bank =NULL , *device =NULL ; +int index =-1 ; +dmi_memdev_name (mem_err->mem_dev_handle, &bank, &device); + p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , + mem_err->mem_dev_handle);if (bank !=NULL && device !=NULL ) p +=sprintf (p,"DIMM location:%s %s " , bank, device); -else - p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , - mem_err->mem_dev_handle); + + index =ghes_edac_dimm_index (mem_err->mem_dev_handle); +if (index >=0 ) { + e->top_layer = index; + e->enable_per_layer_report = true; + } + }if (p > e->location) *(p -1 ) ='\0' ;
include/linux/edac.h +2 -0
@@ -451,6 +451,8 @@ struct dimm_info {u32 nr_pages;/* number of pages on this dimm */ unsigned csrow, cschannel;/* Points to the old API data */ + +u16 smbios_handle;/* Handle for SMBIOS type 17 */ };/**
Signature · 1 line
2.7.4
Borislav Petkov
maintainerQuoted 9 lines · Fan Wu
The current
ghes_edacdriver does not update per-dimm error counters when reporting memory errors, because there is no platform-independent way to find DIMMs based on the error information provided by firmware. This patch offers a solution for platforms whose firmwares provide valid module handles (SMBIOS type 17) in error records. In this caseghes_edacwill use the module handles to locate DIMMs and thus makes per-dimm error reporting possible.
Quoted 5 lines
Signed-off-by Fan Wu <[email protected]>--- drivers/edac/ghes_edac.c | 36 +++++++++++++++++++++++++++++++++--- include/linux/edac.h | 2 ++ 2 files changed, 35 insertions(+), 3 deletions(-)
If we're going to do this, it needs to be tested on an x86 box which loads ghes_edac. Adding Toshi to Cc.
Otherwise it must remain ARM-specific.
drivers/edac/ghes_edac.c static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) · line 84
Quoted 9 lines
drivers/edac/ghes_edac.c +1
-0@@ -81,6 +81,26 @@ static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) (*num_dimm)++; } +static int ghes_edac_dimm_index (u16 handle)
get_dimm_smbios_handle()
drivers/edac/ghes_edac.c static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) · line 90
Quoted 6 lines
drivers/edac/ghes_edac.c +6
-0+{ +struct mem_ctl_info *mci; +int i; + +if (!ghes_pvt) +return -1 ;
You don't need that test.
drivers/edac/ghes_edac.c static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) · line 95
Quoted 5 lines
drivers/edac/ghes_edac.c +5
-0+ + mci = ghes_pvt->mci; + +if (!mci) +return -1 ;
Ditto.
Quoted 11 lines
drivers/edac/ghes_edac.c +8
-0+ +for (i =0 ; i < mci->tot_dimms; i++) { +if (mci->dimms[i]->smbios_handle == handle) +return i; + } +return -1 ; +} +static void ghes_edac_dmidecode (const struct dmi_header *dh,void *arg) {struct ghes_edac_dimm_fill *dimm_fill = arg;
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Hi Fan,
Quoted 4 lines · Fan Wu
The current
ghes_edacdriver does not update per-dimm error counters when reporting memory errors, because there is no platform-independent way to find DIMMs based on the error information provided by firmware.
I'd argue there is: its in the CPER records, we just didn't do anything useful with the information in the past!
Quoted 12 lines
This patch offers a solution
for platforms whose firmwares provide valid module handles (SMBIOS type 17) in error records. In this caseghes_edacwill use the module handles to locate DIMMs and thus makes per-dimm error reporting possible.drivers/edac/ghes_edac.c +0
-0
drivers/edac/ghes_edac.c static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) · line 90
Quoted 10 lines
drivers/edac/ghes_edac.c +7
-0@@ -81,6 +81,26 @@ static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) (*num_dimm)++; } +static int ghes_edac_dimm_index (u16 handle) +{ +struct mem_ctl_info *mci; +int i; + +if (!ghes_pvt) +return -1 ;
ghes_edac_report_mem_error() already checked this, as its the only caller there is no need to check it again.
drivers/edac/ghes_edac.c static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) · line 95
Quoted 4 lines
drivers/edac/ghes_edac.c +4
-0+ mci = ghes_pvt->mci; + +if (!mci) +return -1 ;
Can this happen? ghes_edac_report_mem_error() would have dereferenced this already!
If you need the struct mem_ctl_info, you may as well pass it in as the only caller has it to hand.
Quoted 12 lines
drivers/edac/ghes_edac.c +8
-0+ +for (i =0 ; i < mci->tot_dimms; i++) { +if (mci->dimms[i]->smbios_handle == handle) +return i; + } +return -1 ; +} +static void ghes_edac_dmidecode (const struct dmi_header *dh,void *arg) {struct ghes_edac_dimm_fill *dimm_fill = arg;
drivers/edac/ghes_edac.c static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) · line 200
Quoted 4 lines
drivers/edac/ghes_edac.c +1
-0@@ -177,6 +197,8 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) entry->total_width, entry->data_width); } + dimm->smbios_handle = entry->handle;
We aren't checking for duplicate handles, (e.g. they're all zero). I think this is fine as chances are firmware on those systems won't set CPER_MEM_VALID_MODULE_HANDLE. If it does, the handle it gives us is ambiguous, and we pick a dimm, instead of whine-ing about broken firmware tables.
(I'm just drawing attention to it in case someone disagrees)
Quoted 8 lines
drivers/edac/ghes_edac.c +1
-0dimm_fill->count++; } }@@ -327,12 +349,20 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) p +=sprintf (p,"bit_pos:%d " , mem_err->bit_pos);if (mem_err->validation_bits &CPER_MEM_VALID_MODULE_HANDLE ) {const char *bank =NULL , *device =NULL ; +int index =-1 ;
drivers/edac/ghes_edac.c void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) · line 336
Quoted 10 lines
drivers/edac/ghes_edac.c +3
-3+dmi_memdev_name (mem_err->mem_dev_handle, &bank, &device); + p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , + mem_err->mem_dev_handle);if (bank !=NULL && device !=NULL ) p +=sprintf (p,"DIMM location:%s %s " , bank, device); -else - p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , - mem_err->mem_dev_handle);
Why do we now print the handle every time? The handle is pretty meaningless, it can only be used to find the location-strings, if we get those we print them instead.
drivers/edac/ghes_edac.c void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) · line 368
Quoted 9 lines
drivers/edac/ghes_edac.c +6
-0+ index =ghes_edac_dimm_index (mem_err->mem_dev_handle); +if (index >=0 ) { + e->top_layer = index; + e->enable_per_layer_report = true; + } + }if (p > e->location) *(p -1 ) ='\0' ;
Looks good to me!
Thanks,
James
Hi Boris,
Quoted 4 lines
If we're going to do this, it needs to be tested on an x86 box which loads
ghes_edac. Adding Toshi to Cc.Otherwise it must remain ARM-specific.
Toshi it would be great if you can help! I'll also test the change in x86 but not sure if the firmware updates module_handle.
Quoted 3 lines
Quoted 1 line
+static int
ghes_edac_dimm_index(u16 handle)
get_dimm_smbios_handle()
This function returns an index. So how about get_dimm_smbios_index()?
Quoted 8 lines
drivers/edac/ghes_edac.c static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) · line 90
Quoted 6 lines
drivers/edac/ghes_edac.c +6
-0+{ +struct mem_ctl_info *mci; +int i; + +if (!ghes_pvt) +return -1 ;You don't need that test.
Will remove.
Quoted 7 lines
drivers/edac/ghes_edac.c static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) · line 95
Quoted 5 lines
drivers/edac/ghes_edac.c +5
-0+ + mci = ghes_pvt->mci; + +if (!mci) +return -1 ;Ditto.
Will remove
Thanks,
Fan
Hi James,
Quoted 6 lines
Quoted 3 lines
The current
ghes_edacdriver does not update per-dimm error counters when reporting memory errors, because there is no platform-independent way to find DIMMs based on the error information provided by firmware.I'd argue there is: its in the CPER records, we just didn't do anything useful with the information in the past!
Agreed. Will update the wording.
Quoted 9 lines
drivers/edac/ghes_edac.c static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) · line 90
Quoted 6 lines
drivers/edac/ghes_edac.c +6
-0+static int ghes_edac_dimm_index (u16 handle) { +struct mem_ctl_info *mci; +int i; + +if (!ghes_pvt) +return -1 ;
ghes_edac_report_mem_error()already checked this, as its the only caller there is no need to check it again.
Will remove.
Quoted 11 lines
drivers/edac/ghes_edac.c static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) · line 95
Quoted 5 lines
drivers/edac/ghes_edac.c +4
-0+ mci = ghes_pvt->mci; + +if (!mci) +return -1 ;Can this happen?
ghes_edac_report_mem_error()would have dereferenced this already!If you need the struct
mem_ctl_info, you may as well pass it in as the only caller has it to hand.
Will remove.
Quoted 24 lines
Quoted 13 lines
drivers/edac/ghes_edac.c +8
-0+ +for (i =0 ; i < mci->tot_dimms; i++) { +if (mci->dimms[i]->smbios_handle == handle) +return i; + } +return -1 ; +} + static void ghes_edac_dmidecode(const struct dmi_header *dh, void*arg) {
structghes_edac_dimm_fill*dimm_fill= arg; @@ -177,6 +197,8 @@
static voidghes_edac_dmidecode(const struct dmi_header *dh, void *arg)drivers/edac/ghes_edac.c static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) · line 200
Quoted 4 lines
drivers/edac/ghes_edac.c +1
-0entry->total_width, entry->data_width); } + dimm->smbios_handle = entry->handle;We aren't checking for duplicate handles, (e.g. they're all zero). I think this is fine as chances are firmware on those systems won't set
CPER_MEM_VALID_MODULE_HANDLE. If it does, the handle it gives us is ambiguous, and we pick a dimm, instead of whine-ing about broken firmware tables.
Quoted 1 line
(I'm just drawing attention to it in case someone disagrees)
SBMIOS tables are typically automatically generated so chances for duplicate handles are small.
Quoted 15 lines
drivers/edac/ghes_edac.c void ghes_edac_report_mem_error(int sev,
Quoted 5 lines
drivers/edac/ghes_edac.c +0
-0dimm_fill->count++; } }@@ -327,12 +349,20 @@ void ghes_edac_report_mem_error(int sev,struct
cper_sec_mem_err*mem_err)Review void ghes_edac_report_mem_error(int sev, · line 350
Quoted 2 lines
(quoted diff) +0
-0p += sprintf(p, "bit_pos:%d ", mem_err->bit_pos); if (mem_err->validation_bits &
CPER_MEM_VALID_MODULE_HANDLE) {drivers/edac/ghes_edac.c void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
Quoted 4 lines
drivers/edac/ghes_edac.c +2
-0const char *bank =NULL , *device =NULL ; +int index =-1 ; + dmi_memdev_name(mem_err->mem_dev_handle, &bank,&device);
Quoted 11 lines
drivers/edac/ghes_edac.c void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) · line 335
Quoted 7 lines
drivers/edac/ghes_edac.c +2
-3+ p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , + mem_err->mem_dev_handle);if (bank !=NULL && device !=NULL ) p +=sprintf (p,"DIMM location:%s %s " , bank, device); -else - p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , - mem_err->mem_dev_handle);Why do we now print the handle every time? The handle is pretty meaningless, it can only be used to find the location-strings, if we get those we print them instead.
For ghes_edac the bank/device is informational, and nothing would go wrong if the bank/device numbers are the same as another entry. But the handle is now critical for DIMM lookup, thus pull it out.
Thanks!
Fan
Boris Petkov
maintainerQuoted 5 lines · wufan
Quoted 3 lines
Quoted 1 line
+static int
ghes_edac_dimm_index(u16 handle)
get_dimm_smbios_handle()This function returns an index. So how about
get_dimm_smbios_index()?
Sure.
Signature · 1 line
Sent from a small device: formatting sux and brevity is inevitable.
Hi Fan,
Quoted 23 lines · wufan
Quoted 11 lines
Review void ghes_edac_report_mem_error(int sev,
Quoted 1 line
(quoted diff) +0
-0@@ -327,12 +349,20 @@ void ghes_edac_report_mem_error(int sev,struct
cper_sec_mem_err*mem_err)Review void ghes_edac_report_mem_error(int sev, · line 350
Quoted 2 lines
(quoted diff) +0
-0p += sprintf(p, "bit_pos:%d ", mem_err->bit_pos); if (mem_err->validation_bits &
CPER_MEM_VALID_MODULE_HANDLE) {drivers/edac/ghes_edac.c void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
Quoted 4 lines
drivers/edac/ghes_edac.c +2
-0const char *bank =NULL , *device =NULL ; +int index =-1 ; + dmi_memdev_name(mem_err->mem_dev_handle, &bank,&device);
Quoted 11 lines
drivers/edac/ghes_edac.c void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) · line 335
Quoted 7 lines
drivers/edac/ghes_edac.c +2
-3+ p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , + mem_err->mem_dev_handle);if (bank !=NULL && device !=NULL ) p +=sprintf (p,"DIMM location:%s %s " , bank, device); -else - p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , - mem_err->mem_dev_handle);Why do we now print the handle every time? The handle is pretty meaningless, it can only be used to find the location-strings, if we get those we print them instead.
Quoted 3 lines
For
ghes_edacthe bank/device is informational, and nothing would go wrong if the bank/device numbers are the same as another entry. But the handle is now critical for DIMM lookup, thus pull it out.
Is printing the handle to the kernel log critical?
I'd expect something collecting errors to read from sysfs, not dmesg. I thought the whole point here was to update the per-dimm counters in sysfs.
Thanks,
James
Hi Zhengqiang,
Quoted 8 lines · Fan Wu
The current
ghes_edacdriver does not update per-dimm error counters when reporting memory errors, because there is no platform-independent way to find DIMMs based on the error information provided by firmware. This patch offers a solution for platforms whose firmwares provide valid module handles (SMBIOS type 17) in error records. In this caseghes_edacwill use the module handles to locate DIMMs and thus makes per-dimm error reporting possible.
Does your platform set CPER_MEM_VALID_MODULE_HANDLE in GHES Memory errors? If so, any chance you could test this patch on your platform? [0] (original patch: https://lore.kernel.org/patchwork/patch/978928/)
Thanks,
James
[0] https://marc.info/?l=linux-edac&m=152603960002324
Quoted 78 lines
drivers/edac/ghes_edac.c +33
-3@@ -81,6 +81,26 @@ static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) (*num_dimm)++; } +static int ghes_edac_dimm_index (u16 handle) +{ +struct mem_ctl_info *mci; +int i; + +if (!ghes_pvt) +return -1 ; + + mci = ghes_pvt->mci; + +if (!mci) +return -1 ; + +for (i =0 ; i < mci->tot_dimms; i++) { +if (mci->dimms[i]->smbios_handle == handle) +return i; + } +return -1 ; +} +static void ghes_edac_dmidecode (const struct dmi_header *dh,void *arg) {struct ghes_edac_dimm_fill *dimm_fill = arg;@@ -177,6 +197,8 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) entry->total_width, entry->data_width); } + dimm->smbios_handle = entry->handle; + dimm_fill->count++; } }@@ -327,12 +349,20 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) p +=sprintf (p,"bit_pos:%d " , mem_err->bit_pos);if (mem_err->validation_bits &CPER_MEM_VALID_MODULE_HANDLE ) {const char *bank =NULL , *device =NULL ; +int index =-1 ; +dmi_memdev_name (mem_err->mem_dev_handle, &bank, &device); + p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , + mem_err->mem_dev_handle);if (bank !=NULL && device !=NULL ) p +=sprintf (p,"DIMM location:%s %s " , bank, device); -else - p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , - mem_err->mem_dev_handle); + + index =ghes_edac_dimm_index (mem_err->mem_dev_handle); +if (index >=0 ) { + e->top_layer = index; + e->enable_per_layer_report = true; + } + }if (p > e->location) *(p -1 ) ='\0' ;include/linux/edac.h +2
-0@@ -451,6 +451,8 @@ struct dimm_info {u32 nr_pages;/* number of pages on this dimm */ unsigned csrow, cschannel;/* Points to the old API data */ + +u16 smbios_handle;/* Handle for SMBIOS type 17 */ };/**
Hi Boris,
Quoted 10 lines · Borislav Petkov
Quoted 8 lines · Fan Wu
The current
ghes_edacdriver does not update per-dimm error counters when reporting memory errors, because there is no platform-independent way to find DIMMs based on the error information provided by firmware. This patch offers a solution for platforms whose firmwares provide valid module handles (SMBIOS type 17) in error records. In this caseghes_edacwill use the module handles to locate DIMMs and thus makes per-dimm error reporting possible.
Quoted 2 lines
If we're going to do this, it needs to be tested on an x86 box which loads
ghes_edac. Adding Toshi to Cc.
Good point, thanks.
Quoted 1 line
Otherwise it must remain ARM-specific.
Hmmm, that would be a shame.
This should only be a problem if HPE Servers set CPER_MEM_VALID_MODULE_HANDLE, but don't actually provide module handles, or if firmware has a different idea of what they are.
If firmware never sets CPER_MEM_VALID_MODULE_HANDLE, this patch shouldn't change anything.
(Someone must have an x86 that sets CPER_MEM_VALID_MODULE_HANDLE, otherwise the code wouldn't be there right?!)
Thanks,
James
Hi James,
Quoted 8 lines
Quoted 3 lines
For
ghes_edacthe bank/device is informational, and nothing would go wrong if the bank/device numbers are the same as another entry. But the handle is now critical for DIMM lookup, thus pull it out.Is printing the handle to the kernel log critical?
I'd expect something collecting errors to read from sysfs, not dmesg. I thought the whole point here was to update the per-dimm counters in sysfs.
No, printing out the handle is not critical. What I meant is because the information is critical it would be nice to have it available for debugging purpose. Otherwise it would be hard to find the handle if bank/device is not accurate.
Thanks,
Fan
Quoted 26 lines · James Morse
Hi Fan,
Quoted 23 lines · wufan
Quoted 22 lines
Review void ghes_edac_report_mem_error(int sev,
Quoted 1 line
(quoted diff) +0
-0@@ -327,12 +349,20 @@ void ghes_edac_report_mem_error(int sev,struct
cper_sec_mem_err*mem_err)Review void ghes_edac_report_mem_error(int sev, · line 350
Quoted 2 lines
(quoted diff) +0
-0p += sprintf(p, "bit_pos:%d ", mem_err->bit_pos); if (mem_err->validation_bits &
CPER_MEM_VALID_MODULE_HANDLE) {drivers/edac/ghes_edac.c void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
Quoted 4 lines
drivers/edac/ghes_edac.c +2
-0const char *bank =NULL , *device =NULL ; +int index =-1 ; + dmi_memdev_name(mem_err->mem_dev_handle, &bank,&device);
drivers/edac/ghes_edac.c void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) · line 335
Quoted 7 lines
drivers/edac/ghes_edac.c +2
-3+ p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , + mem_err->mem_dev_handle);if (bank !=NULL && device !=NULL ) p +=sprintf (p,"DIMM location:%s %s " , bank, device); -else - p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , - mem_err->mem_dev_handle);Why do we now print the handle every time? The handle is pretty meaningless, it can only be used to find the location-strings, if we get those we print them instead.
Quoted 6 lines
Quoted 3 lines
For
ghes_edacthe bank/device is informational, and nothing would go wrong if the bank/device numbers are the same as another entry. But the handle is now critical for DIMM lookup, thus pull it out.Is printing the handle to the kernel log critical?
I don't see why we would need this print. The bank/device print is enough to map what is shown in dmesg to an SMBIOS entry if that's really needed.
Thanks,
Tyler
On 30/08/2018 17:34, James Morse wrote:
Hi James,
Zhengqiang no longer works on this topic, so I have cc'ed some more guys who should be able to help.
John
Quoted 105 lines
Hi Zhengqiang,
Quoted 8 lines · Fan Wu
The current
ghes_edacdriver does not update per-dimm error counters when reporting memory errors, because there is no platform-independent way to find DIMMs based on the error information provided by firmware. This patch offers a solution for platforms whose firmwares provide valid module handles (SMBIOS type 17) in error records. In this caseghes_edacwill use the module handles to locate DIMMs and thus makes per-dimm error reporting possible.Does your platform set
CPER_MEM_VALID_MODULE_HANDLEin GHES Memory errors? If so, any chance you could test this patch on your platform? [0] (original patch: https://lore.kernel.org/patchwork/patch/978928/)Thanks,
James
[0] https://marc.info/?l=linux-edac&m=152603960002324
Quoted 70 lines
drivers/edac/ghes_edac.c +33
-3@@ -81,6 +81,26 @@ static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) (*num_dimm)++; } +static int ghes_edac_dimm_index (u16 handle) +{ +struct mem_ctl_info *mci; +int i; + +if (!ghes_pvt) +return -1 ; + + mci = ghes_pvt->mci; + +if (!mci) +return -1 ; + +for (i =0 ; i < mci->tot_dimms; i++) { +if (mci->dimms[i]->smbios_handle == handle) +return i; + } +return -1 ; +} +static void ghes_edac_dmidecode (const struct dmi_header *dh,void *arg) {struct ghes_edac_dimm_fill *dimm_fill = arg;@@ -177,6 +197,8 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) entry->total_width, entry->data_width); } + dimm->smbios_handle = entry->handle; + dimm_fill->count++; } }@@ -327,12 +349,20 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) p +=sprintf (p,"bit_pos:%d " , mem_err->bit_pos);if (mem_err->validation_bits &CPER_MEM_VALID_MODULE_HANDLE ) {const char *bank =NULL , *device =NULL ; +int index =-1 ; +dmi_memdev_name (mem_err->mem_dev_handle, &bank, &device); + p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , + mem_err->mem_dev_handle);if (bank !=NULL && device !=NULL ) p +=sprintf (p,"DIMM location:%s %s " , bank, device); -else - p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , - mem_err->mem_dev_handle); + + index =ghes_edac_dimm_index (mem_err->mem_dev_handle); +if (index >=0 ) { + e->top_layer = index; + e->enable_per_layer_report = true; + } + }if (p > e->location) *(p -1 ) ='\0' ;include/linux/edac.h +0
-0include/linux/edac.h struct dimm_info { · line 458
Quoted 8 lines
include/linux/edac.h +2
-0@@ -451,6 +451,8 @@ struct dimm_info {u32 nr_pages;/* number of pages on this dimm */ unsigned csrow, cschannel;/* Points to the old API data */ + +u16 smbios_handle;/* Handle for SMBIOS type 17 */ };/** .
Hi Tyler,
Quoted 5 lines
Quoted 2 lines
Is printing the handle to the kernel log critical?
I don't see why we would need this print. The bank/device print is enough to map what is shown in dmesg to an SMBIOS entry if that's really needed.
This change is mostly for convenience. I'll revert it since we have two votes against it now.
Thanks,
Fan
Quoted 24 lines · John Garry
On 30/08/2018 17:34, James Morse wrote:
Hi James,
Zhengqiang no longer works on this topic, so I have cc'ed some more guys who should be able to help.
John
Quoted 16 lines
Hi Zhengqiang,
Quoted 8 lines · Fan Wu
The current
ghes_edacdriver does not update per-dimm error counters when reporting memory errors, because there is no platform-independent way to find DIMMs based on the error information provided by firmware. This patch offers a solution for platforms whose firmwares provide valid module handles (SMBIOS type 17) in error records. In this caseghes_edacwill use the module handles to locate DIMMs and thus makes per-dimm error reporting possible.Does your platform set
CPER_MEM_VALID_MODULE_HANDLEin GHES Memory errors? If so, any chance you could test this patch on your platform? [0] (original patch: https://lore.kernel.org/patchwork/patch/978928/)
Hi James,
Our platform do not set CPER_MEM_VALID_MODULE_HANDLE in GHES Memory errors.
Thanks,
tanxiaofei
Quoted 94 lines
Quoted 83 lines
Thanks,
James
[0] https://marc.info/?l=linux-edac&m=152603960002324
Quoted 76 lines
drivers/edac/ghes_edac.c +33
-3@@ -81,6 +81,26 @@ static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) (*num_dimm)++; } +static int ghes_edac_dimm_index (u16 handle) +{ +struct mem_ctl_info *mci; +int i; + +if (!ghes_pvt) +return -1 ; + + mci = ghes_pvt->mci; + +if (!mci) +return -1 ; + +for (i =0 ; i < mci->tot_dimms; i++) { +if (mci->dimms[i]->smbios_handle == handle) +return i; + } +return -1 ; +} +static void ghes_edac_dmidecode (const struct dmi_header *dh,void *arg) {struct ghes_edac_dimm_fill *dimm_fill = arg;@@ -177,6 +197,8 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) entry->total_width, entry->data_width); } + dimm->smbios_handle = entry->handle; + dimm_fill->count++; } }@@ -327,12 +349,20 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) p +=sprintf (p,"bit_pos:%d " , mem_err->bit_pos);if (mem_err->validation_bits &CPER_MEM_VALID_MODULE_HANDLE ) {const char *bank =NULL , *device =NULL ; +int index =-1 ; +dmi_memdev_name (mem_err->mem_dev_handle, &bank, &device); + p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , + mem_err->mem_dev_handle);if (bank !=NULL && device !=NULL ) p +=sprintf (p,"DIMM location:%s %s " , bank, device); -else - p +=sprintf (p,"DIMM DMI handle: 0x%.4x " , - mem_err->mem_dev_handle); + + index =ghes_edac_dimm_index (mem_err->mem_dev_handle); +if (index >=0 ) { + e->top_layer = index; + e->enable_per_layer_report = true; + } + }if (p > e->location) *(p -1 ) ='\0' ;include/linux/edac.h +2
-0@@ -451,6 +451,8 @@ struct dimm_info {u32 nr_pages;/* number of pages on this dimm */ unsigned csrow, cschannel;/* Points to the old API data */ + +u16 smbios_handle;/* Handle for SMBIOS type 17 */ };Quoted 6 lines
include/linux/edac.h struct dimm_info { · line 458
Quoted 2 lines
include/linux/edac.h +0
-0/** .
.
Signature · 2 lines
best wishes ???
Thanks tanxiaofei!
Boris/James, are you OK to sign off, or you want to see more tests on this patch?
Thanks,
Fan
Quoted 11 lines
-----Original Message-----
From: tanxiaofei <[email protected]>
Sent: Friday, August 31, 2018 4:06 AMHi James,
Our platform do not set
CPER_MEM_VALID_MODULE_HANDLEin GHES Memory errors.Thanks,
tanxiaofei
Borislav Petkov
maintainerQuoted 4 lines · wufan
Thanks tanxiaofei!
Boris/James, are you OK to sign off, or you want to see more tests on this patch?
Please do not top-post.
Now, I don't have any problems with it - I'm still sceptical as the firmware is a stinking pile but if we cannot find a broken case, I guess we can take this one for a spin and revert it if there's trouble down the road.
Unless James has objections.
Then, you sent a v2 here:
https://lkml.kernel.org/r/[email protected]
and you've received a bunch of Reviewed-by's and Tested-by's and a couple of new comments.
Incorporate *all* of those and send me a v3.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.