mtd: nand: raw: macronix: allow disabling block protection
Subsystems (3)
cover mtd: nand: raw: macronix: allow disabling block protection
Some devices hang when block protection is enabled, so let's add a boolean property to allow disabling it.
Álvaro Fernández Rojas (2):
dt-bindings: mtd: nand: Macronix: document new binding
mtd: nand: raw: macronix: allow disabling block protection
Documentation/devicetree/bindings/mtd/nand-macronix.txt | 3 +++ drivers/mtd/nand/raw/nand_macronix.c | 4 ++++ 2 files changed, 7 insertions(+)
Signature · 1 line
2.30.2
PATCH 1/2 dt-bindings: mtd: nand: Macronix: document new binding
Add new "mxic,disable-block-protection" binding documentation. This binding allows disabling block protection support for those devices not supporting it.
--- Documentation/devicetree/bindings/mtd/nand-macronix.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/mtd/nand-macronix.txt +3 -0
@@ -16,6 +16,9 @@ in children nodes. Required NAND chip properties in children mode: - randomizer enable: should be "mxic,enable-randomizer-otp" +Optional NAND chip properties in children mode: +- block protection disable: should be "mxic,disable-block-protection" + Example: nand: nand-controller@unit-address {
Signature · 1 line
2.30.2
Miquel Raynal
maintainerRe: [PATCH 1/2] dt-bindings: mtd: nand: Macronix: document new binding
Hi Álvaro,
[email protected] wrote on Thu, 23 Mar 2023 13:45:09 +0100:
Quoted 14 lines
Add new "mxic,disable-block-protection" binding documentation. This binding allows disabling block protection support for those devices not supporting it.
Signed-off-by Álvaro Fernández Rojas <[email protected]>--- Documentation/devicetree/bindings/mtd/nand-macronix.txt | 3 +++ 1 file changed, 3 insertions(+)Documentation/devicetree/bindings/mtd/nand-macronix.txt +0
-0
Documentation/devicetree/bindings/mtd/nand-macronix.txt in children nodes. · line 21
Quoted 6 lines
Documentation/devicetree/bindings/mtd/nand-macronix.txt +3
-0@@ -16,6 +16,9 @@ in children nodes. Required NAND chip properties in children mode: - randomizer enable: should be "mxic,enable-randomizer-otp" +Optional NAND chip properties in children mode: +- block protection disable: should be "mxic,disable-block-protection" +
Besides the fact that nowadays we prefer to see binding conversions to yaml before adding anything, I don't think this will fly.
I'm not sure exactly what "disable block protection" means, we already have similar properties like "lock" and "secure-regions", not sure they will fit but I think it's worth checking.
Otherwise, why would you disable the block protection? What does it mean exactly? I'm not in favor of a Macronix-specific property here.
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 1/2] dt-bindings: mtd: nand: Macronix: document new binding
Hi Miquèl,
Quoted 29 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Thu, 23 Mar 2023 13:45:09 +0100:
Quoted 14 lines
Add new "mxic,disable-block-protection" binding documentation. This binding allows disabling block protection support for those devices not supporting it.
Signed-off-by Álvaro Fernández Rojas <[email protected]>--- Documentation/devicetree/bindings/mtd/nand-macronix.txt | 3 +++ 1 file changed, 3 insertions(+)Documentation/devicetree/bindings/mtd/nand-macronix.txt +0
-0Documentation/devicetree/bindings/mtd/nand-macronix.txt in children nodes. · line 21
Quoted 6 lines
Documentation/devicetree/bindings/mtd/nand-macronix.txt +3
-0@@ -16,6 +16,9 @@ in children nodes. Required NAND chip properties in children mode: - randomizer enable: should be "mxic,enable-randomizer-otp" +Optional NAND chip properties in children mode: +- block protection disable: should be "mxic,disable-block-protection" +Besides the fact that nowadays we prefer to see binding conversions to yaml before adding anything, I don't think this will fly.
Quoted 3 lines
I'm not sure exactly what "disable block protection" means, we already have similar properties like "lock" and "secure-regions", not sure they will fit but I think it's worth checking.
As explained in 2/2, commit 03a539c7a118 introduced a regression on Sercomm H500-s (BCM63268) OpenWrt devices with Macronix MX30LF1G18AC which hangs the device.
This is the log with block protection disabled:
[ 0.495831] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504995] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.511526] nand: Macronix MX30LF1G18AC [ 0.515586] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523516] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.535912] Bad block table found at page 65472, version 0x01 [ 0.544268] Bad block table found at page 65408, version 0x01 [ 0.954329] 9 fixed-partitions partitions found on MTD device brcmnand.0
...
This is the log with block protection enabled:
[ 0.495095] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504249] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.510772] nand: Macronix MX30LF1G18AC [ 0.514874] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.522780] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.539687] Bad block table not found for chip 0 [ 0.550153] Bad block table not found for chip 0 [ 0.555069] Scanning device for bad blocks [ 0.601213] CPU 1 Unable to handle kernel paging request at virtual
address 10277f00, epc == 8039ce70, ra == 8016ad50
*** Device hangs ***
Enabling macronix_nand_block_protection_support() makes the device unable to detect the bad block table and hangs it when trying to scan for bad blocks.
Quoted 6 lines
Otherwise, why would you disable the block protection? What does it mean exactly? I'm not in favor of a Macronix-specific property here.
Thanks,
Miquèl
--
Álvaro
Miquel Raynal
maintainerRe: [PATCH 1/2] dt-bindings: mtd: nand: Macronix: document new binding
Hi Álvaro,
[email protected] wrote on Fri, 24 Mar 2023 11:31:17 +0100:
Quoted 68 lines
Hi Miquèl,
Quoted 29 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Thu, 23 Mar 2023 13:45:09 +0100:
Quoted 14 lines
Add new "mxic,disable-block-protection" binding documentation. This binding allows disabling block protection support for those devices not supporting it.
Signed-off-by Álvaro Fernández Rojas <[email protected]>--- Documentation/devicetree/bindings/mtd/nand-macronix.txt | 3 +++ 1 file changed, 3 insertions(+)Documentation/devicetree/bindings/mtd/nand-macronix.txt +0
-0Documentation/devicetree/bindings/mtd/nand-macronix.txt in children nodes. · line 21
Quoted 6 lines
Documentation/devicetree/bindings/mtd/nand-macronix.txt +3
-0@@ -16,6 +16,9 @@ in children nodes. Required NAND chip properties in children mode: - randomizer enable: should be "mxic,enable-randomizer-otp" +Optional NAND chip properties in children mode: +- block protection disable: should be "mxic,disable-block-protection" +Besides the fact that nowadays we prefer to see binding conversions to yaml before adding anything, I don't think this will fly.
Quoted 3 lines
I'm not sure exactly what "disable block protection" means, we already have similar properties like "lock" and "secure-regions", not sure they will fit but I think it's worth checking.
As explained in 2/2, commit
03a539c7a118introduced a regression on Sercomm H500-s (BCM63268) OpenWrt devices with Macronix MX30LF1G18AC which hangs the device.This is the log with block protection disabled:
[ 0.495831] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504995] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.511526] nand: Macronix MX30LF1G18AC [ 0.515586] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523516] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.535912] Bad block table found at page 65472, version 0x01 [ 0.544268] Bad block table found at page 65408, version 0x01 [ 0.954329] 9 fixed-partitions partitions found on MTD device brcmnand.0...
This is the log with block protection enabled:
[ 0.495095] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504249] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.510772] nand: Macronix MX30LF1G18AC [ 0.514874] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.522780] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.539687] Bad block table not found for chip 0 [ 0.550153] Bad block table not found for chip 0 [ 0.555069] Scanning device for bad blocks [ 0.601213] CPU 1 Unable to handle kernel paging request at virtual
Quoted 6 lines
address
10277f00, epc ==8039ce70, ra ==8016ad50
*** Device hangs ***Enabling
macronix_nand_block_protection_support()makes the device unable to detect the bad block table and hangs it when trying to scan for bad blocks.
Please trace nand_macronix.c and look:
- are the get_features and set_features really supported by the controller driver?
- what is the state of the locking configuration in the chip when you boot?
- is there anything that locks the device by calling mxic_nand_lock() ?
- finding no bbt is one thing, hanging is another, where is it hanging exactly? (offset in nand/ and line in the code)
Quoted 10 lines
Quoted 7 lines
Otherwise, why would you disable the block protection? What does it mean exactly? I'm not in favor of a Macronix-specific property here.
Thanks,
Miquèl--
Álvaro
Thanks,
Miquèl
Re: [PATCH 1/2] dt-bindings: mtd: nand: Macronix: document new binding
Quoted 76 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Fri, 24 Mar 2023 11:31:17 +0100:
Quoted 71 lines
Hi Miquèl,
Quoted 29 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Thu, 23 Mar 2023 13:45:09 +0100:
Quoted 14 lines
Add new "mxic,disable-block-protection" binding documentation. This binding allows disabling block protection support for those devices not supporting it.
Signed-off-by Álvaro Fernández Rojas <[email protected]>--- Documentation/devicetree/bindings/mtd/nand-macronix.txt | 3 +++ 1 file changed, 3 insertions(+)Documentation/devicetree/bindings/mtd/nand-macronix.txt +0
-0Documentation/devicetree/bindings/mtd/nand-macronix.txt in children nodes. · line 21
Quoted 6 lines
Documentation/devicetree/bindings/mtd/nand-macronix.txt +3
-0@@ -16,6 +16,9 @@ in children nodes. Required NAND chip properties in children mode: - randomizer enable: should be "mxic,enable-randomizer-otp" +Optional NAND chip properties in children mode: +- block protection disable: should be "mxic,disable-block-protection" +Besides the fact that nowadays we prefer to see binding conversions to yaml before adding anything, I don't think this will fly.
Quoted 3 lines
I'm not sure exactly what "disable block protection" means, we already have similar properties like "lock" and "secure-regions", not sure they will fit but I think it's worth checking.
As explained in 2/2, commit
03a539c7a118introduced a regression on Sercomm H500-s (BCM63268) OpenWrt devices with Macronix MX30LF1G18AC which hangs the device.This is the log with block protection disabled:
[ 0.495831] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504995] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.511526] nand: Macronix MX30LF1G18AC [ 0.515586] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523516] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.535912] Bad block table found at page 65472, version 0x01 [ 0.544268] Bad block table found at page 65408, version 0x01 [ 0.954329] 9 fixed-partitions partitions found on MTD device brcmnand.0...
This is the log with block protection enabled:
[ 0.495095] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504249] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.510772] nand: Macronix MX30LF1G18AC [ 0.514874] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.522780] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.539687] Bad block table not found for chip 0 [ 0.550153] Bad block table not found for chip 0 [ 0.555069] Scanning device for bad blocks [ 0.601213] CPU 1 Unable to handle kernel paging request at virtualaddress
10277f00, epc ==8039ce70, ra ==8016ad50
*** Device hangs ***
Quoted 7 lines
Quoted 3 lines
Enabling
macronix_nand_block_protection_support()makes the device unable to detect the bad block table and hangs it when trying to scan for bad blocks.Please trace
nand_macronix.cand look:
- are theget_featuresandset_featuresreally supported by the controller driver?
This is what I could find by debugging:
[ 0.494993] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.505375] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.512077] nand: Macronix MX30LF1G18AC [ 0.515994] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523928] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.534415] bcm6368_nand 10000200.nand: ll_op cmd 0xa00ee [ 0.539988] bcm6368_nand 10000200.nand: ll_op cmd 0x600a0 [ 0.545659] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.551214] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.557843] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.563475] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.569998] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.575653] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.582246] bcm6368_nand 10000200.nand: ll_op cmd 0x80010000 [ 0.588067] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.594657] nand: nand_get_features: addr=a0 subfeature_param=[00 00 00 00] -> 0 [ 0.602341] macronix_nand_block_protection_support: ONFI_FEATURE_ADDR_MXIC_PROTECTION=0 [ 0.610548] macronix_nand_block_protection_support: != MXIC_BLOCK_PROTECTION_ALL_LOCK [ 0.624760] Bad block table not found for chip 0 [ 0.635542] Bad block table not found for chip 0 [ 0.640270] Scanning device for bad blocks
I don't know how to tell if get_features / set_features is really supported...
Quoted 2 lines
- what is the state of the locking configuration in the chip when you boot?
Unlocked, I guess...
How can I check that?
Quoted 3 lines
- is there anything that locks the device by calling
mxic_nand_lock()?
- finding no bbt is one thing, hanging is another, where is it hanging exactly? (offset in nand/ and line in the code)
I've got no idea...
Quoted 15 lines
Quoted 11 lines
Quoted 8 lines
Otherwise, why would you disable the block protection? What does it mean exactly? I'm not in favor of a Macronix-specific property here.
Thanks,
Miquèl--
ÁlvaroThanks,
Miquèl
Miquel Raynal
maintainerRe: [PATCH 1/2] dt-bindings: mtd: nand: Macronix: document new binding
Hi Álvaro,
[email protected] wrote on Fri, 24 Mar 2023 12:21:11 +0100:
Quoted 115 lines
Quoted 76 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Fri, 24 Mar 2023 11:31:17 +0100:
Quoted 71 lines
Hi Miquèl,
Quoted 29 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Thu, 23 Mar 2023 13:45:09 +0100:
Quoted 14 lines
Add new "mxic,disable-block-protection" binding documentation. This binding allows disabling block protection support for those devices not supporting it.
Signed-off-by Álvaro Fernández Rojas <[email protected]>--- Documentation/devicetree/bindings/mtd/nand-macronix.txt | 3 +++ 1 file changed, 3 insertions(+)Documentation/devicetree/bindings/mtd/nand-macronix.txt +0
-0Documentation/devicetree/bindings/mtd/nand-macronix.txt in children nodes. · line 21
Quoted 6 lines
Documentation/devicetree/bindings/mtd/nand-macronix.txt +3
-0@@ -16,6 +16,9 @@ in children nodes. Required NAND chip properties in children mode: - randomizer enable: should be "mxic,enable-randomizer-otp" +Optional NAND chip properties in children mode: +- block protection disable: should be "mxic,disable-block-protection" +Besides the fact that nowadays we prefer to see binding conversions to yaml before adding anything, I don't think this will fly.
Quoted 3 lines
I'm not sure exactly what "disable block protection" means, we already have similar properties like "lock" and "secure-regions", not sure they will fit but I think it's worth checking.
As explained in 2/2, commit
03a539c7a118introduced a regression on Sercomm H500-s (BCM63268) OpenWrt devices with Macronix MX30LF1G18AC which hangs the device.This is the log with block protection disabled:
[ 0.495831] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504995] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.511526] nand: Macronix MX30LF1G18AC [ 0.515586] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523516] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.535912] Bad block table found at page 65472, version 0x01 [ 0.544268] Bad block table found at page 65408, version 0x01 [ 0.954329] 9 fixed-partitions partitions found on MTD device brcmnand.0...
This is the log with block protection enabled:
[ 0.495095] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504249] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.510772] nand: Macronix MX30LF1G18AC [ 0.514874] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.522780] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.539687] Bad block table not found for chip 0 [ 0.550153] Bad block table not found for chip 0 [ 0.555069] Scanning device for bad blocks [ 0.601213] CPU 1 Unable to handle kernel paging request at virtualaddress
10277f00, epc ==8039ce70, ra ==8016ad50
*** Device hangs ***Quoted 7 lines
Quoted 3 lines
Enabling
macronix_nand_block_protection_support()makes the device unable to detect the bad block table and hangs it when trying to scan for bad blocks.Please trace
nand_macronix.cand look:
- are theget_featuresandset_featuresreally supported by the controller driver?This is what I could find by debugging:
[ 0.494993] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.505375] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.512077] nand: Macronix MX30LF1G18AC [ 0.515994] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523928] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.534415] bcm6368_nand 10000200.nand: ll_op cmd 0xa00ee [ 0.539988] bcm6368_nand 10000200.nand: ll_op cmd 0x600a0 [ 0.545659] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.551214] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.557843] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.563475] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.569998] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.575653] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.582246] bcm6368_nand 10000200.nand: ll_op cmd 0x80010000 [ 0.588067] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.594657] nand: nand_get_features: addr=a0 subfeature_param=[00 00 00 00] -> 0 [ 0.602341] macronix_nand_block_protection_support: ONFI_FEATURE_ADDR_MXIC_PROTECTION=0 [ 0.610548] macronix_nand_block_protection_support: != MXIC_BLOCK_PROTECTION_ALL_LOCK [ 0.624760] Bad block table not found for chip 0 [ 0.635542] Bad block table not found for chip 0 [ 0.640270] Scanning device for bad blocks
Quoted 1 line
I don't know how to tell if
get_features/set_featuresis really supported...
Looks like your driver does not support exec_op but the core provides a get/set_feature implementation.
Quoted 6 lines
Quoted 3 lines
- what is the state of the locking configuration in the chip when you boot?
Unlocked, I guess...
How can I check that?
It's in your dump, the chip returns 0, meaning it's all unlocked, apparently.
Quoted 1 line
Quoted 1 line
- is there anything that locks the device by calling
mxic_nand_lock()?
So nobody locks the device I guess? Did you add traces there?
Quoted 4 lines
Quoted 2 lines
- finding no bbt is one thing, hanging is another, where is it hanging exactly? (offset in nand/ and line in the code)
I've got no idea...
You can use ftrace or just add printks a bit everywhere and try to get closer and closer.
I looked at the patch, I don't see anything strange. Besides, I have a close enough datasheet and I don't see what could confuse the device.
Are you really sure this patch is the problem? Is the WP pin wired on your design?
Thanks,
Miquèl
Re: [PATCH 1/2] dt-bindings: mtd: nand: Macronix: document new binding
Hi Miquèl,
2023-03-24 14:45 GMT+01:00, Miquel Raynal <[email protected]>:
Quoted 131 lines
Hi Álvaro,
[email protected] wrote on Fri, 24 Mar 2023 12:21:11 +0100:
Quoted 127 lines
Quoted 88 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Fri, 24 Mar 2023 11:31:17 +0100:
Quoted 83 lines
Hi Miquèl,
Quoted 34 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Thu, 23 Mar 2023 13:45:09 +0100:
Quoted 22 lines
Add new "mxic,disable-block-protection" binding documentation. This binding allows disabling block protection support for those devices not
supporting it.Signed-off-by Álvaro Fernández Rojas <[email protected]>--- Documentation/devicetree/bindings/mtd/nand-macronix.txt | 3 +++ 1 file changed, 3 insertions(+)diff --git
a/Documentation/devicetree/bindings/mtd/nand-macronix.txtb/Documentation/devicetree/bindings/mtd/nand-macronix.txtindexffab28a2c4d1..03f65ca32cd3100644Documentation/devicetree/bindings/mtd/nand-macronix.txt +2
-0@@ -16,6 +16,9 @@ in children nodes. Required NAND chip properties in children mode: - randomizer enable: should be "mxic,enable-randomizer-otp" +Optional NAND chip properties in children mode: +- block protection disable: should beQuoted 2 lines
"mxic,disable-block-protection"
+Besides the fact that nowadays we prefer to see binding conversions to
yaml before adding anything, I don't think this will fly.Quoted 4 lines
I'm not sure exactly what "disable block protection" means, we already have similar properties like "lock" and "secure-regions", not
sure they will fit but I think it's worth checking.As explained in 2/2, commit
03a539c7a118introduced a regression on Sercomm H500-s (BCM63268) OpenWrt devices with Macronix MX30LF1G18AC which hangs the device.This is the log with block protection disabled:
[ 0.495831] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504995] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.511526] nand: Macronix MX30LF1G18AC [ 0.515586] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523516] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.535912] Bad block table found at page 65472, version 0x01 [ 0.544268] Bad block table found at page 65408, version 0x01 [ 0.954329] 9 fixed-partitions partitions found on MTD devicebrcmnand.0
...This is the log with block protection enabled:
[ 0.495095] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504249] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.510772] nand: Macronix MX30LF1G18AC [ 0.514874] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.522780] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.539687] Bad block table not found for chip 0 [ 0.550153] Bad block table not found for chip 0 [ 0.555069] Scanning device for bad blocks [ 0.601213] CPU 1 Unable to handle kernel paging request atvirtual
address10277f00, epc ==8039ce70, ra ==8016ad50
*** Device hangs ***Quoted 7 lines
Quoted 3 lines
Enabling
macronix_nand_block_protection_support()makes the device unable to detect the bad block table and hangs it when trying to scan for bad blocks.Please trace
nand_macronix.cand look:
- are theget_featuresandset_featuresreally supported by the controller driver?This is what I could find by debugging:
[ 0.494993] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.505375] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.512077] nand: Macronix MX30LF1G18AC [ 0.515994] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523928] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.534415] bcm6368_nand 10000200.nand: ll_op cmd 0xa00ee [ 0.539988] bcm6368_nand 10000200.nand: ll_op cmd 0x600a0 [ 0.545659] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.551214] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.557843] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.563475] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.569998] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.575653] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.582246] bcm6368_nand 10000200.nand: ll_op cmd 0x80010000 [ 0.588067] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.594657] nand: nand_get_features: addr=a0 subfeature_param=[00 00 00 00] -> 0 [ 0.602341] macronix_nand_block_protection_support: ONFI_FEATURE_ADDR_MXIC_PROTECTION=0 [ 0.610548] macronix_nand_block_protection_support: != MXIC_BLOCK_PROTECTION_ALL_LOCK [ 0.624760] Bad block table not found for chip 0 [ 0.635542] Bad block table not found for chip 0 [ 0.640270] Scanning device for bad blocks
Quoted 5 lines
Quoted 2 lines
I don't know how to tell if
get_features/set_featuresis really supported...Looks like your driver does not support
exec_opbut the core provides a get/set_feature implementation.
According to Florian, low level should be supported on brcmnand controllers >= 4.0
Also:
https://github.com/nomis/bcm963xx_4.12L.06B_consumer/blob/e2f23ddbb20bf75689372b6e6a5a0dc613f6e313/shared/opensource/include/bcm963xx/63268_map_part.h#L1597
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines
- what is the state of the locking configuration in the chip when you boot?
Unlocked, I guess...
How can I check that?It's in your dump, the chip returns 0, meaning it's all unlocked, apparently.
Well, I can read/write the device if block protection isn’t disabled, so I guess we can confirm it’s unlocked…
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
- is there anything that locks the device by calling
mxic_nand_lock()?So nobody locks the device I guess? Did you add traces there?
It doesn’t get to the point that it enabled the lock/unlock functions since it fails when checking if feature is 0x38, so there’s no point in adding those traces…
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
- finding no bbt is one thing, hanging is another, where is it hanging exactly? (offset in nand/ and line in the code)
I've got no idea...
You can use ftrace or just add printks a bit everywhere and try to get closer and closer.
I think that after trying to get the feature it just start reading nonsense from the NAND and at some point it hangs due to that garbage… Is it posible that the NAND starts behaving like this after getting the feature due to some specific config of my device?
Quoted 6 lines
I looked at the patch, I don't see anything strange. Besides, I have a close enough datasheet and I don't see what could confuse the device.
Are you really sure this patch is the problem? Is the WP pin wired on your design?
There’s no WP pin in brcmnand controllers < 7.0
Quoted 4 lines
Thanks,
Miquèl
Thanks,
Álvaro
Miquel Raynal
maintainerRe: [PATCH 1/2] dt-bindings: mtd: nand: Macronix: document new binding
Hi Álvaro,
+ YouChing and Jaime from Macronix
TLDR for them: there is a misbehavior since Mason added block protection support. Just checking if the blocks are protected seems to misconfigure the chip entirely, see below. Any hints?
[email protected] wrote on Fri, 24 Mar 2023 15:15:47 +0100:
Quoted 137 lines
Hi Miquèl,
2023-03-24 14:45 GMT+01:00, Miquel Raynal <[email protected]>:
Quoted 134 lines
Hi Álvaro,
[email protected] wrote on Fri, 24 Mar 2023 12:21:11 +0100:
Quoted 129 lines
Quoted 88 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Fri, 24 Mar 2023 11:31:17 +0100:
Quoted 83 lines
Hi Miquèl,
Quoted 34 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Thu, 23 Mar 2023 13:45:09 +0100:
Quoted 22 lines
Add new "mxic,disable-block-protection" binding documentation. This binding allows disabling block protection support for those devices not
supporting it.Signed-off-by Álvaro Fernández Rojas <[email protected]>--- Documentation/devicetree/bindings/mtd/nand-macronix.txt | 3 +++ 1 file changed, 3 insertions(+)diff --git
a/Documentation/devicetree/bindings/mtd/nand-macronix.txtb/Documentation/devicetree/bindings/mtd/nand-macronix.txtindexffab28a2c4d1..03f65ca32cd3100644Documentation/devicetree/bindings/mtd/nand-macronix.txt +2
-0@@ -16,6 +16,9 @@ in children nodes. Required NAND chip properties in children mode: - randomizer enable: should be "mxic,enable-randomizer-otp" +Optional NAND chip properties in children mode: +- block protection disable: should beQuoted 2 lines
"mxic,disable-block-protection"
+Besides the fact that nowadays we prefer to see binding conversions to
yaml before adding anything, I don't think this will fly.Quoted 4 lines
I'm not sure exactly what "disable block protection" means, we already have similar properties like "lock" and "secure-regions", not
sure they will fit but I think it's worth checking.As explained in 2/2, commit
03a539c7a118introduced a regression on Sercomm H500-s (BCM63268) OpenWrt devices with Macronix MX30LF1G18AC which hangs the device.This is the log with block protection disabled:
[ 0.495831] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504995] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.511526] nand: Macronix MX30LF1G18AC [ 0.515586] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523516] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.535912] Bad block table found at page 65472, version 0x01 [ 0.544268] Bad block table found at page 65408, version 0x01 [ 0.954329] 9 fixed-partitions partitions found on MTD devicebrcmnand.0
...This is the log with block protection enabled:
[ 0.495095] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504249] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.510772] nand: Macronix MX30LF1G18AC [ 0.514874] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.522780] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.539687] Bad block table not found for chip 0 [ 0.550153] Bad block table not found for chip 0 [ 0.555069] Scanning device for bad blocks [ 0.601213] CPU 1 Unable to handle kernel paging request atvirtual
address10277f00, epc ==8039ce70, ra ==8016ad50
*** Device hangs ***Quoted 7 lines
Quoted 3 lines
Enabling
macronix_nand_block_protection_support()makes the device unable to detect the bad block table and hangs it when trying to scan for bad blocks.Please trace
nand_macronix.cand look:
- are theget_featuresandset_featuresreally supported by the controller driver?This is what I could find by debugging:
[ 0.494993] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.505375] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.512077] nand: Macronix MX30LF1G18AC [ 0.515994] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523928] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.534415] bcm6368_nand 10000200.nand: ll_op cmd 0xa00ee [ 0.539988] bcm6368_nand 10000200.nand: ll_op cmd 0x600a0 [ 0.545659] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.551214] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.557843] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.563475] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.569998] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.575653] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.582246] bcm6368_nand 10000200.nand: ll_op cmd 0x80010000 [ 0.588067] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.594657] nand: nand_get_features: addr=a0 subfeature_param=[00 00 00 00] -> 0 [ 0.602341] macronix_nand_block_protection_support: ONFI_FEATURE_ADDR_MXIC_PROTECTION=0 [ 0.610548] macronix_nand_block_protection_support: != MXIC_BLOCK_PROTECTION_ALL_LOCK [ 0.624760] Bad block table not found for chip 0 [ 0.635542] Bad block table not found for chip 0 [ 0.640270] Scanning device for bad blocksI don't know how to tell if
get_features/set_featuresis really supported...
Quoted 7 lines
Quoted 2 lines
Looks like your driver does not support
exec_opbut the core provides a get/set_feature implementation.According to Florian, low level should be supported on brcmnand controllers >= 4.0
Also:
https://github.com/nomis/bcm963xx_4.12L.06B_consumer/blob/e2f23ddbb20bf75689372b6e6a5a0dc613f6e313/shared/opensource/include/bcm963xx/63268_map_part.h#L1597
Just to be sure, you're using a mainline controller driver, not this one?
Quoted 15 lines
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines
- what is the state of the locking configuration in the chip when you boot?
Unlocked, I guess...
How can I check that?It's in your dump, the chip returns 0, meaning it's all unlocked, apparently.
Well, I can read/write the device if block protection isn’t disabled, so I guess we can confirm it’s unlocked…
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
- is there anything that locks the device by calling
mxic_nand_lock()?So nobody locks the device I guess? Did you add traces there?
It doesn’t get to the point that it enabled the lock/unlock functions since it fails when checking if feature is
0x38, so there’s no point in adding those traces…
Right, it returns before setting these I guess.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
- finding no bbt is one thing, hanging is another, where is it hanging exactly? (offset in nand/ and line in the code)
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
I've got no idea...
You can use ftrace or just add printks a bit everywhere and try to get closer and closer.
I think that after trying to get the feature it just start reading nonsense from the NAND and at some point it hangs due to that garbage…
It should refuse to mount the device somehow, but in no case the kernel should hang.
Quoted 11 lines
Is it posible that the NAND starts behaving like this after getting the feature due to some specific config of my device?
Quoted 6 lines
I looked at the patch, I don't see anything strange. Besides, I have a close enough datasheet and I don't see what could confuse the device.
Are you really sure this patch is the problem? Is the WP pin wired on your design?
There’s no WP pin in brcmnand controllers < 7.0
What about the chip?
Thanks,
Miquèl
Re: [PATCH 1/2] dt-bindings: mtd: nand: Macronix: document new binding
Hi Miquèl,
2023-03-24 15:36 GMT+01:00, Miquel Raynal <[email protected]>:
Quoted 6 lines
Hi Álvaro,
+ YouChing and Jaime from Macronix
TLDR for them: there is a misbehavior since Mason added block protection support. Just checking if the blocks are protected seems to misconfigure the chip entirely, see below. Any hints?
Could it be that the NAND is stuck expecting a read 0x00 command which isn’t sent after getting the features?
Quoted 155 lines
[email protected] wrote on Fri, 24 Mar 2023 15:15:47 +0100:
Quoted 152 lines
Hi Miquèl,
2023-03-24 14:45 GMT+01:00, Miquel Raynal <[email protected]>:
Quoted 148 lines
Hi Álvaro,
[email protected] wrote on Fri, 24 Mar 2023 12:21:11 +0100:
Quoted 139 lines
Quoted 94 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Fri, 24 Mar 2023 11:31:17 +0100:
Quoted 89 lines
Hi Miquèl,
Quoted 37 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Thu, 23 Mar 2023 13:45:09 +0100:
Quoted 24 lines
Add new "mxic,disable-block-protection" binding documentation. This binding allows disabling block protection support for those
devices not
supporting it.Signed-off-by Álvaro Fernández Rojas <[email protected]>--- Documentation/devicetree/bindings/mtd/nand-macronix.txt | 3 +++ 1 file changed, 3 insertions(+)diff --git
a/Documentation/devicetree/bindings/mtd/nand-macronix.txtb/Documentation/devicetree/bindings/mtd/nand-macronix.txtindexffab28a2c4d1..03f65ca32cd3100644Documentation/devicetree/bindings/mtd/nand-macronix.txt +2
-0@@ -16,6 +16,9 @@ in children nodes. Required NAND chip properties in children mode: - randomizer enable: should be "mxic,enable-randomizer-otp" +Optional NAND chip properties in children mode: +- block protection disable: should beQuoted 2 lines
"mxic,disable-block-protection"
+Besides the fact that nowadays we prefer to see binding conversions
to
yaml before adding anything, I don't think this will fly.Quoted 5 lines
I'm not sure exactly what "disable block protection" means, we already have similar properties like "lock" and "secure-regions",
not
sure they will fit but I think it's worth checking.As explained in 2/2, commit
03a539c7a118introduced a regression on
Sercomm H500-s (BCM63268) OpenWrt devices with Macronix MX30LF1G18AC
which hangs the device.This is the log with block protection disabled:
[ 0.495831] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504995] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.511526] nand: Macronix MX30LF1G18AC [ 0.515586] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523516] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.535912] Bad block table found at page 65472, version 0x01 [ 0.544268] Bad block table found at page 65408, version 0x01 [ 0.954329] 9 fixed-partitions partitions found on MTD devicebrcmnand.0
...This is the log with block protection enabled:
[ 0.495095] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504249] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.510772] nand: Macronix MX30LF1G18AC [ 0.514874] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.522780] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.539687] Bad block table not found for chip 0 [ 0.550153] Bad block table not found for chip 0 [ 0.555069] Scanning device for bad blocks [ 0.601213] CPU 1 Unable to handle kernel paging request atvirtual
address10277f00, epc ==8039ce70, ra ==8016ad50
*** Device hangs ***Quoted 8 lines
Quoted 4 lines
Enabling
macronix_nand_block_protection_support()makes the device unable to detect the bad block table and hangs it when trying to scan
for bad blocks.Please trace
nand_macronix.cand look:
- are theget_featuresandset_featuresreally supported by the controller driver?This is what I could find by debugging:
[ 0.494993] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.505375] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.512077] nand: Macronix MX30LF1G18AC [ 0.515994] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523928] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.534415] bcm6368_nand 10000200.nand: ll_op cmd 0xa00ee [ 0.539988] bcm6368_nand 10000200.nand: ll_op cmd 0x600a0 [ 0.545659] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.551214] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.557843] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.563475] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.569998] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.575653] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.582246] bcm6368_nand 10000200.nand: ll_op cmd 0x80010000 [ 0.588067] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.594657] nand: nand_get_features: addr=a0 subfeature_param=[00 00 00 00] -> 0 [ 0.602341] macronix_nand_block_protection_support: ONFI_FEATURE_ADDR_MXIC_PROTECTION=0 [ 0.610548] macronix_nand_block_protection_support: != MXIC_BLOCK_PROTECTION_ALL_LOCK [ 0.624760] Bad block table not found for chip 0 [ 0.635542] Bad block table not found for chip 0 [ 0.640270] Scanning device for bad blocksQuoted 2 lines
I don't know how to tell if
get_features/set_featuresis really supported...Looks like your driver does not support
exec_opbut the core provides a get/set_feature implementation.
Quoted 7 lines
Quoted 4 lines
According to Florian, low level should be supported on brcmnand controllers >= 4.0
Also:
https://github.com/nomis/bcm963xx_4.12L.06B_consumer/blob/e2f23ddbb20bf75689372b6e6a5a0dc613f6e313/shared/opensource/include/bcm963xx/63268_map_part.h#L1597Just to be sure, you're using a mainline controller driver, not this one?
Yes, this was just to prove that the HW I’m using has get/set features support. I’m using OpenWrt, so it’s linux v5.15 driver.
Quoted 36 lines
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
- what is the state of the locking configuration in the chip when you
boot?Quoted 5 lines
Quoted 2 lines
Unlocked, I guess...
How can I check that?It's in your dump, the chip returns 0, meaning it's all unlocked, apparently.
Well, I can read/write the device if block protection isn’t disabled, so I guess we can confirm it’s unlocked…
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
- is there anything that locks the device by calling
mxic_nand_lock()?So nobody locks the device I guess? Did you add traces there?
It doesn’t get to the point that it enabled the lock/unlock functions since it fails when checking if feature is
0x38, so there’s no point in adding those traces…Right, it returns before setting these I guess.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
- finding no bbt is one thing, hanging is another, where is it hanging
exactly? (offset in nand/ and line in the code)I've got no idea...
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
You can use ftrace or just add printks a bit everywhere and try to get closer and closer.
I think that after trying to get the feature it just start reading nonsense from the NAND and at some point it hangs due to that garbage…
It should refuse to mount the device somehow, but in no case the kernel should hang.
Yes, I think that this is a side effect (maybe a different bug somewhere else).
Quoted 8 lines
Quoted 8 lines
Is it posible that the NAND starts behaving like this after getting the feature due to some specific config of my device?
Quoted 4 lines
I looked at the patch, I don't see anything strange. Besides, I have a close enough datasheet and I don't see what could confuse the device.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Are you really sure this patch is the problem? Is the WP pin wired on your design?
There’s no WP pin in brcmnand controllers < 7.0
What about the chip?
Maybe it has a GPIO controlling that, but I don’t have that info…
Quoted 4 lines
Thanks,
Miquèl
Miquel Raynal
maintainerRe: [PATCH 1/2] dt-bindings: mtd: nand: Macronix: document new binding
Hi Álvaro,
[email protected] wrote on Fri, 24 Mar 2023 18:04:38 +0100:
Quoted 5 lines
Hi Miquèl,
2023-03-24 15:36 GMT+01:00, Miquel Raynal <[email protected]>:
Quoted 2 lines
Hi Álvaro,
Quoted 7 lines
Quoted 4 lines
+ YouChing and Jaime from Macronix
TLDR for them: there is a misbehavior since Mason added block protection support. Just checking if the blocks are protected seems to misconfigure the chip entirely, see below. Any hints?Could it be that the NAND is stuck expecting a read
0x00command which isn’t sent after getting the features?
I have no idea, please try that, you can manually generate a READ0 by hacking an existing read helper.
Quoted 159 lines
Quoted 159 lines
[email protected] wrote on Fri, 24 Mar 2023 15:15:47 +0100:
Quoted 156 lines
Hi Miquèl,
2023-03-24 14:45 GMT+01:00, Miquel Raynal <[email protected]>:
Quoted 143 lines
Hi Álvaro,
[email protected] wrote on Fri, 24 Mar 2023 12:21:11 +0100:
Quoted 139 lines
Quoted 94 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Fri, 24 Mar 2023 11:31:17 +0100:
Quoted 89 lines
Hi Miquèl,
Quoted 37 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Thu, 23 Mar 2023 13:45:09 +0100:
Quoted 24 lines
Add new "mxic,disable-block-protection" binding documentation. This binding allows disabling block protection support for those
devices not
supporting it.Signed-off-by Álvaro Fernández Rojas <[email protected]>--- Documentation/devicetree/bindings/mtd/nand-macronix.txt | 3 +++ 1 file changed, 3 insertions(+)diff --git
a/Documentation/devicetree/bindings/mtd/nand-macronix.txtb/Documentation/devicetree/bindings/mtd/nand-macronix.txtindexffab28a2c4d1..03f65ca32cd3100644Documentation/devicetree/bindings/mtd/nand-macronix.txt +2
-0@@ -16,6 +16,9 @@ in children nodes. Required NAND chip properties in children mode: - randomizer enable: should be "mxic,enable-randomizer-otp" +Optional NAND chip properties in children mode: +- block protection disable: should beQuoted 2 lines
"mxic,disable-block-protection"
+Besides the fact that nowadays we prefer to see binding conversions
to
yaml before adding anything, I don't think this will fly.Quoted 5 lines
I'm not sure exactly what "disable block protection" means, we already have similar properties like "lock" and "secure-regions",
not
sure they will fit but I think it's worth checking.As explained in 2/2, commit
03a539c7a118introduced a regression on
Sercomm H500-s (BCM63268) OpenWrt devices with Macronix MX30LF1G18AC
which hangs the device.This is the log with block protection disabled:
[ 0.495831] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504995] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.511526] nand: Macronix MX30LF1G18AC [ 0.515586] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523516] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.535912] Bad block table found at page 65472, version 0x01 [ 0.544268] Bad block table found at page 65408, version 0x01 [ 0.954329] 9 fixed-partitions partitions found on MTD devicebrcmnand.0
...This is the log with block protection enabled:
[ 0.495095] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504249] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.510772] nand: Macronix MX30LF1G18AC [ 0.514874] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.522780] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.539687] Bad block table not found for chip 0 [ 0.550153] Bad block table not found for chip 0 [ 0.555069] Scanning device for bad blocks [ 0.601213] CPU 1 Unable to handle kernel paging request atvirtual
address10277f00, epc ==8039ce70, ra ==8016ad50
*** Device hangs ***Quoted 8 lines
Quoted 4 lines
Enabling
macronix_nand_block_protection_support()makes the device unable to detect the bad block table and hangs it when trying to scan
for bad blocks.Please trace
nand_macronix.cand look:
- are theget_featuresandset_featuresreally supported by the controller driver?This is what I could find by debugging:
[ 0.494993] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.505375] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.512077] nand: Macronix MX30LF1G18AC [ 0.515994] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523928] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.534415] bcm6368_nand 10000200.nand: ll_op cmd 0xa00ee [ 0.539988] bcm6368_nand 10000200.nand: ll_op cmd 0x600a0 [ 0.545659] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.551214] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.557843] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.563475] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.569998] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.575653] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.582246] bcm6368_nand 10000200.nand: ll_op cmd 0x80010000 [ 0.588067] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.594657] nand: nand_get_features: addr=a0 subfeature_param=[00 00 00 00] -> 0 [ 0.602341] macronix_nand_block_protection_support: ONFI_FEATURE_ADDR_MXIC_PROTECTION=0 [ 0.610548] macronix_nand_block_protection_support: != MXIC_BLOCK_PROTECTION_ALL_LOCK [ 0.624760] Bad block table not found for chip 0 [ 0.635542] Bad block table not found for chip 0 [ 0.640270] Scanning device for bad blocksQuoted 5 lines
Quoted 2 lines
I don't know how to tell if
get_features/set_featuresis really supported...Looks like your driver does not support
exec_opbut the core provides a get/set_feature implementation.According to Florian, low level should be supported on brcmnand controllers >= 4.0
Also:
https://github.com/nomis/bcm963xx_4.12L.06B_consumer/blob/e2f23ddbb20bf75689372b6e6a5a0dc613f6e313/shared/opensource/include/bcm963xx/63268_map_part.h#L1597
Quoted 5 lines
Quoted 2 lines
Just to be sure, you're using a mainline controller driver, not this one?
Yes, this was just to prove that the HW I’m using has get/set features support. I’m using OpenWrt, so it’s linux v5.15 driver.
Ok, thanks for the confirmation.
Quoted 40 lines
Quoted 40 lines
Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
- what is the state of the locking configuration in the chip when you
boot?Quoted 5 lines
Quoted 2 lines
Unlocked, I guess...
How can I check that?It's in your dump, the chip returns 0, meaning it's all unlocked, apparently.
Well, I can read/write the device if block protection isn’t disabled, so I guess we can confirm it’s unlocked…
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
- is there anything that locks the device by calling
mxic_nand_lock()?So nobody locks the device I guess? Did you add traces there?
It doesn’t get to the point that it enabled the lock/unlock functions since it fails when checking if feature is
0x38, so there’s no point in adding those traces…Right, it returns before setting these I guess.
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
- finding no bbt is one thing, hanging is another, where is it hanging
exactly? (offset in nand/ and line in the code)I've got no idea...
You can use ftrace or just add printks a bit everywhere and try to get closer and closer.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I think that after trying to get the feature it just start reading nonsense from the NAND and at some point it hangs due to that garbage…
It should refuse to mount the device somehow, but in no case the kernel should hang.
Yes, I think that this is a side effect (maybe a different bug somewhere else).
Could be worth checking.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Is it posible that the NAND starts behaving like this after getting the feature due to some specific config of my device?
Quoted 4 lines
I looked at the patch, I don't see anything strange. Besides, I have a close enough datasheet and I don't see what could confuse the device.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Are you really sure this patch is the problem? Is the WP pin wired on your design?
There’s no WP pin in brcmnand controllers < 7.0
What about the chip?
Maybe it has a GPIO controlling that, but I don’t have that info…
I mean, on the board, is the chip connected to some kind of pull-up/down resistor? Because it may change its behavior.
Regarding your issue, I see there is a problem, but I don't get why. The current proposal is not satisfying, I cannot pick this up. We need feedback from Macronix :-)
Thanks,
Miquèl
Re: [PATCH 1/2] dt-bindings: mtd: nand: Macronix: document new binding
In reply to Álvaro Fernández RojasHello YouChing and Jaime,
I still didn't get any feedback from you (or Macronix) on this issue. Did you have time to look into it?
Thanks,
Álvaro.
Quoted 248 lines · Álvaro Fernández Rojas
Hi Miquèl,
2023-03-24 15:36 GMT+01:00, Miquel Raynal <[email protected]>:
Quoted 6 lines
Hi Álvaro,
+ YouChing and Jaime from Macronix
TLDR for them: there is a misbehavior since Mason added block protection support. Just checking if the blocks are protected seems to misconfigure the chip entirely, see below. Any hints?Could it be that the NAND is stuck expecting a read
0x00command which isn’t sent after getting the features?Quoted 155 lines
[email protected] wrote on Fri, 24 Mar 2023 15:15:47 +0100:
Quoted 152 lines
Hi Miquèl,
2023-03-24 14:45 GMT+01:00, Miquel Raynal <[email protected]>:
Quoted 148 lines
Hi Álvaro,
[email protected] wrote on Fri, 24 Mar 2023 12:21:11 +0100:
Quoted 139 lines
Quoted 94 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Fri, 24 Mar 2023 11:31:17 +0100:
Quoted 89 lines
Hi Miquèl,
Quoted 37 lines · Miquel Raynal
Hi Álvaro,
[email protected] wrote on Thu, 23 Mar 2023 13:45:09 +0100:
Quoted 24 lines
Add new "mxic,disable-block-protection" binding documentation. This binding allows disabling block protection support for those
devices not
supporting it.Signed-off-by Álvaro Fernández Rojas <[email protected]>--- Documentation/devicetree/bindings/mtd/nand-macronix.txt | 3 +++ 1 file changed, 3 insertions(+)diff --git
a/Documentation/devicetree/bindings/mtd/nand-macronix.txtb/Documentation/devicetree/bindings/mtd/nand-macronix.txtindexffab28a2c4d1..03f65ca32cd3100644Documentation/devicetree/bindings/mtd/nand-macronix.txt +2
-0@@ -16,6 +16,9 @@ in children nodes. Required NAND chip properties in children mode: - randomizer enable: should be "mxic,enable-randomizer-otp" +Optional NAND chip properties in children mode: +- block protection disable: should beQuoted 2 lines
"mxic,disable-block-protection"
+Besides the fact that nowadays we prefer to see binding conversions
to
yaml before adding anything, I don't think this will fly.Quoted 5 lines
I'm not sure exactly what "disable block protection" means, we already have similar properties like "lock" and "secure-regions",
not
sure they will fit but I think it's worth checking.As explained in 2/2, commit
03a539c7a118introduced a regression on
Sercomm H500-s (BCM63268) OpenWrt devices with Macronix MX30LF1G18AC
which hangs the device.This is the log with block protection disabled:
[ 0.495831] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504995] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.511526] nand: Macronix MX30LF1G18AC [ 0.515586] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523516] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.535912] Bad block table found at page 65472, version 0x01 [ 0.544268] Bad block table found at page 65408, version 0x01 [ 0.954329] 9 fixed-partitions partitions found on MTD devicebrcmnand.0
...This is the log with block protection enabled:
[ 0.495095] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504249] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.510772] nand: Macronix MX30LF1G18AC [ 0.514874] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.522780] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.539687] Bad block table not found for chip 0 [ 0.550153] Bad block table not found for chip 0 [ 0.555069] Scanning device for bad blocks [ 0.601213] CPU 1 Unable to handle kernel paging request atvirtual
address10277f00, epc ==8039ce70, ra ==8016ad50
*** Device hangs ***Quoted 8 lines
Quoted 4 lines
Enabling
macronix_nand_block_protection_support()makes the device unable to detect the bad block table and hangs it when trying to scan
for bad blocks.Please trace
nand_macronix.cand look:
- are theget_featuresandset_featuresreally supported by the controller driver?This is what I could find by debugging:
[ 0.494993] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.505375] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.512077] nand: Macronix MX30LF1G18AC [ 0.515994] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523928] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.534415] bcm6368_nand 10000200.nand: ll_op cmd 0xa00ee [ 0.539988] bcm6368_nand 10000200.nand: ll_op cmd 0x600a0 [ 0.545659] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.551214] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.557843] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.563475] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.569998] bcm6368_nand 10000200.nand: ll_op cmd 0x10000 [ 0.575653] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.582246] bcm6368_nand 10000200.nand: ll_op cmd 0x80010000 [ 0.588067] bcm6368_nand 10000200.nand: NAND_CMD_GET_FEATURES = 0x00 [ 0.594657] nand: nand_get_features: addr=a0 subfeature_param=[00 00 00 00] -> 0 [ 0.602341] macronix_nand_block_protection_support: ONFI_FEATURE_ADDR_MXIC_PROTECTION=0 [ 0.610548] macronix_nand_block_protection_support: != MXIC_BLOCK_PROTECTION_ALL_LOCK [ 0.624760] Bad block table not found for chip 0 [ 0.635542] Bad block table not found for chip 0 [ 0.640270] Scanning device for bad blocksQuoted 2 lines
I don't know how to tell if
get_features/set_featuresis really supported...Looks like your driver does not support
exec_opbut the core provides a get/set_feature implementation.Quoted 7 lines
Quoted 4 lines
According to Florian, low level should be supported on brcmnand controllers >= 4.0
Also:
https://github.com/nomis/bcm963xx_4.12L.06B_consumer/blob/e2f23ddbb20bf75689372b6e6a5a0dc613f6e313/shared/opensource/include/bcm963xx/63268_map_part.h#L1597Just to be sure, you're using a mainline controller driver, not this one?
Yes, this was just to prove that the HW I’m using has get/set features support. I’m using OpenWrt, so it’s linux v5.15 driver.
Quoted 36 lines
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
- what is the state of the locking configuration in the chip when you
boot?Quoted 5 lines
Quoted 2 lines
Unlocked, I guess...
How can I check that?It's in your dump, the chip returns 0, meaning it's all unlocked, apparently.
Well, I can read/write the device if block protection isn’t disabled, so I guess we can confirm it’s unlocked…
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
- is there anything that locks the device by calling
mxic_nand_lock()?So nobody locks the device I guess? Did you add traces there?
It doesn’t get to the point that it enabled the lock/unlock functions since it fails when checking if feature is
0x38, so there’s no point in adding those traces…Right, it returns before setting these I guess.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
- finding no bbt is one thing, hanging is another, where is it hanging
exactly? (offset in nand/ and line in the code)I've got no idea...
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
You can use ftrace or just add printks a bit everywhere and try to get closer and closer.
I think that after trying to get the feature it just start reading nonsense from the NAND and at some point it hangs due to that garbage…
It should refuse to mount the device somehow, but in no case the kernel should hang.
Yes, I think that this is a side effect (maybe a different bug somewhere else).
Quoted 8 lines
Quoted 8 lines
Is it posible that the NAND starts behaving like this after getting the feature due to some specific config of my device?
Quoted 4 lines
I looked at the patch, I don't see anything strange. Besides, I have a close enough datasheet and I don't see what could confuse the device.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Are you really sure this patch is the problem? Is the WP pin wired on your design?
There’s no WP pin in brcmnand controllers < 7.0
What about the chip?
Maybe it has a GPIO controlling that, but I don’t have that info…
Quoted 4 lines
Thanks,
Miquèl
PATCH 2/2 mtd: nand: raw: macronix: allow disabling block protection
In reply to Álvaro Fernández RojasSome devices hang when block protection is enabled, so let's add a boolean property to allow disabling it.
--- drivers/mtd/nand/raw/nand_macronix.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mtd/nand/raw/nand_macronix.c +4 -0
@@ -219,9 +219,13 @@ static int mxic_nand_unlock(struct nand_chip *chip, loff_t ofs, uint64_t len)static void macronix_nand_block_protection_support (struct nand_chip *chip) { +struct device_node *dn =nand_get_flash_node (chip);u8 feature[ONFI_SUBFEATURE_PARAM_LEN ];int ret; +if (of_property_read_bool (dn,"mxic,disable-block-protection" )) +return ; +bitmap_set (chip->parameters.get_feature_list,ONFI_FEATURE_ADDR_MXIC_PROTECTION ,1 );
Signature · 1 line
2.30.2
Hi,
Quoted 3 lines · Álvaro Fernández Rojas
Some devices hang when block protection is enabled, so let's add a boolean property to allow disabling it.
Why do they hang?
Quoted 9 lines · Tudor Ambarus
Hi,
Quoted 3 lines · Álvaro Fernández Rojas
Some devices hang when block protection is enabled, so let's add a boolean property to allow disabling it.
Why do they hang?
At first I thought it would be due to the low level op not being supported on BCM63268 brcmnand controllers, but after debugging it seemed to be working...
This is the log with block protection disabled:
[ 0.495831] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504995] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.511526] nand: Macronix MX30LF1G18AC [ 0.515586] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.523516] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.535912] Bad block table found at page 65472, version 0x01 [ 0.544268] Bad block table found at page 65408, version 0x01 [ 0.954329] 9 fixed-partitions partitions found on MTD device brcmnand.0
...
This is the log with block protection enabled:
[ 0.495095] bcm6368_nand 10000200.nand: there is not valid maps for state default [ 0.504249] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 [ 0.510772] nand: Macronix MX30LF1G18AC [ 0.514874] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.522780] bcm6368_nand 10000200.nand: detected 128MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-4 [ 0.539687] Bad block table not found for chip 0 [ 0.550153] Bad block table not found for chip 0 [ 0.555069] Scanning device for bad blocks [ 0.601213] CPU 1 Unable to handle kernel paging request at virtual
address 10277f00, epc == 8039ce70, ra == 8016ad50
*** Device hangs ***
As you can see, when block protection is enabled, the bad block table isn't found and when the device is scanned for bad blocks it just hangs...
If you want me to debug something I would be happy to do it, but I need some guidance here...
Best regards,
Álvaro.