Add a driver to report Firmware first errors (via GHES)
Subsystems (5)
cover Add a driver to report Firmware first errors (via GHES)
There are currently 3 error mechanisms inside the Linux Kernel:
edac, mcelog and ghes.
Unfortunately, not all those error mechanisms will work at the same time, as accessing the error registers by the BIOS may interfere on reading them from OS.
So, all those 3 mechanisms need to be integrated, in order to avoid such problems.
This patch series adds a new EDAC driver that uses "Firmware first" APEI/GHES as an error report mechanism. It automatically disables the hardware-driven EDAC drivers when GHES is enabled, preventing to have both OS and BIOS to read at the very same error mechanisms.
It was tested on a "Lizard Head Pass" Intel machine, equipped with BIOS SE5C600.86B.99.99.x059.091020121352 (09/10/2012).
Test results:
The driver is properly binding into the EDAC core. This BIOS announces and sets "Firmware first" mode:
[ 4.537704] ghes_edac: This EDAC driver relies on BIOS to enumerate memory and get error reports. [ 4.547644] ghes_edac: Unfortunately, not all BIOSes reflect the memory layout correctly. [ 4.556807] ghes_edac: So, the end result of using this driver varies from vendor to vendor. [ 4.566260] ghes_edac: If you find incorrect reports, please ask your vendor to fix its BIOS. [ 4.575811] ghes_edac: This system has 48 DIMM sockets. [ 4.581687] EDAC DEBUG: ghes_edac_dmidecode: DIMM0: DDR3 size = 8192 MB(ECC) [ 4.581691] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.581695] EDAC DEBUG: ghes_edac_dmidecode: DIMM3: DDR3 size = 8192 MB(ECC) [ 4.581698] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.581702] EDAC DEBUG: ghes_edac_dmidecode: DIMM6: DDR3 size = 8192 MB(ECC) [ 4.581705] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.581708] EDAC DEBUG: ghes_edac_dmidecode: DIMM9: DDR3 size = 8192 MB(ECC) [ 4.581711] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.581715] EDAC DEBUG: ghes_edac_dmidecode: DIMM12: DDR3 size = 8192 MB(ECC) [ 4.581718] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.581722] EDAC DEBUG: ghes_edac_dmidecode: DIMM15: DDR3 size = 8192 MB(ECC) [ 4.581724] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.581728] EDAC DEBUG: ghes_edac_dmidecode: DIMM18: DDR3 size = 8192 MB(ECC) [ 4.581730] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.581734] EDAC DEBUG: ghes_edac_dmidecode: DIMM21: DDR3 size = 8192 MB(ECC) [ 4.581737] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.581741] EDAC DEBUG: ghes_edac_dmidecode: DIMM24: DDR3 size = 8192 MB(ECC) [ 4.581752] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.581756] EDAC DEBUG: ghes_edac_dmidecode: DIMM27: DDR3 size = 8192 MB(ECC) [ 4.581759] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.581763] EDAC DEBUG: ghes_edac_dmidecode: DIMM30: DDR3 size = 8192 MB(ECC) [ 4.581766] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.581769] EDAC DEBUG: ghes_edac_dmidecode: DIMM33: DDR3 size = 8192 MB(ECC) [ 4.581772] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.581776] EDAC DEBUG: ghes_edac_dmidecode: DIMM36: DDR3 size = 8192 MB(ECC) [ 4.581778] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.581782] EDAC DEBUG: ghes_edac_dmidecode: DIMM39: DDR3 size = 8192 MB(ECC) [ 4.581784] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.581788] EDAC DEBUG: ghes_edac_dmidecode: DIMM42: DDR3 size = 8192 MB(ECC) [ 4.581791] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.581795] EDAC DEBUG: ghes_edac_dmidecode: DIMM45: DDR3 size = 8192 MB(ECC) [ 4.581797] EDAC DEBUG: ghes_edac_dmidecode: type 24, detail 0x80, width 72(total 64) [ 4.582724] EDAC MC0: Giving out device to 'ghes_edac.c' 'ghes_edac': DEV ghes [ 4.591145] EDAC MC1: Giving out device to 'ghes_edac.c' 'ghes_edac': DEV ghes [ 4.599524] GHES: APEI firmware first mode is enabled by APEI bit and WHEA _OSC.
However, with this BIOS, the "Firmware first" is not working. The errors are only seen via MCELOG error mechanism:
# mcelog Hardware event. This is not a software error. MCE 0 CPU 0 BANK 5 MISC 20404c4c86 ADDR 320000 TIME 1360931174 Fri Feb 15 07:26:14 2013 MCG status: MCi status: Corrected error MCi_MISC register valid MCi_ADDR register valid MCA: MEMORY CONTROLLER RD_CHANNEL0_ERR Transaction: Memory read error STATUS 8c00004000010090 MCGSTATUS 0 MCGCAP 1000c14 APICID 0 SOCKETID 0 CPUID Vendor Intel Family 6 Model 45 Hardware event. This is not a software error.
So, I was unable to test the GHES->EDAC error report method.
Mauro Carvalho Chehab (13):
edac: lock module owner to avoid error report conflicts
ghes: move structures/enum to a header file
ghes: add the needed hooks for EDAC error report
edac: add a new memory layer type
ghes_edac: Register at EDAC core the BIOS report
ghes_edac: Allow registering more than once
edac: add support for raw error reports
ghes_edac: add support for reporting errors via EDAC
ghes_edac: do a better job of filling EDAC DIMM info
edac: better report error conditions in debug mode
edac: initialize the core earlier
ghes_edac.c: Don't credit the same memory dimm twice
ghes_edac: Improve driver's printk messages
drivers/acpi/apei/ghes.c | 64 +++------ drivers/edac/Kconfig | 23 ++++ drivers/edac/Makefile | 1 + drivers/edac/edac_core.h | 17 +++ drivers/edac/edac_mc.c | 136 ++++++++++++++----- drivers/edac/edac_mc_sysfs.c | 7 +- drivers/edac/edac_module.c | 2 +- drivers/edac/ghes_edac.c | 313 +++++++++++++++++++++++++++++++++++++++++++ include/acpi/ghes.h | 72 ++++++++++ include/linux/edac.h | 5 + 10 files changed, 560 insertions(+), 80 deletions(-) create mode 100644 drivers/edac/ghes_edac.c create mode 100644 include/acpi/ghes.h
Signature · 1 line
1.8.1.2
PATCH 1/13 edac: lock module owner to avoid error report conflicts
APEI GHES and i7core_edac/sb_edac currently can be loaded at the same time, but those are Highlander modules:
"There can be only one".
There are two reasons for that:
1) Each driver assumes that it is the only one registering at the EDAC core, as it is driver's responsibility to number the memory controllers, and all of them start from 0;
2) If BIOS is handling the memory errors, the OS can't also be doing it, as one will mangle with the other.
So, we need to add an module owner's lock at the EDAC core, in order to avoid having two different modules handling memory errors at the same time. The best way for doing this lock seems to use the driver's name, as this is unique, and won't require changes on every driver.
--- drivers/edac/edac_mc.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
drivers/edac/edac_mc.c +22 -4
@@ -42,6 +42,12 @@static DEFINE_MUTEX (mem_ctls_mutex);static LIST_HEAD (mc_devices); +/* +* Used to lock EDAC MC to just one module, avoiding two drivers e. g. +* apei/ghes and i7core_edac to be used at the same time. +*/ +static void const *edac_mc_owner; +unsigned edac_dimm_info_location (struct dimm_info *dimm,char *buf,unsigned len) {
@@ -659,9 +665,9 @@ fail1:return 1 ; } -static void del_mc_from_global_list (struct mem_ctl_info *mci) +static int del_mc_from_global_list (struct mem_ctl_info *mci) { -atomic_dec (&edac_handlers); +int handlers =atomic_dec_return (&edac_handlers);list_del_rcu (&mci->link);/* these are for safe removal of devices from global list while
@@ -669,6 +675,8 @@ static void del_mc_from_global_list(struct mem_ctl_info *mci)*/ synchronize_rcu ();INIT_LIST_HEAD (&mci->link); + +return handlers; }/**
@@ -712,6 +720,7 @@ EXPORT_SYMBOL(edac_mc_find);/* FIXME - should a warning be printed if no error detection? correction? */ int edac_mc_add_mc (struct mem_ctl_info *mci) { +int ret = -EINVAL ;edac_dbg (0 ,"\n" );#ifdef CONFIG_EDAC_DEBUG
@@ -742,6 +751,11 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)#endif mutex_lock (&mem_ctls_mutex); +if (edac_mc_owner && edac_mc_owner != mci->mod_name) { + ret = -EPERM ; + goto fail0; + } +if (add_mc_to_global_list (mci)) goto fail0;
@@ -768,6 +782,8 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)edac_mc_printk (mci,KERN_INFO ,"Giving out device to '%s' '%s':" " DEV %s\n" , mci->mod_name, mci->ctl_name,edac_dev_name (mci)); + edac_mc_owner = mci->mod_name; +mutex_unlock (&mem_ctls_mutex);return 0 ;
@@ -776,7 +792,7 @@ fail1: fail0:mutex_unlock (&mem_ctls_mutex); -return 1 ; +return ret; }EXPORT_SYMBOL_GPL (edac_mc_add_mc);
@@ -802,7 +818,9 @@ struct mem_ctl_info *edac_mc_del_mc(struct device *dev)return NULL ; } -del_mc_from_global_list (mci); +if (!del_mc_from_global_list (mci)) { + edac_mc_owner =NULL ; + }mutex_unlock (&mem_ctls_mutex);/* flush workq processes */
Signature · 1 line
1.8.1.2
PATCH 2/13 ghes: move structures/enum to a header file
In reply to Mauro Carvalho ChehabAs a ghes_edac driver will need to access ghes structures, in order to properly handle the errors, move those structures to a separate header file. No functional changes.
--- drivers/acpi/apei/ghes.c | 47 ++--------------------------------------------- include/acpi/ghes.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 45 deletions(-) create mode 100644 include/acpi/ghes.h
drivers/acpi/apei/ghes.c +2 -45
@@ -48,8 +48,8 @@#include <linux/genalloc.h> #include <linux/pci.h> #include <linux/aer.h> -#include <acpi/apei.h> -#include <acpi/hed.h> + +#include <acpi/ghes.h> #include <asm/mce.h> #include <asm/tlbflush.h> #include <asm/nmi.h>
@@ -84,42 +84,6 @@ ((struct acpi_hest_generic_status *) \ ((struct ghes_estatus_node *)(estatus_node) + 1)) -/* -* One struct ghes is created for each generic hardware error source. -* It provides the context for APEI hardware error timer/IRQ/SCI/NMI -* handler. -* -* estatus: memory buffer for error status block, allocated during -* HEST parsing. - */ -#define GHES_TO_CLEAR 0x0001 -#define GHES_EXITING 0x0002 - -struct ghes { -struct acpi_hest_generic *generic; -struct acpi_hest_generic_status *estatus; -u64 buffer_paddr; -unsigned long flags; -union { -struct list_head list; -struct timer_list timer; -unsigned int irq; - }; -}; - -struct ghes_estatus_node { -struct llist_node llnode; -struct acpi_hest_generic *generic; -}; - -struct ghes_estatus_cache { -u32 estatus_len; -atomic_t count; -struct acpi_hest_generic *generic; -unsigned long long time_in; -struct rcu_head rcu; -}; -bool ghes_disable;module_param_named (disable, ghes_disable, bool,0 );
@@ -333,13 +297,6 @@ static void ghes_fini(struct ghes *ghes)apei_unmap_generic_address (&ghes->generic->error_status_address); } -enum { -GHES_SEV_NO =0x0 , -GHES_SEV_CORRECTED =0x1 , -GHES_SEV_RECOVERABLE =0x2 , -GHES_SEV_PANIC =0x3 , -}; -static inline int ghes_severity (int severity) {switch (severity) {
include/acpi/ghes.h new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
1.8.1.2
PATCH 3/13 ghes: add the needed hooks for EDAC error report
In reply to Mauro Carvalho ChehabIn order to allow reporting errors via EDAC, add hooks for:
1) register an EDAC driver;
2) unregister an EDAC driver;
3) report errors via EDAC.
As the EDAC driver will need to access the ghes structure, adds it as one of the parameters for ghes_do_proc.
--- drivers/acpi/apei/ghes.c | 17 ++++++++++++++--- include/acpi/ghes.h | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-)
drivers/acpi/apei/ghes.c +14 -3
@@ -409,7 +409,8 @@ static void ghes_clear_estatus(struct ghes *ghes) ghes->flags &= ~GHES_TO_CLEAR ; } -static void ghes_do_proc (const struct acpi_hest_generic_status *estatus) +static void ghes_do_proc (struct ghes *ghes, +const struct acpi_hest_generic_status *estatus) {int sev, sec_sev;struct acpi_hest_generic_data *gdata;
@@ -421,6 +422,8 @@ static void ghes_do_proc(const struct acpi_hest_generic_status *estatus) CPER_SEC_PLATFORM_MEM)) {struct cper_sec_mem_err *mem_err; mem_err = (struct cper_sec_mem_err *)(gdata+1 ); +ghes_edac_report_mem_error (ghes, sev, mem_err); +#ifdef CONFIG_X86_MCE apei_mce_report_mem_error (sev ==GHES_SEV_CORRECTED , mem_err);
@@ -639,7 +642,7 @@ static int ghes_proc(struct ghes *ghes)if (ghes_print_estatus (NULL , ghes->generic, ghes->estatus))ghes_estatus_cache_add (ghes->generic, ghes->estatus); } -ghes_do_proc (ghes->estatus); +ghes_do_proc (ghes, ghes->estatus); out:ghes_clear_estatus (ghes);return 0 ;
@@ -732,7 +735,7 @@ static void ghes_proc_in_irq(struct irq_work *irq_work) estatus =GHES_ESTATUS_FROM_NODE (estatus_node); len =apei_estatus_len (estatus); node_len =GHES_ESTATUS_NODE_LEN (len); -ghes_do_proc (estatus); +ghes_do_proc (estatus_node->ghes, estatus);if (!ghes_estatus_cached (estatus)) { generic = estatus_node->generic;if (ghes_print_estatus (NULL , generic, estatus))
@@ -821,6 +824,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) estatus_node = (void *)gen_pool_alloc (ghes_estatus_pool, node_len);if (estatus_node) { + estatus_node->ghes = ghes; estatus_node->generic = ghes->generic; estatus =GHES_ESTATUS_FROM_NODE (estatus_node);memcpy (estatus, ghes->estatus, len);
@@ -942,6 +946,10 @@ static int ghes_probe(struct platform_device *ghes_dev) }platform_set_drvdata (ghes_dev, ghes); + rc =ghes_edac_register (ghes, &ghes_dev->dev); +if (rc <0 ) + goto err; +return 0 ; err:if (ghes) {
@@ -995,6 +1003,9 @@ static int ghes_remove(struct platform_device *ghes_dev) }ghes_fini (ghes); + +ghes_edac_unregister (ghes); +kfree (ghes);platform_set_drvdata (ghes_dev,NULL );
include/acpi/ghes.h +27 -0
@@ -22,11 +22,14 @@ struct ghes {struct timer_list timer;unsigned int irq; }; + +struct mem_ctl_info *mci; };struct ghes_estatus_node {struct llist_node llnode;struct acpi_hest_generic *generic; +struct ghes *ghes; };struct ghes_estatus_cache {
@@ -43,3 +46,27 @@ enum {GHES_SEV_RECOVERABLE =0x2 , GHES_SEV_PANIC = 0x3, }; + +#ifdef CONFIG_EDAC_GHES +void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err); + +int ghes_edac_register (struct ghes *ghes,struct device *dev); + +void ghes_edac_unregister (struct ghes *ghes); + +#else +static inline void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err) +{ +} + +static inline int ghes_edac_register (struct ghes *ghes,struct device *dev) +{ +return 0 ; +} + +static inline void ghes_edac_unregister (struct ghes *ghes) +{ +} +#endif
Signature · 1 line
1.8.1.2
Re: [PATCH EDAC 03/13] ghes: add the needed hooks for EDAC error report
Sorry for late!
Quoted 65 lines · Mauro Carvalho Chehab
In order to allow reporting errors via EDAC, add hooks for:
1) register an EDAC driver;
2) unregister an EDAC driver;
3) report errors via EDAC.As the EDAC driver will need to access the ghes structure, adds it as one of the parameters for
ghes_do_proc.Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/acpi/apei/ghes.c | 17 ++++++++++++++--- include/acpi/ghes.h | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-)drivers/acpi/apei/ghes.c +7
-3@@ -409,7 +409,8 @@ static void ghes_clear_estatus(struct ghes *ghes) ghes->flags &= ~GHES_TO_CLEAR ; } -static void ghes_do_proc (const struct acpi_hest_generic_status *estatus) +static void ghes_do_proc (struct ghes *ghes, +const struct acpi_hest_generic_status *estatus) {int sev, sec_sev;struct acpi_hest_generic_data *gdata;@@ -421,6 +422,8 @@ static void ghes_do_proc(const struct acpi_hest_generic_status *estatus) CPER_SEC_PLATFORM_MEM)) {struct cper_sec_mem_err *mem_err; mem_err = (struct cper_sec_mem_err *)(gdata+1 ); +ghes_edac_report_mem_error (ghes, sev, mem_err); +#ifdef CONFIG_X86_MCE apei_mce_report_mem_error (sev ==GHES_SEV_CORRECTED , mem_err);@@ -639,7 +642,7 @@ static int ghes_proc(struct ghes *ghes)if (ghes_print_estatus (NULL , ghes->generic, ghes->estatus))ghes_estatus_cache_add (ghes->generic, ghes->estatus); } -ghes_do_proc (ghes->estatus); +ghes_do_proc (ghes, ghes->estatus); out:ghes_clear_estatus (ghes);return 0 ;@@ -732,7 +735,7 @@ static void ghes_proc_in_irq(struct irq_work *irq_work) estatus =GHES_ESTATUS_FROM_NODE (estatus_node); len =apei_estatus_len (estatus); node_len =GHES_ESTATUS_NODE_LEN (len); -ghes_do_proc (estatus); +ghes_do_proc (estatus_node->ghes, estatus);if (!ghes_estatus_cached (estatus)) { generic = estatus_node->generic;if (ghes_print_estatus (NULL , generic, estatus))@@ -821,6 +824,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) estatus_node = (void *)gen_pool_alloc (ghes_estatus_pool, node_len);if (estatus_node) { + estatus_node->ghes = ghes; estatus_node->generic = ghes->generic; estatus =GHES_ESTATUS_FROM_NODE (estatus_node);memcpy (estatus, ghes->estatus, len);
drivers/acpi/apei/ghes.c static int ghes_probe(struct platform_device *ghes_dev) · line 952
Quoted 7 lines
drivers/acpi/apei/ghes.c +4
-0@@ -942,6 +946,10 @@ static int ghes_probe(struct platform_device *ghes_dev) }platform_set_drvdata (ghes_dev, ghes); + rc =ghes_edac_register (ghes, &ghes_dev->dev); +if (rc <0 ) + goto err; +
If ghes_edac_register() failed, we need to do some cleanup such as unregister from hed etc.
Or just move ghes_edac_register() before switch?
Quoted 18 lines
drivers/acpi/apei/ghes.c +3
-0return 0 ; err:if (ghes) {@@ -995,6 +1003,9 @@ static int ghes_remove(struct platform_device *ghes_dev) }ghes_fini (ghes); + +ghes_edac_unregister (ghes); +kfree (ghes);platform_set_drvdata (ghes_dev,NULL );include/acpi/ghes.h +0
-0
include/acpi/ghes.h struct ghes { · line 26
Quoted 5 lines
include/acpi/ghes.h +2
-0@@ -22,11 +22,14 @@ struct ghes {struct timer_list timer;unsigned int irq; }; + +struct mem_ctl_info *mci;
Why we need this? This is not used by ghes.[hc].
Quoted 27 lines
include/acpi/ghes.h +15
-0};struct ghes_estatus_node {struct llist_node llnode;struct acpi_hest_generic *generic; +struct ghes *ghes; };struct ghes_estatus_cache {@@ -43,3 +46,27 @@ enum {GHES_SEV_RECOVERABLE =0x2 , GHES_SEV_PANIC = 0x3, }; + +#ifdef CONFIG_EDAC_GHES +void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err); + +int ghes_edac_register (struct ghes *ghes,struct device *dev); + +void ghes_edac_unregister (struct ghes *ghes); + +#else +static inline void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err) +{ +}
include/acpi/ghes.h enum { · line 72
Quoted 10 lines
include/acpi/ghes.h +10
-0+ +static inline int ghes_edac_register (struct ghes *ghes,struct device *dev) +{ +return 0 ; +} + +static inline void ghes_edac_unregister (struct ghes *ghes) +{ +} +#endif
I think it is better to put the above declaration into module which implement these functions instead of use these functions.
Best Regards,
Huang Ying
Re: [PATCH EDAC 03/13] ghes: add the needed hooks for EDAC error report
Em Thu, 21 Feb 2013 09:26:07 +0800
Huang Ying <[email protected]> escreveu:
Quoted 1 line
Sorry for late!
Thanks for your comments. See my answers below.
Quoted 78 lines · Mauro Carvalho Chehab
Quoted 65 lines
In order to allow reporting errors via EDAC, add hooks for:
1) register an EDAC driver;
2) unregister an EDAC driver;
3) report errors via EDAC.As the EDAC driver will need to access the ghes structure, adds it as one of the parameters for
ghes_do_proc.Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/acpi/apei/ghes.c | 17 ++++++++++++++--- include/acpi/ghes.h | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-)drivers/acpi/apei/ghes.c +7
-3@@ -409,7 +409,8 @@ static void ghes_clear_estatus(struct ghes *ghes) ghes->flags &= ~GHES_TO_CLEAR ; } -static void ghes_do_proc (const struct acpi_hest_generic_status *estatus) +static void ghes_do_proc (struct ghes *ghes, +const struct acpi_hest_generic_status *estatus) {int sev, sec_sev;struct acpi_hest_generic_data *gdata;@@ -421,6 +422,8 @@ static void ghes_do_proc(const struct acpi_hest_generic_status *estatus) CPER_SEC_PLATFORM_MEM)) {struct cper_sec_mem_err *mem_err; mem_err = (struct cper_sec_mem_err *)(gdata+1 ); +ghes_edac_report_mem_error (ghes, sev, mem_err); +#ifdef CONFIG_X86_MCE apei_mce_report_mem_error (sev ==GHES_SEV_CORRECTED , mem_err);@@ -639,7 +642,7 @@ static int ghes_proc(struct ghes *ghes)if (ghes_print_estatus (NULL , ghes->generic, ghes->estatus))ghes_estatus_cache_add (ghes->generic, ghes->estatus); } -ghes_do_proc (ghes->estatus); +ghes_do_proc (ghes, ghes->estatus); out:ghes_clear_estatus (ghes);return 0 ;@@ -732,7 +735,7 @@ static void ghes_proc_in_irq(struct irq_work *irq_work) estatus =GHES_ESTATUS_FROM_NODE (estatus_node); len =apei_estatus_len (estatus); node_len =GHES_ESTATUS_NODE_LEN (len); -ghes_do_proc (estatus); +ghes_do_proc (estatus_node->ghes, estatus);if (!ghes_estatus_cached (estatus)) { generic = estatus_node->generic;if (ghes_print_estatus (NULL , generic, estatus))@@ -821,6 +824,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) estatus_node = (void *)gen_pool_alloc (ghes_estatus_pool, node_len);if (estatus_node) { + estatus_node->ghes = ghes; estatus_node->generic = ghes->generic; estatus =GHES_ESTATUS_FROM_NODE (estatus_node);memcpy (estatus, ghes->estatus, len);drivers/acpi/apei/ghes.c static int ghes_probe(struct platform_device *ghes_dev) · line 952
Quoted 7 lines
drivers/acpi/apei/ghes.c +4
-0@@ -942,6 +946,10 @@ static int ghes_probe(struct platform_device *ghes_dev) }platform_set_drvdata (ghes_dev, ghes); + rc =ghes_edac_register (ghes, &ghes_dev->dev); +if (rc <0 ) + goto err; +If
ghes_edac_register()failed, we need to do some cleanup such as unregister from hed etc.
Quoted 1 line
Or just move
ghes_edac_register()before switch?
Moving it to happen before the switch() looks the better. We need to unregister ghes_edac if IRQ fails.
Quoted 12 lines
Quoted 12 lines
drivers/acpi/apei/ghes.c +3
-0return 0 ; err:if (ghes) {@@ -995,6 +1003,9 @@ static int ghes_remove(struct platform_device *ghes_dev) }ghes_fini (ghes); + +ghes_edac_unregister (ghes); +kfree (ghes);
Quoted 13 lines
include/acpi/ghes.h struct ghes { · line 26
Quoted 11 lines
drivers/acpi/apei/ghes.c +0
-0platform_set_drvdata (ghes_dev,NULL );include/acpi/ghes.h +2
-0@@ -22,11 +22,14 @@ struct ghes {struct timer_list timer;unsigned int irq; }; + +struct mem_ctl_info *mci;Why we need this? This is not used by ghes.[hc].
This will be needed by the EDAC driver, as the EDAC core has its own main struct, and such struct need to be recovered when reporting an error.
As this struct is not used by ghes, there's no need to even include the include/linux/edac.h, where this is declared, as gcc will just handle it as "void *" when compiling ghes.
I opted for this design as it is simpler, and costs just 8 bytes for each ghes struct, and no extra code is needed.
However, as you're not happy with it, I'm removing it from there, and adding a list at the edac driver, together with a mutex, to serialize its access, associating each ghes struct with their corresponding MC struct.
I'll post the patch replacing patch 05/13 soon.
Quoted 33 lines
Quoted 33 lines
include/acpi/ghes.h +20
-0};struct ghes_estatus_node {struct llist_node llnode;struct acpi_hest_generic *generic; +struct ghes *ghes; };struct ghes_estatus_cache {@@ -43,3 +46,27 @@ enum {GHES_SEV_RECOVERABLE =0x2 , GHES_SEV_PANIC = 0x3, }; + +#ifdef CONFIG_EDAC_GHES +void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err); + +int ghes_edac_register (struct ghes *ghes,struct device *dev); + +void ghes_edac_unregister (struct ghes *ghes); + +#else +static inline void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err) +{ +} + +static inline int ghes_edac_register (struct ghes *ghes,struct device *dev) +{ +return 0 ; +}
Quoted 8 lines
include/acpi/ghes.h enum { · line 72
Quoted 5 lines
include/acpi/ghes.h +5
-0+ +static inline void ghes_edac_unregister (struct ghes *ghes) +{ +} +#endif I think it is better to put the above declaration into module which implement these functions instead of use these functions.
This is due to Linux Coding Style. See Documentation/SubmittingPatches, session 2, item 1:
2) #ifdefs are ugly
Code cluttered with ifdefs is difficult to read and maintain. Don't do
it. Instead, put your ifdefs in a header, and conditionally define
'static inline' functions, or macros, which are used in the code.
Let the compiler optimize away the "no-op" case.
Simple example, of poor code:
dev = alloc_etherdev (sizeof(struct funky_private));
if (!dev)
return -ENODEV;
#ifdef CONFIG_NET_FUNKINESS
init_funky_net(dev);
#endif
Cleaned-up example:
(in header)
#ifndef CONFIG_NET_FUNKINESS
static inline void init_funky_net (struct net_device *d) {}
#endif
(in the code itself)
dev = alloc_etherdev (sizeof(struct funky_private));
if (!dev)
return -ENODEV;
init_funky_net(dev);There is also an advantage on taking this approach: this patch can have just the ghes changes, and will still compile fine, as CONFIG_EDAC_GHES is not defined yet. So, the patch becomes is simpler and easier to review.
If I would do it otherwise, I would need to fold patch 5 to avoid breaking git bisect.
Regards,
Mauro
Patch with the changes enclosed.
-
[PATCH EDACv2 03/13] ghes: add the needed hooks for EDAC error report
In order to allow reporting errors via EDAC, add hooks for:
1) register an EDAC driver;
2) unregister an EDAC driver;
3) report errors via EDAC.
As the EDAC driver will need to access the ghes structure, adds it as one of the parameters for ghes_do_proc.
drivers/acpi/apei/ghes.c +19 -5
@@ -409,7 +409,8 @@ static void ghes_clear_estatus(struct ghes *ghes) ghes->flags &= ~GHES_TO_CLEAR ; } -static void ghes_do_proc (const struct acpi_hest_generic_status *estatus) +static void ghes_do_proc (struct ghes *ghes, +const struct acpi_hest_generic_status *estatus) {int sev, sec_sev;struct acpi_hest_generic_data *gdata;
@@ -421,6 +422,8 @@ static void ghes_do_proc(const struct acpi_hest_generic_status *estatus) CPER_SEC_PLATFORM_MEM)) {struct cper_sec_mem_err *mem_err; mem_err = (struct cper_sec_mem_err *)(gdata+1 ); +ghes_edac_report_mem_error (ghes, sev, mem_err); +#ifdef CONFIG_X86_MCE apei_mce_report_mem_error (sev ==GHES_SEV_CORRECTED , mem_err);
@@ -639,7 +642,7 @@ static int ghes_proc(struct ghes *ghes)if (ghes_print_estatus (NULL , ghes->generic, ghes->estatus))ghes_estatus_cache_add (ghes->generic, ghes->estatus); } -ghes_do_proc (ghes->estatus); +ghes_do_proc (ghes, ghes->estatus); out:ghes_clear_estatus (ghes);return 0 ;
@@ -732,7 +735,7 @@ static void ghes_proc_in_irq(struct irq_work *irq_work) estatus =GHES_ESTATUS_FROM_NODE (estatus_node); len =apei_estatus_len (estatus); node_len =GHES_ESTATUS_NODE_LEN (len); -ghes_do_proc (estatus); +ghes_do_proc (estatus_node->ghes, estatus);if (!ghes_estatus_cached (estatus)) { generic = estatus_node->generic;if (ghes_print_estatus (NULL , generic, estatus))
@@ -821,6 +824,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) estatus_node = (void *)gen_pool_alloc (ghes_estatus_pool, node_len);if (estatus_node) { + estatus_node->ghes = ghes; estatus_node->generic = ghes->generic; estatus =GHES_ESTATUS_FROM_NODE (estatus_node);memcpy (estatus, ghes->estatus, len);
@@ -899,6 +903,11 @@ static int ghes_probe(struct platform_device *ghes_dev) ghes =NULL ; goto err; } + + rc =ghes_edac_register (ghes, &ghes_dev->dev); +if (rc <0 ) + goto err; +switch (generic->notify.type) {case ACPI_HEST_NOTIFY_POLLED : ghes->timer.function = ghes_poll_func;
@@ -911,13 +920,13 @@ static int ghes_probe(struct platform_device *ghes_dev)if (acpi_gsi_to_irq (generic->notify.vector, &ghes->irq)) {pr_err (GHES_PFX "Failed to map GSI to IRQ for generic hardware error source: %d\n" , generic->header.source_id); - goto err; + goto err2; }if (request_irq (ghes->irq, ghes_irq_func,0 ,"GHES IRQ" , ghes)) {pr_err (GHES_PFX "Failed to register IRQ for generic hardware error source: %d\n" , generic->header.source_id); - goto err; + goto err2; }break ;case ACPI_HEST_NOTIFY_SCI :
@@ -943,6 +952,8 @@ static int ghes_probe(struct platform_device *ghes_dev)platform_set_drvdata (ghes_dev, ghes);return 0 ; +err2: +ghes_edac_unregister (ghes); err:if (ghes) {ghes_fini (ghes);
@@ -995,6 +1006,9 @@ static int ghes_remove(struct platform_device *ghes_dev) }ghes_fini (ghes); + +ghes_edac_unregister (ghes); +kfree (ghes);platform_set_drvdata (ghes_dev,NULL );
include/acpi/ghes.h +25 -0
@@ -27,6 +27,7 @@ struct ghes {struct ghes_estatus_node {struct llist_node llnode;struct acpi_hest_generic *generic; +struct ghes *ghes; };struct ghes_estatus_cache {
@@ -43,3 +44,27 @@ enum {GHES_SEV_RECOVERABLE =0x2 , GHES_SEV_PANIC = 0x3, }; + +#ifdef CONFIG_EDAC_GHES +void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err); + +int ghes_edac_register (struct ghes *ghes,struct device *dev); + +void ghes_edac_unregister (struct ghes *ghes); + +#else +static inline void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err) +{ +} + +static inline int ghes_edac_register (struct ghes *ghes,struct device *dev) +{ +return 0 ; +} + +static inline void ghes_edac_unregister (struct ghes *ghes) +{ +} +#endif
Re: [PATCH EDAC 03/13] ghes: add the needed hooks for EDAC error report
Quoted 205 lines · Mauro Carvalho Chehab
Em Thu, 21 Feb 2013 09:26:07 +0800
Huang Ying <[email protected]> escreveu:Quoted 1 line
Sorry for late!
Thanks for your comments. See my answers below.
Quoted 78 lines · Mauro Carvalho Chehab
Quoted 65 lines
In order to allow reporting errors via EDAC, add hooks for:
1) register an EDAC driver;
2) unregister an EDAC driver;
3) report errors via EDAC.As the EDAC driver will need to access the ghes structure, adds it as one of the parameters for
ghes_do_proc.Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/acpi/apei/ghes.c | 17 ++++++++++++++--- include/acpi/ghes.h | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-)drivers/acpi/apei/ghes.c +7
-3@@ -409,7 +409,8 @@ static void ghes_clear_estatus(struct ghes *ghes) ghes->flags &= ~GHES_TO_CLEAR ; } -static void ghes_do_proc (const struct acpi_hest_generic_status *estatus) +static void ghes_do_proc (struct ghes *ghes, +const struct acpi_hest_generic_status *estatus) {int sev, sec_sev;struct acpi_hest_generic_data *gdata;@@ -421,6 +422,8 @@ static void ghes_do_proc(const struct acpi_hest_generic_status *estatus) CPER_SEC_PLATFORM_MEM)) {struct cper_sec_mem_err *mem_err; mem_err = (struct cper_sec_mem_err *)(gdata+1 ); +ghes_edac_report_mem_error (ghes, sev, mem_err); +#ifdef CONFIG_X86_MCE apei_mce_report_mem_error (sev ==GHES_SEV_CORRECTED , mem_err);@@ -639,7 +642,7 @@ static int ghes_proc(struct ghes *ghes)if (ghes_print_estatus (NULL , ghes->generic, ghes->estatus))ghes_estatus_cache_add (ghes->generic, ghes->estatus); } -ghes_do_proc (ghes->estatus); +ghes_do_proc (ghes, ghes->estatus); out:ghes_clear_estatus (ghes);return 0 ;@@ -732,7 +735,7 @@ static void ghes_proc_in_irq(struct irq_work *irq_work) estatus =GHES_ESTATUS_FROM_NODE (estatus_node); len =apei_estatus_len (estatus); node_len =GHES_ESTATUS_NODE_LEN (len); -ghes_do_proc (estatus); +ghes_do_proc (estatus_node->ghes, estatus);if (!ghes_estatus_cached (estatus)) { generic = estatus_node->generic;if (ghes_print_estatus (NULL , generic, estatus))@@ -821,6 +824,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) estatus_node = (void *)gen_pool_alloc (ghes_estatus_pool, node_len);if (estatus_node) { + estatus_node->ghes = ghes; estatus_node->generic = ghes->generic; estatus =GHES_ESTATUS_FROM_NODE (estatus_node);memcpy (estatus, ghes->estatus, len);drivers/acpi/apei/ghes.c static int ghes_probe(struct platform_device *ghes_dev) · line 952
Quoted 7 lines
drivers/acpi/apei/ghes.c +4
-0@@ -942,6 +946,10 @@ static int ghes_probe(struct platform_device *ghes_dev) }platform_set_drvdata (ghes_dev, ghes); + rc =ghes_edac_register (ghes, &ghes_dev->dev); +if (rc <0 ) + goto err; +If
ghes_edac_register()failed, we need to do some cleanup such as unregister from hed etc.Quoted 1 line
Or just move
ghes_edac_register()before switch?Moving it to happen before the
switch()looks the better. We need to unregisterghes_edacif IRQ fails.Quoted 12 lines
Quoted 12 lines
drivers/acpi/apei/ghes.c +3
-0return 0 ; err:if (ghes) {@@ -995,6 +1003,9 @@ static int ghes_remove(struct platform_device *ghes_dev) }ghes_fini (ghes); + +ghes_edac_unregister (ghes); +kfree (ghes);Quoted 13 lines
include/acpi/ghes.h struct ghes { · line 26
Quoted 11 lines
drivers/acpi/apei/ghes.c +0
-0platform_set_drvdata (ghes_dev,NULL );include/acpi/ghes.h +2
-0@@ -22,11 +22,14 @@ struct ghes {struct timer_list timer;unsigned int irq; }; + +struct mem_ctl_info *mci;Why we need this? This is not used by ghes.[hc].
This will be needed by the EDAC driver, as the EDAC core has its own main struct, and such struct need to be recovered when reporting an error.
As this struct is not used by ghes, there's no need to even include the
include/linux/edac.h, where this is declared, as gcc will just handle it as "void *" when compiling ghes.I opted for this design as it is simpler, and costs just 8 bytes for each ghes struct, and no extra code is needed.
However, as you're not happy with it, I'm removing it from there, and adding a list at the edac driver, together with a mutex, to serialize its access, associating each ghes struct with their corresponding MC struct.
I'll post the patch replacing patch 05/13 soon.
Quoted 33 lines
Quoted 33 lines
include/acpi/ghes.h +20
-0};struct ghes_estatus_node {struct llist_node llnode;struct acpi_hest_generic *generic; +struct ghes *ghes; };struct ghes_estatus_cache {@@ -43,3 +46,27 @@ enum {GHES_SEV_RECOVERABLE =0x2 , GHES_SEV_PANIC = 0x3, }; + +#ifdef CONFIG_EDAC_GHES +void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err); + +int ghes_edac_register (struct ghes *ghes,struct device *dev); + +void ghes_edac_unregister (struct ghes *ghes); + +#else +static inline void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err) +{ +} + +static inline int ghes_edac_register (struct ghes *ghes,struct device *dev) +{ +return 0 ; +}Quoted 8 lines
include/acpi/ghes.h enum { · line 70
Quoted 5 lines
include/acpi/ghes.h +5
-0+ +static inline void ghes_edac_unregister (struct ghes *ghes) +{ +} +#endif I think it is better to put the above declaration into module which implement these functions instead of use these functions.
This is due to Linux Coding Style. See
Documentation/SubmittingPatches, session 2, item 1:2) #ifdefs are ugly Code cluttered with ifdefs is difficult to read and maintain. Don't do it. Instead, put your ifdefs in a header, and conditionally define 'static inline' functions, or macros, which are used in the code. Let the compiler optimize away the "no-op" case. Simple example, of poor code: dev = alloc_etherdev (sizeof(struct funky_private)); if (!dev) return -ENODEV; #ifdef CONFIG_NET_FUNKINESS init_funky_net(dev); #endif Cleaned-up example: (in header) #ifndef CONFIG_NET_FUNKINESS static inline void init_funky_net (struct net_device *d) {} #endif (in the code itself) dev = alloc_etherdev (sizeof(struct funky_private)); if (!dev) return -ENODEV; init_funky_net(dev);
Quoted 3 lines
There is also an advantage on taking this approach: this patch can have just the ghes changes, and will still compile fine, as
CONFIG_EDAC_GHESis not defined yet. So, the patch becomes is simpler and easier to review.
Thanks for your explanation. I agree to keep this in header file.
My original suggestion is that it may be better to move this from ghes.h to some place like "ghes_edac.h", because these functions are implemented in "ghes_edac.c" instead of ghes.c.
Quoted 101 lines
If I would do it otherwise, I would need to fold patch 5 to avoid breaking git bisect.
Regards,
MauroPatch with the changes enclosed.
-
[PATCH EDACv2 03/13] ghes: add the needed hooks for EDAC error report
In order to allow reporting errors via EDAC, add hooks for:
1) register an EDAC driver;
2) unregister an EDAC driver;
3) report errors via EDAC.As the EDAC driver will need to access the ghes structure, adds it as one of the parameters for
ghes_do_proc.Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/acpi/apei/ghes.c +14
-5@@ -409,7 +409,8 @@ static void ghes_clear_estatus(struct ghes *ghes) ghes->flags &= ~GHES_TO_CLEAR ; } -static void ghes_do_proc (const struct acpi_hest_generic_status *estatus) +static void ghes_do_proc (struct ghes *ghes, +const struct acpi_hest_generic_status *estatus) {int sev, sec_sev;struct acpi_hest_generic_data *gdata;@@ -421,6 +422,8 @@ static void ghes_do_proc(const struct acpi_hest_generic_status *estatus) CPER_SEC_PLATFORM_MEM)) {struct cper_sec_mem_err *mem_err; mem_err = (struct cper_sec_mem_err *)(gdata+1 ); +ghes_edac_report_mem_error (ghes, sev, mem_err); +#ifdef CONFIG_X86_MCE apei_mce_report_mem_error (sev ==GHES_SEV_CORRECTED , mem_err);@@ -639,7 +642,7 @@ static int ghes_proc(struct ghes *ghes)if (ghes_print_estatus (NULL , ghes->generic, ghes->estatus))ghes_estatus_cache_add (ghes->generic, ghes->estatus); } -ghes_do_proc (ghes->estatus); +ghes_do_proc (ghes, ghes->estatus); out:ghes_clear_estatus (ghes);return 0 ;@@ -732,7 +735,7 @@ static void ghes_proc_in_irq(struct irq_work *irq_work) estatus =GHES_ESTATUS_FROM_NODE (estatus_node); len =apei_estatus_len (estatus); node_len =GHES_ESTATUS_NODE_LEN (len); -ghes_do_proc (estatus); +ghes_do_proc (estatus_node->ghes, estatus);if (!ghes_estatus_cached (estatus)) { generic = estatus_node->generic;if (ghes_print_estatus (NULL , generic, estatus))@@ -821,6 +824,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) estatus_node = (void *)gen_pool_alloc (ghes_estatus_pool, node_len);if (estatus_node) { + estatus_node->ghes = ghes; estatus_node->generic = ghes->generic; estatus =GHES_ESTATUS_FROM_NODE (estatus_node);memcpy (estatus, ghes->estatus, len);@@ -899,6 +903,11 @@ static int ghes_probe(struct platform_device *ghes_dev) ghes =NULL ; goto err; } + + rc =ghes_edac_register (ghes, &ghes_dev->dev); +if (rc <0 ) + goto err; +switch (generic->notify.type) {case ACPI_HEST_NOTIFY_POLLED : ghes->timer.function = ghes_poll_func;@@ -911,13 +920,13 @@ static int ghes_probe(struct platform_device *ghes_dev)if (acpi_gsi_to_irq (generic->notify.vector, &ghes->irq)) {pr_err (GHES_PFX "Failed to map GSI to IRQ for generic hardware error source: %d\n" , generic->header.source_id); - goto err; + goto err2; }if (request_irq (ghes->irq, ghes_irq_func,0 ,"GHES IRQ" , ghes)) {pr_err (GHES_PFX "Failed to register IRQ for generic hardware error source: %d\n" , generic->header.source_id); - goto err; + goto err2; }break ;case ACPI_HEST_NOTIFY_SCI :
drivers/acpi/apei/ghes.c static int ghes_probe(struct platform_device *ghes_dev) · line 955
Quoted 4 lines
drivers/acpi/apei/ghes.c +1
-0@@ -943,6 +952,8 @@ static int ghes_probe(struct platform_device *ghes_dev)platform_set_drvdata (ghes_dev, ghes);return 0 ; +err2:
Suggest to rename it to err_edac_unreg or something like that. Just a suggestion.
Best Regards,
Huang Ying
Quoted 55 lines
drivers/acpi/apei/ghes.c +4
-0+ghes_edac_unregister (ghes); err:if (ghes) {ghes_fini (ghes);@@ -995,6 +1006,9 @@ static int ghes_remove(struct platform_device *ghes_dev) }ghes_fini (ghes); + +ghes_edac_unregister (ghes); +kfree (ghes);platform_set_drvdata (ghes_dev,NULL );include/acpi/ghes.h +25
-0@@ -27,6 +27,7 @@ struct ghes {struct ghes_estatus_node {struct llist_node llnode;struct acpi_hest_generic *generic; +struct ghes *ghes; };struct ghes_estatus_cache {@@ -43,3 +44,27 @@ enum {GHES_SEV_RECOVERABLE =0x2 , GHES_SEV_PANIC = 0x3, }; + +#ifdef CONFIG_EDAC_GHES +void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err); + +int ghes_edac_register (struct ghes *ghes,struct device *dev); + +void ghes_edac_unregister (struct ghes *ghes); + +#else +static inline void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err) +{ +} + +static inline int ghes_edac_register (struct ghes *ghes,struct device *dev) +{ +return 0 ; +} + +static inline void ghes_edac_unregister (struct ghes *ghes) +{ +} +#endif
Re: [PATCH EDAC 03/13] ghes: add the needed hooks for EDAC error report
Em Fri, 22 Feb 2013 08:45:11 +0800
Huang Ying <[email protected]> escreveu:
Quoted 9 lines · Mauro Carvalho Chehab
Quoted 7 lines
Em Thu, 21 Feb 2013 09:26:07 +0800
Huang Ying <[email protected]> escreveu:There is also an advantage on taking this approach: this patch can have just the ghes changes, and will still compile fine, as
CONFIG_EDAC_GHESis not defined yet. So, the patch becomes is simpler and easier to review.
Quoted 6 lines
Thanks for your explanation. I agree to keep this in header file.
My original suggestion is that it may be better to move this from
ghes.hto some place like "ghes_edac.h", because these functions are implemented in "ghes_edac.c" instead ofghes.c.
Ah! Well, I considered a separate header when writing this patch, but adding another header for just 3 functions where the parameters are more related to ghes than with ghes_edac seemed overkill to me.
IMO, a single comment at the header pointing to ghes_edac.c would improve it.
Quoted 22 lines
Quoted 22 lines
(quoted diff) +2
-2switch (generic->notify.type) { case ACPI_HEST_NOTIFY_POLLED: ghes->timer.function = ghes_poll_func;@@ -911,13 +920,13 @@ static int ghes_probe(struct platform_device *ghes_dev) if (acpi_gsi_to_irq(generic->notify.vector, &ghes->irq)) { pr_err(GHES_PFX "Failed to map GSI to IRQ for generic hardware error source: %d\n", generic->header.source_id); - goto err; + goto err2; } if (request_irq(ghes->irq, ghes_irq_func, 0, "GHES IRQ", ghes)) { pr_err(GHES_PFX "Failed to register IRQ for generic hardware error source: %d\n", generic->header.source_id); - goto err; + goto err2; } break; case ACPI_HEST_NOTIFY_SCI:@@ -943,6 +952,8 @@ static int ghes_probe(struct platform_device *ghes_dev) platform_set_drvdata(ghes_dev, ghes);
Quoted 5 lines
Review static int ghes_probe(struct platform_device *ghes_dev) · line 955
Quoted 2 lines
(quoted diff) +1
-0return 0; +err2:Suggest to rename it to
err_edac_unregor something like that. Just a suggestion.
Done.
I'm folding the enclosed patch on it.
Thanks for review!
Regards,
Mauro
drivers/acpi/apei/ghes.c +3 -3
@@ -920,13 +920,13 @@ static int ghes_probe(struct platform_device *ghes_dev)if (acpi_gsi_to_irq (generic->notify.vector, &ghes->irq)) {pr_err (GHES_PFX "Failed to map GSI to IRQ for generic hardware error source: %d\n" , generic->header.source_id); - goto err2; + goto err_edac_unreg; }if (request_irq (ghes->irq, ghes_irq_func,0 ,"GHES IRQ" , ghes)) {pr_err (GHES_PFX "Failed to register IRQ for generic hardware error source: %d\n" , generic->header.source_id); - goto err2; + goto err_edac_unreg; }break ;case ACPI_HEST_NOTIFY_SCI :
@@ -952,7 +952,7 @@ static int ghes_probe(struct platform_device *ghes_dev)platform_set_drvdata (ghes_dev, ghes);return 0 ; -err2: +err_edac_unreg:ghes_edac_unregister (ghes); err:if (ghes) {
include/acpi/ghes.h +2 -0
@@ -45,6 +45,8 @@ enum { GHES_SEV_PANIC = 0x3, }; +/* From drivers/edac/ghes_acpi.h */ +#ifdef CONFIG_EDAC_GHES void ghes_edac_report_mem_error (struct ghes *ghes,int sev,struct cper_sec_mem_err *mem_err);
Signature · 2 lines
Cheers, Mauro
Re: [PATCH EDAC 03/13] ghes: add the needed hooks for EDAC error report
Em Fri, 22 Feb 2013 05:50:21 -0300
Mauro Carvalho Chehab <[email protected]> escreveu:
Quoted 25 lines
Em Fri, 22 Feb 2013 08:45:11 +0800
Huang Ying <[email protected]> escreveu:Quoted 9 lines · Mauro Carvalho Chehab
Quoted 7 lines
Em Thu, 21 Feb 2013 09:26:07 +0800
Huang Ying <[email protected]> escreveu:There is also an advantage on taking this approach: this patch can have just the ghes changes, and will still compile fine, as
CONFIG_EDAC_GHESis not defined yet. So, the patch becomes is simpler and easier to review.Quoted 6 lines
Thanks for your explanation. I agree to keep this in header file.
My original suggestion is that it may be better to move this from
ghes.hto some place like "ghes_edac.h", because these functions are implemented in "ghes_edac.c" instead ofghes.c.Ah! Well, I considered a separate header when writing this patch, but adding another header for just 3 functions where the parameters are more related to ghes than with
ghes_edacseemed overkill to me.IMO, a single comment at the header pointing to
ghes_edac.cwould improve it.
...
Quoted 1 line
+/* From
drivers/edac/ghes_acpi.h*/
...with is obviously wrong.
Mental note to myself: never hack too early in the morning before drinking a cup of coffee.
Anyway, fixed on the patch below. Could you please ack?
Regards,
Mauro.
[PATCH EDAC] ghes: add the needed hooks for EDAC error report
In order to allow reporting errors via EDAC, add hooks for:
1) register an EDAC driver;
2) unregister an EDAC driver;
3) report errors via EDAC.
As the EDAC driver will need to access the ghes structure, adds it as one of the parameters for ghes_do_proc.
drivers/acpi/apei/ghes.c +19 -5
@@ -409,7 +409,8 @@ static void ghes_clear_estatus(struct ghes *ghes) ghes->flags &= ~GHES_TO_CLEAR ; } -static void ghes_do_proc (const struct acpi_hest_generic_status *estatus) +static void ghes_do_proc (struct ghes *ghes, +const struct acpi_hest_generic_status *estatus) {int sev, sec_sev;struct acpi_hest_generic_data *gdata;
@@ -421,6 +422,8 @@ static void ghes_do_proc(const struct acpi_hest_generic_status *estatus) CPER_SEC_PLATFORM_MEM)) {struct cper_sec_mem_err *mem_err; mem_err = (struct cper_sec_mem_err *)(gdata+1 ); +ghes_edac_report_mem_error (ghes, sev, mem_err); +#ifdef CONFIG_X86_MCE apei_mce_report_mem_error (sev ==GHES_SEV_CORRECTED , mem_err);
@@ -639,7 +642,7 @@ static int ghes_proc(struct ghes *ghes)if (ghes_print_estatus (NULL , ghes->generic, ghes->estatus))ghes_estatus_cache_add (ghes->generic, ghes->estatus); } -ghes_do_proc (ghes->estatus); +ghes_do_proc (ghes, ghes->estatus); out:ghes_clear_estatus (ghes);return 0 ;
@@ -732,7 +735,7 @@ static void ghes_proc_in_irq(struct irq_work *irq_work) estatus =GHES_ESTATUS_FROM_NODE (estatus_node); len =apei_estatus_len (estatus); node_len =GHES_ESTATUS_NODE_LEN (len); -ghes_do_proc (estatus); +ghes_do_proc (estatus_node->ghes, estatus);if (!ghes_estatus_cached (estatus)) { generic = estatus_node->generic;if (ghes_print_estatus (NULL , generic, estatus))
@@ -821,6 +824,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) estatus_node = (void *)gen_pool_alloc (ghes_estatus_pool, node_len);if (estatus_node) { + estatus_node->ghes = ghes; estatus_node->generic = ghes->generic; estatus =GHES_ESTATUS_FROM_NODE (estatus_node);memcpy (estatus, ghes->estatus, len);
@@ -899,6 +903,11 @@ static int ghes_probe(struct platform_device *ghes_dev) ghes =NULL ; goto err; } + + rc =ghes_edac_register (ghes, &ghes_dev->dev); +if (rc <0 ) + goto err; +switch (generic->notify.type) {case ACPI_HEST_NOTIFY_POLLED : ghes->timer.function = ghes_poll_func;
@@ -911,13 +920,13 @@ static int ghes_probe(struct platform_device *ghes_dev)if (acpi_gsi_to_irq (generic->notify.vector, &ghes->irq)) {pr_err (GHES_PFX "Failed to map GSI to IRQ for generic hardware error source: %d\n" , generic->header.source_id); - goto err; + goto err_edac_unreg; }if (request_irq (ghes->irq, ghes_irq_func,0 ,"GHES IRQ" , ghes)) {pr_err (GHES_PFX "Failed to register IRQ for generic hardware error source: %d\n" , generic->header.source_id); - goto err; + goto err_edac_unreg; }break ;case ACPI_HEST_NOTIFY_SCI :
@@ -943,6 +952,8 @@ static int ghes_probe(struct platform_device *ghes_dev)platform_set_drvdata (ghes_dev, ghes);return 0 ; +err_edac_unreg: +ghes_edac_unregister (ghes); err:if (ghes) {ghes_fini (ghes);
@@ -995,6 +1006,9 @@ static int ghes_remove(struct platform_device *ghes_dev) }ghes_fini (ghes); + +ghes_edac_unregister (ghes); +kfree (ghes);platform_set_drvdata (ghes_dev,NULL );
include/acpi/ghes.h +27 -0
@@ -27,6 +27,7 @@ struct ghes {struct ghes_estatus_node {struct llist_node llnode;struct acpi_hest_generic *generic; +struct ghes *ghes; };struct ghes_estatus_cache {
@@ -43,3 +44,29 @@ enum {GHES_SEV_RECOVERABLE =0x2 , GHES_SEV_PANIC = 0x3, }; + +/* From drivers/edac/ghes_edac.c */ + +#ifdef CONFIG_EDAC_GHES +void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err); + +int ghes_edac_register (struct ghes *ghes,struct device *dev); + +void ghes_edac_unregister (struct ghes *ghes); + +#else +static inline void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err) +{ +} + +static inline int ghes_edac_register (struct ghes *ghes,struct device *dev) +{ +return 0 ; +} + +static inline void ghes_edac_unregister (struct ghes *ghes) +{ +} +#endif
Huang Ying
Acked-byRe: [PATCH EDAC 03/13] ghes: add the needed hooks for EDAC error report
Quoted 46 lines · Mauro Carvalho Chehab
Em Fri, 22 Feb 2013 05:50:21 -0300
Mauro Carvalho Chehab <[email protected]> escreveu:Quoted 25 lines
Em Fri, 22 Feb 2013 08:45:11 +0800
Huang Ying <[email protected]> escreveu:Quoted 9 lines · Mauro Carvalho Chehab
Quoted 7 lines
Em Thu, 21 Feb 2013 09:26:07 +0800
Huang Ying <[email protected]> escreveu:There is also an advantage on taking this approach: this patch can have just the ghes changes, and will still compile fine, as
CONFIG_EDAC_GHESis not defined yet. So, the patch becomes is simpler and easier to review.Quoted 6 lines
Thanks for your explanation. I agree to keep this in header file.
My original suggestion is that it may be better to move this from
ghes.hto some place like "ghes_edac.h", because these functions are implemented in "ghes_edac.c" instead ofghes.c.Ah! Well, I considered a separate header when writing this patch, but adding another header for just 3 functions where the parameters are more related to ghes than with
ghes_edacseemed overkill to me.IMO, a single comment at the header pointing to
ghes_edac.cwould improve it....
Quoted 1 line
+/* From
drivers/edac/ghes_acpi.h*/...with is obviously wrong.
Mental note to myself: never hack too early in the morning before drinking a cup of coffee.
Anyway, fixed on the patch below. Could you please ack?
Regards,
Mauro.[PATCH EDAC] ghes: add the needed hooks for EDAC error report
In order to allow reporting errors via EDAC, add hooks for:
Quoted 8 lines
1) register an EDAC driver;
2) unregister an EDAC driver;
3) report errors via EDAC.As the EDAC driver will need to access the ghes structure, adds it as one of the parameters for
ghes_do_proc.Signed-off-by Mauro Carvalho Chehab <[email protected]>
Quoted 140 lines
drivers/acpi/apei/ghes.c +19
-5@@ -409,7 +409,8 @@ static void ghes_clear_estatus(struct ghes *ghes) ghes->flags &= ~GHES_TO_CLEAR ; } -static void ghes_do_proc (const struct acpi_hest_generic_status *estatus) +static void ghes_do_proc (struct ghes *ghes, +const struct acpi_hest_generic_status *estatus) {int sev, sec_sev;struct acpi_hest_generic_data *gdata;@@ -421,6 +422,8 @@ static void ghes_do_proc(const struct acpi_hest_generic_status *estatus) CPER_SEC_PLATFORM_MEM)) {struct cper_sec_mem_err *mem_err; mem_err = (struct cper_sec_mem_err *)(gdata+1 ); +ghes_edac_report_mem_error (ghes, sev, mem_err); +#ifdef CONFIG_X86_MCE apei_mce_report_mem_error (sev ==GHES_SEV_CORRECTED , mem_err);@@ -639,7 +642,7 @@ static int ghes_proc(struct ghes *ghes)if (ghes_print_estatus (NULL , ghes->generic, ghes->estatus))ghes_estatus_cache_add (ghes->generic, ghes->estatus); } -ghes_do_proc (ghes->estatus); +ghes_do_proc (ghes, ghes->estatus); out:ghes_clear_estatus (ghes);return 0 ;@@ -732,7 +735,7 @@ static void ghes_proc_in_irq(struct irq_work *irq_work) estatus =GHES_ESTATUS_FROM_NODE (estatus_node); len =apei_estatus_len (estatus); node_len =GHES_ESTATUS_NODE_LEN (len); -ghes_do_proc (estatus); +ghes_do_proc (estatus_node->ghes, estatus);if (!ghes_estatus_cached (estatus)) { generic = estatus_node->generic;if (ghes_print_estatus (NULL , generic, estatus))@@ -821,6 +824,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) estatus_node = (void *)gen_pool_alloc (ghes_estatus_pool, node_len);if (estatus_node) { + estatus_node->ghes = ghes; estatus_node->generic = ghes->generic; estatus =GHES_ESTATUS_FROM_NODE (estatus_node);memcpy (estatus, ghes->estatus, len);@@ -899,6 +903,11 @@ static int ghes_probe(struct platform_device *ghes_dev) ghes =NULL ; goto err; } + + rc =ghes_edac_register (ghes, &ghes_dev->dev); +if (rc <0 ) + goto err; +switch (generic->notify.type) {case ACPI_HEST_NOTIFY_POLLED : ghes->timer.function = ghes_poll_func;@@ -911,13 +920,13 @@ static int ghes_probe(struct platform_device *ghes_dev)if (acpi_gsi_to_irq (generic->notify.vector, &ghes->irq)) {pr_err (GHES_PFX "Failed to map GSI to IRQ for generic hardware error source: %d\n" , generic->header.source_id); - goto err; + goto err_edac_unreg; }if (request_irq (ghes->irq, ghes_irq_func,0 ,"GHES IRQ" , ghes)) {pr_err (GHES_PFX "Failed to register IRQ for generic hardware error source: %d\n" , generic->header.source_id); - goto err; + goto err_edac_unreg; }break ;case ACPI_HEST_NOTIFY_SCI :@@ -943,6 +952,8 @@ static int ghes_probe(struct platform_device *ghes_dev)platform_set_drvdata (ghes_dev, ghes);return 0 ; +err_edac_unreg: +ghes_edac_unregister (ghes); err:if (ghes) {ghes_fini (ghes);@@ -995,6 +1006,9 @@ static int ghes_remove(struct platform_device *ghes_dev) }ghes_fini (ghes); + +ghes_edac_unregister (ghes); +kfree (ghes);platform_set_drvdata (ghes_dev,NULL );include/acpi/ghes.h +27
-0@@ -27,6 +27,7 @@ struct ghes {struct ghes_estatus_node {struct llist_node llnode;struct acpi_hest_generic *generic; +struct ghes *ghes; };struct ghes_estatus_cache {@@ -43,3 +44,29 @@ enum {GHES_SEV_RECOVERABLE =0x2 , GHES_SEV_PANIC = 0x3, }; + +/* From drivers/edac/ghes_edac.c */ + +#ifdef CONFIG_EDAC_GHES +void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err); + +int ghes_edac_register (struct ghes *ghes,struct device *dev); + +void ghes_edac_unregister (struct ghes *ghes); + +#else +static inline void ghes_edac_report_mem_error (struct ghes *ghes,int sev, +struct cper_sec_mem_err *mem_err) +{ +} + +static inline int ghes_edac_register (struct ghes *ghes,struct device *dev) +{ +return 0 ; +} + +static inline void ghes_edac_unregister (struct ghes *ghes) +{ +} +#endif
PATCH 4/13 edac: add a new memory layer type
In reply to Mauro Carvalho ChehabThere are some cases where the memory controller layout is completely hidden. This is the case of firmware-driven error code, like the one provided by GHES. Add a new layer to be used on such memory error report mechanisms.
--- drivers/edac/edac_mc.c | 1 + include/linux/edac.h | 4 ++++ 2 files changed, 5 insertions(+)
drivers/edac/edac_mc.c +1 -0
@@ -918,6 +918,7 @@ const char *edac_layer_name[] = { [EDAC_MC_LAYER_CHANNEL] = "channel", [EDAC_MC_LAYER_SLOT] = "slot", [EDAC_MC_LAYER_CHIP_SELECT] = "csrow", + [EDAC_MC_LAYER_ALL_MEM ] ="memory" , };EXPORT_SYMBOL_GPL (edac_layer_name);
include/linux/edac.h +4 -0
@@ -375,6 +375,9 @@ enum scrub_type {* @EDAC_MC_LAYER_CHANNEL: memory layer is named "channel" * @EDAC_MC_LAYER_SLOT: memory layer is named "slot" * @EDAC_MC_LAYER_CHIP_SELECT: memory layer is named "chip select" +* @EDAC_MC_LAYER_ALL_MEM: memory layout is unknown. All memory is mapped +* as a single memory area. This is used when +* retrieving errors from a firmware driven driver. * * This enum is used by the drivers to tell edac_mc_sysfs what name should * be used when describing a memory stick location.
@@ -384,6 +387,7 @@ enum edac_mc_layer_type {EDAC_MC_LAYER_CHANNEL ,EDAC_MC_LAYER_SLOT ,EDAC_MC_LAYER_CHIP_SELECT , + EDAC_MC_LAYER_ALL_MEM, };/**
Signature · 1 line
1.8.1.2
PATCH 5/13 ghes_edac: Register at EDAC core the BIOS report
In reply to Mauro Carvalho ChehabRegister GHES at EDAC MC core, in order to avoid other drivers to also handle errors and mangle with error data.
The edac core will warrant that just one driver will be used, so the first one to register (BIOS first) will be the one that will be reporting the hardware errors.
For now, the EDAC driver does nothing but to register at the EDAC core, preventing the hardware-driven mechanism to interfere with GHES.
--- drivers/edac/Kconfig | 23 +++++++++++++++ drivers/edac/Makefile | 1 + drivers/edac/ghes_edac.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 drivers/edac/ghes_edac.c
drivers/edac/Kconfig +23 -0
@@ -80,6 +80,29 @@ config EDAC_MM_EDAC occurred so that a particular failing memory module can be replaced. If unsure, select 'Y'. +config EDAC_GHES + bool "Output ACPI APEI/GHES BIOS detected errors via EDAC" + depends on ACPI_APEI_GHES && (EDAC_MM_EDAC=y) + default y + help + Not all machines support hardware-driven error report. Some of those + provide a BIOS-driven error report mechanism via ACPI, using the + APEI/GHES driver. By enabling this option, the error reports provided + by GHES are sent to userspace via the EDAC API. + + When this option is enabled, it will disable the hardware-driven + mechanisms, if a GHES BIOS is detected, entering into the + "Firmware First" mode. + + It should be noticed that keeping both GHES and a hardware-driven + error mechanism won't work well, as BIOS will race with OS, while + reading the error registers. So, if you want to not use "Firmware + first" GHES error mechanism, you should disable GHES either at + compilation time or by passing "ghes_disable=1" Kernel parameter + at boot time. + + In doubt, say 'Y'. + config EDAC_AMD64 tristate "AMD64 (Opteron, Athlon64) K8, F10h" depends on EDAC_MM_EDAC && AMD_NB && X86_64 && EDAC_DECODE_MCE
drivers/edac/Makefile +1 -0
@@ -16,6 +16,7 @@ ifdef CONFIG_PCI edac_core-y += edac_pci.o edac_pci_sysfs.o endif +obj-$(CONFIG_EDAC_GHES) += ghes_edac.o obj-$(CONFIG_EDAC_MCE_INJ) += mce_amd_inj.o edac_mce_amd-y := mce_amd.o
drivers/edac/ghes_edac.c new file +75 -0
75 lines not on this page · raw message
Signature · 1 line
1.8.1.2
PATCH 6/13 ghes_edac: Allow registering more than once
In reply to Mauro Carvalho ChehabI was expecting that the GHES register call would happen only once, but it is registered once per-cpu. So, we need to create several memory controllers, one by cpu.
--- drivers/edac/ghes_edac.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/edac/ghes_edac.c +15 -2
@@ -5,6 +5,9 @@#define GHES_PFX "ghes_edac: "#define GHES_EDAC_REVISION " Ver: 1.0.0" +static DEFINE_MUTEX (ghes_edac_lock); +static int ghes_edac_mc_num; +void ghes_edac_report_mem_error (struct ghes *ghes,int sev,struct cper_sec_mem_err *mem_err) {
@@ -22,9 +25,16 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) layers[0 ].type =EDAC_MC_LAYER_ALL_MEM ; layers[0 ].size =1 ; layers[0 ].is_virt_csrow = true; - mci =edac_mc_alloc (0 ,ARRAY_SIZE (layers), layers,0 ); + +/* +* We need to serialize edac_mc_alloc() and edac_mc_add_mc(), +* to avoid duplicated memory controller numbers +*/ +mutex_lock (&ghes_edac_lock); + mci =edac_mc_alloc (ghes_edac_mc_num,ARRAY_SIZE (layers), layers,0 );if (!mci) {pr_info (GHES_PFX "Can't allocate memory for EDAC data\n" ); +mutex_unlock (&ghes_edac_lock);return -ENOMEM ; }
@@ -53,11 +63,14 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev)if (rc <0 ) {pr_info (GHES_PFX "Can't register at EDAC core\n" );edac_mc_free (mci); - +mutex_unlock (&ghes_edac_lock);return -ENODEV ; } + ghes->mci = mci; + ghes_edac_mc_num++; +mutex_unlock (&ghes_edac_lock);return 0 ; }EXPORT_SYMBOL_GPL (ghes_edac_register);
Signature · 1 line
1.8.1.2
PATCH 7/13 edac: add support for raw error reports
In reply to Mauro Carvalho ChehabThat allows APEI GHES driver to report errors directly, using the EDAC error report API.
--- drivers/edac/edac_core.h | 17 ++++++++ drivers/edac/edac_mc.c | 109 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 100 insertions(+), 26 deletions(-)
drivers/edac/edac_core.h +17 -0
@@ -453,6 +453,23 @@ extern struct mem_ctl_info *find_mci_by_dev(struct device *dev);extern struct mem_ctl_info *edac_mc_del_mc (struct device *dev);extern int edac_mc_find_csrow_by_page (struct mem_ctl_info *mci,unsigned long page); + +void edac_raw_mc_handle_error (const enum hw_event_mc_err_type type, +struct mem_ctl_info *mci, +long grain, +const u16 error_count, +const int top_layer, +const int mid_layer, +const int low_layer, +const unsigned long page_frame_number, +const unsigned long offset_in_page, +const unsigned long syndrome, +const char *msg, +const char *location, +const char *label, +const char *other_detail, +const bool enable_per_layer_report); + void edac_mc_handle_error(const enum hw_event_mc_err_type type, struct mem_ctl_info *mci, const u16 error_count,
drivers/edac/edac_mc.c +83 -26
132 lines not on this page · raw message
Signature · 1 line
1.8.1.2
Borislav Petkov
maintainerRe: [PATCH EDAC 07/13] edac: add support for raw error reports
Quoted 23 lines · Mauro Carvalho Chehab
That allows APEI GHES driver to report errors directly, using the EDAC error report API.
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/edac/edac_core.h | 17 ++++++++ drivers/edac/edac_mc.c | 109 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 100 insertions(+), 26 deletions(-)drivers/edac/edac_core.h +6
-0@@ -453,6 +453,23 @@ extern struct mem_ctl_info *find_mci_by_dev(struct device *dev);extern struct mem_ctl_info *edac_mc_del_mc (struct device *dev);extern int edac_mc_find_csrow_by_page (struct mem_ctl_info *mci,unsigned long page); + +void edac_raw_mc_handle_error(const enum hw_event_mc_err_type type, + struct mem_ctl_info *mci, + long grain, + const u16 error_count, + const int top_layer,
drivers/edac/edac_core.h extern struct mem_ctl_info *find_mci_by_dev(struct device *dev); · line 471
Quoted 10 lines
drivers/edac/edac_core.h +10
-0+const int mid_layer, + const int low_layer, + const unsigned long page_frame_number, + const unsigned long offset_in_page, + const unsigned long syndrome, + const char *msg, + const char *location, + const char *label, + const char *other_detail, + const bool enable_per_layer_report);
The argument count of this one looks like an overkill. Maybe it would be nicer, cleaner to do this:
void __edac_handle_mc_error(const enum hw_event_mc_err_type type,
struct mem_ctl_info *mci, struct error_desc *e);
and struct error_desc collects all the remaining arguments.
This way you can't get the arguments order wrong, forget one or whatever; and it would be much less stack pressure on the function calls.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH EDAC 07/13] edac: add support for raw error reports
Em Fri, 15 Feb 2013 15:13:30 +0100
Borislav Petkov <[email protected]> escreveu:
Quoted 39 lines · Mauro Carvalho Chehab
Quoted 23 lines
That allows APEI GHES driver to report errors directly, using the EDAC error report API.
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/edac/edac_core.h | 17 ++++++++ drivers/edac/edac_mc.c | 109 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 100 insertions(+), 26 deletions(-)drivers/edac/edac_core.h +6
-0@@ -453,6 +453,23 @@ extern struct mem_ctl_info *find_mci_by_dev(struct device *dev);extern struct mem_ctl_info *edac_mc_del_mc (struct device *dev);extern int edac_mc_find_csrow_by_page (struct mem_ctl_info *mci,unsigned long page); + +void edac_raw_mc_handle_error(const enum hw_event_mc_err_type type, + struct mem_ctl_info *mci, + long grain, + const u16 error_count, + const int top_layer,drivers/edac/edac_core.h extern struct mem_ctl_info *find_mci_by_dev(struct device *dev); · line 471
Quoted 10 lines
drivers/edac/edac_core.h +10
-0+const int mid_layer, + const int low_layer, + const unsigned long page_frame_number, + const unsigned long offset_in_page, + const unsigned long syndrome, + const char *msg, + const char *location, + const char *label, + const char *other_detail, + const bool enable_per_layer_report);The argument count of this one looks like an overkill. Maybe it would be nicer, cleaner to do this:
void __edac_handle_mc_error(const enum
hw_event_mc_err_typetype,
Quoted 8 lines
struct mem_ctl_info *mci, struct error_desc *e);and struct
error_desccollects all the remaining arguments.This way you can't get the arguments order wrong, forget one or whatever; and it would be much less stack pressure on the function calls.
Well, for sure using an structure will help to avoid missing a parameter or exchanging its order. The stack usage won't reduce, though, because the structure will keep using the stack. As I can't foresee the usage of this function call outside the core and by the GHES driver, I'm not sure what would be the better.
Anyway, I moved it to an structure in the enclosed patch.
Regards,
Mauro
--
edac: put all arguments for the raw error handling call into a struct
The number of arguments for edac_raw_mc_handle_error() is too big; put them into a structure.
drivers/edac/edac_core.h +21 -14
@@ -381,6 +381,25 @@ struct edac_pci_ctl_info {struct completion kobj_complete; }; +/* +* Raw error report structure +*/ +struct edac_raw_error_desc { +long grain; +u16 error_count; +int top_layer; +int mid_layer; +int low_layer; +unsigned long page_frame_number; +unsigned long offset_in_page; +unsigned long syndrome; +const char *msg; +const char *location; +const char *label; +const char *other_detail; +bool enable_per_layer_report; +}; +#define to_edac_pci_ctl_work (w) \ container_of(w, struct edac_pci_ctl_info,work)
@@ -455,20 +474,8 @@ extern int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci, unsigned long page);void edac_raw_mc_handle_error (const enum hw_event_mc_err_type type, -struct mem_ctl_info *mci, -long grain, -const u16 error_count, -const int top_layer, -const int mid_layer, -const int low_layer, -const unsigned long page_frame_number, -const unsigned long offset_in_page, -const unsigned long syndrome, -const char *msg, -const char *location, -const char *label, -const char *other_detail, -const bool enable_per_layer_report); +struct mem_ctl_info *mci, +struct edac_raw_error_desc *err); void edac_mc_handle_error(const enum hw_event_mc_err_type type, struct mem_ctl_info *mci,
drivers/edac/edac_mc.c +40 -58
168 lines not on this page · raw message
drivers/edac/ghes_edac.c +12 -8
@@ -162,15 +162,16 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg)void ghes_edac_report_mem_error (struct ghes *ghes,int sev,struct cper_sec_mem_err *mem_err) { +struct edac_raw_error_desc e;enum hw_event_mc_err_type type; -unsigned long page =0 , offset =0 , grain =0 ;char location[80 ]; -char *label ="unknown" ; + +memset (&e,0 ,sizeof (e));if (mem_err->validation_bits &CPER_MEM_VALID_PHYSICAL_ADDRESS ) { - page = mem_err->physical_addr >>PAGE_SHIFT ; - offset = mem_err->physical_addr & ~PAGE_MASK ; - grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK ); + e.page_frame_number = mem_err->physical_addr >>PAGE_SHIFT ; + e.offset_in_page = mem_err->physical_addr & ~PAGE_MASK ; + e.grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK ); }switch (sev) {
@@ -194,9 +195,12 @@ void ghes_edac_report_mem_error(struct ghes *ghes, int sev, mem_err->bit_pos);edac_dbg (3 ,"error at location %s\n" , location); -edac_raw_mc_handle_error (type, ghes->mci, grain,1 ,0 ,0 ,0 , - page, offset,0 , -"APEI" , location, label,"" ,0 ); + e.error_count =1 ; + e.msg ="APEI" ; + e.location = location; + e.label ="unknown" ; + e.other_detail ="" ; +edac_raw_mc_handle_error (type, ghes->mci, &e); }EXPORT_SYMBOL_GPL (ghes_edac_report_mem_error);
Borislav Petkov
maintainerRe: [PATCH EDAC 07/13] edac: add support for raw error reports
Quoted 3 lines · Mauro Carvalho Chehab
Well, for sure using an structure will help to avoid missing a parameter or exchanging its order. The stack usage won't reduce, though, because the structure will keep using the stack.
If you allocate it on the stack of the caller, yes. If you kmalloc it, no.
In any case, passing a pointer to struct edac_raw_error_desc only will allow on x86_64 (and i386 AFAICT) to use only registers to pass callee function arguments. Which is always a win. You probably need to stare at compiler output to see what gcc actually does with -O2 optimizations.
Quoted 2 lines
As I can't foresee the usage of this function call outside the core and by the GHES driver, I'm not sure what would be the better.
Having an error descriptor is always better, even if it were only for clarity's and simplicity's sake.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH EDAC 07/13] edac: add support for raw error reports
Em Fri, 15 Feb 2013 16:41:23 +0100
Borislav Petkov <[email protected]> escreveu:
Quoted 7 lines · Mauro Carvalho Chehab
Quoted 3 lines
Well, for sure using an structure will help to avoid missing a parameter or exchanging its order. The stack usage won't reduce, though, because the structure will keep using the stack.
If you allocate it on the stack of the caller, yes. If you kmalloc it, no.
Sure, but calling kmalloc while handling a memory error doesn't seem a very good idea, IMHO. So, better to either use an already allocated space (or the stack).
Quoted 5 lines
In any case, passing a pointer to struct
edac_raw_error_desconly will allow onx86_64(and i386 AFAICT) to use only registers to pass callee function arguments. Which is always a win. You probably need to stare at compiler output to see what gcc actually does with -O2 optimizations.
Yes, I know, but, on the other hand, there's the additional cost of copying almost all data into the structure.
Quoted 5 lines
Quoted 2 lines
As I can't foresee the usage of this function call outside the core and by the GHES driver, I'm not sure what would be the better.
Having an error descriptor is always better, even if it were only for clarity's and simplicity's sake.
Yes, the code is now clearer.
Ok, I'll keep this patch on my git. I'll likely fold it with the previous one on the final patchset.
Signature · 2 lines
Cheers, Mauro
Borislav Petkov
maintainerRe: [PATCH EDAC 07/13] edac: add support for raw error reports
Quoted 3 lines · Mauro Carvalho Chehab
Sure, but calling kmalloc while handling a memory error doesn't seem a very good idea, IMHO. So, better to either use an already allocated space (or the stack).
Either that, or prealloc a buffer on EDAC initialization. You probably won't need more than one in 99% of the cases so if you keep it simple with a single static buffer for starters, that would probably be the cleanest solution.
Quoted 2 lines
Yes, I know, but, on the other hand, there's the additional cost of copying almost all data into the structure.
That's very easily paralelizable on out-of-order CPUs (I'd say, all of them which need to run EDAC, can do that :-)) so it wouldn't hurt.
Also, you could allocate the struct in the callers and work directly with its members before sending it down to edac_raw_mc_handle_error() - that would probably simplify the code a bit more.
Quoted 2 lines
Ok, I'll keep this patch on my git. I'll likely fold it with the previous one on the final patchset.
Yep.
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH EDAC 07/13] edac: add support for raw error reports
Em Fri, 15 Feb 2013 17:02:57 +0100
Borislav Petkov <[email protected]> escreveu:
Quoted 13 lines · Mauro Carvalho Chehab
Quoted 3 lines
Sure, but calling kmalloc while handling a memory error doesn't seem a very good idea, IMHO. So, better to either use an already allocated space (or the stack).
Either that, or prealloc a buffer on EDAC initialization. You probably won't need more than one in 99% of the cases so if you keep it simple with a single static buffer for starters, that would probably be the cleanest solution.
Quoted 2 lines
Yes, I know, but, on the other hand, there's the additional cost of copying almost all data into the structure.
Quoted 6 lines
That's very easily paralelizable on out-of-order CPUs (I'd say, all of them which need to run EDAC, can do that :-)) so it wouldn't hurt.
Also, you could allocate the struct in the callers and work directly with its members before sending it down to
edac_raw_mc_handle_error()- that would probably simplify the code a bit more.
Yeah, pre-allocating a buffer is something that it was on my plans. It seems it is time to do it in a clean way. I prefer to keep this as a separate patch from 07/13, as it has a different rationale, and mixing with 07/13 would just mix two different subjects.
Also, having it separate helps reviewing.
---
[PATCH] edac: put all arguments for the raw error handling call into a struct
The number of arguments for edac_raw_mc_handle_error() is too big; put them into a structure and allocate space for it inside edac_mc_alloc().
That reduces a lot the stack usage and simplifies the raw API call.
Tested with sb_edac driver and MCE error injection. Worked as expected:
[ 143.066100] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0) [ 143.086424] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0) [ 143.106570] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0) [ 143.126712] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0)
drivers/edac/edac_core.h +13 -14
@@ -454,21 +454,20 @@ extern struct mem_ctl_info *edac_mc_del_mc(struct device *dev);extern int edac_mc_find_csrow_by_page (struct mem_ctl_info *mci,unsigned long page); +static inline void edac_raw_error_desc_clean (struct edac_raw_error_desc *e) +{ +int offset = offsetof(struct edac_raw_error_desc , grain); + + *e->location ='\0' ; + *e->label ='\0' ; + +memset (e + offset,0 ,sizeof (*e) - offset); +} + +void edac_raw_mc_handle_error (const enum hw_event_mc_err_type type, -struct mem_ctl_info *mci, -long grain, -const u16 error_count, -const int top_layer, -const int mid_layer, -const int low_layer, -const unsigned long page_frame_number, -const unsigned long offset_in_page, -const unsigned long syndrome, -const char *msg, -const char *location, -const char *label, -const char *other_detail, -const bool enable_per_layer_report); +struct mem_ctl_info *mci, +struct edac_raw_error_desc *e); void edac_mc_handle_error(const enum hw_event_mc_err_type type, struct mem_ctl_info *mci,
drivers/edac/edac_mc.c +60 -70
238 lines not on this page · raw message
drivers/edac/ghes_edac.c +15 -11
@@ -175,15 +175,20 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg)void ghes_edac_report_mem_error (struct ghes *ghes,int sev,struct cper_sec_mem_err *mem_err) { +struct edac_raw_error_desc *e = &ghes->mci->error_event;enum hw_event_mc_err_type type; -unsigned long page =0 , offset =0 , grain =0 ; -char location[80 ]; -char *label ="unknown" ; + +/* Cleans the error report buffer */ +edac_raw_error_desc_clean (e); + e->error_count =1 ; + e->msg ="APEI" ; + e->label ="unknown" ; + e->other_detail ="" ;if (mem_err->validation_bits &CPER_MEM_VALID_PHYSICAL_ADDRESS ) { - page = mem_err->physical_addr >>PAGE_SHIFT ; - offset = mem_err->physical_addr & ~PAGE_MASK ; - grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK ); + e->page_frame_number = mem_err->physical_addr >>PAGE_SHIFT ; + e->offset_in_page = mem_err->physical_addr & ~PAGE_MASK ; + e->grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK ); }switch (sev) {
@@ -201,15 +206,14 @@ void ghes_edac_report_mem_error(struct ghes *ghes, int sev, type =HW_EVENT_ERR_INFO ; } -sprintf (location,"node:%d card:%d module:%d bank:%d device:%d row: %d column:%d bit_pos:%d" , +sprintf (e->location, +"node:%d card:%d module:%d bank:%d device:%d row: %d column:%d bit_pos:%d" , mem_err->node, mem_err->card, mem_err->module, mem_err->bank, mem_err->device, mem_err->row, mem_err->column, mem_err->bit_pos); -edac_dbg (3 ,"error at location %s\n" , location); +edac_dbg (3 ,"error at location %s\n" , e->location); -edac_raw_mc_handle_error (type, ghes->mci, grain,1 ,0 ,0 ,0 , - page, offset,0 , -"APEI" , location, label,"" ,0 ); +edac_raw_mc_handle_error (type, ghes->mci, e); }EXPORT_SYMBOL_GPL (ghes_edac_report_mem_error);
include/linux/edac.h +46 -0
58 lines not on this page · raw message
Borislav Petkov
maintainerRe: [PATCH EDAC 07/13] edac: add support for raw error reports
Quoted 6 lines · Mauro Carvalho Chehab
Yeah, pre-allocating a buffer is something that it was on my plans. It seems it is time to do it in a clean way. I prefer to keep this as a separate patch from 07/13, as it has a different rationale, and mixing with 07/13 would just mix two different subjects.
Also, having it separate helps reviewing.
Yep.
Quoted 24 lines
---
[PATCH] edac: put all arguments for the raw error handling call into a struct
The number of arguments for
edac_raw_mc_handle_error()is too big; put them into a structure and allocate space for it insideedac_mc_alloc().That reduces a lot the stack usage and simplifies the raw API call.
Tested with
sb_edacdriver and MCE error injection. Worked as expected:[ 143.066100] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0) [ 143.086424] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0) [ 143.106570] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0) [ 143.126712] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0)Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/edac/edac_core.h +0
-0
drivers/edac/edac_core.h extern struct mem_ctl_info *edac_mc_del_mc(struct device *dev); · line 462
Quoted 9 lines
drivers/edac/edac_core.h +6
-0@@ -454,21 +454,20 @@ extern struct mem_ctl_info *edac_mc_del_mc(struct device *dev);extern int edac_mc_find_csrow_by_page (struct mem_ctl_info *mci,unsigned long page); +static inline void edac_raw_error_desc_clean (struct edac_raw_error_desc *e) +{ +int offset = offsetof(struct edac_raw_error_desc , grain); + + *e->location ='\0' ; + *e->label ='\0' ;
Why the special handling? Why not memset the whole thing?
Quoted 55 lines
drivers/edac/edac_core.h +7
-14+ +memset (e + offset,0 ,sizeof (*e) - offset); +} + +void edac_raw_mc_handle_error (const enum hw_event_mc_err_type type, -struct mem_ctl_info *mci, -long grain, -const u16 error_count, -const int top_layer, -const int mid_layer, -const int low_layer, -const unsigned long page_frame_number, -const unsigned long offset_in_page, -const unsigned long syndrome, -const char *msg, -const char *location, -const char *label, -const char *other_detail, -const bool enable_per_layer_report); +struct mem_ctl_info *mci, +struct edac_raw_error_desc *e); void edac_mc_handle_error(const enum hw_event_mc_err_type type, struct mem_ctl_info *mci,drivers/edac/edac_mc.c +11
-0@@ -42,6 +42,12 @@static DEFINE_MUTEX (mem_ctls_mutex);static LIST_HEAD (mc_devices); +/* Maximum size of the location string */ +#define LOCATION_SIZE 80 + +/* String used to join two or more labels */ +#define OTHER_LABEL " or " +/* * Used to lock EDAC MC to just one module, avoiding two drivers e. g. * apei/ghes and i7core_edac to be used at the same time. @@ -232,6 +238,11 @@ static void _edac_mc_free(struct mem_ctl_info *mci) }kfree (mci->csrows); } + +/* Frees the error report string area */ +kfree (mci->error_event.location); +kfree (mci->error_event.label); +kfree (mci); }
drivers/edac/edac_mc.c struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, · line 463
Quoted 8 lines
drivers/edac/edac_mc.c +5
-0@@ -445,6 +456,12 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, } } +/* Allocate memory for the error report */ + mci->error_event.location =kmalloc (LOCATION_SIZE ,GFP_KERNEL ); + mci->error_event.label =kmalloc ((EDAC_MC_LABEL_LEN +1 + +sizeof (OTHER_LABEL )) * mci->tot_dimms, +GFP_KERNEL );
I see, those are separate strings. Why not embed them into struct edac_raw_error_desc? This would simplify the whole buffer handling even more and you won't need to kmalloc them.
Also just FYI, everytime you do kmalloc, you need to handle the case where it returns an error.
[ … ]
Quoted 18 lines
drivers/edac/edac_mc.c +2
-5@@ -1174,18 +1162,26 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type,const char *msg, const char *other_detail) { - /* FIXME: too much for stack: move it to some pre-alocated area */ - char location[80]; -char label[(EDAC_MC_LABEL_LEN +1 +sizeof (OTHER_LABEL )) * mci->tot_dimms]; char *p;int row =-1 , chan =-1 ;int pos[EDAC_MAX_LAYERS ] = { top_layer, mid_layer, low_layer };int i; -long grain; -bool enable_per_layer_report = false; +struct edac_raw_error_desc *e = &mci->error_event;edac_dbg (3 ,"MC%d\n" , mci->mc_idx); +/* Fills the error report buffer */
drivers/edac/edac_mc.c void edac_mc_handle_error(const enum hw_event_mc_err_type type, · line 1183
Quoted 10 lines
drivers/edac/edac_mc.c +10
-0+edac_raw_error_desc_clean (e); + e->error_count = error_count; + e->top_layer = top_layer; + e->mid_layer = mid_layer; + e->low_layer = low_layer; + e->page_frame_number = page_frame_number; + e->offset_in_page = offset_in_page; + e->syndrome = syndrome; + e->msg = msg; + e->other_detail = other_detail;
Btw, this could be simplified even further if we would've made it like this from the get-go: if lowlevel EDAC drivers would populate the buffer already, we wouldn't need to do that copying again. And, it is ironic but I did that already in amd64_edac - see __log_bus_error, where I have an amd64_edac-specific struct err_info descriptor which is being handed off up.
Oh well, maybe something for later.
[ … ]
Quoted 5 lines
drivers/edac/edac_mc.c +0
-1@@ -1302,14 +1297,9 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type, edac_layer_name[mci->layers[i].type], pos[i]); } -if (p > location)
drivers/edac/edac_mc.c void edac_mc_handle_error(const enum hw_event_mc_err_type type, · line 1303
Quoted 10 lines
drivers/edac/edac_mc.c +2
-6+if (p > e->location) *(p -1 ) ='\0' ; -edac_raw_mc_handle_error (type, mci, grain, error_count, - top_layer, mid_layer, low_layer, - page_frame_number, offset_in_page, - syndrome, - msg, location, label, other_detail, - enable_per_layer_report); +edac_raw_mc_handle_error (type, mci, e);
Ok, now this hunk looks nice. :-)
[ … ]
Quoted 52 lines
include/linux/edac.h +40
-0@@ -555,6 +555,46 @@ struct errcount_attribute_data {int layer0, layer1, layer2; }; +/** +* edac_raw_error_desc - Raw error report structure +* @grain: minimum granularity for an error report, in bytes +* @error_count: number of errors of the same type +* @top_layer: top layer of the error (layer[0]) +* @mid_layer: middle layer of the error (layer[1]) +* @low_layer: low layer of the error (layer[2]) +* @page_frame_number: page where the error happened +* @offset_in_page: page offset +* @syndrome: syndrome of the error (or 0 if unknown or if +* the syndrome is not applicable) +* @msg: error message +* @location: location of the error +* @label: label of the affected DIMM(s) +* @other_detail: other driver-specific detail about the error +* @enable_per_layer_report: if false, the error affects all layers +* (typically, a memory controller error) +*/ +struct edac_raw_error_desc { +/* +* NOTE: everything before grain won't be cleaned by +* edac_raw_error_desc_clean() +*/ +char *location; +char *label; +long grain; + +/* the vars below and grain will be cleaned on every new error report */ +u16 error_count; +int top_layer; +int mid_layer; +int low_layer; +unsigned long page_frame_number; +unsigned long offset_in_page; +unsigned long syndrome; +const char *msg; +const char *other_detail; +bool enable_per_layer_report; +}; +/* MEMORY controller information structure */ struct mem_ctl_info {
include/linux/edac.h struct mem_ctl_info { · line 710
Quoted 8 lines
include/linux/edac.h +5
-0@@ -663,6 +703,12 @@ struct mem_ctl_info {/* work struct for this MC */ struct delayed_work work; +/* +* Used to report an error - by being at the global struct +* makes the memory allocated by the EDAC core +*/ +struct edac_raw_error_desc error_event;
I think 'error_desc' is clearer. This way you can refer to it everywhere with mci->error_desc and you know what it is. ->error_event is kinda ambiguous IMHO.
Signature · 9 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlRe: [PATCH EDAC 07/13] edac: add support for raw error reports
Em Sat, 16 Feb 2013 17:57:48 +0100
Borislav Petkov <[email protected]> escreveu:
Quoted 37 lines · Mauro Carvalho Chehab
Quoted 6 lines
Yeah, pre-allocating a buffer is something that it was on my plans. It seems it is time to do it in a clean way. I prefer to keep this as a separate patch from 07/13, as it has a different rationale, and mixing with 07/13 would just mix two different subjects.
Also, having it separate helps reviewing.
Yep.
Quoted 27 lines
---
[PATCH] edac: put all arguments for the raw error handling call into a struct
The number of arguments for
edac_raw_mc_handle_error()is too big; put them into a structure and allocate space for it insideedac_mc_alloc().That reduces a lot the stack usage and simplifies the raw API call.
Tested with
sb_edacdriver and MCE error injection. Worked as expected:[ 143.066100] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0) [ 143.086424] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0) [ 143.106570] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0) [ 143.126712] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0)Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/edac/edac_core.h +0
-0@@ -454,21 +454,20 @@ extern struct mem_ctl_info *edac_mc_del_mc(struct device *dev);extern int edac_mc_find_csrow_by_page (struct mem_ctl_info *mci,unsigned long page);
Quoted 8 lines
drivers/edac/edac_core.h extern struct mem_ctl_info *edac_mc_del_mc(struct device *dev); · line 462
Quoted 6 lines
drivers/edac/edac_core.h +6
-0+static inline void edac_raw_error_desc_clean (struct edac_raw_error_desc *e) +{ +int offset = offsetof(struct edac_raw_error_desc , grain); + + *e->location ='\0' ; + *e->label ='\0' ;Why the special handling? Why not memset the whole thing?
We don't want to clean the pointers for the allocated area, just to clean the strings.
Quoted 59 lines
Quoted 59 lines
drivers/edac/edac_core.h +7
-14+ +memset (e + offset,0 ,sizeof (*e) - offset); +} + +void edac_raw_mc_handle_error (const enum hw_event_mc_err_type type, -struct mem_ctl_info *mci, -long grain, -const u16 error_count, -const int top_layer, -const int mid_layer, -const int low_layer, -const unsigned long page_frame_number, -const unsigned long offset_in_page, -const unsigned long syndrome, -const char *msg, -const char *location, -const char *label, -const char *other_detail, -const bool enable_per_layer_report); +struct mem_ctl_info *mci, +struct edac_raw_error_desc *e); void edac_mc_handle_error(const enum hw_event_mc_err_type type, struct mem_ctl_info *mci,drivers/edac/edac_mc.c +11
-0@@ -42,6 +42,12 @@static DEFINE_MUTEX (mem_ctls_mutex);static LIST_HEAD (mc_devices); +/* Maximum size of the location string */ +#define LOCATION_SIZE 80 + +/* String used to join two or more labels */ +#define OTHER_LABEL " or " +/* * Used to lock EDAC MC to just one module, avoiding two drivers e. g. * apei/ghes and i7core_edac to be used at the same time. @@ -232,6 +238,11 @@ static void _edac_mc_free(struct mem_ctl_info *mci) }kfree (mci->csrows); } + +/* Frees the error report string area */ +kfree (mci->error_event.location); +kfree (mci->error_event.label); +kfree (mci); }@@ -445,6 +456,12 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, } }
Quoted 9 lines
drivers/edac/edac_mc.c struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, · line 463
Quoted 5 lines
drivers/edac/edac_mc.c +5
-0+/* Allocate memory for the error report */ + mci->error_event.location =kmalloc (LOCATION_SIZE ,GFP_KERNEL ); + mci->error_event.label =kmalloc ((EDAC_MC_LABEL_LEN +1 + +sizeof (OTHER_LABEL )) * mci->tot_dimms, +GFP_KERNEL );I see, those are separate strings. Why not embed them into struct
edac_raw_error_desc? This would simplify the whole buffer handling even more and you won't need to kmalloc them.
We could do it for the location. The space for label, however, depends on how many DIMMs are in the system, as multiple dimm's may be present, and the core will point to all possible affected DIMMs.
Ok, perhaps we could just allocate one big area for it (like one page), as this would very likely be enough for it, and change the logic to take the buffer size into account when filling it.
Quoted 2 lines
Also just FYI, everytime you do kmalloc, you need to handle the case where it returns an error.
Yeah, I forgot to add the error handling logic.
Quoted 38 lines
[ … ]
Quoted 18 lines
drivers/edac/edac_mc.c +2
-5@@ -1174,18 +1162,26 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type,const char *msg, const char *other_detail) { - /* FIXME: too much for stack: move it to some pre-alocated area */ - char location[80]; -char label[(EDAC_MC_LABEL_LEN +1 +sizeof (OTHER_LABEL )) * mci->tot_dimms]; char *p;int row =-1 , chan =-1 ;int pos[EDAC_MAX_LAYERS ] = { top_layer, mid_layer, low_layer };int i; -long grain; -bool enable_per_layer_report = false; +struct edac_raw_error_desc *e = &mci->error_event;edac_dbg (3 ,"MC%d\n" , mci->mc_idx); +/* Fills the error report buffer */ drivers/edac/edac_mc.c void edac_mc_handle_error(const enum hw_event_mc_err_type type, · line 1183
Quoted 10 lines
drivers/edac/edac_mc.c +10
-0+edac_raw_error_desc_clean (e); + e->error_count = error_count; + e->top_layer = top_layer; + e->mid_layer = mid_layer; + e->low_layer = low_layer; + e->page_frame_number = page_frame_number; + e->offset_in_page = offset_in_page; + e->syndrome = syndrome; + e->msg = msg; + e->other_detail = other_detail;Btw, this could be simplified even further if we would've made it like this from the get-go: if lowlevel EDAC drivers would populate the buffer already, we wouldn't need to do that copying again. And, it is ironic but I did that already in
amd64_edac- see__log_bus_error, where I have an amd64_edac-specific structerr_infodescriptor which is being handed off up.
Quoted 1 line
Oh well, maybe something for later.
I agree, but this is a separate patch, IMHO. It will require to change the logic again on all drivers, and re-test compilation on all supported archs.
Quoted 77 lines
[ … ]
Quoted 5 lines
drivers/edac/edac_mc.c +0
-1@@ -1302,14 +1297,9 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type, edac_layer_name[mci->layers[i].type], pos[i]); } -if (p > location)drivers/edac/edac_mc.c void edac_mc_handle_error(const enum hw_event_mc_err_type type, · line 1303
Quoted 10 lines
drivers/edac/edac_mc.c +2
-6+if (p > e->location) *(p -1 ) ='\0' ; -edac_raw_mc_handle_error (type, mci, grain, error_count, - top_layer, mid_layer, low_layer, - page_frame_number, offset_in_page, - syndrome, - msg, location, label, other_detail, - enable_per_layer_report); +edac_raw_mc_handle_error (type, mci, e);Ok, now this hunk looks nice. :-)
[ … ]
Quoted 55 lines
include/linux/edac.h +40
-0@@ -555,6 +555,46 @@ struct errcount_attribute_data {int layer0, layer1, layer2; }; +/** +* edac_raw_error_desc - Raw error report structure +* @grain: minimum granularity for an error report, in bytes +* @error_count: number of errors of the same type +* @top_layer: top layer of the error (layer[0]) +* @mid_layer: middle layer of the error (layer[1]) +* @low_layer: low layer of the error (layer[2]) +* @page_frame_number: page where the error happened +* @offset_in_page: page offset +* @syndrome: syndrome of the error (or 0 if unknown or if +* the syndrome is not applicable) +* @msg: error message +* @location: location of the error +* @label: label of the affected DIMM(s) +* @other_detail: other driver-specific detail about the error +* @enable_per_layer_report: if false, the error affects all layers +* (typically, a memory controller error) +*/ +struct edac_raw_error_desc { +/* +* NOTE: everything before grain won't be cleaned by +* edac_raw_error_desc_clean() +*/ +char *location; +char *label; +long grain; + +/* the vars below and grain will be cleaned on every new error report */ +u16 error_count; +int top_layer; +int mid_layer; +int low_layer; +unsigned long page_frame_number; +unsigned long offset_in_page; +unsigned long syndrome; +const char *msg; +const char *other_detail; +bool enable_per_layer_report; +}; +/* MEMORY controller information structure */ struct mem_ctl_info {@@ -663,6 +703,12 @@ struct mem_ctl_info {/* work struct for this MC */ struct delayed_work work;
Quoted 9 lines
include/linux/edac.h struct mem_ctl_info { · line 710
Quoted 5 lines
include/linux/edac.h +5
-0+/* +* Used to report an error - by being at the global struct +* makes the memory allocated by the EDAC core +*/ +struct edac_raw_error_desc error_event;I think '
error_desc' is clearer. This way you can refer to it everywhere withmci->error_descand you know what it is. ->error_event is kinda ambiguous IMHO.
Ok, I'll replace it.
Signature · 6 lines
Cheers, Mauro -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Borislav Petkov
maintainerRe: [PATCH EDAC 07/13] edac: add support for raw error reports
Quoted 7 lines · Mauro Carvalho Chehab
We could do it for the location. The space for label, however, depends on how many DIMMs are in the system, as multiple dimm's may be present, and the core will point to all possible affected DIMMs.
Ok, perhaps we could just allocate one big area for it (like one page), as this would very likely be enough for it, and change the logic to take the buffer size into account when filling it.
Or, in the case where ->label is all dimms on the mci, you simply put "All DIMMs on MCI%d" in there and done. Simple.
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH EDAC 07/13] edac: add support for raw error reports
Em Mon, 18 Feb 2013 14:52:51 +0100
Borislav Petkov <[email protected]> escreveu:
Quoted 11 lines · Mauro Carvalho Chehab
Quoted 7 lines
We could do it for the location. The space for label, however, depends on how many DIMMs are in the system, as multiple dimm's may be present, and the core will point to all possible affected DIMMs.
Ok, perhaps we could just allocate one big area for it (like one page), as this would very likely be enough for it, and change the logic to take the buffer size into account when filling it.
Or, in the case where ->label is all dimms on the mci, you simply put "All DIMMs on MCI%d" in there and done. Simple.
The core does this already when it has no glue at all about where is the error.
The core is prepared to the case where the location is only half-filled, as this is a common scenario on the drivers, and important enough on some memory controllers.
As already discussed, on most memory controllers nowadays, the memory controller can't point to a single DIMM, as the error correction code takes 128 bits (2 DIMMs). It is impossible for the error correction code to determine on what DIMM an uncorrected error happened[1].
With Nehalem memory controllers, depending on the memory configuration, the minimal DIMM granularity for an uncorrected error can be even worse:
4 DIMMs, if 128-bits error correction code and mirror mode are both enabled.
There are some border cases where the driver can simply not discover on what channel or on what dimm(or csrow) inside a channel the error happened. The error could be associated with some failure at the logic or at the bus that communicated with the Advanced Memory Buffers on an FB-DIMM memory controller, for example.
So, the real core's worse case scenario would be if the driver can't determine on what DIMM inside a channel the error happened. As a channel can have a large number of DIMMs[2] the allocated area for the label should be conservative.
(16? Not sure what's the worse case),
[1] such error can even not be fatal, if that particular address is unused.
[2] Currently, up to 8, according with:
$for i in $(git grep "layers.*size\s*=" drivers/edac|perl -ne 'print "$1 " if (m/\=\s*([A-Z][^\s]+);/);'); do echo $i; git grep $i drivers/edac; done|grep define|perl -ne 'print "$1 " if (m/define\s+[^\s]+\s(\d+)/)' 8 8 2 2 4 2 3 3 3 8 4 4 3 3 1 1 4
and
$ git grep "layers.*size\s*=" drivers/edac|perl -ne 'print "$1 " if (m/\=\s*(\d+);/);' 1 1 1 1 2 2 8 4 1 1 1 1
Nothing prevents that a driver would have more than 8 DIMMs per layer in the future.
Signature · 2 lines
Cheers, Mauro
Re: [PATCH EDAC 07/13] edac: add support for raw error reports
Em Mon, 18 Feb 2013 12:24:29 -0300
Mauro Carvalho Chehab <[email protected]> escreveu:
Quoted 52 lines
Em Mon, 18 Feb 2013 14:52:51 +0100
Borislav Petkov <[email protected]> escreveu:Quoted 11 lines · Mauro Carvalho Chehab
Quoted 7 lines
We could do it for the location. The space for label, however, depends on how many DIMMs are in the system, as multiple dimm's may be present, and the core will point to all possible affected DIMMs.
Ok, perhaps we could just allocate one big area for it (like one page), as this would very likely be enough for it, and change the logic to take the buffer size into account when filling it.
Or, in the case where ->label is all dimms on the mci, you simply put "All DIMMs on MCI%d" in there and done. Simple.
The core does this already when it has no glue at all about where is the error.
The core is prepared to the case where the location is only half-filled, as this is a common scenario on the drivers, and important enough on some memory controllers.
As already discussed, on most memory controllers nowadays, the memory controller can't point to a single DIMM, as the error correction code takes 128 bits (2 DIMMs). It is impossible for the error correction code to determine on what DIMM an uncorrected error happened[1].
With Nehalem memory controllers, depending on the memory configuration, the minimal DIMM granularity for an uncorrected error can be even worse:
4 DIMMs, if 128-bits error correction code and mirror mode are both enabled.There are some border cases where the driver can simply not discover on what channel or on what dimm(or csrow) inside a channel the error happened. The error could be associated with some failure at the logic or at the bus that communicated with the Advanced Memory Buffers on an FB-DIMM memory controller, for example.
So, the real core's worse case scenario would be if the driver can't determine on what DIMM inside a channel the error happened. As a channel can have a large number of DIMMs[2] the allocated area for the label should be conservative.
(16? Not sure what's the worse case),
[1] such error can even not be fatal, if that particular address is unused.
[2] Currently, up to 8, according with:
$for i in $(git grep "layers.*size\s*=" drivers/edac|perl -ne 'print "$1 " if (m/\=\s*([A-Z][^\s]+);/);'); do echo $i; git grep $i drivers/edac; done|grep define|perl -ne 'print "$1 " if (m/define\s+[^\s]+\s(\d+)/)' 8 8 2 2 4 2 3 3 3 8 4 4 3 3 1 1 4
Quoted 6 lines
and
$ git grep "layers.*size\s*=" drivers/edac|perl -ne 'print "$1 " if (m/\=\s*(\d+);/);' 1 1 1 1 2 2 8 4 1 1 1 1Nothing prevents that a driver would have more than 8 DIMMs per layer in the future.
I suspect that you'll be happy with the enclosed patch ;)
It embeds the two string buffers at the mci structure. There are space there for up to EDAC_MAX_LABELS at the "mci->label" string. If an error affects more than EDAC_MAX_LABELS, the report logic will write "any memory", just like what happens when the driver can't discover where the error is.
Tested with sb_edac driver.
Regards,
Mauro
[PATCH EDAC] edac: put all arguments for the raw error handling call into a struct
The number of arguments for edac_raw_mc_handle_error() is too big; put them into a structure and allocate space for it inside edac_mc_alloc().
That reduces a lot the stack usage and simplifies the raw API call.
Tested with sb_edac driver and MCE error injection. Worked as expected:
[ 143.066100] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0) [ 143.086424] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0) [ 143.106570] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0) [ 143.126712] EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x320 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0)
drivers/edac/edac_core.h +2 -14
@@ -455,20 +455,8 @@ extern int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci, unsigned long page);void edac_raw_mc_handle_error (const enum hw_event_mc_err_type type, -struct mem_ctl_info *mci, -long grain, -const u16 error_count, -const int top_layer, -const int mid_layer, -const int low_layer, -const unsigned long page_frame_number, -const unsigned long offset_in_page, -const unsigned long syndrome, -const char *msg, -const char *location, -const char *label, -const char *other_detail, -const bool enable_per_layer_report); +struct mem_ctl_info *mci, +struct edac_raw_error_desc *e); void edac_mc_handle_error(const enum hw_event_mc_err_type type, struct mem_ctl_info *mci,
drivers/edac/edac_mc.c +49 -71
209 lines not on this page · raw message
drivers/edac/ghes_edac.c +15 -11
@@ -175,15 +175,20 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg)void ghes_edac_report_mem_error (struct ghes *ghes,int sev,struct cper_sec_mem_err *mem_err) { +struct edac_raw_error_desc *e = &ghes->mci->error_desc;enum hw_event_mc_err_type type; -unsigned long page =0 , offset =0 , grain =0 ; -char location[80 ]; -char *label ="unknown" ; + +/* Cleans the error report buffer */ +memset (e,0 ,sizeof (*e)); + e->error_count =1 ; + e->msg ="APEI" ; +strcpy (e->label,"unknown" ); + e->other_detail ="" ;if (mem_err->validation_bits &CPER_MEM_VALID_PHYSICAL_ADDRESS ) { - page = mem_err->physical_addr >>PAGE_SHIFT ; - offset = mem_err->physical_addr & ~PAGE_MASK ; - grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK ); + e->page_frame_number = mem_err->physical_addr >>PAGE_SHIFT ; + e->offset_in_page = mem_err->physical_addr & ~PAGE_MASK ; + e->grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK ); }switch (sev) {
@@ -201,15 +206,14 @@ void ghes_edac_report_mem_error(struct ghes *ghes, int sev, type =HW_EVENT_ERR_INFO ; } -sprintf (location,"node:%d card:%d module:%d bank:%d device:%d row: %d column:%d bit_pos:%d" , +sprintf (e->location, +"node:%d card:%d module:%d bank:%d device:%d row: %d column:%d bit_pos:%d" , mem_err->node, mem_err->card, mem_err->module, mem_err->bank, mem_err->device, mem_err->row, mem_err->column, mem_err->bit_pos); -edac_dbg (3 ,"error at location %s\n" , location); +edac_dbg (3 ,"error at location %s\n" , e->location); -edac_raw_mc_handle_error (type, ghes->mci, grain,1 ,0 ,0 ,0 , - page, offset,0 , -"APEI" , location, label,"" ,0 ); +edac_raw_mc_handle_error (type, ghes->mci, e); }EXPORT_SYMBOL_GPL (ghes_edac_report_mem_error);
include/linux/edac.h +56 -0
76 lines not on this page · raw message
PATCH 8/13 ghes_edac: add support for reporting errors via EDAC
In reply to Mauro Carvalho ChehabNow that the EDAC core is capable of just forward the errors via the userspace API, add a report mechanism for the GHES errors.
--- drivers/edac/ghes_edac.c | 36 +++++++++++++++++++++++++++++++++++- include/linux/edac.h | 1 + 2 files changed, 36 insertions(+), 1 deletion(-)
drivers/edac/ghes_edac.c +35 -1
@@ -9,8 +9,42 @@ static DEFINE_MUTEX(ghes_edac_lock);static int ghes_edac_mc_num;void ghes_edac_report_mem_error (struct ghes *ghes,int sev, -struct cper_sec_mem_err *mem_err) +struct cper_sec_mem_err *mem_err) { +enum hw_event_mc_err_type type; +unsigned long page =0 , offset =0 , grain =0 ; +char location[80 ]; +char *label ="unknown" ; + +if (mem_err->validation_bits &CPER_MEM_VALID_PHYSICAL_ADDRESS ) { + page = mem_err->physical_addr >>PAGE_SHIFT ; + offset = mem_err->physical_addr & ~PAGE_MASK ; + grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK ); + } + +switch (sev) { +case GHES_SEV_CORRECTED : + type =HW_EVENT_ERR_CORRECTED ; +break ; +case GHES_SEV_RECOVERABLE : + type =HW_EVENT_ERR_UNCORRECTED ; +break ; +case GHES_SEV_PANIC : + type =HW_EVENT_ERR_FATAL ; +break ; +default : +case GHES_SEV_NO : + type =HW_EVENT_ERR_INFO ; + } + +sprintf (location,"node:%d card:%d module:%d bank:%d device:%d row: %d column:%d bit_pos:%d" , + mem_err->node, mem_err->card, mem_err->module, + mem_err->bank, mem_err->device, mem_err->row, mem_err->column, + mem_err->bit_pos); + +edac_raw_mc_handle_error (type, ghes->mci, grain,1 ,0 ,0 ,0 , + page, offset,0 , +"APEI" , location, label,"" ,0 ); }EXPORT_SYMBOL_GPL (ghes_edac_report_mem_error);
include/linux/edac.h +1 -0
@@ -100,6 +100,7 @@ enum hw_event_mc_err_type {HW_EVENT_ERR_CORRECTED ,HW_EVENT_ERR_UNCORRECTED ,HW_EVENT_ERR_FATAL , + HW_EVENT_ERR_INFO, };/**
Signature · 1 line
1.8.1.2
PATCH 9/13 ghes_edac: do a better job of filling EDAC DIMM info
In reply to Mauro Carvalho ChehabInstead of just faking a random value for the DIMM data, get the information that it is available via DMI table.
--- drivers/edac/ghes_edac.c | 192 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 180 insertions(+), 12 deletions(-)
drivers/edac/ghes_edac.c +180 -12
@@ -1,5 +1,6 @@#include <acpi/ghes.h> #include <linux/edac.h> +#include <linux/dmi.h> #include "edac_core.h" #define GHES_PFX "ghes_edac: "
@@ -8,6 +9,155 @@static DEFINE_MUTEX (ghes_edac_lock);static int ghes_edac_mc_num; +/* Memory Device - Type 17 of SMBIOS spec */ +struct memdev_dmi_entry { +u8 type; +u8 length; +u16 handle; +u16 phys_mem_array_handle; +u16 mem_err_info_handle; +u16 total_width; +u16 data_width; +u16 size; +u8 form_factor; +u8 device_set; +u8 device_locator; +u8 bank_locator; +u8 memory_type; +u16 type_detail; +u16 speed; +u8 manufacturer; +u8 serial_number; +u8 asset_tag; +u8 part_number; +u8 attributes; +u32 extended_size; +u16 conf_mem_clk_speed; +} __attribute__((__packed__ )); + +struct ghes_edac_dimm_fill { +struct mem_ctl_info *mci; +unsigned count; +}; + +char *memory_type[] = { + [MEM_EMPTY ] ="EMPTY" , + [MEM_RESERVED ] ="RESERVED" , + [MEM_UNKNOWN ] ="UNKNOWN" , + [MEM_FPM ] ="FPM" , + [MEM_EDO ] ="EDO" , + [MEM_BEDO ] ="BEDO" , + [MEM_SDR ] ="SDR" , + [MEM_RDR ] ="RDR" , + [MEM_DDR ] ="DDR" , + [MEM_RDDR ] ="RDDR" , + [MEM_RMBS ] ="RMBS" , + [MEM_DDR2 ] ="DDR2" , + [MEM_FB_DDR2 ] ="FB_DDR2" , + [MEM_RDDR2 ] ="RDDR2" , + [MEM_XDR ] ="XDR" , + [MEM_DDR3 ] ="DDR3" , + [MEM_RDDR3 ] ="RDDR3" , +}; + +static void ghes_edac_count_dimms (const struct dmi_header *dh,void *arg) +{ +int *num_dimm = arg; + +if (dh->type ==DMI_ENTRY_MEM_DEVICE ) + (*num_dimm)++; +} + +static void ghes_edac_dmidecode (const struct dmi_header *dh,void *arg) +{ +struct ghes_edac_dimm_fill *dimm_fill = arg; +struct mem_ctl_info *mci = dimm_fill->mci; + +if (dh->type ==DMI_ENTRY_MEM_DEVICE ) { +struct memdev_dmi_entry *entry = (struct memdev_dmi_entry *)dh; +struct dimm_info *dimm =EDAC_DIMM_PTR (mci->layers, mci->dimms, + mci->n_layers, + dimm_fill->count,0 ,0 ); + +if (entry->size ==0xffff ) { +pr_info (GHES_PFX "Can't get dimm size\n" ); + dimm->nr_pages =MiB_TO_PAGES (32 );/* Unknown */ + }else if (entry->size ==0x7fff ) { + dimm->nr_pages =MiB_TO_PAGES (entry->extended_size); + }else { +if (entry->size &1 <<15 ) + dimm->nr_pages =MiB_TO_PAGES ((entry->size & +0x7fff ) <<10 ); +else + dimm->nr_pages =MiB_TO_PAGES (entry->size); + } + +switch (entry->memory_type) { +case 0x12 : +if (entry->type_detail &1 <<13 ) + dimm->mtype =MEM_RDDR ; +else + dimm->mtype =MEM_DDR ; +break ; +case 0x13 : +if (entry->type_detail &1 <<13 ) + dimm->mtype =MEM_RDDR2 ; +else + dimm->mtype =MEM_DDR2 ; +break ; +case 0x14 : + dimm->mtype =MEM_FB_DDR2 ; +break ; +case 0x18 : +if (entry->type_detail &1 <<13 ) + dimm->mtype =MEM_RDDR3 ; +else + dimm->mtype =MEM_DDR3 ; +break ; +default : +if (entry->type_detail &1 <<6 ) + dimm->mtype =MEM_RMBS ; +else if ((entry->type_detail & ((1 <<7 ) | (1 <<13 ))) + == ((1 <<7 ) | (1 <<13 ))) + dimm->mtype =MEM_RDR ; +else if (entry->type_detail &1 <<7 ) + dimm->mtype =MEM_SDR ; +else if (entry->type_detail &1 <<9 ) + dimm->mtype =MEM_EDO ; +else + dimm->mtype =MEM_UNKNOWN ; + } + +/* +* Actually, we can only detect if the memory has bits for +* checksum or not +*/ +if (entry->total_width == entry->data_width) + dimm->edac_mode =EDAC_NONE ; +else + dimm->edac_mode =EDAC_SECDED ; + + dimm->dtype =DEV_UNKNOWN ; + dimm->grain =128 ;/* Likely, worse case */ + +/* +* FIXME: It shouldn't be hard to also fill the DIMM labels +*/ + +if (dimm->nr_pages) { +pr_info (GHES_PFX "DIMM%i: %s size = %d MB%s\n" , + dimm_fill->count, memory_type[dimm->mtype], +PAGES_TO_MiB (dimm->nr_pages), + (dimm->edac_mode !=EDAC_NONE )?"(ECC)" :"" ); +pr_info (GHES_PFX "\ttype %d, detail 0x%02x, width %d(total %d)\n" , + entry->memory_type, entry->type_detail, + entry->total_width, entry->data_width); + } + + dimm_fill->count++; + } +} +void ghes_edac_report_mem_error (struct ghes *ghes,int sev,struct cper_sec_mem_err *mem_err) {
@@ -50,14 +200,23 @@ EXPORT_SYMBOL_GPL(ghes_edac_report_mem_error);int ghes_edac_register (struct ghes *ghes,struct device *dev) { -int rc; +bool fake = false; +int rc, num_dimm =0 ;struct mem_ctl_info *mci;struct edac_mc_layer layers[1 ]; -struct csrow_info *csrow; -struct dimm_info *dimm; +struct ghes_edac_dimm_fill dimm_fill; + +/* Get the number of DIMMs */ +dmi_walk (ghes_edac_count_dimms, &num_dimm); + +/* Check if we've got a bogus BIOS */ +if (num_dimm ==0 ) { + fake = true; + num_dimm =1 ; + } layers[0 ].type =EDAC_MC_LAYER_ALL_MEM ; - layers[0 ].size =1 ; + layers[0 ].size = num_dimm; layers[0 ].is_virt_csrow = true;/*
@@ -65,6 +224,8 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev)* to avoid duplicated memory controller numbers */ mutex_lock (&ghes_edac_lock); +pr_info ("ghes_edac#%d: allocating space for %d dimms\n" , + ghes_edac_mc_num, num_dimm); mci =edac_mc_alloc (ghes_edac_mc_num,ARRAY_SIZE (layers), layers,0 );if (!mci) {pr_info (GHES_PFX "Can't allocate memory for EDAC data\n" );
@@ -83,15 +244,22 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) mci->ctl_name ="ghes_edac" ; mci->dev_name ="ghes" ; - csrow = mci->csrows[0 ]; - dimm = csrow->channels[0 ]->dimm; +if (!fake) { +/* Fill DIMM info from DMI */ + dimm_fill.count =0 ; + dimm_fill.mci = mci; +dmi_walk (ghes_edac_dmidecode, &dimm_fill); + }else { +struct dimm_info *dimm =EDAC_DIMM_PTR (mci->layers, mci->dimms, + mci->n_layers,0 ,0 ,0 ); -/* FIXME: FAKE DATA */ - dimm->nr_pages =1000 ; - dimm->grain =128 ; - dimm->mtype =MEM_UNKNOWN ; - dimm->dtype =DEV_UNKNOWN ; - dimm->edac_mode =EDAC_SECDED ; +pr_info (GHES_PFX "Crappy BIOS detected. Faking DIMM EDAC data\n" ); + dimm->nr_pages =1000 ; + dimm->grain =128 ; + dimm->mtype =MEM_UNKNOWN ; + dimm->dtype =DEV_UNKNOWN ; + dimm->edac_mode =EDAC_SECDED ; + } rc =edac_mc_add_mc (mci);if (rc <0 ) {
Signature · 1 line
1.8.1.2
PATCH 10/13 edac: better report error conditions in debug mode
In reply to Mauro Carvalho ChehabIt is hard to find what's wrong without a proper error report. Improve it, in debug mode.
--- drivers/edac/edac_mc_sysfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/edac/edac_mc_sysfs.c +6 -1
@@ -429,8 +429,12 @@ static int edac_create_csrow_objects(struct mem_ctl_info *mci)if (!nr_pages_per_csrow (csrow))continue ; err =edac_create_csrow_object (mci, mci->csrows[i], i); -if (err <0 ) +if (err <0 ) { +edac_dbg (1 , +"failure: create csrow objects for csrow %d\n" , + i); goto error; + } }return 0 ;
@@ -1007,6 +1011,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)edac_dbg (0 ,"creating device %s\n" ,dev_name (&mci->dev)); err =device_add (&mci->dev);if (err <0 ) { +edac_dbg (1 ,"failure: create device %s\n" ,dev_name (&mci->dev));bus_unregister (&mci->bus);kfree (mci->bus.name);return err;
Signature · 1 line
1.8.1.2
PATCH 11/13 edac: initialize the core earlier
In reply to Mauro Carvalho ChehabIn order for it to work with it builtin, the EDAC core should be initialized earlier, otherwise the ghes_edac driver initializes before edac_mc_sysfs_init() being called:
...
[ 4.998373] EDAC MC0: Giving out device to 'ghes_edac.c' 'ghes_edac': DEV ghes ... [ 4.998373] EDAC MC1: Giving out device to 'ghes_edac.c' 'ghes_edac': DEV ghes [ 6.519495] EDAC MC: Ver: 3.0.0 [ 6.523749] EDAC DEBUG: edac_mc_sysfs_init: device mc created
The net result is that no EDAC sysfs nodes will appear.
--- drivers/edac/edac_module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/edac_module.c +1 -1
@@ -146,7 +146,7 @@ static void __exit edac_exit(void)/* * Inform the kernel of our entry and exit points */ -module_init (edac_init); +subsys_initcall (edac_init);module_exit (edac_exit);MODULE_LICENSE ("GPL" );
Signature · 1 line
1.8.1.2
PATCH 12/13 ghes_edac.c: Don't credit the same memory dimm twice
In reply to Mauro Carvalho ChehabOn my tests on a 4xE5-4650 CPU's system, the GHES EDAC driver is called twice. As the SMBIOS DMI enumeration call will seek for the entire DIMM sockets in the system, on this machine, equipped with 128 GB of RAM, the memory is displayed twice:
+-----------------------+
| mc0 | mc1 |----------+-----------------------+
memory45: | 8192 MB | 8192 MB |
memory44: | 0 MB | 0 MB |
----------+-----------------------+
memory43: | 0 MB | 0 MB |
memory42: | 8192 MB | 8192 MB |
----------+-----------------------+
memory41: | 0 MB | 0 MB |
memory40: | 0 MB | 0 MB |
----------+-----------------------+
memory39: | 8192 MB | 8192 MB |
memory38: | 0 MB | 0 MB |
----------+-----------------------+
memory37: | 0 MB | 0 MB |
memory36: | 8192 MB | 8192 MB |
----------+-----------------------+
memory35: | 0 MB | 0 MB |
memory34: | 0 MB | 0 MB |
----------+-----------------------+
memory33: | 8192 MB | 8192 MB |
memory32: | 0 MB | 0 MB |
----------+-----------------------+
memory31: | 0 MB | 0 MB |
memory30: | 8192 MB | 8192 MB |
----------+-----------------------+
memory29: | 0 MB | 0 MB |
memory28: | 0 MB | 0 MB |
----------+-----------------------+
memory27: | 8192 MB | 8192 MB |
memory26: | 0 MB | 0 MB |
----------+-----------------------+
memory25: | 0 MB | 0 MB |
memory24: | 8192 MB | 8192 MB |
----------+-----------------------+
memory23: | 0 MB | 0 MB |
memory22: | 0 MB | 0 MB |
----------+-----------------------+
memory21: | 8192 MB | 8192 MB |
memory20: | 0 MB | 0 MB |
----------+-----------------------+
memory19: | 0 MB | 0 MB |
memory18: | 8192 MB | 8192 MB |
----------+-----------------------+
memory17: | 0 MB | 0 MB |
memory16: | 0 MB | 0 MB |
----------+-----------------------+
memory15: | 8192 MB | 8192 MB |
memory14: | 0 MB | 0 MB |
----------+-----------------------+
memory13: | 0 MB | 0 MB |
memory12: | 8192 MB | 8192 MB |
----------+-----------------------+
memory11: | 0 MB | 0 MB |
memory10: | 0 MB | 0 MB |
----------+-----------------------+
memory9: | 8192 MB | 8192 MB | memory8: | 0 MB | 0 MB | ----------+-----------------------+ memory7: | 0 MB | 0 MB | memory6: | 8192 MB | 8192 MB | ----------+-----------------------+ memory5: | 0 MB | 0 MB | memory4: | 0 MB | 0 MB | ----------+-----------------------+ memory3: | 8192 MB | 8192 MB | memory2: | 0 MB | 0 MB | ----------+-----------------------+ memory1: | 0 MB | 0 MB | memory0: | 8192 MB | 8192 MB |
----------+-----------------------+
Total sum of 256 GB.
As there's no reliable way to credit DIMMS to the right memory controller, just put everything on memory controller 0 (with should always exist).
--- drivers/edac/ghes_edac.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/edac/ghes_edac.c +13 -4
@@ -245,10 +245,19 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) mci->dev_name ="ghes" ;if (!fake) { -/* Fill DIMM info from DMI */ - dimm_fill.count =0 ; - dimm_fill.mci = mci; -dmi_walk (ghes_edac_dmidecode, &dimm_fill); +/* +* Fill DIMM info from DMI for the memory controller #0 +* +* Keep it in blank for the other memory controllers, as +* there's no reliable way to properly credit each DIMM to +* the memory controller, as different BIOSes fill the +* DMI bank location fields on different ways +*/ +if (!ghes_edac_mc_num) { + dimm_fill.count =0 ; + dimm_fill.mci = mci; +dmi_walk (ghes_edac_dmidecode, &dimm_fill); + } }else {struct dimm_info *dimm =EDAC_DIMM_PTR (mci->layers, mci->dimms, mci->n_layers,0 ,0 ,0 );
Signature · 1 line
1.8.1.2
PATCH 13/13 ghes_edac: Improve driver's printk messages
In reply to Mauro Carvalho ChehabProvide a better infrastructure for printk's inside the driver:
- use edac_dbg() for debug messages;
- standardize the usage of pr_info();
- provide warning about the risk of relying on this driver.
While here, changes the size of a fake memory to 1 page. This is as good or as bad as 1000 pages, but it is easier for userspace to detect, as I don't expect that any machine implementing GHES would provide just 1 page available ;)
--- drivers/edac/ghes_edac.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/edac/ghes_edac.c +21 -7
@@ -80,7 +80,8 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) dimm_fill->count, 0, 0);if (entry->size ==0xffff ) { -pr_info (GHES_PFX "Can't get dimm size\n" ); +pr_info (GHES_PFX "Can't get DIMM%i size\n" , + dimm_fill->count); dimm->nr_pages =MiB_TO_PAGES (32 );/* Unknown */ }else if (entry->size ==0x7fff ) { dimm->nr_pages =MiB_TO_PAGES (entry->extended_size);
@@ -145,11 +146,11 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg)*/ if (dimm->nr_pages) { -pr_info (GHES_PFX "DIMM%i: %s size = %d MB%s\n" , +edac_dbg (1 ,"DIMM%i: %s size = %d MB%s\n" , dimm_fill->count, memory_type[dimm->mtype],PAGES_TO_MiB (dimm->nr_pages), (dimm->edac_mode !=EDAC_NONE )?"(ECC)" :"" ); -pr_info (GHES_PFX "\ttype %d, detail 0x%02x, width %d(total %d)\n" , +edac_dbg (2 ,"\ttype %d, detail 0x%02x, width %d(total %d)\n" , entry->memory_type, entry->type_detail, entry->total_width, entry->data_width); }
@@ -191,6 +192,7 @@ void ghes_edac_report_mem_error(struct ghes *ghes, int sev, mem_err->node, mem_err->card, mem_err->module, mem_err->bank, mem_err->device, mem_err->row, mem_err->column, mem_err->bit_pos); +edac_dbg (3 ,"error at location %s\n" , location); edac_raw_mc_handle_error(type, ghes->mci, grain, 1, 0, 0, 0, page, offset, 0,
@@ -224,8 +226,6 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev)* to avoid duplicated memory controller numbers */ mutex_lock (&ghes_edac_lock); -pr_info ("ghes_edac#%d: allocating space for %d dimms\n" , - ghes_edac_mc_num, num_dimm); mci =edac_mc_alloc (ghes_edac_mc_num,ARRAY_SIZE (layers), layers,0 );if (!mci) {pr_info (GHES_PFX "Can't allocate memory for EDAC data\n" );
@@ -244,6 +244,21 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) mci->ctl_name ="ghes_edac" ; mci->dev_name ="ghes" ; +if (!ghes_edac_mc_num) { +if (!fake) { +pr_info (GHES_PFX "This EDAC driver relies on BIOS to enumerate memory and get error reports.\n" ); +pr_info (GHES_PFX "Unfortunately, not all BIOSes reflect the memory layout correctly.\n" ); +pr_info (GHES_PFX "So, the end result of using this driver varies from vendor to vendor.\n" ); +pr_info (GHES_PFX "If you find incorrect reports, please ask your vendor to fix its BIOS.\n" ); +pr_info (GHES_PFX "This system has %d DIMM sockets.\n" , + num_dimm); + }else { +pr_info (GHES_PFX "This system has a very crappy BIOS: It doesn't even list the DIMMS.\n" ); +pr_info (GHES_PFX "Its SMBIOS info is wrong. It is doubtful that the error report would\n" ); +pr_info (GHES_PFX "work on such system. Use this driver with caution\n" ); + } + } +if (!fake) {/* * Fill DIMM info from DMI for the memory controller #0
@@ -262,8 +277,7 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev)struct dimm_info *dimm =EDAC_DIMM_PTR (mci->layers, mci->dimms, mci->n_layers,0 ,0 ,0 ); -pr_info (GHES_PFX "Crappy BIOS detected. Faking DIMM EDAC data\n" ); - dimm->nr_pages =1000 ; + dimm->nr_pages =1 ; dimm->grain =128 ; dimm->mtype =MEM_UNKNOWN ; dimm->dtype =DEV_UNKNOWN ;
Signature · 1 line
1.8.1.2
Re: [PATCH EDAC 13/13] ghes_edac: Improve driver's printk messages
Quoted 5 lines · Mauro Carvalho Chehab
Provide a better infrastructure for printk's inside the driver:
- useedac_dbg()for debug messages;
- standardize the usage ofpr_info();
- provide warning about the risk of relying on this driver.
[]
drivers/edac/ghes_edac.c
Quoted 1 line
drivers/edac/ghes_edac.c +0
-0
[]
drivers/edac/ghes_edac.c static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) · line 84
Quoted 7 lines
drivers/edac/ghes_edac.c +2
-1@@ -80,7 +80,8 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) dimm_fill->count, 0, 0);if (entry->size ==0xffff ) { -pr_info (GHES_PFX "Can't get dimm size\n" ); +pr_info (GHES_PFX "Can't get DIMM%i size\n" , + dimm_fill->count);
Perhaps these should use
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
and remove GHEX_PFX from all the pr_<level>()'s?
Re: [PATCH EDAC 13/13] ghes_edac: Improve driver's printk messages
Em Fri, 15 Feb 2013 08:38:17 -0800
Joe Perches <[email protected]> escreveu:
Quoted 12 lines · Mauro Carvalho Chehab
Quoted 5 lines
Provide a better infrastructure for printk's inside the driver:
- useedac_dbg()for debug messages;
- standardize the usage ofpr_info();
- provide warning about the risk of relying on this driver.[]
drivers/edac/ghes_edac.c
Quoted 1 line
drivers/edac/ghes_edac.c +0
-0[]
Quoted 3 lines
drivers/edac/ghes_edac.c +0
-0@@ -80,7 +80,8 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) dimm_fill->count, 0, 0);
Quoted 8 lines
drivers/edac/ghes_edac.c static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) · line 84
Quoted 4 lines
drivers/edac/ghes_edac.c +2
-1if (entry->size ==0xffff ) { -pr_info (GHES_PFX "Can't get dimm size\n" ); +pr_info (GHES_PFX "Can't get DIMM%i size\n" , + dimm_fill->count);Perhaps these should use
#definepr_fmt(fmt)KBUILD_MODNAME": " fmt
and removeGHEX_PFXfrom all the pr_<level>()'s?
Yeah, sure.
Regards,
Mauro
-
[PATCH] ghes_edac: remove GHES_PFX macro
As suggested by Joe:
On Fri, 15 Feb 2013 08:38:17 -0800
Joe Perches <[email protected]> wrote:
Perhaps these should use
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt and remove GHES_PFX from all the pr_<level>()'s?
drivers/edac/ghes_edac.c +15 -13
@@ -1,14 +1,16 @@ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <acpi/ghes.h> #include <linux/edac.h> #include <linux/dmi.h> #include "edac_core.h" -#define GHES_PFX "ghes_edac: "#define GHES_EDAC_REVISION " Ver: 1.0.0"static DEFINE_MUTEX (ghes_edac_lock);static int ghes_edac_mc_num; +/* Memory Device - Type 17 of SMBIOS spec */ struct memdev_dmi_entry {u8 type;
@@ -80,7 +82,7 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) dimm_fill->count, 0, 0);if (entry->size ==0xffff ) { -pr_info (GHES_PFX "Can't get DIMM%i size\n" , +pr_info ("Can't get DIMM%i size\n" , dimm_fill->count); dimm->nr_pages =MiB_TO_PAGES (32 );/* Unknown */ }else if (entry->size ==0x7fff ) {
@@ -232,7 +234,7 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev)mutex_lock (&ghes_edac_lock); mci =edac_mc_alloc (ghes_edac_mc_num,ARRAY_SIZE (layers), layers,0 );if (!mci) { -pr_info (GHES_PFX "Can't allocate memory for EDAC data\n" ); +pr_info ("Can't allocate memory for EDAC data\n" );mutex_unlock (&ghes_edac_lock);return -ENOMEM ; }
@@ -250,17 +252,17 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev)if (!ghes_edac_mc_num) {if (!fake) { -pr_info (GHES_PFX "This EDAC driver relies on BIOS to enumerate memory and get error reports.\n" ); -pr_info (GHES_PFX "Unfortunately, not all BIOSes reflect the memory layout correctly.\n" ); -pr_info (GHES_PFX "So, the end result of using this driver varies from vendor to vendor.\n" ); -pr_info (GHES_PFX "If you find incorrect reports, please contact your hardware vendor\n" ); -pr_info (GHES_PFX "to correct its BIOS.\n" ); -pr_info (GHES_PFX "This system has %d DIMM sockets.\n" , +pr_info ("This EDAC driver relies on BIOS to enumerate memory and get error reports.\n" ); +pr_info ("Unfortunately, not all BIOSes reflect the memory layout correctly.\n" ); +pr_info ("So, the end result of using this driver varies from vendor to vendor.\n" ); +pr_info ("If you find incorrect reports, please contact your hardware vendor\n" ); +pr_info ("to correct its BIOS.\n" ); +pr_info ("This system has %d DIMM sockets.\n" , num_dimm); }else { -pr_info (GHES_PFX "This system has a very crappy BIOS: It doesn't even list the DIMMS.\n" ); -pr_info (GHES_PFX "Its SMBIOS info is wrong. It is doubtful that the error report would\n" ); -pr_info (GHES_PFX "work on such system. Use this driver with caution\n" ); +pr_info ("This system has a very crappy BIOS: It doesn't even list the DIMMS.\n" ); +pr_info ("Its SMBIOS info is wrong. It is doubtful that the error report would\n" ); +pr_info ("work on such system. Use this driver with caution\n" ); } }
@@ -291,7 +293,7 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) rc =edac_mc_add_mc (mci);if (rc <0 ) { -pr_info (GHES_PFX "Can't register at EDAC core\n" ); +pr_info ("Can't register at EDAC core\n" );edac_mc_free (mci);mutex_unlock (&ghes_edac_lock);return -ENODEV ;