Skip to contentSkip to conversation

edac,ghes,cper: Add device to Memory Error Record

PATCH In review Shuai Xue 2 participants 3 messages Nov 30, 2021 – Dec 2, 2021

Subsystems (2)
lore
Share & tools
lore

Shuai Xue

author
#0 lore raw

PATCH 1/1 edac,ghes,cper: Add device to Memory Error Record

If Bit 7 of Validation Bits is valid, the device number of the memory associated with errors should be reported to Memory Error Record.

---
 drivers/edac/ghes_edac.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/edac/ghes_edac.c +2 -0
index a918ca93e4f7..cf98b270d6f7 100644
@@ -378,6 +378,8 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
 	if (mem_err->validation_bits & CPER_MEM_VALID_BANK_ADDRESS)
 		p += sprintf(p, "bank_address:%d ",
 			     mem_err->bank & CPER_MEM_BANK_ADDRESS_MASK);
+	if (mem_err->validation_bits & CPER_MEM_VALID_DEVICE)
+		p += sprintf(p, "device:%d ", mem_err->device);
 	if (mem_err->validation_bits & (CPER_MEM_VALID_ROW | CPER_MEM_VALID_ROW_EXT)) {
 		u32 row = mem_err->row;
 
Signature · 1 line
2.20.1.12.g72788fdb
maintainer
#1 lore raw
Quoted 13 lines · Shuai Xue

If Bit 7 of Validation Bits is valid, the device number of the memory associated with errors should be reported to Memory Error Record.

---
 drivers/edac/ghes_edac.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/edac/ghes_edac.c +0 -0
index a918ca93e4f7..cf98b270d6f7 100644

drivers/edac/ghes_edac.c void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) · line 385

Quoted 8 lines
drivers/edac/ghes_edac.c +2 -0
@@ -378,6 +378,8 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
 	if (mem_err->validation_bits & CPER_MEM_VALID_BANK_ADDRESS)
 		p += sprintf(p, "bank_address:%d ",
 			     mem_err->bank & CPER_MEM_BANK_ADDRESS_MASK);
+	if (mem_err->validation_bits & CPER_MEM_VALID_DEVICE)
+		p += sprintf(p, "device:%d ", mem_err->device);
 	if (mem_err->validation_bits & (CPER_MEM_VALID_ROW | CPER_MEM_VALID_ROW_EXT)) {
 		u32 row = mem_err->row;
 

This looks OK (same as code in drivers/firmware/efi/cper.c in the cper_mem_err_location() function. But that makes me wonder why there is near duplication of code in ghes_edac.c?

The cper.c code seems to be written defensively using scnprintf() instead of sprintf(). Could ghes_edac share the same code?

-Tony

author
#2 lore raw

Hi, Tony,

Quoted 3 lines

This looks OK (same as code in drivers/firmware/efi/cper.c in the cper_mem_err_location() function. But that makes me wonder why there is near duplication of code in ghes_edac.c?

May it is a legacy issue.

Quoted 2 lines

The cper.c code seems to be written defensively using scnprintf() instead of sprintf(). Could ghes_edac share the same code?

I think so, ghes_edac_report_mem_error in ghes_edac.c is Long Method and have Duplicated Code with cper_mem_err_location, cper_dimm_err_location, and cper_mem_err_type_str in drivers/firmware/efi/cper.c.

I will send a new patch to rework ghes_edac_report_mem_error.

Cheers
Shuai

Quoted 32 lines · Tony
Quoted 13 lines · Shuai Xue

If Bit 7 of Validation Bits is valid, the device number of the memory associated with errors should be reported to Memory Error Record.

---
 drivers/edac/ghes_edac.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/edac/ghes_edac.c +0 -0
index a918ca93e4f7..cf98b270d6f7 100644

drivers/edac/ghes_edac.c void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) · line 385

Quoted 8 lines
drivers/edac/ghes_edac.c +2 -0
@@ -378,6 +378,8 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
 	if (mem_err->validation_bits & CPER_MEM_VALID_BANK_ADDRESS)
 		p += sprintf(p, "bank_address:%d ",
 			     mem_err->bank & CPER_MEM_BANK_ADDRESS_MASK);
+	if (mem_err->validation_bits & CPER_MEM_VALID_DEVICE)
+		p += sprintf(p, "device:%d ", mem_err->device);
 	if (mem_err->validation_bits & (CPER_MEM_VALID_ROW | CPER_MEM_VALID_ROW_EXT)) {
 		u32 row = mem_err->row;
 

This looks OK (same as code in drivers/firmware/efi/cper.c in the cper_mem_err_location() function. But that makes me wonder why there is near duplication of code in ghes_edac.c?

The cper.c code seems to be written defensively using scnprintf() instead of sprintf(). Could ghes_edac share the same code?

-Tony