Skip to contentSkip to conversation

edac: Add APM X-Gene SoC EDAC driver

PATCH Superseded Loc Ho 6 participants 24 messages May 18, 2015 – May 28, 2015

Subsystems (9)

v10 of 11 Superseded Latest is v11 →

lore
Share & tools
lore

Loc Ho

author
#0 lore raw

v10 cover edac: Add APM X-Gene SoC EDAC driver

This patch adds support for the APM X-Gene SoC EDAC driver for DT.

v10:
* Move regmap for CSW, MCBA, MCBB, and efuse to top driver node and add accessor support functions
* Change retrieval OF address proerty for subnode to use of_address_to_resource
* Add COMPILE_TEST to Kconfig for EDAC_XGENE
* Update DT binding documentation and DT node accordingly
* Remove DT node naming and number from nodes

v9:
* Update maintainer section
* Update binding documentation to reflect update DT binding
* Restructure the EDAC driver such that its includes subnode for MC, PMD's, and future L3's and SoC.
* Update DT node to reflect update DT binding
* NOTE: Temporary removed L3 and SoC. They will be added back later on.

v8:
* Change ASM_EDAC_H to __ASM_EDAC_H in file edac.h
* Add WARN_ONCE in stub function atomic_scrub
* Update DTS binding documentation (with only memory controller node)
* Temporary remove L1/L2, L3, and SoC driver code and update memory driver code accordingly

v7:
* Update binding documentation for memory controller, PMD, L3, and SoC EDAC
* Change resource for PCP, CSW, MCBA, MCBB, and efuse to syscon type nodes and updae driver accordingly
* Fix clearing L2 RTO register properly
* Fix the MODULE_DEVICE_TABLE for OF
* Update DT accordingly to binding documentation

v6:
* Rebase to 4.0.0-rc3
* Add memory scrub stub function and enable ARM64 EDAC support patch
* Add bit definition defines for L2RTOS registers
* Remove un-necessary clearing of all L1/L2 software generated registers
* Remove wrong notification of LSU un-correctable error
* Change L2 reporting of un-correcable error to correctable error
* Change clearing of the L2C L2RTO registers
* Add support for L2 HW version 1 and version 2 or above
* Add support for L3 HW version 1 and version 2 or above

v5:
* Rebase to 3.17.rc1 (next)
* Update binding documentation for additional SoC node binding resource
* Enable MCU correctable and uncorrectable interrupts if not enabled by firmware
* Enable top level interrupt only after all MCU registered. Otherwise, error interrupt will never get cleared by the corresponding MCU.
* Remove clearing of L1 and L2 errors during initialization time. Otherwise, they will not be captured between firmware booting and error configuration.
* Add capture and clearing SoC register bus errors
* Add register bus resource to SoC DT node

v4:
* Fix PMD l1/l2 error reading address due to wrong variable type
* Fix clearing of software generated and HW errors for l1/l2

v3:
* Update binding documentation for PMD DT node and exampples
* Add binding documentation for SoC DT node
* Change MC, PMD, and L3C driver error injection to use debugfs
* Add missing IRQ for MC correctable error (code and DT)
* Use true/false where appropriate instead 1/0
* Add bit definition for L1 MMUESR register and fully decode this error
* Remove the un-necessary dev variable from xgene_edac_pmd_ctx structure
* Add check for disabled PMD (code and DT)
* Switch to edac_printk instead pr_err
* Some minor comments update

v2:
* Add EDAC entry in MAINTAINERS for APM EDAC driver
* Remove the MC scrub patch
* Remove the word 'Caches' from Kconfig
* Change all MASK defines to use BIT(x)
* Update comment or remove them
* Wrap error injection code around CONFIG_EDAC_DEBUG
* Change function name xgene_edac_mc_hw_init to xgene_edac_mc_irq_ctl
* Change all function XXX_hw_init to XXX_hw_ctl
* Fix typo 'activie'
* Move calling function edac_mc_alloc after resource retrieval
* Check for NULL on platform_get_resource return if reference directly
* Add documentation for struct xgene_edac_pmd_ctx
* Move L1 and L2 check out of function xgene_edac_pmd_check to its own functions
* Use for loop for configure each CPU of an PMD
* Replace /2 by >> 1
* Remove unnecessary comment on edac_device_add_device failure
* Make mem_err_ip static const
* Unwind EDAC register correctly if failed
---
Loc Ho (5):
arm64: Enable EDAC on ARM64
MAINTAINERS: Add entry for APM X-Gene SoC EDAC driver
Documentation: Add documentation for the APM X-Gene SoC EDAC DTS
binding
edac: Add APM X-Gene SoC EDAC driver
arm64: Add APM X-Gene SoC EDAC DTS entries

 .../devicetree/bindings/edac/apm-xgene-edac.txt    |   74 ++
 MAINTAINERS                                        |    7 +
 arch/arm64/Kconfig                                 |    1 +
 arch/arm64/boot/dts/apm/apm-storm.dtsi             |   75 ++
 arch/arm64/include/asm/edac.h                      |   28 +
 drivers/edac/Kconfig                               |    7 +
 drivers/edac/Makefile                              |    1 +
 drivers/edac/xgene_edac.c                          | 1313 ++++++++++++++++++++
 8 files changed, 1506 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/edac/apm-xgene-edac.txt
 create mode 100644 arch/arm64/include/asm/edac.h
 create mode 100644 drivers/edac/xgene_edac.c
author
#1 lore raw

PATCH v10 1/5 arm64: Enable EDAC on ARM64

Add an stub atomic_scrub function and enable EDAC for arm64.

---
 arch/arm64/Kconfig            |    1 +
 arch/arm64/include/asm/edac.h |   28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm64/include/asm/edac.h
arch/arm64/Kconfig +1 -0
index 4269dba..577078f 100644
@@ -22,6 +22,7 @@ config ARM64
 	select BUILDTIME_EXTABLE_SORT
 	select CLONE_BACKWARDS
 	select COMMON_CLK
+	select EDAC_SUPPORT
 	select CPU_PM if (SUSPEND || CPU_IDLE)
 	select DCACHE_WORD_ACCESS
 	select GENERIC_ALLOCATOR
arch/arm64/include/asm/edac.h new file +28 -0
new file mode 100644
index 0000000..683495b
@@ -0,0 +1,28 @@
+/*
+ * ARM64 EDAC Header File
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __ASM_EDAC_H
+#define __ASM_EDAC_H
+
+/*
+ * ECC atomic, DMA, SMP and interrupt safe scrub function.
+ */
+static inline void atomic_scrub(void *va, u32 size)
+{
+	/* Stub function for now until an ARM64 HW has a way to test it. */
+	WARN_ONCE(1, "not implemented");
+}
+
+#endif
Signature · 1 line
1.7.1
author
#2 lore raw

PATCH v10 2/5 MAINTAINERS: Add entry for APM X-Gene SoC EDAC driver

This patch adds a MAINTAINERS entry for APM X-Gene SoC EDAC driver.

---
 MAINTAINERS |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
MAINTAINERS +7 -0
index 00a586b..0134fee 100644
@@ -3735,6 +3735,13 @@ W:	bluesmoke.sourceforge.net
 S:	Maintained
 F:	drivers/edac/sb_edac.c
 
+EDAC-XGENE
+APPLIED MICRO (APM) X-GENE SOC EDAC
+M:     Loc Ho <[email protected]>
+S:     Supported
+F:     drivers/edac/xgene_edac.c
+F:     Documentation/devicetree/bindings/edac/apm-xgene-edac.txt
+
 EDIROL UA-101/UA-1000 DRIVER
 M:	Clemens Ladisch <[email protected]>
 L:	alsa-devel at alsa-project.org (moderated for non-subscribers)
Signature · 1 line
1.7.1
author
#3 lore raw

PATCH v10 3/5 Documentation: Add documentation for the APM X-Gene SoC EDAC DTS binding

This patch adds documentation for the APM X-Gene SoC EDAC DTS binding.

---
 .../devicetree/bindings/edac/apm-xgene-edac.txt    |   74 ++++++++++++++++++++
 1 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/edac/apm-xgene-edac.txt
Documentation/devicetree/bindings/edac/apm-xgene-edac.txt new file +74 -0
new file mode 100644
index 0000000..d8f2782
@@ -0,0 +1,74 @@
+* APM X-Gene SoC EDAC node
+
+EDAC node is defined to describe on-chip error detection and correction.
+The follow error types are supported:
+
+  memory controller	- Memory controller
+  PMD (L1/L2)		- Processor module unit (PMD) L1/L2 cache
+
+The following section describes the EDAC DT node binding.
+
+Required properties:
+- compatible		: Shall be "apm,xgene-edac".
+- regmap-csw		: Regmap of the CPU switch fabric (CSW) resource.
+- regmap-mcba		: Regmap of the MCB-A (memory bridge) resource.
+- regmap-mcbb		: Regmap of the MCB-B (memory bridge) resource.
+- regmap-efuse		: Regmap of the PMD efuse resource.
+- reg			: First resource shall be the CPU bus (PCP) resource.
+- interrupts            : Interrupt-specifier for MCU, PMD, L3, or SoC error
+			  IRQ(s).
+
+Required properties for memory controller subnode:
+- compatible		: Shall be "apm,xgene-edac-mc".
+- reg			: First resource shall be the memory controller unit
+                          (MCU) resource.
+
+Required properties for PMD subnode:
+- compatible		: Shall be "apm,xgene-edac-pmd".
+- reg			: First resource shall be the PMD resource.
+
+Example:
+	csw: csw at 7e200000 {
+		compatible = "syscon";
+		reg = <0x0 0x7e200000 0x0 0x1000>;
+	};
+
+	mcba: mcba at 7e700000 {
+		compatible = "syscon";
+		reg = <0x0 0x7e700000 0x0 0x1000>;
+	};
+
+	mcbb: mcbb at 7e720000 {
+		compatible = "syscon";
+		reg = <0x0 0x7e720000 0x0 0x1000>;
+	};
+
+	efuse: efuse at 1054a000 {
+		compatible = "syscon";
+		reg = <0x0 0x1054a000 0x0 0x20>;
+	};
+
+	edac at 78800000 {
+		compatible = "apm,xgene-edac";
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+		regmap-csw = <&csw>;
+		regmap-mcba = <&mcba>;
+		regmap-mcbb = <&mcbb>;
+		regmap-efuse = <&efuse>;
+		reg = <0x0 0x78800000 0x0 0x100>;
+		interrupts = <0x0 0x20 0x4>,
+			     <0x0 0x21 0x4>,
+			     <0x0 0x27 0x4>;
+
+		edacmc at 7e800000 {
+			compatible = "apm,xgene-edac-mc";
+			reg = <0x0 0x7e800000 0x0 0x1000>;
+		};
+
+		edacpmd at 7c000000 {
+			compatible = "apm,xgene-edac-pmd";
+			reg = <0x0 0x7c000000 0x0 0x200000>;
+		};
+	};
Signature · 1 line
1.7.1
author
#4 lore raw

PATCH v10 4/5 edac: Add APM X-Gene SoC EDAC driver

This patch adds support for the APM X-Gene SoC EDAC driver.

---
 drivers/edac/Kconfig      |    7 +
 drivers/edac/Makefile     |    1 +
 drivers/edac/xgene_edac.c | 1313 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1321 insertions(+), 0 deletions(-)
 create mode 100644 drivers/edac/xgene_edac.c
drivers/edac/Kconfig +7 -0
index cb59619..ffa7cac 100644
@@ -392,4 +392,11 @@ config EDAC_SYNOPSYS
 	  Support for error detection and correction on the Synopsys DDR
 	  memory controller.
 
+config EDAC_XGENE
+	tristate "APM X-Gene SoC"
+	depends on EDAC_MM_EDAC && (ARM64 || COMPILE_TEST)
+	help
+	  Support for error detection and correction on the
+	  APM X-Gene family of SOCs.
+
 endif # EDAC
drivers/edac/Makefile +1 -0
index b255f36..28ef2a5 100644
@@ -68,3 +68,4 @@ obj-$(CONFIG_EDAC_OCTEON_PCI)		+= octeon_edac-pci.o
 
 obj-$(CONFIG_EDAC_ALTERA_MC)		+= altera_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)		+= synopsys_edac.o
+obj-$(CONFIG_EDAC_XGENE)		+= xgene_edac.o
drivers/edac/xgene_edac.c new file +1313 -0

1,313 lines not on this page · raw message

Signature · 1 line
1.7.1
author
#5 lore raw

PATCH v10 5/5 arm64: Add APM X-Gene SoC EDAC DTS entries

This patch adds APM X-Gene SoC EDAC DTS entries.

---
 arch/arm64/boot/dts/apm/apm-storm.dtsi |   75 ++++++++++++++++++++++++++++++++
 1 files changed, 75 insertions(+), 0 deletions(-)
arch/arm64/boot/dts/apm/apm-storm.dtsi +75 -0
index c8d3e0e..51aa174 100644
@@ -374,6 +374,81 @@
 			};
 		};
 
+		csw: csw at 7e200000 {
+			compatible = "syscon";
+			reg = <0x0 0x7e200000 0x0 0x1000>;
+		};
+
+		mcba: mcba at 7e700000 {
+			compatible = "syscon";
+			reg = <0x0 0x7e700000 0x0 0x1000>;
+		};
+
+		mcbb: mcbb at 7e720000 {
+			compatible = "syscon";
+			reg = <0x0 0x7e720000 0x0 0x1000>;
+		};
+
+		efuse: efuse at 1054a000 {
+			compatible = "syscon";
+			reg = <0x0 0x1054a000 0x0 0x20>;
+		};
+
+		edac at 78800000 {
+			compatible = "apm,xgene-edac";
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges;
+			regmap-csw = <&csw>;
+			regmap-mcba = <&mcba>;
+			regmap-mcbb = <&mcbb>;
+			regmap-efuse = <&efuse>;
+			reg = <0x0 0x78800000 0x0 0x100>;
+			interrupts = <0x0 0x20 0x4>,
+				     <0x0 0x21 0x4>,
+				     <0x0 0x27 0x4>;
+
+			edacmc at 7e800000 {
+				compatible = "apm,xgene-edac-mc";
+				reg = <0x0 0x7e800000 0x0 0x1000>;
+			};
+
+			edacmc at 7e840000 {
+				compatible = "apm,xgene-edac-mc";
+				reg = <0x0 0x7e840000 0x0 0x1000>;
+			};
+
+			edacmc at 7e880000 {
+				compatible = "apm,xgene-edac-mc";
+				reg = <0x0 0x7e880000 0x0 0x1000>;
+			};
+
+			edacmc at 7e8c0000 {
+				compatible = "apm,xgene-edac-mc";
+				reg = <0x0 0x7e8c0000 0x0 0x1000>;
+			};
+
+			edacpmd at 7c000000 {
+				compatible = "apm,xgene-edac-pmd";
+				reg = <0x0 0x7c000000 0x0 0x200000>;
+			};
+
+			edacpmd at 7c200000 {
+				compatible = "apm,xgene-edac-pmd";
+				reg = <0x0 0x7c200000 0x0 0x200000>;
+			};
+
+			edacpmd at 7c400000 {
+				compatible = "apm,xgene-edac-pmd";
+				reg = <0x0 0x7c400000 0x0 0x200000>;
+			};
+
+			edacpmd at 7c600000 {
+				compatible = "apm,xgene-edac-pmd";
+				reg = <0x0 0x7c600000 0x0 0x200000>;
+			};
+		};
+
 		pcie0: pcie at 1f2b0000 {
 			status = "disabled";
 			device_type = "pci";
Signature · 1 line
1.7.1
#6 lore raw

PATCH v10 4/5 edac: Add APM X-Gene SoC EDAC driver

In reply to Loc Ho
Quoted 9 lines · On Monday 18 May 2015 17:24:40 Loc Ho wrote:

This patch adds support for the APM X-Gene SoC EDAC driver.

---
 drivers/edac/Kconfig      |    7 +
 drivers/edac/Makefile     |    1 +
 drivers/edac/xgene_edac.c | 1313 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1321 insertions(+), 0 deletions(-)
 create mode 100644 drivers/edac/xgene_edac.c

Looks reasonable overall, good job. Just a few details that are left:

drivers/edac/xgene_edac.c line 79

Quoted 10 lines
drivers/edac/xgene_edac.c new file +10 -0
+
+static int xgene_edac_pcp_rd(struct xgene_edac *edac, u32 reg, u32 *val);
+static int xgene_edac_pcp_clrbits(struct xgene_edac *edac, u32 reg,
+				  u32 bits_mask);
+static int xgene_edac_pcp_setbits(struct xgene_edac *edac, u32 reg,
+				  u32 bits_mask);
+static int xgene_edac_csw_rd(struct xgene_edac *edac, u32 reg, u32 *val);
+static int xgene_edac_mcba_rd(struct xgene_edac *edac, u32 reg, u32 *val);
+static int xgene_edac_mcbb_rd(struct xgene_edac *edac, u32 reg, u32 *val);
+static int xgene_edac_efuse_rd(struct xgene_edac *edac, u32 reg, u32 *val);

It's better to avoid any forward declaration for local functions, and instead reorder the file to move the definition before the first use.

drivers/edac/xgene_edac.c line 84

Quoted 4 lines
drivers/edac/xgene_edac.c new file +4 -0
+static int edac_mc_idx;
+static int edac_mc_active_mask;
+static int edac_mc_registered_mask;
+static DEFINE_MUTEX(xgene_edac_mc_lock);

It would also be best to avoid global variables, but it seems that at least the edac_mc_idx is needed to work with the EDAC subsystem. Maybe Boris has an idea for how to avoid it.

Quoted 26 lines
drivers/edac/xgene_edac.c new file +26 -0
+#ifdef CONFIG_EDAC_DEBUG
+static ssize_t xgene_edac_mc_err_inject_write(struct file *file,
+					      const char __user *data,
+					      size_t count, loff_t *ppos)
+{
+	struct mem_ctl_info *mci = file->private_data;
+	struct xgene_edac_mc_ctx *ctx = mci->pvt_info;
+	int i;
+
+	for (i = 0; i < MCU_MAX_RANK; i++) {
+		writel(MCU_ESRR_MULTUCERR_MASK | MCU_ESRR_BACKUCERR_MASK |
+		       MCU_ESRR_DEMANDUCERR_MASK | MCU_ESRR_CERR_MASK,
+		       ctx->mcu_csr + MCUESRRA0 + i * MCU_RANK_STRIDE);
+	}
+	return count;
+}
+
+static const struct file_operations xgene_edac_mc_debug_inject_fops = {
+	.open = simple_open,
+	.write = xgene_edac_mc_err_inject_write,
+	.llseek = generic_file_llseek,
+};
+
+static void xgene_edac_mc_create_debugfs_node(struct mem_ctl_info *mci)
+{
+	if (!mci->debugfs)

drivers/edac/xgene_edac.c line 166

Quoted 10 lines
drivers/edac/xgene_edac.c new file +10 -0
+		return;
+
+	debugfs_create_file("inject_ctrl", S_IWUSR, mci->debugfs, mci,
+			    &xgene_edac_mc_debug_inject_fops);
+}
+#else
+static void xgene_edac_mc_create_debugfs_node(struct mem_ctl_info *mci)
+{
+}
+#endif

Here, it would be better style to avoid the #ifdef. If you just use

static void xgene_edac_mc_create_debugfs_node(struct mem_ctl_info *mci)

{
	if (! IS_ENABLED(CONFIG_EDAC_DEBUG) || !mci->debugfs)
		return;

the compiler will drop all the debug code when that option is not set, but will still check the code for correctness, and emit any warnings that one might want to see.

Quoted 21 lines
drivers/edac/xgene_edac.c new file +21 -0
+static int xgene_edac_csw_rd(struct xgene_edac *edac, u32 reg, u32 *val)
+{
+	if (edac == NULL)
+		return -EINVAL;
+
+	return regmap_read(edac->csw_map, reg, val);
+}
+
+static int xgene_edac_mcba_rd(struct xgene_edac *edac, u32 reg, u32 *val)
+{
+	if (edac == NULL)
+		return -EINVAL;
+
+	return regmap_read(edac->mcba_map, reg, val);
+}
+
+static int xgene_edac_mcbb_rd(struct xgene_edac *edac, u32 reg, u32 *val)
+{
+	if (edac == NULL)
+		return -EINVAL;
+

drivers/edac/xgene_edac.c line 1100

Quoted 10 lines
drivers/edac/xgene_edac.c new file +10 -0
+	return regmap_read(edac->mcbb_map, reg, val);
+}
+
+static int xgene_edac_efuse_rd(struct xgene_edac *edac, u32 reg, u32 *val)
+{
+	if (edac == NULL)
+		return -EINVAL;
+
+	return regmap_read(edac->efuse_map, reg, val);
+}

I would drop the NULL check, and just refuse to probe the device if any of the regmaps are unavailable. You list the properties as 'required' in DT, so if any of the pointers are NULL here, that is really a bug somewhere (kernel or DT), not a user error, so -EINVAL is not appropriate.

Also, these all have very few callers, so just open-code the regmap_read() instead of having wrappers.

Quoted 6 lines
drivers/edac/xgene_edac.c new file +6 -0
+
+static int xgene_edac_pcp_setbits(struct xgene_edac *edac, u32 reg,
+				  u32 bits_mask)
+{
+	u32 val;
+

drivers/edac/xgene_edac.c line 1116

Quoted 10 lines
drivers/edac/xgene_edac.c new file +10 -0
+	if (edac == NULL)
+		return -EINVAL;
+
+	spin_lock(&edac->lock);
+	val = readl(edac->pcp_csr + reg);
+	val |= bits_mask;
+	writel(val, edac->pcp_csr + reg);
+	spin_unlock(&edac->lock);
+	return 0;
+}

If you cache the interrupt masks in the xgene_edac structure, you can avoid the read-modify-write functions for updating the register in place.

Arnd

maintainer
#7 lore raw

PATCH v10 4/5 edac: Add APM X-Gene SoC EDAC driver

Quoted 8 lines · Arnd Bergmann

drivers/edac/xgene_edac.c line 84

Quoted 4 lines
drivers/edac/xgene_edac.c new file +4 -0
+static int edac_mc_idx;
+static int edac_mc_active_mask;
+static int edac_mc_registered_mask;
+static DEFINE_MUTEX(xgene_edac_mc_lock);

It would also be best to avoid global variables, but it seems that at least the edac_mc_idx is needed to work with the EDAC subsystem. Maybe Boris has an idea for how to avoid it.

Right, so AFAICT this is used in

	edac_mc_alloc(edac_mc_idx++

and basically we're supplying the memory controller numbers in the order we're calling xgene_edac_mc_add(). Perhaps we need to make the memory controller numbering explicit with DT...

Signature · 5 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
#8 lore raw

PATCH v10 4/5 edac: Add APM X-Gene SoC EDAC driver

Quoted 10 lines · On Friday 22 May 2015 10:46:25 Borislav Petkov wrote:
Quoted 8 lines · Arnd Bergmann

drivers/edac/xgene_edac.c line 84

Quoted 4 lines
drivers/edac/xgene_edac.c new file +4 -0
+static int edac_mc_idx;
+static int edac_mc_active_mask;
+static int edac_mc_registered_mask;
+static DEFINE_MUTEX(xgene_edac_mc_lock);

It would also be best to avoid global variables, but it seems that at least the edac_mc_idx is needed to work with the EDAC subsystem. Maybe Boris has an idea for how to avoid it.

Quoted 7 lines

Right, so AFAICT this is used in

        edac_mc_alloc(edac_mc_idx++

and basically we're supplying the memory controller numbers in the order we're calling xgene_edac_mc_add(). Perhaps we need to make the memory controller numbering explicit with DT...

I see now that the number is also used in xgene_edac_mc_is_active() as an index for the MCBADDRMR register, which seems very fragile, as it relies on the DT nodes getting seen in the same order by the driver that the hardware blocks are used in.

Better add an explicit DT property for the index that is defined to be the same as MCBADDRMR bits, e.g.

                       edacmc at 7e800000 {
                             compatible = "apm,xgene-edac-mc";
                             reg = <0x0 0x7e800000 0x0 0x1000>;
			      memory-controller = <0>;
                       };

or use a reference to the normal memory controller DT node outside of the EDAC, and put a number in that one.

Is there a strict 1:1 relation between the DIMM slot numbering on the board and the memory controller number within the EDAC registers?

Arnd

author
#9 lore raw

PATCH v10 4/5 edac: Add APM X-Gene SoC EDAC driver

Hi,

Quoted 31 lines
Quoted 9 lines
Quoted 8 lines

drivers/edac/xgene_edac.c line 84

Quoted 4 lines
drivers/edac/xgene_edac.c new file +4 -0
+static int edac_mc_idx;
+static int edac_mc_active_mask;
+static int edac_mc_registered_mask;
+static DEFINE_MUTEX(xgene_edac_mc_lock);

It would also be best to avoid global variables, but it seems that at least the edac_mc_idx is needed to work with the EDAC subsystem. Maybe Boris has an idea for how to avoid it.

Quoted 7 lines

Right, so AFAICT this is used in

        edac_mc_alloc(edac_mc_idx++

and basically we're supplying the memory controller numbers in the order we're calling xgene_edac_mc_add(). Perhaps we need to make the memory controller numbering explicit with DT...

I see now that the number is also used in xgene_edac_mc_is_active() as an index for the MCBADDRMR register, which seems very fragile, as it relies on the DT nodes getting seen in the same order by the driver that the hardware blocks are used in.

Better add an explicit DT property for the index that is defined to be the same as MCBADDRMR bits, e.g.

                       edacmc at 7e800000 {
                             compatible = "apm,xgene-edac-mc";
                             reg = <0x0 0x7e800000 0x0 0x1000>;
                              memory-controller = <0>;
                       };
Quoted 6 lines

or use a reference to the normal memory controller DT node outside of the EDAC, and put a number in that one.

Is there a strict 1:1 relation between the DIMM slot numbering on the board and the memory controller number within the EDAC registers?

Yes... The status active bit position is strictly tie to an controller. Like the suggestion with memory-controller property.

-Loc

author
#10 lore raw

PATCH v10 4/5 edac: Add APM X-Gene SoC EDAC driver

In reply to Borislav Petkov

Hi,

Quoted 9 lines
Quoted 8 lines

drivers/edac/xgene_edac.c line 84

Quoted 4 lines
drivers/edac/xgene_edac.c new file +4 -0
+static int edac_mc_idx;
+static int edac_mc_active_mask;
+static int edac_mc_registered_mask;
+static DEFINE_MUTEX(xgene_edac_mc_lock);

It would also be best to avoid global variables, but it seems that at least the edac_mc_idx is needed to work with the EDAC subsystem. Maybe Boris has an idea for how to avoid it.

Quoted 8 lines

Right, so AFAICT this is used in

        edac_mc_alloc(edac_mc_idx++

and basically we're supplying the memory controller numbers in the order we're calling xgene_edac_mc_add(). Perhaps we need to make the memory controller numbering explicit with DT...

Let me move them all into the top level driver given that the MC is now a subnode.

-Loc

#11 lore raw

PATCH v10 4/5 edac: Add APM X-Gene SoC EDAC driver

In reply to Loc Ho
Quoted 2 lines · On Monday 18 May 2015 17:24:40 Loc Ho wrote:

+ tmp_ctx.mcu_id = ((res.start >> 16) & 0xF) / 4;

Just found this line: you are effectively hardcoding the physical register layout of the chip in the driver here, to get the index of the memory controller. This is a very bad idea as it prevents you from reusing this driver for another chip that puts the same registers in a different place, don't do that.

Arnd

#12 lore raw

PATCH v10 3/5 Documentation: Add documentation for the APM X-Gene SoC EDAC DTS binding

In reply to Loc Ho
Quoted 3 lines · On Monday 18 May 2015 17:24:39 Loc Ho wrote:

This patch adds documentation for the APM X-Gene SoC EDAC DTS binding.

This is starting to look pretty good. One final comment:

Quoted 10 lines
Documentation/devicetree/bindings/edac/apm-xgene-edac.txt new file +10 -0
+Example:
+	csw: csw at 7e200000 {
+		compatible = "syscon";
+		reg = <0x0 0x7e200000 0x0 0x1000>;
+	};
+
+	mcba: mcba at 7e700000 {
+		compatible = "syscon";
+		reg = <0x0 0x7e700000 0x0 0x1000>;
+	};

Documentation/devicetree/bindings/edac/apm-xgene-edac.txt line 49

Quoted 10 lines
Documentation/devicetree/bindings/edac/apm-xgene-edac.txt new file +10 -0
+
+	mcbb: mcbb at 7e720000 {
+		compatible = "syscon";
+		reg = <0x0 0x7e720000 0x0 0x1000>;
+	};
+
+	efuse: efuse at 1054a000 {
+		compatible = "syscon";
+		reg = <0x0 0x1054a000 0x0 0x20>;
+	};

I think it would be helpful to assign a proper compatible string (in addition o syscon, not replacing it) for each of these, just in case we ever need to add a proper driver for one of them, or in case a future chip uses an unmodified edac block with a slightly different set of fuses or other registers that are referenced here.

Arnd

maintainer
#13 lore raw

PATCH v10 1/5 arm64: Enable EDAC on ARM64

In reply to Loc Ho
Quoted 43 lines · Loc Ho

Add an stub atomic_scrub function and enable EDAC for arm64.

---
 arch/arm64/Kconfig            |    1 +
 arch/arm64/include/asm/edac.h |   28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm64/include/asm/edac.h
arch/arm64/Kconfig +1 -0
index 4269dba..577078f 100644
@@ -22,6 +22,7 @@ config ARM64
 	select BUILDTIME_EXTABLE_SORT
 	select CLONE_BACKWARDS
 	select COMMON_CLK
+	select EDAC_SUPPORT
 	select CPU_PM if (SUSPEND || CPU_IDLE)
 	select DCACHE_WORD_ACCESS
 	select GENERIC_ALLOCATOR
arch/arm64/include/asm/edac.h new file +16 -0
new file mode 100644
index 0000000..683495b
@@ -0,0 +1,28 @@
+/*
+ * ARM64 EDAC Header File
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __ASM_EDAC_H

arch/arm64/include/asm/edac.h line 26

Quoted 10 lines
arch/arm64/include/asm/edac.h new file +10 -0
+#define __ASM_EDAC_H
+
+/*
+ * ECC atomic, DMA, SMP and interrupt safe scrub function.
+ */
+static inline void atomic_scrub(void *va, u32 size)
+{
+	/* Stub function for now until an ARM64 HW has a way to test it. */
+	WARN_ONCE(1, "not implemented");
+}

So you're adding this empty function, it issues a warning for which the user can't really do anything about and on top of that, it is not even used in this patchset.

So please kill it from this submission.

You can add a full-fledged version later after you test it successfully on real hw.

Signature · 5 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
author
#14 lore raw

PATCH v10 1/5 arm64: Enable EDAC on ARM64

Hi,

Quoted 59 lines · Borislav Petkov
Quoted 43 lines · Loc Ho

Add an stub atomic_scrub function and enable EDAC for arm64.

---
 arch/arm64/Kconfig            |    1 +
 arch/arm64/include/asm/edac.h |   28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm64/include/asm/edac.h
arch/arm64/Kconfig +1 -0
index 4269dba..577078f 100644
@@ -22,6 +22,7 @@ config ARM64
      select BUILDTIME_EXTABLE_SORT
      select CLONE_BACKWARDS
      select COMMON_CLK
+     select EDAC_SUPPORT
      select CPU_PM if (SUSPEND || CPU_IDLE)
      select DCACHE_WORD_ACCESS
      select GENERIC_ALLOCATOR
arch/arm64/include/asm/edac.h new file +16 -0
new file mode 100644
index 0000000..683495b
@@ -0,0 +1,28 @@
+/*
+ * ARM64 EDAC Header File
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __ASM_EDAC_H

arch/arm64/include/asm/edac.h line 26

Quoted 10 lines
arch/arm64/include/asm/edac.h new file +10 -0
+#define __ASM_EDAC_H
+
+/*
+ * ECC atomic, DMA, SMP and interrupt safe scrub function.
+ */
+static inline void atomic_scrub(void *va, u32 size)
+{
+     /* Stub function for now until an ARM64 HW has a way to test it. */
+     WARN_ONCE(1, "not implemented");
+}

So you're adding this empty function, it issues a warning for which the user can't really do anything about and on top of that, it is not even used in this patchset.

Quoted 1 line

So please kill it from this submission.

This was discussed here
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/326986.html.
Without this, it will have compiler error as this function is called by.function edac_mc_scrub_block in file drivers/edac/edac_mc.c.

Quoted 3 lines

You can add a full-fledged version later after you test it successfully on real hw.

Our platform don't use it as it has HW scrub support.

-Loc

maintainer
#15 lore raw

PATCH v10 1/5 arm64: Enable EDAC on ARM64

Quoted 4 lines · Loc Ho

This was discussed here
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/326986.html.
Without this, it will have compiler error as this function is called by.function edac_mc_scrub_block in file drivers/edac/edac_mc.c.

Argh, that's just silly. We should have a __weak atomic_scrub() in the edac core which arches can override but not have to supply a dummy just because...

I'll try to hack up something later.

Signature · 5 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
maintainer
#16 lore raw

PATCH v10 1/5 arm64: Enable EDAC on ARM64

Adding more arch people.

Quoted 11 lines · Borislav Petkov
Quoted 4 lines · Loc Ho

This was discussed here
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/326986.html.
Without this, it will have compiler error as this function is called by.function edac_mc_scrub_block in file drivers/edac/edac_mc.c.

Argh, that's just silly. We should have a __weak atomic_scrub() in the edac core which arches can override but not have to supply a dummy just because...

I'll try to hack up something later.

Phew, so this wasn't easy but I think I have it. And it is nicer now. Patch as a reply to this message.

Signature · 5 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
maintainer
#17 lore raw

RFC PATCH 1/1 EDAC: Cleanup atomic_scrub mess

From: Borislav Petkov <[email protected]>

So first of all, this atomic_scrub() function's naming is bad. It looks like an atomic_t helper. Change it to edac_atomic_scrub().

The bigger problem is that this function is arch-specific and every new arch which doesn't necessarily need that functionality still needs to define it, otherwise EDAC doesn't compile.

So instead of doing that and including arch-specific headers, have each arch define an EDAC_ATOMIC_SCRUB symbol which can be used in edac_mc.c for ifdeffery. Much cleaner.

We already are doing this with another symbol - EDAC_SUPPORT. This is also much cleaner than having CONFIG_EDAC explicitly depend on all the arches which need/have EDAC support and drivers.

This way I can kill the useless edac.h header in tile too.

Cc Russell King <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Chris Metcalf <[email protected]>
Cc x86 at kernel.org
Cc Doug Thompson <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Markos Chandras <[email protected]>
Cc "Steven J. Hill" <[email protected]>
Cc "Maciej W. Rozycki" <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc linux-kernel at vger.kernel.org
Cc linux-mips at linux-mips.org
Cc linuxppc-dev at lists.ozlabs.org
Cc linux-edac at vger.kernel.org

---

Patch is still RFC as I need to compile in on those other arches first. It should build though - it is simple enough ... famous last words :-P

 arch/arm/Kconfig                |  2 ++
 arch/arm/include/asm/edac.h     |  5 +++--
 arch/mips/Kconfig               |  1 +
 arch/mips/include/asm/edac.h    |  4 ++--
 arch/powerpc/Kconfig            |  2 ++
 arch/powerpc/include/asm/edac.h |  4 ++--
 arch/tile/Kconfig               |  1 +
 arch/tile/include/asm/edac.h    | 29 -----------------------------
 arch/x86/Kconfig                |  2 ++
 arch/x86/include/asm/edac.h     |  2 +-
 drivers/edac/Kconfig            |  7 ++++---
 drivers/edac/edac_mc.c          |  9 +++++++--
 12 files changed, 27 insertions(+), 41 deletions(-)
 delete mode 100644 arch/tile/include/asm/edac.h
arch/arm/Kconfig +2 -0
index 45df48ba0b12..325d6f3a596a 100644
@@ -15,6 +15,8 @@ config ARM
 	select CLONE_BACKWARDS
 	select CPU_PM if (SUSPEND || CPU_IDLE)
 	select DCACHE_WORD_ACCESS if HAVE_EFFICIENT_UNALIGNED_ACCESS
+	select EDAC_SUPPORT
+	select EDAC_ATOMIC_SCRUB
 	select GENERIC_ALLOCATOR
 	select GENERIC_ATOMIC64 if (CPU_V7M || CPU_V6 || !CPU_32v6K || !AEABI)
 	select GENERIC_CLOCKEVENTS_BROADCAST if SMP
arch/arm/include/asm/edac.h +3 -2
index 0df7a2c1fc3d..5189fa819b60 100644
@@ -18,11 +18,12 @@
 #define ASM_EDAC_H
 /*
  * ECC atomic, DMA, SMP and interrupt safe scrub function.
- * Implements the per arch atomic_scrub() that EDAC use for software
+ * Implements the per arch edac_atomic_scrub() that EDAC use for software
  * ECC scrubbing.  It reads memory and then writes back the original
  * value, allowing the hardware to detect and correct memory errors.
  */
-static inline void atomic_scrub(void *va, u32 size)
+
+static inline void edac_atomic_scrub(void *va, u32 size)
 {
 #if __LINUX_ARM_ARCH__ >= 6
 	unsigned int *virt_addr = va;
arch/mips/Kconfig +1 -0
index f5016656494f..b65edf514b40 100644
@@ -819,6 +819,7 @@ config CAVIUM_OCTEON_SOC
 	select SYS_SUPPORTS_64BIT_KERNEL
 	select SYS_SUPPORTS_BIG_ENDIAN
 	select EDAC_SUPPORT
+	select EDAC_ATOMIC_SCRUB
 	select SYS_SUPPORTS_LITTLE_ENDIAN
 	select SYS_SUPPORTS_HOTPLUG_CPU if CPU_BIG_ENDIAN
 	select SYS_HAS_EARLY_PRINTK
arch/mips/include/asm/edac.h +2 -2
index 94105d3f58f4..980b16527374 100644
@@ -5,7 +5,7 @@
 
 /* ECC atomic, DMA, SMP and interrupt safe scrub function */
 
-static inline void atomic_scrub(void *va, u32 size)
+static inline void edac_atomic_scrub(void *va, u32 size)
 {
 	unsigned long *virt_addr = va;
 	unsigned long temp;
@@ -21,7 +21,7 @@ static inline void atomic_scrub(void *va, u32 size)
 
 		__asm__ __volatile__ (
 		"	.set	mips2					\n"
-		"1:	ll	%0, %1		# atomic_scrub		\n"
+		"1:	ll	%0, %1		# edac_atomic_scrub	\n"
 		"	addu	%0, $0					\n"
 		"	sc	%0, %1					\n"
 		"	beqz	%0, 1b					\n"
arch/powerpc/Kconfig +2 -0
index 190cc48abc0c..5ef27113b898 100644
@@ -153,6 +153,8 @@ config PPC
 	select NO_BOOTMEM
 	select HAVE_GENERIC_RCU_GUP
 	select HAVE_PERF_EVENTS_NMI if PPC64
+	select EDAC_SUPPORT
+	select EDAC_ATOMIC_SCRUB
 
 config GENERIC_CSUM
 	def_bool CPU_LITTLE_ENDIAN
arch/powerpc/include/asm/edac.h +2 -2
index 6ead88bbfbb8..5571e23d253e 100644
@@ -12,11 +12,11 @@
 #define ASM_EDAC_H
 /*
  * ECC atomic, DMA, SMP and interrupt safe scrub function.
- * Implements the per arch atomic_scrub() that EDAC use for software
+ * Implements the per arch edac_atomic_scrub() that EDAC use for software
  * ECC scrubbing.  It reads memory and then writes back the original
  * value, allowing the hardware to detect and correct memory errors.
  */
-static __inline__ void atomic_scrub(void *va, u32 size)
+static __inline__ void edac_atomic_scrub(void *va, u32 size)
 {
 	unsigned int *virt_addr = va;
 	unsigned int temp;
arch/tile/Kconfig +1 -0
index a07e31b50d3f..59cf0b911898 100644
@@ -28,6 +28,7 @@ config TILE
 	select HAVE_DEBUG_STACKOVERFLOW
 	select ARCH_WANT_FRAME_POINTERS
 	select HAVE_CONTEXT_TRACKING
+	select EDAC_SUPPORT
 
 # FIXME: investigate whether we need/want these options.
 #	select HAVE_IOREMAP_PROT
arch/tile/include/asm/edac.h deleted +0 -29
deleted file mode 100644
index 87fc83eeaffd..000000000000
@@ -1,29 +0,0 @@
-/*
- * Copyright 2011 Tilera Corporation. All Rights Reserved.
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation, version 2.
- *
- *   This program is distributed in the hope that it will be useful, but
- *   WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- *   NON INFRINGEMENT.  See the GNU General Public License for
- *   more details.
- */
-
-#ifndef _ASM_TILE_EDAC_H
-#define _ASM_TILE_EDAC_H
-
-/* ECC atomic, DMA, SMP and interrupt safe scrub function */
-
-static inline void atomic_scrub(void *va, u32 size)
-{
-	/*
-	 * These is nothing to be done here because CE is
-	 * corrected by the mshim.
-	 */
-	return;
-}
-
-#endif /* _ASM_TILE_EDAC_H */
arch/x86/Kconfig +2 -0
index 226d5696e1d1..482c160a9fe9 100644
@@ -143,6 +143,8 @@ config X86
 	select ACPI_LEGACY_TABLES_LOOKUP if ACPI
 	select X86_FEATURE_NAMES if PROC_FS
 	select SRCU
+	select EDAC_SUPPORT
+	select EDAC_ATOMIC_SCRUB
 
 config INSTRUCTION_DECODER
 	def_bool y
arch/x86/include/asm/edac.h +1 -1
index e9b57ecc70c5..cf8fdf83b231 100644
@@ -3,7 +3,7 @@
 
 /* ECC atomic, DMA, SMP and interrupt safe scrub function */
 
-static inline void atomic_scrub(void *va, u32 size)
+static inline void edac_atomic_scrub(void *va, u32 size)
 {
 	u32 i, *virt_addr = va;
 
drivers/edac/Kconfig +4 -3
index 2d2530cdf99d..a90e06ac1631 100644
@@ -2,15 +2,16 @@
 #	EDAC Kconfig
 #	Copyright (c) 2008 Doug Thompson www.softwarebitmaker.com
 #	Licensed and distributed under the GPL
-#
+
+config EDAC_ATOMIC_SCRUB
+	bool
 
 config EDAC_SUPPORT
 	bool
 
 menuconfig EDAC
 	bool "EDAC (Error Detection And Correction) reporting"
-	depends on HAS_IOMEM
-	depends on X86 || PPC || TILE || ARM || EDAC_SUPPORT
+	depends on HAS_IOMEM && EDAC_SUPPORT
 	help
 	  EDAC is designed to report errors in the core system.
 	  These are low-level errors that are reported in the CPU or
drivers/edac/edac_mc.c +7 -2
index af3be1914dbb..943ed8cf71b9 100644
@@ -30,11 +30,16 @@
 #include <linux/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/page.h>
-#include <asm/edac.h>
 #include "edac_core.h"
 #include "edac_module.h"
 #include <ras/ras_event.h>
 
+#ifdef CONFIG_EDAC_ATOMIC_SCRUB
+#include <asm/edac.h>
+#else
+#define edac_atomic_scrub(va, size) do { } while (0)
+#endif
+
 /* lock to memory controller's control array */
 static DEFINE_MUTEX(mem_ctls_mutex);
 static LIST_HEAD(mc_devices);
@@ -874,7 +879,7 @@ static void edac_mc_scrub_block(unsigned long page, unsigned long offset,
 	virt_addr = kmap_atomic(pg);
 
 	/* Perform architecture specific atomic scrub operation */
-	atomic_scrub(virt_addr + offset, size);
+	edac_atomic_scrub(virt_addr + offset, size);
 
 	/* Unmap and complete */
 	kunmap_atomic(virt_addr);
Signature · 8 lines
2.3.5

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
#18 lore raw

RFC PATCH 1/1 EDAC: Cleanup atomic_scrub mess

Quoted 13 lines · Borislav Petkov

From: Borislav Petkov<[email protected]>

So first of all, this atomic_scrub() function's naming is bad. It looks like an atomic_t helper. Change it to edac_atomic_scrub().

The bigger problem is that this function is arch-specific and every new arch which doesn't necessarily need that functionality still needs to define it, otherwise EDAC doesn't compile.

So instead of doing that and including arch-specific headers, have each arch define an EDAC_ATOMIC_SCRUB symbol which can be used in edac_mc.c for ifdeffery. Much cleaner.

Quoted 7 lines

We already are doing this with another symbol - EDAC_SUPPORT. This is also much cleaner than having CONFIG_EDAC explicitly depend on all the arches which need/have EDAC support and drivers.

This way I can kill the useless edac.h header in tile too.

Signature · 2 lines
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com
maintainer
#19 lore raw

RFC PATCH 1/1 EDAC: Cleanup atomic_scrub mess

Quoted 18 lines · Chris Metcalf
Quoted 17 lines · Borislav Petkov

From: Borislav Petkov<[email protected]>

So first of all, this atomic_scrub() function's naming is bad. It looks like an atomic_t helper. Change it to edac_atomic_scrub().

The bigger problem is that this function is arch-specific and every new arch which doesn't necessarily need that functionality still needs to define it, otherwise EDAC doesn't compile.

So instead of doing that and including arch-specific headers, have each arch define an EDAC_ATOMIC_SCRUB symbol which can be used in edac_mc.c for ifdeffery. Much cleaner.

We already are doing this with another symbol - EDAC_SUPPORT. This is also much cleaner than having CONFIG_EDAC explicitly depend on all the arches which need/have EDAC support and drivers.

Quoted 5 lines
Quoted 3 lines

This way I can kill the useless edac.h header in tile too.

Thanks.

Just to clarify after today's discussion on IRC: this patch doesn't change current DRAM scrubbing behavior on the relevant arches - it simply makes the definition of that atomic_scrub thing non-mandatory on new arches or on those which don't need it.

In the meantime, patch has been build-tested on arm and ppc - the two I'm missing an ACK for.

:-)

Signature · 5 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
#20 lore raw

RFC PATCH 1/1 EDAC: Cleanup atomic_scrub mess

Quoted 27 lines · Borislav Petkov
Quoted 18 lines · Chris Metcalf
Quoted 17 lines · Borislav Petkov

From: Borislav Petkov<[email protected]>

So first of all, this atomic_scrub() function's naming is bad. It looks like an atomic_t helper. Change it to edac_atomic_scrub().

The bigger problem is that this function is arch-specific and every new arch which doesn't necessarily need that functionality still needs to define it, otherwise EDAC doesn't compile.

So instead of doing that and including arch-specific headers, have each arch define an EDAC_ATOMIC_SCRUB symbol which can be used in edac_mc.c for ifdeffery. Much cleaner.

We already are doing this with another symbol - EDAC_SUPPORT. This is also much cleaner than having CONFIG_EDAC explicitly depend on all the arches which need/have EDAC support and drivers.

Quoted 5 lines
Quoted 3 lines

This way I can kill the useless edac.h header in tile too.

Thanks.

Quoted 7 lines

Just to clarify after today's discussion on IRC: this patch doesn't change current DRAM scrubbing behavior on the relevant arches - it simply makes the definition of that atomic_scrub thing non-mandatory on new arches or on those which don't need it.

In the meantime, patch has been build-tested on arm and ppc - the two I'm missing an ACK for.

I haven't tested it but it looks sane:

cheers

#21 lore raw

RFC PATCH 1/1 EDAC: Cleanup atomic_scrub mess

In reply to Borislav Petkov
Quoted 13 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

So first of all, this atomic_scrub() function's naming is bad. It looks like an atomic_t helper. Change it to edac_atomic_scrub().

The bigger problem is that this function is arch-specific and every new arch which doesn't necessarily need that functionality still needs to define it, otherwise EDAC doesn't compile.

So instead of doing that and including arch-specific headers, have each arch define an EDAC_ATOMIC_SCRUB symbol which can be used in edac_mc.c for ifdeffery. Much cleaner.

Quoted 8 lines

We already are doing this with another symbol - EDAC_SUPPORT. This is also much cleaner than having CONFIG_EDAC explicitly depend on all the arches which need/have EDAC support and drivers.

This way I can kill the useless edac.h header in tile too.

arch/arm/Kconfig config ARM · line 19

Quoted 10 lines
arch/arm/Kconfig +2 -0
index 45df48ba0b12..325d6f3a596a 100644
@@ -15,6 +15,8 @@ config ARM
 	select CLONE_BACKWARDS
 	select CPU_PM if (SUSPEND || CPU_IDLE)
 	select DCACHE_WORD_ACCESS if HAVE_EFFICIENT_UNALIGNED_ACCESS
+	select EDAC_SUPPORT
+	select EDAC_ATOMIC_SCRUB

I wonder if it would make sense to conditionalise EDAC_SUPPORT on...

		if CPU_32v6 || CPU_32v7

since presumably its not useful for older architectures (certainly edac_atomic_scrub() is a no-op for earlier arches.)

Quoted 22 lines
arch/arm/Kconfig +0 -0
 	select GENERIC_ALLOCATOR
 	select GENERIC_ATOMIC64 if (CPU_V7M || CPU_V6 || !CPU_32v6K || !AEABI)
 	select GENERIC_CLOCKEVENTS_BROADCAST if SMP
arch/arm/include/asm/edac.h +3 -2
index 0df7a2c1fc3d..5189fa819b60 100644
@@ -18,11 +18,12 @@
 #define ASM_EDAC_H
 /*
  * ECC atomic, DMA, SMP and interrupt safe scrub function.
- * Implements the per arch atomic_scrub() that EDAC use for software
+ * Implements the per arch edac_atomic_scrub() that EDAC use for software
  * ECC scrubbing.  It reads memory and then writes back the original
  * value, allowing the hardware to detect and correct memory errors.
  */
-static inline void atomic_scrub(void *va, u32 size)
+
+static inline void edac_atomic_scrub(void *va, u32 size)
 {
 #if __LINUX_ARM_ARCH__ >= 6
 	unsigned int *virt_addr = va;
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
maintainer
#22 lore raw

RFC PATCH 1/1 EDAC: Cleanup atomic_scrub mess

Quoted 1 line · Russell King - ARM Linux

Thanks!

I've got all the ACKs now :-)

Quoted 13 lines

arch/arm/Kconfig config ARM · line 19

Quoted 11 lines
arch/arm/Kconfig +2 -0
index 45df48ba0b12..325d6f3a596a 100644
@@ -15,6 +15,8 @@ config ARM
 	select CLONE_BACKWARDS
 	select CPU_PM if (SUSPEND || CPU_IDLE)
 	select DCACHE_WORD_ACCESS if HAVE_EFFICIENT_UNALIGNED_ACCESS
+	select EDAC_SUPPORT
+	select EDAC_ATOMIC_SCRUB

I wonder if it would make sense to conditionalise EDAC_SUPPORT on...

Quoted 1 line
		if CPU_32v6 || CPU_32v7

I guess you can.

Especially if no newer 32-bit ARM would need the scrubbing anymore. Disadvantage is, if turns out CPU_32v8 (would there even be v8, no idea...) and newer would need it after all, you'd have to explicitly enable it.

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
#23 lore raw

v10 cover edac: Add APM X-Gene SoC EDAC driver

In reply to Loc Ho
Quoted 10 lines · On Monday 18 May 2015 17:24:36 Loc Ho wrote:

This patch adds support for the APM X-Gene SoC EDAC driver for DT.

v10:
* Move regmap for CSW, MCBA, MCBB, and efuse to top driver node and add accessor support functions
* Change retrieval OF address proerty for subnode to use of_address_to_resource
* Add COMPILE_TEST to Kconfig for EDAC_XGENE
* Update DT binding documentation and DT node accordingly
* Remove DT node naming and number from nodes

Looks good to me. When you address my last comments, please add

Arnd