EDAC, altera: Add Altera L2 Cache and OCRAM EDAC Support
Subsystems (6)
PATCH v9 1/4 EDAC, altera: Add Altera L2 Cache and OCRAM EDAC Support
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.
Each type of ECC is individually configurable.
---
v9: Improve device tree node release. Free managed resources
on error path. Fix ocram memory leak.
v8: Remove MASK from single bit mask names.
s/altr,edac/altr,socfpga-ecc-manager
Use debugfs instead of sysfs.
Add chip family name to match string.
Fix header year.
Fix build dependencies & change commit accordingly. s/CONFIG_EDAC_ALTERA_MC/CONFIG_EDAC_ALTERA
v7: s/of_get_named_gen_pool/of_gen_pool_get
Remove #ifdef for EDAC_DEBUG
Use -ENODEV instead of EPROBE_DEFER
v6: Convert to nested EDAC in device tree. Force L2 cache
on for L2Cache ECC & remove L2 cache syscon for checking enable bit. Update year in header.
v5: No change.
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)
v3: Move OCRAM and L2 cache EDAC functions into altera_edac.c
instead of separate files.
v2: Fix L2 dependency comments.
--- drivers/edac/Kconfig | 26 ++- drivers/edac/Makefile | 2 +- drivers/edac/altera_edac.c | 487 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 507 insertions(+), 8 deletions(-)
drivers/edac/Kconfig +21 -5
@@ -367,14 +367,30 @@ 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" +config EDAC_ALTERA + bool "Altera SOCFPGA ECC" depends on EDAC_MM_EDAC=y && 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. + Altera SOCs. This must be selected for SDRAM ECC. + Note that the preloader must initialize the SDRAM + before loading the kernel. + +config EDAC_ALTERA_L2C + bool "Altera L2 Cache ECC" + depends on EDAC_ALTERA=y + select CACHE_L2X0 + help + Support for error detection and correction on the + Altera L2 cache Memory for Altera SoCs. This option + requires L2 cache so it will force that selection. + +config EDAC_ALTERA_OCRAM + bool "Altera On-Chip RAM ECC" + depends on EDAC_ALTERA=y && SRAM && GENERIC_ALLOCATOR + help + Support for error detection and correction on the + Altera On-Chip RAM Memory for Altera SoCs. config EDAC_SYNOPSYS tristate "Synopsys DDR Memory Controller"
drivers/edac/Makefile +1 -1
@@ -67,6 +67,6 @@ 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 +obj-$(CONFIG_EDAC_ALTERA) += altera_edac.o obj-$(CONFIG_EDAC_SYNOPSYS) += synopsys_edac.o obj-$(CONFIG_EDAC_XGENE) += xgene_edac.o
drivers/edac/altera_edac.c +485 -2
516 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v9 2/4 ARM: dts: Add Altera L2 Cache and OCRAM EDAC entries
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
---
v9: Remove 0x from ecc-manager in bindings and dts.
v8: Fix node names to include chip family and use ecc manager
to better describe the driver. Rename socfpga-edac.txt to socfpga-eccmgr.txt.
v7: No Change
v6: Change to nested EDAC device nodes based on community
feedback. Remove L2 syscon. Use consolidated binding.
v3-5: No Change
v2: Remove OCRAM declaration and reference prior patch.
--- .../bindings/arm/altera/socfpga-eccmgr.txt | 49 ++++++++++++++++++++ arch/arm/boot/dts/socfpga.dtsi | 20 ++++++++ 2 files changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-eccmgr.txt
Documentation/devicetree/bindings/arm/altera/socfpga-eccmgr.txt new file +49 -0
@@ -0,0 +1,49 @@ +Altera SoCFPGA ECC Manager +This driver uses the EDAC framework to implement the SOCFPGA ECC Manager. +The ECC Manager counts and corrects single bit errors and counts/handles +double bit errors which are uncorrectable. + +Required Properties: +- compatible : Should be "altr,socfpga-ecc-manager" +- #address-cells: must be 1 +- #size-cells: must be 1 +- ranges : standard definition, should translate from local addresses + +Subcomponents: + +L2 Cache ECC +Required Properties: +- compatible : Should be "altr,socfpga-l2-ecc" +- 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. + +On Chip RAM ECC +Required Properties: +- compatible : Should be "altr,socfpga-ocram-ecc" +- 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: + + eccmgr: eccmgr@ffd08140 { + compatible = "altr,socfpga-ecc-manager"; + #address-cells = <1>; + #size-cells = <1>; + ranges; + + l2-ecc@ffd08140 { + compatible = "altr,socfpga-l2-ecc"; + reg = <0xffd08140 0x4>; + interrupts = <0 36 1>, <0 37 1>; + }; + + ocram-ecc@ffd08144 { + compatible = "altr,socfpga-ocram-ecc"; + reg = <0xffd08144 0x4>; + iram = <&ocram>; + interrupts = <0 178 1>, <0 179 1>; + }; + };
arch/arm/boot/dts/socfpga.dtsi +20 -0
@@ -656,6 +656,26 @@ status = "disabled"; }; + eccmgr: eccmgr@ffd08140 { + compatible = "altr,socfpga-ecc-manager"; + #address-cells = <1>; + #size-cells = <1>; + ranges; + + l2-ecc@ffd08140 { + compatible = "altr,socfpga-l2-ecc"; + reg = <0xffd08140 0x4>; + interrupts = <0 36 1>, <0 37 1>; + }; + + ocram-ecc@ffd08144 { + compatible = "altr,socfpga-ocram-ecc"; + reg = <0xffd08144 0x4>; + iram = <&ocram>; + interrupts = <0 178 1>, <0 179 1>; + }; + }; + L2: l2-cache@fffef000 { compatible = "arm,pl310-cache"; reg = <0xfffef000 0x1000>;
Signature · 1 line
1.7.9.5
PATCH v9 4/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 stored in memory otherwise the ECC will fail on reads.
---
v9: Improve node release handling.
v8: Address community comments on strings. Fix match strings based
on maintainer feedback. Update year in header.
v7: enable OCRAM ECC during platform init
v6: Implement OCRAM discovery changes from community. Add
of_node_put(). Remove be32_to_cpup(). Use __init() which allows removal of .init_machine(). Update year in header.
--- arch/arm/mach-socfpga/Makefile | 1 + arch/arm/mach-socfpga/core.h | 1 + arch/arm/mach-socfpga/ocram.c | 49 +++++++++++++++++++++++++++++++++++++++ arch/arm/mach-socfpga/socfpga.c | 3 +++ 4 files changed, 54 insertions(+) create mode 100644 arch/arm/mach-socfpga/ocram.c
arch/arm/mach-socfpga/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-y := socfpga.o obj-$(CONFIG_SMP) += headsmp.o platsmp.o obj-$(CONFIG_SOCFPGA_SUSPEND) += pm.o self-refresh.o obj-$(CONFIG_EDAC_ALTERA_L2C) += l2_cache.o +obj-$(CONFIG_EDAC_ALTERA_OCRAM) += ocram.o
arch/arm/mach-socfpga/core.h +1 -0
@@ -37,6 +37,7 @@extern void socfpga_init_clocks (void );extern void socfpga_sysmgr_init (void );void socfpga_init_l2_ecc (void ); +void socfpga_init_ocram_ecc (void );extern void __iomem *sys_manager_base_addr;extern void __iomem *rst_manager_base_addr;
arch/arm/mach-socfpga/ocram.c new file +49 -0
49 lines not on this page · raw message
arch/arm/mach-socfpga/socfpga.c +3 -0
@@ -61,6 +61,9 @@ static void __init socfpga_init_irq(void)socfpga_sysmgr_init ();if (IS_ENABLED (CONFIG_EDAC_ALTERA_L2C ))socfpga_init_l2_ecc (); + +if (IS_ENABLED (CONFIG_EDAC_ALTERA_OCRAM )) +socfpga_init_ocram_ecc (); }static void socfpga_cyclone5_restart (enum reboot_mode mode,const char *cmd)
Signature · 1 line
1.7.9.5
PATCH v9 3/4 ARM: socfpga: enable L2 cache ECC on startup
In reply to [email protected]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 stored in memory otherwise the ECC will fail on reads.
---
v9: Improve node put handling.
v8: Address community suggestions for strings. Fix string based on
maintainer feedback. Update year in header.
v7: unmap locally scoped mapped_l2_edac_addr and add of_node_put(np)
v6: Remove pr_debug() & update year in header.
--- arch/arm/mach-socfpga/Makefile | 1 + arch/arm/mach-socfpga/core.h | 1 + arch/arm/mach-socfpga/l2_cache.c | 41 ++++++++++++++++++++++++++++++++++++++ arch/arm/mach-socfpga/socfpga.c | 2 ++ 4 files changed, 45 insertions(+) create mode 100644 arch/arm/mach-socfpga/l2_cache.c
arch/arm/mach-socfpga/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-y := socfpga.o obj-$(CONFIG_SMP) += headsmp.o platsmp.o obj-$(CONFIG_SOCFPGA_SUSPEND) += pm.o self-refresh.o +obj-$(CONFIG_EDAC_ALTERA_L2C) += l2_cache.o
arch/arm/mach-socfpga/core.h +1 -0
@@ -36,6 +36,7 @@extern void socfpga_init_clocks (void );extern void socfpga_sysmgr_init (void ); +void socfpga_init_l2_ecc (void );extern void __iomem *sys_manager_base_addr;extern void __iomem *rst_manager_base_addr;
arch/arm/mach-socfpga/l2_cache.c new file +41 -0
41 lines not on this page · raw message
arch/arm/mach-socfpga/socfpga.c +2 -0
@@ -59,6 +59,8 @@ static void __init socfpga_init_irq(void) {irqchip_init ();socfpga_sysmgr_init (); +if (IS_ENABLED (CONFIG_EDAC_ALTERA_L2C )) +socfpga_init_l2_ecc (); }static void socfpga_cyclone5_restart (enum reboot_mode mode,const char *cmd)
Signature · 1 line
1.7.9.5
Borislav Petkov
maintainerQuoted 40 lines · tthayer at opensource.altera.com
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.
Each type of ECC is individually configurable.
Signed-off-by Thor Thayer <[email protected]>---
v9: Improve device tree node release. Free managed resources
on error path. Fix ocram memory leak.
v8: Remove MASK from single bit mask names.
s/altr,edac/altr,socfpga-ecc-manager
Use debugfs instead of sysfs.
Add chip family name to match string.
Fix header year.
Fix build dependencies & change commit accordingly. s/CONFIG_EDAC_ALTERA_MC/CONFIG_EDAC_ALTERA
v7: s/of_get_named_gen_pool/of_gen_pool_get
Remove #ifdef forEDAC_DEBUG
Use-ENODEVinstead ofEPROBE_DEFER
v6: Convert to nested EDAC in device tree. Force L2 cache
on for L2Cache ECC & remove L2 cache syscon for checking enable bit. Update year in header.
v5: No change.
v4: Change mask defines to useBIT().
Fix comment style to agree with kernel coding style. Better printk description for read != write in trigger. Remove SysFS debugging message.
Betterdci->mod_name
Movegen_poolpointer assignment to end of function. Invert logic to reduce indent in ocram depenency check. Change fromdev_err()toedac_printk()
Replace magic numbers with defines & comments. Improve error injection test.
ChangeMakefileintermediary name to altr (from alt)
v3: Move OCRAM and L2 cache EDAC functions intoaltera_edac.c
instead of separate files.
v2: Fix L2 dependency comments.
Quoted 5 lines
--- drivers/edac/Kconfig | 26 ++- drivers/edac/Makefile | 2 +- drivers/edac/altera_edac.c | 487 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 507 insertions(+), 8 deletions(-)
I'm still waiting for the people on CC to confirm the DT changes. A couple of comments on the EDAC bits below.
....
Quoted 7 lines
drivers/edac/altera_edac.c +7
-0+static irqreturn_t altr_edac_device_handler (int irq,void *dev_id) +{ +struct edac_device_ctl_info *dci = dev_id; +struct altr_edac_device_dev *drvdata = dci->pvt_info; +const struct edac_device_prv_data *priv = drvdata->data; + +if (irq == drvdata->sb_irq) {
drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 612
Quoted 10 lines
drivers/edac/altera_edac.c +10
-0+if (priv->ce_clear_mask) +writel (priv->ce_clear_mask, drvdata->base); +edac_device_handle_ce (dci,0 ,0 , drvdata->edac_dev_name); + } +if (irq == drvdata->db_irq) { +if (priv->ue_clear_mask) +writel (priv->ue_clear_mask, drvdata->base); +edac_device_handle_ue (dci,0 ,0 , drvdata->edac_dev_name); +panic ("\nEDAC:ECC_DEVICE[Uncorrectable errors]\n" ); + }
And irq is guaranteed to always be ->sb_irq or ->db_irq?
Otherwise, you can do
else WARN_ON(1);
just in case.
Quoted 3 lines
drivers/edac/altera_edac.c +3
-0+ +return IRQ_HANDLED ; +}
...
Quoted 83 lines
drivers/edac/altera_edac.c +83
-0+/* +* altr_edac_device_probe() +* This is a generic EDAC device driver that will support +* various Altera memory devices such as the L2 cache ECC and +* OCRAM ECC as well as the memories for other peripherals. +* Module specific initialization is done by passing the +* function index in the device tree. +*/ +static int altr_edac_device_probe (struct platform_device *pdev) +{ +struct edac_device_ctl_info *dci; +struct altr_edac_device_dev *drvdata; +struct resource *r; +int res =0 ; +struct device_node *np = pdev->dev.of_node; +char *ecc_name = (char *)np->name; +static int dev_instance; +struct dentry *debugfs; + +if (!devres_open_group (&pdev->dev,NULL ,GFP_KERNEL )) { +edac_printk (KERN_ERR ,EDAC_DEVICE , +"Unable to open devm\n" ); +return -ENOMEM ; + } + + r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!r) { +edac_printk (KERN_ERR ,EDAC_DEVICE , +"Unable to get mem resource\n" ); + res = -ENODEV ; + goto fail; + } + +if (!devm_request_mem_region (&pdev->dev, r->start,resource_size (r), +dev_name (&pdev->dev))) { +edac_printk (KERN_ERR ,EDAC_DEVICE , +"%s:Error requesting mem region\n" , ecc_name); + res = -EBUSY ; + goto fail; + } + + dci =edac_device_alloc_ctl_info (sizeof (*drvdata), ecc_name, +1 , ecc_name,1 ,0 ,NULL ,0 , + dev_instance++); + +if (!dci) { +edac_printk (KERN_ERR ,EDAC_DEVICE , +"%s: Unable to allocate EDAC device\n" , ecc_name); + res = -ENOMEM ; + goto fail; + } + + drvdata = dci->pvt_info; + dci->dev = &pdev->dev; +platform_set_drvdata (pdev, dci); + drvdata->edac_dev_name = ecc_name; + + drvdata->base =devm_ioremap (&pdev->dev, r->start,resource_size (r)); +if (!drvdata->base) + goto fail1; + +/* Get driver specific data for this EDAC device */ + drvdata->data =of_match_node (altr_edac_device_of_match, np)->data; + +/* Check specific dependencies for the module */ +if (drvdata->data->setup) { + res = drvdata->data->setup (pdev, drvdata->base); +if (res <0 ) + goto fail1; + } + + drvdata->sb_irq =platform_get_irq (pdev,0 ); + res =devm_request_irq (&pdev->dev, drvdata->sb_irq, + altr_edac_device_handler, +0 ,dev_name (&pdev->dev), dci); +if (res <0 ) + goto fail1; + + drvdata->db_irq =platform_get_irq (pdev,1 ); + res =devm_request_irq (&pdev->dev, drvdata->db_irq, + altr_edac_device_handler, +0 ,dev_name (&pdev->dev), dci); +if (res <0 )
drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 809
Quoted 10 lines
drivers/edac/altera_edac.c +10
-0+ goto fail1; + + dci->mod_name ="Altera ECC Manager" ; + dci->dev_name = drvdata->edac_dev_name; + + debugfs =edac_debugfs_create_dir (ecc_name); +if (debugfs) +altr_create_edacdev_dbgfs (dci, drvdata->data, debugfs); + +if (edac_device_add_device (dci))
<--- if you end up here and debugfs nodes have been created, you need to destroy them here. You probably could change edac_debugfs_exit() to call debugfs_remove_recursive() and make sure your driver calls it.
Right now we're calling edac_debugfs_exit() in edac_exit() and I *think* that is ok for a platform device driver as this one but I haven't actually *verified* that.
Quoted 53 lines
drivers/edac/altera_edac.c +53
-0+ goto fail1; + +devres_close_group (&pdev->dev,NULL ); + +return 0 ; + +fail1: +edac_device_free_ctl_info (dci); +fail: +devres_release_group (&pdev->dev,NULL ); +edac_printk (KERN_ERR ,EDAC_DEVICE , +"%s:Error setting up EDAC device: %d\n" , ecc_name, res); + +return res; +} + +static int altr_edac_device_remove (struct platform_device *pdev) +{ +struct edac_device_ctl_info *dci =platform_get_drvdata (pdev); + +edac_device_del_device (&pdev->dev); +edac_device_free_ctl_info (dci); + +return 0 ; +} + +static struct platform_driver altr_edac_device_driver = { + .probe = altr_edac_device_probe, + .remove = altr_edac_device_remove, + .driver = { + .name ="altr_edac_device" , + .of_match_table = altr_edac_device_of_match, + }, +}; +module_platform_driver (altr_edac_device_driver); + +/*********************** OCRAM EDAC Device Functions *********************/ + +#ifdef CONFIG_EDAC_ALTERA_OCRAM + +static void *ocram_alloc_mem (size_t size,void **other) +{ +struct device_node *np; +struct gen_pool *gp; +void *sram_addr; + + np =of_find_compatible_node (NULL ,NULL ,"altr,socfpga-ocram-ecc" ); +if (!np) +return NULL ; + + gp =of_gen_pool_get (np,"iram" ,0 ); +of_node_put (np); +if (!gp)
drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 872
Quoted 10 lines
drivers/edac/altera_edac.c +10
-0+return NULL ; + + sram_addr = (void *)gen_pool_alloc (gp, size); +if (!sram_addr) +return NULL ; + +memset (sram_addr,0 , size); +wmb ();/* Ensure data is written out */ + + *other = gp;/* Remember this handle for freeing later */
Please put comments ontop of the line they're referring to. Those side-things are cluttering the code unnecessarily.
Quoted 8 lines
drivers/edac/altera_edac.c +8
-0+ +return sram_addr; +} + +static void ocram_free_mem (void *p,size_t size,void *other) +{ +gen_pool_free ((struct gen_pool *)other, (u32 )p, size); +}
drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 890
Quoted 10 lines
drivers/edac/altera_edac.c +10
-0+ +/* +* altr_ocram_dependencies() +* Test for OCRAM cache ECC dependencies upon entry because +* platform specific startup should have initialized the +* On-Chip RAM memory and enabled the ECC. +* Can't turn on ECC here because accessing un-initialized +* memory will cause CE/UE errors possibly causing an ABORT. +*/ +static int altr_ocram_dependencies(struct platform_device *pdev,
A verb in the name?
altr_ocram_test_deps
or
altr_ocram_check_deps
or so?
Quoted 32 lines
drivers/edac/altera_edac.c +32
-0+ void __iomem *base) +{ +u32 control; + + control =readl (base) &ALTR_OCR_ECC_EN ; +if (control) +return 0 ; + +edac_printk (KERN_ERR ,EDAC_DEVICE , +"OCRAM: No ECC present or ECC disabled.\n" ); +return -ENODEV ; +} + +const struct edac_device_prv_data ocramecc_data = { + .setup = altr_ocram_dependencies, + .ce_clear_mask = (ALTR_OCR_ECC_EN |ALTR_OCR_ECC_SERR ), + .ue_clear_mask = (ALTR_OCR_ECC_EN |ALTR_OCR_ECC_DERR ), + .dbgfs_name ="altr_ocram_trigger" , + .alloc_mem = ocram_alloc_mem, + .free_mem = ocram_free_mem, + .ecc_enable_mask =ALTR_OCR_ECC_EN , + .ce_set_mask = (ALTR_OCR_ECC_EN |ALTR_OCR_ECC_INJS ), + .ue_set_mask = (ALTR_OCR_ECC_EN |ALTR_OCR_ECC_INJD ), + .trig_alloc_sz =ALTR_TRIG_OCRAM_BYTE_SIZE , +}; + +#endif /* CONFIG_EDAC_ALTERA_OCRAM */ + +/********************* L2 Cache EDAC Device Functions ********************/ + +#ifdef CONFIG_EDAC_ALTERA_L2C +
drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 932
Quoted 10 lines
drivers/edac/altera_edac.c +10
-0+static void *l2_alloc_mem (size_t size,void **other) +{ +struct device *dev = *other; +void *ptemp =devm_kzalloc (dev, size,GFP_KERNEL ); + +if (!ptemp) +return NULL ; + +/* Make sure everything is written out */ +wmb ();
See, it reads much better with the comment ontop. :)
Quoted 18 lines
drivers/edac/altera_edac.c +18
-0+ +/* +* Clean all cache levels up to LoC (includes L2) +* This ensures the corrupted data is written into +* L2 cache for readback test (which causes ECC error). +*/ +flush_cache_all (); + +return ptemp; +} + +static void l2_free_mem (void *p,size_t size,void *other) +{ +struct device *dev = other; + +if (dev && p) +devm_kfree (dev, p); +}
drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 960
Quoted 10 lines
drivers/edac/altera_edac.c +10
-0+ +/* +* altr_l2_dependencies() +* Test for L2 cache ECC dependencies upon entry because +* platform specific startup should have initialized the L2 +* memory and enabled the ECC. +* Bail if ECC is not enabled. +* Note that L2 Cache Enable is forced at build time. +*/ +static int altr_l2_dependencies(struct platform_device *pdev,
Here too, pls add a verb in the function name.
Quoted 13 lines
drivers/edac/altera_edac.c +13
-0+ void __iomem *base) +{ +u32 control; + + control =readl (base) &ALTR_L2_ECC_EN ; +if (!control) { +edac_printk (KERN_ERR ,EDAC_DEVICE , +"L2: No ECC present, or ECC disabled\n" ); +return -ENODEV ; + } + +return 0 ; +}
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Hi Boris.
Quoted 47 lines · Borislav Petkov
Quoted 40 lines · On Wed, Jan 27, 2016 at 10:13:20AM -0600, [email protected] wrote:
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.
Each type of ECC is individually configurable.
Signed-off-by Thor Thayer <[email protected]>---
v9: Improve device tree node release. Free managed resources
on error path. Fix ocram memory leak.
v8: Remove MASK from single bit mask names.
s/altr,edac/altr,socfpga-ecc-manager
Use debugfs instead of sysfs.
Add chip family name to match string.
Fix header year.
Fix build dependencies & change commit accordingly. s/CONFIG_EDAC_ALTERA_MC/CONFIG_EDAC_ALTERA
v7: s/of_get_named_gen_pool/of_gen_pool_get
Remove #ifdef forEDAC_DEBUG
Use-ENODEVinstead ofEPROBE_DEFER
v6: Convert to nested EDAC in device tree. Force L2 cache
on for L2Cache ECC & remove L2 cache syscon for checking enable bit. Update year in header.
v5: No change.
v4: Change mask defines to useBIT().
Fix comment style to agree with kernel coding style. Better printk description for read != write in trigger. Remove SysFS debugging message.
Betterdci->mod_name
Movegen_poolpointer assignment to end of function. Invert logic to reduce indent in ocram depenency check. Change fromdev_err()toedac_printk()
Replace magic numbers with defines & comments. Improve error injection test.
ChangeMakefileintermediary name to altr (from alt)
v3: Move OCRAM and L2 cache EDAC functions intoaltera_edac.c
instead of separate files.
v2: Fix L2 dependency comments.Quoted 5 lines
--- drivers/edac/Kconfig | 26 ++- drivers/edac/Makefile | 2 +- drivers/edac/altera_edac.c | 487 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 507 insertions(+), 8 deletions(-)
Quoted 4 lines
I'm still waiting for the people on CC to confirm the DT changes. A couple of comments on the EDAC bits below.
Understood. I did get a conditional ACK from Rob Herring on the DT portion of the patch from the last revision (as long as I made the changes he suggested which I did in this patch). There may be other comments though.
Quoted 23 lines
....
Quoted 7 lines
drivers/edac/altera_edac.c +7
-0+static irqreturn_t altr_edac_device_handler (int irq,void *dev_id) +{ +struct edac_device_ctl_info *dci = dev_id; +struct altr_edac_device_dev *drvdata = dci->pvt_info; +const struct edac_device_prv_data *priv = drvdata->data; + +if (irq == drvdata->sb_irq) {drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 612
Quoted 10 lines
drivers/edac/altera_edac.c +10
-0+if (priv->ce_clear_mask) +writel (priv->ce_clear_mask, drvdata->base); +edac_device_handle_ce (dci,0 ,0 , drvdata->edac_dev_name); + } +if (irq == drvdata->db_irq) { +if (priv->ue_clear_mask) +writel (priv->ue_clear_mask, drvdata->base); +edac_device_handle_ue (dci,0 ,0 , drvdata->edac_dev_name); +panic ("\nEDAC:ECC_DEVICE[Uncorrectable errors]\n" ); + }And irq is guaranteed to always be ->sb_irq or ->db_irq?
Quoted 6 lines
Otherwise, you can do
else WARN_ON(1);just in case.
Those are the only cases of irq but it would be good to be alerted if that is not the case. I will add. Thanks!
Quoted 17 lines
Quoted 4 lines
drivers/edac/altera_edac.c +3
-0+ +return IRQ_HANDLED ; +}...
Quoted 10 lines
drivers/edac/altera_edac.c +10
-0+/* +* altr_edac_device_probe() +* This is a generic EDAC device driver that will support +* various Altera memory devices such as the L2 cache ECC and +* OCRAM ECC as well as the memories for other peripherals. +* Module specific initialization is done by passing the +* function index in the device tree. +*/ +static int altr_edac_device_probe (struct platform_device *pdev) +{
<snip>
Quoted 14 lines
drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 809
Quoted 9 lines
drivers/edac/altera_edac.c +9
-0+ + dci->mod_name ="Altera ECC Manager" ; + dci->dev_name = drvdata->edac_dev_name; + + debugfs =edac_debugfs_create_dir (ecc_name); +if (debugfs) +altr_create_edacdev_dbgfs (dci, drvdata->data, debugfs); + +if (edac_device_add_device (dci))<--- if you end up here and debugfs nodes have been created, you need to destroy them here. You probably could change
edac_debugfs_exit()to calldebugfs_remove_recursive()and make sure your driver calls it.
Quoted 3 lines
Right now we're calling
edac_debugfs_exit()inedac_exit()and I *think* that is ok for a platform device driver as this one but I haven't actually *verified* that.
Yes, thanks. I was using the xgene code as an example but I missed the unregister (although it looks like the xgene's unregister affects sysfs instead of debugfs). I'm also moving the debugfs creation to the end of the probe since it is not critical and avoids an error path if creation fails.
I'll make the debugfs_remove_recursive() change as a separate patch in my next version.
Quoted 4 lines
Quoted 4 lines
drivers/edac/altera_edac.c +3
-0+ goto fail1; + +devres_close_group (&pdev->dev,NULL );
<snip>
Quoted 9 lines
drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 872
Quoted 5 lines
drivers/edac/altera_edac.c +5
-0+ +memset (sram_addr,0 , size); +wmb ();/* Ensure data is written out */ + + *other = gp;/* Remember this handle for freeing later */ Please put comments ontop of the line they're referring to. Those side-things are cluttering the code unnecessarily.
OK.
Quoted 21 lines
Quoted 8 lines
drivers/edac/altera_edac.c +8
-0+ +return sram_addr; +} + +static void ocram_free_mem (void *p,size_t size,void *other) +{ +gen_pool_free ((struct gen_pool *)other, (u32 )p, size); +}drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 890
Quoted 10 lines
drivers/edac/altera_edac.c +10
-0+ +/* +* altr_ocram_dependencies() +* Test for OCRAM cache ECC dependencies upon entry because +* platform specific startup should have initialized the +* On-Chip RAM memory and enabled the ECC. +* Can't turn on ECC here because accessing un-initialized +* memory will cause CE/UE errors possibly causing an ABORT. +*/ +static int altr_ocram_dependencies(struct platform_device *pdev,A verb in the name?
Quoted 7 lines
altr_ocram_test_depsor
altr_ocram_check_depsor so?
OK. Thanks.
Quoted 4 lines
Quoted 4 lines
drivers/edac/altera_edac.c +4
-0+ void __iomem *base) +{ +u32 control; +
<snip>
Quoted 6 lines
Quoted 3 lines
+ * Note that L2 Cache Enable is forced at build time.
+ */
+static int altr_l2_dependencies(structplatform_device*pdev,Here too, pls add a verb in the function name.
OK. Thanks.
Quoted 5 lines
Quoted 5 lines
drivers/edac/altera_edac.c +5
-0+ void __iomem *base) +{ +u32 control; + + control =readl (base) &ALTR_L2_ECC_EN ;
Quoted 9 lines
drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 973
Quoted 8 lines
drivers/edac/altera_edac.c +8
-0+if (!control) { +edac_printk (KERN_ERR ,EDAC_DEVICE , +"L2: No ECC present, or ECC disabled\n" ); +return -ENODEV ; + } + +return 0 ; +}
Thanks for reviewing!
Borislav Petkov
maintainerQuoted 3 lines · Thor Thayer
Understood. I did get a conditional ACK from Rob Herring on the DT portion of the patch from the last revision (as long as I made the changes he suggested which I did in this patch). There may be other comments though.
Ah, and I wasn't precise: there are also arch/arm/mach-socfpga/ changes which I'm going to take through the EDAC tree *only* if ARM people ack them.
And by "ARM people" and from looking at get_maintainer output I mean Dinh and he's on CC ...
Quoted 2 lines
Those are the only cases of irq but it would be good to be alerted if that is not the case. I will add. Thanks!
Yeah, it is a "just in case" thing - it might just as well be too cautious and completely unnecessary so your decision.
Quoted 7 lines
Yes, thanks. I was using the xgene code as an example but I missed the unregister (although it looks like the xgene's unregister affects sysfs instead of debugfs). I'm also moving the debugfs creation to the end of the probe since it is not critical and avoids an error path if creation fails.
I'll make the
debugfs_remove_recursive()change as a separate patch in my next version.
Good, thanks!
Also, if something's not right in drivers/edac/debugfs.c wrt usability and so on, feel free to propose changes. I've extracted it there because I didn't want every driver to reinvent the wheel.
Thanks.
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Re: [PATCHv9 3/4] ARM: socfpga: enable L2 cache ECC on startup
In reply to [email protected]Quoted 13 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 stored in memory otherwise the ECC will fail on reads.
Signed-off-by Thor Thayer <[email protected]>---
v9: Improve node put handling.
v8: Address community suggestions for strings. Fix string based on
maintainer feedback. Update year in header.
v7: unmap locally scopedmapped_l2_edac_addrand addof_node_put(np)
v6: Removepr_debug()& update year in header.
Quoted 8 lines
--- arch/arm/mach-socfpga/Makefile | 1 + arch/arm/mach-socfpga/core.h | 1 + arch/arm/mach-socfpga/l2_cache.c | 41 ++++++++++++++++++++++++++++++++++++++ arch/arm/mach-socfpga/socfpga.c | 2 ++ 4 files changed, 45 insertions(+) create mode 100644 arch/arm/mach-socfpga/l2_cache.c
Re: [PATCHv9 4/4] ARM: socfpga: Enable OCRAM ECC on startup
In reply to [email protected]Quoted 15 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 stored in memory otherwise the ECC will fail on reads.
Signed-off-by Thor Thayer <[email protected]>---
v9: Improve node release handling.
v8: Address community comments on strings. Fix match strings based
on maintainer feedback. Update year in header.
v7: enable OCRAM ECC during platform init
v6: Implement OCRAM discovery changes from community. Add
of_node_put(). Removebe32_to_cpup(). Use__init()which allows removal of .init_machine(). Update year in header.
Quoted 8 lines
--- arch/arm/mach-socfpga/Makefile | 1 + arch/arm/mach-socfpga/core.h | 1 + arch/arm/mach-socfpga/ocram.c | 49 +++++++++++++++++++++++++++++++++++++++ arch/arm/mach-socfpga/socfpga.c | 3 +++ 4 files changed, 54 insertions(+) create mode 100644 arch/arm/mach-socfpga/ocram.c