1. 27 3月, 2012 6 次提交
    • B
      mtd: nand: write BBM to OOB even with flash-based BBT · e2414f4c
      Brian Norris 提交于
      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: NBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      e2414f4c
    • A
      mtd: add leading underscore to all mtd functions · 3c3c10bb
      Artem Bityutskiy 提交于
      This patch renames all MTD functions by adding a "_" prefix:
      
      mtd->erase -> mtd->_erase
      mtd->read_oob -> mtd->_read_oob
      ...
      
      The reason is that we are re-working the MTD API and from now on it is
      an error to use MTD function pointers directly - we have a corresponding
      API call for every pointer. By adding a leading "_" we achieve the following:
      
      1. Make sure we convert every direct pointer users
      2. A leading "_" suggests that this interface is internal and it becomes
         less likely that people will use them directly
      3. Make sure all the out-of-tree modules stop compiling and the owners
         spot the big API change and amend them.
      Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      3c3c10bb
    • B
      mtd: nand: move SCANLASTPAGE handling to the correct code block · df698621
      Brian Norris 提交于
      As nand_default_block_markbad() is becoming more complex, it helps to
      have code appear only in its relevant codepath(s). Here, the calculation
      of `ofs' based on NAND_BBT_SCANLASTPAGE is only useful on paths where we
      write bad block markers to OOB. We move the condition/calculation closer
      to the `write' operation and update the comment to more correctly
      describe the operation.
      
      The variable `wr_ofs' is also used to help isolate our calculation of
      the "write" offset from the usage of `ofs' to represent the eraseblock
      offset. This will become useful when we reorder operations in the next
      patch.
      
      This patch should make no functional change.
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      df698621
    • B
      mtd: nand: differentiate 1- vs. 2-byte writes when marking bad blocks · 85443319
      Brian Norris 提交于
      It seems that we have developed a bad-block-marking "feature" out of
      pure laziness:
      
        "We write two bytes per location, so we dont have to mess with 16 bit
        access."
      
      It's relatively simple to write a 1 byte at a time on x8 devices and 2
      bytes at a time on x16 devices, so let's do it.
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      85443319
    • B
      mtd: nand: fix SCAN2NDPAGE check for BBM · cdbec050
      Brian Norris 提交于
      nand_block_bad() doesn't check the correct pages when
      NAND_BBT_SCAN2NDPAGE is enabled. It should scan both the OOB region of
      both the 1st and 2nd page of each block.
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      cdbec050
    • B
      mtd: nand: erase block before marking bad · 00918429
      Brian Norris 提交于
      Many NAND flash systems (especially those with MLC NAND) cannot be
      reliably written twice in a row. For instance, when marking a bad block,
      the block may already have data written to it, and so we should attempt
      to erase the block before writing a bad block marker to its OOB region.
      
      We can ignore erase failures, since the block may be bad such that it
      cannot be erased properly; we still attempt to write zeros to its spare
      area.
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      00918429
  2. 11 1月, 2012 1 次提交
  3. 10 1月, 2012 1 次提交
  4. 16 10月, 2011 1 次提交
    • B
      mtd: nand: initialize ops.mode · 23b1a99b
      Brian Norris 提交于
      Our `ops' information was converted to a local variable recently, and
      apparently, old code relied on the fact that the global version was
      often left in a valid mode. We can't make this assumption on local
      structs, and we shouldn't be relying on a previous state anyway.
      
      Instead, we initialize mode to 0 for don't-care situations (i.e., the
      operation does not use OOB anyway) and MTD_OPS_PLACE_OOB when we want to
      place OOB data.
      
      This fixes a bug with nand_default_block_markbad(), where we catch on
      the BUG() call in nand_fill_oob():
      
      Kernel bug detected[#1]:
      ...
      Call Trace:
      [<80307350>] nand_fill_oob.clone.5+0xa4/0x15c
      [<803075d8>] nand_do_write_oob+0x1d0/0x260
      [<803077c4>] nand_default_block_markbad+0x15c/0x1a8
      [<802e8c2c>] part_block_markbad+0x80/0x98
      [<802ebc74>] mtd_ioctl+0x6d8/0xbd0
      [<802ec1a4>] mtd_unlocked_ioctl+0x38/0x5c
      [<800d9c60>] do_vfs_ioctl+0xa4/0x6e4
      [<800da2e4>] sys_ioctl+0x44/0xa0
      [<8001381c>] stack_done+0x20/0x40
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      23b1a99b
  5. 21 9月, 2011 1 次提交
    • B
      mtd: nand: invalidate cache on unaligned reads · 6d77b9d0
      Brian Norris 提交于
      In rare cases, we are given an unaligned parameter `from' in
      `nand_do_read_ops()'. In such cases, we use the page cache
      (chip->buffers->databuf) as an intermediate buffer before dumping to the
      client buffer. However, there are also cases where this buffer is not
      cleanly reusable. In those cases, we need to make sure that we
      explicitly invalidate the cache.
      
      This patch prevents accidental reusage of the page cache, and for me,
      this solves some problems I come across when reading a corrupted BBT
      from flash (NAND_BBT_USE_FLASH and NAND_BBT_NO_OOB).
      
      Note: the rare "unaligned" case is a result of the extra BBT pattern +
      version located in the data area instead of OOB.
      
      Also, this patch disables caching on raw reads, since we are reading
      without error correction. This is, obviously, prone to errors and should
      not be cached.
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@intel.com>
      6d77b9d0
  6. 11 9月, 2011 18 次提交
  7. 25 5月, 2011 3 次提交
  8. 31 3月, 2011 1 次提交
  9. 12 3月, 2011 1 次提交
    • I
      mtd: nand: add software BCH ECC support · 193bd400
      Ivan Djelic 提交于
      This patch adds software BCH ECC support to mtd, in order to handle recent
      NAND device ecc requirements (4 bits or more).
      
      It does so by adding a new ecc mode (NAND_ECC_SOFT_BCH) for use by board
      drivers, and a new Kconfig option to enable BCH support. It relies on the
      generic BCH library introduced in a previous patch.
      
      When a board driver uses mode NAND_ECC_SOFT_BCH, it should also set fields
      chip->ecc.size and chip->ecc.bytes to select BCH ecc data size and required
      error correction capability. See nand_bch_init() documentation for details.
      
      It has been tested on the following platforms using mtd-utils, UBI and
      UBIFS: x86 (with nandsim), arm926ejs.
      Signed-off-by: NIvan Djelic <ivan.djelic@parrot.com>
      Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      193bd400
  10. 11 3月, 2011 1 次提交
  11. 06 1月, 2011 4 次提交
  12. 04 12月, 2010 2 次提交