ubi: fix data aborts in case of NAND bit flips during block read

The UBI layer generates the following data aborts if any of the
NAND block contains bit flips

    ubi0: attaching mtd2
    ubi0: fixable bit-flip detected at PEB 149
    ubi0: scanning is finished
    ubi0: fixable bit-flip detected at PEB 149
    data abort
    pc : [<4a934cc8>]          lr : [<4a933aec>]
    reloc pc : [<4a934cc8>]    lr : [<4a933aec>]
    sp : 4a77f2e0  ip : 00000095     fp : 00000075
    r10: 000001b7  r9 : 4a77fea0     r8 : 00000001
    r7 : 0001f000  r6 : 0001f000     r5 : 4a785e40  r4 : 4a7c4180
    r3 : 00000000  r2 : 00000075     r1 : 4a7860b8  r0 : 4a7c49c0
    Flags: nzcv  IRQs off  FIQs off  Mode SVC_32
    Resetting CPU ...

UBI layer will move the data from original block to some other
block in case of bit flips in the function ubi_eba_copy_leb. This
function uses volume EBA table vol->eba_tbl. The current UBI code
calls ubi_wl_init followed by ubi_eba_init but the ubi_eba_init
only initializes the volume EBA table. In case of bit failure,
the ubi_wl_init calls function __schedule_ubi_work which will
call ubi_eba_copy_leb and triggers data abort.

ubi_attach() {
    ubi_wl_init ->  __schedule_ubi_work -> ubi_eba_copy_leb
    ubi_eba_init
}

The UBI code has been written for Linux kernel and it has been
ported to UBOOT. Since UBOOT does not support threads so all the
thread functions are being called in uboot synchronously.
In Linux kernel, the UBI background thread starts
after the initialization, which is being controlled by
thread_enabled variable which will be set to true after all
initialization.

Now this patch checks for thread_enabled variable and call the
do_work only if the thread is enabled.

Change-Id: I4b2b40031dbd5f16ceefef541248973ca326cd9c
Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
1 file changed