Uncorrectable bitflips with Linux 4.12 on SAMA5D2
Hello,
On a custom board based on Microchip's SAMA5D2 SoC, I am encountering ECC problems with the NAND Flash controller. The board is currently working with Linux v4.9.x, but it does not with Linux 4.12.
Some pages on the NAND Flash memory chip of the device have bitflips. With Linux 4.9.x, the bitflips are fixed by the PMECC code, but with Linux 4.12, the errors are reported as uncorrectable.
Quoted 1 line
From my end, I updated the board's device tree to include the
sama5d2.dtsi as it exists in Linux 4.12, but the rest of the file is the same as for Linux 4.9. From my understanding, it should be sufficient as the legacy DTB binding for the NAND controller is supported.
The relevant extract is:
nand0: nand at 80000000 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_nand_default>;
status = "okay";
nand-ecc-mode = "hw";
atmel,pmecc-cap = <8>;
atmel,pmecc-sector-size = <512>;
/delete-property/ atmel,nand-has-dma;
};The attached files show the same block read through nanddump, with Linux 4.9 and Linux 4.12
Best regards,
Signature · 15 lines
Romain Izard -------------- next part -------------- A non-text attachment was scrubbed... Name: ad97000_nofix.dump Type: application/octet-stream Size: 10880 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170717/da725c62/attachment-0002.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: ad97000_fix.dump Type: application/octet-stream Size: 10880 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170717/da725c62/attachment-0003.obj>
+Ludovic, Nicolas and Alexandre
Hi Romain,
Le Mon, 17 Jul 2017 18:11:26 +0200,
Romain Izard <[email protected]> a ?crit :
Quoted 10 lines
Hello,
On a custom board based on Microchip's SAMA5D2 SoC, I am encountering ECC problems with the NAND Flash controller. The board is currently working with Linux v4.9.x, but it does not with Linux 4.12.
Some pages on the NAND Flash memory chip of the device have bitflips. With Linux 4.9.x, the bitflips are fixed by the PMECC code, but with Linux 4.12, the errors are reported as uncorrectable.
Quoted 5 lines
From my end, I updated the board's device tree to include the
sama5d2.dtsias it exists in Linux 4.12, but the rest of the file is the same as for Linux 4.9. From my understanding, it should be sufficient as the legacy DTB binding for the NAND controller is supported.
I know Ludovic add some problems with the NAND controller on sama5d2, but it was with the new bindings (see the fixes here [1]).
Your problem seems a bit different since you're using the backward compat code.
Could you dump PMECC/NFC regs when booting 4.9 and 4.12, and see if there's a difference?
Quoted 13 lines
The relevant extract is:
nand0: nand at 80000000 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_nand_default>; status = "okay"; nand-ecc-mode = "hw"; atmel,pmecc-cap = <8>; atmel,pmecc-sector-size = <512>; /delete-property/ atmel,nand-has-dma; };
Quoted 2 lines
The attached files show the same block read through nanddump, with Linux 4.9 and Linux 4.12
Yep, the dumps show 2 identical pages except for the bitflip in ECC block 2, but I can't tell from this dump why PMECC fails to correct bitflips.
Really sorry that you have to debug this problem, but I don't have a sama5d2 platform with a NAND on it and couldn't test my modification on this platform :-/.
Thanks,
Boris
Le Mon, 17 Jul 2017 19:48:09 +0200,
Boris Brezillon <[email protected]> a ?crit :
Quoted 23 lines
+Ludovic, Nicolas and Alexandre
Hi Romain,
Le Mon, 17 Jul 2017 18:11:26 +0200,
Romain Izard <[email protected]> a ?crit :Quoted 10 lines
Hello,
On a custom board based on Microchip's SAMA5D2 SoC, I am encountering ECC problems with the NAND Flash controller. The board is currently working with Linux v4.9.x, but it does not with Linux 4.12.
Some pages on the NAND Flash memory chip of the device have bitflips. With Linux 4.9.x, the bitflips are fixed by the PMECC code, but with Linux 4.12, the errors are reported as uncorrectable.
Quoted 5 lines
From my end, I updated the board's device tree to include the
sama5d2.dtsias it exists in Linux 4.12, but the rest of the file is the same as for Linux 4.9. From my understanding, it should be sufficient as the legacy DTB binding for the NAND controller is supported.
Quoted 5 lines
I know Ludovic add some problems with the NAND controller on sama5d2, but it was with the new bindings (see the fixes here [1]).
Your problem seems a bit different since you're using the backward compat code.
Can you try with the following patch applied?
--->8---
Quoted 1 line
From
cb95a16cdd497137872c44d5dd4e251ec73c79c1Mon Sep 17 00:00:00 2001
From: Boris Brezillon <[email protected]>
Date: Mon, 17 Jul 2017 20:09:59 +0200
Subject: [PATCH] mtd: nand: atmel: Fix DT backward compatibility in pmecc.c
PMECC caps extraction from old DT bindings is broken, thus leading to erroneous EL registers offset, which in turn make HW ECC unusable on sama5d2 when old bindings are in use.
Passing the NAND dev node instead of the NFC node to of_match_node() solves the problem.
--- drivers/mtd/nand/atmel/pmecc.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/mtd/nand/atmel/pmecc.c +6 -15
@@ -945,6 +945,7 @@ struct atmel_pmecc *devm_atmel_pmecc_get(struct device *userdev)*/ struct platform_device *pdev =to_platform_device (userdev);const struct atmel_pmecc_caps *caps; +const struct of_device_id *match;/* No PMECC engine available. */ if (!of_property_read_bool(userdev->of_node,
@@ -953,21 +954,11 @@ struct atmel_pmecc *devm_atmel_pmecc_get(struct device *userdev) caps = &at91sam9g45_caps; -/* -* Try to find the NFC subnode and extract the associated caps -* from there. -*/ - np =of_find_compatible_node (userdev->of_node,NULL , -"atmel,sama5d3-nfc" ); -if (np) { -const struct of_device_id *match; - - match =of_match_node (atmel_pmecc_legacy_match, np); -if (match && match->data) - caps = match->data; - -of_node_put (np); - } +/* Find the caps associated to the NAND dev node. */ + match =of_match_node (atmel_pmecc_legacy_match, + userdev->of_node); +if (match && match->data) + caps = match->data; pmecc =atmel_pmecc_create (pdev, caps,1 ,2 ); }
Romain Izard
Tested-byHi Boris,
2017-07-17 20:20 GMT+02:00 Boris Brezillon <[email protected]>:
Quoted 83 lines
Le Mon, 17 Jul 2017 19:48:09 +0200,
Boris Brezillon <[email protected]> a ?crit :Quoted 23 lines
+Ludovic, Nicolas and Alexandre
Hi Romain,
Le Mon, 17 Jul 2017 18:11:26 +0200,
Romain Izard <[email protected]> a ?crit :Quoted 10 lines
Hello,
On a custom board based on Microchip's SAMA5D2 SoC, I am encountering ECC problems with the NAND Flash controller. The board is currently working with Linux v4.9.x, but it does not with Linux 4.12.
Some pages on the NAND Flash memory chip of the device have bitflips. With Linux 4.9.x, the bitflips are fixed by the PMECC code, but with Linux 4.12, the errors are reported as uncorrectable.
Quoted 5 lines
From my end, I updated the board's device tree to include the
sama5d2.dtsias it exists in Linux 4.12, but the rest of the file is the same as for Linux 4.9. From my understanding, it should be sufficient as the legacy DTB binding for the NAND controller is supported.Quoted 5 lines
I know Ludovic add some problems with the NAND controller on sama5d2, but it was with the new bindings (see the fixes here [1]).
Your problem seems a bit different since you're using the backward compat code.
Can you try with the following patch applied?
--->8---
Fromcb95a16cdd497137872c44d5dd4e251ec73c79c1Mon Sep 17 00:00:00 2001
From: Boris Brezillon <[email protected]>
Date: Mon, 17 Jul 2017 20:09:59 +0200
Subject: [PATCH] mtd: nand: atmel: Fix DT backward compatibility inpmecc.cPMECC caps extraction from old DT bindings is broken, thus leading to erroneous EL registers offset, which in turn make HW ECC unusable on sama5d2 when old bindings are in use.
Passing the NAND dev node instead of the NFC node to
of_match_node()solves the problem.Signed-off-by Boris Brezillon <[email protected]>Fixes f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand driver")Cc <[email protected]>--- drivers/mtd/nand/atmel/pmecc.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)drivers/mtd/nand/atmel/pmecc.c +1
-13@@ -945,6 +945,7 @@ struct atmel_pmecc *devm_atmel_pmecc_get(struct device *userdev)*/ struct platform_device *pdev =to_platform_device (userdev);const struct atmel_pmecc_caps *caps; +const struct of_device_id *match;/* No PMECC engine available. */ if (!of_property_read_bool(userdev->of_node,@@ -953,21 +954,11 @@ struct atmel_pmecc *devm_atmel_pmecc_get(struct device *userdev) caps = &at91sam9g45_caps; -/* -* Try to find the NFC subnode and extract the associated caps -* from there. -*/ - np =of_find_compatible_node (userdev->of_node,NULL , -"atmel,sama5d3-nfc" ); -if (np) { -const struct of_device_id *match; - - match =of_match_node (atmel_pmecc_legacy_match, np); -if (match && match->data) - caps = match->data; -
drivers/mtd/nand/atmel/pmecc.c struct atmel_pmecc *devm_atmel_pmecc_get(struct device *userdev) · line 964
Quoted 10 lines
drivers/mtd/nand/atmel/pmecc.c +5
-2-of_node_put (np); - } +/* Find the caps associated to the NAND dev node. */ + match =of_match_node (atmel_pmecc_legacy_match, + userdev->of_node); +if (match && match->data) + caps = match->data; pmecc =atmel_pmecc_create (pdev, caps,1 ,2 ); }
The proposed patch fixes my issue. Thank you for your quick response!
You can add my:
Best regards,
Signature · 1 line
Romain Izard
Boris Brezillon
AppliedQuoted 44 lines · On Mon, 17 Jul 2017 20:20:08 +0200 Boris Brezillon…
Le Mon, 17 Jul 2017 19:48:09 +0200,
Boris Brezillon <[email protected]> a ?crit :Quoted 23 lines
+Ludovic, Nicolas and Alexandre
Hi Romain,
Le Mon, 17 Jul 2017 18:11:26 +0200,
Romain Izard <[email protected]> a ?crit :Quoted 10 lines
Hello,
On a custom board based on Microchip's SAMA5D2 SoC, I am encountering ECC problems with the NAND Flash controller. The board is currently working with Linux v4.9.x, but it does not with Linux 4.12.
Some pages on the NAND Flash memory chip of the device have bitflips. With Linux 4.9.x, the bitflips are fixed by the PMECC code, but with Linux 4.12, the errors are reported as uncorrectable.
Quoted 5 lines
From my end, I updated the board's device tree to include the
sama5d2.dtsias it exists in Linux 4.12, but the rest of the file is the same as for Linux 4.9. From my understanding, it should be sufficient as the legacy DTB binding for the NAND controller is supported.Quoted 5 lines
I know Ludovic add some problems with the NAND controller on sama5d2, but it was with the new bindings (see the fixes here [1]).
Your problem seems a bit different since you're using the backward compat code.
Can you try with the following patch applied?
--->8---
Fromcb95a16cdd497137872c44d5dd4e251ec73c79c1Mon Sep 17 00:00:00 2001
From: Boris Brezillon <[email protected]>
Date: Mon, 17 Jul 2017 20:09:59 +0200
Subject: [PATCH] mtd: nand: atmel: Fix DT backward compatibility inpmecc.cPMECC caps extraction from old DT bindings is broken, thus leading to erroneous EL registers offset, which in turn make HW ECC unusable on sama5d2 when old bindings are in use.
Quoted 6 lines
Passing the NAND dev node instead of the NFC node to
of_match_node()solves the problem.Signed-off-by Boris Brezillon <[email protected]>Fixes f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand driver")Cc <[email protected]>
Applied to nand/fixes.
Quoted 47 lines
--- drivers/mtd/nand/atmel/pmecc.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)drivers/mtd/nand/atmel/pmecc.c +6
-15@@ -945,6 +945,7 @@ struct atmel_pmecc *devm_atmel_pmecc_get(struct device *userdev)*/ struct platform_device *pdev =to_platform_device (userdev);const struct atmel_pmecc_caps *caps; +const struct of_device_id *match;/* No PMECC engine available. */ if (!of_property_read_bool(userdev->of_node,@@ -953,21 +954,11 @@ struct atmel_pmecc *devm_atmel_pmecc_get(struct device *userdev) caps = &at91sam9g45_caps; -/* -* Try to find the NFC subnode and extract the associated caps -* from there. -*/ - np =of_find_compatible_node (userdev->of_node,NULL , -"atmel,sama5d3-nfc" ); -if (np) { -const struct of_device_id *match; - - match =of_match_node (atmel_pmecc_legacy_match, np); -if (match && match->data) - caps = match->data; - -of_node_put (np); - } +/* Find the caps associated to the NAND dev node. */ + match =of_match_node (atmel_pmecc_legacy_match, + userdev->of_node); +if (match && match->data) + caps = match->data; pmecc =atmel_pmecc_create (pdev, caps,1 ,2 ); }______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/