• Brian Norris's avatar
    mtd: nand: wait to set BBT version · dadc17a3
    Brian Norris authored
    Because there are so many cases of checking, writing, and re-writing of
    the bad block table(s), we might as well wait until the we've settled on
    a valid, clean copy of the table. This also prevents us from falsely
    incrementing the table version. For example, we may have the following:
    
      Primary table, with version 0x02
      Mirror table, with version 0x01
      Primary table has uncorrectable ECC errors
    
    If we don't have this fix applied, then we will:
    
      Choose to read the primary table (higher version)
      Set mirror table version to 0x02
      Read back primary table
      Invalidate table because of ECC errors
      Retry readback operation with mirror table, now version 0x02
      Mirrored table reads cleanly
      Writeback BBT to primary table location (with "version 0x02")
    
    However, the mirrored table shouldn't have a new version number.
    Instead, we actually want:
    
      Choose to read the primary table (higher version)
      Read back primary table
      Invalidate table because of ECC errors
      Retry readback with mirror table (version 0x01)
      Mirrored table reads cleanly
      Set both tables to version 0x01
      Writeback BBT to primary table location (version 0x01)
    Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
    Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@intel.com>
    dadc17a3
nand_bbt.c 38 KB