mtd: spi-nor: Fix address width on flash chips > 16MB
Subsystems (3)
PATCH RESEND v2 1/1 mtd: spi-nor: Fix address width on flash chips > 16MB
If a flash chip has more than 16MB capacity but its BFPT reports BFPT_DWORD1_ADDRESS_BYTES_3_OR_4, the spi-nor framework defaults to 3.
The check in spi_nor_set_addr_width() doesn't catch it because addr_width did get set. This fixes that check.
--- drivers/mtd/spi-nor/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/mtd/spi-nor/core.c +5 -3
@@ -3009,13 +3009,15 @@ static int spi_nor_set_addr_width(struct spi_nor *nor)/* already configured from SFDP */ }else if (nor->info->addr_width) { nor->addr_width = nor->info->addr_width; - }else if (nor->mtd.size >0x1000000 ) { -/* enable 4-byte addressing if the device exceeds 16MiB */ - nor->addr_width =4 ; }else { nor->addr_width =3 ; } +if (nor->addr_width ==3 && nor->mtd.size >0x1000000 ) { +/* enable 4-byte addressing if the device exceeds 16MiB */ + nor->addr_width =4 ; + } +if (nor->addr_width >SPI_NOR_MAX_ADDR_WIDTH ) {dev_dbg (nor->dev,"address width is too large: %u\n" , nor->addr_width);
Signature · 1 line
2.17.1
Quoted 19 lines · Bert Vermeulen
If a flash chip has more than 16MB capacity but its BFPT reports
BFPT_DWORD1_ADDRESS_BYTES_3_OR_4, the spi-nor framework defaults to 3.The check in
spi_nor_set_addr_width()doesn't catch it becauseaddr_widthdid get set. This fixes that check.Fixes f9acd7fa80be ("mtd: spi-nor: sfdp: default to addr_width of 3 for configurable widths")Signed-off-by Bert Vermeulen <[email protected]>Reviewed-by Tudor Ambarus <[email protected]>--- drivers/mtd/spi-nor/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/mtd/spi-nor/core.c +0
-0@@ -3009,13 +3009,15 @@ static int spi_nor_set_addr_width(struct spi_nor *nor)/* already configured from SFDP */
drivers/mtd/spi-nor/core.c static int spi_nor_set_addr_width(struct spi_nor *nor) · line 3016
Quoted 10 lines
drivers/mtd/spi-nor/core.c +1
-3}else if (nor->info->addr_width) { nor->addr_width = nor->info->addr_width; - }else if (nor->mtd.size >0x1000000 ) { -/* enable 4-byte addressing if the device exceeds 16MiB */ - nor->addr_width =4 ; }else { nor->addr_width =3 ; } +if (nor->addr_width ==3 && nor->mtd.size >0x1000000 ) {
Nitpick: ^^^^^^^^^^^^^^^^^^^^^^^^ you can drop this part. But its
fine either way.
Quoted 7 lines
drivers/mtd/spi-nor/core.c +4
-0+/* enable 4-byte addressing if the device exceeds 16MiB */ + nor->addr_width =4 ; + } +if (nor->addr_width >SPI_NOR_MAX_ADDR_WIDTH ) {dev_dbg (nor->dev,"address width is too large: %u\n" , nor->addr_width);
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments India
Vignesh Raghavendra
maintainerQuoted 29 lines · Pratyush Yadav
Quoted 28 lines · Bert Vermeulen
If a flash chip has more than 16MB capacity but its BFPT reports
BFPT_DWORD1_ADDRESS_BYTES_3_OR_4, the spi-nor framework defaults to 3.The check in
spi_nor_set_addr_width()doesn't catch it becauseaddr_widthdid get set. This fixes that check.Fixes f9acd7fa80be ("mtd: spi-nor: sfdp: default to addr_width of 3 for configurable widths")Signed-off-by Bert Vermeulen <[email protected]>Reviewed-by Tudor Ambarus <[email protected]>--- drivers/mtd/spi-nor/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/mtd/spi-nor/core.c +0
-3@@ -3009,13 +3009,15 @@ static int spi_nor_set_addr_width(struct spi_nor *nor)/* already configured from SFDP */ }else if (nor->info->addr_width) { nor->addr_width = nor->info->addr_width; - }else if (nor->mtd.size >0x1000000 ) { -/* enable 4-byte addressing if the device exceeds 16MiB */ - nor->addr_width =4 ; }else { nor->addr_width =3 ; }
Quoted 4 lines
drivers/mtd/spi-nor/core.c static int spi_nor_set_addr_width(struct spi_nor *nor) · line 3016
Quoted 1 line
drivers/mtd/spi-nor/core.c +1
-0+if (nor->addr_width ==3 && nor->mtd.size >0x1000000 ) {Nitpick: ^^^^^^^^^^^^^^^^^^^^^^^^ you can drop this part. But its
fine either way.
I don't think its a good idea to drop nor->addr_width == 3 check as nor->info->addr_width is permitted to have a value > 4 (although there is no such flash today)...
Quoted 10 lines
Reviewed-by Pratyush Yadav <[email protected]>drivers/mtd/spi-nor/core.c static int spi_nor_set_addr_width(struct spi_nor *nor) · line 3023
Quoted 7 lines
drivers/mtd/spi-nor/core.c +4
-0+/* enable 4-byte addressing if the device exceeds 16MiB */ + nor->addr_width =4 ; + } +if (nor->addr_width >SPI_NOR_MAX_ADDR_WIDTH ) {dev_dbg (nor->dev,"address width is too large: %u\n" , nor->addr_width);
Regards
Vignesh
Quoted 32 lines · Vignesh Raghavendra
Quoted 29 lines · Pratyush Yadav
Quoted 28 lines · Bert Vermeulen
If a flash chip has more than 16MB capacity but its BFPT reports
BFPT_DWORD1_ADDRESS_BYTES_3_OR_4, the spi-nor framework defaults to 3.The check in
spi_nor_set_addr_width()doesn't catch it becauseaddr_widthdid get set. This fixes that check.Fixes f9acd7fa80be ("mtd: spi-nor: sfdp: default to addr_width of 3 for configurable widths")Signed-off-by Bert Vermeulen <[email protected]>Reviewed-by Tudor Ambarus <[email protected]>--- drivers/mtd/spi-nor/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/mtd/spi-nor/core.c +0
-3@@ -3009,13 +3009,15 @@ static int spi_nor_set_addr_width(struct spi_nor *nor)/* already configured from SFDP */ }else if (nor->info->addr_width) { nor->addr_width = nor->info->addr_width; - }else if (nor->mtd.size >0x1000000 ) { -/* enable 4-byte addressing if the device exceeds 16MiB */ - nor->addr_width =4 ; }else { nor->addr_width =3 ; }
Quoted 8 lines
Quoted 4 lines
drivers/mtd/spi-nor/core.c static int spi_nor_set_addr_width(struct spi_nor *nor) · line 3016
Quoted 1 line
drivers/mtd/spi-nor/core.c +1
-0+if (nor->addr_width ==3 && nor->mtd.size >0x1000000 ) {Nitpick: ^^^^^^^^^^^^^^^^^^^^^^^^ you can drop this part. But its
fine either way.I don't think its a good idea to drop
nor->addr_width== 3 check asnor->info->addr_widthis permitted to have a value > 4 (although there is no such flash today)...
The check below for SPI_NOR_MAX_ADDR_WIDTH will return an error when nor->addr_width > 4, but I see your point.
Quoted 13 lines
Quoted 10 lines
Reviewed-by Pratyush Yadav <[email protected]>drivers/mtd/spi-nor/core.c static int spi_nor_set_addr_width(struct spi_nor *nor) · line 3023
Quoted 7 lines
drivers/mtd/spi-nor/core.c +4
-0+/* enable 4-byte addressing if the device exceeds 16MiB */ + nor->addr_width =4 ; + } +if (nor->addr_width >SPI_NOR_MAX_ADDR_WIDTH ) {dev_dbg (nor->dev,"address width is too large: %u\n" , nor->addr_width);Regards
Vignesh
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments India
Greg KH
maintainerQuoted 6 lines · Bert Vermeulen
If a flash chip has more than 16MB capacity but its BFPT reports
BFPT_DWORD1_ADDRESS_BYTES_3_OR_4, the spi-nor framework defaults to 3.The check in
spi_nor_set_addr_width()doesn't catch it becauseaddr_widthdid get set. This fixes that check.
Quoted 6 lines
Fixes f9acd7fa80be ("mtd: spi-nor: sfdp: default to addr_width of 3 for configurable widths")Signed-off-by Bert Vermeulen <[email protected]>Reviewed-by Tudor Ambarus <[email protected]>--- drivers/mtd/spi-nor/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
Quoted 5 lines · Bert Vermeulen
If a flash chip has more than 16MB capacity but its BFPT reports
BFPT_DWORD1_ADDRESS_BYTES_3_OR_4, the spi-nor framework defaults to 3.The check in
spi_nor_set_addr_width()doesn't catch it becauseaddr_widthdid get set. This fixes that check.
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks! [1/1] mtd: spi-nor: Fix address width on flash chips > 16MB
https://git.kernel.org/mtd/c/324f78dfb4
--
Regards
Vignesh
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/