1. 25 5月, 2011 1 次提交
    • G
      mtd: create function to perform large allocations · 33b53716
      Grant Erickson 提交于
      Introduce a common function to handle large, contiguous kmalloc buffer
      allocations by exponentially backing off on the size of the requested
      kernel transfer buffer until it succeeds or until the requested
      transfer buffer size falls below the page size.
      
      This helps ensure the operation can succeed under low-memory, highly-
      fragmented situations albeit somewhat more slowly.
      
      Artem: so this patch solves the problem that the kernel tries to kmalloc too
      large buffers, which (a) may fail and does fail - people complain about this,
      and (b) slows down the system in case of high memory fragmentation, because
      the kernel starts dropping caches, writing back, swapping, etc. But we do not
      really have to allocate a lot of memory to do the I/O, we may do this even with
      as little as one min. I/O unit (NAND page) of RAM. So the idea of this patch is
      that if the user asks to read or write a lot, we try to kmalloc a lot, with GFP
      flags which make the kernel _not_ drop caches, etc. If we can allocate it - good,
      if not - we try to allocate twice as less, and so on, until we reach the min.
      I/O unit size, which is our last resort allocation and use the normal
      GFP_KERNEL flag.
      
      Artem: re-write the allocation function so that it makes sure the allocated
      buffer is aligned to the min. I/O size of the flash.
      Signed-off-by: NGrant Erickson <marathon96@gmail.com>
      Tested-by: NBen Gardiner <bengardiner@nanometrics.ca>
      Tested-by: NStefano Babic <sbabic@denx.de>
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      33b53716
  2. 06 1月, 2011 1 次提交
    • A
      mtd: add writebufsize field to mtd_info struct · 0e4ca7e5
      Anatolij Gustschin 提交于
      This field will be used to indicate the write buffer size
      of the MTD device. UBI will set it's minimal I/O unit size
      (min_io_size) to the indicated write buffer size. By this
      change we intend to fix failed recovery of UBIFS partitions
      we currently observe on NOR flash when mounting the partition
      after unclean unmount.
      
      Currently the min_io_size is set to mtd->writesize (which is 1
      byte for NOR flash). But flash programming is often done from
      prepared write buffer containing multiple bytes and is performed
      in one programming operation which could be interrupted by a power
      cut or a system reset causing corrupted (partially written) areas
      in a flash sector. Knowing the size of potentially corrupted areas
      UBIFS scanning and recovery algorithms are able to perform
      successful recovery.
      
      In case of NOR flash minimal I/O size must be equal to the
      maximal size of the write buffer used by embedded flash
      programming algorithm. In case of NAND flash mtd->writebufsize
      should be equivalent to mtd->writesize.
      
      The subsequent patches will add mtd->writebufsize initialization
      where needed.
      Signed-off-by: NAnatolij Gustschin <agust@denx.de>
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      0e4ca7e5
  3. 25 10月, 2010 2 次提交
    • B
      mtd: edit comments on deprecation of ioctl ECCGETLAYOUT · 0ceacf36
      Brian Norris 提交于
      There were some improvements and additions necessary in the
      comments explaining of the expansion of nand_ecclayout, the
      introduction of nand_ecclayout_user, and the deprecation of the
      ioctl ECCGETLAYOUT.
      
      Also, I found a better placement for the macro MTD_MAX_ECCPOS_ENTRIES;
      next to the definition of MTD_MAX_OOBFREE_ENTRIES in mtd-abi.h. The macro
      is really only important for the ioctl code (found in drivers/mtd/mtdchar.c)
      but since there are small edits being made to the user-space header, I
      figured this is a better location.
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      0ceacf36
    • B
      mtd: nand: expand nand_ecc_layout, deprecate ioctl ECCGETLAYOUT · cc26c3cd
      Brian Norris 提交于
      struct nand_ecclayout is too small for many new chips; OOB regions can be as
      large as 448 bytes and may increase more in the future. Thus, copying that
      struct to user-space with the ECCGETLAYOUT ioctl is not a good idea; the ioctl
      would have to be updated every time there's a change to the current largest
      size.
      
      Instead, the old nand_ecclayout is renamed to nand_ecclayout_user and a
      new struct nand_ecclayout is created that can accomodate larger sizes and
      expand without affecting the user-space. struct nand_ecclayout can still
      be used in board drivers without modification -- at least for now.
      
      A new function is provided to convert from the new to the old in order to
      allow the deprecated ioctl to continue to work with truncated data. Perhaps
      the ioctl, the conversion process, and the struct nand_ecclayout_user can be
      removed altogether in the future.
      
      Note: There are comments in nand/davinci_nand.c::nand_davinci_probe()
      regarding this issue; this driver (and maybe others) can be updated to
      account for extra space. All kernel drivers can use the expanded
      nand_ecclayout as a drop-in replacement and ignore its benefits.
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      cc26c3cd
  4. 09 8月, 2010 2 次提交
  5. 02 8月, 2010 1 次提交
  6. 27 2月, 2010 2 次提交
  7. 25 2月, 2010 1 次提交
  8. 03 8月, 2009 1 次提交
  9. 04 4月, 2009 1 次提交
    • D
      [MTD] driver model updates · 1f24b5a8
      David Brownell 提交于
      Update driver model support in the MTD framework, so it fits
      better into the current udev-based hotplug framework:
      
       - Each mtd_info now has a device node.  MTD drivers should set
         the dev.parent field to point to the physical device, before
         setting up partitions or otherwise declaring MTDs.
      
       - Those device nodes always map to /sys/class/mtdX device nodes,
         which no longer depend on MTD_CHARDEV.
      
       - Those mtdX sysfs nodes have a "starter set" of attributes;
         it's not yet sufficient to replace /proc/mtd.
      
       - Enabling MTD_CHARDEV provides /sys/class/mtdXro/ nodes and the
         /sys/class/mtd*/dev attributes (for udev, mdev, etc).
      
       - Include a MODULE_ALIAS_CHARDEV_MAJOR macro.  It'll work with
         udev creating the /dev/mtd* nodes, not just a static rootfs.
      
      So the sysfs structure is pretty much what you'd expect, except
      that readonly chardev nodes are a bit quirky.
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      1f24b5a8
  10. 24 3月, 2009 1 次提交
  11. 06 1月, 2009 1 次提交
  12. 10 12月, 2008 2 次提交
  13. 12 8月, 2008 1 次提交
  14. 30 7月, 2008 1 次提交
  15. 22 7月, 2008 1 次提交
  16. 05 6月, 2008 1 次提交
  17. 02 5月, 2008 1 次提交
  18. 07 2月, 2008 1 次提交
    • R
      [MTD] Add mtd panic_write function pointer · 388bbb09
      Richard Purdie 提交于
      MTDs are well suited for logging critical data and the mtdoops driver
      allows kernel panics/oops to be written to flash in a blackbox flight
      recorder fashion allowing better debugging and analysis of crashes.
      
      Any kernel oops in user context can be easily handled since the kernel
      continues as normal and any queued mtd writes are scheduled. Any kernel
      oops in interrupt context results in a panic and the delayed writes will
      not be scheduled however. The existing mtd->write function cannot be
      called in interrupt context so these messages can never be written to
      flash.
      
      This patch adds a panic_write function pointer that drivers can
      optionally implement which can be called in interrupt context. It is
      only intended to be called when its known the kernel is about to panic
      and we need to write to succeed. Since the kernel is not going to be
      running for much longer, this function can break locks and delay to
      ensure the write succeeds (but not sleep).
      Signed-off-by: NRichard Purdie <rpurdie@rpsys.net>
      Signed-off-by: NDavid Woodhouse <dwmw2@infradead.org>
      388bbb09
  19. 21 9月, 2007 1 次提交
  20. 09 5月, 2007 2 次提交
  21. 03 4月, 2007 1 次提交
  22. 08 3月, 2007 1 次提交
    • V
      [MTD] [NAND] make oobavail public · 1f92267c
      Vitaly Wool 提交于
      During the MTD rework the oobavail parameter of mtd_info structure has become
      private. This is not quite correct in terms of integrity and logic. If we have
      means to write to OOB area, then we'd like to know upfront how many bytes out
      of OOB are spare per page to be able to adapt to specific cases.
      The patch inlined adds the public oobavail parameter.
      Signed-off-by: NVitaly Wool <vwool@ru.mvista.com>
      Signed-off-by: NDavid Woodhouse <dwmw2@infradead.org>
      1f92267c
  23. 09 2月, 2007 3 次提交
  24. 29 11月, 2006 5 次提交
  25. 29 6月, 2006 1 次提交
  26. 14 6月, 2006 1 次提交
  27. 30 5月, 2006 1 次提交
    • T
      [MTD] NAND Expose the new raw mode function and status info to userspace · f1a28c02
      Thomas Gleixner 提交于
      The raw read/write access to NAND (without ECC) has been changed in the
      NAND rework. Expose the new way - setting the file mode via ioctl - to
      userspace. Also allow to read out the ecc statistics information so userspace
      tools can see that bitflips happened and whether errors where correctable
      or not. Also expose the number of bad blocks for the partition, so nandwrite
      can check if the data fits into the parition before writing to it.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      f1a28c02
  28. 29 5月, 2006 2 次提交
    • T
      [MTD] Rework the out of band handling completely · 8593fbc6
      Thomas Gleixner 提交于
      Hopefully the last iteration on this!
      
      The handling of out of band data on NAND was accompanied by tons of fruitless
      discussions and halfarsed patches to make it work for a particular
      problem. Sufficiently annoyed by I all those "I know it better" mails and the
      resonable amount of discarded "it solves my problem" patches, I finally decided
      to go for the big rework. After removing the _ecc variants of mtd read/write
      functions the solution to satisfy the various requirements was to refactor the
      read/write _oob functions in mtd.
      
      The major change is that read/write_oob now takes a pointer to an operation
      descriptor structure "struct mtd_oob_ops".instead of having a function with at
      least seven arguments.
      
      read/write_oob which should probably renamed to a more descriptive name, can do
      the following tasks:
      
      - read/write out of band data
      - read/write data content and out of band data
      - read/write raw data content and out of band data (ecc disabled)
      
      struct mtd_oob_ops has a mode field, which determines the oob handling mode.
      
      Aside of the MTD_OOB_RAW mode, which is intended to be especially for
      diagnostic purposes and some internal functions e.g. bad block table creation,
      the other two modes are for mtd clients:
      
      MTD_OOB_PLACE puts/gets the given oob data exactly to/from the place which is
      described by the ooboffs and ooblen fields of the mtd_oob_ops strcuture. It's
      up to the caller to make sure that the byte positions are not used by the ECC
      placement algorithms.
      
      MTD_OOB_AUTO puts/gets the given oob data automaticaly to/from the places in
      the out of band area which are described by the oobfree tuples in the ecclayout
      data structre which is associated to the devicee.
      
      The decision whether data plus oob or oob only handling is done depends on the
      setting of the datbuf member of the data structure. When datbuf == NULL then
      the internal read/write_oob functions are selected, otherwise the read/write
      data routines are invoked.
      
      Tested on a few platforms with all variants. Please be aware of possible
      regressions for your particular device / application scenario
      
      Disclaimer: Any whining will be ignored from those who just contributed "hot
      air blurb" and never sat down to tackle the underlying problem of the mess in
      the NAND driver grown over time and the big chunk of work to fix up the
      existing users. The problem was not the holiness of the existing MTD
      interfaces. The problems was the lack of time to go for the big overhaul. It's
      easy to add more mess to the existing one, but it takes alot of effort to go
      for a real solution.
      
      Improvements and bugfixes are welcome!
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      8593fbc6
    • T
      [MTD] Remove silly MTD_WRITE/READ macros · f4a43cfc
      Thomas Gleixner 提交于
      Most of those macros are unused and the used ones just obfuscate
      the code. Remove them and fixup all users.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      f4a43cfc