Add Altera peripheral memories to EDAC framework
Subsystems (6)
v4 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.
v2 changes:
- Split On-Chip RAM ECC platform initialization into separate patch from L2 ECC platform initialization.
- Fix L2 cache dependency comments.
- Remove OCRAM node from dts and reference prior patch.
v3 changes:
- Move L2 cache & On-Chip RAM EDAC code into altera_edac.c
- Remove SDRAM module compile.
v4 changes:
- Change mask defines to use BIT().
- Fix comment style to agree with kernel coding style.
- Better printk description for read != write in trigger.
- Remove SysFS debugging message.
- Better dci->mod_name
- Move gen_pool pointer assignment to end of function.
- Invert logic to reduce indent in ocram depenency check.
- Change from dev_err() to edac_printk()
- Replace magic numbers with defines & comments.
- Improve error injection test.
- Change Makefile intermediary name to altr (from alt)
Thor Thayer (5):
arm: socfpga: Enable L2 Cache ECC on startup.
arm: socfpga: Enable OCRAM ECC on startup.
edac: altera: Remove SDRAM module compile
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 | 2 + 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 | 18 +- drivers/edac/Makefile | 5 +- drivers/edac/altera_edac.c | 481 +++++++++++++++++++- 13 files changed, 751 insertions(+), 6 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
Signature · 1 line
1.7.9.5
PATCH v4 1/5 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.
v3/4: No change
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v4 2/5 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.
v3/4: No change
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v4 3/5 edac: altera: Remove SDRAM module compile
In reply to [email protected]From: Thor Thayer <[email protected]>
The SDRAM EDAC requires SDRAM configuration/initialization before SDRAM is accessed (in the preloader). Having a module compile is not desired so force to be built into kernel.
---
v3: Added in this version as a separate patch.
v4: No change.
--- drivers/edac/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/edac/Kconfig +2 -2
@@ -377,8 +377,8 @@ config EDAC_OCTEON_PCI Cavium Octeon family of SOCs. config EDAC_ALTERA_MC - tristate "Altera SDRAM Memory Controller EDAC" - depends on EDAC_MM_EDAC && ARCH_SOCFPGA + bool "Altera SDRAM Memory Controller EDAC" + depends on EDAC_MM_EDAC=y && ARCH_SOCFPGA help Support for error detection and correction on the Altera SDRAM memory controller. Note that the
Signature · 1 line
1.7.9.5
PATCH v4 4/5 edac: altera: Add Altera L2 Cache 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 model. The SDRAM controller is using the Memory Controller model.
The SDRAM ECC is a separate Kconfig option because:
1) the SDRAM preparation can take almost 2 seconds on boot and some customers need a faster boot time.
2) the SDRAM has an ECC initialization dependency on the preloader which is outside the kernel. It is desirable to be able to turn the SDRAM on & off separately.
---
v2: Fix L2 dependency comments.
v3: Move OCRAM and L2 cache EDAC functions into altera_edac.c
instead of separate files.
v4: Change mask defines to use BIT().
Fix comment style to agree with kernel coding style. Better printk description for read != write in trigger. Remove SysFS debugging message.
Better dci->mod_name
Move gen_pool pointer assignment to end of function. Invert logic to reduce indent in ocram depenency check. Change from dev_err() to edac_printk()
Replace magic numbers with defines & comments. Improve error injection test.
Change Makefile intermediary name to altr (from alt)
--- drivers/edac/Kconfig | 14 ++ drivers/edac/Makefile | 5 +- drivers/edac/altera_edac.c | 481 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 498 insertions(+), 2 deletions(-)
drivers/edac/Kconfig +14 -0
@@ -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 +4 -1
@@ -66,4 +66,7 @@ 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 +altr_edac-y := altera_edac.o +obj-$(CONFIG_EDAC_ALTERA_MC) += altr_edac.o +obj-$(CONFIG_EDAC_ALTERA_L2C) += altr_edac.o +obj-$(CONFIG_EDAC_ALTERA_OCRAM) += altr_edac.o
drivers/edac/altera_edac.c +480 -1
506 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v4 5/5 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.
v3/4: No Change
--- .../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
@@ -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
@@ -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
@@ -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
Re: [PATCHv4 1/5] arm: socfpga: Enable L2 Cache ECC on startup.
In reply to [email protected]Hi Thor,
Quoted 55 lines · tthayer at opensource.altera.com
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.
Signed-off-by Thor Thayer <[email protected]>---
v2: Split OCRAM initialization into separate patch.v3/4: No change
--- 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.hMAINTAINERS +1
-0@@ -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@@ -4,3 +4,4 @@ obj-y := socfpga.o obj-$(CONFIG_SMP) += headsmp.o platsmp.o +obj-$(CONFIG_EDAC_ALTERA_L2C) += l2_cache.oarch/arm/mach-socfpga/l2_cache.c new file +6
-0@@ -0,0 +1,44 @@ +/* +* 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.
arch/arm/mach-socfpga/l2_cache.c line 16
Quoted 10 lines
arch/arm/mach-socfpga/l2_cache.c new file +10
-0+* +* 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/>. +*/ +#include <linux/clk-provider.h>
Why clk-provider.h and not io.h?
Quoted 18 lines
arch/arm/mach-socfpga/l2_cache.c new file +18
-0+#include <linux/of_platform.h> +#include <linux/of_address.h> + +#include "l2_cache.h" + +void socfpga_init_l2_ecc (void ) +{ +struct device_node *np; +void __iomem *mapped_l2_edac_addr; + + np =of_find_compatible_node (NULL ,NULL ,"altr,l2-edac" ); +if (!np) { +pr_err ("SOCFPGA: Unable to find altr,l2-edac in dtb\n" ); +return ; + } + + mapped_l2_edac_addr =of_iomap (np,0 ); +if (!mapped_l2_edac_addr) {
arch/arm/mach-socfpga/l2_cache.c line 44
Quoted 10 lines
arch/arm/mach-socfpga/l2_cache.c new file +10
-0+pr_err ("SOCFPGA: Unable to find L2 ECC mapping in dtb\n" ); +return ; + } + +/* Enable ECC */ +writel (0x01 , mapped_l2_edac_addr); + +pr_debug ("SOCFPGA: Success Initializing L2 cache ECC\n" ); +} +
Extra line here...
Quoted 39 lines
arch/arm/mach-socfpga/l2_cache.h new file +28
-0@@ -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 +0
-0
arch/arm/mach-socfpga/socfpga.c line 2
Quoted 3 lines
arch/arm/mach-socfpga/socfpga.c +1
-1@@ -1,5 +1,5 @@/* -* Copyright (C) 2012 Altera Corporation +* Copyright (C) 2012;2014 Altera Corporation
Should be "2012-2014".
arch/arm/mach-socfpga/socfpga.c line 29
Quoted 9 lines
arch/arm/mach-socfpga/socfpga.c +2
-0* * 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"
Including ocram.h should go into patch 2/5. But I think ocram.h can be removed as well if you just use IS_ENABLED().
arch/arm/mach-socfpga/socfpga.c static void __init socfpga_init_irq(void) · line 88
Quoted 8 lines
arch/arm/mach-socfpga/socfpga.c +1
-0void __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 ();
If you use "if (IS_ENABLED(CONFIG_EDAC_ALTERA_L2C))", then you can remove l2_cache.h.
Dinh
Re: [PATCHv4 2/5] arm: socfpga: Enable OCRAM ECC on startup.
In reply to [email protected]Hi Thor,
Quoted 28 lines · tthayer at opensource.altera.com
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.
Signed-off-by Thor Thayer <[email protected]>---
v2: Split OCRAM ECC portion separately. Addition ofiounmap()and reorganization ofgen_pool_free. Remove defconfig from patch.v3/4: No change
--- 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.hMAINTAINERS +0
-0
MAINTAINERS M: Thor Thayer <[email protected]> · line 1411
Quoted 4 lines
MAINTAINERS +1
-0@@ -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.*
I think you can remove these entries for l2_cache.c and ocram.c since it already falls under mach-socfpga/, which I already maintain.
Quoted 24 lines
MAINTAINERS +0
-0ARM/STI ARCHITECTURE M: Srinivas Kandagatla <[email protected]>arch/arm/mach-socfpga/Makefile +1
-0@@ -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.oarch/arm/mach-socfpga/ocram.c new file +6
-0@@ -0,0 +1,90 @@ +/* +* 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.
arch/arm/mach-socfpga/ocram.c line 16
Quoted 10 lines
arch/arm/mach-socfpga/ocram.c new file +10
-0+* +* 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/>. +*/ +#include <linux/clk-provider.h>
Why clk-provider.h and not io.h?
Quoted 13 lines
arch/arm/mach-socfpga/ocram.c new file +13
-0+#include <linux/genalloc.h> +#include <linux/of_platform.h> + +#include "ocram.h" + +void socfpga_init_ocram_ecc (void ) +{ +struct device_node *np; +const __be32 *prop; +u32 ocr_edac_addr, iram_addr, len; +void __iomem *mapped_ocr_edac_addr; +size_t size; +struct gen_pool *gp;
arch/arm/mach-socfpga/ocram.c line 39
Quoted 10 lines
arch/arm/mach-socfpga/ocram.c new file +10
-0+ + np =of_find_compatible_node (NULL ,NULL ,"altr,ocram-edac" ); +if (!np) { +pr_err ("SOCFPGA: Unable to find altr,ocram-edac in dtb\n" ); +return ; + } + + prop =of_get_property (np,"reg" , &size); + ocr_edac_addr =be32_to_cpup (prop++); + len =be32_to_cpup (prop);
You should be checking for prop before calling be32_to_cpup.
arch/arm/mach-socfpga/ocram.c line 40
Quoted 1 line
arch/arm/mach-socfpga/ocram.c new file +1
-0+if (!prop || size <sizeof (*prop)) {
Then you don't need check for prop here.
Quoted 9 lines
arch/arm/mach-socfpga/ocram.c new file +9
-0+pr_err ("SOCFPGA: Unable to find OCRAM ECC mapping in dtb\n" ); +return ; + } + + gp =of_get_named_gen_pool (np,"iram" ,0 ); +if (!gp) { +pr_err ("SOCFPGA: OCRAM cannot find gen pool\n" ); +return ; + }
arch/arm/mach-socfpga/ocram.c line 59
Quoted 10 lines
arch/arm/mach-socfpga/ocram.c new file +10
-0+ + np =of_find_compatible_node (NULL ,NULL ,"mmio-sram" ); +if (!np) { +pr_err ("SOCFPGA: Unable to find mmio-sram in dtb\n" ); +return ; + } +/* Determine the OCRAM address and size */ + prop =of_get_property (np,"reg" , &size); + iram_addr =be32_to_cpup (prop++); + len =be32_to_cpup (prop);
Same comment here for checking prop before calling be32_to_cpu.
Quoted 15 lines
arch/arm/mach-socfpga/ocram.c new file +15
-0+ +if (!prop || size <sizeof (*prop)) { +pr_err ("SOCFPGA: Unable to find OCRAM mapping in dtb\n" ); +return ; + } + + iram_addr =gen_pool_alloc (gp, len); +if (iram_addr ==0 ) { +pr_err ("SOCFPGA: cannot alloc from gen pool\n" ); +return ; + } + +memset ((void *)iram_addr,0 , len); + +gen_pool_free (gp, iram_addr, len);
arch/arm/mach-socfpga/ocram.c line 84
Quoted 10 lines
arch/arm/mach-socfpga/ocram.c new file +10
-0+ + mapped_ocr_edac_addr =ioremap (ocr_edac_addr,4 ); +if (!mapped_ocr_edac_addr) { +pr_err ("SOCFPGA: Unable to map OCRAM ecc regs.\n" ); +return ; + } + +/* Clear any pending OCRAM ECC interrupts, then enable ECC */ +writel (0x18 , mapped_ocr_edac_addr); +writel (0x19 , mapped_ocr_edac_addr);
Can you add a define for 0x18 and 0x19? What do these values mean?
Quoted 45 lines
arch/arm/mach-socfpga/ocram.c new file +6
-0+ +iounmap (mapped_ocr_edac_addr); + +pr_debug ("SOCFPGA: Success Initializing OCRAM\n" ); +} +arch/arm/mach-socfpga/ocram.h new file +28
-0@@ -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 +0
-0
arch/arm/mach-socfpga/socfpga.c static void socfpga_cyclone5_restart(enum reboot_mode mode, const char *cmd) · line 108
Quoted 8 lines
arch/arm/mach-socfpga/socfpga.c +5
-0@@ -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 ();
Use IS_ENABLED() here, so you can remove the need to have ocram.h. You can put the function declaration in core.h.
Dinh
Quoted 14 lines
arch/arm/mach-socfpga/socfpga.c +3
-0+} +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
Re: [PATCHv4 1/5] arm: socfpga: Enable L2 Cache ECC on startup.
In reply to Dinh NguyenHi Dinh,
Quoted 166 lines · Dinh Nguyen
Hi Thor,
Quoted 55 lines · On 11/07/2014 10:54 AM, [email protected] wrote:
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.
Signed-off-by Thor Thayer <[email protected]>---
v2: Split OCRAM initialization into separate patch.v3/4: No change
--- 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.ccreate mode 100644arch/arm/mach-socfpga/l2_cache.hMAINTAINERS +1
-0@@ -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@@ -4,3 +4,4 @@ obj-y := socfpga.o obj-$(CONFIG_SMP) += headsmp.o platsmp.o +obj-$(CONFIG_EDAC_ALTERA_L2C) += l2_cache.oarch/arm/mach-socfpga/l2_cache.c new file +6
-0@@ -0,0 +1,44 @@ +/* +* 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. arch/arm/mach-socfpga/l2_cache.c line 16
Quoted 10 lines
arch/arm/mach-socfpga/l2_cache.c new file +10
-0+* +* 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/>. +*/ +#include <linux/clk-provider.h> Why
clk-provider.hand notio.h?Quoted 18 lines
arch/arm/mach-socfpga/l2_cache.c new file +18
-0+#include <linux/of_platform.h> +#include <linux/of_address.h> + +#include "l2_cache.h" + +void socfpga_init_l2_ecc (void ) +{ +struct device_node *np; +void __iomem *mapped_l2_edac_addr; + + np =of_find_compatible_node (NULL ,NULL ,"altr,l2-edac" ); +if (!np) { +pr_err ("SOCFPGA: Unable to find altr,l2-edac in dtb\n" ); +return ; + } + + mapped_l2_edac_addr =of_iomap (np,0 ); +if (!mapped_l2_edac_addr) {arch/arm/mach-socfpga/l2_cache.c line 44
Quoted 10 lines
arch/arm/mach-socfpga/l2_cache.c new file +10
-0+pr_err ("SOCFPGA: Unable to find L2 ECC mapping in dtb\n" ); +return ; + } + +/* Enable ECC */ +writel (0x01 , mapped_l2_edac_addr); + +pr_debug ("SOCFPGA: Success Initializing L2 cache ECC\n" ); +} +Extra line here...
Quoted 39 lines
arch/arm/mach-socfpga/l2_cache.h new file +28
-0@@ -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 +0
-0arch/arm/mach-socfpga/socfpga.c line 2
Quoted 3 lines
arch/arm/mach-socfpga/socfpga.c +1
-1@@ -1,5 +1,5 @@/* -* Copyright (C) 2012 Altera Corporation +* Copyright (C) 2012;2014 Altera Corporation Should be "2012-2014".
arch/arm/mach-socfpga/socfpga.c line 29
Quoted 9 lines
arch/arm/mach-socfpga/socfpga.c +2
-0* * 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" Including
ocram.hshould go into patch 2/5. But I thinkocram.hcan be removed as well if you just useIS_ENABLED().arch/arm/mach-socfpga/socfpga.c static void __init socfpga_init_irq(void) · line 88
Quoted 8 lines
arch/arm/mach-socfpga/socfpga.c +1
-0void __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 ();If you use "if (
IS_ENABLED(CONFIG_EDAC_ALTERA_L2C))", then you can removel2_cache.h.
Quoted 3 lines
Dinh
Yes, this is cleaner. I will make these changes. Thanks!
Re: [PATCHv4 2/5] arm: socfpga: Enable OCRAM ECC on startup.
In reply to Dinh NguyenHi Dinh,
Quoted 26 lines · Dinh Nguyen
Hi Thor,
Quoted 23 lines · On 11/07/2014 10:54 AM, [email protected] wrote:
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.
Signed-off-by Thor Thayer <[email protected]>---
v2: Split OCRAM ECC portion separately. Addition ofiounmap()and reorganization ofgen_pool_free. Remove defconfig from patch.v3/4: No change
--- 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.ccreate mode 100644arch/arm/mach-socfpga/ocram.h
Quoted 11 lines
MAINTAINERS M: Thor Thayer <[email protected]> · line 1411
Quoted 9 lines
MAINTAINERS +1
-0@@ -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.*I think you can remove these entries for
l2_cache.candocram.csince it already falls under mach-socfpga/, which I already maintain.
Thanks. I will remove them.
Quoted 27 lines
Quoted 27 lines
MAINTAINERS +0
-0ARM/STI ARCHITECTURE M: Srinivas Kandagatla <[email protected]>arch/arm/mach-socfpga/Makefile +1
-0@@ -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.oarch/arm/mach-socfpga/ocram.c new file +9
-0@@ -0,0 +1,90 @@ +/* +* 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
Quoted 8 lines
arch/arm/mach-socfpga/ocram.c line 16
Quoted 7 lines
arch/arm/mach-socfpga/ocram.c new file +7
-0+* 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/>. +*/ +#include <linux/clk-provider.h> Why
clk-provider.hand notio.h?
I will change to io.h.
Quoted 40 lines
Quoted 13 lines
arch/arm/mach-socfpga/ocram.c new file +13
-0+#include <linux/genalloc.h> +#include <linux/of_platform.h> + +#include "ocram.h" + +void socfpga_init_ocram_ecc (void ) +{ +struct device_node *np; +const __be32 *prop; +u32 ocr_edac_addr, iram_addr, len; +void __iomem *mapped_ocr_edac_addr; +size_t size; +struct gen_pool *gp;arch/arm/mach-socfpga/ocram.c line 39
Quoted 10 lines
arch/arm/mach-socfpga/ocram.c new file +10
-0+ + np =of_find_compatible_node (NULL ,NULL ,"altr,ocram-edac" ); +if (!np) { +pr_err ("SOCFPGA: Unable to find altr,ocram-edac in dtb\n" ); +return ; + } + + prop =of_get_property (np,"reg" , &size); + ocr_edac_addr =be32_to_cpup (prop++); + len =be32_to_cpup (prop);You should be checking for prop before calling
be32_to_cpup.arch/arm/mach-socfpga/ocram.c line 40
Quoted 1 line
arch/arm/mach-socfpga/ocram.c new file +1
-0+if (!prop || size <sizeof (*prop)) {Then you don't need check for prop here.
Quoted 12 lines
arch/arm/mach-socfpga/ocram.c new file +12
-0+pr_err ("SOCFPGA: Unable to find OCRAM ECC mapping in dtb\n" ); +return ; + } + + gp =of_get_named_gen_pool (np,"iram" ,0 ); +if (!gp) { +pr_err ("SOCFPGA: OCRAM cannot find gen pool\n" ); +return ; + } + + np =of_find_compatible_node (NULL ,NULL ,"mmio-sram" ); +if (!np) {
Quoted 8 lines
arch/arm/mach-socfpga/ocram.c line 59
Quoted 7 lines
arch/arm/mach-socfpga/ocram.c new file +7
-0+pr_err ("SOCFPGA: Unable to find mmio-sram in dtb\n" ); +return ; + } +/* Determine the OCRAM address and size */ + prop =of_get_property (np,"reg" , &size); + iram_addr =be32_to_cpup (prop++); + len =be32_to_cpup (prop);Same comment here for checking prop before calling
be32_to_cpu.
Good catch. Thanks.
Quoted 18 lines
Quoted 18 lines
arch/arm/mach-socfpga/ocram.c new file +18
-0+ +if (!prop || size <sizeof (*prop)) { +pr_err ("SOCFPGA: Unable to find OCRAM mapping in dtb\n" ); +return ; + } + + iram_addr =gen_pool_alloc (gp, len); +if (iram_addr ==0 ) { +pr_err ("SOCFPGA: cannot alloc from gen pool\n" ); +return ; + } + +memset ((void *)iram_addr,0 , len); + +gen_pool_free (gp, iram_addr, len); + + mapped_ocr_edac_addr =ioremap (ocr_edac_addr,4 ); +if (!mapped_ocr_edac_addr) {
Quoted 8 lines
arch/arm/mach-socfpga/ocram.c line 84
Quoted 7 lines
arch/arm/mach-socfpga/ocram.c new file +7
-0+pr_err ("SOCFPGA: Unable to map OCRAM ecc regs.\n" ); +return ; + } + +/* Clear any pending OCRAM ECC interrupts, then enable ECC */ +writel (0x18 , mapped_ocr_edac_addr); +writel (0x19 , mapped_ocr_edac_addr);Can you add a define for
0x18and0x19? What do these values mean?
Sure.
Quoted 56 lines
Quoted 45 lines
arch/arm/mach-socfpga/ocram.c new file +6
-0+ +iounmap (mapped_ocr_edac_addr); + +pr_debug ("SOCFPGA: Success Initializing OCRAM\n" ); +} +arch/arm/mach-socfpga/ocram.h new file +28
-0@@ -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 +0
-0arch/arm/mach-socfpga/socfpga.c static void socfpga_cyclone5_restart(enum reboot_mode mode, const char *cmd) · line 108
Quoted 8 lines
arch/arm/mach-socfpga/socfpga.c +5
-0@@ -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 ();Use
IS_ENABLED()here, so you can remove the need to haveocram.h. You can put the function declaration incore.h.
Quoted 1 line
Dinh
I will make the changes. Thanks!
Quoted 15 lines
Quoted 15 lines
arch/arm/mach-socfpga/socfpga.c +3
-0+} +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