EDAC/nuvoton: Add NPCM memory controller driver
Subsystems (5)
v17 cover EDAC/nuvoton: Add NPCM memory controller driver
This patch series add DTS node, dt-bindings document and driver for memory controller present on Nuvoton NPCM SoCs.
The memory controller supports single bit error correction and double bit error detection (in-line ECC in which a section 1/8th of the memory device used to store data is used for ECC storage).
Changes in v17:
- Correct subject prefixes of patch 1/3.
- Change dt-bindings document name to "nuvoton,npcm-memory-controller.yaml" and refine the document format.
Changes in v16:
- Correct dt-bindings document path in MAINTAINERS.
- Fix wrong indentation in driver.
Changes in v15:
- Move dt-bindings document to memory-controllers directory and remove superfluous string in content title.
Changes in v14:
- Fix compile warnings.
Changes in v13:
- Support error injection via debugfs.
- Fix coding style issues.
Marvin Lin (3):
ARM: dts: nuvoton: Add node for NPCM memory controller
dt-bindings: edac: nuvoton: Add document for NPCM memory controller EDAC/npcm: Add NPCM memory controller driver
.../nuvoton,npcm-memory-controller.yaml | 50 ++ MAINTAINERS | 8 + arch/arm/boot/dts/nuvoton-common-npcm7xx.dtsi | 7 + drivers/edac/Kconfig | 11 + drivers/edac/Makefile | 1 + drivers/edac/npcm_edac.c | 520 ++++++++++++++++++ 6 files changed, 597 insertions(+) create mode 100644 Documentation/devicetree/bindings/memory-controllers/nuvoton,npcm-memory-controller.yaml create mode 100644 drivers/edac/npcm_edac.c
Signature · 1 line
2.34.1
PATCH v17 1/3 ARM: dts: nuvoton: Add node for NPCM memory controller
Add node for memory controller present on Nuvoton NPCM SoCs. The memory controller supports single bit error correction and double bit error detection.
--- arch/arm/boot/dts/nuvoton-common-npcm7xx.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/boot/dts/nuvoton-common-npcm7xx.dtsi +7 -0
@@ -179,6 +179,13 @@ fiux: spi@fb001000 { status = "disabled"; }; + mc: memory-controller@f0824000 { + compatible = "nuvoton,npcm750-memory-controller"; + reg = <0xf0824000 0x1000>; + interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + }; + apb { #address-cells = <1>; #size-cells = <1>;
Signature · 1 line
2.34.1
PATCH v17 2/3 dt-bindings: edac: nuvoton: Add document for NPCM memory controller
In reply to Marvin LinAdd dt-bindings document for Nuvoton NPCM memory controller.
--- .../nuvoton,npcm-memory-controller.yaml | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Documentation/devicetree/bindings/memory-controllers/nuvoton,npcm-memory-controller.yaml
Documentation/devicetree/bindings/memory-controllers/nuvoton,npcm-memory-controller.yaml new file +50 -0
@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/memory-controllers/nuvoton,npcm-memory-controller.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton NPCM Memory Controller + +maintainers: + - Marvin Lin <[email protected]> + - Stanley Chu <[email protected]> + +description: | + The Nuvoton BMC SoC supports DDR4 memory with or without ECC (error correction + check). + + The memory controller supports single bit error correction, double bit error + detection (in-line ECC in which a section (1/8th) of the memory device used to + store data is used for ECC storage). + + Note, the bootloader must configure ECC mode for the memory controller. + +properties: + compatible: + enum: + - nuvoton,npcm750-memory-controller + - nuvoton,npcm845-memory-controller + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + mc: memory-controller@f0824000 { + compatible = "nuvoton,npcm750-memory-controller"; + reg = <0xf0824000 0x1000>; + interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; + };
Signature · 1 line
2.34.1
Re: [PATCH v17 2/3] dt-bindings: edac: nuvoton: Add document for NPCM memory controller
Quoted 1 line · Marvin Lin
Add dt-bindings document for Nuvoton NPCM memory controller.
Subject: use "memory-controllers" prefix, not edac.
Best regards,
Krzysztof
Re: [PATCH v17 2/3] dt-bindings: edac: nuvoton: Add document for NPCM memory controller
Quoted 3 lines
Quoted 1 line
Add dt-bindings document for Nuvoton NPCM memory controller.
Subject: use "memory-controllers" prefix, not edac.
Thanks for the review. I'll correct it in the next patch.
Regards,
Marvin
PATCH v17 3/3 EDAC/npcm: Add NPCM memory controller driver
In reply to Marvin LinAdd driver for memory controller present on Nuvoton NPCM SoCs. The memory controller supports single bit error correction and double bit error detection.
--- MAINTAINERS | 8 + drivers/edac/Kconfig | 11 + drivers/edac/Makefile | 1 + drivers/edac/npcm_edac.c | 520 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 540 insertions(+) create mode 100644 drivers/edac/npcm_edac.c
MAINTAINERS +8 -0
@@ -7524,6 +7524,14 @@ L: [email protected] S: Maintained F: drivers/edac/mpc85xx_edac.[ch] +EDAC-NPCM +M: Marvin Lin <[email protected]> +M: Stanley Chu <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/memory-controllers/nuvoton,npcm-memory-controller.yaml +F: drivers/edac/npcm_edac.c + EDAC-PASEMI M: Egor Martovetsky <[email protected]> L: [email protected]
drivers/edac/Kconfig +11 -0
@@ -542,4 +542,15 @@ config EDAC_DMC520 Support for error detection and correction on the SoCs with ARM DMC-520 DRAM controller. +config EDAC_NPCM + tristate "Nuvoton NPCM DDR Memory Controller" + depends on (ARCH_NPCM || COMPILE_TEST) + help + Support for error detection and correction on the Nuvoton NPCM DDR + memory controller. + + The memory controller supports single bit error correction, double bit + error detection (in-line ECC in which a section 1/8th of the memory + device used to store data is used for ECC storage). + endif # EDAC
drivers/edac/Makefile +1 -0
@@ -84,3 +84,4 @@ obj-$(CONFIG_EDAC_QCOM) += qcom_edac.o obj-$(CONFIG_EDAC_ASPEED) += aspeed_edac.o obj-$(CONFIG_EDAC_BLUEFIELD) += bluefield_edac.o obj-$(CONFIG_EDAC_DMC520) += dmc520_edac.o +obj-$(CONFIG_EDAC_NPCM) += npcm_edac.o
drivers/edac/npcm_edac.c new file +520 -0
520 lines not on this page · raw message
Signature · 1 line
2.34.1
Borislav Petkov
maintainerRe: [PATCH v17 3/3] EDAC/npcm: Add NPCM memory controller driver
drivers/edac/npcm_edac.c line 102
Quoted 8 lines · Marvin Lin
drivers/edac/npcm_edac.c new file +8
-0+static void handle_ce (struct mem_ctl_info *mci) +{ +struct priv_data *priv = mci->pvt_info; +const struct npcm_platform_data *pdata = priv->pdata; +u64 addr =0 ; +u64 data =0 ; +u32 val_h =0 ; +u32 val_l, id, synd;
u32 val_h = 0, val_l, id, synd;
u64 addr = 0, data = 0;Also, for all your functions:
The EDAC tree preferred ordering of variable declarations at the beginning of a function is reverse fir tree order::
struct long_struct_name *descriptive_name; unsigned long foo, bar; unsigned int tmp; int ret;
The above is faster to parse than the reverse ordering::
int ret; unsigned int tmp; unsigned long foo, bar; struct long_struct_name *descriptive_name;
And even more so than random ordering::
unsigned long foo, bar; int ret; struct long_struct_name *descriptive_name; unsigned int tmp;
Quoted 13 lines
drivers/edac/npcm_edac.c new file +13
-0+regmap_read (npcm_regmap, pdata->ctl_ce_addr_l, &val_l); +if (pdata->chip ==NPCM8XX_CHIP ) { +regmap_read (npcm_regmap, pdata->ctl_ce_addr_h, &val_h); + val_h &= pdata->ce_addr_h_mask; + } + addr = ((addr | val_h) <<32 ) | val_l; + +regmap_read (npcm_regmap, pdata->ctl_ce_data_l, &val_l); +if (pdata->chip ==NPCM8XX_CHIP ) +regmap_read (npcm_regmap, pdata->ctl_ce_data_h, &val_h); + data = ((data | val_h) <<32 ) | val_l; + +regmap_read (npcm_regmap, pdata->ctl_source_id, &id);
drivers/edac/npcm_edac.c line 126
Quoted 10 lines
drivers/edac/npcm_edac.c new file +10
-0+ id = (id & pdata->source_id_ce_mask) >> pdata->source_id_ce_shift; + +regmap_read (npcm_regmap, pdata->ctl_ce_synd, &synd); + synd = (synd & pdata->ce_synd_mask) >> pdata->ce_synd_shift; + +snprintf (priv->message,EDAC_MSG_SIZE , +"addr = 0x%llx, data = 0x%llx, id = 0x%x" , addr, data, id); + + edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1, addr >> PAGE_SHIFT, + addr & ~PAGE_MASK, synd, 0, 0, -1, priv->message,
No need for that linebreak with the trailing piece.
drivers/edac/npcm_edac.c line 137
Quoted 11 lines
drivers/edac/npcm_edac.c new file +11
-0+ ""); +} + +static void handle_ue (struct mem_ctl_info *mci) +{ +struct priv_data *priv = mci->pvt_info; +const struct npcm_platform_data *pdata = priv->pdata; +u64 addr =0 ; +u64 data =0 ; +u32 val_h =0 ; +u32 val_l, id, synd;
As above.
Quoted 40 lines
drivers/edac/npcm_edac.c new file +40
-0+ +regmap_read (npcm_regmap, pdata->ctl_ue_addr_l, &val_l); +if (pdata->chip ==NPCM8XX_CHIP ) { +regmap_read (npcm_regmap, pdata->ctl_ue_addr_h, &val_h); + val_h &= pdata->ue_addr_h_mask; + } + addr = ((addr | val_h) <<32 ) | val_l; + +regmap_read (npcm_regmap, pdata->ctl_ue_data_l, &val_l); +if (pdata->chip ==NPCM8XX_CHIP ) +regmap_read (npcm_regmap, pdata->ctl_ue_data_h, &val_h); + data = ((data | val_h) <<32 ) | val_l; + +regmap_read (npcm_regmap, pdata->ctl_source_id, &id); + id = (id & pdata->source_id_ue_mask) >> pdata->source_id_ue_shift; + +regmap_read (npcm_regmap, pdata->ctl_ue_synd, &synd); + synd = (synd & pdata->ue_synd_mask) >> pdata->ue_synd_shift; + +snprintf (priv->message,EDAC_MSG_SIZE , +"addr = 0x%llx, data = 0x%llx, id = 0x%x" , addr, data, id); + +edac_mc_handle_error (HW_EVENT_ERR_UNCORRECTED , mci,1 , + addr >>PAGE_SHIFT , addr & ~PAGE_MASK , synd,0 ,0 , +-1 , priv->message,"" ); +} + +static irqreturn_t edac_ecc_isr (int irq,void *dev_id) +{ +struct mem_ctl_info *mci = dev_id; +struct priv_data *priv = mci->pvt_info; +const struct npcm_platform_data *pdata = priv->pdata; +u32 status; + +regmap_read (npcm_regmap, pdata->ctl_int_status, &status); +if (status & pdata->int_status_ce_mask) { +handle_ce (mci); + +/* acknowledge the CE interrupt */ + regmap_write(npcm_regmap, pdata->ctl_int_ack,
drivers/edac/npcm_edac.c line 187
Quoted 10 lines
drivers/edac/npcm_edac.c new file +10
-0+ pdata->int_ack_ce_mask); +return IRQ_HANDLED ; + }else if (status & pdata->int_status_ue_mask) { +handle_ue (mci); + +/* acknowledge the UE interrupt */ +regmap_write (npcm_regmap, pdata->ctl_int_ack, + pdata->int_ack_ue_mask); +return IRQ_HANDLED ; + }
WARN_ON_ONCE(1);
to catch weird cases.
Quoted 28 lines
drivers/edac/npcm_edac.c new file +28
-0+ +return IRQ_NONE ; +} + +static ssize_t force_ecc_error (struct file *file,const char __user *data, +size_t count,loff_t *ppos) +{ +struct device *dev = file->private_data; +struct mem_ctl_info *mci =to_mci (dev); +struct priv_data *priv = mci->pvt_info; +const struct npcm_platform_data *pdata = priv->pdata; +int ret; +u32 val, syndrome; + +/* +* error_type - 0: CE, 1: UE +* location - 0: data, 1: checkcode +* bit - 0 ~ 63 for data and 0 ~ 7 for checkcode +*/ +edac_printk (KERN_INFO ,EDAC_MOD_NAME , +"force an ECC error, type = %d, location = %d, bit = %d\n" , + priv->error_type, priv->location, priv->bit); + +/* ensure no pending writes */ + ret =regmap_read_poll_timeout (npcm_regmap, pdata->ctl_controller_busy, + val, !(val & pdata->controller_busy_mask), +1000 ,10000 ); +if (ret) {
drivers/edac/npcm_edac.c line 225
Quoted 10 lines
drivers/edac/npcm_edac.c new file +10
-0+edac_printk (KERN_INFO ,EDAC_MOD_NAME , +"wait pending writes timeout\n" ); +return count; + } + +regmap_read (npcm_regmap, pdata->ctl_xor_check_bits, &val); + val &= ~pdata->xor_check_bits_mask; + +/* write syndrome to XOR_CHECK_BITS */ +if (priv->error_type ==0 ) {
if (priv->error_type == ERROR_TYPE_CORRECTABLE
Use defines. Below too.
drivers/edac/npcm_edac.c line 228
Quoted 5 lines
drivers/edac/npcm_edac.c new file +3
-0+if (priv->location ==0 && priv->bit >63 ) { +edac_printk (KERN_INFO ,EDAC_MOD_NAME , +"data bit should not exceed 63\n" );
"data bit should not exceed 63 (%d)\n", priv->bit...)
Below too.
drivers/edac/npcm_edac.c line 239
Quoted 11 lines
drivers/edac/npcm_edac.c new file +11
-0+return count; + } + +if (priv->location ==1 && priv->bit >7 ) { +edac_printk (KERN_INFO ,EDAC_MOD_NAME , +"checkcode bit should not exceed 7\n" ); +return count; + } + + syndrome = priv->location ?1 << priv->bit : + data_synd[priv->bit];
syndrome = priv->location ? 1 << priv->bit : data_synd[priv->bit];
Quoted 11 lines
drivers/edac/npcm_edac.c new file +11
-0+regmap_write (npcm_regmap, pdata->ctl_xor_check_bits, + val | (syndrome << pdata->xor_check_bits_shift) | + pdata->writeback_en_mask); + }else if (priv->error_type ==1 ) { +regmap_write (npcm_regmap, pdata->ctl_xor_check_bits, + val | (UE_SYNDROME << pdata->xor_check_bits_shift)); + } + +/* force write check */ +regmap_update_bits (npcm_regmap, pdata->ctl_xor_check_bits, + pdata->fwc_mask, pdata->fwc_mask);
drivers/edac/npcm_edac.c line 261
Quoted 10 lines
drivers/edac/npcm_edac.c new file +10
-0+ +return count; +} + +static const struct file_operations force_ecc_error_fops = { + .open = simple_open, + .write = force_ecc_error, + .llseek = generic_file_llseek, +}; +
I'd find it helpful if there were a short recipe in a comment here explaining how the injection should be done...
Quoted 127 lines
drivers/edac/npcm_edac.c new file +127
-0+static void setup_debugfs (struct mem_ctl_info *mci) +{ +struct priv_data *priv = mci->pvt_info; + + priv->debugfs =edac_debugfs_create_dir (mci->mod_name); +if (!priv->debugfs) +return ; + +edac_debugfs_create_x8 ("error_type" ,0644 , priv->debugfs, + &priv->error_type); +edac_debugfs_create_x8 ("location" ,0644 , priv->debugfs, + &priv->location); +edac_debugfs_create_x8 ("bit" ,0644 , priv->debugfs, &priv->bit); +edac_debugfs_create_file ("force_ecc_error" ,0200 , priv->debugfs, + &mci->dev, &force_ecc_error_fops); +} + +static int setup_irq (struct mem_ctl_info *mci,struct platform_device *pdev) +{ +struct priv_data *priv = mci->pvt_info; +const struct npcm_platform_data *pdata = priv->pdata; +int ret, irq; + + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) { +edac_printk (KERN_ERR ,EDAC_MOD_NAME ,"IRQ not defined in DTS\n" ); +return irq; + } + + ret =devm_request_irq (&pdev->dev, irq, edac_ecc_isr,0 , +dev_name (&pdev->dev), mci); +if (ret <0 ) { +edac_printk (KERN_ERR ,EDAC_MOD_NAME ,"failed to request IRQ\n" ); +return ret; + } + +/* enable the functional group of ECC and mask the others */ +regmap_write (npcm_regmap, pdata->ctl_int_mask_master, + pdata->int_mask_master_non_ecc_mask); + +if (pdata->chip ==NPCM8XX_CHIP ) +regmap_write (npcm_regmap, pdata->ctl_int_mask_ecc, + pdata->int_mask_ecc_non_event_mask); + +return 0 ; +} + +static const struct regmap_config npcm_regmap_cfg = { + .reg_bits =32 , + .reg_stride =4 , + .val_bits =32 , +}; + +static int edac_probe (struct platform_device *pdev) +{ +const struct npcm_platform_data *pdata; +struct device *dev = &pdev->dev; +struct edac_mc_layer layers[1 ]; +struct mem_ctl_info *mci; +struct priv_data *priv; +void __iomem *reg; +int rc; +u32 val; + + reg =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (reg)) +return PTR_ERR (reg); + + npcm_regmap =devm_regmap_init_mmio (dev, reg, &npcm_regmap_cfg); +if (IS_ERR (npcm_regmap)) +return PTR_ERR (npcm_regmap); + + pdata =of_device_get_match_data (dev); +if (!pdata) +return -EINVAL ; + +/* bail out if ECC is not enabled */ +regmap_read (npcm_regmap, pdata->ctl_ecc_en, &val); +if (!(val & pdata->ecc_en_mask)) { +edac_printk (KERN_ERR ,EDAC_MOD_NAME ,"ECC is not enabled\n" ); +return -EPERM ; + } + + edac_op_state =EDAC_OPSTATE_INT ; + + layers[0 ].type =EDAC_MC_LAYER_ALL_MEM ; + layers[0 ].size =1 ; + + mci =edac_mc_alloc (0 ,ARRAY_SIZE (layers), layers, +sizeof (struct priv_data )); +if (!mci) +return -ENOMEM ; + + mci->pdev = &pdev->dev; + priv = mci->pvt_info; + priv->reg = reg; + priv->pdata = pdata; +platform_set_drvdata (pdev, mci); + + mci->mtype_cap =MEM_FLAG_DDR4 ; + mci->edac_ctl_cap =EDAC_FLAG_SECDED ; + mci->scrub_cap =SCRUB_FLAG_HW_SRC ; + mci->scrub_mode =SCRUB_HW_SRC ; + mci->edac_cap =EDAC_FLAG_SECDED ; + mci->ctl_name ="npcm_ddr_controller" ; + mci->dev_name =dev_name (&pdev->dev); + mci->mod_name =EDAC_MOD_NAME ; + mci->ctl_page_to_phys =NULL ; + + rc =setup_irq (mci, pdev); +if (rc) + goto free_edac_mc; + + rc =edac_mc_add_mc (mci); +if (rc) + goto free_edac_mc; + +if (IS_ENABLED (CONFIG_EDAC_DEBUG ) && pdata->chip ==NPCM8XX_CHIP ) +setup_debugfs (mci); + +return rc; + +free_edac_mc: +edac_mc_free (mci); +return rc; +} +
drivers/edac/npcm_edac.c line 398
Quoted 10 lines
drivers/edac/npcm_edac.c new file +10
-0+static int edac_remove (struct platform_device *pdev) +{ +struct mem_ctl_info *mci =platform_get_drvdata (pdev); +struct priv_data *priv = mci->pvt_info; +const struct npcm_platform_data *pdata = priv->pdata; + +regmap_write (npcm_regmap, pdata->ctl_int_mask_master, + pdata->int_mask_master_global_mask); +regmap_update_bits (npcm_regmap, pdata->ctl_ecc_en, pdata->ecc_en_mask, +0 );
You have a bunch of those things: the 80 cols rule is not a rigid and a static one - you should rather apply common sense. As in:
Does it make sense to have this ugly linebreak with only the 0 argument there?
regmap_update_bits(npcm_regmap, pdata->ctl_ecc_en, pdata->ecc_en_mask, 0);
or should I simply let it stick out:
regmap_update_bits(npcm_regmap, pdata->ctl_ecc_en, pdata->ecc_en_mask, 0);
and have much more readable code?
Please apply common sense to all your linebreaks above.
drivers/edac/npcm_edac.c line 401
Quoted 3 lines
drivers/edac/npcm_edac.c new file +3
-0+ +edac_mc_del_mc (&pdev->dev); +edac_mc_free (mci);
<--- What happens if someone tries to inject errors right at this moment, when you've freed the mci?
Hint: you should destroy resources in the opposite order you've allocated them.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH v17 3/3] EDAC/npcm: Add NPCM memory controller driver
Hi Boris,
Thanks for the review.
Quoted 25 lines
drivers/edac/npcm_edac.c line 102
Quoted 4 lines
drivers/edac/npcm_edac.c new file +4
-0+u64 addr =0 ; +u64 data =0 ; +u32 val_h =0 ; +u32 val_l, id, synd;u32 val_h = 0, val_l, id, synd; u64 addr = 0, data = 0;Also, for all your functions:
The EDAC tree preferred ordering of variable declarations at the beginning of a function is reverse fir tree order::
struct long_struct_name *descriptive_name; unsigned long foo, bar; unsigned int tmp; int ret;The above is faster to parse than the reverse ordering::
int ret; unsigned int tmp; unsigned long foo, bar; struct long_struct_name *descriptive_name;
Quoted 6 lines
And even more so than random ordering::
unsigned long foo, bar; int ret; struct long_struct_name *descriptive_name; unsigned int tmp;
I'll check all functions and follow this order.
Quoted 5 lines
drivers/edac/npcm_edac.c line 126
Quoted 2 lines
drivers/edac/npcm_edac.c new file +2
-0+ edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1, addr >> PAGE_SHIFT, + addr & ~PAGE_MASK, synd, 0, 0, -1, priv->message,No need for that linebreak with the trailing piece.
Quoted 8 lines
drivers/edac/npcm_edac.c line 137
Quoted 6 lines
drivers/edac/npcm_edac.c new file +5
-0+ ""); +u64 addr =0 ; +u64 data =0 ; +u32 val_h =0 ; +u32 val_l, id, synd;As above.
Check.
Quoted 19 lines
Quoted 6 lines
drivers/edac/npcm_edac.c new file +6
-0+regmap_read (npcm_regmap, pdata->ctl_int_status, &status); +if (status & pdata->int_status_ce_mask) { +handle_ce (mci); + +/* acknowledge the CE interrupt */ + regmap_write(npcm_regmap, pdata->ctl_int_ack,drivers/edac/npcm_edac.c line 187
Quoted 10 lines
drivers/edac/npcm_edac.c new file +10
-0+ pdata->int_ack_ce_mask); +return IRQ_HANDLED ; + }else if (status & pdata->int_status_ue_mask) { +handle_ue (mci); + +/* acknowledge the UE interrupt */ +regmap_write (npcm_regmap, pdata->ctl_int_ack, + pdata->int_ack_ue_mask); +return IRQ_HANDLED ; + }WARN_ON_ONCE(1);
Quoted 1 line
to catch weird cases.
OK.
Quoted 8 lines
drivers/edac/npcm_edac.c line 225
Quoted 2 lines
drivers/edac/npcm_edac.c new file +2
-0+/* write syndrome to XOR_CHECK_BITS */ +if (priv->error_type ==0 ) {if (priv->error_type == ERROR_TYPE_CORRECTABLEUse defines. Below too.
Quoted 1 line
+ if (
priv->location== 0 &&priv->bit> 63) {
Will add defines.
Quoted 13 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ edac_printk(KERN_INFO, EDAC_MOD_NAME, + "data bit should not exceed 63\n");"data bit should not exceed 63 (%d)\n", priv->bit...)Below too.
Quoted 6 lines
drivers/edac/npcm_edac.c new file +6
-0+return count; + } + +if (priv->location ==1 && priv->bit >7 ) { +edac_printk (KERN_INFO ,EDAC_MOD_NAME , +"checkcode bit should not exceed 7\n" );
OK.
Quoted 5 lines
drivers/edac/npcm_edac.c line 239
Quoted 2 lines
drivers/edac/npcm_edac.c new file +2
-0+ syndrome = priv->location ?1 << priv->bit : + data_synd[priv->bit];syndrome = priv->location ? 1 << priv->bit : data_synd[priv->bit];
Just to confirm the indentation, is it right as follows?
syndrome = priv->location ? 1 << priv->bit
: data_synd[priv->bit];
And I was wondering if I should just remove the line break and let it stick out?
Quoted 5 lines
I'd find it helpful if there were a short recipe in a comment here explaining how the injection should be done...
Review
Quoted 2 lines
(quoted diff) +2
-0+static void setup_debugfs(struct mem_ctl_info *mci) +{
OK, will add some injection examples here.
Quoted 11 lines
drivers/edac/npcm_edac.c line 398
Quoted 2 lines
drivers/edac/npcm_edac.c new file +2
-0+regmap_update_bits (npcm_regmap, pdata->ctl_ecc_en, pdata->ecc_en_mask, +0 );You have a bunch of those things: the 80 cols rule is not a rigid and a static one - you should rather apply common sense. As in:
Does it make sense to have this ugly linebreak with only the 0 argument there?
regmap_update_bits(npcm_regmap, pdata->ctl_ecc_en, pdata->ecc_en_mask, 0);
Quoted 7 lines
or should I simply let it stick out:
regmap_update_bits(npcm_regmap, pdata->ctl_ecc_en, pdata->ecc_en_mask, 0);and have much more readable code?
Please apply common sense to all your linebreaks above.
Thanks for the guide.
Quoted 8 lines
drivers/edac/npcm_edac.c line 401
Quoted 2 lines
drivers/edac/npcm_edac.c new file +2
-0+edac_mc_del_mc (&pdev->dev); +edac_mc_free (mci);<--- What happens if someone tries to inject errors right at this moment, when you've freed the mci?
Hint: you should destroy resources in the opposite order you've allocated them.
Understand. I'll correct the destroy order.
Regards,
Marvin
Borislav Petkov
maintainerRe: [PATCH v17 3/3] EDAC/npcm: Add NPCM memory controller driver
Quoted 6 lines · Kun-Fa Lin
Quoted 5 lines
drivers/edac/npcm_edac.c line 239
Quoted 2 lines
drivers/edac/npcm_edac.c new file +2
-0+ syndrome = priv->location ?1 << priv->bit : + data_synd[priv->bit];syndrome = priv->location ? 1 << priv->bit : data_synd[priv->bit];
Quoted 6 lines
Just to confirm the indentation, is it right as follows?
syndrome =
priv->location? 1 <<priv->bit: data_synd[priv->bit];And I was wondering if I should just remove the line break and let it stick out?
The idea is to have the '?' and the ':' under each other so that one can visually immediately "parse" where each of the sides of the ternary statement start.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH v17 3/3] EDAC/npcm: Add NPCM memory controller driver
Quoted 7 lines
Quoted 1 line
And I was wondering if I should just remove the line break and let it
stick out?
The idea is to have the '?' and the ':' under each other so that one can visually immediately "parse" where each of the sides of the ternary statement start.
Get it, thanks.