Skip to contentSkip to conversation

Add Altera peripheral memories to EDAC framework

PATCH Superseded [email protected] 2 participants 11 messages Oct 17, 2014 – Oct 30, 2014

Subsystems (5)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add Altera peripheral memories to EDAC framework

From: Thor Thayer <[email protected]>

This patch adds the L2 cache and OCRAM peripherals to the EDAC framework using the EDAC device framework. The ECC is enabled early in the boot process in the platform specific code.

Thor Thayer (4):
arm: socfpga: Enable L2 Cache ECC on startup.
arm: socfpga: Enable OCRAM ECC on startup.
edac: altera: Add Altera L2 Cache and OCRAM EDAC Support
arm: dts: Add Altera L2 Cache and OCRAM EDAC

 .../bindings/arm/altera/socfpga-l2-edac.txt        |   15 ++
 .../bindings/arm/altera/socfpga-ocram-edac.txt     |   16 ++
 MAINTAINERS                                        |    4 +-
 arch/arm/boot/dts/socfpga.dtsi                     |   15 +-
 arch/arm/mach-socfpga/Makefile                     |    2 +
 arch/arm/mach-socfpga/l2_cache.c                   |   44 ++++
 arch/arm/mach-socfpga/l2_cache.h                   |   28 +++
 arch/arm/mach-socfpga/ocram.c                      |   90 +++++++
 arch/arm/mach-socfpga/ocram.h                      |   28 +++
 arch/arm/mach-socfpga/socfpga.c                    |   13 +-
 drivers/edac/Kconfig                               |   14 ++
 drivers/edac/Makefile                              |    3 +
 drivers/edac/altera_edac_mgr.c                     |  261 ++++++++++++++++++++
 drivers/edac/altera_edac_mgr.h                     |   56 +++++
 drivers/edac/altera_l2_edac.c                      |  130 ++++++++++
 drivers/edac/altera_ocram_edac.c                   |  107 ++++++++
 16 files changed, 823 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-l2-edac.txt
 create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-ocram-edac.txt
 create mode 100644 arch/arm/mach-socfpga/l2_cache.c
 create mode 100644 arch/arm/mach-socfpga/l2_cache.h
 create mode 100644 arch/arm/mach-socfpga/ocram.c
 create mode 100644 arch/arm/mach-socfpga/ocram.h
 create mode 100644 drivers/edac/altera_edac_mgr.c
 create mode 100644 drivers/edac/altera_edac_mgr.h
 create mode 100644 drivers/edac/altera_l2_edac.c
 create mode 100644 drivers/edac/altera_ocram_edac.c
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/4 arm: socfpga: Enable L2 Cache ECC on startup.

From: Thor Thayer <[email protected]>

This patch enables the ECC for L2 cache on machine startup. The ECC has to be enabled before data is is stored in memory otherwise the ECC will fail on reads.

---
v2: Split OCRAM initialization into separate patch.

---
 MAINTAINERS                      |    1 +
 arch/arm/mach-socfpga/Makefile   |    1 +
 arch/arm/mach-socfpga/l2_cache.c |   44 ++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-socfpga/l2_cache.h |   28 ++++++++++++++++++++++++
 arch/arm/mach-socfpga/socfpga.c  |    5 ++++-
 5 files changed, 78 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-socfpga/l2_cache.c
 create mode 100644 arch/arm/mach-socfpga/l2_cache.h
MAINTAINERS +1 -0
index ee1bc5b..d0c7752 100644
@@ -1407,6 +1407,7 @@ ARM/SOCFPGA EDAC SUPPORT
 M:	Thor Thayer <[email protected]>
 S:	Maintained
 F:	drivers/edac/altera_edac.
+F:	arch/arm/mach-socfpga/l2_cache.*
 
 ARM/STI ARCHITECTURE
 M:	Srinivas Kandagatla <[email protected]>
arch/arm/mach-socfpga/Makefile +1 -0
index 6dd7a93..142609e 100644
@@ -4,3 +4,4 @@
 
 obj-y					:= socfpga.o
 obj-$(CONFIG_SMP)	+= headsmp.o platsmp.o
+obj-$(CONFIG_EDAC_ALTERA_L2C) += l2_cache.o
arch/arm/mach-socfpga/l2_cache.c new file +44 -0

44 lines not on this page · raw message

arch/arm/mach-socfpga/l2_cache.h new file +28 -0
new file mode 100644
index 0000000..58e140d
@@ -0,0 +1,28 @@
+/*
+ * Copyright Altera Corporation (C) 2014. All rights reserved.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MACH_SOCFPGA_L2_CACHE_H
+#define MACH_SOCFPGA_L2_CACHE_H
+
+#ifdef CONFIG_EDAC_ALTERA_L2C
+void socfpga_init_l2_ecc(void);
+#else
+inline void socfpga_init_l2_ecc(void)
+{
+}
+#endif
+
+#endif /* #ifndef MACH_SOCFPGA_L2_CACHE_H */
arch/arm/mach-socfpga/socfpga.c +4 -1
index adbf383..af6413a 100644
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2012 Altera Corporation
+ *  Copyright (C) 2012;2014 Altera Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,8 @@
 #include <asm/mach/map.h>
 
 #include "core.h"
+#include "l2_cache.h"
+#include "ocram.h"
 
 void __iomem *socfpga_scu_base_addr = ((void __iomem *)(SOCFPGA_SCU_VIRT_BASE));
 void __iomem *sys_manager_base_addr;
@@ -83,6 +85,7 @@ static void __init socfpga_init_irq(void)
 {
 	irqchip_init();
 	socfpga_sysmgr_init();
+	socfpga_init_l2_ecc();
 }
 
 static void socfpga_cyclone5_restart(enum reboot_mode mode, const char *cmd)
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v2 2/4 arm: socfpga: Enable OCRAM ECC on startup.

In reply to [email protected]

From: Thor Thayer <[email protected]>

This patch enables the ECC for On-Chip RAM on machine startup. The ECC has to be enabled before data is is stored in memory otherwise the ECC will fail on reads.

---
v2: Split OCRAM ECC portion separately. Addition of iounmap() and reorganization of gen_pool_free. Remove defconfig from patch.

---
 MAINTAINERS                     |    1 +
 arch/arm/mach-socfpga/Makefile  |    1 +
 arch/arm/mach-socfpga/ocram.c   |   90 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-socfpga/ocram.h   |   28 ++++++++++++
 arch/arm/mach-socfpga/socfpga.c |    8 ++++
 5 files changed, 128 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/ocram.c
 create mode 100644 arch/arm/mach-socfpga/ocram.h
MAINTAINERS +1 -0
index d0c7752..c6d390e 100644
@@ -1408,6 +1408,7 @@ M:	Thor Thayer <[email protected]>
 S:	Maintained
 F:	drivers/edac/altera_edac.
 F:	arch/arm/mach-socfpga/l2_cache.*
+F:	arch/arm/mach-socfpga/ocram.*
 
 ARM/STI ARCHITECTURE
 M:	Srinivas Kandagatla <[email protected]>
arch/arm/mach-socfpga/Makefile +1 -0
index 142609e..1552ca5 100644
@@ -5,3 +5,4 @@
 obj-y					:= socfpga.o
 obj-$(CONFIG_SMP)	+= headsmp.o platsmp.o
 obj-$(CONFIG_EDAC_ALTERA_L2C) += l2_cache.o
+obj-$(CONFIG_EDAC_ALTERA_OCRAM) += ocram.o
arch/arm/mach-socfpga/ocram.c new file +90 -0

90 lines not on this page · raw message

arch/arm/mach-socfpga/ocram.h new file +28 -0
new file mode 100644
index 0000000..f93cf84
@@ -0,0 +1,28 @@
+/*
+ * Copyright Altera Corporation (C) 2014. All rights reserved.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MACH_SOCFPGA_OCRAM_H
+#define MACH_SOCFPGA_OCRAM_H
+
+#ifdef CONFIG_EDAC_ALTERA_OCRAM
+void socfpga_init_ocram_ecc(void);
+#else
+inline void socfpga_init_ocram_ecc(void)
+{
+}
+#endif
+
+#endif /* #ifndef MACH_SOCFPGA_OCRAM_H */
arch/arm/mach-socfpga/socfpga.c +8 -0
index af6413a..fb41aca 100644
@@ -101,6 +101,13 @@ static void socfpga_cyclone5_restart(enum reboot_mode mode, const char *cmd)
 	writel(temp, rst_manager_base_addr + SOCFPGA_RSTMGR_CTRL);
 }
 
+static void __init socfpga_cyclone5_init(void)
+{
+	of_platform_populate(NULL, of_default_bus_match_table,
+			     NULL, NULL);
+	socfpga_init_ocram_ecc();
+}
+
 static const char *altera_dt_match[] = {
 	"altr,socfpga",
 	NULL
@@ -112,6 +119,7 @@ DT_MACHINE_START(SOCFPGA, "Altera SOCFPGA")
 	.smp		= smp_ops(socfpga_smp_ops),
 	.map_io		= socfpga_map_io,
 	.init_irq	= socfpga_init_irq,
+	.init_machine	= socfpga_cyclone5_init,
 	.restart	= socfpga_cyclone5_restart,
 	.dt_compat	= altera_dt_match,
 MACHINE_END
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v2 3/4 edac: altera: Add Altera L2 and OCRAM EDAC support

In reply to [email protected]

From: Thor Thayer <[email protected]>

Adding L2 Cache and On-Chip RAM EDAC support for the Altera SoCs using the EDAC_DEVICE framework. The EDAC manager abstracts the common probe functionality and test triggers. The L2 Cache and OCRAM files handle the specific memory functions (alloc & free) for the testing triggers.

---
v2: Fix L2 dependency comments.

---
 MAINTAINERS                      |    2 +-
 drivers/edac/Kconfig             |   14 ++
 drivers/edac/Makefile            |    3 +
 drivers/edac/altera_edac_mgr.c   |  261 ++++++++++++++++++++++++++++++++++++++
 drivers/edac/altera_edac_mgr.h   |   56 ++++++++
 drivers/edac/altera_l2_edac.c    |  130 +++++++++++++++++++
 drivers/edac/altera_ocram_edac.c |  107 ++++++++++++++++
 7 files changed, 572 insertions(+), 1 deletion(-)
 create mode 100644 drivers/edac/altera_edac_mgr.c
 create mode 100644 drivers/edac/altera_edac_mgr.h
 create mode 100644 drivers/edac/altera_l2_edac.c
 create mode 100644 drivers/edac/altera_ocram_edac.c
MAINTAINERS +1 -1
index c6d390e..f5a0692 100644
@@ -1406,7 +1406,7 @@ F:	drivers/clk/socfpga/
 ARM/SOCFPGA EDAC SUPPORT
 M:	Thor Thayer <[email protected]>
 S:	Maintained
-F:	drivers/edac/altera_edac.
+F:	drivers/edac/altera_*
 F:	arch/arm/mach-socfpga/l2_cache.*
 F:	arch/arm/mach-socfpga/ocram.*
 
drivers/edac/Kconfig +14 -0
index 7072c28..a9f98c2 100644
@@ -385,4 +385,18 @@ config EDAC_ALTERA_MC
 	  preloader must initialize the SDRAM before loading
 	  the kernel.
 
+config EDAC_ALTERA_L2C
+	bool "Altera L2 Cache EDAC"
+	depends on EDAC_MM_EDAC=y && ARCH_SOCFPGA && CACHE_L2X0
+	help
+	  Support for error detection and correction on the
+	  Altera L2 cache Memory for Altera SoCs.
+
+config EDAC_ALTERA_OCRAM
+	bool "Altera On-Chip RAM EDAC"
+	depends on EDAC_MM_EDAC=y && ARCH_SOCFPGA && SRAM && GENERIC_ALLOCATOR
+	help
+	  Support for error detection and correction on the
+	  Altera On-Chip RAM Memory for Altera SoCs.
+
 endif # EDAC
drivers/edac/Makefile +3 -0
index 359aa49..4e3889b 100644
@@ -67,3 +67,6 @@ 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
+alt_edac_mgr-y				:= altera_edac_mgr.o
+obj-$(CONFIG_EDAC_ALTERA_L2C)		+= alt_edac_mgr.o altera_l2_edac.o
+obj-$(CONFIG_EDAC_ALTERA_OCRAM)		+= alt_edac_mgr.o altera_ocram_edac.o
drivers/edac/altera_edac_mgr.c new file +261 -0

261 lines not on this page · raw message

drivers/edac/altera_edac_mgr.h new file +56 -0

56 lines not on this page · raw message

drivers/edac/altera_l2_edac.c new file +130 -0

130 lines not on this page · raw message

drivers/edac/altera_ocram_edac.c new file +107 -0

107 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#4 lore raw

PATCH v2 4/4 arm: dts: Add Altera L2 Cache and OCRAM EDAC

In reply to [email protected]

From: Thor Thayer <[email protected]>

Adding the device tree entries and bindings needed to support the Altera L2 cache and On-Chip RAM EDAC. This patch relies upon an earlier patch to declare and setup On-chip RAM properly.
http://www.spinics.net/lists/devicetree/msg51117.html

---
v2: Remove OCRAM declaration and reference prior patch.

---
 .../bindings/arm/altera/socfpga-l2-edac.txt        |   15 +++++++++++++++
 .../bindings/arm/altera/socfpga-ocram-edac.txt     |   16 ++++++++++++++++
 arch/arm/boot/dts/socfpga.dtsi                     |   15 ++++++++++++++-
 3 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-l2-edac.txt
 create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-ocram-edac.txt
Documentation/devicetree/bindings/arm/altera/socfpga-l2-edac.txt new file +15 -0
new file mode 100644
index 0000000..35b19e3
@@ -0,0 +1,15 @@
+Altera SoCFPGA L2 cache Error Detection and Correction [EDAC]
+
+Required Properties:
+- compatible : Should be "altr,l2-edac"
+- reg : Address and size for ECC error interrupt clear registers.
+- interrupts : Should be single bit error interrupt, then double bit error
+	interrupt. Note the rising edge type.
+
+Example:
+
+	l2edac at ffd08140 {
+		compatible = "altr,l2-edac";
+		reg = <0xffd08140 0x4>;
+		interrupts = <0 36 1>, <0 37 1>;
+	};
Documentation/devicetree/bindings/arm/altera/socfpga-ocram-edac.txt new file +16 -0
new file mode 100644
index 0000000..31ab205
@@ -0,0 +1,16 @@
+Altera SoCFPGA On-Chip RAM Error Detection and Correction [EDAC]
+
+OCRAM ECC Required Properties:
+- compatible : Should be "altr,ocram-edac"
+- reg : Address and size for ECC error interrupt clear registers.
+- iram : phandle to On-Chip RAM definition.
+- interrupts : Should be single bit error interrupt, then double bit error
+	interrupt. Note the rising edge type.
+
+Example:
+	ocramedac at ffd08144 {
+		compatible = "altr,ocram-edac";
+		reg = <0xffd08144 0x4>;
+		iram = <&ocram>;
+		interrupts = <0 178 1>, <0 179 1>;
+	};
arch/arm/boot/dts/socfpga.dtsi +14 -1
index 6af96ed..32c63a3 100644
@@ -618,8 +618,21 @@
 			interrupts = <0 39 4>;
 		};
 
+		l2edac at ffd08140 {
+			compatible = "altr,l2-edac";
+			reg = <0xffd08140 0x4>;
+			interrupts = <0 36 1>, <0 37 1>;
+		};
+
+		ocramedac at ffd08144 {
+			compatible = "altr,ocram-edac";
+			reg = <0xffd08144 0x4>;
+			iram = <&ocram>;
+			interrupts = <0 178 1>, <0 179 1>;
+		};
+
 		L2: l2-cache at fffef000 {
-			compatible = "arm,pl310-cache";
+			compatible = "arm,pl310-cache", "syscon";
 			reg = <0xfffef000 0x1000>;
 			interrupts = <0 38 0x04>;
 			cache-unified;
Signature · 1 line
1.7.9.5
#5 lore raw
In reply to [email protected]

Hi Borislav,

Quoted 29 lines · tthayer at opensource.altera.com

From: Thor Thayer <[email protected]>

This patch adds the L2 cache and OCRAM peripherals to the EDAC framework using the EDAC device framework. The ECC is enabled early in the boot process in the platform specific code.

Thor Thayer (4):
arm: socfpga: Enable L2 Cache ECC on startup.
arm: socfpga: Enable OCRAM ECC on startup.
edac: altera: Add Altera L2 Cache and OCRAM EDAC Support
arm: dts: Add Altera L2 Cache and OCRAM EDAC

  .../bindings/arm/altera/socfpga-l2-edac.txt        |   15 ++
  .../bindings/arm/altera/socfpga-ocram-edac.txt     |   16 ++
  MAINTAINERS                                        |    4 +-
  arch/arm/boot/dts/socfpga.dtsi                     |   15 +-
  arch/arm/mach-socfpga/Makefile                     |    2 +
  arch/arm/mach-socfpga/l2_cache.c                   |   44 ++++
  arch/arm/mach-socfpga/l2_cache.h                   |   28 +++
  arch/arm/mach-socfpga/ocram.c                      |   90 +++++++
  arch/arm/mach-socfpga/ocram.h                      |   28 +++
  arch/arm/mach-socfpga/socfpga.c                    |   13 +-
  drivers/edac/Kconfig                               |   14 ++
  drivers/edac/Makefile                              |    3 +
  drivers/edac/altera_edac_mgr.c                     |  261 ++++++++++++++++++++
  drivers/edac/altera_edac_mgr.h                     |   56 +++++
  drivers/edac/altera_l2_edac.c                      |  130 ++++++++++
  drivers/edac/altera_ocram_edac.c                   |  107 ++++++++
  16 files changed, 823 insertions(+), 3 deletions(-)
Quoted 11 lines

create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-l2-edac.txt create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-ocram-edac.txt create mode 100644 arch/arm/mach-socfpga/l2_cache.c
create mode 100644 arch/arm/mach-socfpga/l2_cache.h
create mode 100644 arch/arm/mach-socfpga/ocram.c
create mode 100644 arch/arm/mach-socfpga/ocram.h
create mode 100644 drivers/edac/altera_edac_mgr.c
create mode 100644 drivers/edac/altera_edac_mgr.h
create mode 100644 drivers/edac/altera_l2_edac.c
create mode 100644 drivers/edac/altera_ocram_edac.c

Do you have any comments about this driver?

Thanks,

Thor

maintainer
#6 lore raw
Quoted 1 line · Thor Thayer

Do you have any comments about this driver?

Just a question: why do you have three .c files for something which does only error injection and nothing else AFAICT? Why isn't this part of altera_edac.c?

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#7 lore raw
Quoted 6 lines · Borislav Petkov
Quoted 1 line · Thor Thayer

Do you have any comments about this driver?

Just a question: why do you have three .c files for something which does only error injection and nothing else AFAICT? Why isn't this part of altera_edac.c?

There are 2 files for doing the error injection (altera_l2_edac.c and altera_ocram_edac.c) and then 1 file for the irq handling and probe (altera_edac_mgr.c).

The L2 cache and the On-Chip RAM drivers were based on the Calxeda L2 cache driver and when written as 2 separate files, the resulting code was very similar from the probe and error handling standpoint so the common code was combined (altera_edac_mgr.c).

The Memory Controller model was used for the SDRAM EDAC (altera_edac.c) since it matches the DIMM model. The MC model didn't seem to fit the discrete memories like OCRAM and L2 cache (these files) so I used the EDAC device model which agreed with the Calxeda L2 cache driver.

Should I move the EDAC Device probe and error handling from altera_edac_mgr.c to altera_edac.c? Can I mix the MC and Device models in the same file?

Thanks for reviewing and for commenting.

Thor

maintainer
#8 lore raw
Quoted 3 lines · Thor Thayer

Should I move the EDAC Device probe and error handling from altera_edac_mgr.c to altera_edac.c? Can I mix the MC and Device models in the same file?

Right, for basic practical reasons, I'd like to keep all functionality pertaining to one hw flavour in one compilation unit/one driver. We can always split them later if a compelling reason emerges.

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#9 lore raw
Quoted 10 lines · Borislav Petkov
Quoted 3 lines · Thor Thayer

Should I move the EDAC Device probe and error handling from altera_edac_mgr.c to altera_edac.c? Can I mix the MC and Device models in the same file?

Right, for basic practical reasons, I'd like to keep all functionality pertaining to one hw flavour in one compilation unit/one driver. We can always split them later if a compelling reason emerges.

Thanks.

OK. I will make the changes.

Would the L2 cache and OCRAM specific functions also be in altera_edac.c? Each of these EDAC pieces is independent and can be compiled in without the others. I've read that the use of #ifdef's is discouraged and having separate files in the Makefile solves that.

Thanks for the clarification.

Thor

maintainer
#10 lore raw
Quoted 4 lines · Thor Thayer

Would the L2 cache and OCRAM specific functions also be in altera_edac.c? Each of these EDAC pieces is independent and can be compiled in without the others. I've read that the use of #ifdef's is discouraged and having separate files in the Makefile solves that.

Let's keep it simple and put all the altera bits in one file for now. If we need to split some of the functionality out, we can always do that later.

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--