Skip to contentSkip to conversation

EDAC: Enhancements to Synopsys EDAC driver

PATCH In review Manish Narani 5 participants 25 messages Oct 25, 2018 – Nov 6, 2018

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

v10 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.

Changes in v2:
- Moved checking of DDR_ECC_INTR_SUPPORT from (1/4) to (3/4) as it is a feature of ZynqMP DDRC
- The Binding Documentation in (2/4) is modified as per the review comments

Changes in v3:
- The commit message in (2/4) is modified (Synopsys EDAC Driver --> ZynqMP DDRC)

Changes in v4:
- Updated the commit message in (1/4)
- Renamed function pointer names removing 'synps_' in (1/4)
- Shortened unnecessary long lines as per the review comment on (1/4)

Changes in v5:
- Updated the commit message in (2/4) and (4/4).
- Removed the unnecessary check for match data in probe() in (1/4)
- Some Indentation changes for better readability in (1/4) and (3/4)
- Removed repeated code in (3/4)
- Used 'zynq' and 'zynqmp' instead of 'synps_enh_edac' in function names

Changes in v6:
- Splitted the patches according to functionalities
- Addressed code style comments from v5 review
- Moved the Error Injection to CONFIG_EDAC_DEBUG mode

Changes in v7:
- Included DTS patch (6/7) which was missed in v6 patch set

Changes in v8:
- patch (1/7) from v7 is split in to 3 different logically different patches
1. functional changes like code cleanup
2. functions renaming
3. comments cleanup
- Added a separate patch (4) for making always successful functions as void
- Corrected 'Too many parentheses' review comment in patch (5)
- Corrected comments as per the v7 review feedback
- Made dedicated functions for IRQ setup, IRQ enable and IRQ disable in patch (8)
- Addressed review comments in patch (10)

Changes in v9:
- Added check for return value of of_device_get_match_data() function in (1/6).
- From v8 the first 5 patches are removed in this series as they are applied on:
https://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git/?h=edac-for-4.20-synps
- Updated Kconfig to check for ARCH_ZYNQMP instead of ARM64

Change in v10:
- Moved the checking for ce_cnt and ue_cnt before the readl() call
- Aligned arguments on the opening brace in setup_irq()

Manish Narani (6):
edac: synopsys: Add error handling for NULL in probe()
dt: bindings: Document ZynqMP DDRC in Synopsys documentation
edac: synopsys: Add macro defines for ZynqMP DDRC
edac: synopsys: Add EDAC ECC support for ZynqMP DDRC
arm64: zynqmp: Add DDRC node
edac: synopsys: Add Error Injection support for ZynqMP DDRC

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

PATCH v10 1/6 edac: synopsys: Add error handling for NULL in probe()

The function of_device_get_match_data() can return NULL in case of error. Add error handling for the same in probe().

---
 drivers/edac/synopsys_edac.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/edac/synopsys_edac.c +3 -0
index 1c3795d..0005ef3 100644
@@ -477,6 +477,9 @@ static int mc_probe(struct platform_device *pdev)
 		return PTR_ERR(baseaddr);
 
 	p_data = of_device_get_match_data(&pdev->dev);
+	if (!p_data)
+		return -ENODEV;
+
 	if (!p_data->get_ecc_state(baseaddr)) {
 		edac_printk(KERN_INFO, EDAC_MC, "ECC not enabled\n");
 		return -ENXIO;
Signature · 1 line
2.1.1
#2 lore raw

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

In reply to Manish Narani

Add information of ZynqMP DDRC which reports the single bit errors that are corrected and the double bit errors that are detected.

---
 .../bindings/memory-controllers/synopsys.txt       | 27 ++++++++++++++++++----
 1 file changed, 22 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/memory-controllers/synopsys.txt +22 -5
index a43d26d..9d32762 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
-two bit errors.
+The ZynqMP DDR ECC controller has an optional ECC support in 64-bit and 32-bit
+bus width configurations.
+
+The Zynq DDR ECC controller has an optional ECC support in half-bus width
+(16-bit) configuration.
+
+These both ECC controllers correct single bit ECC errors and detect double bit
+ECC 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":
+ - interrupts: Property with a value describing the interrupt number.
 
 Example:
 	memory-controller at f8006000 {
 		compatible = "xlnx,zynq-ddrc-a05";
 		reg = <0xf8006000 0x1000>;
 	};
+
+	mc: memory-controller at 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
#3 lore raw

PATCH v10 3/6 edac: synopsys: Add macro defines for ZynqMP DDRC

In reply to Manish Narani

Add macro defines for ZynqMP DDR controller. These macros will be used for ZynqMP ECC operations.

---
 drivers/edac/synopsys_edac.c | 168 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 168 insertions(+)
drivers/edac/synopsys_edac.c +168 -0
index 0005ef3..d1999e0 100644
@@ -97,6 +97,174 @@
 #define SCRUB_MODE_MASK			0x7
 #define SCRUB_MODE_SECDED		0x4
 
+/* DDR ECC Quirks */
+#define DDR_ECC_INTR_SUPPORT		BIT(0)
+#define DDR_ECC_DATA_POISON_SUPPORT	BIT(1)
+
+/* ZynqMP Enhanced DDR memory controller registers that are relevant to ECC */
+/* ECC Configuration Registers */
+#define ECC_CFG0_OFST			0x70
+#define ECC_CFG1_OFST			0x74
+
+/* ECC Status Register */
+#define ECC_STAT_OFST			0x78
+
+/* ECC Clear Register */
+#define ECC_CLR_OFST			0x7C
+
+/* ECC Error count Register */
+#define ECC_ERRCNT_OFST			0x80
+
+/* ECC Corrected Error Address Register */
+#define ECC_CEADDR0_OFST		0x84
+#define ECC_CEADDR1_OFST		0x88
+
+/* ECC Syndrome Registers */
+#define ECC_CSYND0_OFST			0x8C
+#define ECC_CSYND1_OFST			0x90
+#define ECC_CSYND2_OFST			0x94
+
+/* ECC Bit Mask0 Address Register */
+#define ECC_BITMASK0_OFST		0x98
+#define ECC_BITMASK1_OFST		0x9C
+#define ECC_BITMASK2_OFST		0xA0
+
+/* ECC UnCorrected Error Address Register */
+#define ECC_UEADDR0_OFST		0xA4
+#define ECC_UEADDR1_OFST		0xA8
+
+/* ECC Syndrome Registers */
+#define ECC_UESYND0_OFST		0xAC
+#define ECC_UESYND1_OFST		0xB0
+#define ECC_UESYND2_OFST		0xB4
+
+/* ECC Poison Address Reg */
+#define ECC_POISON0_OFST		0xB8
+#define ECC_POISON1_OFST		0xBC
+
+#define ECC_ADDRMAP0_OFFSET		0x200
+
+/* Control register bitfield definitions */
+#define ECC_CTRL_BUSWIDTH_MASK		0x3000
+#define ECC_CTRL_BUSWIDTH_SHIFT		12
+#define ECC_CTRL_CLR_CE_ERRCNT		BIT(2)
+#define ECC_CTRL_CLR_UE_ERRCNT		BIT(3)
+
+/* DDR Control Register width definitions  */
+#define DDRCTL_EWDTH_16			2
+#define DDRCTL_EWDTH_32			1
+#define DDRCTL_EWDTH_64			0
+
+/* ECC status register definitions */
+#define ECC_STAT_UECNT_MASK		0xF0000
+#define ECC_STAT_UECNT_SHIFT		16
+#define ECC_STAT_CECNT_MASK		0xF00
+#define ECC_STAT_CECNT_SHIFT		8
+#define ECC_STAT_BITNUM_MASK		0x7F
+
+/* DDR QOS Interrupt register definitions */
+#define DDR_QOS_IRQ_STAT_OFST		0x20200
+#define DDR_QOSUE_MASK			0x4
+#define	DDR_QOSCE_MASK			0x2
+#define	ECC_CE_UE_INTR_MASK		0x6
+#define DDR_QOS_IRQ_EN_OFST		0x20208
+#define DDR_QOS_IRQ_DB_OFST		0x2020C
+
+/* ECC Corrected Error Register Mask and Shifts*/
+#define ECC_CEADDR0_RW_MASK		0x3FFFF
+#define ECC_CEADDR0_RNK_MASK		BIT(24)
+#define ECC_CEADDR1_BNKGRP_MASK		0x3000000
+#define ECC_CEADDR1_BNKNR_MASK		0x70000
+#define ECC_CEADDR1_BLKNR_MASK		0xFFF
+#define ECC_CEADDR1_BNKGRP_SHIFT	24
+#define ECC_CEADDR1_BNKNR_SHIFT		16
+
+/* ECC Poison register shifts */
+#define ECC_POISON0_RANK_SHIFT		24
+#define ECC_POISON0_RANK_MASK		BIT(24)
+#define ECC_POISON0_COLUMN_SHIFT	0
+#define ECC_POISON0_COLUMN_MASK		0xFFF
+#define ECC_POISON1_BG_SHIFT		28
+#define ECC_POISON1_BG_MASK		0x30000000
+#define ECC_POISON1_BANKNR_SHIFT	24
+#define ECC_POISON1_BANKNR_MASK		0x7000000
+#define ECC_POISON1_ROW_SHIFT		0
+#define ECC_POISON1_ROW_MASK		0x3FFFF
+
+/* DDR Memory type defines */
+#define MEM_TYPE_DDR3			0x1
+#define MEM_TYPE_LPDDR3			0x8
+#define MEM_TYPE_DDR2			0x4
+#define MEM_TYPE_DDR4			0x10
+#define MEM_TYPE_LPDDR4			0x20
+
+/* DDRC Software control register */
+#define DDRC_SWCTL			0x320
+
+/* DDRC ECC CE & UE poison mask */
+#define ECC_CEPOISON_MASK		0x3
+#define ECC_UEPOISON_MASK		0x1
+
+/* DDRC Device config masks */
+#define DDRC_MSTR_CFG_MASK		0xC0000000
+#define DDRC_MSTR_CFG_SHIFT		30
+#define DDRC_MSTR_CFG_X4_MASK		0x0
+#define DDRC_MSTR_CFG_X8_MASK		0x1
+#define DDRC_MSTR_CFG_X16_MASK		0x2
+#define DDRC_MSTR_CFG_X32_MASK		0x3
+
+#define DDR_MAX_ROW_SHIFT		18
+#define DDR_MAX_COL_SHIFT		14
+#define DDR_MAX_BANK_SHIFT		3
+#define DDR_MAX_BANKGRP_SHIFT		2
+
+#define ROW_MAX_VAL_MASK		0xF
+#define COL_MAX_VAL_MASK		0xF
+#define BANK_MAX_VAL_MASK		0x1F
+#define BANKGRP_MAX_VAL_MASK		0x1F
+#define RANK_MAX_VAL_MASK		0x1F
+
+#define ROW_B0_BASE			6
+#define ROW_B1_BASE			7
+#define ROW_B2_BASE			8
+#define ROW_B3_BASE			9
+#define ROW_B4_BASE			10
+#define ROW_B5_BASE			11
+#define ROW_B6_BASE			12
+#define ROW_B7_BASE			13
+#define ROW_B8_BASE			14
+#define ROW_B9_BASE			15
+#define ROW_B10_BASE			16
+#define ROW_B11_BASE			17
+#define ROW_B12_BASE			18
+#define ROW_B13_BASE			19
+#define ROW_B14_BASE			20
+#define ROW_B15_BASE			21
+#define ROW_B16_BASE			22
+#define ROW_B17_BASE			23
+
+#define COL_B2_BASE			2
+#define COL_B3_BASE			3
+#define COL_B4_BASE			4
+#define COL_B5_BASE			5
+#define COL_B6_BASE			6
+#define COL_B7_BASE			7
+#define COL_B8_BASE			8
+#define COL_B9_BASE			9
+#define COL_B10_BASE			10
+#define COL_B11_BASE			11
+#define COL_B12_BASE			12
+#define COL_B13_BASE			13
+
+#define BANK_B0_BASE			2
+#define BANK_B1_BASE			3
+#define BANK_B2_BASE			4
+
+#define BANKGRP_B0_BASE			2
+#define BANKGRP_B1_BASE			3
+
+#define RANK_B0_BASE			6
+
 /**
  * struct ecc_error_info - ECC error log information.
  * @row:	Row number.
Signature · 1 line
2.1.1
#4 lore raw

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

In reply to Manish Narani

Add EDAC ECC support for ZynqMP DDRC IP. The IP supports interrupts for corrected and uncorrected errors. Add interrupt handlers for the same.

---
 drivers/edac/Kconfig         |   2 +-
 drivers/edac/synopsys_edac.c | 322 ++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 306 insertions(+), 18 deletions(-)
drivers/edac/Kconfig +1 -1
index 57304b2..7c40eb2 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 || ARCH_ZYNQMP
 	help
 	  Support for error detection and correction on the Synopsys DDR
 	  memory controller.
drivers/edac/synopsys_edac.c +305 -17

435 lines not on this page · raw message

Signature · 1 line
2.1.1
#5 lore raw

PATCH v10 5/6 arm64: zynqmp: Add DDRC node

In reply to Manish Narani

Add ddrc memory controller node in dts. The size mentioned in dts is 0x30000, because we need to access DDR_QOS INTR registers located at 0xFD090208 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 29ce234..a81d3b16 100644
@@ -355,6 +355,13 @@
 			xlnx,bus-width = <64>;
 		};
 
+		mc: memory-controller at fd070000 {
+			compatible = "xlnx,zynqmp-ddrc-2.40a";
+			reg = <0x0 0xfd070000 0x0 0x30000>;
+			interrupt-parent = <&gic>;
+			interrupts = <0 112 4>;
+		};
+
 		gem0: ethernet at ff0b0000 {
 			compatible = "cdns,zynqmp-gem", "cdns,gem";
 			status = "disabled";
Signature · 1 line
2.1.1
maintainer
#6 lore raw

Re: [PATCH v10 5/6] arm64: zynqmp: Add DDRC node

Quoted 18 lines · Manish Narani

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

---
 arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/xilinx/zynqmp.dtsi +0 -0
index 29ce234..a81d3b16 100644
@@ -355,6 +355,13 @@
 			xlnx,bus-width = <64>;
 		};
 

arch/arm64/boot/dts/xilinx/zynqmp.dtsi line 367

Quoted 10 lines
arch/arm64/boot/dts/xilinx/zynqmp.dtsi +7 -0
+		mc: memory-controller at fd070000 {
+			compatible = "xlnx,zynqmp-ddrc-2.40a";
+			reg = <0x0 0xfd070000 0x0 0x30000>;
+			interrupt-parent = <&gic>;
+			interrupts = <0 112 4>;
+		};
+
 		gem0: ethernet at ff0b0000 {
 			compatible = "cdns,zynqmp-gem", "cdns,gem";
 			status = "disabled";

Ok, talking to Mark on IRC, he says those DT changes normally go through the arm-soc tree.

And I'm fine with that except if we do that, then the EDAC changes go through my tree and those drivers could end up temporarily broken depending on the merge order and timing.

So should we perhaps make an arm-soc shared, immutable branch which you guys export for me with those DT changes applied, which I can merge into my tree and apply the EDAC changes ontop.

This is what we've been doing with the tip tree until now and it has proven successful.

Thoughts?

Signature · 4 lines
Regards/Gruss,
    Boris.

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

Re: [PATCH v10 5/6] arm64: zynqmp: Add DDRC node

Hi Boris,

Quoted 33 lines · Borislav Petkov
Quoted 18 lines · Manish Narani

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

---
 arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/xilinx/zynqmp.dtsi +0 -0
index 29ce234..a81d3b16 100644
@@ -355,6 +355,13 @@
 			xlnx,bus-width = <64>;
 		};
 

arch/arm64/boot/dts/xilinx/zynqmp.dtsi line 367

Quoted 10 lines
arch/arm64/boot/dts/xilinx/zynqmp.dtsi +7 -0
+		mc: memory-controller at fd070000 {
+			compatible = "xlnx,zynqmp-ddrc-2.40a";
+			reg = <0x0 0xfd070000 0x0 0x30000>;
+			interrupt-parent = <&gic>;
+			interrupts = <0 112 4>;
+		};
+
 		gem0: ethernet at ff0b0000 {
 			compatible = "cdns,zynqmp-gem", "cdns,gem";
 			status = "disabled";

Ok, talking to Mark on IRC, he says those DT changes normally go through the arm-soc tree.

Quoted 3 lines

And I'm fine with that except if we do that, then the EDAC changes go through my tree and those drivers could end up temporarily broken depending on the merge order and timing.

I don't think that driver will be broken. You can build them, use them on out of tree HW. And when this patch is merged to mainline it will be enabled for xilinx soc.

Quoted 9 lines

So should we perhaps make an arm-soc shared, immutable branch which you guys export for me with those DT changes applied, which I can merge into my tree and apply the EDAC changes ontop.

This is what we've been doing with the tip tree until now and it has proven successful.

Thoughts?

Normally driver is merged via appropriate subsystem with DT binding doc and enabled for the soc/platform later.
Also in connection to process which you have described above. DT node should match binding which is in your tree and should go first and then enabling for certain SoC on the top.

TBH I can't see any reason to do merges but if you want to do that way we can also do it.

Thanks,
Michal

maintainer
#8 lore raw

Re: [PATCH v10 5/6] arm64: zynqmp: Add DDRC node

Quoted 3 lines · Michal Simek

I don't think that driver will be broken. You can build them, use them on out of tree HW. And when this patch is merged to mainline it will be enabled for xilinx soc.

But if the DT entries are missing, the driver won't load, would it?

Quoted 2 lines

TBH I can't see any reason to do merges but if you want to do that way we can also do it.

The reason is because there's a separate DT tree and all those arm drivers need DT.

I have already acked EDAC patches to go through other trees too, FWIW. Which is not optimal either if someone sends fixes ontop but I cannot apply them yet because the dependent patches are in a different tree.

So yes, there are at least two good reasons for merging a shared branch.

Signature · 4 lines
Regards/Gruss,
    Boris.

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

Re: [PATCH v10 5/6] arm64: zynqmp: Add DDRC node

Quoted 6 lines · Borislav Petkov
Quoted 3 lines · Michal Simek

I don't think that driver will be broken. You can build them, use them on out of tree HW. And when this patch is merged to mainline it will be enabled for xilinx soc.

But if the DT entries are missing, the driver won't load, would it?

you don't have that HW anyway.

Quoted 8 lines
Quoted 3 lines

TBH I can't see any reason to do merges but if you want to do that way we can also do it.

The reason is because there's a separate DT tree and all those arm drivers need DT.

I have already acked EDAC patches to go through other trees too, FWIW.

I looked at v10 and I can't see your ack there. Can you please give me a link?
I see Rob's reviewed by in v10 2/6

Quoted 4 lines

Which is not optimal either if someone sends fixes ontop but I cannot apply them yet because the dependent patches are in a different tree.

So yes, there are at least two good reasons for merging a shared branch.

I have not a problem with that. I can simply take patch (process via arm-soc) with pointing to reviewed binding doc and you will take the rest when this is in arm-soc tree.

Thanks,
Michal

maintainer
#10 lore raw

Re: [PATCH v10 5/6] arm64: zynqmp: Add DDRC node

Quoted 1 line · Michal Simek

you don't have that HW anyway.

Grrr, I'm not talking about me - I'm talking about people testing linux-next. And perhaps in this particular case it won't matter because this hw is not shipping yet or whatever but the question is about the principle of the whole thing.

Quoted 2 lines

I looked at v10 and I can't see your ack there. Can you please give me a link?

I'm talking about *other* patches for another driver.

Please note that I'm replying to this thread as an example - the procedural question I have is not only related to the synopsys changes but the synopsys changes are a good example for the problem of EDAC changes being sent to me along with DT additions.

As such, the question was aimed more at arm-soc people - that's why they were in To: - not at you.

Signature · 4 lines
Regards/Gruss,
    Boris.

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

Re: [PATCH v10 5/6] arm64: zynqmp: Add DDRC node

Quoted 13 lines · Borislav Petkov
Quoted 1 line · Michal Simek

you don't have that HW anyway.

Grrr, I'm not talking about me - I'm talking about people testing linux-next. And perhaps in this particular case it won't matter because this hw is not shipping yet or whatever but the question is about the principle of the whole thing.

Quoted 2 lines

I looked at v10 and I can't see your ack there. Can you please give me a link?

I'm talking about *other* patches for another driver.

Quoted 7 lines

Please note that I'm replying to this thread as an example - the procedural question I have is not only related to the synopsys changes but the synopsys changes are a good example for the problem of EDAC changes being sent to me along with DT additions.

As such, the question was aimed more at arm-soc people - that's why they were in To: - not at you.

ok. Got it.

M

#12 lore raw

Re: [PATCH v10 5/6] arm64: zynqmp: Add DDRC node

In reply to Borislav Petkov
Quoted 14 lines · Borislav Petkov
Quoted 1 line · Michal Simek

you don't have that HW anyway.

Grrr, I'm not talking about me - I'm talking about people testing linux-next. And perhaps in this particular case it won't matter because this hw is not shipping yet or whatever but the question is about the principle of the whole thing.

Quoted 2 lines

I looked at v10 and I can't see your ack there. Can you please give me a link?

I'm talking about *other* patches for another driver.

Quoted 7 lines

Please note that I'm replying to this thread as an example - the procedural question I have is not only related to the synopsys changes but the synopsys changes are a good example for the problem of EDAC changes being sent to me along with DT additions.

As such, the question was aimed more at arm-soc people - that's why they were in To: - not at you.

Hi Boris,

In general, for new functionality where needing both the driver change and a DT change to enable it (or a driver change and a config change to enable it), we have been merging the changes separately between driver trees and arm-soc. I.e. things will be in place, but not enabled, until both sides land. Main reason for doing so is to cut down on arbitrary dependencies between the trees, since there can sometimes end up being a lot of them.

Since DT should strive for being backwards compatible (i.e, a driver change shouldn't require a DT change for the kernel to not regress functionally), this has been working pretty well.

However, if there's some other reason to share a base between the two trees, we can do that. For most cases we've found that it's not needed though. So let us know what you prefer here.

-Olof

maintainer
#13 lore raw

Re: [PATCH v10 5/6] arm64: zynqmp: Add DDRC node

Hi Olof,

Quoted 7 lines · Olof Johansson

In general, for new functionality where needing both the driver change and a DT change to enable it (or a driver change and a config change to enable it), we have been merging the changes separately between driver trees and arm-soc. I.e. things will be in place, but not enabled, until both sides land. Main reason for doing so is to cut down on arbitrary dependencies between the trees, since there can sometimes end up being a lot of them.

Well, makes sense too and it is the least problematic approach. :-)

Quoted 3 lines

Since DT should strive for being backwards compatible (i.e, a driver change shouldn't require a DT change for the kernel to not regress functionally), this has been working pretty well.

Ok.

Quoted 3 lines

However, if there's some other reason to share a base between the two trees, we can do that. For most cases we've found that it's not needed though. So let us know what you prefer here.

No, I just wanted to make sure drivers can still function when they go to linux-next. But I certainly can get on board with keeping drivers and DT changes separate as it requires no sync and the short period of time when they don't load in linux-next, is perfectly ok.

So can I assume you guys are going to pick up:

https://lkml.kernel.org/r/1538667328-9465-7-git-send-email-manish.narani at xilinx.com
https://lkml.kernel.org/r/1540447621-22870-6-git-send-email-manish.narani at xilinx.com

?

I can then pick up the rest.

And I'll be ignoring DT stuff sent to me from now on and concentrate on the EDAC drivers, assuming former will go through your tree.

Sounds good?

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

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

Re: [PATCH v10 5/6] arm64: zynqmp: Add DDRC node

Quoted 20 lines · Borislav Petkov

Hi Olof,

Quoted 7 lines · Olof Johansson

In general, for new functionality where needing both the driver change and a DT change to enable it (or a driver change and a config change to enable it), we have been merging the changes separately between driver trees and arm-soc. I.e. things will be in place, but not enabled, until both sides land. Main reason for doing so is to cut down on arbitrary dependencies between the trees, since there can sometimes end up being a lot of them.

Well, makes sense too and it is the least problematic approach. :-)

Quoted 3 lines

Since DT should strive for being backwards compatible (i.e, a driver change shouldn't require a DT change for the kernel to not regress functionally), this has been working pretty well.

Ok.

Quoted 8 lines
Quoted 3 lines

However, if there's some other reason to share a base between the two trees, we can do that. For most cases we've found that it's not needed though. So let us know what you prefer here.

No, I just wanted to make sure drivers can still function when they go to linux-next. But I certainly can get on board with keeping drivers and DT changes separate as it requires no sync and the short period of time when they don't load in linux-next, is perfectly ok.

Ok, sounds good.

Quoted 4 lines

So can I assume you guys are going to pick up:

https://lkml.kernel.org/r/1538667328-9465-7-git-send-email-manish.narani at xilinx.com
https://lkml.kernel.org/r/1540447621-22870-6-git-send-email-manish.narani at xilinx.com

Yeah, Michal should pick those up for his platform and send them in to us (or let us know if he wants us to take them directly, but usually they come in through platform maintainers sending us pull requests).

Quoted 9 lines

?

I can then pick up the rest.

And I'll be ignoring DT stuff sent to me from now on and concentrate on the EDAC drivers, assuming former will go through your tree.

Sounds good?

Yeah, that's the way we've been trying to do for various subsystems and it's been working pretty well. Of course, if there's need to coordinate more closely for something in the future we'll be happy to do so.

-Olof

maintainer
#15 lore raw

Re: [PATCH v10 5/6] arm64: zynqmp: Add DDRC node

Quoted 4 lines · Olof Johansson

Yeah, that's the way we've been trying to do for various subsystems and it's been working pretty well. Of course, if there's need to coordinate more closely for something in the future we'll be happy to do so.

Goodie. Let's do that for now and we can always revisit when there's real need.

Thx!

Signature · 4 lines
Regards/Gruss,
    Boris.

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

Re: [PATCH v10 5/6] arm64: zynqmp: Add DDRC node

Quoted 8 lines · Borislav Petkov
Quoted 4 lines · Olof Johansson

Yeah, that's the way we've been trying to do for various subsystems and it's been working pretty well. Of course, if there's need to coordinate more closely for something in the future we'll be happy to do so.

Goodie. Let's do that for now and we can always revisit when there's real need.

I think Boris should take also this one (dt binding doc change) because it is aligned with changes in the driver.
https://lkml.kernel.org/r/1538667328-9465-7-git-send-email-manish.narani at xilinx.com

And I will take this one.
https://lkml.kernel.org/r/1540447621-22870-6-git-send-email-manish.narani at xilinx.com

But not a problem with taking both if you like but this make more sense to me.

Thanks,
Michal

#18 lore raw

Re: [PATCH v10 5/6] arm64: zynqmp: Add DDRC node

In reply to Manish Narani
Quoted 18 lines · Manish Narani

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

---
 arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/xilinx/zynqmp.dtsi +0 -0
index 29ce234..a81d3b16 100644
@@ -355,6 +355,13 @@
 			xlnx,bus-width = <64>;
 		};
 

arch/arm64/boot/dts/xilinx/zynqmp.dtsi line 367

Quoted 10 lines
arch/arm64/boot/dts/xilinx/zynqmp.dtsi +7 -0
+		mc: memory-controller at fd070000 {
+			compatible = "xlnx,zynqmp-ddrc-2.40a";
+			reg = <0x0 0xfd070000 0x0 0x30000>;
+			interrupt-parent = <&gic>;
+			interrupts = <0 112 4>;
+		};
+
 		gem0: ethernet at ff0b0000 {
 			compatible = "cdns,zynqmp-gem", "cdns,gem";
 			status = "disabled";

Applied with changed subject "arm64: dts: zynqmp: Add DDRC node" to zynqmp/dt branch.

Thanks,
Michal

#19 lore raw

PATCH v10 6/6 edac: synopsys: Add Error Injection support for ZynqMP DDRC

In reply to Manish Narani

Add support for Error Injection for ZynqMP DDRC IP. For injecting errors, the Row, Column, Bank, Bank Group and Rank bits positions are determined via Address Map registers of Synopsys DDRC.

---
 drivers/edac/synopsys_edac.c | 420 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 413 insertions(+), 7 deletions(-)
drivers/edac/synopsys_edac.c +413 -7
index e81f18a..2d26338 100644
@@ -302,12 +302,18 @@ struct synps_ecc_status {
 
 /**
  * struct synps_edac_priv - DDR memory controller private instance data.
- * @baseaddr:	Base address of the DDR controller.
- * @message:	Buffer for framing the event specific info.
- * @stat:	ECC status information.
- * @p_data:	Platform data.
- * @ce_cnt:	Correctable Error count.
- * @ue_cnt:	Uncorrectable Error count.
+ * @baseaddr:		Base address of the DDR controller.
+ * @message:		Buffer for framing the event specific info.
+ * @stat:		ECC status information.
+ * @p_data:		Platform data.
+ * @ce_cnt:		Correctable Error count.
+ * @ue_cnt:		Uncorrectable Error count.
+ * @poison_addr:	Data poison address.
+ * @row_shift:		Bit shifts for row bit.
+ * @col_shift:		Bit shifts for column bit.
+ * @bank_shift:		Bit shifts for bank bit.
+ * @bankgrp_shift:	Bit shifts for bank group bit.
+ * @rank_shift:		Bit shifts for rank bit.
  */
 struct synps_edac_priv {
 	void __iomem *baseaddr;
@@ -316,6 +322,14 @@ struct synps_edac_priv {
 	const struct synps_platform_data *p_data;
 	u32 ce_cnt;
 	u32 ue_cnt;
+#ifdef CONFIG_EDAC_DEBUG
+	ulong poison_addr;
+	u32 row_shift[18];
+	u32 col_shift[14];
+	u32 bank_shift[3];
+	u32 bankgrp_shift[2];
+	u32 rank_shift[1];
+#endif
 };
 
 /**
@@ -877,7 +891,11 @@ static const struct synps_platform_data zynqmp_edac_def = {
 	.get_mtype	= zynqmp_get_mtype,
 	.get_dtype	= zynqmp_get_dtype,
 	.get_ecc_state	= zynqmp_get_ecc_state,
-	.quirks		= DDR_ECC_INTR_SUPPORT,
+	.quirks         = (DDR_ECC_INTR_SUPPORT
+#ifdef CONFIG_EDAC_DEBUG
+			  | DDR_ECC_DATA_POISON_SUPPORT
+#endif
+			  ),
 };
 
 static const struct of_device_id synps_edac_match[] = {
@@ -896,6 +914,375 @@ static const struct of_device_id synps_edac_match[] = {
 
 MODULE_DEVICE_TABLE(of, synps_edac_match);
 
+#ifdef CONFIG_EDAC_DEBUG
+#define to_mci(k) container_of(k, struct mem_ctl_info, dev)
+
+/**
+ * ddr_poison_setup -	Update poison registers.
+ * @priv:		DDR memory controller private instance data.
+ *
+ * Update poison registers as per DDR mapping.
+ * Return: none.
+ */
+static void ddr_poison_setup(struct synps_edac_priv *priv)
+{
+	int col = 0, row = 0, bank = 0, bankgrp = 0, rank = 0, regval;
+	int index;
+	ulong hif_addr = 0;
+
+	hif_addr = priv->poison_addr >> 3;
+
+	for (index = 0; index < DDR_MAX_ROW_SHIFT; index++) {
+		if (priv->row_shift[index])
+			row |= (((hif_addr >> priv->row_shift[index]) &
+						BIT(0)) << index);
+		else
+			break;
+	}
+
+	for (index = 0; index < DDR_MAX_COL_SHIFT; index++) {
+		if (priv->col_shift[index] || index < 3)
+			col |= (((hif_addr >> priv->col_shift[index]) &
+						BIT(0)) << index);
+		else
+			break;
+	}
+
+	for (index = 0; index < DDR_MAX_BANK_SHIFT; index++) {
+		if (priv->bank_shift[index])
+			bank |= (((hif_addr >> priv->bank_shift[index]) &
+						BIT(0)) << index);
+		else
+			break;
+	}
+
+	for (index = 0; index < DDR_MAX_BANKGRP_SHIFT; index++) {
+		if (priv->bankgrp_shift[index])
+			bankgrp |= (((hif_addr >> priv->bankgrp_shift[index])
+						& BIT(0)) << index);
+		else
+			break;
+	}
+
+	if (priv->rank_shift[0])
+		rank = (hif_addr >> priv->rank_shift[0]) & BIT(0);
+
+	regval = (rank << ECC_POISON0_RANK_SHIFT) & ECC_POISON0_RANK_MASK;
+	regval |= (col << ECC_POISON0_COLUMN_SHIFT) & ECC_POISON0_COLUMN_MASK;
+	writel(regval, priv->baseaddr + ECC_POISON0_OFST);
+
+	regval = (bankgrp << ECC_POISON1_BG_SHIFT) & ECC_POISON1_BG_MASK;
+	regval |= (bank << ECC_POISON1_BANKNR_SHIFT) & ECC_POISON1_BANKNR_MASK;
+	regval |= (row << ECC_POISON1_ROW_SHIFT) & ECC_POISON1_ROW_MASK;
+	writel(regval, priv->baseaddr + ECC_POISON1_OFST);
+}
+
+static ssize_t inject_data_error_show(struct device *dev,
+				      struct device_attribute *mattr,
+				      char *data)
+{
+	struct mem_ctl_info *mci = to_mci(dev);
+	struct synps_edac_priv *priv = mci->pvt_info;
+
+	return sprintf(data, "Poison0 Addr: 0x%08x\n\rPoison1 Addr: 0x%08x\n\r"
+			"Error injection Address: 0x%lx\n\r",
+			readl(priv->baseaddr + ECC_POISON0_OFST),
+			readl(priv->baseaddr + ECC_POISON1_OFST),
+			priv->poison_addr);
+}
+
+static ssize_t inject_data_error_store(struct device *dev,
+				       struct device_attribute *mattr,
+				       const char *data, size_t count)
+{
+	struct mem_ctl_info *mci = to_mci(dev);
+	struct synps_edac_priv *priv = mci->pvt_info;
+
+	if (kstrtoul(data, 0, &priv->poison_addr))
+		return -EINVAL;
+
+	ddr_poison_setup(priv);
+
+	return count;
+}
+
+static ssize_t inject_data_poison_show(struct device *dev,
+				       struct device_attribute *mattr,
+				       char *data)
+{
+	struct mem_ctl_info *mci = to_mci(dev);
+	struct synps_edac_priv *priv = mci->pvt_info;
+
+	return sprintf(data, "Data Poisoning: %s\n\r",
+			(((readl(priv->baseaddr + ECC_CFG1_OFST)) & 0x3) == 0x3)
+			? ("Correctable Error") : ("UnCorrectable Error"));
+}
+
+static ssize_t inject_data_poison_store(struct device *dev,
+					struct device_attribute *mattr,
+					const char *data, size_t count)
+{
+	struct mem_ctl_info *mci = to_mci(dev);
+	struct synps_edac_priv *priv = mci->pvt_info;
+
+	writel(0, priv->baseaddr + DDRC_SWCTL);
+	if (strncmp(data, "CE", 2) == 0)
+		writel(ECC_CEPOISON_MASK, priv->baseaddr + ECC_CFG1_OFST);
+	else
+		writel(ECC_UEPOISON_MASK, priv->baseaddr + ECC_CFG1_OFST);
+	writel(1, priv->baseaddr + DDRC_SWCTL);
+
+	return count;
+}
+
+static DEVICE_ATTR_RW(inject_data_error);
+static DEVICE_ATTR_RW(inject_data_poison);
+
+static int edac_create_sysfs_attributes(struct mem_ctl_info *mci)
+{
+	int rc;
+
+	rc = device_create_file(&mci->dev, &dev_attr_inject_data_error);
+	if (rc < 0)
+		return rc;
+	rc = device_create_file(&mci->dev, &dev_attr_inject_data_poison);
+	if (rc < 0)
+		return rc;
+	return 0;
+}
+
+static void edac_remove_sysfs_attributes(struct mem_ctl_info *mci)
+{
+	device_remove_file(&mci->dev, &dev_attr_inject_data_error);
+	device_remove_file(&mci->dev, &dev_attr_inject_data_poison);
+}
+
+static void setup_row_address_map(struct synps_edac_priv *priv, u32 *addrmap)
+{
+	u32 addrmap_row_b2_10;
+	int index;
+
+	priv->row_shift[0] = (addrmap[5] & ROW_MAX_VAL_MASK) + ROW_B0_BASE;
+	priv->row_shift[1] = ((addrmap[5] >> 8) &
+			ROW_MAX_VAL_MASK) + ROW_B1_BASE;
+
+	addrmap_row_b2_10 = (addrmap[5] >> 16) & ROW_MAX_VAL_MASK;
+	if (addrmap_row_b2_10 != ROW_MAX_VAL_MASK) {
+		for (index = 2; index < 11; index++)
+			priv->row_shift[index] = addrmap_row_b2_10 +
+				index + ROW_B0_BASE;
+
+	} else {
+		priv->row_shift[2] = (addrmap[9] &
+				ROW_MAX_VAL_MASK) + ROW_B2_BASE;
+		priv->row_shift[3] = ((addrmap[9] >> 8) &
+				ROW_MAX_VAL_MASK) + ROW_B3_BASE;
+		priv->row_shift[4] = ((addrmap[9] >> 16) &
+				ROW_MAX_VAL_MASK) + ROW_B4_BASE;
+		priv->row_shift[5] = ((addrmap[9] >> 24) &
+				ROW_MAX_VAL_MASK) + ROW_B5_BASE;
+		priv->row_shift[6] = (addrmap[10] &
+				ROW_MAX_VAL_MASK) + ROW_B6_BASE;
+		priv->row_shift[7] = ((addrmap[10] >> 8) &
+				ROW_MAX_VAL_MASK) + ROW_B7_BASE;
+		priv->row_shift[8] = ((addrmap[10] >> 16) &
+				ROW_MAX_VAL_MASK) + ROW_B8_BASE;
+		priv->row_shift[9] = ((addrmap[10] >> 24) &
+				ROW_MAX_VAL_MASK) + ROW_B9_BASE;
+		priv->row_shift[10] = (addrmap[11] &
+				ROW_MAX_VAL_MASK) + ROW_B10_BASE;
+	}
+
+	priv->row_shift[11] = (((addrmap[5] >> 24) & ROW_MAX_VAL_MASK) ==
+				ROW_MAX_VAL_MASK) ? 0 : (((addrmap[5] >> 24) &
+				ROW_MAX_VAL_MASK) + ROW_B11_BASE);
+	priv->row_shift[12] = ((addrmap[6] & ROW_MAX_VAL_MASK) ==
+				ROW_MAX_VAL_MASK) ? 0 : ((addrmap[6] &
+				ROW_MAX_VAL_MASK) + ROW_B12_BASE);
+	priv->row_shift[13] = (((addrmap[6] >> 8) & ROW_MAX_VAL_MASK) ==
+				ROW_MAX_VAL_MASK) ? 0 : (((addrmap[6] >> 8) &
+				ROW_MAX_VAL_MASK) + ROW_B13_BASE);
+	priv->row_shift[14] = (((addrmap[6] >> 16) & ROW_MAX_VAL_MASK) ==
+				ROW_MAX_VAL_MASK) ? 0 : (((addrmap[6] >> 16) &
+				ROW_MAX_VAL_MASK) + ROW_B14_BASE);
+	priv->row_shift[15] = (((addrmap[6] >> 24) & ROW_MAX_VAL_MASK) ==
+				ROW_MAX_VAL_MASK) ? 0 : (((addrmap[6] >> 24) &
+				ROW_MAX_VAL_MASK) + ROW_B15_BASE);
+	priv->row_shift[16] = ((addrmap[7] & ROW_MAX_VAL_MASK) ==
+				ROW_MAX_VAL_MASK) ? 0 : ((addrmap[7] &
+				ROW_MAX_VAL_MASK) + ROW_B16_BASE);
+	priv->row_shift[17] = (((addrmap[7] >> 8) & ROW_MAX_VAL_MASK) ==
+				ROW_MAX_VAL_MASK) ? 0 : (((addrmap[7] >> 8) &
+				ROW_MAX_VAL_MASK) + ROW_B17_BASE);
+}
+
+static void setup_column_address_map(struct synps_edac_priv *priv, u32 *addrmap)
+{
+	u32 width, memtype;
+	int index;
+
+	memtype = readl(priv->baseaddr + CTRL_OFST);
+	width = (memtype & ECC_CTRL_BUSWIDTH_MASK) >> ECC_CTRL_BUSWIDTH_SHIFT;
+
+	priv->col_shift[0] = 0;
+	priv->col_shift[1] = 1;
+	priv->col_shift[2] = (addrmap[2] & COL_MAX_VAL_MASK) + COL_B2_BASE;
+	priv->col_shift[3] = ((addrmap[2] >> 8) &
+			COL_MAX_VAL_MASK) + COL_B3_BASE;
+	priv->col_shift[4] = (((addrmap[2] >> 16) & COL_MAX_VAL_MASK) ==
+			COL_MAX_VAL_MASK) ? 0 : (((addrmap[2] >> 16) &
+					COL_MAX_VAL_MASK) + COL_B4_BASE);
+	priv->col_shift[5] = (((addrmap[2] >> 24) & COL_MAX_VAL_MASK) ==
+			COL_MAX_VAL_MASK) ? 0 : (((addrmap[2] >> 24) &
+					COL_MAX_VAL_MASK) + COL_B5_BASE);
+	priv->col_shift[6] = ((addrmap[3] & COL_MAX_VAL_MASK) ==
+			COL_MAX_VAL_MASK) ? 0 : ((addrmap[3] &
+					COL_MAX_VAL_MASK) + COL_B6_BASE);
+	priv->col_shift[7] = (((addrmap[3] >> 8) & COL_MAX_VAL_MASK) ==
+			COL_MAX_VAL_MASK) ? 0 : (((addrmap[3] >> 8) &
+					COL_MAX_VAL_MASK) + COL_B7_BASE);
+	priv->col_shift[8] = (((addrmap[3] >> 16) & COL_MAX_VAL_MASK) ==
+			COL_MAX_VAL_MASK) ? 0 : (((addrmap[3] >> 16) &
+					COL_MAX_VAL_MASK) + COL_B8_BASE);
+	priv->col_shift[9] = (((addrmap[3] >> 24) & COL_MAX_VAL_MASK) ==
+			COL_MAX_VAL_MASK) ? 0 : (((addrmap[3] >> 24) &
+					COL_MAX_VAL_MASK) + COL_B9_BASE);
+	if (width == DDRCTL_EWDTH_64) {
+		if (memtype & MEM_TYPE_LPDDR3) {
+			priv->col_shift[10] = ((addrmap[4] &
+				COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 :
+				((addrmap[4] & COL_MAX_VAL_MASK) +
+				 COL_B10_BASE);
+			priv->col_shift[11] = (((addrmap[4] >> 8) &
+				COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 :
+				(((addrmap[4] >> 8) & COL_MAX_VAL_MASK) +
+				 COL_B11_BASE);
+		} else {
+			priv->col_shift[11] = ((addrmap[4] &
+				COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 :
+				((addrmap[4] & COL_MAX_VAL_MASK) +
+				 COL_B10_BASE);
+			priv->col_shift[13] = (((addrmap[4] >> 8) &
+				COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 :
+				(((addrmap[4] >> 8) & COL_MAX_VAL_MASK) +
+				 COL_B11_BASE);
+		}
+	} else if (width == DDRCTL_EWDTH_32) {
+		if (memtype & MEM_TYPE_LPDDR3) {
+			priv->col_shift[10] = (((addrmap[3] >> 24) &
+				COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 :
+				(((addrmap[3] >> 24) & COL_MAX_VAL_MASK) +
+				 COL_B9_BASE);
+			priv->col_shift[11] = ((addrmap[4] &
+				COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 :
+				((addrmap[4] & COL_MAX_VAL_MASK) +
+				 COL_B10_BASE);
+		} else {
+			priv->col_shift[11] = (((addrmap[3] >> 24) &
+				COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 :
+				(((addrmap[3] >> 24) & COL_MAX_VAL_MASK) +
+				 COL_B9_BASE);
+			priv->col_shift[13] = ((addrmap[4] &
+				COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 :
+				((addrmap[4] & COL_MAX_VAL_MASK) +
+				 COL_B10_BASE);
+		}
+	} else {
+		if (memtype & MEM_TYPE_LPDDR3) {
+			priv->col_shift[10] = (((addrmap[3] >> 16) &
+				COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 :
+				(((addrmap[3] >> 16) & COL_MAX_VAL_MASK) +
+				 COL_B8_BASE);
+			priv->col_shift[11] = (((addrmap[3] >> 24) &
+				COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 :
+				(((addrmap[3] >> 24) & COL_MAX_VAL_MASK) +
+				 COL_B9_BASE);
+			priv->col_shift[13] = ((addrmap[4] &
+				COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 :
+				((addrmap[4] & COL_MAX_VAL_MASK) +
+				 COL_B10_BASE);
+		} else {
+			priv->col_shift[11] = (((addrmap[3] >> 16) &
+				COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 :
+				(((addrmap[3] >> 16) & COL_MAX_VAL_MASK) +
+				 COL_B8_BASE);
+			priv->col_shift[13] = (((addrmap[3] >> 24) &
+				COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 :
+				(((addrmap[3] >> 24) & COL_MAX_VAL_MASK) +
+				 COL_B9_BASE);
+		}
+	}
+
+	if (width) {
+		for (index = 9; index > width; index--) {
+			priv->col_shift[index] = priv->col_shift[index - width];
+			priv->col_shift[index - width] = 0;
+		}
+	}
+
+}
+
+static void setup_bank_address_map(struct synps_edac_priv *priv, u32 *addrmap)
+{
+	priv->bank_shift[0] = (addrmap[1] & BANK_MAX_VAL_MASK) + BANK_B0_BASE;
+	priv->bank_shift[1] = ((addrmap[1] >> 8) &
+				BANK_MAX_VAL_MASK) + BANK_B1_BASE;
+	priv->bank_shift[2] = (((addrmap[1] >> 16) &
+				BANK_MAX_VAL_MASK) == BANK_MAX_VAL_MASK) ? 0 :
+				(((addrmap[1] >> 16) & BANK_MAX_VAL_MASK) +
+				 BANK_B2_BASE);
+
+}
+
+static void setup_bg_address_map(struct synps_edac_priv *priv, u32 *addrmap)
+{
+	priv->bankgrp_shift[0] = (addrmap[8] &
+				BANKGRP_MAX_VAL_MASK) + BANKGRP_B0_BASE;
+	priv->bankgrp_shift[1] = (((addrmap[8] >> 8) & BANKGRP_MAX_VAL_MASK) ==
+				BANKGRP_MAX_VAL_MASK) ? 0 : (((addrmap[8] >> 8)
+				& BANKGRP_MAX_VAL_MASK) + BANKGRP_B1_BASE);
+
+}
+
+static void setup_rank_address_map(struct synps_edac_priv *priv, u32 *addrmap)
+{
+	priv->rank_shift[0] = ((addrmap[0] & RANK_MAX_VAL_MASK) ==
+				RANK_MAX_VAL_MASK) ? 0 : ((addrmap[0] &
+				RANK_MAX_VAL_MASK) + RANK_B0_BASE);
+}
+
+/**
+ * setup_address_map -	Set Address Map by querying ADDRMAP registers.
+ * @priv:		DDR memory controller private instance data.
+ *
+ * Set Address Map by querying ADDRMAP registers.
+ *
+ * Return: none.
+ */
+static void setup_address_map(struct synps_edac_priv *priv)
+{
+	u32 addrmap[12];
+	int index;
+
+	for (index = 0; index < 12; index++) {
+		u32 addrmap_offset;
+
+		addrmap_offset = ECC_ADDRMAP0_OFFSET + (index * 4);
+		addrmap[index] = readl(priv->baseaddr + addrmap_offset);
+	}
+
+	setup_row_address_map(priv, addrmap);
+
+	setup_column_address_map(priv, addrmap);
+
+	setup_bank_address_map(priv, addrmap);
+
+	setup_bg_address_map(priv, addrmap);
+
+	setup_rank_address_map(priv, addrmap);
+}
+#endif /* CONFIG_EDAC_DEBUG */
+
 /**
  * mc_probe - Check controller and bind driver.
  * @pdev:	platform device.
@@ -963,6 +1350,20 @@ static int mc_probe(struct platform_device *pdev)
 		goto free_edac_mc;
 	}
 
+#ifdef CONFIG_EDAC_DEBUG
+	if (priv->p_data->quirks & DDR_ECC_DATA_POISON_SUPPORT) {
+		if (edac_create_sysfs_attributes(mci)) {
+			edac_printk(KERN_ERR, EDAC_MC,
+					"Failed to create sysfs entries\n");
+			goto free_edac_mc;
+		}
+	}
+
+	if (of_device_is_compatible(pdev->dev.of_node,
+				    "xlnx,zynqmp-ddrc-2.40a"))
+		setup_address_map(priv);
+#endif
+
 	/*
 	 * Start capturing the correctable and uncorrectable errors. A write of
 	 * 0 starts the counters.
@@ -992,6 +1393,11 @@ static int mc_remove(struct platform_device *pdev)
 	if (priv->p_data->quirks & DDR_ECC_INTR_SUPPORT)
 		disable_intr(priv);
 
+#ifdef CONFIG_EDAC_DEBUG
+	if (priv->p_data->quirks & DDR_ECC_DATA_POISON_SUPPORT)
+		edac_remove_sysfs_attributes(mci);
+#endif
+
 	edac_mc_del_mc(&pdev->dev);
 	edac_mc_free(mci);
 
Signature · 1 line
2.1.1
#20 lore raw
In reply to Manish Narani

Ping!

Quoted 91 lines

-----Original Message-----
From: Manish Narani [mailto:manish.narani at xilinx.com]
Sent: Thursday, October 25, 2018 11:37 AM
To: robh+dt at kernel.org; mark.rutland at arm.com; Michal Simek <[email protected]>; bp at alien8.de; mchehab at kernel.org; Manish Narani <[email protected]>; amit.kucheria at linaro.org; sudeep.holla at arm.com; leoyang.li at nxp.com
Cc: devicetree at vger.kernel.org; linux-kernel at vger.kernel.org; linux-arm- kernel at lists.infradead.org; linux-edac at vger.kernel.org
Subject: [PATCH v10 0/6] 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.

Changes in v2:
- Moved checking of DDR_ECC_INTR_SUPPORT from (1/4) to (3/4) as it
is
a feature of ZynqMP DDRC
- The Binding Documentation in (2/4) is modified as per the review comments

Changes in v3:
- The commit message in (2/4) is modified (Synopsys EDAC Driver --> ZynqMP DDRC)

Changes in v4:
- Updated the commit message in (1/4)
- Renamed function pointer names removing 'synps_' in (1/4)
- Shortened unnecessary long lines as per the review comment on (1/4)

Changes in v5:
- Updated the commit message in (2/4) and (4/4).
- Removed the unnecessary check for match data in probe() in (1/4)
- Some Indentation changes for better readability in (1/4) and (3/4)
- Removed repeated code in (3/4)
- Used 'zynq' and 'zynqmp' instead of 'synps_enh_edac' in function
names

Changes in v6:
- Splitted the patches according to functionalities
- Addressed code style comments from v5 review
- Moved the Error Injection to CONFIG_EDAC_DEBUG mode

Changes in v7:
- Included DTS patch (6/7) which was missed in v6 patch set

Changes in v8:
- patch (1/7) from v7 is split in to 3 different logically different patches
1. functional changes like code cleanup
2. functions renaming
3. comments cleanup
- Added a separate patch (4) for making always successful functions as
void
- Corrected 'Too many parentheses' review comment in patch (5)
- Corrected comments as per the v7 review feedback
- Made dedicated functions for IRQ setup, IRQ enable and IRQ disable
in patch (8)
- Addressed review comments in patch (10)

Changes in v9:

	- Added check for return value of of_device_get_match_data() function
	  in (1/6).
	- From v8 the first 5 patches are removed in this series as they are
	  applied on:

	https://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git/?h=edac-for-

4.20-synps
- Updated Kconfig to check for ARCH_ZYNQMP instead of ARM64

Change in v10:
- Moved the checking for ce_cnt and ue_cnt before the readl() call
- Aligned arguments on the opening brace in setup_irq()

Manish Narani (6):
edac: synopsys: Add error handling for NULL in probe()
dt: bindings: Document ZynqMP DDRC in Synopsys documentation
edac: synopsys: Add macro defines for ZynqMP DDRC
edac: synopsys: Add EDAC ECC support for ZynqMP DDRC
arm64: zynqmp: Add DDRC node
edac: synopsys: Add Error Injection support for ZynqMP DDRC

 .../bindings/memory-controllers/synopsys.txt       |  27 +-
 arch/arm64/boot/dts/xilinx/zynqmp.dtsi             |   7 +
 drivers/edac/Kconfig                               |   2 +-
 drivers/edac/synopsys_edac.c                       | 911 ++++++++++++++++++++-
 4 files changed, 918 insertions(+), 29 deletions(-)

--
2.1.1

maintainer
#21 lore raw
Quoted 1 line · Manish Narani

Ping!

Let me paste to you what I replied to a similar ping during the merge window:

You do realize that we're right in the merge window right now, right?

And people are busy sending pull requests and fixing fallout.

So sending new stuff during the two weeks of the merge window, will kinda put you on the backburner. Try to remember that next time and be patient.

Signature · 4 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
maintainer
#22 lore raw
In reply to Manish Narani
Quoted 12 lines · Manish Narani

Change in v10:
- Moved the checking for ce_cnt and ue_cnt before the readl() call
- Aligned arguments on the opening brace in setup_irq()

Manish Narani (6):
edac: synopsys: Add error handling for NULL in probe()
dt: bindings: Document ZynqMP DDRC in Synopsys documentation
edac: synopsys: Add macro defines for ZynqMP DDRC
edac: synopsys: Add EDAC ECC support for ZynqMP DDRC
arm64: zynqmp: Add DDRC node
edac: synopsys: Add Error Injection support for ZynqMP DDRC

Quoted 5 lines
 .../bindings/memory-controllers/synopsys.txt       |  27 +-
 arch/arm64/boot/dts/xilinx/zynqmp.dtsi             |   7 +
 drivers/edac/Kconfig                               |   2 +-
 drivers/edac/synopsys_edac.c                       | 911 ++++++++++++++++++++-
 4 files changed, 918 insertions(+), 29 deletions(-)

Ok, patches pushed here:

(minus https://lkml.kernel.org/r/1540447621-22870-6-git-send-email-manish.narani at xilinx.com)

https://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git/log/?h=edac-for-4.21-synps

Please run this on the hw before I queue it for linux-next.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

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

Hi Boris,

Quoted 30 lines

-----Original Message-----
From: Borislav Petkov [mailto:bp at alien8.de]
Sent: Tuesday, November 6, 2018 3:34 PM
To: Manish Narani <[email protected]>
Cc: robh+dt at kernel.org; mark.rutland at arm.com; Michal Simek <[email protected]>; mchehab at kernel.org; amit.kucheria at linaro.org; sudeep.holla at arm.com; leoyang.li at nxp.com; devicetree at vger.kernel.org; linux-kernel at vger.kernel.org; linux-arm-kernel at lists.infradead.org; linux- edac at vger.kernel.org
Subject: Re: [PATCH v10 0/6] EDAC: Enhancements to Synopsys EDAC driver

Quoted 12 lines · Manish Narani

Change in v10:
- Moved the checking for ce_cnt and ue_cnt before the readl() call
- Aligned arguments on the opening brace in setup_irq()

Manish Narani (6):
edac: synopsys: Add error handling for NULL in probe()
dt: bindings: Document ZynqMP DDRC in Synopsys documentation
edac: synopsys: Add macro defines for ZynqMP DDRC
edac: synopsys: Add EDAC ECC support for ZynqMP DDRC
arm64: zynqmp: Add DDRC node
edac: synopsys: Add Error Injection support for ZynqMP DDRC

Quoted 5 lines
 .../bindings/memory-controllers/synopsys.txt       |  27 +-
 arch/arm64/boot/dts/xilinx/zynqmp.dtsi             |   7 +
 drivers/edac/Kconfig                               |   2 +-
 drivers/edac/synopsys_edac.c                       | 911 ++++++++++++++++++++-
 4 files changed, 918 insertions(+), 29 deletions(-)
Quoted 8 lines

Ok, patches pushed here:

(minus https://lkml.kernel.org/r/1540447621-22870-6-git-send-email-
manish.narani at xilinx.com)

https://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git/log/?h=edac-for-4.21-
synps

Thanks a lot for your support.

Quoted 1 line

Please run this on the hw before I queue it for linux-next.

I have tested this and verified as working fine on hardware. You can go ahead and queue it for linux-next.

Thanks,
Manish

maintainer
#24 lore raw
Quoted 2 lines · Manish Narani

I have tested this and verified as working fine on hardware. You can go ahead and queue it for linux-next.

Pushed,
Thanks.

Signature · 4 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.