mtd: spi-nor: Set the erase flag for multi-die
Subsystems (2)
PATCH v3 1/2 mtd: spi-nor: Set the erase flag for multi-die
From: Fabio Estevam <[email protected]>
Instead of manually passing the .flags = NO_CHIP_ERASE in the case of multi-die SPI NOR flash, retrieve the information about the number of dies directly from SFDP and set the SNOR_F_NO_OP_CHIP_ERASE flag in the multi-die case.
---
Changes since v2:
- Newly introduced.
drivers/mtd/spi-nor/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +1 -1
@@ -2850,7 +2850,7 @@ static void spi_nor_init_flags(struct spi_nor *nor) nor->flags |=SNOR_F_HAS_SR_BP3_BIT6 ; } -if (flags &NO_CHIP_ERASE ) +if (flags &NO_CHIP_ERASE || nor->params->n_dice >1 ) nor->flags |=SNOR_F_NO_OP_CHIP_ERASE ; if (flags & SPI_NOR_RWW && nor->params->n_banks > 1 &&
Signature · 6 lines
2.34.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 2/2 mtd: spi-nor: micron-st: Add support for mt25qu01g
From: Fabio Estevam <[email protected]>
Add support for the MT25QU01G 128MB Micron Serial NOR Flash Memory model.
Tested on a i.MX8MP based board:
~# cat /sys/devices/platform/soc@0/30800000.bus/30bb0000.spi/spi_master/spi0/spi0.0/spi-nor/jedec_id 20bb21104400
~# cat /sys/devices/platform/soc@0/30800000.bus/30bb0000.spi/spi_master/spi0/spi0.0/spi-nor/manufacturer st
~# cat /sys/devices/platform/soc@0/30800000.bus/30bb0000.spi/spi_master/spi0/spi0.0/spi-nor/partname mt25qu01g
~# xxd -p /sys/devices/platform/soc@0/30800000.bus/30bb0000.spi/spi_master/spi0/spi0.0/spi-nor/sfdp 53464450060101ff00060110300000ff84000102800000ffffffffffffff ffffffffffffffffffffffffffffffffffffe520fbffffffff3f29eb276b 273b27bbffffffffffff27bbffff29eb0c2010d80f520000244a99008b8e 03e1ac0127387a757a75fbbdd55c4a0f82ff81bd3d36ffffffffffffffff ffffffffffffffffffe7ffff21dcffff
~# md5sum /sys/devices/platform/soc@0/30800000.bus/30bb0000.spi/spi_master/spi0/spi0.0/spi-nor/sfdp 9d28d1b11de8b15ba9152644219d9a78 /sys/devices/platform/soc@0/30800000.bus/30bb0000.spi/spi_master/spi0/spi0.0/spi-nor/sfdp
~# dd if=/dev/urandom of=spi_test bs=1M count=128 128+0 records in
128+0 records out
134217728 bytes (134 MB, 128 MiB) copied, 4.77424 s, 28.1 MB/s
~# mtd_debug write /dev/mtd0 0 134217728 spi_test
Copied 134217728 bytes from spi_test to address 0x00000000 in flash
~# mtd_debug read /dev/mtd0 0 134217728 spi_read
Copied 134217728 bytes from address 0x00000000 in flash to spi_read
~# sha1sum spi_test spi_read 6778615a7b7db2d3c3fa122721d940082eb67039 spi_test 6778615a7b7db2d3c3fa122721d940082eb67039 spi_read
~# flash_erase /dev/mtd0 0 0
Erasing 131072 Kibyte @ 0 -- 100 % complete
~# hexdump -C /dev/mtd0
00000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| *
08000000
---
Changes since v2:
- Added fixups to report the correct n_dice information.
- Removed .flags = NO_CHIP_ERASE (Michael)
- Removed .mfr_flags = USE_FSR (Michael)
drivers/mtd/spi-nor/micron-st.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/mtd/spi-nor/micron-st.c +18 -0
@@ -192,6 +192,20 @@ static struct spi_nor_fixups mt25qu512a_fixups = { .post_bfpt = mt25qu512a_post_bfpt_fixup, }; +static int mt25qu01g_post_sfdp_fixup (struct spi_nor *nor) +{ +struct spi_nor_flash_parameter *params = nor->params; + +/* MT25QU01G does not define the SCCR entry, so pass n_dice manually. */ + params->n_dice =2 ; + +return 0 ; +} + +static struct spi_nor_fixups mt25qu01g_fixups = { + .post_sfdp = mt25qu01g_post_sfdp_fixup, +}; +static const struct flash_info st_nor_parts[] = { { .name ="m25p05-nonjedec" ,
@@ -429,6 +443,10 @@ static const struct flash_info st_nor_parts[] = { SPI_NOR_BP3_SR_BIT6, .no_sfdp_flags = SECT_4K | SPI_NOR_QUAD_READ, .mfr_flags = USE_FSR, + }, { + .id = SNOR_ID(0x20, 0xbb, 0x21, 0x10, 0x44, 0x00), + .name = "mt25qu01g", + .fixups = &mt25qu01g_fixups, }, { .id = SNOR_ID(0x20, 0xbb, 0x21), .name = "n25q00a",
Signature · 6 lines
2.34.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 2/2] mtd: spi-nor: micron-st: Add support for mt25qu01g
Hi, Fabio,
The entire patch looks very suspicious to me. I'd like some more tests please, see my reasoning below.
Quoted 44 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Add support for the MT25QU01G 128MB Micron Serial NOR Flash Memory model.
Tested on a i.MX8MP based board:
~# cat
/sys/devices/platform/soc@0/30800000.bus/30bb0000.spi/spi_master/spi0/spi0.0/spi-nor/jedec_id20bb21104400~# cat
/sys/devices/platform/soc@0/30800000.bus/30bb0000.spi/spi_master/spi0/spi0.0/spi-nor/manufacturerst~# cat
/sys/devices/platform/soc@0/30800000.bus/30bb0000.spi/spi_master/spi0/spi0.0/spi-nor/partnamemt25qu01g~# xxd -p
/sys/devices/platform/soc@0/30800000.bus/30bb0000.spi/spi_master/spi0/spi0.0/spi-nor/sfdp53464450060101ff00060110300000ff84000102800000ffffffffffffffffffffffffffffffffffffffffffffffffffe520fbffffffff3f29eb276b273b27bbffffffffffff27bbffff29eb0c2010d80f520000244a99008b8e03e1ac0127387a757a75fbbdd55c4a0f82ff81bd3d36ffffffffffffffffffffffffffffffffffe7ffff21dcffff~# md5sum
/sys/devices/platform/soc@0/30800000.bus/30bb0000.spi/spi_master/spi0/spi0.0/spi-nor/sfdp9d28d1b11de8b15ba9152644219d9a78/sys/devices/platform/soc@0/30800000.bus/30bb0000.spi/spi_master/spi0/spi0.0/spi-nor/sfdp~# dd if=/dev/urandom of=spi_test bs=1M count=128 128+0 records in
128+0 records out
134217728 bytes (134 MB, 128 MiB) copied, 4.77424 s, 28.1 MB/s~#
mtd_debugwrite/dev/mtd00 134217728spi_test
Copied 134217728 bytes fromspi_testto address0x00000000in flash~#
mtd_debugread/dev/mtd00 134217728spi_read
Copied 134217728 bytes from address0x00000000in flash tospi_read~# sha1sum
spi_testspi_read6778615a7b7db2d3c3fa122721d940082eb67039spi_test6778615a7b7db2d3c3fa122721d940082eb67039spi_read
Quoted 7 lines
~#
flash_erase/dev/mtd00 0
Erasing 131072 Kibyte @ 0 -- 100 % complete~# hexdump -C
/dev/mtd0
00000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| *
08000000
This doesn't prove the flash works because if the entire flash is already erased and all the ops are noops, the test passes.
Would you please do the following tests instead?
1/ dd if=/dev/urandom of=spi_test bs=1M count=128
2/ mtd_debug write /dev/mtd0 0 134217728 spi_test
3/ just make sure that we wrote something and the flash does not contains just 0xff data. Read 246 bytes from both dies and dump them. mtd_debug read /dev/mtd0 0 256 first-die
cat first-diemtd_debug read /dev/mtd0 67108864 256 second-die
cat second-die
4/ now that we are sure we have some data in it and not just 0xff, erase the entire flash and make sure we get just 0xff when reading flash_erase /dev/mtd0 0 0
hexdump -C /dev/mtd0
6/ now do the write-readback-verify testmtd_debug write /dev/mtd0 0 134217728 spi_testmtd_debug read /dev/mtd0 0 134217728 spi_read
sha1sum spi_test spi_read
Quoted 7 lines
Signed-off-by Fabio Estevam <[email protected]>---
Changes since v2:
- Added fixups to report the correctn_diceinformation.
- Removed .flags =NO_CHIP_ERASE(Michael)
- Removed .mfr_flags =USE_FSR(Michael)
Not a good idea to remove USE_FSR. FSR is used to determine page program and erase errors, please keep it.
Quoted 9 lines
drivers/mtd/spi-nor/micron-st.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)drivers/mtd/spi-nor/micron-st.c +0
-0
drivers/mtd/spi-nor/micron-st.c static struct spi_nor_fixups mt25qu512a_fixups = { · line 201
Quoted 10 lines
drivers/mtd/spi-nor/micron-st.c +7
-0@@ -192,6 +192,20 @@ static struct spi_nor_fixups mt25qu512a_fixups = { .post_bfpt = mt25qu512a_post_bfpt_fixup, }; +static int mt25qu01g_post_sfdp_fixup (struct spi_nor *nor) +{ +struct spi_nor_flash_parameter *params = nor->params; + +/* MT25QU01G does not define the SCCR entry, so pass n_dice manually. */ + params->n_dice =2 ; +
I wonder why this is needed if it's not used anywhere. Do you set this just so that based on it to set the no-chip-erase flag? If yes, set the no chip erase flag directly and drop the entire fixup hook. Would be good to introduce the die erase capability if you care about erase speed.
Skimming over the datasheet you pointed out didn't help me remove my concerns.
See "Table 24: 4-BYTE READ MEMORY Operations", it says "a die can be read with a single command", but we don't consider this anywhere in the code.
If the flash works with the current code, why does it work? Please enable dev_dbg, we have one in spi_nor_read(), we shall see what's going on.
Cheers,
ta
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
A message that is not in the archive (sent off-list or not yet received): CAOMZO5AxBwG_LFNNFVMXVwv2YLd2f_BJD5e+dOUGyOtMWTMvOw@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): CAOMZO5BFO4cgNRv507HpqhSDR+JKL7BcEUTWMeVRpMroqhmCjA@mail.gmail.com
Re: [PATCH v3 2/2] mtd: spi-nor: micron-st: Add support for mt25qu01g
Hi Tudor,
Quoted 1 line · Fabio Estevam
Here are the cross-die results:
Do you still have concerns about v2?
https://lore.kernel.org/linux-mtd/[email protected]/
Please note that n25q00, mt25ql02g, n25q00a, and mt25qu02g are currently supported and are also multi-die chips.
I just don't understand why mt25qu01g cannot join the party.
Thanks
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 2/2] mtd: spi-nor: micron-st: Add support for mt25qu01g
Quoted 2 lines · Fabio Estevam
Hi Tudor,
Hi,
Quoted 6 lines · Fabio Estevam
Quoted 2 lines
Here are the cross-die results:
Do you still have concerns about v2?
I saw your previous email, didn't get the chance to read the datasheet.
Quoted 7 lines
https://lore.kernel.org/linux-mtd/[email protected]/
Please note that n25q00, mt25ql02g, n25q00a, and mt25qu02g are currently supported and are also multi-die chips.
I just don't understand why mt25qu01g cannot join the party.
I'm not against the patch per se, but the datasheet confused me when I skimmed over it. Will try to re-read it. FYI, the merge window hasn't closed, I'll start queuing patches once -rc1 is out. I'll get back to you.
ta
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 6 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Instead of manually passing the .flags =
NO_CHIP_ERASEin the case of multi-die SPI NOR flash, retrieve the information about the number of dies directly from SFDP and set theSNOR_F_NO_OP_CHIP_ERASEflag in the multi-die case.
We don't have enough data from manufacturers to make such an assumption. And since this is not backed up by a standard, I'd like to stick to the .flags = NO_CHIP_ERASE for now.
Quoted 15 lines
Suggested-by Michael Walle <[email protected]>Signed-off-by Fabio Estevam <[email protected]>---
Changes since v2:
- Newly introduced.drivers/mtd/spi-nor/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mtd/spi-nor/core.c +0
-0
drivers/mtd/spi-nor/core.c static void spi_nor_init_flags(struct spi_nor *nor) · line 2856
Quoted 8 lines
drivers/mtd/spi-nor/core.c +1
-1@@ -2850,7 +2850,7 @@ static void spi_nor_init_flags(struct spi_nor *nor) nor->flags |=SNOR_F_HAS_SR_BP3_BIT6 ; } -if (flags &NO_CHIP_ERASE ) +if (flags &NO_CHIP_ERASE || nor->params->n_dice >1 ) nor->flags |=SNOR_F_NO_OP_CHIP_ERASE ; if (flags & SPI_NOR_RWW && nor->params->n_banks > 1 &&
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 8 lines
Quoted 4 lines
Instead of manually passing the .flags =
NO_CHIP_ERASEin the case of multi-die SPI NOR flash, retrieve the information about the number of dies directly from SFDP and set theSNOR_F_NO_OP_CHIP_ERASEflag in the multi-die case.We don't have enough data from manufacturers to make such an assumption. And since this is not backed up by a standard, I'd like to stick to the .flags =
NO_CHIP_ERASEfor now
mh. we have two flashes which are multi die ones. as far as I remember. i checked the semper flash and it didn't support chip erase. also.. chip erase isn't a standard either and not backed by SFDP, correct? We shouldn't use it in the first place. So we might have a chance to fix that for multi die chips now.
So as long as there isn't a multi die flash which supports
chip erase, I'd like to keep the additional flags as minimal as possible. for the best case scenario it would just work out of the box with just SFDP, which is impossible if we need that no_chip_erase flag.
-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/