Skip to contentSkip to conversation

Add EDAC support for Cadence ddr controller

PATCH In review Dhananjay Kangude 3 participants 7 messages Feb 25, 2020 – Feb 26, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Add EDAC support for Cadence ddr controller

These patches add new edac driver for Cadence ddr memory controller. Cadence controller detects single(CE) and double(UE) bit errors during memory operations(RMW). DDR controller raised the interrupt on detection of the ecc error event and fill the data into registers. Driver handle the interrupt event and notify edac subsystem about ecc errors.

The patch series has two patches:
1. Add driver support into edac subsystem
2. Add devicetree binding in yaml format

Dhananjay Kangude (2):
EDAC/Cadence:Add EDAC driver for cadence memory controller
dt-bindings: edac: Add cadence ddr mc support

 .../devicetree/bindings/edac/cdns,ddr-edac.yaml    |   56 ++
 drivers/edac/Kconfig                               |    7 +
 drivers/edac/Makefile                              |    1 +
 drivers/edac/cadence_edac.c                        |  615 ++++++++++++++++++++
 4 files changed, 679 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/edac/cdns,ddr-edac.yaml
 create mode 100644 drivers/edac/cadence_edac.c
#1 lore raw

PATCH 1/2 EDAC/Cadence:Add EDAC driver for cadence memory controller

Added edac platform driver for Cadence DDR controller which notify the ecc events based on the single or double bit errors during memory operations.

---
 drivers/edac/Kconfig        |    7 +
 drivers/edac/Makefile       |    1 +
 drivers/edac/cadence_edac.c |  615 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 623 insertions(+), 0 deletions(-)
 create mode 100644 drivers/edac/cadence_edac.c
drivers/edac/Kconfig +7 -0
index fe2eb89..4bea379 100644
@@ -530,4 +530,11 @@ config EDAC_DMC520
 	  Support for error detection and correction on the
 	  SoCs with ARM DMC-520 DRAM controller.
 
+config EDAC_CADENCE
+	tristate "Candence DDR Memory Controller ECC"
+	help
+	  Support for error detection and correction on the Cadence DDR
+	  memory controller. The driver provide the statistics  for single bit(CE)
+	  and double bit(UE) error correction.
+
 endif # EDAC
drivers/edac/Makefile +1 -0
index 269e151..a56cf2e 100644
@@ -88,3 +88,4 @@ obj-$(CONFIG_EDAC_QCOM)			+= qcom_edac.o
 obj-$(CONFIG_EDAC_ASPEED)		+= aspeed_edac.o
 obj-$(CONFIG_EDAC_BLUEFIELD)		+= bluefield_edac.o
 obj-$(CONFIG_EDAC_DMC520)		+= dmc520_edac.o
+obj-$(CONFIG_EDAC_CADENCE)		+= cadence_edac.o
drivers/edac/cadence_edac.c new file +615 -0

615 lines not on this page · raw message

Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH 1/2] EDAC/Cadence:Add EDAC driver for cadence memory controller

Thank you for the patch! Yet something to improve:

Hi Dhananjay,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on ras/edac-for-next]
[also build test ERROR on next-20200225]
[cannot apply to v5.6-rc3]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dhananjay-Kangude/Add-EDAC-support-for-Cadence-ddr-controller/20200225-185633
base:   https://git.kernel.org/pub/scm/linux/kernel/git/ras/ras.git edac-for-next
config: i386-allyesconfig (attached as .config)
compiler: gcc-7 (Debian 7.5.0-5) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag

All error/warnings (new ones prefixed by >>):

drivers//edac/cadence_edac.c: In function 'init_mem_layout':

>> drivers//edac/cadence_edac.c:179:9: error: implicit declaration of function 'EDAC_DIMM_PTR' [-Werror=implicit-function-declaration]
     dimm = EDAC_DIMM_PTR(mci->layers, mci->dimms, mci->n_layers, 0, 0, 0);
            ^~~~~~~~~~~~~
>> drivers//edac/cadence_edac.c:179:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     dimm = EDAC_DIMM_PTR(mci->layers, mci->dimms, mci->n_layers, 0, 0, 0);
          ^
   drivers//edac/cadence_edac.c: In function 'cdns_edac_mc_probe':
   drivers//edac/cadence_edac.c:476:17: warning: unused variable 'root' [-Wunused-variable]
     struct dentry *root;
                    ^~~~

cc1: some warnings being treated as errors

vim +/EDAC_DIMM_PTR +179 drivers//edac/cadence_edac.c

159
160 /**
161 * init_mem_layout - Set address Map as per the mc design.
162 * @mci: memory controller information.
163 *
164 * Set Address Map as per mc instance .
165 *
166 * Return: none.
167 */
168 static void init_mem_layout(struct mem_ctl_info *mci)
169 {
170 struct cdns_edac_priv_data *priv = mci->pvt_info;
171 struct csrow_info *csi;
172 struct dimm_info *dimm;
173 struct sysinfo inf;
174 enum mem_type mtype;
175 u32 val, width;
176 u32 size, row;
177 u8 j;
178

 > 179		dimm = EDAC_DIMM_PTR(mci->layers, mci->dimms, mci->n_layers, 0, 0, 0);

180
181 si_meminfo(&inf);
182 for (row = 0; row < mci->nr_csrows; row++) {
183 csi = mci->csrows[row];
184 size = inf.totalram * inf.mem_unit;
185
186 for (j = 0; j < csi->nr_channels; j++) {
187 dimm = csi->channels[j]->dimm;
188 dimm->edac_mode = EDAC_FLAG_SECDED;
189 /* Get memory type by reading hw registers*/
190 val = readl(priv->reg + DDR_CTL_MEM_TYPE_REG);
191 mtype = val & ECC_CTL_MTYPE_MASK;
192
193 if (mtype == MEM_TYPE_DDR4)
194 dimm->mtype = MEM_DDR4;
195 else
196 dimm->mtype = MEM_EMPTY;
197
198 /*Get EDAC devtype width for the current mc*/
199 width = (readl(priv->reg + DDR_CTL_MEM_WIDTH_REG) &
200 CTL_MEM_MAX_WIDTH_MASK);
201 switch (width) {
202 case WDTH_16:
203 dimm->dtype = DEV_X2;
204 break;
205 case WDTH_32:
206 dimm->dtype = DEV_X4;
207 break;
208 case WDTH_64:
209 dimm->dtype = DEV_X8;
210 break;
211 default:
212 dimm->dtype = DEV_UNKNOWN;
213 }
214
215 dimm->nr_pages = (size >> PAGE_SHIFT) /
216 csi->nr_channels;
217 dimm->grain = CDNS_EDAC_ERR_GRAIN;
218 }
219 }
220 }
221

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#3 lore raw

[RFC PATCH] EDAC/Cadence: data_synd[] can be static

In reply to Dhananjay Kangude
Fixes: 201447a5db9b ("EDAC/Cadence:Add EDAC driver for cadence memory controller")
Fixes 201447a5db9b ("EDAC/Cadence:Add EDAC driver for cadence memory controller")
---
 cadence_edac.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/edac/cadence_edac.c +2 -2
index 3887db5665eee..17aa656a740ee 100644
@@ -121,7 +121,7 @@
 /* Syndrome values */
 #define ECC_DOUBLE_MULTI_ERR_SYND	0x03
 
-char data_synd[] = {
+static char data_synd[] = {
 			0xf4, 0xf1, 0xec, 0xea, 0xe9, 0xe6, 0xe5, 0xe3,
 			0xdc, 0xda, 0xd9, 0xd6, 0xd5, 0xd3, 0xce, 0xcb,
 			0xb5, 0xb0, 0xad, 0xab, 0xa8, 0xa7, 0xa4, 0xa2,
@@ -132,7 +132,7 @@ char data_synd[] = {
 			0x1c, 0x1a, 0x19, 0x16, 0x15, 0x13, 0x0e, 0x0b
 		  };
 
-char check_synd[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
+static char check_synd[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
 
 /**
  * struct cdns_platform_data -  cadence platform data structure.
#4 lore raw

Re: [PATCH 1/2] EDAC/Cadence:Add EDAC driver for cadence memory controller

In reply to Dhananjay Kangude
Thank you for the patch! Yet something to improve:

Hi Dhananjay,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on ras/edac-for-next]
[also build test ERROR on next-20200225]
[cannot apply to v5.6-rc3]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dhananjay-Kangude/Add-EDAC-support-for-Cadence-ddr-controller/20200225-185633
base:   https://git.kernel.org/pub/scm/linux/kernel/git/ras/ras.git edac-for-next
config: arm64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (git://gitmirror/llvm_project 7f9f027c62623bff79730cd30d1a8a534e2ddb06)

reproduce:
# FIXME the reproduce steps for clang is not ready yet

If you fix the issue, kindly add following tag

All error/warnings (new ones prefixed by >>):

>> drivers/edac/cadence_edac.c:179:9: error: implicit declaration of function 'EDAC_DIMM_PTR' [-Werror,-Wimplicit-function-declaration]
           dimm = EDAC_DIMM_PTR(mci->layers, mci->dimms, mci->n_layers, 0, 0, 0);
                  ^
>> drivers/edac/cadence_edac.c:179:7: warning: incompatible integer to pointer conversion assigning to 'struct dimm_info *' from 'int' [-Wint-conversion]
           dimm = EDAC_DIMM_PTR(mci->layers, mci->dimms, mci->n_layers, 0, 0, 0);
                ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/edac/cadence_edac.c:476:17: warning: unused variable 'root' [-Wunused-variable]
           struct dentry *root;
                          ^

2 warnings and 1 error generated.

vim +/EDAC_DIMM_PTR +179 drivers/edac/cadence_edac.c

159
160 /**
161 * init_mem_layout - Set address Map as per the mc design.
162 * @mci: memory controller information.
163 *
164 * Set Address Map as per mc instance .
165 *
166 * Return: none.
167 */
168 static void init_mem_layout(struct mem_ctl_info *mci)
169 {
170 struct cdns_edac_priv_data *priv = mci->pvt_info;
171 struct csrow_info *csi;
172 struct dimm_info *dimm;
173 struct sysinfo inf;
174 enum mem_type mtype;
175 u32 val, width;
176 u32 size, row;
177 u8 j;
178

 > 179		dimm = EDAC_DIMM_PTR(mci->layers, mci->dimms, mci->n_layers, 0, 0, 0);

180
181 si_meminfo(&inf);
182 for (row = 0; row < mci->nr_csrows; row++) {
183 csi = mci->csrows[row];
184 size = inf.totalram * inf.mem_unit;
185
186 for (j = 0; j < csi->nr_channels; j++) {
187 dimm = csi->channels[j]->dimm;
188 dimm->edac_mode = EDAC_FLAG_SECDED;
189 /* Get memory type by reading hw registers*/
190 val = readl(priv->reg + DDR_CTL_MEM_TYPE_REG);
191 mtype = val & ECC_CTL_MTYPE_MASK;
192
193 if (mtype == MEM_TYPE_DDR4)
194 dimm->mtype = MEM_DDR4;
195 else
196 dimm->mtype = MEM_EMPTY;
197
198 /*Get EDAC devtype width for the current mc*/
199 width = (readl(priv->reg + DDR_CTL_MEM_WIDTH_REG) &
200 CTL_MEM_MAX_WIDTH_MASK);
201 switch (width) {
202 case WDTH_16:
203 dimm->dtype = DEV_X2;
204 break;
205 case WDTH_32:
206 dimm->dtype = DEV_X4;
207 break;
208 case WDTH_64:
209 dimm->dtype = DEV_X8;
210 break;
211 default:
212 dimm->dtype = DEV_UNKNOWN;
213 }
214
215 dimm->nr_pages = (size >> PAGE_SHIFT) /
216 csi->nr_channels;
217 dimm->grain = CDNS_EDAC_ERR_GRAIN;
218 }
219 }
220 }
221

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#5 lore raw

PATCH 2/2 dt-bindings: edac: Add cadence ddr mc support

In reply to Dhananjay Kangude

Add documentation for cadence ddr memory controller EDAC DTS bindings

---
 .../devicetree/bindings/edac/cdns,ddr-edac.yaml    |   56 ++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/edac/cdns,ddr-edac.yaml
Documentation/devicetree/bindings/edac/cdns,ddr-edac.yaml new file +56 -0
new file mode 100644
index 0000000..df70647
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/edac/cdns,ddr-edac.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cadence DDR IP with ECC support (EDAC)
+
+description:
+  This binding describes the Cadence DDR/LPDDR IP with ECC feature enabled
+  to detect and correct CE/UE errors.
+
+maintainers:
+  - Dhananjay Kangdue <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - cdns,cadence-ddr4-mc-edac
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 1
+
+  reg:
+    minItems: 1
+    maxItems: 2
+    items:
+      - description:
+          Register block of DDR/LPDDR apb registers up to mapped area.
+          Mapped area contains the register set for memory controller,
+          phy and PI module register set doesn't part of this mapping.
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    edac: edac@fd100000 {
+        compatible = "cdns,cadence-ddr4-mc-edac";
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges;
+        reg = <0xfd100000 0x4000>;
+        interrupts = <0x00 0x01 0x04>;
+        };
+...
Signature · 1 line
1.7.1
maintainer
#6 lore raw

Re: [PATCH 2/2] dt-bindings: edac: Add cadence ddr mc support

Quoted 8 lines · Dhananjay Kangude

Add documentation for cadence ddr memory controller EDAC DTS bindings

---
 .../devicetree/bindings/edac/cdns,ddr-edac.yaml    |   56 ++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/edac/cdns,ddr-edac.yaml

My bot found errors running 'make dt_binding_check' on your patch:

Documentation/devicetree/bindings/display/simple-framebuffer.example.dts:21.16-37.11: Warning (chosen_node_is_root): /example-0/chosen: chosen node must be at root node /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/edac/cdns,ddr-edac.example.dt.yaml: edac@fd100000: 'ranges' does not match any of the regexes: 'pinctrl-[0-9]+'

See https://patchwork.ozlabs.org/patch/1243950
Please check and re-submit.