Addition of Altera SDRAM Controller Summary
Subsystems (3)
v7 cover Addition of Altera SDRAM Controller Summary
From: Thor Thayer <[email protected]>
This patch series adds Altera SDRAM EDAC support.
The one sticky issue seems to be the use of "syscon". One register in the SDRAM controller shares bitfields with different functionality. In this series the devicetree includes the "syscon" designation for the SDRAM Controller [patch 1] but the bindings document does not. This flexibility means future generations of SDRAM controller may correct this sharing of bitfields without changes to the bindings.
Thor Thayer (3):
devicetree: Addition of the Altera SDRAM Controller.
Add the Altera SDRAM controller bindings and device tree changes to the Altera SoC project.
devicetree: Addition of the Altera SDRAM EDAC.
Add the Altera SDRAM EDAC bindings and device tree changes to the Altera SoC project.
edac: altera: Add EDAC support for Altera SoC SDRAM Controller.
This patch adds support for the CycloneV and ArriaV SDRAM controllers. Correction and reporting of SBEs, Panic on DBEs.
.../bindings/arm/altera/socfpga-sdram-edac.txt | 15 + .../bindings/arm/altera/socfpga-sdram.txt | 11 + arch/arm/boot/dts/socfpga.dtsi | 11 + drivers/edac/Kconfig | 9 + drivers/edac/Makefile | 2 + drivers/edac/altera_edac.c | 448 ++++++++++++++++++++ 6 files changed, 496 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdram-edac.txt create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdram.txt create mode 100644 drivers/edac/altera_edac.c
Signature · 1 line
1.7.9.5
PATCH v7 2/3 devicetree: Addition of the Altera SDRAM EDAC.
From: Thor Thayer <[email protected]>
Add the Altera SDRAM EDAC bindings and device tree changes to the Altera SoC project.
---
v2: Changes to SoC EDAC source code.
v3: Fix typo in device tree documentation.
v4,v5: No changes - bump version for consistency.
v6: Assign ECC registers in SDRAM controller to EDAC
v7: Fix SDRAM EDAC base address.
--- .../bindings/arm/altera/socfpga-sdram-edac.txt | 15 +++++++++++++++ arch/arm/boot/dts/socfpga.dtsi | 6 ++++++ 2 files changed, 21 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdram-edac.txt
Documentation/devicetree/bindings/arm/altera/socfpga-sdram-edac.txt new file +15 -0
@@ -0,0 +1,15 @@ +Altera SOCFPGA SDRAM Error Detection & Correction [EDAC] + +Required properties: +- compatible : should contain "altr,sdram-edac"; +- reg : should contain the ECC register range in sdram + controller (address and length). +- interrupts : Should contain the SDRAM ECC IRQ in the + appropriate format for the IRQ controller. + +Example: + sdramedac@ffc2502c { + compatible = "altr,sdram-edac"; + reg = <0xffc2502c 0x28>; + interrupts = <0 39 4>; + };
arch/arm/boot/dts/socfpga.dtsi +6 -0
@@ -687,6 +687,12 @@ reg = <0xffc25000 0x4>; }; + sdramedac@ffc2502c { + compatible = "altr,sdram-edac"; + reg = <0xffc2502c 0x28>; + interrupts = <0 39 4>; + }; + rst: rstmgr@ffd05000 { compatible = "altr,rst-mgr"; reg = <0xffd05000 0x1000>;
Signature · 1 line
1.7.9.5
PATCH v7 1/3 devicetree: Addition of the Altera SDRAM Controller.
In reply to [email protected]From: Thor Thayer <[email protected]>
Add the Altera SDRAM controller bindings and device tree changes to the Altera SoC project.
---
v2: Changes to SoC SDRAM EDAC code.
v3: Implement code suggestions for SDRAM EDAC code.
v4: Remove syscon from SDRAM controller bindings.
v5: No Change, bump version for consistency.
v6: Only map the ctrlcfg register as syscon.
v7: No change. Bump for consistency.
--- .../bindings/arm/altera/socfpga-sdram.txt | 11 +++++++++++ arch/arm/boot/dts/socfpga.dtsi | 5 +++++ 2 files changed, 16 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdram.txt
Documentation/devicetree/bindings/arm/altera/socfpga-sdram.txt new file +11 -0
@@ -0,0 +1,11 @@ +Altera SOCFPGA SDRAM Controller + +Required properties: +- compatible : "altr,sdr-ctl"; +- reg : Should contain 1 register ranges(address and length) + +Example: + sdrctl@ffc25000 { + compatible = "altr,sdr-ctl"; + reg = <0xffc25000 0x4>; + };
arch/arm/boot/dts/socfpga.dtsi +5 -0
@@ -682,6 +682,11 @@ clocks = <&l4_sp_clk>; }; + sdrctl@ffc25000 { + compatible = "altr,sdr-ctl", "syscon"; + reg = <0xffc25000 0x4>; + }; + rst: rstmgr@ffd05000 { compatible = "altr,rst-mgr"; reg = <0xffd05000 0x1000>;
Signature · 1 line
1.7.9.5
PATCH v7 3/3 edac: altera: Add EDAC support for Altera SoC SDRAM Controller.
In reply to [email protected]From: Thor Thayer <[email protected]>
This patch adds support for the CycloneV and ArriaV SDRAM controllers. Correction and reporting of SBEs, Panic on DBEs.
---
v2: Use the SDRAM controller registers to calculate memory size
instead of the Device Tree. Update To & Cc list. Add maintainer information.
v3: EDAC driver cleanup based on comments from Mailing list.
v4: Panic on DBE. Add macro around inject-error reads to prevent
them from being optimized out. Remove of_match_ptr since this will always use Device Tree.
v5: Addition of printk to trigger function to ensure read vars
are not optimized out.
v6: Changes to split out shared SDRAM controller reg (offset 0x00)
as a syscon device and allocate ECC specific SDRAM registers to EDAC.
v7: No change. Bump version for consistency.
--- drivers/edac/Kconfig | 9 + drivers/edac/Makefile | 2 + drivers/edac/altera_edac.c | 448 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 459 insertions(+) create mode 100644 drivers/edac/altera_edac.c
drivers/edac/Kconfig +9 -0
@@ -368,4 +368,13 @@ config EDAC_OCTEON_PCI Support for error detection and correction on the Cavium Octeon family of SOCs. +config EDAC_ALTERA_MC + bool "Altera SDRAM Memory Controller EDAC" + depends on EDAC_MM_EDAC && ARCH_SOCFPGA + help + Support for error detection and correction on the + Altera SDRAM memory controller. Note that the + preloader must initialize the SDRAM before loading + the kernel. + endif # EDAC
drivers/edac/Makefile +2 -0
@@ -64,3 +64,5 @@ obj-$(CONFIG_EDAC_OCTEON_PC) += octeon_edac-pc.o obj-$(CONFIG_EDAC_OCTEON_L2C) += octeon_edac-l2c.o obj-$(CONFIG_EDAC_OCTEON_LMC) += octeon_edac-lmc.o obj-$(CONFIG_EDAC_OCTEON_PCI) += octeon_edac-pci.o + +obj-$(CONFIG_EDAC_ALTERA_MC) += altera_edac.o
drivers/edac/altera_edac.c new file +448 -0
448 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCHv7 3/3] edac: altera: Add EDAC support for Altera SoC SDRAM Controller.
Hi Thor,
Quoted 87 lines · tthayer at altera.com
From: Thor Thayer <[email protected]>
This patch adds support for the CycloneV and ArriaV SDRAM controllers. Correction and reporting of SBEs, Panic on DBEs.
Signed-off-by Thor Thayer <[email protected]>---
v2: Use the SDRAM controller registers to calculate memory size
instead of the Device Tree. Update To & Cc list. Add maintainer information.v3: EDAC driver cleanup based on comments from Mailing list.
v4: Panic on DBE. Add macro around inject-error reads to prevent
them from being optimized out. Removeof_match_ptrsince this will always use Device Tree.v5: Addition of printk to trigger function to ensure read vars
are not optimized out.v6: Changes to split out shared SDRAM controller reg (offset
0x00)
as a syscon device and allocate ECC specific SDRAM registers to EDAC.v7: No change. Bump version for consistency.
--- drivers/edac/Kconfig | 9 + drivers/edac/Makefile | 2 + drivers/edac/altera_edac.c | 448 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 459 insertions(+)create mode 100644
drivers/edac/altera_edac.cdrivers/edac/Kconfig +9
-0@@ -368,4 +368,13 @@ config EDAC_OCTEON_PCI Support for error detection and correction on the Cavium Octeon family of SOCs. +config EDAC_ALTERA_MC + bool "Altera SDRAM Memory Controller EDAC" + depends on EDAC_MM_EDAC && ARCH_SOCFPGA + help + Support for error detection and correction on the + Altera SDRAM memory controller. Note that the + preloader must initialize the SDRAM before loading + the kernel. + endif # EDACdrivers/edac/Makefile +2
-0@@ -64,3 +64,5 @@ obj-$(CONFIG_EDAC_OCTEON_PC) += octeon_edac-pc.o obj-$(CONFIG_EDAC_OCTEON_L2C) += octeon_edac-l2c.o obj-$(CONFIG_EDAC_OCTEON_LMC) += octeon_edac-lmc.o obj-$(CONFIG_EDAC_OCTEON_PCI) += octeon_edac-pci.o + +obj-$(CONFIG_EDAC_ALTERA_MC) += altera_edac.odrivers/edac/altera_edac.c new file +21
-0@@ -0,0 +1,448 @@ +/* +* Copyright Altera Corporation (C) 2014. All rights reserved. +* Copyright 2011-2012 Calxeda, Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* This file is subject to the terms and conditions of the GNU General Public +* License. See the file "COPYING" in the main directory of this archive +* for more details. + +* +* Adapted from the highbank_mc_edac driver +* +*/
drivers/edac/altera_edac.c line 31
Quoted 10 lines
drivers/edac/altera_edac.c new file +10
-0+#include <linux/types.h> +#include <linux/kernel.h> +#include <linux/ctype.h> +#include <linux/edac.h> +#include <linux/interrupt.h> +#include <linux/platform_device.h> +#include <linux/of_platform.h> +#include <linux/uaccess.h> +#include <linux/mfd/syscon.h> +#include <linux/regmap.h>
Did you miss my comment to put these headers in alpabetical order?
Dinh
Re: [PATCHv7 3/3] edac: altera: Add EDAC support for Altera SoC SDRAM Controller.
Hi Dinh,
Quoted 110 lines · Dinh Nguyen
Hi Thor,
Quoted 93 lines · tthayer at altera.com
From: Thor Thayer <[email protected]>
This patch adds support for the CycloneV and ArriaV SDRAM controllers. Correction and reporting of SBEs, Panic on DBEs.
Signed-off-by Thor Thayer <[email protected]>---
v2: Use the SDRAM controller registers to calculate memory size
instead of the Device Tree. Update To & Cc list. Add maintainer information.v3: EDAC driver cleanup based on comments from Mailing list.
v4: Panic on DBE. Add macro around inject-error reads to prevent
them from being optimized out. Removeof_match_ptrsince this will always use Device Tree.v5: Addition of printk to trigger function to ensure read vars
are not optimized out.v6: Changes to split out shared SDRAM controller reg (offset
0x00)
as a syscon device and allocate ECC specific SDRAM registers to EDAC.v7: No change. Bump version for consistency.
--- drivers/edac/Kconfig | 9 + drivers/edac/Makefile | 2 + drivers/edac/altera_edac.c | 448 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 459 insertions(+)create mode 100644
drivers/edac/altera_edac.cdrivers/edac/Kconfig +9
-0@@ -368,4 +368,13 @@ config EDAC_OCTEON_PCI Support for error detection and correction on the Cavium Octeon family of SOCs. +config EDAC_ALTERA_MC + bool "Altera SDRAM Memory Controller EDAC" + depends on EDAC_MM_EDAC && ARCH_SOCFPGA + help + Support for error detection and correction on the + Altera SDRAM memory controller. Note that the + preloader must initialize the SDRAM before loading + the kernel. + endif # EDACdrivers/edac/Makefile +0
-0@@ -64,3 +64,5 @@ obj-$(CONFIG_EDAC_OCTEON_PC) +=octeon_edac-pc.o
obj-$(CONFIG_EDAC_OCTEON_L2C) += octeon_edac-l2c.o obj-$(CONFIG_EDAC_OCTEON_LMC) += octeon_edac-lmc.o obj-$(CONFIG_EDAC_OCTEON_PCI) += octeon_edac-pci.odrivers/edac/Makefile +2
-0+ +obj-$(CONFIG_EDAC_ALTERA_MC) += altera_edac.odrivers/edac/altera_edac.c new file +11
-0@@ -0,0 +1,448 @@ +/* +* Copyright Altera Corporation (C) 2014. All rights reserved. +* Copyright 2011-2012 Calxeda, Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.drivers/edac/altera_edac.c new file +5
-0+ +* +* Adapted from the highbank_mc_edac driver +* +*/ drivers/edac/altera_edac.c line 31
Quoted 10 lines
drivers/edac/altera_edac.c new file +10
-0+#include <linux/types.h> +#include <linux/kernel.h> +#include <linux/ctype.h> +#include <linux/edac.h> +#include <linux/interrupt.h> +#include <linux/platform_device.h> +#include <linux/of_platform.h> +#include <linux/uaccess.h> +#include <linux/mfd/syscon.h> +#include <linux/regmap.h> Did you miss my comment to put these headers in alpabetical order?
Quoted 1 line
Dinh
Yep, I missed your comment - looking at it now.
Re: [PATCHv7 2/3] devicetree: Addition of the Altera SDRAM EDAC.
In reply to [email protected]Quoted 47 lines · tthayer at altera.com
From: Thor Thayer <[email protected]>
Add the Altera SDRAM EDAC bindings and device tree changes to the Altera SoC project.
Signed-off-by Thor Thayer <[email protected]>---
v2: Changes to SoC EDAC source code.v3: Fix typo in device tree documentation.
v4,v5: No changes - bump version for consistency.
v6: Assign ECC registers in SDRAM controller to EDAC
v7: Fix SDRAM EDAC base address.
--- .../bindings/arm/altera/socfpga-sdram-edac.txt | 15 +++++++++++++++ arch/arm/boot/dts/socfpga.dtsi | 6 ++++++ 2 files changed, 21 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdram-edac.txtDocumentation/devicetree/bindings/arm/altera/socfpga-sdram-edac.txt new file +15
-0@@ -0,0 +1,15 @@ +Altera SOCFPGA SDRAM Error Detection & Correction [EDAC] + +Required properties: +- compatible : should contain "altr,sdram-edac"; +- reg : should contain the ECC register range in sdram + controller (address and length). +- interrupts : Should contain the SDRAM ECC IRQ in the + appropriate format for the IRQ controller. + +Example: + sdramedac at ffc2502c { + compatible = "altr,sdram-edac"; + reg = <0xffc2502c 0x28>; + interrupts = <0 39 4>; + };arch/arm/boot/dts/socfpga.dtsi +0
-0
arch/arm/boot/dts/socfpga.dtsi line 694
Quoted 8 lines
arch/arm/boot/dts/socfpga.dtsi +5
-0@@ -687,6 +687,12 @@ reg = <0xffc25000 0x4>; }; + sdramedac at ffc2502c { + compatible = "altr,sdram-edac"; + reg = <0xffc2502c 0x28>; + interrupts = <0 39 4>; + };
I'm not sure I understand this. The ECC register existing within the SDRAM controller, which we have a binding for. Why do we need a separate binding for a subset of registers within an IP block?
Why can we not have a single binding for the entire SDRAM controlelr and decompse that within Linux as it makes sense for the appropriate subsystyems?
Leaking Linux design into bindings is a bad idea; it makes it harder to change things.
Mark.
Re: [PATCHv7 2/3] devicetree: Addition of the Altera SDRAM EDAC.
Hi Mark
Quoted 61 lines · Mark Rutland
Quoted 47 lines · tthayer at altera.com
From: Thor Thayer <[email protected]>
Add the Altera SDRAM EDAC bindings and device tree changes to the Altera SoC project.
Signed-off-by Thor Thayer <[email protected]>---
v2: Changes to SoC EDAC source code.v3: Fix typo in device tree documentation.
v4,v5: No changes - bump version for consistency.
v6: Assign ECC registers in SDRAM controller to EDAC
v7: Fix SDRAM EDAC base address.
--- .../bindings/arm/altera/socfpga-sdram-edac.txt | 15 +++++++++++++++ arch/arm/boot/dts/socfpga.dtsi | 6 ++++++ 2 files changed, 21 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdram-edac.txtDocumentation/devicetree/bindings/arm/altera/socfpga-sdram-edac.txt new file +15
-0@@ -0,0 +1,15 @@ +Altera SOCFPGA SDRAM Error Detection & Correction [EDAC] + +Required properties: +- compatible : should contain "altr,sdram-edac"; +- reg : should contain the ECC register range in sdram + controller (address and length). +- interrupts : Should contain the SDRAM ECC IRQ in the + appropriate format for the IRQ controller. + +Example: + sdramedac at ffc2502c { + compatible = "altr,sdram-edac"; + reg = <0xffc2502c 0x28>; + interrupts = <0 39 4>; + };arch/arm/boot/dts/socfpga.dtsi +0
-0arch/arm/boot/dts/socfpga.dtsi line 694
Quoted 8 lines
arch/arm/boot/dts/socfpga.dtsi +5
-0@@ -687,6 +687,12 @@ reg = <0xffc25000 0x4>; }; + sdramedac at ffc2502c { + compatible = "altr,sdram-edac"; + reg = <0xffc2502c 0x28>; + interrupts = <0 39 4>; + };I'm not sure I understand this. The ECC register existing within the SDRAM controller, which we have a binding for. Why do we need a separate binding for a subset of registers within an IP block?
Quoted 8 lines
Why can we not have a single binding for the entire SDRAM controlelr and decompse that within Linux as it makes sense for the appropriate subsystyems?
Leaking Linux design into bindings is a bad idea; it makes it harder to change things.
Mark.
Sorry, I missed your reply. Luckily Dinh pointed it out to me.
The SDRAM Controller binding is just 1 register but it includes bitfields that describe the SDRAM configuration as well as some bitfields for ECC. Ideally the ECC bitfields would be in a separate register and could be included in the SDRAM EDAC block.
It is anticipated that other drivers and U-Boot may need to read the SDRAM configuration which is why this register contains a "syscon" designation.
The SDRAM EDAC block is a set of registers in the SDRAM Controller IP register space that are ECC specific. I was thinking this should be a separate binding since it encompasses 1 complete task but I see your point about just having 1 binding.
I appreciate your help on figuring the proper way to handle this. Sorry about reposting without addressing your comment.
Thanks,
Thor
Re: [PATCHv7 3/3] edac: altera: Add EDAC support for Altera SoC SDRAM Controller.
In reply to [email protected]drivers/edac/altera_edac.c line 250
Quoted 12 lines
drivers/edac/altera_edac.c new file +12
-0+ read_reg =readl (mc_vbase +DRAMADDRW ); + + width =readl (mc_vbase +DRAMIFWIDTH ); + + col = (read_reg &DRAMADDRW_COLBIT_MASK ) >> +DRAMADDRW_COLBIT_LSB ; + row = (read_reg &DRAMADDRW_ROWBIT_MASK ) >> +DRAMADDRW_ROWBIT_LSB ; + bank = (read_reg &DRAMADDRW_BANKBIT_MASK ) >> +DRAMADDRW_BANKBIT_LSB ; + cs = (read_reg &DRAMADDRW_CSBIT_MASK ) >> +DRAMADDRW_CSBIT_LSB ;
As I said, all the defines only make this harder to read. The code is pretty obvious if you put numbers in here...
Plus I'd like an explanation/comment of how the error injection works.
Thanks,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Borislav Petkov
maintainerRe: [PATCHv7 3/3] edac: altera: Add EDAC support for Altera SoC SDRAM Controller.
Quoted 7 lines · Pavel Machek
Quoted 7 lines
drivers/edac/altera_edac.c new file +7
-0+ read_reg =readl (mc_vbase +DRAMADDRW ); + + width =readl (mc_vbase +DRAMIFWIDTH ); + + col = (read_reg &DRAMADDRW_COLBIT_MASK ) >> +DRAMADDRW_COLBIT_LSB ; + row = (read_reg & DRAMADDRW_ROWBIT_MASK) >>
Quoted 8 lines
drivers/edac/altera_edac.c line 250
Quoted 5 lines
drivers/edac/altera_edac.c new file +5
-0+DRAMADDRW_ROWBIT_LSB ; + bank = (read_reg &DRAMADDRW_BANKBIT_MASK ) >> +DRAMADDRW_BANKBIT_LSB ; + cs = (read_reg &DRAMADDRW_CSBIT_MASK ) >> +DRAMADDRW_CSBIT_LSB ;As I said, all the defines only make this harder to read. The code is pretty obvious if you put numbers in here...
Since when it is a good coding practice to put naked numbers instead of descriptive macro names??!
Now, I can understand that the macro names could be made more descriptive so that you can understand what they mean, but naked numbers?! You must be joking although 1st of April is long gone.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCHv7 3/3] edac: altera: Add EDAC support for Altera SoC SDRAM Controller.
Quoted 17 lines · Borislav Petkov
Quoted 7 lines · Pavel Machek
Quoted 7 lines
drivers/edac/altera_edac.c new file +7
-0+ read_reg =readl (mc_vbase +DRAMADDRW ); + + width =readl (mc_vbase +DRAMIFWIDTH ); + + col = (read_reg &DRAMADDRW_COLBIT_MASK ) >> +DRAMADDRW_COLBIT_LSB ; + row = (read_reg & DRAMADDRW_ROWBIT_MASK) >>Quoted 8 lines
drivers/edac/altera_edac.c line 250
Quoted 5 lines
drivers/edac/altera_edac.c new file +5
-0+DRAMADDRW_ROWBIT_LSB ; + bank = (read_reg &DRAMADDRW_BANKBIT_MASK ) >> +DRAMADDRW_BANKBIT_LSB ; + cs = (read_reg &DRAMADDRW_CSBIT_MASK ) >> +DRAMADDRW_CSBIT_LSB ;As I said, all the defines only make this harder to read. The code is pretty obvious if you put numbers in here...
Quoted 6 lines
Since when it is a good coding practice to put naked numbers instead of descriptive macro names??!
Now, I can understand that the macro names could be made more descriptive so that you can understand what they mean, but naked numbers?! You must be joking although 1st of April is long gone.
I'm not joking. Try to understand and verify the code above. You can't. The "descriptive macro names" are useless; all the code does is split register in pieces. With the numbers it would be very obvious.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Borislav Petkov
maintainerRe: [PATCHv7 3/3] edac: altera: Add EDAC support for Altera SoC SDRAM Controller.
Quoted 3 lines · Pavel Machek
I'm not joking. Try to understand and verify the code above. You can't. The "descriptive macro names" are useless; all the code does is split register in pieces. With the numbers it would be very obvious.
No, you need to fix the names not switch to naked numbers.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCHv7 3/3] edac: altera: Add EDAC support for Altera SoC SDRAM Controller.
Quoted 6 lines · Borislav Petkov
Quoted 3 lines · Pavel Machek
I'm not joking. Try to understand and verify the code above. You can't. The "descriptive macro names" are useless; all the code does is split register in pieces. With the numbers it would be very obvious.
No, you need to fix the names not switch to naked numbers.
Hiding numbers that are used just once into defines to put them out of sight does not really help readability.
Compare:
+#define DRAMADDRW_COLBIT_MASK 0x001F
+#define DRAMADDRW_COLBIT_LSB 0
+#define DRAMADDRW_ROWBIT_MASK 0x02E0
+#define DRAMADDRW_ROWBIT_LSB 5
+#define DRAMADDRW_BANKBIT_MASK 0x1C00
+#define DRAMADDRW_BANKBIT_LSB 10
+#define DRAMADDRW_CSBIT_MASK 0xE000
+#define DRAMADDRW_CSBIT_LSB 13
(Insert few screens of code so that you have to scroll or split window).
What information do the define names have? None, I already know how hardware registers work.
+ col = (read_reg & DRAMADDRW_COLBIT_MASK) >>
+ DRAMADDRW_COLBIT_LSB;
+ row = (read_reg & DRAMADDRW_ROWBIT_MASK) >>
+ DRAMADDRW_ROWBIT_LSB;
+ bank = (read_reg & DRAMADDRW_BANKBIT_MASK) >>
+ DRAMADDRW_BANKBIT_LSB;
+ cs = (read_reg & DRAMADDRW_CSBIT_MASK) >>
+ DRAMADDRW_CSBIT_LSB;
Instead, we could have:
col = read_reg & 0x001F; row = (read_reg & 0x02E0) >> 5; bank = (read_reg & 0x1C00) >> 10; cs = (read_reg & 0xE000) >> 13;
All information is preserved, code is shorter and easier to understand.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCHv7 2/3] devicetree: Addition of the Altera SDRAM EDAC.
In reply to Mark RutlandQuoted 61 lines · Mark Rutland
Quoted 47 lines · tthayer at altera.com
From: Thor Thayer <[email protected]>
Add the Altera SDRAM EDAC bindings and device tree changes to the Altera SoC project.
Signed-off-by Thor Thayer <[email protected]>---
v2: Changes to SoC EDAC source code.v3: Fix typo in device tree documentation.
v4,v5: No changes - bump version for consistency.
v6: Assign ECC registers in SDRAM controller to EDAC
v7: Fix SDRAM EDAC base address.
--- .../bindings/arm/altera/socfpga-sdram-edac.txt | 15 +++++++++++++++ arch/arm/boot/dts/socfpga.dtsi | 6 ++++++ 2 files changed, 21 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdram-edac.txtDocumentation/devicetree/bindings/arm/altera/socfpga-sdram-edac.txt new file +15
-0@@ -0,0 +1,15 @@ +Altera SOCFPGA SDRAM Error Detection & Correction [EDAC] + +Required properties: +- compatible : should contain "altr,sdram-edac"; +- reg : should contain the ECC register range in sdram + controller (address and length). +- interrupts : Should contain the SDRAM ECC IRQ in the + appropriate format for the IRQ controller. + +Example: + sdramedac at ffc2502c { + compatible = "altr,sdram-edac"; + reg = <0xffc2502c 0x28>; + interrupts = <0 39 4>; + };arch/arm/boot/dts/socfpga.dtsi +0
-0arch/arm/boot/dts/socfpga.dtsi line 694
Quoted 8 lines
arch/arm/boot/dts/socfpga.dtsi +5
-0@@ -687,6 +687,12 @@ reg = <0xffc25000 0x4>; }; + sdramedac at ffc2502c { + compatible = "altr,sdram-edac"; + reg = <0xffc2502c 0x28>; + interrupts = <0 39 4>; + };I'm not sure I understand this. The ECC register existing within the SDRAM controller, which we have a binding for. Why do we need a separate binding for a subset of registers within an IP block?
Quoted 8 lines
Why can we not have a single binding for the entire SDRAM controlelr and decompse that within Linux as it makes sense for the appropriate subsystyems?
Leaking Linux design into bindings is a bad idea; it makes it harder to change things.
Mark.
Hi Mark,
How would we decompose this within Linux. MFD? Is there an example that I can look at?
We originally used syscon for the entire sdram controller register block but we got dinged on it.
Thanks for your help.
Thor
Re: [PATCHv7 2/3] devicetree: Addition of the Altera SDRAM EDAC.
Quoted 72 lines · Thor Thayer
Quoted 61 lines · Mark Rutland
Quoted 47 lines · tthayer at altera.com
From: Thor Thayer <[email protected]>
Add the Altera SDRAM EDAC bindings and device tree changes to the Altera SoC project.
Signed-off-by Thor Thayer <[email protected]>---
v2: Changes to SoC EDAC source code.v3: Fix typo in device tree documentation.
v4,v5: No changes - bump version for consistency.
v6: Assign ECC registers in SDRAM controller to EDAC
v7: Fix SDRAM EDAC base address.
--- .../bindings/arm/altera/socfpga-sdram-edac.txt | 15 +++++++++++++++ arch/arm/boot/dts/socfpga.dtsi | 6 ++++++ 2 files changed, 21 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdram-edac.txtDocumentation/devicetree/bindings/arm/altera/socfpga-sdram-edac.txt new file +15
-0@@ -0,0 +1,15 @@ +Altera SOCFPGA SDRAM Error Detection & Correction [EDAC] + +Required properties: +- compatible : should contain "altr,sdram-edac"; +- reg : should contain the ECC register range in sdram + controller (address and length). +- interrupts : Should contain the SDRAM ECC IRQ in the + appropriate format for the IRQ controller. + +Example: + sdramedac at ffc2502c { + compatible = "altr,sdram-edac"; + reg = <0xffc2502c 0x28>; + interrupts = <0 39 4>; + };arch/arm/boot/dts/socfpga.dtsi +0
-0arch/arm/boot/dts/socfpga.dtsi line 694
Quoted 8 lines
arch/arm/boot/dts/socfpga.dtsi +5
-0@@ -687,6 +687,12 @@ reg = <0xffc25000 0x4>; }; + sdramedac at ffc2502c { + compatible = "altr,sdram-edac"; + reg = <0xffc2502c 0x28>; + interrupts = <0 39 4>; + };I'm not sure I understand this. The ECC register existing within the SDRAM controller, which we have a binding for. Why do we need a separate binding for a subset of registers within an IP block?
Quoted 8 lines
Why can we not have a single binding for the entire SDRAM controlelr and decompse that within Linux as it makes sense for the appropriate subsystyems?
Leaking Linux design into bindings is a bad idea; it makes it harder to change things.
Mark.
Quoted 7 lines
Hi Mark,
How would we decompose this within Linux. MFD? Is there an example that I can look at?
We originally used syscon for the entire sdram controller register block but we got dinged on it.
I think it is good feedback that we don't want the devicetree to break up this register range (unless someone wants to argue that).
The problem we need to solve here is that the sdram controller register range has registers that are needed for at least 3 different functions/drivers: edac, fpga bridges, and loe power mode (putting ddr in self-refresh). We would not want to do that in one driver. Originally we had the whole sdram controller as 'syscon' and that was frowned upon. I think someone suggested a MFD. We can do that and will do that if that will move things forward. But that would just be a mfd that ioremaps the range and provides read/write functions for other drivers to use (which starts looking very similar to syscon except that it adds more code to the kernel to do what syscon does). It seems like that's what syscon was for (looking at Documentation/devicetree/bindings/mfd/syscon.txt).
So can we have a consensus here on syscon or a very minimal mfd or some other clear way of moving forward?
Alan
Quoted 4 lines
Thanks for your help.
Thor