generic: disable 'small sector' erase in m25p80 driver
authorGabor Juhos <juhosg@openwrt.org>
Tue, 13 Dec 2011 20:41:22 +0000 (20:41 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Tue, 13 Dec 2011 20:41:22 +0000 (20:41 +0000)
This fixes the issues with the jffs2 images on various boards. Using
JFFS2 on devices with 4KiB erase sectors is not safe:
http://lists.infradead.org/pipermail/linux-mtd/2011-June/036591.html

SVN-Revision: 29521

target/linux/generic/config-2.6.39
target/linux/generic/config-3.0
target/linux/generic/config-3.1
target/linux/generic/patches-2.6.39/475-mtd-m25p80-allow-to-disable-small-sector-erase.patch [new file with mode: 0644]
target/linux/generic/patches-3.0/476-mtd-m25p80-allow-to-disable-small-sector-erase.patch [new file with mode: 0644]
target/linux/generic/patches-3.1/476-mtd-m25p80-allow-to-disable-small-sector-erase.patch [new file with mode: 0644]

index fd6c5cdb06236bedeab433a9e1932120440999e2..b6bbc5ab26e1c441782506e015b643264fd8efbd 100644 (file)
@@ -1288,6 +1288,7 @@ CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_LXT_PHY is not set
 CONFIG_LZMA_COMPRESS=y
 CONFIG_LZMA_DECOMPRESS=y
+# CONFIG_M25PXX_PREFER_SMALL_SECTOR_ERASE is not set
 # CONFIG_MAC80211 is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
index bc31d94866f64f282321ba3f9e610480628b612d..ac04ad7468c4c10f8bb79e621ff0496662c0c477 100644 (file)
@@ -1278,6 +1278,7 @@ CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_LXT_PHY is not set
 CONFIG_LZMA_COMPRESS=y
 CONFIG_LZMA_DECOMPRESS=y
+# CONFIG_M25PXX_PREFER_SMALL_SECTOR_ERASE is not set
 # CONFIG_MAC80211 is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
index 2a0440c8b1b1f45f2c3babd313cc1d191018b0d5..64890b501168ff78b38107891568d02d6a6d4720 100644 (file)
@@ -1291,6 +1291,7 @@ CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_LXT_PHY is not set
 CONFIG_LZMA_COMPRESS=y
 CONFIG_LZMA_DECOMPRESS=y
+# CONFIG_M25PXX_PREFER_SMALL_SECTOR_ERASE is not set
 # CONFIG_MAC80211 is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
diff --git a/target/linux/generic/patches-2.6.39/475-mtd-m25p80-allow-to-disable-small-sector-erase.patch b/target/linux/generic/patches-2.6.39/475-mtd-m25p80-allow-to-disable-small-sector-erase.patch
new file mode 100644 (file)
index 0000000..484a24a
--- /dev/null
@@ -0,0 +1,41 @@
+--- a/drivers/mtd/devices/Kconfig
++++ b/drivers/mtd/devices/Kconfig
+@@ -102,6 +102,14 @@ config M25PXX_USE_FAST_READ
+       help
+         This option enables FAST_READ access supported by ST M25Pxx.
++config M25PXX_PREFER_SMALL_SECTOR_ERASE
++      bool "Prefer small sector erase"
++      depends on MTD_M25P80
++      default y
++      help
++        This option enables use of the small erase sectors if that is
++        supported by the flash chip.
++
+ config MTD_SST25L
+       tristate "Support SST25L (non JEDEC) SPI Flash chips"
+       depends on SPI_MASTER
+--- a/drivers/mtd/devices/m25p80.c
++++ b/drivers/mtd/devices/m25p80.c
+@@ -77,6 +77,12 @@
+ #define FAST_READ_DUMMY_BYTE 0
+ #endif
++#ifdef CONFIG_M25PXX_PREFER_SMALL_SECTOR_ERASE
++#define PREFER_SMALL_SECTOR_ERASE 1
++#else
++#define PREFER_SMALL_SECTOR_ERASE 0
++#endif
++
+ /****************************************************************************/
+ struct m25p {
+@@ -902,7 +908,7 @@ static int __devinit m25p_probe(struct s
+               flash->mtd.write = m25p80_write;
+       /* prefer "small sector" erase if possible */
+-      if (info->flags & SECT_4K) {
++      if (PREFER_SMALL_SECTOR_ERASE && (info->flags & SECT_4K)) {
+               flash->erase_opcode = OPCODE_BE_4K;
+               flash->mtd.erasesize = 4096;
+       } else if (info->flags & SECT_4K_PMC) {
diff --git a/target/linux/generic/patches-3.0/476-mtd-m25p80-allow-to-disable-small-sector-erase.patch b/target/linux/generic/patches-3.0/476-mtd-m25p80-allow-to-disable-small-sector-erase.patch
new file mode 100644 (file)
index 0000000..cc78d91
--- /dev/null
@@ -0,0 +1,41 @@
+--- a/drivers/mtd/devices/Kconfig
++++ b/drivers/mtd/devices/Kconfig
+@@ -102,6 +102,14 @@ config M25PXX_USE_FAST_READ
+       help
+         This option enables FAST_READ access supported by ST M25Pxx.
++config M25PXX_PREFER_SMALL_SECTOR_ERASE
++      bool "Prefer small sector erase"
++      depends on MTD_M25P80
++      default y
++      help
++        This option enables use of the small erase sectors if that is
++        supported by the flash chip.
++
+ config MTD_SST25L
+       tristate "Support SST25L (non JEDEC) SPI Flash chips"
+       depends on SPI_MASTER
+--- a/drivers/mtd/devices/m25p80.c
++++ b/drivers/mtd/devices/m25p80.c
+@@ -83,6 +83,12 @@
+ #define JEDEC_MFR(_jedec_id)  ((_jedec_id) >> 16)
++#ifdef CONFIG_M25PXX_PREFER_SMALL_SECTOR_ERASE
++#define PREFER_SMALL_SECTOR_ERASE 1
++#else
++#define PREFER_SMALL_SECTOR_ERASE 0
++#endif
++
+ /****************************************************************************/
+ struct m25p {
+@@ -924,7 +930,7 @@ static int __devinit m25p_probe(struct s
+               flash->mtd.write = m25p80_write;
+       /* prefer "small sector" erase if possible */
+-      if (info->flags & SECT_4K) {
++      if (PREFER_SMALL_SECTOR_ERASE && (info->flags & SECT_4K)) {
+               flash->erase_opcode = OPCODE_BE_4K;
+               flash->mtd.erasesize = 4096;
+       } else if (info->flags & SECT_4K_PMC) {
diff --git a/target/linux/generic/patches-3.1/476-mtd-m25p80-allow-to-disable-small-sector-erase.patch b/target/linux/generic/patches-3.1/476-mtd-m25p80-allow-to-disable-small-sector-erase.patch
new file mode 100644 (file)
index 0000000..cc78d91
--- /dev/null
@@ -0,0 +1,41 @@
+--- a/drivers/mtd/devices/Kconfig
++++ b/drivers/mtd/devices/Kconfig
+@@ -102,6 +102,14 @@ config M25PXX_USE_FAST_READ
+       help
+         This option enables FAST_READ access supported by ST M25Pxx.
++config M25PXX_PREFER_SMALL_SECTOR_ERASE
++      bool "Prefer small sector erase"
++      depends on MTD_M25P80
++      default y
++      help
++        This option enables use of the small erase sectors if that is
++        supported by the flash chip.
++
+ config MTD_SST25L
+       tristate "Support SST25L (non JEDEC) SPI Flash chips"
+       depends on SPI_MASTER
+--- a/drivers/mtd/devices/m25p80.c
++++ b/drivers/mtd/devices/m25p80.c
+@@ -83,6 +83,12 @@
+ #define JEDEC_MFR(_jedec_id)  ((_jedec_id) >> 16)
++#ifdef CONFIG_M25PXX_PREFER_SMALL_SECTOR_ERASE
++#define PREFER_SMALL_SECTOR_ERASE 1
++#else
++#define PREFER_SMALL_SECTOR_ERASE 0
++#endif
++
+ /****************************************************************************/
+ struct m25p {
+@@ -924,7 +930,7 @@ static int __devinit m25p_probe(struct s
+               flash->mtd.write = m25p80_write;
+       /* prefer "small sector" erase if possible */
+-      if (info->flags & SECT_4K) {
++      if (PREFER_SMALL_SECTOR_ERASE && (info->flags & SECT_4K)) {
+               flash->erase_opcode = OPCODE_BE_4K;
+               flash->mtd.erasesize = 4096;
+       } else if (info->flags & SECT_4K_PMC) {