mtd: spi-nor: Fix non-uniform erase map issues
Subsystems (2)
cover mtd: spi-nor: Fix non-uniform erase map issues
From: Takahiro Kuwano <[email protected]>
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(-)
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 1/4 mtd: spi-nor: sfdp: Fix wrong erase type bitmask for overlaid region
From: Takahiro Kuwano <[email protected]>
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)'.
--- drivers/mtd/spi-nor/sfdp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/sfdp.c +1 -1
@@ -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);
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 2/4 mtd: spi-nor: sfdp: Fix last erase region marking
In reply to [email protected]From: Takahiro Kuwano <[email protected]>
The place of spi_nor_region_mark_end() must be moved, because 'i' is re-used for the index of erase[].
--- drivers/mtd/spi-nor/sfdp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mtd/spi-nor/sfdp.c +1 -2
@@ -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 ; }
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 3/4 mtd: spi-nor: core: Fix erase type discovery for overlaid region
In reply to [email protected]From: Takahiro Kuwano <[email protected]>
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'.
--- drivers/mtd/spi-nor/core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/mtd/spi-nor/core.c +5 -4
@@ -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 ;
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 4/4 mtd: spi-nor: core: Add erase size check for erase command initialization
In reply to [email protected]From: Takahiro Kuwano <[email protected]>
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.
--- drivers/mtd/spi-nor/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/spi-nor/core.c +1 -0
@@ -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)) {
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Hi, Takahiro,
Are these theoretical fixes or do they fix the non uniform erase on some flash?
Cheers,
ta
Quoted 12 lines · On 10/2/20 8:17 AM, [email protected] wrote:
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
From: Takahiro Kuwano <[email protected]>
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
Quoted 7 lines
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/
Hi Tudor,
Quoted 4 lines · On 1/24/2021 7:34 PM, [email protected] 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/[email protected]/
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/
Tudor Ambarus
AppliedQuoted 9 lines · On Fri, 2 Oct 2020 14:17:58 +0900, [email protected] 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,
Signature · 5 lines
Tudor Ambarus <[email protected]> ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/