archive mirror
 help / color / mirror / Atom feed
From: "Thibaut VARÈNE" <>
	"Thibaut VARÈNE" <>
Subject: [PATCH v3 3/3] mtd: spi-nor: allow overriding uniform erase
Date: Fri, 29 Jul 2022 11:16:36 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

This patch introduces a new CONFIG_MTD_SPI_NOR_USE_VARIABLE_ERASE option
which forces an SPI NOR mtd device to use non-uniform erase, enabling
(on supporting hardware) to complete erase operations using all
available erasesizes through spi_nor_erase_multi_sectors().

The majority of current SPI NOR devices support multiple erasesizes:
instead of forcing all operations to use 4K erase size for everything
(using CONFIG_MTD_SPI_NOR_USE_4K_SECTORS) when write access to a
minor-aligned partition is needed, this patch allows the kernel to use
the largest suitable erase size for a given operation, thus improving

Signed-off-by: John Thomson <>
Signed-off-by: Thibaut VARÈNE <>
 drivers/mtd/spi-nor/Kconfig | 10 ++++++++++
 drivers/mtd/spi-nor/core.c  |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index 24cd25de2..09df9f1a8 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -10,6 +10,16 @@ menuconfig MTD_SPI_NOR
+	bool "Disable uniform_erase to allow use of all hardware supported erasesizes"
+	depends on !MTD_SPI_NOR_USE_4K_SECTORS
+	default n
+	help
+	  Allow mixed use of all hardware supported erasesizes,
+	  by forcing spi_nor to use the multiple eraseregions code path.
+	  For example: A 68K erase will use one 64K erase, and one 4K erase
+	  on supporting hardware.
 	bool "Use small 4096 B erase sectors"
 	default y
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index bafd3396e..b4b539a9f 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1048,6 +1048,8 @@ static u8 spi_nor_convert_3to4_erase(u8 opcode)
 static bool spi_nor_has_uniform_erase(const struct spi_nor *nor)
+		return false;
 	return !!nor->params->erase_map.uniform_erase_type;

Linux MTD discussion mailing list

  parent reply	other threads:[~2022-07-29  9:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-29  9:16 [PATCH v3 0/3] mtd: write support for minor-aligned partitions Thibaut VARÈNE
2022-07-29  9:16 ` [PATCH v3 1/3] mtd: mtdpart: " Thibaut VARÈNE
2022-07-29  9:16 ` [PATCH v3 2/3] mtd: spi-nor: set erasesize_minor for non-uniform erase Thibaut VARÈNE
2022-07-29  9:16 ` Thibaut VARÈNE [this message]
2022-08-09  9:23 ` [PATCH v3 0/3] mtd: write support for minor-aligned partitions Thibaut VARÈNE
2022-08-09 15:45   ` Tudor.Ambarus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).