Linux-mtd Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/4] mtd: spi-nor: Fix non-uniform erase map issues
@ 2020-10-02  5:17 tkuw584924
  2020-10-02  5:17 ` [PATCH 1/4] mtd: spi-nor: sfdp: Fix wrong erase type bitmask for overlaid region tkuw584924
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ 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>

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] 5+ messages in thread

* [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
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ 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	[flat|nested] 5+ 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
  2020-10-02  5:18 ` [PATCH 4/4] mtd: spi-nor: core: Add erase size check for erase command initialization tkuw584924
  3 siblings, 0 replies; 5+ 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(&region[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(&region[i - 1]);
-
 	return 0;
 }
 
-- 
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 5+ 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
  3 siblings, 0 replies; 5+ 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	[flat|nested] 5+ 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
  3 siblings, 0 replies; 5+ 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	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 3/4] mtd: spi-nor: core: Fix erase type discovery for overlaid region tkuw584924
2020-10-02  5:18 ` [PATCH 4/4] mtd: spi-nor: core: Add erase size check for erase command initialization tkuw584924

Linux-mtd Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mtd/0 linux-mtd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mtd linux-mtd/ https://lore.kernel.org/linux-mtd \
		linux-mtd@lists.infradead.org
	public-inbox-index linux-mtd

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mtd


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git