linux/drivers/mtd/nand
Brian Norris e2414f4c20 mtd: nand: write BBM to OOB even with flash-based BBT
Currently, the flash-based BBT implementation writes bad block data only
to its flash-based table and not to the OOB marker area. Then, as new bad
blocks are marked over time, the OOB markers become incomplete and the
flash-based table becomes the only source of current bad block
information. This becomes an obvious problem when, for example:

 * bootloader cannot read the flash-based BBT format
 * BBT is corrupted and the flash must be rescanned for bad
   blocks; we want to remember bad blocks that were marked from Linux

So to keep the bad block markers in sync with the flash-based BBT, this
patch changes the default so that we write bad block markers to the proper
OOB area on each block in addition to flash-based BBT. Comments are
updated, expanded, and/or relocated as necessary.

The new flash-based BBT procedure for marking bad blocks:
 (1) erase the affected block, to allow OOB marker to be written cleanly
 (2) update in-memory BBT
 (3) write bad block marker to OOB area of affected block
 (4) update flash-based BBT
Note that we retain the first error encountered in (3) or (4), finish the
procedures, and dump the error in the end.

This should handle power cuts gracefully enough. (1) and (2) are mostly
harmless (note that (1) will not erase an already-recognized bad block).
The OOB and BBT may be "out of sync" if we experience power loss bewteen
(3) and (4), but we can reasonably expect that on next boot, subsequent
I/O operations will discover that the block should be marked bad again,
thus re-syncing the OOB and BBT.

Note that this is a change from the previous default flash-based BBT
behavior. If your system cannot support writing bad block markers to OOB,
use the new NAND_BBT_NO_OOB_BBM option (in combination with
NAND_BBT_USE_FLASH and NAND_BBT_NO_OOB).

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2012-03-27 00:27:02 +01:00
..
gpmi-nand mtd: nand: gpmi: use correct member for checking NAND_BBT_USE_FLASH 2012-03-27 00:21:33 +01:00
alauda.c mtd: add leading underscore to all mtd functions 2012-03-27 00:20:01 +01:00
ams-delta.c mtd: convert drivers/mtd/* to use module_platform_driver() 2012-01-09 18:12:35 +00:00
atmel_nand_ecc.h [ARM] 5265/3: [AT91] Add copyright info 2008-09-21 23:01:18 +01:00
atmel_nand.c Revert "mtd: atmel_nand: optimize read/write buffer functions" 2012-02-04 08:04:57 +00:00
au1550nd.c MTD: nand: make au1550nd.c a platform_driver 2011-12-08 10:42:10 +00:00
autcpu12.c mtd: nand: rename NAND_USE_FLASH_BBT 2011-09-11 15:01:56 +03:00
bcm_umi_bch.c mtd: add bcmring nand driver 2009-10-20 10:07:23 +09:00
bcm_umi_nand.c mtd: convert drivers/mtd/* to use module_platform_driver() 2012-01-09 18:12:35 +00:00
bf5xx_nand.c mtd: bf5xx_nand: convert to mtd_device_register() 2011-05-25 02:23:15 +01:00
cafe_nand.c Merge git://git.infradead.org/mtd-2.6 2011-11-07 09:11:16 -08:00
cmx270_nand.c Merge git://git.infradead.org/mtd-2.6 2011-11-07 09:11:16 -08:00
cs553x_nand.c mtd: cs553x_nand.c: use mtd_device_parse_register 2011-09-11 15:02:08 +03:00
davinci_nand.c mtd: davinci: if no amif timing is passed, don; t setup cscfg register 2012-01-09 18:13:25 +00:00
denali.c mtd: denali: detect the number of banks before resetting NAND 2011-09-11 15:02:04 +03:00
denali.h mtd: denali: detect the number of banks 2011-05-25 02:02:12 +01:00
diskonchip.c mtd: introduce mtd_read interface 2012-01-09 18:25:19 +00:00
docg4.c mtd: docg4: fix printk() warnings 2012-03-27 00:21:44 +01:00
fsl_elbc_nand.c mtd: nand: Add ONFI support for FSL NAND controller 2012-01-09 18:18:47 +00:00
fsl_upm.c mtd: convert drivers/mtd/* to use module_platform_driver() 2012-01-09 18:12:35 +00:00
fsmc_nand.c mtd: fsmc_nand.c: use mtd_device_parse_register 2011-09-11 15:02:08 +03:00
gpio.c mtd: gpio-nand: add device tree bindings 2012-01-09 18:23:58 +00:00
h1910.c mtd: h1910.c: use mtd_device_parse_register 2011-09-11 15:02:08 +03:00
jz4740_nand.c mtd: convert drivers/mtd/* to use module_platform_driver() 2012-01-09 18:12:35 +00:00
Kconfig mtd: nand: add support for diskonchip G4 nand flash device 2012-03-27 00:18:31 +01:00
Makefile mtd: nand: add support for diskonchip G4 nand flash device 2012-03-27 00:18:31 +01:00
mpc5121_nfc.c mtd: convert drivers/mtd/* to use module_platform_driver() 2012-01-09 18:12:35 +00:00
mxc_nand.c mtd: mxc_nand: preset_v1_v2: unlock all NAND flash blocks 2011-09-23 15:25:35 +03:00
nand_base.c mtd: nand: write BBM to OOB even with flash-based BBT 2012-03-27 00:27:02 +01:00
nand_bbt.c mtd: introduce mtd_write_oob interface 2012-01-09 18:25:24 +00:00
nand_bch.c mtd: cleanup style on pr_debug messages 2011-09-11 15:02:16 +03:00
nand_bcm_umi.c mtd: add bcmring nand driver 2009-10-20 10:07:23 +09:00
nand_bcm_umi.h mtd: nand_bcm: fix hot spin and code duplication 2010-02-26 16:56:35 +00:00
nand_ecc.c mtd: spelling, capitalization, uniformity 2011-09-11 15:02:13 +03:00
nand_ids.c mtd: nand: add 512 Mbit device code (Macronix) 2012-01-09 17:59:44 +00:00
nandsim.c mtd: introduce mtd_block_markbad interface 2012-01-09 18:25:48 +00:00
ndfc.c mtd: convert drivers/mtd/* to use module_platform_driver() 2012-01-09 18:12:35 +00:00
nomadik_nand.c mtd: introduce mtd_resume interface 2012-01-09 18:25:46 +00:00
nuc900_nand.c mtd: convert drivers/mtd/* to use module_platform_driver() 2012-01-09 18:12:35 +00:00
omap2.c mtd: convert drivers/mtd/* to use module_platform_driver() 2012-01-09 18:12:35 +00:00
orion_nand.c mtd: orion_nand.c: use mtd_device_parse_register 2011-09-11 15:02:09 +03:00
pasemi_nand.c mtd: convert drivers/mtd/* to use module_platform_driver() 2012-01-09 18:12:35 +00:00
plat_nand.c mtd: convert drivers/mtd/* to use module_platform_driver() 2012-01-09 18:12:35 +00:00
ppchameleonevb.c mtd: ppchameleonevb.c: use mtd_device_parse_register 2011-09-11 15:02:09 +03:00
pxa3xx_nand.c module_param: make bool parameters really bool (drivers & misc) 2012-01-13 09:32:20 +10:30
r852.c module_param: make bool parameters really bool (drivers & misc) 2012-01-13 09:32:20 +10:30
r852.h mtd: r852: remove useless pci powerup/down from suspend/resume routines 2010-10-25 01:32:21 +01:00
rtc_from4.c mtd: replace DEBUG() with pr_debug() 2011-09-11 15:02:16 +03:00
s3c2410.c mtd: s3c2410 nand: Remove uncessary null check 2011-09-11 15:02:17 +03:00
sh_flctl.c mtd: convert remaining users to mtd_device_register() 2011-05-25 02:25:00 +01:00
sharpsl.c mtd: convert drivers/mtd/* to use module_platform_driver() 2012-01-09 18:12:35 +00:00
sm_common.c mtd: introduce mtd_write_oob interface 2012-01-09 18:25:24 +00:00
sm_common.h mtd: sm_common: split smartmedia and xD table 2010-05-14 01:03:46 +01:00
socrates_nand.c mtd: convert drivers/mtd/* to use module_platform_driver() 2012-01-09 18:12:35 +00:00
spia.c mtd: convert remaining users to mtd_device_register() 2011-05-25 02:25:00 +01:00
tmio_nand.c mtd: convert drivers/mtd/* to use module_platform_driver() 2012-01-09 18:12:35 +00:00
txx9ndfmc.c mtd: txx9ndfmc: use devm_request_and_ioremap 2012-01-09 18:24:11 +00:00