Skip to contentSkip to conversation

sf: Fix to compute proper sector_size

PATCH Superseded Jagannadha Sutradharudu Teki 2 participants 4 messages Apr 24, 2015 – Apr 27, 2015 Memory technology devices (MTD)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sf: Fix to compute proper sector_size

Upto now flash sector_size is assigned from params which isn't necessarily a sector size from vendor, so based on the SECT_* flags from flash_params the erase_size will compute and it will become the sector_size finally.

Bug report (from Bin Meng):
=> sf probe
SF: Detected SST25VF016B with page size 256 Bytes, erase size 4 KiB, total 2 MiB, mapped at ffe00000

=> sf erase 0 +100
SF: 65536 bytes @ 0x0 Erased: OK

---
Changes for v2:

	- 
 drivers/mtd/spi/sf_internal.h | 3 ++-
 drivers/mtd/spi/sf_probe.c    | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/mtd/spi/sf_internal.h +2 -1
index bd834dc..bef8701 100644
@@ -119,7 +119,8 @@ int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len,
  * @name:		Device name ([MANUFLETTER][DEVTYPE][DENSITY][EXTRAINFO])
  * @jedec:		Device jedec ID (0x[1byte_manuf_id][2byte_dev_id])
  * @ext_jedec:		Device ext_jedec ID
- * @sector_size:	Sector size of this device
+ * @sector_size:	Isn't necessarily a sector size from vendor,
+ *			the size here is what works with Sector erase (64KB)
  * @nr_sectors:	No.of sectors on this device
  * @e_rd_cmd:		Enum list for read commands
  * @flags:		Important param, for flash specific behaviour
drivers/mtd/spi/sf_probe.c +3 -0
index de8d0b7..3f6b882 100644
@@ -184,6 +184,9 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
 		flash->erase_size = flash->sector_size;
 	}
 
+	/* Now erase size becomes valid sector size */
+	flash->sector_size = flash->erase_size;
+
 	/* Look for the fastest read cmd */
 	cmd = fls(params->e_rd_cmd & flash->spi->op_mode_rx);
 	if (cmd) {
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v2 1/1 sf: Fix to compute proper sector_size

Hi Bin,

Quoted 5 lines · Jagannadha Sutradharudu Teki

Upto now flash sector_size is assigned from params which isn't necessarily a sector size from vendor, so based on the SECT_* flags from flash_params the erase_size will compute and it will become the sector_size finally.

Quoted 7 lines

Bug report (from Bin Meng):
=> sf probe
SF: Detected SST25VF016B with page size 256 Bytes, erase size 4 KiB, total 2 MiB, mapped at ffe00000

=> sf erase 0 +100
SF: 65536 bytes @ 0x0 Erased: OK

Can you please test this.

Quoted 39 lines

---
Changes for v2:

        -
 drivers/mtd/spi/sf_internal.h | 3 ++-
 drivers/mtd/spi/sf_probe.c    | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/mtd/spi/sf_internal.h +2 -1
index bd834dc..bef8701 100644
@@ -119,7 +119,8 @@ int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len,
  * @name:              Device name ([MANUFLETTER][DEVTYPE][DENSITY][EXTRAINFO])
  * @jedec:             Device jedec ID (0x[1byte_manuf_id][2byte_dev_id])
  * @ext_jedec:         Device ext_jedec ID
- * @sector_size:       Sector size of this device
+ * @sector_size:       Isn't necessarily a sector size from vendor,
+ *                     the size here is what works with Sector erase (64KB)
  * @nr_sectors:        No.of sectors on this device
  * @e_rd_cmd:          Enum list for read commands
  * @flags:             Important param, for flash specific behaviour
drivers/mtd/spi/sf_probe.c +3 -1
index de8d0b7..3f6b882 100644
@@ -184,6 +184,9 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
                flash->erase_size = flash->sector_size;
        }
 
+       /* Now erase size becomes valid sector size */
+       flash->sector_size = flash->erase_size;
+
        /* Look for the fastest read cmd */
        cmd = fls(params->e_rd_cmd & flash->spi->op_mode_rx);
        if (cmd) {
--
Quoted 2 lines

1.9.1

thanks!

Signature · 1 line
Jagan.
#2 lore raw

PATCH v2 1/1 sf: Fix to compute proper sector_size

In reply to Jagannadha Sutradharudu Teki

Hi Jagan,

Quoted 10 lines · Jagannadha Sutradharudu Teki

Upto now flash sector_size is assigned from params which isn't necessarily a sector size from vendor, so based on the SECT_* flags from flash_params the erase_size will compute and it will become the sector_size finally.

Bug report (from Bin Meng):
=> sf probe
SF: Detected SST25VF016B with page size 256 Bytes, erase size 4 KiB, total 2 MiB, mapped at ffe00000

Quoted 5 lines

=> sf erase 0 +100
SF: 65536 bytes @ 0x0 Erased: OK

But please see my comments blow.

Quoted 12 lines

---
Changes for v2:

        -
 drivers/mtd/spi/sf_internal.h | 3 ++-
 drivers/mtd/spi/sf_probe.c    | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/mtd/spi/sf_internal.h +0 -0
index bd834dc..bef8701 100644

drivers/mtd/spi/sf_internal.h int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len, · line 123

Quoted 6 lines
drivers/mtd/spi/sf_internal.h +2 -1
@@ -119,7 +119,8 @@ int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len,
  * @name:              Device name ([MANUFLETTER][DEVTYPE][DENSITY][EXTRAINFO])
  * @jedec:             Device jedec ID (0x[1byte_manuf_id][2byte_dev_id])
  * @ext_jedec:         Device ext_jedec ID
- * @sector_size:       Sector size of this device
+ * @sector_size:       Isn't necessarily a sector size from vendor,
+ *                     the size here is what works with Sector erase (64KB)

Sector -> sector. Also I think we should remove (64KB) here as it is confusing.

Quoted 8 lines
drivers/mtd/spi/sf_internal.h +0 -0
  * @nr_sectors:        No.of sectors on this device
  * @e_rd_cmd:          Enum list for read commands
  * @flags:             Important param, for flash specific behaviour
drivers/mtd/spi/sf_probe.c +0 -0
index de8d0b7..3f6b882 100644

drivers/mtd/spi/sf_probe.c static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,

Quoted 10 lines
drivers/mtd/spi/sf_probe.c +3 -1
@@ -184,6 +184,9 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
                flash->erase_size = flash->sector_size;
        }
 
+       /* Now erase size becomes valid sector size */
+       flash->sector_size = flash->erase_size;
+
        /* Look for the fastest read cmd */
        cmd = fls(params->e_rd_cmd & flash->spi->op_mode_rx);
        if (cmd) {
--

Regards,
Bin

author
#3 lore raw

PATCH v2 1/1 sf: Fix to compute proper sector_size

Quoted 31 lines · Bin Meng

Hi Jagan,

Quoted 10 lines · Jagannadha Sutradharudu Teki

Upto now flash sector_size is assigned from params which isn't necessarily a sector size from vendor, so based on the SECT_* flags from flash_params the erase_size will compute and it will become the sector_size finally.

Bug report (from Bin Meng):
=> sf probe
SF: Detected SST25VF016B with page size 256 Bytes, erase size 4 KiB, total 2 MiB, mapped at ffe00000

Quoted 5 lines

=> sf erase 0 +100
SF: 65536 bytes @ 0x0 Erased: OK

But please see my comments blow.

Quoted 7 lines

---
Changes for v2:

        -
 drivers/mtd/spi/sf_internal.h | 3 ++-
 drivers/mtd/spi/sf_probe.c    | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)
Quoted 11 lines

drivers/mtd/spi/sf_internal.h int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len, · line 123

Quoted 11 lines
drivers/mtd/spi/sf_internal.h +2 -1
index bd834dc..bef8701 100644
@@ -119,7 +119,8 @@ int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len,
  * @name:              Device name ([MANUFLETTER][DEVTYPE][DENSITY][EXTRAINFO])
  * @jedec:             Device jedec ID (0x[1byte_manuf_id][2byte_dev_id])
  * @ext_jedec:         Device ext_jedec ID
- * @sector_size:       Sector size of this device
+ * @sector_size:       Isn't necessarily a sector size from vendor,
+ *                     the size here is what works with Sector erase (64KB)

Ok I will replace CMD_ERASE_64K instead of Sector erase (64KB)

"the size listed here is what works with CMD_ERASE_64K"

Any comments?

Quoted 14 lines

Sector -> sector. Also I think we should remove (64KB) here as it is confusing.

Quoted 11 lines
drivers/mtd/spi/sf_internal.h +0 -0
  * @nr_sectors:        No.of sectors on this device
  * @e_rd_cmd:          Enum list for read commands
  * @flags:             Important param, for flash specific behaviour
drivers/mtd/spi/sf_probe.c +0 -0
index de8d0b7..3f6b882 100644
@@ -184,6 +184,9 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
                flash->erase_size = flash->sector_size;
        }
 
Quoted 7 lines

drivers/mtd/spi/sf_probe.c static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,

Quoted 7 lines
drivers/mtd/spi/sf_probe.c +3 -1
+       /* Now erase size becomes valid sector size */
+       flash->sector_size = flash->erase_size;
+
        /* Look for the fastest read cmd */
        cmd = fls(params->e_rd_cmd & flash->spi->op_mode_rx);
        if (cmd) {
--

thanks!

Signature · 1 line
Jagan.