u-boot-brain/drivers/mtd/nand/raw
Peng Fan 552c88273e nand: mxs: fix the bitflips for erased page when uncorrectable error
This patch is porting from linux:
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/commit/
?h=imx_4.1.15_1.0.0_ga&id=3d42fcece496224fde59f9343763fb2dfc5b0768

"
We may meet the bitflips in reading an erased page(contains all 0xFF),
this may causes the UBIFS corrupt, please see the log from Elie:

-----------------------------------------------------------------
[    3.831323] UBI warning: ubi_io_read: error -74 (ECC error) while reading 16384 bytes from PEB 443:245760, read only 16384 bytes, retry
[    3.845026] UBI warning: ubi_io_read: error -74 (ECC error) while reading 16384 bytes from PEB 443:245760, read only 16384 bytes, retry
[    3.858710] UBI warning: ubi_io_read: error -74 (ECC error) while reading 16384 bytes from PEB 443:245760, read only 16384 bytes, retry
[    3.872408] UBI error: ubi_io_read: error -74 (ECC error) while reading 16384 bytes from PEB 443:245760, read 16384 bytes
...
[    4.011529] UBIFS error (pid 36): ubifs_recover_leb: corrupt empty space LEB 27:237568, corruption starts at 9815
[    4.021897] UBIFS error (pid 36): ubifs_scanned_corruption: corruption at LEB 27:247383
[    4.030000] UBIFS error (pid 36): ubifs_scanned_corruption: first 6569 bytes from LEB 27:247383
-----------------------------------------------------------------

This patch does a check for the uncorrectable failure in the following steps:

   [0] set the threshold.
       The threshold is set based on the truth:
       "A single 0 bit will lead to gf_len(13 or 14) bits 0 after the BCH
        do the ECC."

        For the sake of safe, we will set the threshold with half the gf_len, and
        do not make it bigger the ECC strength.

   [1] count the bitflips of the current ECC chunk, assume it is N.

   [2] if the (N <= threshold) is true, we continue to read out the page with
       ECC disabled. and we count the bitflips again, assume it is N2.
       (We read out the whole page, not just a chunk, this makes the check
        more strictly, and make the code more simple.)

   [3] if the (N2 <= threshold) is true again, we can regard this is a erased
       page. This is because a real erased page is full of 0xFF(maybe also has
       several bitflips), while a page contains the 0xFF data will definitely
       has many bitflips in the ECC parity areas.

   [4] if the [3] fails, we can regard this is a page filled with the '0xFF'
       data.
"

Signed-off-by: Peng Fan <peng.fan@nxp.com>
2020-05-10 20:55:20 +02:00
..
brcmnand nand: brcmnand: return without disabling clock 2020-04-27 20:29:33 +02:00
am335x_spl_bch.c mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
arasan_nfc.c mtd: nand: Fix on-die ecc issues in arasan_nfc driver 2020-02-28 12:04:10 +01:00
atmel_nand_ecc.h mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
atmel_nand.c dm: core: Create a new header file for 'compat' features 2020-02-05 19:33:46 -07:00
davinci_nand.c nand: davinci: avoid out of bounds array access 2019-07-31 13:08:07 -04:00
denali_dt.c dm: core: Create a new header file for 'compat' features 2020-02-05 19:33:46 -07:00
denali_spl.c mtd: rawnand: denali-spl: Add missing hardware init on SoCFPGA 2020-02-01 01:14:32 +09:00
denali.c dma-mapping: move dma_map_(un)single() to <linux/dma-mapping.h> 2020-02-19 21:27:30 +08:00
denali.h mtd: rawnand: denali: Do not reset the block before booting the kernel 2020-02-01 01:14:32 +09:00
fsl_elbc_nand.c dm: core: Require users of devres to include the header 2020-02-05 19:33:46 -07:00
fsl_elbc_spl.c common: Move ARM cache operations out of common.h 2019-12-02 18:24:58 -05:00
fsl_ifc_nand.c dm: core: Require users of devres to include the header 2020-02-05 19:33:46 -07:00
fsl_ifc_spl.c common: Move ARM cache operations out of common.h 2019-12-02 18:24:58 -05:00
fsl_upm.c mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
fsmc_nand.c mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
kb9202_nand.c mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
Kconfig mtd: rawnand: denali_dt: use UCLASS_MTD instead of UCLASS_MISC 2020-02-01 01:14:32 +09:00
kirkwood_nand.c mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
kmeter1_nand.c mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
lpc32xx_nand_mlc.c mtd: nand: lpc32xx mlc: predefine number of NAND chips to support 2018-11-16 13:34:36 -05:00
lpc32xx_nand_slc.c mtd: nand: lpc32xx slc: disable DMA support in SPL builds 2018-11-16 13:34:37 -05:00
Makefile drivers: nand: brcmnand: add initial support 2019-04-22 11:55:58 -04:00
mxc_nand_spl.c common: Move hang() to the same header as panic() 2020-01-17 17:53:40 -05:00
mxc_nand.c mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
mxc_nand.h mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
mxs_nand_dt.c mtd: gpmi: provide the option to use legacy bch geometry 2020-05-10 20:55:20 +02:00
mxs_nand_spl.c dm: core: Require users of devres to include the header 2020-02-05 19:33:46 -07:00
mxs_nand.c nand: mxs: fix the bitflips for erased page when uncorrectable error 2020-05-10 20:55:20 +02:00
nand_base.c dm: core: Require users of devres to include the header 2020-02-05 19:33:46 -07:00
nand_bbt.c dm: core: Require users of devres to include the header 2020-02-05 19:33:46 -07:00
nand_bch.c dm: core: Require users of devres to include the header 2020-02-05 19:33:46 -07:00
nand_ecc.c mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
nand_ids.c mtd: nand: raw: Add Hynix H27UBG8T2BTR id table 2019-01-02 00:58:16 +05:30
nand_plat.c mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
nand_spl_load.c mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
nand_spl_loaders.c mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
nand_spl_simple.c mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
nand_timings.c dm: core: Require users of devres to include the header 2020-02-05 19:33:46 -07:00
nand_util.c dm: core: Require users of devres to include the header 2020-02-05 19:33:46 -07:00
nand.c mtd: rename CONFIG_MTD_DEVICE -> CONFIG_MTD 2019-12-03 23:04:10 -05:00
omap_elm.c mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
omap_gpmc.c mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
pxa3xx_nand.c mtd: nand: pxa3xx: fix raw read when last_chunk_size == 0 2020-04-24 15:17:14 -04:00
pxa3xx_nand.h mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
stm32_fmc2_nand.c dm: core: Require users of devres to include the header 2020-02-05 19:33:46 -07:00
sunxi_nand_spl.c mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
sunxi_nand.c dm: core: Create a new header file for 'compat' features 2020-02-05 19:33:46 -07:00
tegra_nand.c dm: core: Create a new header file for 'compat' features 2020-02-05 19:33:46 -07:00
tegra_nand.h mtd: move NAND files into a raw/ subdirectory 2018-09-20 20:10:49 +05:30
vf610_nfc.c dm: core: Create a new header file for 'compat' features 2020-02-05 19:33:46 -07:00
zynq_nand.c ARM: zynq: Fix invalid check on NAND_CMD_NONE. 2020-04-27 14:21:18 +02:00