linux-stable/drivers/mtd
Masahiro Yamada 20d48595f8 mtd: nand: denali: fix bitflips calculation in handle_ecc()
This function is wrong in multiple ways:

[1] Counting corrected bytes instead of corrected bits.

The following code is counting the number of corrected _bytes_.

    /* correct the ECC error */
    buf[offset] ^= err_cor_value;
    mtd->ecc_stats.corrected++;
    bitflips++;

What the core framework expects is the number of corrected _bits_.
They can be different if multiple bitflips occur within one byte.

[2] total number of errors instead of max of per-sector errors

The core framework expects that corrected errors are counted per
sector, then the max value should be taken.  The current code simply
iterates over the whole page, i.e. counts the total number of
correction in the page.  This means "too many bitflips" is triggered
earlier than it should be, i.e. the NAND device is worn out sooner.

Besides those bugs, this function is unreadable due to the deep
nesting.  Notice the whole code in this function is wrapped in
if (irq_status & INTR__ECC_ERR), so this conditional can be moved
out of the function.  Also, use shorter names for local variables.

Re-work the function to fix all the issues.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2017-04-25 14:18:33 +02:00
..
chips mtd: cfi_cmdset_0020: Deinline do_write_buffer, save 5316 bytes 2016-07-09 18:53:33 -07:00
devices Merge branch 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm 2017-02-28 11:50:53 -08:00
lpddr mtd: lpddr: show parent device in sysfs 2015-10-13 09:21:17 -07:00
maps mtd: physmap_of: fixup gemini/versatile dependencies 2017-02-10 09:53:41 -08:00
nand mtd: nand: denali: fix bitflips calculation in handle_ecc() 2017-04-25 14:18:33 +02:00
onenand mtd: silence some uninitialized variable warnings 2016-07-09 18:14:39 -07:00
spi-nor mtd: aspeed: remove redundant dev_err call in aspeed_smc_probe() 2017-02-10 11:20:22 -08:00
tests sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h> 2017-03-02 08:42:32 +01:00
ubi statx: Add a system call to make enhanced file info available 2017-03-02 20:51:15 -05:00
afs.c mtd: partitions: make parsers return 'const' partition arrays 2015-12-09 10:21:57 -08:00
ar7part.c mtd: partitions: make parsers return 'const' partition arrays 2015-12-09 10:21:57 -08:00
bcm47xxpart.c mtd: bcm47xxpart: support layouts with multiple TRX partitions 2017-02-09 18:59:45 -08:00
bcm63xxpart.c mtd: bcm63xxpart: give width specifier an 'int', not 'size_t' 2016-03-07 13:13:58 -08:00
cmdlinepart.c mtd: partitions: make parsers return 'const' partition arrays 2015-12-09 10:21:57 -08:00
ftl.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
inftlcore.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
inftlmount.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
Kconfig mtd: bcm63xxpart: Remove dependency on mach-bcm63xx 2016-02-12 10:27:48 -08:00
Makefile
mtd_blkdevs.c block: fold cmd_type into the REQ_OP_ space 2017-01-31 14:00:44 -07:00
mtdblock.c
mtdblock_ro.c
mtdchar.c mtd: Fix typo: "occured" -> "occurred" 2017-02-08 14:24:57 -08:00
mtdconcat.c mtd: create an mtd_ooblayout_ops struct to ease ECC layout definition 2016-04-19 22:05:55 +02:00
mtdcore.c mtd: fix typos in ooblayout comment blocks 2017-02-08 13:32:08 -08:00
mtdcore.h mtd: partitions: support a cleanup callback for parsers 2015-12-09 14:57:44 -08:00
mtdoops.c
mtdpart.c mtd: Add partition device node to mtd partition devices 2017-02-09 19:19:25 -08:00
mtdsuper.c
mtdswap.c mtd: mtdswap: fix spelling mistake "erassure" -> "erasure" 2016-11-22 11:43:52 -08:00
nftlcore.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
nftlmount.c
ofpart.c mtd: Add partition device node to mtd partition devices 2017-02-09 19:19:25 -08:00
redboot.c mtd: partitions: make parsers return 'const' partition arrays 2015-12-09 10:21:57 -08:00
rfd_ftl.c
sm_ftl.c treewide: Fix typos in printk 2016-04-18 11:23:24 +02:00
sm_ftl.h
ssfdc.c mtd: Replace if and BUG with BUG_ON 2016-07-09 18:48:54 -07:00