Skip to contentSkip to conversation

EDAC drivers for Armada XP L2 and DDR

PATCH Superseded Jan Luebbe 4 participants 16 messages Aug 2, 2017 – Aug 14, 2017

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jan Luebbe

author maintainer
#0 lore raw

v2 cover EDAC drivers for Armada XP L2 and DDR

This series adds drivers for the L2 cache and DDR RAM ECC functionality as found on the MV78230/MV78x60 SoCs. I've tested these changes with the MV78460 (on a custom board with a DDR3 ECC DIMM).

Also contained in this series are an additional debugfs wrapper and devm_ helpers for edac_mc_/edac_device_ allocation and registration, which make error handing and cleanup simpler.

Compared to the previous v1 series, the following changes have been made:
- Add the aurora-l2 register defines earlier in the series (suggested by Russell King and Gregory CLEMENT )
- Changed the DT vendor prefix from "arm" to "marvell" for the ecc-enable/disable properties on the aurora-l2 (suggested by Russell King)
- Fix some warnings reported by checkpatch

Compared to the original RFC series, the following changes have been made:
- Integrated Chris' patches for parity and ECC configuration via DT
- Merged the DDR RAM and L2 cache drivers (as requested by Borislav, analogous to fsl_ddr_edac.c and mpc85xx_edac.c)
- Added myself to MAINTAINERS (requested by Borislav)
- L2 cache: Track the msg size and use snprintf (review comment by Chris)
- L2 cache: Split error injection from the check function (review comment by Chris)
- DDR RAM: Allow 16 bit width in addition to 32 and 64 bit (review comment by Chris)
- Use of_match_ptr() (review comments by Chris)
- Minor checkpatch cleanups

Chris Packham (2):
ARM: l2x0: support parity-enable/disable on aurora
ARM: l2x0: add marvell,ecc-enable property for aurora

Jan Luebbe (7):
ARM: l2c: move cache-aurora-l2.h to asm/hardware
ARM: aurora-l2: add prefix to MAX_RANGE_SIZE
ARM: aurora-l2: add defines for parity and ECC registers
EDAC: Add missing debugfs_create_x32 wrapper
EDAC: Add devres helpers for
edac_mc_alloc/edac_mc_add_mc(_with_groups)
EDAC: Add devres helpers for
edac_device_alloc_ctl_info/edac_device_add_device
EDAC: Add driver for the Marvell Armada XP SDRAM and L2 cache ECC

 Documentation/devicetree/bindings/arm/l2c2x0.txt |   2 +
 MAINTAINERS                                      |   6 +
 arch/arm/include/asm/hardware/cache-aurora-l2.h  | 103 ++++
 arch/arm/mm/cache-aurora-l2.h                    |  55 --
 arch/arm/mm/cache-l2x0.c                         |  20 +-
 drivers/edac/Kconfig                             |   7 +
 drivers/edac/Makefile                            |   1 +
 drivers/edac/armada_xp_edac.c                    | 639 +++++++++++++++++++++++
 drivers/edac/debugfs.c                           |  11 +
 drivers/edac/edac_device.c                       |  60 +++
 drivers/edac/edac_device.h                       |  29 +
 drivers/edac/edac_mc.c                           |  54 ++
 drivers/edac/edac_mc.h                           |  26 +
 drivers/edac/edac_module.h                       |   5 +
 14 files changed, 960 insertions(+), 58 deletions(-)
 create mode 100644 arch/arm/include/asm/hardware/cache-aurora-l2.h
 delete mode 100644 arch/arm/mm/cache-aurora-l2.h
 create mode 100644 drivers/edac/armada_xp_edac.c
Signature · 1 line
2.11.0
author maintainer
#1 lore raw

PATCH v2 1/9 ARM: l2c: move cache-aurora-l2.h to asm/hardware

This include file will be used by the AURORA EDAC code.

---
 arch/arm/{mm => include/asm/hardware}/cache-aurora-l2.h | 0
 arch/arm/mm/cache-l2x0.c                                | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename arch/arm/{mm => include/asm/hardware}/cache-aurora-l2.h (100%)
arch/arm/include/asm/hardware/cache-aurora-l2.h renamed from arch/arm/mm/cache-aurora-l2.h +0 -0
similarity index 100%
rename from arch/arm/mm/cache-aurora-l2.h
rename to arch/arm/include/asm/hardware/cache-aurora-l2.h
arch/arm/mm/cache-l2x0.c +1 -1
index 808efbb89b88..a00d6f7fd34c 100644
@@ -30,8 +30,8 @@
 #include <asm/cp15.h>
 #include <asm/cputype.h>
 #include <asm/hardware/cache-l2x0.h>
+#include <asm/hardware/cache-aurora-l2.h>
 #include "cache-tauros3.h"
-#include "cache-aurora-l2.h"
 
 struct l2c_init_data {
 	const char *type;
Signature · 1 line
2.11.0
author maintainer
#2 lore raw

PATCH v2 2/9 ARM: aurora-l2: add prefix to MAX_RANGE_SIZE

In reply to Jan Luebbe

The macro name is too generic, so add a AURORA_ prefix.

---
 arch/arm/include/asm/hardware/cache-aurora-l2.h | 2 +-
 arch/arm/mm/cache-l2x0.c                        | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/include/asm/hardware/cache-aurora-l2.h +1 -1
index c86124769831..dc5c479ec4c3 100644
@@ -41,7 +41,7 @@
 #define AURORA_ACR_FORCE_WRITE_THRO_POLICY	\
 	(2 << AURORA_ACR_FORCE_WRITE_POLICY_OFFSET)
 
-#define MAX_RANGE_SIZE		1024
+#define AURORA_MAX_RANGE_SIZE	1024
 
 #define AURORA_WAY_SIZE_SHIFT	2
 
arch/arm/mm/cache-l2x0.c +2 -2
index a00d6f7fd34c..7d2d2a3c67d0 100644
@@ -1364,8 +1364,8 @@ static unsigned long aurora_range_end(unsigned long start, unsigned long end)
 	 * since cache range operations stall the CPU pipeline
 	 * until completion.
 	 */
-	if (end > start + MAX_RANGE_SIZE)
-		end = start + MAX_RANGE_SIZE;
+	if (end > start + AURORA_MAX_RANGE_SIZE)
+		end = start + AURORA_MAX_RANGE_SIZE;
 
 	/*
 	 * Cache range operations can't straddle a page boundary.
Signature · 1 line
2.11.0
author maintainer
#3 lore raw

PATCH v2 3/9 ARM: aurora-l2: add defines for parity and ECC registers

In reply to Jan Luebbe

These defines will be used by subsequent patches to add support for the parity check and error correction functionality in the Aurora L2 cache controller.

---
 arch/arm/include/asm/hardware/cache-aurora-l2.h | 48 +++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
arch/arm/include/asm/hardware/cache-aurora-l2.h +48 -0
index dc5c479ec4c3..c32be689d1f6 100644
@@ -31,6 +31,9 @@
 #define AURORA_ACR_REPLACEMENT_TYPE_SEMIPLRU \
 	(3 << AURORA_ACR_REPLACEMENT_OFFSET)
 
+#define AURORA_ACR_PARITY_EN	(1 << 21)
+#define AURORA_ACR_ECC_EN	(1 << 20)
+
 #define AURORA_ACR_FORCE_WRITE_POLICY_OFFSET	0
 #define AURORA_ACR_FORCE_WRITE_POLICY_MASK	\
 	(0x3 << AURORA_ACR_FORCE_WRITE_POLICY_OFFSET)
@@ -41,6 +44,51 @@
 #define AURORA_ACR_FORCE_WRITE_THRO_POLICY	\
 	(2 << AURORA_ACR_FORCE_WRITE_POLICY_OFFSET)
 
+#define AURORA_ERR_CNT_REG          0x600
+#define AURORA_ERR_ATTR_CAP_REG     0x608
+#define AURORA_ERR_ADDR_CAP_REG     0x60c
+#define AURORA_ERR_WAY_CAP_REG      0x610
+#define AURORA_ERR_INJECT_CTL_REG   0x614
+#define AURORA_ERR_INJECT_MASK_REG  0x618
+
+#define AURORA_ERR_CNT_CLR_OFFSET         31
+#define AURORA_ERR_CNT_CLR		   \
+	(0x1 << AURORA_ERR_CNT_CLR_OFFSET)
+#define AURORA_ERR_CNT_UE_OFFSET          16
+#define AURORA_ERR_CNT_UE_MASK             \
+	(0x7fff << AURORA_ERR_CNT_UE_OFFSET)
+#define AURORA_ERR_CNT_CE_OFFSET            0
+#define AURORA_ERR_CNT_CE_MASK              \
+	(0xffff << AURORA_ERR_CNT_CE_OFFSET)
+
+#define AURORA_ERR_ATTR_CAP_ERR_SOURCE_OFFSET       16
+#define AURORA_ERR_ATTR_CAP_ERR_SOURCE_MASK          \
+	(0x7 << AURORA_ERR_ATTR_CAP_ERR_SOURCE_OFFSET)
+#define AURORA_ERR_ATTR_CAP_TRANS_TYPE_OFFSET       12
+#define AURORA_ERR_ATTR_CAP_TRANS_TYPE_MASK          \
+	(0xf << AURORA_ERR_ATTR_CAP_TRANS_TYPE_OFFSET)
+#define AURORA_ERR_ATTR_CAP_ERR_TYPE_OFFSET          8
+#define AURORA_ERR_ATTR_CAP_ERR_TYPE_MASK            \
+	(0x3 << AURORA_ERR_ATTR_CAP_ERR_TYPE_OFFSET)
+#define AURORA_ERR_ATTR_CAP_VALID_OFFSET             0
+#define AURORA_ERR_ATTR_CAP_VALID                    \
+	(0x1 << AURORA_ERR_ATTR_CAP_VALID_OFFSET)
+
+#define AURORA_ERR_ADDR_CAP_ADDR_MASK 0xffffffe0
+
+#define AURORA_ERR_WAY_CAP_INDEX_OFFSET          8
+#define AURORA_ERR_WAY_CAP_INDEX_MASK            \
+	(0xfff << AURORA_ERR_WAY_CAP_INDEX_OFFSET)
+#define AURORA_ERR_WAY_CAP_WAY_OFFSET          1
+#define AURORA_ERR_WAY_CAP_WAY_MASK            \
+	(0xf << AURORA_ERR_WAY_CAP_WAY_OFFSET)
+
+#define AURORA_ERR_INJECT_CTL_ADDR_MASK 0xfffffff0
+#define AURORA_ERR_ATTR_CAP_TRANS_TYPE_OFFSET   12
+#define AURORA_ERR_INJECT_CTL_EN_MASK          0x3
+#define AURORA_ERR_INJECT_CTL_EN_PARITY        0x2
+#define AURORA_ERR_INJECT_CTL_EN_ECC           0x1
+
 #define AURORA_MAX_RANGE_SIZE	1024
 
 #define AURORA_WAY_SIZE_SHIFT	2
Signature · 1 line
2.11.0
author maintainer
#4 lore raw

PATCH v2 4/9 ARM: l2x0: support parity-enable/disable on aurora

In reply to Jan Luebbe

From: Chris Packham <[email protected]>

The aurora cache on the Marvell Armada-XP SoC supports the same tag parity features as the other l2x0 cache implementations.

[jlu at pengutronix.de: use aurora specific define AURORA_ACR_PARITY_EN]
---
 arch/arm/mm/cache-l2x0.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/mm/cache-l2x0.c +7 -0
index 7d2d2a3c67d0..b70bee74750d 100644
@@ -1505,6 +1505,13 @@ static void __init aurora_of_parse(const struct device_node *np,
 		mask |= AURORA_ACR_FORCE_WRITE_POLICY_MASK;
 	}
 
+	if (of_property_read_bool(np, "arm,parity-enable")) {
+		mask |= AURORA_ACR_PARITY_EN;
+		val |= AURORA_ACR_PARITY_EN;
+	} else if (of_property_read_bool(np, "arm,parity-disable")) {
+		mask |= AURORA_ACR_PARITY_EN;
+	}
+
 	*aux_val &= ~mask;
 	*aux_val |= val;
 	*aux_mask &= ~mask;
Signature · 1 line
2.11.0
author maintainer
#5 lore raw

PATCH v2 5/9 ARM: l2x0: add marvell,ecc-enable property for aurora

In reply to Jan Luebbe

From: Chris Packham <[email protected]>

The aurora cache on the Marvell Armada-XP SoC supports ECC protection for the L2 data arrays. Add a "marvell,ecc-enable" device tree property which can be used to enable this.

[jlu at pengutronix.de: use aurora specific define AURORA_ACR_ECC_EN]
---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 2 ++
 arch/arm/mm/cache-l2x0.c                         | 7 +++++++
 2 files changed, 9 insertions(+)
Documentation/devicetree/bindings/arm/l2c2x0.txt +2 -0
index fbe6cb21f4cf..15a84f0ba9f1 100644
@@ -76,6 +76,8 @@ Optional properties:
   specified to indicate that such transforms are precluded.
 - arm,parity-enable : enable parity checking on the L2 cache (L220 or PL310).
 - arm,parity-disable : disable parity checking on the L2 cache (L220 or PL310).
+- marvell,ecc-enable : enable ECC protection on the L2 cache
+- marvell,ecc-disable : disable ECC protection on the L2 cache
 - arm,outer-sync-disable : disable the outer sync operation on the L2 cache.
   Some core tiles, especially ARM PB11MPCore have a faulty L220 cache that
   will randomly hang unless outer sync operations are disabled.
arch/arm/mm/cache-l2x0.c +7 -0
index b70bee74750d..644f786e4fa9 100644
@@ -1505,6 +1505,13 @@ static void __init aurora_of_parse(const struct device_node *np,
 		mask |= AURORA_ACR_FORCE_WRITE_POLICY_MASK;
 	}
 
+	if (of_property_read_bool(np, "marvell,ecc-enable")) {
+		mask |= AURORA_ACR_ECC_EN;
+		val |= AURORA_ACR_ECC_EN;
+	} else if (of_property_read_bool(np, "marvell,ecc-disable")) {
+		mask |= AURORA_ACR_ECC_EN;
+	}
+
 	if (of_property_read_bool(np, "arm,parity-enable")) {
 		mask |= AURORA_ACR_PARITY_EN;
 		val |= AURORA_ACR_PARITY_EN;
Signature · 1 line
2.11.0
author maintainer
#6 lore raw

PATCH v2 6/9 EDAC: Add missing debugfs_create_x32 wrapper

In reply to Jan Luebbe

We already have wrappers for x8 and x16, so add the missing x32 one.

---
 drivers/edac/debugfs.c     | 11 +++++++++++
 drivers/edac/edac_module.h |  5 +++++
 2 files changed, 16 insertions(+)
drivers/edac/debugfs.c +11 -0
index 92dbb7e2320c..268ede7a60b2 100644
@@ -161,3 +161,14 @@ struct dentry *edac_debugfs_create_x16(const char *name, umode_t mode,
 	return debugfs_create_x16(name, mode, parent, value);
 }
 EXPORT_SYMBOL_GPL(edac_debugfs_create_x16);
+
+/* Wrapper for debugfs_create_x32() */
+struct dentry *edac_debugfs_create_x32(const char *name, umode_t mode,
+				       struct dentry *parent, u32 *value)
+{
+	if (!parent)
+		parent = edac_debugfs;
+
+	return debugfs_create_x32(name, mode, parent, value);
+}
+EXPORT_SYMBOL_GPL(edac_debugfs_create_x32);
drivers/edac/edac_module.h +5 -0
index 014871e169cc..3d87cb15ab45 100644
@@ -81,6 +81,8 @@ struct dentry *
 edac_debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent, u8 *value);
 struct dentry *
 edac_debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent, u16 *value);
+struct dentry *
+edac_debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent, u32 *value);
 #else
 static inline int edac_debugfs_init(void)					{ return -ENODEV; }
 static inline void edac_debugfs_exit(void)					{ }
@@ -97,6 +99,9 @@ edac_debugfs_create_x8(const char *name, umode_t mode,
 static inline struct dentry *
 edac_debugfs_create_x16(const char *name, umode_t mode,
 		       struct dentry *parent, u16 *value)			{ return NULL; }
+static inline struct dentry *
+edac_debugfs_create_x32(const char *name, umode_t mode,
+		       struct dentry *parent, u32 *value)			{ return NULL; }
 #endif
 
 /*
Signature · 1 line
2.11.0
author maintainer
#7 lore raw

PATCH v2 7/9 EDAC: Add devres helpers for edac_mc_alloc/edac_mc_add_mc(_with_groups)

In reply to Jan Luebbe

These helpers simplify error handling in the _probe functions and automate deallocation in the _remove functions.

---
 drivers/edac/edac_mc.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/edac/edac_mc.h | 26 ++++++++++++++++++++++++
 2 files changed, 80 insertions(+)
drivers/edac/edac_mc.c +54 -0
index 480072139b7a..d3ee2b851329 100644
@@ -517,6 +517,34 @@ void edac_mc_free(struct mem_ctl_info *mci)
 }
 EXPORT_SYMBOL_GPL(edac_mc_free);
 
+/**
+ * devm_edac_mc_free() - Internal helper to call edac_mc_free from a devres
+ *	action.
+ */
+static void devm_edac_mc_free(void *mci)
+{
+	edac_mc_free((struct mem_ctl_info *)mci);
+}
+
+struct mem_ctl_info *devm_edac_mc_alloc(struct device *dev,
+					unsigned int mc_num,
+					unsigned int n_layers,
+					struct edac_mc_layer *layers,
+					unsigned int sz_pvt)
+{
+	struct mem_ctl_info *mci;
+
+	mci = edac_mc_alloc(mc_num, n_layers, layers, sz_pvt);
+	if (!mci)
+		return mci;
+
+	if (devm_add_action_or_reset(dev, devm_edac_mc_free, mci))
+		return NULL;
+
+	return mci;
+}
+EXPORT_SYMBOL_GPL(devm_edac_mc_alloc);
+
 bool edac_has_mcs(void)
 {
 	bool ret;
@@ -828,6 +856,32 @@ struct mem_ctl_info *edac_mc_del_mc(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(edac_mc_del_mc);
 
+/**
+ * devm_edac_mc_del_mc() - Internal helper to call edac_mc_del_mc from a devres
+ *	action.
+ */
+static void devm_edac_mc_del_mc(void *dev)
+{
+	edac_mc_del_mc((struct device *)dev);
+}
+
+int devm_edac_mc_add_mc_with_groups(struct device *dev,
+				    struct mem_ctl_info *mci,
+				    const struct attribute_group **groups)
+{
+	int ret;
+
+	ret = edac_mc_add_mc_with_groups(mci, groups);
+	if (ret)
+		return ret;
+
+	if (devm_add_action_or_reset(dev, devm_edac_mc_del_mc, dev))
+		return 1;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(devm_edac_mc_add_mc_with_groups);
+
 static void edac_mc_scrub_block(unsigned long page, unsigned long offset,
 				u32 size)
 {
drivers/edac/edac_mc.h +26 -0
index 5357800e418d..32f88cc4a65b 100644
@@ -149,6 +149,32 @@ extern int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci,
 extern void edac_mc_free(struct mem_ctl_info *mci);
 
 /**
+ * devm_edac_mc_alloc() - Helper to call edac_mc_alloc() and register it for
+ *	cleanup with devres.
+ *
+ * Returns:
+ *	On success, return a pointer to struct mem_ctl_info pointer;
+ *	%NULL otherwise
+ */
+struct mem_ctl_info *devm_edac_mc_alloc(struct device *dev,
+					unsigned int mc_num,
+					unsigned int n_layers,
+					struct edac_mc_layer *layers,
+					unsigned int sz_pvt);
+
+/**
+ * devm_edac_mc_add_mc_with_groups() - Helper to call
+ *	edac_mc_add_mc_with_groups() and register it for cleanup with devres.
+ *
+ * Returns:
+ *	0 on Success, or an error code on failure
+ */
+int devm_edac_mc_add_mc_with_groups(struct device *dev,
+				    struct mem_ctl_info *mci,
+				    const struct attribute_group **groups);
+#define devm_edac_mc_add_mc(dev, mci)	devm_edac_mc_add_mc_with_groups(dev, mci, NULL)
+
+/**
  * edac_has_mcs() - Check if any MCs have been allocated.
  *
  * Returns:
Signature · 1 line
2.11.0
maintainer
#8 lore raw

PATCH v2 7/9 EDAC: Add devres helpers for edac_mc_alloc/edac_mc_add_mc(_with_groups)

Quoted 34 lines · Jan Luebbe

These helpers simplify error handling in the _probe functions and automate deallocation in the _remove functions.

---
 drivers/edac/edac_mc.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/edac/edac_mc.h | 26 ++++++++++++++++++++++++
 2 files changed, 80 insertions(+)
drivers/edac/edac_mc.c +17 -0
index 480072139b7a..d3ee2b851329 100644
@@ -517,6 +517,34 @@ void edac_mc_free(struct mem_ctl_info *mci)
 }
 EXPORT_SYMBOL_GPL(edac_mc_free);
 
+/**
+ * devm_edac_mc_free() - Internal helper to call edac_mc_free from a devres
+ *	action.
+ */
+static void devm_edac_mc_free(void *mci)
+{
+	edac_mc_free((struct mem_ctl_info *)mci);
+}
+
+struct mem_ctl_info *devm_edac_mc_alloc(struct device *dev,
+					unsigned int mc_num,
+					unsigned int n_layers,
+					struct edac_mc_layer *layers,
+					unsigned int sz_pvt)
+{
+	struct mem_ctl_info *mci;
+

drivers/edac/edac_mc.c void edac_mc_free(struct mem_ctl_info *mci) · line 546

Quoted 10 lines
drivers/edac/edac_mc.c +10 -0
+	mci = edac_mc_alloc(mc_num, n_layers, layers, sz_pvt);
+	if (!mci)
+		return mci;
+
+	if (devm_add_action_or_reset(dev, devm_edac_mc_free, mci))
+		return NULL;
+
+	return mci;
+}
+EXPORT_SYMBOL_GPL(devm_edac_mc_alloc);

Ok, I see what you want to do here but I'm not excited.

Rather, what I've been telling other EDAC driver writers is to first probe the hardware as much as possible until they *know* they're all ready to init and only then call the EDAC core to allocate structures.

Because, with this lazy method, the pointless memory allocation and freeing would still happen if the late probing fails. But that allocation and freeing is completely pointless.

So looking at armada_xp_mc_edac_probe(), for example, you should do edac_mc_alloc() *after* armada_xp_mc_edac_read_config() has succeeded. The same idea holds true for aurora_l2_edac_probe(): do all probing and gathering of info from the hardware first and then call EDAC core functions.

Thanks.

Signature · 4 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
author maintainer
#9 lore raw

PATCH v2 8/9 EDAC: Add devres helpers for edac_device_alloc_ctl_info/edac_device_add_device

In reply to Jan Luebbe

These helpers simplify error handling in the _probe functions and automate deallocation in the _remove functions.

---
 drivers/edac/edac_device.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/edac/edac_device.h | 29 ++++++++++++++++++++++
 2 files changed, 89 insertions(+)
drivers/edac/edac_device.c +60 -0
index 65cf2b9355c4..d011f42c3507 100644
@@ -232,6 +232,42 @@ void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info)
 }
 EXPORT_SYMBOL_GPL(edac_device_free_ctl_info);
 
+/**
+ * devm_edac_device_free_ctl_info() - Internal helper to call
+ *	edac_device_free_ctl_info from a devres action
+ */
+static void devm_edac_device_free_ctl_info(void *ctl_info)
+{
+	edac_device_free_ctl_info((struct edac_device_ctl_info *)ctl_info);
+}
+
+struct edac_device_ctl_info *devm_edac_device_alloc_ctl_info(
+	struct device *dev,
+	unsigned int sz_private,
+	char *edac_device_name, unsigned int nr_instances,
+	char *edac_block_name, unsigned int nr_blocks,
+	unsigned int offset_value,
+	struct edac_dev_sysfs_block_attribute *attrib_spec, unsigned int nr_attrib,
+	int device_index)
+{
+	struct edac_device_ctl_info *ctl_info;
+
+	ctl_info = edac_device_alloc_ctl_info(sz_private,
+			edac_device_name, nr_instances,
+			edac_block_name, nr_blocks,
+			offset_value,
+			attrib_spec, nr_attrib,
+			device_index);
+	if (!ctl_info)
+		return ctl_info;
+
+	if (devm_add_action_or_reset(dev, devm_edac_device_free_ctl_info, ctl_info))
+		return NULL;
+
+	return ctl_info;
+}
+EXPORT_SYMBOL_GPL(devm_edac_device_alloc_ctl_info);
+
 /*
  * find_edac_device_by_dev
  *	scans the edac_device list for a specific 'struct device *'
@@ -539,6 +575,30 @@ struct edac_device_ctl_info *edac_device_del_device(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(edac_device_del_device);
 
+/**
+ * devm_edac_device_del_device() - Internal helper to call
+ *	edac_device_del_device from a devres action
+ */
+static void devm_edac_device_del_device(void *dev)
+{
+	edac_device_del_device((struct device *)dev);
+}
+
+int devm_edac_device_add_device(struct device *dev,
+		struct edac_device_ctl_info *edac_dev)
+{
+	int ret;
+
+	ret = edac_device_add_device(edac_dev);
+	if (ret)
+		return ret;
+
+	if (devm_add_action_or_reset(dev, devm_edac_device_del_device, dev))
+		return 1;
+
+	return 0;
+}
+
 static inline int edac_device_get_log_ce(struct edac_device_ctl_info *edac_dev)
 {
 	return edac_dev->log_ce;
drivers/edac/edac_device.h +29 -0
index 1aaba74ae411..711a50b133cd 100644
@@ -258,6 +258,24 @@ extern struct edac_device_ctl_info *edac_device_alloc_ctl_info(
 extern void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info);
 
 /**
+ * devm_edac_device_alloc_ctl_info: Allocate a new managed edac device
+ *	control info structure
+ *
+ *	This function takes the same arguments as edac_device_alloc_ctl_info in
+ *	addition to the owning device. The structure is freed by devres using
+ *	edac_device_free_ctl_info.
+ */
+extern struct edac_device_ctl_info *devm_edac_device_alloc_ctl_info(
+		struct device *dev,
+		unsigned int sizeof_private,
+		char *edac_device_name, unsigned int nr_instances,
+		char *edac_block_name, unsigned int nr_blocks,
+		unsigned int offset_value,
+		struct edac_dev_sysfs_block_attribute *block_attributes,
+		unsigned int nr_attribs,
+		int device_index);
+
+/**
  * edac_device_add_device: Insert the 'edac_dev' structure into the
  *	 edac_device global list and create sysfs entries associated with
  *	 edac_device structure.
@@ -286,6 +304,17 @@ extern int edac_device_add_device(struct edac_device_ctl_info *edac_dev);
 extern struct edac_device_ctl_info *edac_device_del_device(struct device *dev);
 
 /**
+ * devm_edac_device_add_device:
+ *	Helper to call edac_device_add_device and register it for cleanup with
+ *	devres.
+ *
+ * Returns:
+ *	0 on Success, or an error code on failure
+ */
+extern int devm_edac_device_add_device(struct device *dev,
+				       struct edac_device_ctl_info *edac_dev);
+
+/**
  * edac_device_handle_ue():
  *	perform a common output and handling of an 'edac_dev' UE event
  *
Signature · 1 line
2.11.0
author maintainer
#10 lore raw

PATCH v2 9/9 EDAC: Add driver for the Marvell Armada XP SDRAM and L2 cache ECC

In reply to Jan Luebbe

Add support for the ECC functionality as found in the DDR RAM and L2 cache controllers on the MV78230/MV78x60 SoCs. This driver has been tested on the MV78460 (on a custom board with a DDR3 ECC DIMM).

---
 MAINTAINERS                   |   6 +
 drivers/edac/Kconfig          |   7 +
 drivers/edac/Makefile         |   1 +
 drivers/edac/armada_xp_edac.c | 639 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 653 insertions(+)
 create mode 100644 drivers/edac/armada_xp_edac.c
MAINTAINERS +6 -0
index f66488dfdbc9..f40d6b5cfd18 100644
@@ -4814,6 +4814,12 @@ L:	linux-edac at vger.kernel.org
 S:	Maintained
 F:	drivers/edac/amd64_edac*
 
+EDAC-ARMADA
+M:	Jan Luebbe <[email protected]>
+L:	linux-edac at vger.kernel.org
+S:	Maintained
+F:	drivers/edac/armada_xp_*
+
 EDAC-CALXEDA
 M:	Robert Richter <[email protected]>
 L:	linux-edac at vger.kernel.org
drivers/edac/Kconfig +7 -0
index 96afb2aeed18..4e123ec94a4a 100644
@@ -443,6 +443,13 @@ config EDAC_ALTERA_SDMMC
 	  Support for error detection and correction on the
 	  Altera SDMMC FIFO Memory for Altera SoCs.
 
+config EDAC_ARMADA_XP
+	bool "Marvell Armada XP DDR and L2 Cache ECC"
+	depends on ARCH_MVEBU
+	help
+	  Support for error correction and detection on the Marvell Aramada XP
+	  DDR RAM and L2 cache controllers.
+
 config EDAC_SYNOPSYS
 	tristate "Synopsys DDR Memory Controller"
 	depends on ARCH_ZYNQ
drivers/edac/Makefile +1 -0
index 0fd9ffa63299..70a093cc976e 100644
@@ -76,5 +76,6 @@ obj-$(CONFIG_EDAC_OCTEON_PCI)		+= octeon_edac-pci.o
 obj-$(CONFIG_EDAC_THUNDERX)		+= thunderx_edac.o
 
 obj-$(CONFIG_EDAC_ALTERA)		+= altera_edac.o
+obj-$(CONFIG_EDAC_ARMADA_XP)		+= armada_xp_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)		+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)		+= xgene_edac.o
drivers/edac/armada_xp_edac.c new file +639 -0

639 lines not on this page · raw message

Signature · 1 line
2.11.0
#11 lore raw

PATCH v2 9/9 EDAC: Add driver for the Marvell Armada XP SDRAM and L2 cache ECC

One comment

Quoted 9 lines · Jan Luebbe
drivers/edac/armada_xp_edac.c new file +9 -0
+struct armada_xp_mc_edac_drvdata {
+	void __iomem *base;
+
+	unsigned int width; /* width in bytes */
+	bool cs_addr_sel[SDRAM_NUM_CS]; /* bank interleaving */
+
+	char msg[128];
+};
+

...

Quoted 11 lines
drivers/edac/armada_xp_edac.c new file +11 -0
+static int armada_xp_mc_edac_read_config(struct mem_ctl_info *mci)
+{
+	struct armada_xp_mc_edac_drvdata *drvdata = mci->pvt_info;
+	struct dimm_info *dimm;
+	unsigned int i, cs_struct, cs_size;
+	uint32_t config, addr_ctrl, rank_ctrl;
+
+	config = readl(drvdata->base + SDRAM_CONFIG_REG);
+	if (!(config & SDRAM_CONFIG_ECC_MASK))
+		dev_warn(mci->pdev, "SDRAM ECC is not enabled");
+

drivers/edac/armada_xp_edac.c line 254

Quoted 10 lines
drivers/edac/armada_xp_edac.c new file +10 -0
+	if (mci->tot_dimms != SDRAM_NUM_CS) {
+		dev_err(mci->pdev, "Invaild number of DIMMs");
+		return -EINVAL;
+	}
+
+	if (config & SDRAM_CONFIG_BUS_WIDTH_MASK)
+		drvdata->width = 4; /* 64 bit */
+	else
+		drvdata->width = 2; /* 32 bit */
+

Should this be 8 and 4 instead of 4 and 2? The uses of this value are all consistent so there is no error but the numbers don't match the comment in struct armada_xp_mc_edac_drvdata.

maintainer
#12 lore raw

v2 cover EDAC drivers for Armada XP L2 and DDR

In reply to Jan Luebbe
Quoted 8 lines · Jan Luebbe

Chris Packham (2):
ARM: l2x0: support parity-enable/disable on aurora
ARM: l2x0: add marvell,ecc-enable property for aurora

Jan Luebbe (7):
ARM: l2c: move cache-aurora-l2.h to asm/hardware
ARM: aurora-l2: add prefix to MAX_RANGE_SIZE
ARM: aurora-l2: add defines for parity and ECC registers

I'd need an ACK from an ARM maintainer for those if the whole series is going to go through the EDAC tree.

Quoted 6 lines

EDAC: Add missing debugfs_create_x32 wrapper
EDAC: Add devres helpers for
edac_mc_alloc/edac_mc_add_mc(_with_groups)
EDAC: Add devres helpers for
edac_device_alloc_ctl_info/edac_device_add_device
EDAC: Add driver for the Marvell Armada XP SDRAM and L2 cache ECC

Alternatively, I can review those and they can go through an ARM tree.

I'm fine with whatever ARM maintainers prefer.

Signature · 5 lines
Regards/Gruss,
    Boris.

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

v2 cover EDAC drivers for Armada XP L2 and DDR

Hi Gregory and Borislav,

Quoted 5 lines · Borislav Petkov
Quoted 4 lines · Jan Luebbe

Chris Packham (2):
? ARM: l2x0: support parity-enable/disable on aurora ? ARM: l2x0: add marvell,ecc-enable property for aurora

Quoted 7 lines
Quoted 4 lines

Jan Luebbe (7):
? ARM: l2c: move cache-aurora-l2.h to asm/hardware ? ARM: aurora-l2: add prefix to MAX_RANGE_SIZE
? ARM: aurora-l2: add defines for parity and ECC registers

I'd need an ACK from an ARM maintainer for those if the whole series is going to go through the EDAC tree.

Gregory, you've given Reviewed-by tags for some of these in version 1.?

Would you be fine with acking them and merging the series through the EDAC tree?

Quoted 11 lines
Quoted 6 lines

? EDAC: Add missing debugfs_create_x32 wrapper
? EDAC: Add devres helpers for ????edac_mc_alloc/edac_mc_add_mc(_with_groups)
? EDAC: Add devres helpers for ????edac_device_alloc_ctl_info/edac_device_add_device
? EDAC: Add driver for the Marvell Armada XP SDRAM and L2 cache ECC

Alternatively, I can review those and they can go through an ARM tree.

I'm fine with whatever ARM maintainers prefer.

Thanks, if you have any review comments, please let me know.

Regards,
Jan

#14 lore raw

v2 cover EDAC drivers for Armada XP L2 and DDR

Quoted 13 lines · Jan L?bbe

Hi Gregory and Borislav,

Quoted 10 lines · Borislav Petkov
Quoted 8 lines · Jan Luebbe

Chris Packham (2):
? ARM: l2x0: support parity-enable/disable on aurora ? ARM: l2x0: add marvell,ecc-enable property for aurora

Jan Luebbe (7):
? ARM: l2c: move cache-aurora-l2.h to asm/hardware ? ARM: aurora-l2: add prefix to MAX_RANGE_SIZE
? ARM: aurora-l2: add defines for parity and ECC registers

Quoted 7 lines
Quoted 2 lines

I'd need an ACK from an ARM maintainer for those if the whole series is going to go through the EDAC tree.

Gregory, you've given Reviewed-by tags for some of these in version 1.?

Would you be fine with acking them and merging the series through the EDAC tree?

Boris and myself agreed that I'd merge the entire series once the EDAC bits have been reviewed.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
#15 lore raw

v2 cover EDAC drivers for Armada XP L2 and DDR

In reply to Jan Luebbe
Quoted 15 lines · Jan Luebbe

This series adds drivers for the L2 cache and DDR RAM ECC functionality as found on the MV78230/MV78x60 SoCs. I've tested these changes with the MV78460 (on a custom board with a DDR3 ECC DIMM).

Also contained in this series are an additional debugfs wrapper and devm_ helpers for edac_mc_/edac_device_ allocation and registration, which make error handing and cleanup simpler.

Compared to the previous v1 series, the following changes have been made:
- Add the aurora-l2 register defines earlier in the series (suggested by Russell King and Gregory CLEMENT )
- Changed the DT vendor prefix from "arm" to "marvell" for the ecc-enable/disable properties on the aurora-l2 (suggested by Russell King)
- Fix some warnings reported by checkpatch

Quoted 10 lines

Compared to the original RFC series, the following changes have been made:
- Integrated Chris' patches for parity and ECC configuration via DT
- Merged the DDR RAM and L2 cache drivers (as requested by Borislav, analogous to fsl_ddr_edac.c and mpc85xx_edac.c)
- Added myself to MAINTAINERS (requested by Borislav)
- L2 cache: Track the msg size and use snprintf (review comment by Chris)
- L2 cache: Split error injection from the check function (review comment by Chris)
- DDR RAM: Allow 16 bit width in addition to 32 and 64 bit (review comment by Chris)

Thanks for that. I'll make my life easier when I add support for the narrower bus-width.

Quoted 7 lines

- Use of_match_ptr() (review comments by Chris)
- Minor checkpatch cleanups

Chris Packham (2):
ARM: l2x0: support parity-enable/disable on aurora
ARM: l2x0: add marvell,ecc-enable property for aurora

Quoted 10 lines

Jan Luebbe (7):
ARM: l2c: move cache-aurora-l2.h to asm/hardware
ARM: aurora-l2: add prefix to MAX_RANGE_SIZE
ARM: aurora-l2: add defines for parity and ECC registers
EDAC: Add missing debugfs_create_x32 wrapper
EDAC: Add devres helpers for
edac_mc_alloc/edac_mc_add_mc(_with_groups)
EDAC: Add devres helpers for
edac_device_alloc_ctl_info/edac_device_add_device
EDAC: Add driver for the Marvell Armada XP SDRAM and L2 cache ECC