Cleanups in amd64_edac and removal of legacy EDAC sysfs interface
Subsystems (5)
v2 cover Cleanups in amd64_edac and removal of legacy EDAC sysfs interface
This patchset undertakes some cleanups in the amd64_edac module and removes the legacy EDAC sysfs interface since it has been obsolete for more than a decade.
The first patch removes explicit assignment of the ctl_name string and instead generates it at runtime using scnprintf.
The second patch removes the NUM_CONTROLLERS macro and instead uses the max_mcs variable to determine the size of chipselect array.
The third patch removes the old EDAC sysfs interface.
NOTE:
These cleanups were earlier submitted as part of the set adding EDAC support for AMD's newer Family 1Ah-based SOCs.[1] However, since the support patches were critical to enabling EDAC on newer AMD SOCs and since these cleanups were still under review, the set was split up.
[1]: https://lore.kernel.org/all/[email protected]/
Changes in v2:
- Drop the patch that set zn_regs_v2 flag for all SOCs based on Family
1Ah and later.
- Change MAX_CTL_NAMELEN macro from 20 to 19.
- Modify commit message of the second patch per feedback received.
- Skip deprecation and just remove the old EDAC sysfs interface.
Links:
v1: https://lore.kernel.org/all/[email protected]/
Avadhut Naik (3):
EDAC/amd64: Generate ctl_name string at runtime
EDAC/amd64: Remove NUM_CONTROLLERS macro
edac: Remove the legacy EDAC sysfs interface
Documentation/admin-guide/RAS/main.rst | 142 +------- arch/loongarch/configs/loongson3_defconfig | 1 - drivers/edac/Kconfig | 8 - drivers/edac/amd64_edac.c | 61 +--- drivers/edac/amd64_edac.h | 7 +- drivers/edac/edac_mc_sysfs.c | 404 --------------------- 6 files changed, 22 insertions(+), 601 deletions(-)
base-commit: d05ab93a9183520b2a6965765e14a3e6bdf01f90
Signature · 1 line
2.43.0
PATCH v2 1/3 EDAC/amd64: Generate ctl_name string at runtime
Currently, the ctl_name string is statically assigned based on the family and model of the SOC when the amd64_edac module is loaded.
The same, however, is not exactly needed as the string can be generated and assigned at runtime through scnprintf().
Remove all static assignments and generate the string at runtime. Also, cleanup the switch cases which became defunct and consolidate identical cases.
--- drivers/edac/amd64_edac.c | 56 +++++++-------------------------------- drivers/edac/amd64_edac.h | 4 ++- 2 files changed, 13 insertions(+), 47 deletions(-)
drivers/edac/amd64_edac.c +10 -46
@@ -3766,6 +3766,7 @@ static int per_family_init(struct amd64_pvt *pvt) pvt->stepping = boot_cpu_data.x86_stepping; pvt->model = boot_cpu_data.x86_model; pvt->fam = boot_cpu_data.x86; +char *tmp_name =NULL ; pvt->max_mcs =2 ;/*
@@ -3779,7 +3780,7 @@ static int per_family_init(struct amd64_pvt *pvt)switch (pvt->fam) {case 0xf : - pvt->ctl_name = (pvt->ext_model >=K8_REV_F ) ? + tmp_name = (pvt->ext_model >=K8_REV_F ) ?"K8 revF or later" :"K8 revE or earlier" ; pvt->f1_id =PCI_DEVICE_ID_AMD_K8_NB_ADDRMAP ; pvt->f2_id =PCI_DEVICE_ID_AMD_K8_NB_MEMCTL ;
@@ -3788,7 +3789,6 @@ static int per_family_init(struct amd64_pvt *pvt)break ;case 0x10 : - pvt->ctl_name ="F10h" ; pvt->f1_id =PCI_DEVICE_ID_AMD_10H_NB_MAP ; pvt->f2_id =PCI_DEVICE_ID_AMD_10H_NB_DRAM ; pvt->ops->dbam_to_cs = f10_dbam_to_chip_select;
@@ -3797,12 +3797,10 @@ static int per_family_init(struct amd64_pvt *pvt)case 0x15 :switch (pvt->model) {case 0x30 : - pvt->ctl_name ="F15h_M30h" ; pvt->f1_id =PCI_DEVICE_ID_AMD_15H_M30H_NB_F1 ; pvt->f2_id =PCI_DEVICE_ID_AMD_15H_M30H_NB_F2 ;break ;case 0x60 : - pvt->ctl_name ="F15h_M60h" ; pvt->f1_id =PCI_DEVICE_ID_AMD_15H_M60H_NB_F1 ; pvt->f2_id =PCI_DEVICE_ID_AMD_15H_M60H_NB_F2 ; pvt->ops->dbam_to_cs = f15_m60h_dbam_to_chip_select;
@@ -3811,7 +3809,6 @@ static int per_family_init(struct amd64_pvt *pvt)/* Richland is only client */ return -ENODEV ;default : - pvt->ctl_name ="F15h" ; pvt->f1_id =PCI_DEVICE_ID_AMD_15H_NB_F1 ; pvt->f2_id =PCI_DEVICE_ID_AMD_15H_NB_F2 ; pvt->ops->dbam_to_cs = f15_dbam_to_chip_select;
@@ -3822,12 +3819,10 @@ static int per_family_init(struct amd64_pvt *pvt)case 0x16 :switch (pvt->model) {case 0x30 : - pvt->ctl_name ="F16h_M30h" ; pvt->f1_id =PCI_DEVICE_ID_AMD_16H_M30H_NB_F1 ; pvt->f2_id =PCI_DEVICE_ID_AMD_16H_M30H_NB_F2 ;break ;default : - pvt->ctl_name ="F16h" ; pvt->f1_id =PCI_DEVICE_ID_AMD_16H_NB_F1 ; pvt->f2_id =PCI_DEVICE_ID_AMD_16H_NB_F2 ;break ;
@@ -3836,76 +3831,51 @@ static int per_family_init(struct amd64_pvt *pvt)case 0x17 :switch (pvt->model) { - case 0x10 ... 0x2f: - pvt->ctl_name ="F17h_M10h" ; -break ; case 0x30 ... 0x3f: - pvt->ctl_name ="F17h_M30h" ; pvt->max_mcs =8 ;break ; - case 0x60 ... 0x6f: - pvt->ctl_name ="F17h_M60h" ; -break ; - case 0x70 ... 0x7f: - pvt->ctl_name ="F17h_M70h" ; -break ;default : - pvt->ctl_name ="F17h" ;break ; }break ;case 0x18 : - pvt->ctl_name ="F18h" ;break ;case 0x19 :switch (pvt->model) { case 0x00 ... 0x0f: - pvt->ctl_name ="F19h" ; pvt->max_mcs =8 ;break ; case 0x10 ... 0x1f: - pvt->ctl_name ="F19h_M10h" ; pvt->max_mcs =12 ; pvt->flags.zn_regs_v2 =1 ;break ; - case 0x20 ... 0x2f: - pvt->ctl_name ="F19h_M20h" ; -break ; case 0x30 ... 0x3f:if (pvt->F3->device ==PCI_DEVICE_ID_AMD_MI200_DF_F3 ) { - pvt->ctl_name ="MI200" ; + tmp_name ="MI200" ; pvt->max_mcs =4 ; pvt->dram_type =MEM_HBM2 ; pvt->gpu_umc_base =0x50000 ; pvt->ops = &gpu_ops; }else { - pvt->ctl_name ="F19h_M30h" ; pvt->max_mcs =8 ; }break ; - case 0x50 ... 0x5f: - pvt->ctl_name ="F19h_M50h" ; -break ; case 0x60 ... 0x6f: - pvt->ctl_name ="F19h_M60h" ; pvt->flags.zn_regs_v2 =1 ;break ; case 0x70 ... 0x7f: - pvt->ctl_name ="F19h_M70h" ; pvt->max_mcs =4 ; pvt->flags.zn_regs_v2 =1 ;break ; case 0x90 ... 0x9f: - pvt->ctl_name ="F19h_M90h" ; pvt->max_mcs =4 ; pvt->dram_type =MEM_HBM3 ; pvt->gpu_umc_base =0x90000 ; pvt->ops = &gpu_ops;break ; case 0xa0 ... 0xaf: - pvt->ctl_name ="F19h_MA0h" ; pvt->max_mcs =12 ; pvt->flags.zn_regs_v2 =1 ;break ;
@@ -3915,34 +3885,22 @@ static int per_family_init(struct amd64_pvt *pvt)case 0x1A :switch (pvt->model) { case 0x00 ... 0x1f: - pvt->ctl_name ="F1Ah" ; pvt->max_mcs =12 ; pvt->flags.zn_regs_v2 =1 ;break ; case 0x40 ... 0x4f: - pvt->ctl_name ="F1Ah_M40h" ; pvt->flags.zn_regs_v2 =1 ;break ; case 0x50 ... 0x57: - pvt->ctl_name ="F1Ah_M50h" ; + case 0xc0 ... 0xc7: pvt->max_mcs =16 ; pvt->flags.zn_regs_v2 =1 ;break ; case 0x90 ... 0x9f: - pvt->ctl_name ="F1Ah_M90h" ; - pvt->max_mcs =8 ; - pvt->flags.zn_regs_v2 =1 ; -break ; case 0xa0 ... 0xaf: - pvt->ctl_name ="F1Ah_MA0h" ; pvt->max_mcs =8 ; pvt->flags.zn_regs_v2 =1 ;break ; - case 0xc0 ... 0xc7: - pvt->ctl_name ="F1Ah_MC0h" ; - pvt->max_mcs =16 ; - pvt->flags.zn_regs_v2 =1 ; -break ; }break ;
@@ -3951,6 +3909,12 @@ static int per_family_init(struct amd64_pvt *pvt)return -ENODEV ; } +if (tmp_name) +scnprintf (pvt->ctl_name,sizeof (pvt->ctl_name), tmp_name); +else +scnprintf (pvt->ctl_name,sizeof (pvt->ctl_name),"F%02Xh_M%02Xh" , + pvt->fam, pvt->model); +return 0 ; }
drivers/edac/amd64_edac.h +3 -1
@@ -101,6 +101,8 @@#define ON true#define OFF false +#define MAX_CTL_NAMELEN 19 +/* * PCI-defined configuration space registers */
@@ -362,7 +364,7 @@ struct amd64_pvt {/* x4, x8, or x16 syndromes in use */ u8 ecc_sym_sz; -const char *ctl_name; +char ctl_name[MAX_CTL_NAMELEN ];u16 f1_id, f2_id;/* Maximum number of memory controllers per die/node. */ u8 max_mcs;
Signature · 1 line
2.43.0
PATCH v2 2/3 EDAC/amd64: Remove NUM_CONTROLLERS macro
In reply to Avadhut NaikCurrently, the NUM_CONTROLLERS macro is used to limit the amount of memory controllers (UMCs) available per node.
The number of UMCs available per node, however, is already cached by the max_mcs variable of struct amd64_pvt. Allocate the relevant data structures dynamically using the variable instead of static allocation through the macro.
The max_mcs variable is used for legacy systems too. These systems have a max of 2 controllers. Since the default value of max_mcs, set in per_family_init(), is 2, these legacy systems are also covered by this change.
--- drivers/edac/amd64_edac.c | 5 +++++ drivers/edac/amd64_edac.h | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/edac/amd64_edac.c +5 -0
@@ -3732,6 +3732,7 @@ static void hw_info_put(struct amd64_pvt *pvt)pci_dev_put (pvt->F1);pci_dev_put (pvt->F2);kfree (pvt->umc); +kfree (pvt->csels); }static struct low_ops umc_ops = {
@@ -3915,6 +3916,10 @@ static int per_family_init(struct amd64_pvt *pvt)scnprintf (pvt->ctl_name,sizeof (pvt->ctl_name),"F%02Xh_M%02Xh" , pvt->fam, pvt->model); + pvt->csels =kcalloc (pvt->max_mcs,sizeof (*pvt->csels),GFP_KERNEL ); +if (!pvt->csels) +return -ENOMEM ; +return 0 ; }
drivers/edac/amd64_edac.h +1 -2
@@ -96,7 +96,6 @@/* Hardware limit on ChipSelect rows per MC and processors per system */ #define NUM_CHIPSELECTS 8#define DRAM_RANGES 8 -#define NUM_CONTROLLERS 16#define ON true#define OFF false
@@ -348,7 +347,7 @@ struct amd64_pvt {u32 dbam1;/* DRAM Base Address Mapping reg for DCT1 */ /* one for each DCT/UMC */ -struct chip_select csels[NUM_CONTROLLERS ]; +struct chip_select *csels;/* DRAM base and limit pairs F1x[78,70,68,60,58,50,48,40] */ struct dram_range ranges[DRAM_RANGES ];
Signature · 1 line
2.43.0
PATCH v2 3/3 edac: Remove the legacy EDAC sysfs interface
In reply to Avadhut NaikCommit 199747106934 ("edac: add a new per-dimm API and make the old per-virtual-rank API obsolete") introduced a new per-dimm sysfs interface for EDAC making the old per-virtual-rank sysfs interface obsolete.
Since this new sysfs interface was introduced more than a decade ago, remove the obsolete legacy interface.
--- Documentation/admin-guide/RAS/main.rst | 142 +------- arch/loongarch/configs/loongson3_defconfig | 1 - drivers/edac/Kconfig | 8 - drivers/edac/edac_mc_sysfs.c | 404 --------------------- 4 files changed, 3 insertions(+), 552 deletions(-)
Documentation/admin-guide/RAS/main.rst +3 -139
@@ -406,24 +406,8 @@ index of the MC:: |->mc2 .... -Under each ``mcX`` directory each ``csrowX`` is again represented by a -``csrowX``, where ``X`` is the csrow index:: - - .../mc/mc0/ - | - |->csrow0 - |->csrow2 - |->csrow3 - .... - -Notice that there is no csrow1, which indicates that csrow0 is composed -of a single ranked DIMMs. This should also apply in both Channels, in -order to have dual-channel mode be operational. Since both csrow2 and -csrow3 are populated, this indicates a dual ranked set of DIMMs for -channels 0 and 1. - -Within each of the ``mcX`` and ``csrowX`` directories are several EDAC -control and attribute files. +Within each of the ``mcX`` directory are several EDAC control and +attribute files. ``mcX`` directories -------------------
@@ -569,7 +553,7 @@ this ``X`` memory module: - Unbuffered-DDR .. [#f5] On some systems, the memory controller doesn't have any logic - to identify the memory module. On such systems, the directory is called ``rankX`` and works on a similar way as the ``csrowX`` directories. + to identify the memory module. On such systems, the directory is called ``rankX``. On modern Intel memory controllers, the memory controller identifies the memory modules directly. On such systems, the directory is called ``dimmX``.
@@ -577,126 +561,6 @@ this ``X`` memory module: symlinks inside the sysfs mapping that are automatically created by the sysfs subsystem. Currently, they serve no purpose. -``csrowX`` directories ----------------------- - -When CONFIG_EDAC_LEGACY_SYSFS is enabled, sysfs will contain the ``csrowX`` -directories. As this API doesn't work properly for Rambus, FB-DIMMs and -modern Intel Memory Controllers, this is being deprecated in favor of -``dimmX`` directories. - -In the ``csrowX`` directories are EDAC control and attribute files for -this ``X`` instance of csrow: - - -- ``ue_count`` - Total Uncorrectable Errors count attribute file - - This attribute file displays the total count of uncorrectable - errors that have occurred on this csrow. If panic_on_ue is set - this counter will not have a chance to increment, since EDAC - will panic the system. - - -- ``ce_count`` - Total Correctable Errors count attribute file - - This attribute file displays the total count of correctable - errors that have occurred on this csrow. This count is very - important to examine. CEs provide early indications that a - DIMM is beginning to fail. This count field should be - monitored for non-zero values and report such information - to the system administrator. - - -- ``size_mb`` - Total memory managed by this csrow attribute file - - This attribute file displays, in count of megabytes, the memory - that this csrow contains. - - -- ``mem_type`` - Memory Type attribute file - - This attribute file will display what type of memory is currently - on this csrow. Normally, either buffered or unbuffered memory. - Examples: - - - Registered-DDR - - Unbuffered-DDR - - -- ``edac_mode`` - EDAC Mode of operation attribute file - - This attribute file will display what type of Error detection - and correction is being utilized. - - -- ``dev_type`` - Device type attribute file - - This attribute file will display what type of DRAM device is - being utilized on this DIMM. - Examples: - - - x1 - - x2 - - x4 - - x8 - - -- ``ch0_ce_count`` - Channel 0 CE Count attribute file - - This attribute file will display the count of CEs on this - DIMM located in channel 0. - - -- ``ch0_ue_count`` - Channel 0 UE Count attribute file - - This attribute file will display the count of UEs on this - DIMM located in channel 0. - - -- ``ch0_dimm_label`` - Channel 0 DIMM Label control file - - - This control file allows this DIMM to have a label assigned - to it. With this label in the module, when errors occur - the output can provide the DIMM label in the system log. - This becomes vital for panic events to isolate the - cause of the UE event. - - DIMM Labels must be assigned after booting, with information - that correctly identifies the physical slot with its - silk screen label. This information is currently very - motherboard specific and determination of this information - must occur in userland at this time. - - -- ``ch1_ce_count`` - Channel 1 CE Count attribute file - - - This attribute file will display the count of CEs on this - DIMM located in channel 1. - - -- ``ch1_ue_count`` - Channel 1 UE Count attribute file - - - This attribute file will display the count of UEs on this - DIMM located in channel 0. - - -- ``ch1_dimm_label`` - Channel 1 DIMM Label control file - - This control file allows this DIMM to have a label assigned - to it. With this label in the module, when errors occur - the output can provide the DIMM label in the system log. - This becomes vital for panic events to isolate the - cause of the UE event. - - DIMM Labels must be assigned after booting, with information - that correctly identifies the physical slot with its - silk screen label. This information is currently very - motherboard specific and determination of this information - must occur in userland at this time. - System Logging --------------
arch/loongarch/configs/loongson3_defconfig +0 -1
@@ -917,7 +917,6 @@ CONFIG_MMC=y CONFIG_MMC_LOONGSON2=m CONFIG_INFINIBAND=m CONFIG_EDAC=y -# CONFIG_EDAC_LEGACY_SYSFS is not set CONFIG_EDAC_LOONGSON=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_EFI=y
drivers/edac/Kconfig +0 -8
@@ -23,14 +23,6 @@ menuconfig EDAC if EDAC -config EDAC_LEGACY_SYSFS - bool "EDAC legacy sysfs" - default y - help - Enable the compatibility sysfs nodes. - Use 'Y' if your edac utilities aren't ported to work with the newer - structures. - config EDAC_DEBUG bool "Debugging" select DEBUG_FS
drivers/edac/edac_mc_sysfs.c +0 -404
422 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 35 lines · Avadhut Naik
This patchset undertakes some cleanups in the
amd64_edacmodule and removes the legacy EDAC sysfs interface since it has been obsolete for more than a decade.The first patch removes explicit assignment of the
ctl_namestring and instead generates it at runtime using scnprintf.The second patch removes the
NUM_CONTROLLERSmacro and instead uses themax_mcsvariable to determine the size of chipselect array.The third patch removes the old EDAC sysfs interface.
NOTE:
These cleanups were earlier submitted as part of the set adding EDAC support for AMD's newer Family 1Ah-based SOCs.[1] However, since the support patches were critical to enabling EDAC on newer AMD SOCs and since these cleanups were still under review, the set was split up.[1]: https://lore.kernel.org/all/[email protected]/
Changes in v2:
- Drop the patch that setzn_regs_v2flag for all SOCs based on Family
1Ah and later.
- ChangeMAX_CTL_NAMELENmacro from 20 to 19.
- Modify commit message of the second patch per feedback received.
- Skip deprecation and just remove the old EDAC sysfs interface.Links:
v1: https://lore.kernel.org/all/[email protected]/Avadhut Naik (3):
EDAC/amd64: Generatectl_namestring at runtime
EDAC/amd64: RemoveNUM_CONTROLLERSmacro
edac: Remove the legacy EDAC sysfs interface
Quoted 7 lines
Documentation/admin-guide/RAS/main.rst | 142 +------- arch/loongarch/configs/loongson3_defconfig | 1 - drivers/edac/Kconfig | 8 - drivers/edac/amd64_edac.c | 61 +--- drivers/edac/amd64_edac.h | 7 +- drivers/edac/edac_mc_sysfs.c | 404 --------------------- 6 files changed, 22 insertions(+), 601 deletions(-)
Queued, thanks.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette