aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/pending-4.9
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2017-11-03 09:53:54 +0100
committerFelix Fietkau <nbd@nbd.name>2017-11-06 16:38:25 +0100
commitc08293893aadca182b52ef96d3c2b1700282f0f2 (patch)
treeb7cd8f1ea172201bb358c920437952dc53cf6c95 /target/linux/generic/pending-4.9
parent94491a15712732c56dccbf4593000376ae275134 (diff)
downloadupstream-c08293893aadca182b52ef96d3c2b1700282f0f2.tar.gz
upstream-c08293893aadca182b52ef96d3c2b1700282f0f2.tar.bz2
upstream-c08293893aadca182b52ef96d3c2b1700282f0f2.zip
kernel: add support for limiting 4K erase sector support based on flash chip size
Some targets need 4K sectors for small flash chips (e.g. some routerboards, where the entire chip is just one "erase block"), whereas on other devices 4K sectors lead to horrible flash erase/write performance. Set the default limit in the generic kernel configuration to 4 MiB to ensure that all new platforms don't use 4K sectors for bigger flash chips. On all existing targets use 16 MiB for now to avoid regressions. They will be changed individually in follow-up commits. Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'target/linux/generic/pending-4.9')
-rw-r--r--target/linux/generic/pending-4.9/470-mtd-spi-nor-support-limiting-4K-sectors-support-base.patch56
1 files changed, 56 insertions, 0 deletions
diff --git a/target/linux/generic/pending-4.9/470-mtd-spi-nor-support-limiting-4K-sectors-support-base.patch b/target/linux/generic/pending-4.9/470-mtd-spi-nor-support-limiting-4K-sectors-support-base.patch
new file mode 100644
index 0000000000..e1c1de3602
--- /dev/null
+++ b/target/linux/generic/pending-4.9/470-mtd-spi-nor-support-limiting-4K-sectors-support-base.patch
@@ -0,0 +1,56 @@
+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
+@@ -29,6 +29,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.
++
+ config SPI_ATMEL_QUADSPI
+ tristate "Atmel Quad SPI Controller"
+ depends on ARCH_AT91 || (ARM && COMPILE_TEST)
+--- a/drivers/mtd/spi-nor/spi-nor.c
++++ b/drivers/mtd/spi-nor/spi-nor.c
+@@ -1642,10 +1642,12 @@ int spi_nor_scan(struct spi_nor *nor, co
+
+ #ifdef CONFIG_MTD_SPI_NOR_USE_4K_SECTORS
+ /* prefer "small sector" erase if possible */
+- if (info->flags & SECT_4K) {
++ if ((info->flags & SECT_4K) && (mtd->size <=
++ CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT * 1024)) {
+ nor->erase_opcode = SPINOR_OP_BE_4K;
+ mtd->erasesize = 4096;
+- } else if (info->flags & SECT_4K_PMC) {
++ } else if ((info->flags & SECT_4K_PMC) && (mtd->size <=
++ CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT * 1024)) {
+ nor->erase_opcode = SPINOR_OP_BE_4K_PMC;
+ mtd->erasesize = 4096;
+ } else