Skip to contentSkip to conversation

EDAC: Enhancements to Synopsys EDAC driver

PATCH Superseded Manish Narani 3 participants 7 messages Jul 19, 2018 – Jul 31, 2018

Subsystems (4)

v1 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

cover EDAC: Enhancements to Synopsys EDAC driver

This patch series enhances the current EDAC driver to support different platforms.This series adds support for ZynqMP DDRC controller in synopsys EDAC driver. This series also adds Device tree properties and relevant binding documentation.

Manish Narani (4):
edac: synps: Add platform specific structures for ddrc controller
dt: bindings: Document ZynqMP DDRC in Synopsys documentation
edac: synopsys: Add EDAC ECC support for ZynqMP DDRC
arm64: zynqmp: Add DDRC node

 .../bindings/memory-controllers/synopsys.txt       |  25 +-
 arch/arm64/boot/dts/xilinx/zynqmp.dtsi             |   7 +
 drivers/edac/Kconfig                               |   2 +-
 drivers/edac/synopsys_edac.c                       | 916 ++++++++++++++++++++-
 4 files changed, 918 insertions(+), 32 deletions(-)
Signature · 1 line
2.1.1
#1 lore raw

PATCH 1/4 edac: synps: Add platform specific structures for ddrc controller

This patch adds platform specific structures, so that we can add different IP support later using quirks.

---
 drivers/edac/synopsys_edac.c | 70 ++++++++++++++++++++++++++++++++++++--------
 1 file changed, 58 insertions(+), 12 deletions(-)
drivers/edac/synopsys_edac.c +58 -12
index 0c9c59e..447396e 100644
@@ -22,6 +22,7 @@
 #include <linux/edac.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/of.h>
 
 #include "edac_module.h"
 
@@ -95,6 +96,9 @@
 #define SCRUB_MODE_MASK		0x7
 #define SCRUB_MODE_SECDED	0x4
 
+/* DDR ECC Quirks */
+#define DDR_ECC_INTR_SUPPORT	BIT(0)
+
 /**
  * struct ecc_error_info - ECC error log information
  * @row:	Row number
@@ -130,6 +134,7 @@ struct synps_ecc_status {
  * @baseaddr:	Base address of the DDR controller
  * @message:	Buffer for framing the event specific info
  * @stat:	ECC status information
+ * @p_data:	Pointer to platform data
  * @ce_cnt:	Correctable Error count
  * @ue_cnt:	Uncorrectable Error count
  */
@@ -137,11 +142,29 @@ struct synps_edac_priv {
 	void __iomem *baseaddr;
 	char message[SYNPS_EDAC_MSG_SIZE];
 	struct synps_ecc_status stat;
+	const struct synps_platform_data *p_data;
 	u32 ce_cnt;
 	u32 ue_cnt;
 };
 
 /**
+ * struct synps_platform_data -  synps platform data structure
+ * @synps_edac_geterror_info:	function pointer to synps edac error info
+ * @synps_edac_get_mtype:	function pointer to synps edac mtype
+ * @synps_edac_get_dtype:	function pointer to synps edac dtype
+ * @synps_edac_get_eccstate:	function pointer to synps edac eccstate
+ * @quirks:			to differentiate IPs
+ */
+struct synps_platform_data {
+	int (*synps_edac_geterror_info)(void __iomem *base,
+					struct synps_ecc_status *p);
+	enum mem_type (*synps_edac_get_mtype)(const void __iomem *base);
+	enum dev_type (*synps_edac_get_dtype)(const void __iomem *base);
+	bool (*synps_edac_get_eccstate)(void __iomem *base);
+	int quirks;
+};
+
+/**
  * synps_edac_geterror_info - Get the current ecc error info
  * @base:	Pointer to the base address of the ddr memory controller
  * @p:		Pointer to the synopsys ecc status structure
@@ -242,7 +265,8 @@ static void synps_edac_check(struct mem_ctl_info *mci)
 	struct synps_edac_priv *priv = mci->pvt_info;
 	int status;
 
-	status = synps_edac_geterror_info(priv->baseaddr, &priv->stat);
+	status = priv->p_data->synps_edac_geterror_info(priv->baseaddr,
+							&priv->stat);
 	if (status)
 		return;
 
@@ -372,10 +396,12 @@ static int synps_edac_init_csrows(struct mem_ctl_info *mci)
 		for (j = 0; j < csi->nr_channels; j++) {
 			dimm            = csi->channels[j]->dimm;
 			dimm->edac_mode = EDAC_FLAG_SECDED;
-			dimm->mtype     = synps_edac_get_mtype(priv->baseaddr);
+			dimm->mtype     = priv->p_data->synps_edac_get_mtype(
+						priv->baseaddr);
 			dimm->nr_pages  = (size >> PAGE_SHIFT) / csi->nr_channels;
 			dimm->grain     = SYNPS_EDAC_ERR_GRAIN;
-			dimm->dtype     = synps_edac_get_dtype(priv->baseaddr);
+			dimm->dtype     = priv->p_data->synps_edac_get_dtype(
+						priv->baseaddr);
 		}
 	}
 
@@ -423,6 +449,21 @@ static int synps_edac_mc_init(struct mem_ctl_info *mci,
 	return status;
 }
 
+static const struct synps_platform_data zynq_edac_def = {
+	.synps_edac_geterror_info	= synps_edac_geterror_info,
+	.synps_edac_get_mtype		= synps_edac_get_mtype,
+	.synps_edac_get_dtype		= synps_edac_get_dtype,
+	.synps_edac_get_eccstate	= synps_edac_get_eccstate,
+	.quirks				= 0,
+};
+
+static const struct of_device_id synps_edac_match[] = {
+	{ .compatible = "xlnx,zynq-ddrc-a05", .data = (void *)&zynq_edac_def },
+	{ /* end of table */ }
+};
+
+MODULE_DEVICE_TABLE(of, synps_edac_match);
+
 /**
  * synps_edac_mc_probe - Check controller and bind driver
  * @pdev:	Pointer to the platform_device struct
@@ -440,13 +481,22 @@ static int synps_edac_mc_probe(struct platform_device *pdev)
 	int rc;
 	struct resource *res;
 	void __iomem *baseaddr;
+	const struct of_device_id *match;
+	const struct synps_platform_data *p_data;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	baseaddr = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(baseaddr))
 		return PTR_ERR(baseaddr);
 
-	if (!synps_edac_get_eccstate(baseaddr)) {
+	match = of_match_node(synps_edac_match, pdev->dev.of_node);
+	if (!match && !match->data) {
+		dev_err(&pdev->dev, "of_match_node() failed\n");
+		return -EINVAL;
+	}
+
+	p_data = (struct synps_platform_data *)match->data;
+	if (!(p_data->synps_edac_get_eccstate(baseaddr))) {
 		edac_printk(KERN_INFO, EDAC_MC, "ECC not enabled\n");
 		return -ENXIO;
 	}
@@ -468,6 +518,8 @@ static int synps_edac_mc_probe(struct platform_device *pdev)
 
 	priv = mci->pvt_info;
 	priv->baseaddr = baseaddr;
+	priv->p_data = match->data;
+
 	rc = synps_edac_mc_init(mci, pdev);
 	if (rc) {
 		edac_printk(KERN_ERR, EDAC_MC,
@@ -486,7 +538,8 @@ static int synps_edac_mc_probe(struct platform_device *pdev)
 	 * Start capturing the correctable and uncorrectable errors. A write of
 	 * 0 starts the counters.
 	 */
-	writel(0x0, baseaddr + ECC_CTRL_OFST);
+	if (!(priv->p_data->quirks & DDR_ECC_INTR_SUPPORT))
+		writel(0x0, baseaddr + ECC_CTRL_OFST);
 	return rc;
 
 free_edac_mc:
@@ -511,13 +564,6 @@ static int synps_edac_mc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct of_device_id synps_edac_match[] = {
-	{ .compatible = "xlnx,zynq-ddrc-a05", },
-	{ /* end of table */ }
-};
-
-MODULE_DEVICE_TABLE(of, synps_edac_match);
-
 static struct platform_driver synps_edac_mc_driver = {
 	.driver = {
 		   .name = "synopsys-edac",
Signature · 1 line
2.1.1
#2 lore raw

PATCH 2/4 dt: bindings: Document ZynqMP DDRC in Synopsys documentation

In reply to Manish Narani

This patch documents Synopsys EDAC driver which reports the single bit errors that are corrected and the double bit errors that are detected.

---
 .../bindings/memory-controllers/synopsys.txt       | 25 ++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/memory-controllers/synopsys.txt +21 -4
index a43d26d..5d20b76 100644
@@ -1,15 +1,32 @@
 Binding for Synopsys IntelliDDR Multi Protocol Memory Controller
 
-This controller has an optional ECC support in half-bus width (16-bit)
-configuration. The ECC controller corrects one bit error and detects
+Synopsys EDAC driver, it does reports the DDR ECC single bit errors
+that are corrected and double bit ecc errors that are detected by the DDR
+ECC controller.
+
+The Zynq DDR ECC controller has an optional ECC support in half-bus width
+(16-bit) configuration. The ECC controller corrects one bit error and detects
 two bit errors.
 
 Required properties:
- - compatible: Should be 'xlnx,zynq-ddrc-a05'
- - reg: Base address and size of the controllers memory area
+ - compatible: One of:
+	- 'xlnx,zynq-ddrc-a05' : Zynq DDR ECC controller
+	- 'xlnx,zynqmp-ddrc-2.40a' : ZynqMP DDR ECC controller
+ - reg: Should contain DDR controller registers location and length.
+
+Required properties for "xlnx,zynqmp-ddrc-2.40a":
+ - interrupt-parent: Should be core interrupt controller.
+ - interrupts: Property with a value describing the interrupt number.
 
 Example:
 	memory-controller@f8006000 {
 		compatible = "xlnx,zynq-ddrc-a05";
 		reg = <0xf8006000 0x1000>;
 	};
+
+	mc: memory-controller@fd070000 {
+		compatible = "xlnx,zynqmp-ddrc-2.40a";
+		reg = <0x0 0xfd070000 0x0 0x30000>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 112 4>;
+	};
Signature · 1 line
2.1.1
maintainer
#3 lore raw

Re: [PATCH 2/4] dt: bindings: Document ZynqMP DDRC in Synopsys documentation

Quoted 1 line · Manish Narani

This patch documents Synopsys EDAC driver which reports the single bit

Bindings are for h/w, not drivers. I'm pretty sure Synopsys doesn't make an "EDAC driver".

Quoted 12 lines

errors that are corrected and the double bit errors that are detected.

---
 .../bindings/memory-controllers/synopsys.txt       | 25 ++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/memory-controllers/synopsys.txt +0 -0
index a43d26d..5d20b76 100644

Documentation/devicetree/bindings/memory-controllers/synopsys.txt line 5

Quoted 7 lines
Documentation/devicetree/bindings/memory-controllers/synopsys.txt +3 -2
@@ -1,15 +1,32 @@
 Binding for Synopsys IntelliDDR Multi Protocol Memory Controller
 
-This controller has an optional ECC support in half-bus width (16-bit)
-configuration. The ECC controller corrects one bit error and detects
+Synopsys EDAC driver, it does reports the DDR ECC single bit errors
+that are corrected and double bit ecc errors that are detected by the DDR
+ECC controller.

Describe the h/w, not drivers.

s/it does reports/it reports/
s/ecc/ECC/

Quoted 5 lines
Documentation/devicetree/bindings/memory-controllers/synopsys.txt +3 -0
+
+The Zynq DDR ECC controller has an optional ECC support in half-bus width
+(16-bit) configuration. The ECC controller corrects one bit error and detects
 two bit errors.
 

Documentation/devicetree/bindings/memory-controllers/synopsys.txt line 18

Quoted 10 lines
Documentation/devicetree/bindings/memory-controllers/synopsys.txt +7 -2
 Required properties:
- - compatible: Should be 'xlnx,zynq-ddrc-a05'
- - reg: Base address and size of the controllers memory area
+ - compatible: One of:
+	- 'xlnx,zynq-ddrc-a05' : Zynq DDR ECC controller
+	- 'xlnx,zynqmp-ddrc-2.40a' : ZynqMP DDR ECC controller
+ - reg: Should contain DDR controller registers location and length.
+
+Required properties for "xlnx,zynqmp-ddrc-2.40a":
+ - interrupt-parent: Should be core interrupt controller.

Drop this. It is implied.

Documentation/devicetree/bindings/memory-controllers/synopsys.txt line 19

Quoted 1 line
Documentation/devicetree/bindings/memory-controllers/synopsys.txt +1 -0
+ - interrupts: Property with a value describing the interrupt number.

No interrupt for Zynq? That makes ECC reporting hard...

Quoted 16 lines
Documentation/devicetree/bindings/memory-controllers/synopsys.txt +7 -0
 Example:
 	memory-controller@f8006000 {
 		compatible = "xlnx,zynq-ddrc-a05";
 		reg = <0xf8006000 0x1000>;
 	};
+
+	mc: memory-controller@fd070000 {
+		compatible = "xlnx,zynqmp-ddrc-2.40a";
+		reg = <0x0 0xfd070000 0x0 0x30000>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 112 4>;
+	};
Signature · 1 line
2.1.1
#4 lore raw

RE: [PATCH 2/4] dt: bindings: Document ZynqMP DDRC in Synopsys documentation

Hi Rob,

Quoted 14 lines

-----Original Message-----
From: Rob Herring [mailto:[email protected]]
Sent: Thursday, July 26, 2018 12:55 AM
To: Manish Narani <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Will Wong <[email protected]>; Naga Sureshkumar Relli <[email protected]>; Edgar Iglesias <[email protected]>; Bharat Kumar Gogada <[email protected]>; Shubhrajyoti Datta <[email protected]>; [email protected]; Anirudha Sarangi <[email protected]>; Srinivas Goud <[email protected]>
Subject: Re: [PATCH 2/4] dt: bindings: Document ZynqMP DDRC in Synopsys documentation

Quoted 5 lines
Quoted 1 line · Manish Narani

This patch documents Synopsys EDAC driver which reports the single bit

Bindings are for h/w, not drivers. I'm pretty sure Synopsys doesn't make an "EDAC driver".

I will correct it in next version.

Quoted 20 lines
Quoted 6 lines

errors that are corrected and the double bit errors that are detected.

---
 .../bindings/memory-controllers/synopsys.txt       | 25 ++++++++++++++++++-

---

Quoted 13 lines
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/memory-controllers/synopsys.txt b/Documentation/devicetree/bindings/memory-controllers/synopsys.txt index a43d26d..5d20b76 100644
---
a/Documentation/devicetree/bindings/memory-controllers/synopsys.txt +++ b/Documentation/devicetree/bindings/memory-controllers/synopsys.tx +++ t

Documentation/devicetree/bindings/memory-controllers/synopsys.txt +0 -0
@@ -1,15 +1,32 @@
 Binding for Synopsys IntelliDDR Multi Protocol Memory Controller
 
Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +0 -1
-This controller has an optional ECC support in half-bus width

(16-bit) -configuration. The ECC controller corrects one bit error and detects

(quoted diff) +3 -0
+Synopsys EDAC driver, it does reports the DDR ECC single bit errors
+that are corrected and double bit ecc errors that are detected by the
+DDR ECC controller.

Describe the h/w, not drivers.

Okay

Quoted 3 lines

s/it does reports/it reports/
s/ecc/ECC/

Okay

Quoted 8 lines
Quoted 8 lines
(quoted diff) +5 -0
+
+The Zynq DDR ECC controller has an optional ECC support in half-bus
+width
+(16-bit) configuration. The ECC controller corrects one bit error and
+detects
 two bit errors.
Quoted 12 lines

Documentation/devicetree/bindings/memory-controllers/synopsys.txt line 18

Quoted 10 lines

Required properties:
- - compatible: Should be 'xlnx,zynq-ddrc-a05'
- - reg: Base address and size of the controllers memory area
+ - compatible: One of:

Documentation/devicetree/bindings/memory-controllers/synopsys.txt +6 -0
+	- 'xlnx,zynq-ddrc-a05' : Zynq DDR ECC controller
+	- 'xlnx,zynqmp-ddrc-2.40a' : ZynqMP DDR ECC controller
+ - reg: Should contain DDR controller registers location and length.
+
+Required properties for "xlnx,zynqmp-ddrc-2.40a":
+ - interrupt-parent: Should be core interrupt controller.

Drop this. It is implied.

Sure. I will remove it.

Quoted 4 lines
Quoted 2 lines

+ - interrupts: Property with a value describing the interrupt number.

No interrupt for Zynq? That makes ECC reporting hard...

There is no interrupt support in Zynq DDR controller. The ECC reporting is done via polling method.

Quoted 17 lines
Quoted 15 lines

Example:

Documentation/devicetree/bindings/memory-controllers/synopsys.txt +7 -1
 	memory-controller@f8006000 {
 		compatible = "xlnx,zynq-ddrc-a05";
 		reg = <0xf8006000 0x1000>;
 	};
+
+	mc: memory-controller@fd070000 {
+		compatible = "xlnx,zynqmp-ddrc-2.40a";
+		reg = <0x0 0xfd070000 0x0 0x30000>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 112 4>;
+	};
--
Quoted 2 lines

2.1.1

Thanks,
Manish Narani

#5 lore raw

PATCH 3/4 edac: synopsys: Add EDAC ECC support for ZynqMP DDRC

In reply to Manish Narani

This patch adds EDAC ECC support for ZynqMP DDRC IP. The patch also adds support for ECC Error Injection in ZynqMP. The corrected and uncorrected error interrupts support is added in this patch. The Row, Column, Bank, Bank Group and Rank bits positions are determined via Address Map registers of Synopsys DDRC.

---
 drivers/edac/Kconfig         |   2 +-
 drivers/edac/synopsys_edac.c | 848 ++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 833 insertions(+), 17 deletions(-)
drivers/edac/Kconfig +1 -1
index 57304b2..b1fc7a16 100644
@@ -441,7 +441,7 @@ config EDAC_ALTERA_SDMMC
 
 config EDAC_SYNOPSYS
 	tristate "Synopsys DDR Memory Controller"
-	depends on ARCH_ZYNQ
+	depends on ARCH_ZYNQ || ARM64
 	help
 	  Support for error detection and correction on the Synopsys DDR
 	  memory controller.
drivers/edac/synopsys_edac.c +832 -16

977 lines not on this page · raw message

Signature · 1 line
2.1.1
#6 lore raw

PATCH 4/4 arm64: zynqmp: Add DDRC node

In reply to Manish Narani

This patch adds ddrc memory controller node in dts. The size mentioned in dts is 0x30000, because we need to access DDR_QOS INTR registers located at fd090208 from this driver.

---
 arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/xilinx/zynqmp.dtsi +7 -0
index a091e6f..7d6a3cf 100644
@@ -355,6 +355,13 @@
 			xlnx,bus-width = <64>;
 		};
 
+		mc: memory-controller@fd070000 {
+			compatible = "xlnx,zynqmp-ddrc-2.40a";
+			reg = <0x0 0xfd070000 0x0 0x30000>;
+			interrupt-parent = <&gic>;
+			interrupts = <0 112 4>;
+		};
+
 		gem0: ethernet@ff0b0000 {
 			compatible = "cdns,zynqmp-gem", "cdns,gem";
 			status = "disabled";
Signature · 1 line
2.1.1