* [PATCH 1/4] mtd: spi-nor: sfdp: Fix wrong erase type bitmask for overlaid region
2020-10-02 5:17 [PATCH 0/4] mtd: spi-nor: Fix non-uniform erase map issues tkuw584924
@ 2020-10-02 5:17 ` tkuw584924
2020-10-02 5:18 ` [PATCH 2/4] mtd: spi-nor: sfdp: Fix last erase region marking tkuw584924
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: tkuw584924 @ 2020-10-02 5:17 UTC (permalink / raw)
To: linux-mtd
Cc: vigneshr, tudor.ambarus, richard, Bacem.Daassi, tkuw584924,
miquel.raynal, Takahiro Kuwano
From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
At the time spi_nor_region_check_overlay() is called, the erase types are
sorted in ascending order of erase size. The 'erase_type' should be masked
with 'BIT(erase[i].idx)' instead of 'BIT(i)'.
Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
---
drivers/mtd/spi-nor/sfdp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c
index e2a43d39eb5f..5332345b3cb8 100644
--- a/drivers/mtd/spi-nor/sfdp.c
+++ b/drivers/mtd/spi-nor/sfdp.c
@@ -760,7 +760,7 @@ spi_nor_region_check_overlay(struct spi_nor_erase_region *region,
int i;
for (i = 0; i < SNOR_ERASE_TYPE_MAX; i++) {
- if (!(erase_type & BIT(i)))
+ if (!(erase[i].size && erase_type & BIT(erase[i].idx)))
continue;
if (region->size & erase[i].size_mask) {
spi_nor_region_mark_overlay(region);
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/4] mtd: spi-nor: sfdp: Fix last erase region marking
2020-10-02 5:17 [PATCH 0/4] mtd: spi-nor: Fix non-uniform erase map issues tkuw584924
2020-10-02 5:17 ` [PATCH 1/4] mtd: spi-nor: sfdp: Fix wrong erase type bitmask for overlaid region tkuw584924
@ 2020-10-02 5:18 ` tkuw584924
2020-10-02 5:18 ` [PATCH 3/4] mtd: spi-nor: core: Fix erase type discovery for overlaid region tkuw584924
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: tkuw584924 @ 2020-10-02 5:18 UTC (permalink / raw)
To: linux-mtd
Cc: vigneshr, tudor.ambarus, richard, Bacem.Daassi, tkuw584924,
miquel.raynal, Takahiro Kuwano
From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
The place of spi_nor_region_mark_end() must be moved, because 'i' is
re-used for the index of erase[].
Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
---
drivers/mtd/spi-nor/sfdp.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c
index 5332345b3cb8..08de2a2b4452 100644
--- a/drivers/mtd/spi-nor/sfdp.c
+++ b/drivers/mtd/spi-nor/sfdp.c
@@ -830,6 +830,7 @@ spi_nor_init_non_uniform_erase_map(struct spi_nor *nor,
offset = (region[i].offset & ~SNOR_ERASE_FLAGS_MASK) +
region[i].size;
}
+ spi_nor_region_mark_end(®ion[i - 1]);
save_uniform_erase_type = map->uniform_erase_type;
map->uniform_erase_type = spi_nor_sort_erase_mask(map,
@@ -853,8 +854,6 @@ spi_nor_init_non_uniform_erase_map(struct spi_nor *nor,
if (!(regions_erase_type & BIT(erase[i].idx)))
spi_nor_set_erase_type(&erase[i], 0, 0xFF);
- spi_nor_region_mark_end(®ion[i - 1]);
-
return 0;
}
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/4] mtd: spi-nor: core: Fix erase type discovery for overlaid region
2020-10-02 5:17 [PATCH 0/4] mtd: spi-nor: Fix non-uniform erase map issues tkuw584924
2020-10-02 5:17 ` [PATCH 1/4] mtd: spi-nor: sfdp: Fix wrong erase type bitmask for overlaid region tkuw584924
2020-10-02 5:18 ` [PATCH 2/4] mtd: spi-nor: sfdp: Fix last erase region marking tkuw584924
@ 2020-10-02 5:18 ` tkuw584924
2020-10-02 5:18 ` [PATCH 4/4] mtd: spi-nor: core: Add erase size check for erase command initialization tkuw584924
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: tkuw584924 @ 2020-10-02 5:18 UTC (permalink / raw)
To: linux-mtd
Cc: vigneshr, tudor.ambarus, richard, Bacem.Daassi, tkuw584924,
miquel.raynal, Takahiro Kuwano
From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
For overlaid regions, 'region->size' is assined to 'cmd->size' later in
spi_nor_init_erase_cmd() so 'erase->size' can be greater than 'len'.
Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
---
drivers/mtd/spi-nor/core.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 0369d98b2d12..c7d5c86905fa 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1212,14 +1212,15 @@ spi_nor_find_best_erase_type(const struct spi_nor_erase_map *map,
erase = &map->erase_type[i];
+ /* Alignment is not mandatory for overlaid regions */
+ if (region->offset & SNOR_OVERLAID_REGION &&
+ region->size <= len)
+ return erase;
+
/* Don't erase more than what the user has asked for. */
if (erase->size > len)
continue;
- /* Alignment is not mandatory for overlaid regions */
- if (region->offset & SNOR_OVERLAID_REGION)
- return erase;
-
spi_nor_div_by_erase_size(erase, addr, &rem);
if (rem)
continue;
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/4] mtd: spi-nor: core: Add erase size check for erase command initialization
2020-10-02 5:17 [PATCH 0/4] mtd: spi-nor: Fix non-uniform erase map issues tkuw584924
` (2 preceding siblings ...)
2020-10-02 5:18 ` [PATCH 3/4] mtd: spi-nor: core: Fix erase type discovery for overlaid region tkuw584924
@ 2020-10-02 5:18 ` tkuw584924
2021-01-24 10:34 ` [PATCH 0/4] mtd: spi-nor: Fix non-uniform erase map issues Tudor.Ambarus
2021-02-05 13:31 ` Tudor Ambarus
5 siblings, 0 replies; 8+ messages in thread
From: tkuw584924 @ 2020-10-02 5:18 UTC (permalink / raw)
To: linux-mtd
Cc: vigneshr, tudor.ambarus, richard, Bacem.Daassi, tkuw584924,
miquel.raynal, Takahiro Kuwano
From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
Even if erase type is same as previous region, erase size can be different
if the previous region is overlaid region. Since 'region->size' is assigned
to 'cmd->size' for overlaid region, comparing 'erase->size' and 'cmd->size'
can detect previous overlaid region.
Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
---
drivers/mtd/spi-nor/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index c7d5c86905fa..a560e8ce13cd 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1364,6 +1364,7 @@ static int spi_nor_init_erase_cmd_list(struct spi_nor *nor,
goto destroy_erase_cmd_list;
if (prev_erase != erase ||
+ erase->size != cmd->size ||
region->offset & SNOR_OVERLAID_REGION) {
cmd = spi_nor_init_erase_cmd(region, erase);
if (IS_ERR(cmd)) {
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/4] mtd: spi-nor: Fix non-uniform erase map issues
2020-10-02 5:17 [PATCH 0/4] mtd: spi-nor: Fix non-uniform erase map issues tkuw584924
` (3 preceding siblings ...)
2020-10-02 5:18 ` [PATCH 4/4] mtd: spi-nor: core: Add erase size check for erase command initialization tkuw584924
@ 2021-01-24 10:34 ` Tudor.Ambarus
2021-01-25 3:11 ` Takahiro Kuwano
2021-02-05 13:31 ` Tudor Ambarus
5 siblings, 1 reply; 8+ messages in thread
From: Tudor.Ambarus @ 2021-01-24 10:34 UTC (permalink / raw)
To: tkuw584924, linux-mtd, Takahiro.Kuwano
Cc: richard, Bacem.Daassi, vigneshr, miquel.raynal
Hi, Takahiro,
Are these theoretical fixes or do they fix the non uniform erase
on some flash?
Cheers,
ta
On 10/2/20 8:17 AM, tkuw584924@gmail.com wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
>
> This patchset fixes the issues in handling non-uniform erase map.
>
> Takahiro Kuwano (4):
> mtd: spi-nor: sfdp: Fix wrong erase type bitmask for overlaid region
> mtd: spi-nor: sfdp: Fix wrong index of last erase region
> mtd: spi-nor: core: Fix erase type discovery for overlaid region
> mtd: spi-nor: core: Fix erase command list setup for
>
> drivers/mtd/spi-nor/core.c | 10 ++++++----
> drivers/mtd/spi-nor/sfdp.c | 5 ++---
> 2 files changed, 8 insertions(+), 7 deletions(-)
>
> --
> 2.25.1
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/4] mtd: spi-nor: Fix non-uniform erase map issues
2021-01-24 10:34 ` [PATCH 0/4] mtd: spi-nor: Fix non-uniform erase map issues Tudor.Ambarus
@ 2021-01-25 3:11 ` Takahiro Kuwano
0 siblings, 0 replies; 8+ messages in thread
From: Takahiro Kuwano @ 2021-01-25 3:11 UTC (permalink / raw)
To: Tudor.Ambarus, linux-mtd, Takahiro.Kuwano
Cc: richard, Bacem.Daassi, vigneshr, miquel.raynal
Hi Tudor,
On 1/24/2021 7:34 PM, Tudor.Ambarus@microchip.com wrote:
> Hi, Takahiro,
>
> Are these theoretical fixes or do they fix the non uniform erase
> on some flash?
They fix non uniform erase on the S25HL-T/S25HS-T that added by:
https://patchwork.ozlabs.org/project/linux-mtd/patch/20201127064043.29541-1-Takahiro.Kuwano@infineon.com/
And theoretically, they should fix on S25FS-S family that also
has non uniform erase option.
Thank you for looking into this.
Best Regards,
Takahiro
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/4] mtd: spi-nor: Fix non-uniform erase map issues
2020-10-02 5:17 [PATCH 0/4] mtd: spi-nor: Fix non-uniform erase map issues tkuw584924
` (4 preceding siblings ...)
2021-01-24 10:34 ` [PATCH 0/4] mtd: spi-nor: Fix non-uniform erase map issues Tudor.Ambarus
@ 2021-02-05 13:31 ` Tudor Ambarus
5 siblings, 0 replies; 8+ messages in thread
From: Tudor Ambarus @ 2021-02-05 13:31 UTC (permalink / raw)
To: tkuw584924, linux-mtd
Cc: vigneshr, Tudor Ambarus, richard, Bacem.Daassi, miquel.raynal,
Takahiro Kuwano
On Fri, 2 Oct 2020 14:17:58 +0900, tkuw584924@gmail.com wrote:
> This patchset fixes the issues in handling non-uniform erase map.
>
> Takahiro Kuwano (4):
> mtd: spi-nor: sfdp: Fix wrong erase type bitmask for overlaid region
> mtd: spi-nor: sfdp: Fix wrong index of last erase region
> mtd: spi-nor: core: Fix erase type discovery for overlaid region
> mtd: spi-nor: core: Fix erase command list setup for
>
> [...]
Updated commit description in 3/4, and added Fixes tags and
Cc to stable for all.
Applied to spi-nor/next, thanks!
[1/4] mtd: spi-nor: sfdp: Fix wrong erase type bitmask for overlaid region
https://git.kernel.org/mtd/c/abdf5a5ef965
[2/4] mtd: spi-nor: sfdp: Fix last erase region marking
https://git.kernel.org/mtd/c/9166f4af32db
[3/4] mtd: spi-nor: core: Fix erase type discovery for overlaid region
https://git.kernel.org/mtd/c/969b276718de
[4/4] mtd: spi-nor: core: Add erase size check for erase command initialization
https://git.kernel.org/mtd/c/58fa22f68fca
Best regards,
--
Tudor Ambarus <tudor.ambarus@microchip.com>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 8+ messages in thread