[PATCH v1] mtd: gpmi: Bitflip support in erased regions

Elie De Brauwer eliedebrauwer at gmail.com
Fri Dec 13 05:00:45 EST 2013


On Fri, Dec 13, 2013 at 9:49 AM, Huang Shijie <b32955 at freescale.com> wrote:
> On Wed, Dec 11, 2013 at 09:24:58PM +0800, Huang Shijie wrote:
>> On Mon, Dec 09, 2013 at 08:58:10PM +0100, Elie De Brauwer wrote:
>> > programmed to 0 (meaning that the entire page should consist of bytes of
>> > 0xFF. For MLC NAND devices, bit errors may occur on reads (even on blank
>> > pages), so this threshold can be used to tune the erased page checking
>> > algorithm."
>> >
>> > So as my solution I'm setting this erase threshold to the ecc_strength
>> > derived from the geometry, meaning that I will tolerate the same number of
>> > bitflips the BCH block would consider correctable.
>> > The side effect is that whever I'm reading a page (gpmi_ecc_read_page() )
> A solution is to check the HW_BCH_STATUS0:ALLONES.
>
> If it is all ones, we do not check it by software.

Ah, the HW_BCH_STATUS0 register does indeed contain some interesting bits:
- ALLONES  1 = All data bits of this transaction are ONE
(source: imx datasheet page 1292)

Hence I will change gpmi_err_read_page() from my original patch
gpmi_ecc_read_page(). Going from something like:

if (*status == STATUS_ERASED)
    /* Erased block, check/correct bitflips manually. */
    flips = erased_sector_bitflips(payload_virt, i, nfc_geo);
else
   /* BCH block corrected some errors for us. */
   flips = *status;

Into something more

if (*status == STATUS_ERASED)
    if (readl(HW_BCH_STATUS0 & BM_BCH_STATUS0_ALLONES))
        flips = 0;
    else
        /* Erased block, check/correct bitflips manually. */
        flips = erased_sector_bitflips(payload_virt, i, nfc_geo);
else
   /* BCH block corrected some errors for us. */
   flips = *status;


(Hiding the readl() in a function in gpmi-lib.c since all register
peek-n-poke is occuring there). And this way only doing the
soft-bitflip-check where absolutely necessary (where necessary is
defined on a page granularity).

I will provide a v2 of my patch incorporating these changes after I've
had a chance to test them on hardware. (Somewhere this
evening/tomorrow).

>
>
>> > which the BCH block marked as "erased" I need to take a software approach.
>> > The software approach is inspired on what is currently
>> > done in the omap2 driver (but not free from discussion). At that point I
>> > now that the page can contain up to ecc_strenght bitflips, so I need to
>>
>> The ecc_strength can be 40 sometimes.
>
> The only problem is what is the proper value for ERASE_THRESHOLD.
>
> still need more investigate.

Okay, I'm awaiting input on this.

The reason why I set this to ecc_strength was because I assumed that
the BCH could correct up to ecc_strength biterrors, hence I could fix
this amount of bitflips myself. But I agree it can be rough estimate.
In my specific case hardcoding it to 1 would have already fixed it.


Thanks for your feedback !



-- 
Elie De Brauwer



More information about the linux-mtd mailing list