linux_old1/drivers/mtd/nand
Alex Smith b70af9bef4 mtd: nand: increase ready wait timeout and report timeouts
If nand_wait_ready() times out, this is silently ignored, and its
caller will then proceed to read from/write to the chip before it is
ready. This can potentially result in corruption with no indication as
to why.

While a 20ms timeout seems like it should be plenty enough, certain
behaviour can cause it to timeout much earlier than expected. The
situation which prompted this change was that CPU 0, which is
responsible for updating jiffies, was holding interrupts disabled
for a fairly long time while writing to the console during a printk,
causing several jiffies updates to be delayed. If CPU 1 happens to
enter the timeout loop in nand_wait_ready() just before CPU 0 re-
enables interrupts and updates jiffies, CPU 1 will immediately time
out when the delayed jiffies updates are made. The result of this is
that nand_wait_ready() actually waits less time than the NAND chip
would normally take to be ready, and then read_page() proceeds to
read out bad data from the chip.

The situation described above may seem unlikely, but in fact it can be
reproduced almost every boot on the MIPS Creator Ci20.

Therefore, this patch increases the timeout to 400ms. This should be
enough to cover cases where jiffies updates get delayed. In nand_wait()
the timeout was previously chosen based on whether erasing or
programming. This is changed to be 400ms unconditionally as well to
avoid similar problems there. nand_wait() is also slightly refactored
to be consistent with nand_wait{,_status}_ready(). These changes should
have no effect during normal operation.

Debugging this was made more difficult by the misleading comment above
nand_wait_ready() stating "The timeout is caught later" - no timeout was
ever reported, leading me away from the real source of the problem.
Therefore, a pr_warn() is added when a timeout does occur so that it is
easier to pinpoint similar problems in future.

Signed-off-by: Alex Smith <alex.smith@imgtec.com>
Signed-off-by: Harvey Hunt <harvey.hunt@imgtec.com>
Reviewed-by: Niklas Cassel <niklas.cassel@axis.com>
Cc: Alex Smith <alex@alex-smith.me.uk>
Cc: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Niklas Cassel <niklas.cassel@axis.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-10-26 13:02:51 -07:00
..
bcm47xxnflash mtd: nand: bcm47xxnflash: show parent device in sysfs 2015-10-13 12:56:26 -07:00
brcmnand mtd: nand: pass page number to ecc->write_xxx() methods 2015-10-13 12:56:49 -07:00
gpmi-nand mtd: nand: pass page number to ecc->write_xxx() methods 2015-10-13 12:56:49 -07:00
Kconfig mtd: nand: Allow MTD_NAND_BRCMNAND to be selected for ARM64 2015-10-12 14:17:40 -07:00
Makefile mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others 2015-09-29 13:47:58 -07:00
ams-delta.c mtd: nand: ams-delta: fix overwritten mtd_info->owner in initialization 2015-01-15 19:33:03 -08:00
atmel_nand.c mtd: nand: pass page number to ecc->write_xxx() methods 2015-10-13 12:56:49 -07:00
atmel_nand_ecc.h mtd: atmel_nand: add a definition for the oob reserved bytes 2015-04-05 17:47:56 -07:00
atmel_nand_nfc.h mtd: atmel_nand: check NFC busy flag by HSMC_SR instead of NFC cmd regs 2015-03-11 09:49:28 -07:00
au1550nd.c mtd: nand: au1550nd: show parent device in sysfs 2015-10-13 12:56:25 -07:00
bf5xx_nand.c mtd: nand: pass page number to ecc->write_xxx() methods 2015-10-13 12:56:49 -07:00
cafe_nand.c mtd: nand: pass page number to ecc->write_xxx() methods 2015-10-13 12:56:49 -07:00
cmx270_nand.c mtd: cmx270_nand: Remove unnecessary OOM messages 2014-01-03 11:22:29 -08:00
cs553x_nand.c mtd: cs553x_nand: Fix kasprintf() usage 2015-06-16 18:58:47 -07:00
davinci_nand.c mtd: nand: davinci_nand: drop owner and name assignment 2015-10-13 12:56:28 -07:00
denali.c mtd: nand: pass page number to ecc->write_xxx() methods 2015-10-13 12:56:49 -07:00
denali.h mtd: nand: denali: max_banks calculation changed in revision 5.1 2015-09-29 11:44:59 -07:00
denali_dt.c mtd: nand: drop owner assignment from platform_drivers 2014-10-20 16:20:58 +02:00
denali_pci.c mtd: denali_pci: switch to dev_err() 2015-08-18 17:21:37 -07:00
diskonchip.c arch, drivers: don't include <asm/io.h> directly, use <linux/io.h> instead 2015-08-10 23:07:05 -04:00
docg4.c mtd: nand: pass page number to ecc->write_xxx() methods 2015-10-13 12:56:49 -07:00
fsl_elbc_nand.c mtd: nand: pass page number to ecc->write_xxx() methods 2015-10-13 12:56:49 -07:00
fsl_ifc_nand.c mtd: nand: pass page number to ecc->write_xxx() methods 2015-10-13 12:56:49 -07:00
fsl_upm.c mtd: nand: fsl_upm: show parent device in sysfs 2015-10-13 12:56:47 -07:00
fsmc_nand.c mtd: nand: fsmc_nand: show parent device in sysfs 2015-10-13 12:56:30 -07:00
gpio.c mtd: nand: gpio: show parent device in sysfs 2015-10-13 12:56:44 -07:00
hisi504_nand.c mtd: nand: pass page number to ecc->write_xxx() methods 2015-10-13 12:56:49 -07:00
jz4740_nand.c mtd: nand: jz4740_nand: show parent device in sysfs 2015-10-13 12:56:48 -07:00
lpc32xx_mlc.c mtd: lpc32xx_mlc: fix warnings caused by enabling unprepared clock 2015-10-19 18:23:15 -07:00
lpc32xx_slc.c mtd: lpc32xx_slc: fix warnings caused by enabling unprepared clock 2015-10-19 18:23:14 -07:00
mpc5121_nfc.c mtd: nand: mpc5121_nfc: show parent device in sysfs 2015-10-13 12:56:32 -07:00
mxc_nand.c mtd: nand: mxc_nand: drop owner assignment 2015-10-13 12:56:38 -07:00
nand_base.c mtd: nand: increase ready wait timeout and report timeouts 2015-10-26 13:02:51 -07:00
nand_bbt.c mtd: nand_bbt: set the smallest size of bbt table 2015-10-11 12:58:28 -07:00
nand_bch.c mtd: cleanup style on pr_debug messages 2011-09-11 15:02:16 +03:00
nand_ecc.c mtd: nand: add line feed to pr_err 2014-04-16 00:18:26 -07:00
nand_ids.c mtd: nand: add Toshiba TC58NVG0S3E to nand_ids table 2015-08-25 12:24:02 -07:00
nand_timings.c mtd: nand: Use ULL-suffix for big u64 constant 2014-08-19 11:53:09 -07:00
nandsim.c mtd: nandsim: drop null test before destroy functions 2015-09-21 17:04:50 -07:00
ndfc.c mtd: nand: ndfc: show parent device in sysfs 2015-10-13 12:56:39 -07:00
nuc900_nand.c mtd: nand: nuc900_nand: show parent device in sysfs 2015-10-13 12:56:33 -07:00
omap2.c mtd: nand: pass page number to ecc->write_xxx() methods 2015-10-13 12:56:49 -07:00
omap_elm.c mtd: omap_elm: Fix module alias 2015-08-18 17:57:46 -07:00
orion_nand.c mtd: nand: orion_nand: show parent device in sysfs 2015-10-13 12:56:33 -07:00
pasemi_nand.c mtd: nand: pasemi_nand: show parent device in sysfs 2015-10-13 12:56:39 -07:00
plat_nand.c mtd: nand: plat_nand: show parent device in sysfs 2015-10-13 12:56:34 -07:00
pxa3xx_nand.c mtd: pxa3xx_nand: clean up the pxa3xx timings 2015-10-26 11:38:12 -07:00
r852.c mtd: nand: r852: drop owner assignment 2015-10-13 12:56:35 -07:00
r852.h mtd: r852: remove useless pci powerup/down from suspend/resume routines 2010-10-25 01:32:21 +01:00
s3c2410.c mtd: nand: s3c2410: show parent device in sysfs 2015-10-13 12:56:42 -07:00
sh_flctl.c mtd: nand: pass page number to ecc->write_xxx() methods 2015-10-13 12:56:49 -07:00
sharpsl.c mtd: nand: sharpsl: show parent device in sysfs 2015-10-13 12:56:42 -07:00
sm_common.c mtd: nand: refactor chip->block_markbad interface 2013-08-30 16:47:52 +01:00
sm_common.h mtd: use __packed shorthand 2014-08-19 11:53:08 -07:00
socrates_nand.c mtd: nand: socrates_nand: drop owner assignment 2015-10-13 12:56:46 -07:00
sunxi_nand.c mtd: nand: pass page number to ecc->write_xxx() methods 2015-10-13 12:56:49 -07:00
tmio_nand.c mtd: nand: tmio_nand: show parent device in sysfs 2015-10-13 12:56:37 -07:00
txx9ndfmc.c mtd: nand: txx9ndfmc: show parent device in sysfs 2015-10-13 12:56:48 -07:00
vf610_nfc.c mtd: nand: pass page number to ecc->write_xxx() methods 2015-10-13 12:56:49 -07:00
xway_nand.c mtd: plat_nand: use default partition probe 2015-05-27 12:34:35 -07:00