kernel: cut broken SPI_NOR 4K eraseblock LIMIT patch
authorJohn Thomson <git@johnthomson.fastmail.com.au>
Tue, 28 Sep 2021 10:51:56 +0000 (20:51 +1000)
committerKoen Vandeputte <koen.vandeputte@ncentric.com>
Wed, 29 Jun 2022 10:34:49 +0000 (12:34 +0200)
Since 4e0c54bc5bc8 ("kernel: add support for kernel 5.4"),
the spi-nor limit 4k erasesize to spi-nor chips below a configured size
patch has not functioned as intended.

For uniform erasesize SPI-NOR devices, both
nor->erase_opcode & mtd->erasesize are used in erase operations.
These are set before, and not modified by, this
CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT patch.
Thus, an SPI-NOR device with CONFIG_MTD_SPI_NOR_USE_4K_SECTORS will
always use 4k erasesize (where the device supports it).

If this patch was fixed to function as intended, there would be
cases where devices change from a 4K to a 64K erasesize.

Signed-off-by: John Thomson <git@johnthomson.fastmail.com.au>
target/linux/generic/config-5.10
target/linux/generic/config-5.15
target/linux/generic/pending-5.10/470-mtd-spi-nor-support-limiting-4K-sectors-support-base.patch [deleted file]
target/linux/generic/pending-5.15/470-mtd-spi-nor-support-limiting-4K-sectors-support-base.patch [deleted file]
target/linux/layerscape/armv8_64b/config-5.10
target/linux/pistachio/config-5.10
target/linux/ramips/mt7620/config-5.10
target/linux/ramips/rt305x/config-5.10
target/linux/ramips/rt3883/config-5.10

index a08b8c56866599c4b0b120eb1c71a5bbbab15778..27584795195818a84885ab34b6321bfba880c4d2 100644 (file)
@@ -3671,7 +3671,6 @@ CONFIG_MTD_ROOTFS_ROOT_DEV=y
 # CONFIG_MTD_SPI_NAND is not set
 # CONFIG_MTD_SPI_NOR is not set
 # CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
-CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT=4096
 # CONFIG_MTD_SPI_NOR_USE_VARIABLE_ERASE is not set
 CONFIG_MTD_SPLIT=y
 # CONFIG_MTD_SPLIT_BCM63XX_FW is not set
index 15e69f8d0144cbab32fed025798755779e0fb4dd..bd21e99356ec83973436a4e5dac0921ad8f7af5e 100644 (file)
@@ -3814,7 +3814,6 @@ CONFIG_MTD_ROOTFS_ROOT_DEV=y
 CONFIG_MTD_SPI_NOR_SWP_DISABLE_ON_VOLATILE=y
 # CONFIG_MTD_SPI_NOR_SWP_KEEP is not set
 # CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
-CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT=4096
 # CONFIG_MTD_SPI_NOR_USE_VARIABLE_ERASE is not set
 CONFIG_MTD_SPLIT=y
 # CONFIG_MTD_SPLIT_BCM63XX_FW is not set
diff --git a/target/linux/generic/pending-5.10/470-mtd-spi-nor-support-limiting-4K-sectors-support-base.patch b/target/linux/generic/pending-5.10/470-mtd-spi-nor-support-limiting-4K-sectors-support-base.patch
deleted file mode 100644 (file)
index b79c6bb..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-From: Felix Fietkau <nbd@nbd.name>
-Date: Sat, 4 Nov 2017 07:40:23 +0100
-Subject: [PATCH] mtd: spi-nor: support limiting 4K sectors support based on
- flash size
-
-Some devices need 4K sectors to be able to deal with small flash chips.
-For instance, w25x05 is 64 KiB in size, and without 4K sectors, the
-entire chip is just one erase block.
-On bigger flash chip sizes, using 4K sectors can significantly slow down
-many operations, including using a writable filesystem. There are several
-platforms where it makes sense to use a single kernel on both kinds of
-devices.
-
-To support this properly, allow configuring an upper flash chip size
-limit for 4K sectors support.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/drivers/mtd/spi-nor/Kconfig
-+++ b/drivers/mtd/spi-nor/Kconfig
-@@ -34,6 +34,17 @@ config MTD_SPI_NOR_USE_4K_SECTORS
-         Please note that some tools/drivers/filesystems may not work with
-         4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum).
-+config MTD_SPI_NOR_USE_4K_SECTORS_LIMIT
-+      int "Maximum flash chip size to use 4K sectors on (in KiB)"
-+      depends on MTD_SPI_NOR_USE_4K_SECTORS
-+      default "4096"
-+      help
-+        There are many flash chips that support 4K sectors, but are so large
-+        that using them significantly slows down writing large amounts of
-+        data or using a writable filesystem.
-+        Any flash chip larger than the size specified in this option will
-+        not use 4K sectors.
-+
- source "drivers/mtd/spi-nor/controllers/Kconfig"
- endif # MTD_SPI_NOR
---- a/drivers/mtd/spi-nor/core.c
-+++ b/drivers/mtd/spi-nor/core.c
-@@ -2801,6 +2801,21 @@ static void spi_nor_info_init_params(str
-        */
-       erase_mask = 0;
-       i = 0;
-+#ifdef CONFIG_MTD_SPI_NOR_USE_4K_SECTORS
-+      if ((info->flags & SECT_4K_PMC) && (params->size <=
-+                 CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT * 1024)) {
-+              erase_mask |= BIT(i);
-+              spi_nor_set_erase_type(&map->erase_type[i], 4096u,
-+                                     SPINOR_OP_BE_4K_PMC);
-+              i++;
-+      } else if ((info->flags & SECT_4K) && (params->size <=
-+          CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT * 1024)) {
-+              erase_mask |= BIT(i);
-+              spi_nor_set_erase_type(&map->erase_type[i], 4096u,
-+                                     SPINOR_OP_BE_4K);
-+              i++;
-+      }
-+#else
-       if (info->flags & SECT_4K_PMC) {
-               erase_mask |= BIT(i);
-               spi_nor_set_erase_type(&map->erase_type[i], 4096u,
-@@ -2812,6 +2827,7 @@ static void spi_nor_info_init_params(str
-                                      SPINOR_OP_BE_4K);
-               i++;
-       }
-+#endif
-       erase_mask |= BIT(i);
-       spi_nor_set_erase_type(&map->erase_type[i], info->sector_size,
-                              SPINOR_OP_SE);
diff --git a/target/linux/generic/pending-5.15/470-mtd-spi-nor-support-limiting-4K-sectors-support-base.patch b/target/linux/generic/pending-5.15/470-mtd-spi-nor-support-limiting-4K-sectors-support-base.patch
deleted file mode 100644 (file)
index 1649a55..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-From: Felix Fietkau <nbd@nbd.name>
-Date: Sat, 4 Nov 2017 07:40:23 +0100
-Subject: [PATCH] mtd: spi-nor: support limiting 4K sectors support based on
- flash size
-
-Some devices need 4K sectors to be able to deal with small flash chips.
-For instance, w25x05 is 64 KiB in size, and without 4K sectors, the
-entire chip is just one erase block.
-On bigger flash chip sizes, using 4K sectors can significantly slow down
-many operations, including using a writable filesystem. There are several
-platforms where it makes sense to use a single kernel on both kinds of
-devices.
-
-To support this properly, allow configuring an upper flash chip size
-limit for 4K sectors support.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/drivers/mtd/spi-nor/Kconfig
-+++ b/drivers/mtd/spi-nor/Kconfig
-@@ -78,6 +78,17 @@ config MTD_SPI_NOR_SWP_KEEP
- endchoice
-+config MTD_SPI_NOR_USE_4K_SECTORS_LIMIT
-+      int "Maximum flash chip size to use 4K sectors on (in KiB)"
-+      depends on MTD_SPI_NOR_USE_4K_SECTORS
-+      default "4096"
-+      help
-+        There are many flash chips that support 4K sectors, but are so large
-+        that using them significantly slows down writing large amounts of
-+        data or using a writable filesystem.
-+        Any flash chip larger than the size specified in this option will
-+        not use 4K sectors.
-+
- source "drivers/mtd/spi-nor/controllers/Kconfig"
- endif # MTD_SPI_NOR
---- a/drivers/mtd/spi-nor/core.c
-+++ b/drivers/mtd/spi-nor/core.c
-@@ -2640,6 +2640,21 @@ static void spi_nor_info_init_params(str
-        */
-       erase_mask = 0;
-       i = 0;
-+#ifdef CONFIG_MTD_SPI_NOR_USE_4K_SECTORS
-+      if ((info->flags & SECT_4K_PMC) && (params->size <=
-+                 CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT * 1024)) {
-+              erase_mask |= BIT(i);
-+              spi_nor_set_erase_type(&map->erase_type[i], 4096u,
-+                                     SPINOR_OP_BE_4K_PMC);
-+              i++;
-+      } else if ((info->flags & SECT_4K) && (params->size <=
-+          CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT * 1024)) {
-+              erase_mask |= BIT(i);
-+              spi_nor_set_erase_type(&map->erase_type[i], 4096u,
-+                                     SPINOR_OP_BE_4K);
-+              i++;
-+      }
-+#else
-       if (info->flags & SECT_4K_PMC) {
-               erase_mask |= BIT(i);
-               spi_nor_set_erase_type(&map->erase_type[i], 4096u,
-@@ -2651,6 +2666,7 @@ static void spi_nor_info_init_params(str
-                                      SPINOR_OP_BE_4K);
-               i++;
-       }
-+#endif
-       erase_mask |= BIT(i);
-       spi_nor_set_erase_type(&map->erase_type[i], info->sector_size,
-                              SPINOR_OP_SE);
index 149884a5f6a1291c9873c632c18e6774420fd55d..0f46d1cde9d1dd20fc29e28d2332f50391658750 100644 (file)
@@ -511,7 +511,6 @@ CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y
-CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT=16384
 CONFIG_MTD_SPLIT_FIRMWARE=y
 CONFIG_MTD_SPLIT_FIT_FW=y
 CONFIG_MTD_SST25L=y
index d62c5e90217d02f0ba3333c57bf012f01e07242b..9e43b64b0b1da7a015de465f749669de57c0f28c 100644 (file)
@@ -178,7 +178,6 @@ CONFIG_MTD_NAND_CORE=y
 CONFIG_MTD_SPI_NAND=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y
-CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT=16384
 CONFIG_MTD_UBI=y
 CONFIG_MTD_UBI_BEB_LIMIT=20
 CONFIG_MTD_UBI_BLOCK=y
index bb7e50da5d0543c919b552eb79a398e3ce3d362c..8fae1adc373a55f396c21ef025e288b940b5d58b 100644 (file)
@@ -116,7 +116,6 @@ CONFIG_MTD_CMDLINE_PARTS=y
 CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y
-CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT=16384
 CONFIG_MTD_SPLIT_JIMAGE_FW=y
 CONFIG_MTD_SPLIT_SEAMA_FW=y
 CONFIG_MTD_SPLIT_TPLINK_FW=y
index c3c4cf6b0de5fd0926182d10aa31a8e92687c2a5..b41ddb22acac99249f562f6e6fd060dcaa87117a 100644 (file)
@@ -106,7 +106,6 @@ CONFIG_MTD_CMDLINE_PARTS=y
 CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y
-CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT=16384
 CONFIG_MTD_SPLIT_JIMAGE_FW=y
 CONFIG_MTD_SPLIT_SEAMA_FW=y
 CONFIG_MTD_SPLIT_UIMAGE_FW=y
index cb1db1ab8205adac494af9bd43c7ca7e19a789ed..b59ad98b603bfe48d7bc29c14521eab522fa0ea9 100644 (file)
@@ -104,7 +104,6 @@ CONFIG_MTD_CMDLINE_PARTS=y
 CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y
-CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT=16384
 CONFIG_MTD_SPLIT_SEAMA_FW=y
 CONFIG_MTD_SPLIT_UIMAGE_FW=y
 CONFIG_NEED_DMA_MAP_STATE=y