Nikolay Martynov | 28 Nov 07:57 2015

[PATCH] mtd: nandsim: use id_bytes exactly as passed

Currently when 5 bytes are passed as id_bytes the actual id
would be set to 6 bytes long. This means that it is not possible
to properly emulate chips with 5 bytes ids.

This patch addresses this problem

Signed-off-by: Nikolay Martynov <mar.kolya <at>>
 drivers/mtd/nand/nandsim.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index 52c0c1a..4659540 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
 <at>  <at>  -107,6 +107,7  <at>  <at>  static unsigned int overridesize = 0;
 static char *cache_file = NULL;
 static unsigned int bbt;
 static unsigned int bch;
+static unsigned int id_bytes_length;
 static u_char id_bytes[8] = {
 <at>  <at>  -115,7 +116,7  <at>  <at>  static u_char id_bytes[8] = {
 	[4 ... 7] = 0xFF,

-module_param_array(id_bytes, byte, NULL, 0400);
+module_param_array(id_bytes, byte, &id_bytes_length, 0400);
 module_param_named(first_id_byte, id_bytes[0], byte, 0400);
(Continue reading)

Sebastian Andrzej Siewior | 26 Nov 21:23 2015

[PATCH 1/3] mtd: ubi: fixup error correction in do_sync_erase()

Since fastmap we gained do_sync_erase(). This function can return an error
and its error handling isn't obvious. First the memory allocation for
struct ubi_work can fail and as such struct ubi_wl_entry is leaked.
However if the memory allocation succeeds then the tail function takes
care of the struct ubi_wl_entry. A free here could result in a double
To make the error handling simpler, I split the tail function into one
piece which does the work and another which frees the struct ubi_work
which is passed as argument. As result do_sync_erase() can keep the
struct on stack and we get rid of one error source.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy <at>>
 drivers/mtd/ubi/wl.c | 52 ++++++++++++++++++++++++++++------------------------
 1 file changed, 28 insertions(+), 24 deletions(-)

diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index eb4489f9082f..f73233fa737c 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
 <at>  <at>  -603,6 +603,7  <at>  <at>  static int schedule_erase(struct ubi_device *ubi, struct ubi_wl_entry *e,
 	return 0;

+static int __erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk);
  * do_sync_erase - run the erase worker synchronously.
  *  <at> ubi: UBI device description object
 <at>  <at>  -615,20 +616,16  <at>  <at>  static int schedule_erase(struct ubi_device *ubi, struct ubi_wl_entry *e,
 static int do_sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e,
(Continue reading)

Felix Fietkau | 26 Nov 17:27 2015

[PATCH] Revert "mtd: spi-nor: disable protection for Winbond flash at startup"

This reverts commit c6fc2171b249e73745c497b578b417a2946f1b2f.

This commit is breaking read access on at least s25fl064k, but also
possibly other Spansion flash chips.

Any mtd read seems to succeed, but simply returns a zero-filled buffer.

Signed-off-by: Felix Fietkau <nbd <at>>
 drivers/mtd/spi-nor/spi-nor.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 4988390..8b8842e 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
 <at>  <at>  -1194,14 +1194,13  <at>  <at>  int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)

-	 * Atmel, SST, Intel/Numonyx, and others serial NOR tend to power up
-	 * with the software protection bits set
+	 * Atmel, SST and Intel/Numonyx serial nor tend to power
+	 * up with the software protection bits set

 	if (JEDEC_MFR(info) == SNOR_MFR_ATMEL ||
 	    JEDEC_MFR(info) == SNOR_MFR_INTEL ||
-	    JEDEC_MFR(info) == SNOR_MFR_SST ||
-	    JEDEC_MFR(info) == SNOR_MFR_WINBOND) {
(Continue reading)

Rafał Miłecki | 26 Nov 09:05 2015

[PATCH] mtd: spi-nor: include mtd.h header for struct mtd_info definition

So far struct spi_nor was using just a pointer to struct mtd_info so it
wasn't needed to have it fully defined there. After recent change we
embed whole struct so we need to include a proper header.

Fixes: 1976367173a4 ("mtd: spi-nor: embed struct mtd_info within struct spi_nor")
Signed-off-by: Rafał Miłecki <zajec5 <at>>
 include/linux/mtd/spi-nor.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 7bed974..fac3f6f 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
 <at>  <at>  -12,6 +12,7  <at>  <at> 

 #include <linux/bitops.h>
 #include <linux/mtd/cfi.h>
+#include <linux/mtd/mtd.h>

  * Manufacturer IDs
 <at>  <at>  -117,8 +118,6  <at>  <at>  enum spi_nor_option_flags {

-struct mtd_info;
  * struct spi_nor - Structure for defining a the SPI NOR layer
(Continue reading)

Nikolay Martynov | 26 Nov 07:25 2015

[PATCH] mtd: nand: Fix Spansion sparearea size detection

According to datasheet S34ML02G2 and S34ML04G2 have
larger sparea area size than was detected.

Signed-off-by: Nikolay Martynov <mar.kolya <at>>
 drivers/mtd/nand/nand_base.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index ceb68ca..2c01f9e 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
 <at>  <at>  -3415,6 +3415,7  <at>  <at>  static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip,
 	 * Field definitions are in the following datasheets:
 	 * Old style (4,5 byte ID): Samsung K9GAG08U0M (p.32)
+	 *                          Spansion S34ML02G2 (p.33)
 	 * New Samsung (6 byte ID): Samsung K9GAG08U0F (p.44)
 	 * Hynix MLC   (6 byte ID): Hynix H27UBG8T2B (p.22)
 <at>  <at>  -3512,6 +3513,14  <at>  <at>  static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip,
 		*busw = (extid & 0x01) ? NAND_BUSWIDTH_16 : 0;

+		 * Spansion S34ML0[24]G2 have oobsize twice as large
+		 * as S34ML01G2 encoded in the same bit. We
+		 * differentiate them by their ID length
+		 */
+		if (id_len == 5 && id_data[0] == NAND_MFR_AMD)
+			mtd->oobsize *= 2;
(Continue reading)

David Oberhollenzer | 25 Nov 13:41 2015

[RFC][PATCH] mtd-utils: Add read disturb test utility

 - Read disturb test mode repeatedly reads range of blocks
   and counts bit flips. The page with the highest number is
   reported for each block.
 - Implements functionallity of proposed in-kernel read
   disturb test.
 - MLC test mode counts and compares bit flips before and after
   writing to a paired page.
 - Still looking for a better name for the utility.

Signed-off-by: David Oberhollenzer <david.oberhollenzer <at>>
 .gitignore                   |   1 +
 Makefile                     |   2 +-
 nand-utils/readdisturbtest.c | 397 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 399 insertions(+), 1 deletion(-)
 create mode 100644 nand-utils/readdisturbtest.c

diff --git a/.gitignore b/.gitignore
index 2aac52c..7fa8468 100644
--- a/.gitignore
+++ b/.gitignore
 <at>  <at>  -35,6 +35,7  <at>  <at> 
diff --git a/Makefile b/Makefile
(Continue reading)

Maureen Hinckley | 25 Nov 05:29 2015

good day

Greetings To You, 
I am Maureen Hinckley and i won my Power ball Jackpot of $61.5 Million dollars in December 11, 2013, My
jackpot was a gift from God to me and my entire family/foundation has agreed to do the will of
foundation is donating $550,000USD to you. Contact us via my email at (maureenhinckley0 <at> for
further/full details. Best Regards, Maureen Hinckley. Copyright ©2015• The Maureen Hinckley
Foundation• All Rights Reserved.

Linux MTD discussion mailing list
Sebastian Andrzej Siewior | 23 Nov 19:09 2015

[RFC] avoid a live lock in wear_leveling_worker()

  This has been debugged + tested on v3.0 and then forward ported to
  v4.0-rc2. From what I see the problem should still occur whith proper

On boot I managed run into a live lock situation within UBI. For $reason
UBI triggered ensure_wear_leveling() and decided to move a block.

It reads the VID header and then invokes ubi_eba_copy_leb(). It tries to
leb_write_trylock() but the PEB is already locked by `sshd' (which is in
UBI-read path, waiting for the NAND device) so it returns MOVE_RETRY.
Based on MOVE_RETRY UBI decides to invoked schedule_erase() on the empty
The erase_worker() shows up on the CPU almost right away. It erases the
PEB via sync_erase() and then invokes ensure_wear_leveling() and decides
to move a block. The situation repeats as described in the previous
chapter. The only thing changed since the previous iteration is the EC

UBI expects that MOVE_RETRY is a temporary situation while here it is
Each invocation of schedule_erase() invokes nand_get_device() which
succeeds so the UBI background threads owns the NAND device and can erase
a block. During the erase process the UBI threads schedules away while the
NAND drivers waits for an interrupt. While idle, the scheduler puts run able
tasks on the CPU. Two of them are waiting on the wait queue in
nand_get_device() but did not yet have the chance to run since the last
nand_release_device() invocation. One of them owns the PEB lock that causes
ubi_eba_copy_leb() return MOVE_RETRY.
(Continue reading)

Ezequiel Garcia | 23 Nov 02:09 2015

[PATCH] mtd: spi-nor: wait until lock/unlock operations are ready

On Micron and Numonyx devices, the status register write command
(WRSR), raises a work-in-progress bit (WIP) on the status register.
The datasheets for these devices specify that while the status
register write is in progress, the status register WIP bit can still
be read to check the end of the operation.

This commit adds a wait_till_ready call on lock/unlock operations,
only for these manufacturers. This is needed to prevent applications
from issuing erase or program operations before the unlock operation
is completed.

Reported-by: Stas Sergeev <stsp <at>>
Signed-off-by: Ezequiel Garcia <ezequiel <at>>
 drivers/mtd/spi-nor/spi-nor.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index e9c26c0e2258..acc9b05e02be 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
 <at>  <at>  -485,6 +485,7  <at>  <at>  static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
 	u8 status_old, status_new;
 	u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
 	u8 shift = ffs(mask) - 1, pow, val;
+	int ret;

 	status_old = read_sr(nor);

 <at>  <at>  -521,7 +522,13  <at>  <at>  static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
(Continue reading)

Richard Weinberger | 22 Nov 22:43 2015

Re: can't mount ubifs after resizing with ubirsvol


Am 19.11.2015 um 16:46 schrieb Ibrahim Mattus Neto:
> Hi!
> On 19/11/2015 13:02, Richard Weinberger wrote:
>> Am 19.11.2015 um 15:09 schrieb Konstantin Tokarev:
>>> I can confirm that shrinking UBIFS volume corrupts it.
>> There are no UBIFS volumes.
> You mean that there are no UBIFS volumes because of the config file? e.g.

UBIFS has no volumes, it is a filesystem.
UBI has volumes. :-)

>  [data]
>  mode=ubi
>  vol_id=1
>  vol_type=dynamic
>  vol_name=data
>  vol_alignment=1
>  vol_flags=autoresize
>  vol_size=10MiB
>> If you shrink a UBI volume, you kill UBIFS for sure.
>> It is like shrinking a HDD partition without resizing ext4 before.
> In this case, should I use ubiupdatevol (with a new ubifs file) after resizing the ubi volume?
(Continue reading)

Lars-Peter Clausen | 21 Nov 12:14 2015

[PATCH] mtd: nand: r852: Remove unnecessary synchronize_irq() before free_irq()

Calling synchronize_irq() right before free_irq() is quite useless. On one
hand the IRQ can easily fire again before free_irq() is entered, on the
other hand free_irq() itself calls synchronize_irq() internally (in a race
condition free way), before any state associated with the IRQ is freed.

Patch was generated using the following semantic patch:
// <smpl>
 <at>  <at> 
expression irq;
 <at>  <at> 
 free_irq(irq, ...);
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars <at>>
 drivers/mtd/nand/r852.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/mtd/nand/r852.c b/drivers/mtd/nand/r852.c
index d8bb2be..be28cdd 100644
--- a/drivers/mtd/nand/r852.c
+++ b/drivers/mtd/nand/r852.c
 <at>  <at>  -980,7 +980,6  <at>  <at>  static void r852_remove(struct pci_dev *pci_dev)

 	/* Stop interrupts */
-	synchronize_irq(dev->irq);
 	free_irq(dev->irq, dev);

(Continue reading)