EDAC, altera: Add Altera L2 Cache and OCRAM EDAC Support
Subsystems (2)
PATCH v7 1/1 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.
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.
---
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 | 16 ++ drivers/edac/Makefile | 5 +- drivers/edac/altera_edac.c | 488 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 507 insertions(+), 2 deletions(-)
drivers/edac/Kconfig +16 -0
@@ -376,6 +376,22 @@ 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 + 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 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. + config EDAC_SYNOPSYS tristate "Synopsys DDR Memory Controller" depends on EDAC_MM_EDAC && ARCH_ZYNQ
drivers/edac/Makefile +4 -1
@@ -67,6 +67,9 @@ 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 obj-$(CONFIG_EDAC_SYNOPSYS) += synopsys_edac.o obj-$(CONFIG_EDAC_XGENE) += xgene_edac.o
drivers/edac/altera_edac.c +487 -1
513 lines not on this page · raw message
Signature · 1 line
2.4.5
Borislav Petkov
maintainerQuoted 82 lines · On Tue, Oct 27, 2015 at 03:38:12PM -0500, [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.
The SDRAM ECC is a separate
Kconfigoption 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.Signed-off-by Thor Thayer <[email protected]>Signed-off-by Dinh Nguyen <[email protected]>---
v7: s/of_get_named_gen_pool/of_gen_pool_get
Remove #ifdef forEDAC_DEBUG
Use-ENODEVinstead ofEPROBE_DEFERv6: 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.
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 into
altera_edac.c
instead of separate files.v2: Fix L2 dependency comments.
--- drivers/edac/Kconfig | 16 ++ drivers/edac/Makefile | 5 +- drivers/edac/altera_edac.c | 488 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 507 insertions(+), 2 deletions(-)drivers/edac/Kconfig +16
-0@@ -376,6 +376,22 @@ 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 + 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 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. + config EDAC_SYNOPSYS tristate "Synopsys DDR Memory Controller" depends on EDAC_MM_EDAC && ARCH_ZYNQdrivers/edac/Makefile +0
-0
drivers/edac/Makefile obj-$(CONFIG_EDAC_OCTEON_L2C) += octeon_edac-l2c.o · line 73
Quoted 8 lines
drivers/edac/Makefile +4
-1@@ -67,6 +67,9 @@ 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
What are those supposed to accomplish?
Quoted 18 lines
drivers/edac/Makefile +0
-0obj-$(CONFIG_EDAC_SYNOPSYS) += synopsys_edac.o obj-$(CONFIG_EDAC_XGENE) += xgene_edac.odrivers/edac/altera_edac.c +2
-0@@ -17,8 +17,10 @@* Adapted from the highbank_mc_edac driver. */ +#include <asm/cacheflush.h> #include <linux/ctype.h> #include <linux/edac.h> +#include <linux/genalloc.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/mfd/syscon.h>
drivers/edac/altera_edac.c line 39
Quoted 4 lines
drivers/edac/altera_edac.c +1
-0@@ -34,6 +36,7 @@#define EDAC_MOD_STR "altera_edac"#define EDAC_VERSION "1" +#define EDAC_DEVICE "ALTR_MEM"
Let's simply call it "Altera" - it is more human-friendly.
Quoted 11 lines
drivers/edac/altera_edac.c +5
-0static const struct altr_sdram_prv_data c5_data = { .ecc_ctrl_offset =CV_CTLCFG_OFST ,@@ -75,6 +78,33 @@ static const struct altr_sdram_prv_data a10_data = { .ue_set_mask = A10_DIAGINT_TDERRA_MASK, }; +/************************** EDAC Device Defines **************************/ + +/* OCRAM ECC Management Group Defines */ +#define ALTR_MAN_GRP_OCRAM_ECC_OFFSET 0x04 +#define ALTR_OCR_ECC_EN_MASK BIT(0)
drivers/edac/altera_edac.c static const struct altr_sdram_prv_data a10_data = { · line 95
Quoted 10 lines
drivers/edac/altera_edac.c +10
-0+#define ALTR_OCR_ECC_INJS_MASK BIT(1) +#define ALTR_OCR_ECC_INJD_MASK BIT(2) +#define ALTR_OCR_ECC_SERR_MASK BIT(3) +#define ALTR_OCR_ECC_DERR_MASK BIT(4) + +/* L2 ECC Management Group Defines */ +#define ALTR_MAN_GRP_L2_ECC_OFFSET 0x00 +#define ALTR_L2_ECC_EN_MASK BIT(0) +#define ALTR_L2_ECC_INJS_MASK BIT(1) +#define ALTR_L2_ECC_INJD_MASK BIT(2)
Single bit masks? You don't need to call them "_MASK" - simply remove it.
Quoted 15 lines
drivers/edac/altera_edac.c +11
-0+#define ALTR_UE_TRIGGER_CHAR 'U'/* Trigger for UE */ +#define ALTR_TRIGGER_READ_WRD_CNT 32/* Line size x 4 */ +#define ALTR_TRIG_OCRAM_BYTE_SIZE 128/* Line size x 4 */ +#define ALTR_TRIG_L2C_BYTE_SIZE 4096/* Full Page */ + +/*********************** EDAC Memory Controller Functions ****************/ + +/* The SDRAM controller uses the EDAC Memory Controller framework. */ + +#ifdef CONFIG_EDAC_ALTERA_MC +static irqreturn_t altr_sdram_mc_err_handler (int irq,void *dev_id) {struct mem_ctl_info *mci = dev_id;
drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 537
Quoted 4 lines
drivers/edac/altera_edac.c +1
-0@@ -504,6 +534,462 @@ static struct platform_driver altr_sdram_edac_driver = {module_platform_driver (altr_sdram_edac_driver); +#endif /* #ifdef CONFIG_EDAC_ALTERA_MC */
#endif /* CONFIG_EDAC_ALTERA_MC */
is the usual syntax for those.
Quoted 15 lines
drivers/edac/altera_edac.c +15
-0+/************************* EDAC Parent Probe *************************/ + +static const struct of_device_id altr_edac_device_of_match[]; + +static const struct of_device_id altr_edac_of_match[] = { + { .compatible ="altr,edac" }, + {}, +}; +MODULE_DEVICE_TABLE (of, altr_edac_of_match); + +static int altr_edac_probe (struct platform_device *pdev) +{ +of_platform_populate (pdev->dev.of_node, altr_edac_device_of_match, +NULL , &pdev->dev); +return 0 ;
drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 562
Quoted 10 lines
drivers/edac/altera_edac.c +10
-0+} + +static struct platform_driver altr_edac_driver = { + .probe = altr_edac_probe, + .driver = { + .name ="altr_edac" , + .of_match_table = altr_edac_of_match, + }, +}; +module_platform_driver (altr_edac_driver);
WARNING: DT compatible string "altr,edac" appears un-documented -- check ./Documentation/devicetree/bindings/ #176: FILE: drivers/edac/altera_edac.c:543:
+ { .compatible = "altr,edac" },
WARNING: DT compatible string "altr,l2-edac" appears un-documented -- check ./Documentation/devicetree/bindings/ #326: FILE: drivers/edac/altera_edac.c:693:
+ { .compatible = "altr,l2-edac", .data = (void *)&l2ecc_data },
WARNING: DT compatible string "altr,ocram-edac" appears un-documented -- check ./Documentation/devicetree/bindings/ #329: FILE: drivers/edac/altera_edac.c:696:
+ { .compatible = "altr,ocram-edac", .data = (void *)&ocramecc_data },
drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 570
Quoted 8 lines
drivers/edac/altera_edac.c +8
-0+ +/************************* EDAC Device Functions *************************/ + +/* +* EDAC Device Functions (shared between various IPs). +* The discrete memories use the EDAC Device framework. The probe +* and error handling functions are very similar between memories +* so they are shared. The memory allocation and free for EDAC trigger
and freeing
Quoted 40 lines
drivers/edac/altera_edac.c +40
-0+* testing are different for each memory. +*/ + +const struct edac_device_prv_data ocramecc_data; +const struct edac_device_prv_data l2ecc_data; + +struct edac_device_prv_data { +int (*setup)(struct platform_device *pdev,void __iomem *base); +int ce_clear_mask; +int ue_clear_mask; +struct edac_dev_sysfs_attribute *eccmgr_sysfs_attr; +void * (*alloc_mem)(size_t size,void **other); +void (*free_mem)(void *p,size_t size,void *other); +int ecc_enable_mask; +int ce_set_mask; +int ue_set_mask; +int trig_alloc_sz; +}; + +struct altr_edac_device_dev { +void __iomem *base; +int sb_irq; +int db_irq; +const struct edac_device_prv_data *data; +char *edac_dev_name; +}; + +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) { +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)
drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 620
Quoted 10 lines
drivers/edac/altera_edac.c +10
-0+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" ); + } + +return IRQ_HANDLED ; +} + +ssize_t altr_edac_device_trig (struct edac_device_ctl_info *edac_dci, +const char *buffer,size_t count)
Is that an error injection function? If so, it should be behind CONFIG_EDAC_DEBUG or an altera-specific Kconfig item which people can enable - you don't want people to be able to inject errors on production systems.
Also, those injection facilities should be in debugfs and not sysfs - look at xgene_edac for an example.
I'll stop here - that's enough TODO for now :-)
Thanks.
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Quoted 55 lines · Borislav Petkov
Quoted 54 lines · On Tue, Oct 27, 2015 at 03:38:12PM -0500, [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.
The SDRAM ECC is a separate
Kconfigoption 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.Signed-off-by Thor Thayer <[email protected]>Signed-off-by Dinh Nguyen <[email protected]>---
v7: s/of_get_named_gen_pool/of_gen_pool_get
Remove #ifdef forEDAC_DEBUG
Use-ENODEVinstead ofEPROBE_DEFERv6: 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.
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 into
altera_edac.c
instead of separate files.v2: Fix L2 dependency comments.
--- drivers/edac/Kconfig | 16 ++ drivers/edac/Makefile | 5 +- drivers/edac/altera_edac.c | 488 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 507 insertions(+), 2 deletions(-)drivers/edac/Kconfig +0
-0
[snip]
Quoted 8 lines
Quoted 8 lines
drivers/edac/Makefile +0
-0@@ -67,6 +67,9 @@ 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
Quoted 8 lines
drivers/edac/Makefile obj-$(CONFIG_EDAC_OCTEON_L2C) += octeon_edac-l2c.o · line 73
Quoted 5 lines
drivers/edac/Makefile +4
-1-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.oWhat are those supposed to accomplish?
We tried to jam the L2 and OCRAM EDAC functionality in the same altr_edac.c file. It looks like it might be clean if we split out the L2 and OCRAM functions into their appropriate files(altr_edac_l2.c and altr_edac_ocram.c). Do you agree?
Quoted 19 lines
Quoted 19 lines
drivers/edac/Makefile +0
-0obj-$(CONFIG_EDAC_SYNOPSYS) += synopsys_edac.o obj-$(CONFIG_EDAC_XGENE) += xgene_edac.odrivers/edac/altera_edac.c +2
-0@@ -17,8 +17,10 @@* Adapted from the highbank_mc_edac driver. */ +#include <asm/cacheflush.h> #include <linux/ctype.h> #include <linux/edac.h> +#include <linux/genalloc.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/mfd/syscon.h> @@ -34,6 +36,7 @@
Quoted 6 lines
drivers/edac/altera_edac.c line 39
Quoted 3 lines
drivers/edac/altera_edac.c +1
-0#define EDAC_MOD_STR "altera_edac"#define EDAC_VERSION "1" +#define EDAC_DEVICE "ALTR_MEM"Let's simply call it "Altera" - it is more human-friendly.
Ok.
Quoted 16 lines
Quoted 16 lines
drivers/edac/altera_edac.c +10
-0static const struct altr_sdram_prv_data c5_data = { .ecc_ctrl_offset =CV_CTLCFG_OFST ,@@ -75,6 +78,33 @@ static const struct altr_sdram_prv_data a10_data = { .ue_set_mask = A10_DIAGINT_TDERRA_MASK, }; +/************************** EDAC Device Defines **************************/ + +/* OCRAM ECC Management Group Defines */ +#define ALTR_MAN_GRP_OCRAM_ECC_OFFSET 0x04 +#define ALTR_OCR_ECC_EN_MASK BIT(0) +#define ALTR_OCR_ECC_INJS_MASK BIT(1) +#define ALTR_OCR_ECC_INJD_MASK BIT(2) +#define ALTR_OCR_ECC_SERR_MASK BIT(3) +#define ALTR_OCR_ECC_DERR_MASK BIT(4) +
Quoted 9 lines
drivers/edac/altera_edac.c static const struct altr_sdram_prv_data a10_data = { · line 95
Quoted 5 lines
drivers/edac/altera_edac.c +5
-0+/* L2 ECC Management Group Defines */ +#define ALTR_MAN_GRP_L2_ECC_OFFSET 0x00 +#define ALTR_L2_ECC_EN_MASK BIT(0) +#define ALTR_L2_ECC_INJS_MASK BIT(1) +#define ALTR_L2_ECC_INJD_MASK BIT(2)Single bit masks? You don't need to call them "
_MASK" - simply remove it.
Ok.
Quoted 16 lines
Quoted 16 lines
drivers/edac/altera_edac.c +11
-0+#define ALTR_UE_TRIGGER_CHAR 'U'/* Trigger for UE */ +#define ALTR_TRIGGER_READ_WRD_CNT 32/* Line size x 4 */ +#define ALTR_TRIG_OCRAM_BYTE_SIZE 128/* Line size x 4 */ +#define ALTR_TRIG_L2C_BYTE_SIZE 4096/* Full Page */ + +/*********************** EDAC Memory Controller Functions ****************/ + +/* The SDRAM controller uses the EDAC Memory Controller framework. */ + +#ifdef CONFIG_EDAC_ALTERA_MC +static irqreturn_t altr_sdram_mc_err_handler (int irq,void *dev_id) {struct mem_ctl_info *mci = dev_id;@@ -504,6 +534,462 @@ static struct platform_driver altr_sdram_edac_driver = {
Quoted 8 lines
drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 537
Quoted 3 lines
drivers/edac/altera_edac.c +1
-0module_platform_driver (altr_sdram_edac_driver); +#endif /* #ifdef CONFIG_EDAC_ALTERA_MC */ #endif /*
CONFIG_EDAC_ALTERA_MC*/is the usual syntax for those.
Ok..
Quoted 30 lines
Quoted 15 lines
drivers/edac/altera_edac.c +15
-0+/************************* EDAC Parent Probe *************************/ + +static const struct of_device_id altr_edac_device_of_match[]; + +static const struct of_device_id altr_edac_of_match[] = { + { .compatible ="altr,edac" }, + {}, +}; +MODULE_DEVICE_TABLE (of, altr_edac_of_match); + +static int altr_edac_probe (struct platform_device *pdev) +{ +of_platform_populate (pdev->dev.of_node, altr_edac_device_of_match, +NULL , &pdev->dev); +return 0 ;drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 562
Quoted 10 lines
drivers/edac/altera_edac.c +10
-0+} + +static struct platform_driver altr_edac_driver = { + .probe = altr_edac_probe, + .driver = { + .name ="altr_edac" , + .of_match_table = altr_edac_of_match, + }, +}; +module_platform_driver (altr_edac_driver);WARNING: DT compatible string "altr,edac" appears un-documented -- check
./Documentation/devicetree/bindings/#176: FILE:drivers/edac/altera_edac.c:543:
+ { .compatible = "altr,edac" },
Quoted 8 lines
WARNING: DT compatible string "altr,l2-edac" appears un-documented -- check
./Documentation/devicetree/bindings/#326: FILE:drivers/edac/altera_edac.c:693:
+ { .compatible = "altr,l2-edac", .data = (void *)&l2ecc_data },WARNING: DT compatible string "altr,ocram-edac" appears un-documented -- check
./Documentation/devicetree/bindings/#329: FILE:drivers/edac/altera_edac.c:696:
+ { .compatible = "altr,ocram-edac", .data = (void *)&ocramecc_data },
These bindings were in a separate patch that you were not CC'd. I'll keep you on the entire patch set in the future.
Quoted 67 lines
drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 570
Quoted 8 lines
drivers/edac/altera_edac.c +8
-0+ +/************************* EDAC Device Functions *************************/ + +/* +* EDAC Device Functions (shared between various IPs). +* The discrete memories use the EDAC Device framework. The probe +* and error handling functions are very similar between memories +* so they are shared. The memory allocation and free for EDAC trigger and freeing
Quoted 40 lines
drivers/edac/altera_edac.c +40
-0+* testing are different for each memory. +*/ + +const struct edac_device_prv_data ocramecc_data; +const struct edac_device_prv_data l2ecc_data; + +struct edac_device_prv_data { +int (*setup)(struct platform_device *pdev,void __iomem *base); +int ce_clear_mask; +int ue_clear_mask; +struct edac_dev_sysfs_attribute *eccmgr_sysfs_attr; +void * (*alloc_mem)(size_t size,void **other); +void (*free_mem)(void *p,size_t size,void *other); +int ecc_enable_mask; +int ce_set_mask; +int ue_set_mask; +int trig_alloc_sz; +}; + +struct altr_edac_device_dev { +void __iomem *base; +int sb_irq; +int db_irq; +const struct edac_device_prv_data *data; +char *edac_dev_name; +}; + +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) { +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)drivers/edac/altera_edac.c static struct platform_driver altr_sdram_edac_driver = { · line 620
Quoted 10 lines
drivers/edac/altera_edac.c +10
-0+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" ); + } + +return IRQ_HANDLED ; +} + +ssize_t altr_edac_device_trig (struct edac_device_ctl_info *edac_dci, +const char *buffer,size_t count)Is that an error injection function? If so, it should be behind
CONFIG_EDAC_DEBUGor an altera-specificKconfigitem which people can enable - you don't want people to be able to inject errors on production systems.
Quoted 2 lines
Also, those injection facilities should be in debugfs and not sysfs - look at
xgene_edacfor an example.
Yes, there is an injection, and it is using sysfs. Will have to update.
Quoted 3 lines
I'll stop here - that's enough TODO for now :-)
Yes, I'll address all of the above comments in v9.
Thanks for the review.
Dinh
Borislav Petkov
maintainerQuoted 4 lines · Dinh Nguyen
We tried to jam the L2 and OCRAM EDAC functionality in the same
altr_edac.cfile. It looks like it might be clean if we split out the L2 and OCRAM functions into their appropriatefiles(altr_edac_l2.c and altr_edac_ocram.c). Do you agree?
"Clean" in what sense? To me clean is when there's a single compilation unit altera_edac.c which contains all Altera-specific code.
Quoted 2 lines
These bindings were in a separate patch that you were not CC'd. I'll keep you on the entire patch set in the future.
Yes, I believe the devicetree definitions need to go hand-in-hand with its user(s).
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Quoted 9 lines · Borislav Petkov
Quoted 4 lines · Dinh Nguyen
We tried to jam the L2 and OCRAM EDAC functionality in the same
altr_edac.cfile. It looks like it might be clean if we split out the L2 and OCRAM functions into their appropriatefiles(altr_edac_l2.c and altr_edac_ocram.c). Do you agree?"Clean" in what sense? To me clean is when there's a single compilation unit
altera_edac.cwhich contains all Altera-specific code.
altr_edac.c originally added support for SDRAM. Now we're adding support for L2 and OCRAM into the same file by using #ifdef CONFIG_EDAC_ALTERA_OCRAM and CONFIG_EDAC_ALTERA_L2C. So "clean" was to move the l2 and ocram implementation into separate files.
Dinh
Borislav Petkov
maintainerQuoted 4 lines · Dinh Nguyen
altr_edac.coriginally added support for SDRAM. Now we're adding support for L2 and OCRAM into the same file by using #ifdefCONFIG_EDAC_ALTERA_OCRAMandCONFIG_EDAC_ALTERA_L2C. So "clean" was to move the l2 and ocram implementation into separate files.
So what's wrong with adding those to the same file and using different registration functions? Like xgene_edac does, for example.
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Quoted 9 lines · Borislav Petkov
Quoted 4 lines · Dinh Nguyen
altr_edac.coriginally added support for SDRAM. Now we're adding support for L2 and OCRAM into the same file by using #ifdefCONFIG_EDAC_ALTERA_OCRAMandCONFIG_EDAC_ALTERA_L2C. So "clean" was to move the l2 and ocram implementation into separate files.So what's wrong with adding those to the same file and using different registration functions? Like
xgene_edacdoes, for example.
I don't see a way for the xgene to manually build for each configuration using Kconfig? For SoCFGPA, we would like to keep the option to build for each type of ECC.
Dinh
Borislav Petkov
maintainerQuoted 3 lines · Dinh Nguyen
I don't see a way for the xgene to manually build for each configuration using
Kconfig? For SoCFGPA, we would like to keep the option to build for each type of ECC.
xgene builds everything in and unconditionally.
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Borislav Petkov
maintainerQuoted 2 lines · Dinh Nguyen
Right. So for us, if we build in SDRAM ECC unconditionally, there is a requirement with the bootloader to turn on ECC and scrub the memory.
Huh, how does a built-in piece of code cause the bootloader to do something?!?
And how would the bootloader know what's in the kernel? The bootloader runs first and hands off to the kernel...
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Quoted 7 lines · Borislav Petkov
Quoted 3 lines · Dinh Nguyen
I don't see a way for the xgene to manually build for each configuration using
Kconfig? For SoCFGPA, we would like to keep the option to build for each type of ECC.xgene builds everything in and unconditionally.
Right. So for us, if we build in SDRAM ECC unconditionally, there is a requirement with the bootloader to turn on ECC and scrub the memory. This can take up to ~2 seconds and some may not want that.
Dinh
Quoted 10 lines · Borislav Petkov
Quoted 2 lines · Dinh Nguyen
Right. So for us, if we build in SDRAM ECC unconditionally, there is a requirement with the bootloader to turn on ECC and scrub the memory.
Huh, how does a built-in piece of code cause the bootloader to do something?!?
And how would the bootloader know what's in the kernel? The bootloader runs first and hands off to the kernel...
Hi Boris,
The decision about ECC or non-ECC SDRAM is made before building the Linux image and must be matched to the appropriate bootloader (ECC or non-ECC).
If ECC is desired for SDRAM, the bootloader enables SDRAM ECC and then initializes the memory contents (scrub) before the Linux image is loaded into SDRAM.
The ECC syndromes are calculated and stored in SDRAM only when SDRAM ECC is enabled and the SDRAM data is written (in the bootloader case, this is the Linux image). If we suddenly switched ECC on during Linux initialization, we'd be flooded with ECC errors since the ECC syndromes won't match the data for the Linux image.
The scrubbing process takes more time to boot which some of our customers don't want. This is what Dinh was referring to.
Borislav Petkov
maintainerQuoted 7 lines · Thor Thayer
The decision about ECC or non-ECC SDRAM is made before building the Linux image and must be matched to the appropriate bootloader (ECC or non-ECC).
If ECC is desired for SDRAM, the bootloader enables SDRAM ECC and then initializes the memory contents (scrub) before the Linux image is loaded into SDRAM.
Quoted 8 lines
The ECC syndromes are calculated and stored in SDRAM only when SDRAM ECC is enabled and the SDRAM data is written (in the bootloader case, this is the Linux image). If we suddenly switched ECC on during Linux initialization, we'd be flooded with ECC errors since the ECC syndromes won't match the data for the Linux image.
The scrubbing process takes more time to boot which some of our customers don't want. This is what Dinh was referring to.
So that still doesn't have any effect on what's compiled in the EDAC module, AFAICT. You simply build everything in and depending on whether ECC is enabled or not in the bootloader, altera_edac behaves accordingly. On a system with ECC *not* enabled, it would simply have the SDRAM ECC functionality inactive.
This is no different than an x86 system where you enter the BIOS and enable or disable ECC. The EDAC module queries whether ECC has been enabled or not and behaves accordingly.
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Quoted 23 lines · Borislav Petkov
Quoted 7 lines · Thor Thayer
The decision about ECC or non-ECC SDRAM is made before building the Linux image and must be matched to the appropriate bootloader (ECC or non-ECC).
If ECC is desired for SDRAM, the bootloader enables SDRAM ECC and then initializes the memory contents (scrub) before the Linux image is loaded into SDRAM.
Quoted 8 lines
The ECC syndromes are calculated and stored in SDRAM only when SDRAM ECC is enabled and the SDRAM data is written (in the bootloader case, this is the Linux image). If we suddenly switched ECC on during Linux initialization, we'd be flooded with ECC errors since the ECC syndromes won't match the data for the Linux image.
The scrubbing process takes more time to boot which some of our customers don't want. This is what Dinh was referring to.
So that still doesn't have any effect on what's compiled in the EDAC module, AFAICT. You simply build everything in and depending on whether ECC is enabled or not in the bootloader,
altera_edacbehaves accordingly. On a system with ECC *not* enabled, it would simply have the SDRAM ECC functionality inactive.
Quoted 4 lines
This is no different than an x86 system where you enter the BIOS and enable or disable ECC. The EDAC module queries whether ECC has been enabled or not and behaves accordingly.
OK. I see your point for SDRAM.
However, in the case of OCRAM and L2 cache ECC, we want to be able to enable them individually which is what the following does.
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +4
-1-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.oWhat are those supposed to accomplish?
and then the defines are also used to conditionally include the L2 or OCRAM ECC functions because everything is in one file.
However, the highbank and octeon edacs are split into separate files for L2 which Dinh pointed may be cleaner for individual control.
Thanks,
Thor
Borislav Petkov
maintainerQuoted 2 lines · Thor Thayer
and then the defines are also used to conditionally include the L2 or OCRAM ECC functions because everything is in one file.
So?
You don't have to do those funny games in the Makefile. Instead, you have your main CONFIG_EDAC_ALTERA_MC option and all the other CONFIG_* options depend on it. The ifdeffery in altera_edac.c then takes care of what needs to be enabled or not.
However(!), your driver is not huge or something. So I still don't understand why you need that split and those additional config options and why not keep it all together in one file. What is the compelling use case for that split and additional complexity?
Quoted 2 lines
However, the highbank and octeon edacs are split into separate files for L2 which Dinh pointed may be cleaner for individual control.
I should've nacked that split at the time.
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Quoted 16 lines · Borislav Petkov
Quoted 2 lines · Thor Thayer
and then the defines are also used to conditionally include the L2 or OCRAM ECC functions because everything is in one file.
So?
You don't have to do those funny games in the
Makefile. Instead, you have your mainCONFIG_EDAC_ALTERA_MCoption and all the other CONFIG_* options depend on it. The ifdeffery inaltera_edac.cthen takes care of what needs to be enabled or not.However(!), your driver is not huge or something. So I still don't understand why you need that split and those additional config options and why not keep it all together in one file. What is the compelling use case for that split and additional complexity?
Quoted 5 lines
Quoted 2 lines
However, the highbank and octeon edacs are split into separate files for L2 which Dinh pointed may be cleaner for individual control.
I should've nacked that split at the time.
OK, Thanks for the clarification.
The CONFIG_EDAC_ALTERA_MC is a little confusing because it refers to the Memory Controller (SDRAM) and uses that in the menu string(Altera SDRAM Memory Controller EDAC).
Would it be confusing to rename this CONFIG_EDAC_ALTERA, update the SDRAM code to check the ECC Enable bit instead of this config option and update the string in the menu?
I'll keep this as one file and implement your suggested changes and resubmit.
Borislav Petkov
maintainerQuoted 7 lines · Thor Thayer
The
CONFIG_EDAC_ALTERA_MCis a little confusing because it refers to the Memory Controller (SDRAM) and uses that in the menu string(Altera SDRAM Memory Controller EDAC).Would it be confusing to rename this
CONFIG_EDAC_ALTERA, update the SDRAM code to check the ECC Enable bit instead of this config option and update the string in the menu?
Sounds good to me.
Quoted 2 lines
I'll keep this as one file and implement your suggested changes and resubmit.
Thanks.
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.