21 Apr, 2017

2 commits

  • Drop 'parent' argument of bdi_register() and bdi_register_va(). It is
    always NULL.

    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jan Kara
    Signed-off-by: Jens Axboe

    Jan Kara
     
  • MTD already allocates backing_dev_info dynamically. Convert it to use
    generic infrastructure for this including proper refcounting. We drop
    mtd->backing_dev_info as its only use was to pass mtd_bdi pointer from
    one file into another and if we wanted to keep that in a clean way, we'd
    have to make mtd hold and drop bdi reference as needed which seems
    pointless for passing one global pointer...

    CC: David Woodhouse
    CC: Brian Norris
    CC: linux-mtd@lists.infradead.org
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jan Kara
    Signed-off-by: Jens Axboe

    Jan Kara
     

09 Feb, 2017

1 commit


02 Dec, 2016

1 commit

  • The MTD backing dev info objects mtd_bdi was statically allocated.
    So when MTD is built as a loadable module, this object fall in the
    vmalloc address space.

    The problem with that, is that the BDI APIs use wake_up_bit(), which calls
    virt_to_page() to retrieve the memory zone of the page containing the
    wait_queue to wake up, and virt_to_page() is not valid for vmalloc or
    highmem addresses.

    Fix this by allocating the BDI objects dynamically with kmalloc. The
    objects now fall in the logical address space so that BDI APIs will
    work in all cases (mtd builtin or module).

    Signed-off-by: Steve Longerbeam
    Signed-off-by: Jim Baxter
    Signed-off-by: Sandeep Jain
    Reviewed-by: Richard Weinberger
    Reviewed-by: Marek Vasut
    Signed-off-by: Brian Norris

    Steve Longerbeam
     

20 Nov, 2016

3 commits


12 Oct, 2016

1 commit

  • Kernel source files need not include explicitly
    because the top Makefile forces to include it with:

    -include $(srctree)/include/linux/kconfig.h

    This commit removes explicit includes except the following:

    * arch/s390/include/asm/facilities_src.h
    * tools/testing/radix-tree/linux/kernel.h

    These two are used for host programs.

    Link: http://lkml.kernel.org/r/1473656164-11929-1-git-send-email-yamada.masahiro@socionext.com
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Masahiro Yamada
     

15 Sep, 2016

1 commit

  • MLC and TLC NAND devices are using NAND cells exposing more than one bit,
    but instead of attaching all the bits in a given cell to a single NAND
    page, each bit is usually attached to a different page. This concept is
    called 'page pairing', and has significant impacts on the flash storage
    usage.
    The main problem showed by these devices is that interrupting a page
    program operation may not only corrupt the page we are programming
    but also the page it is paired with, hence the need to expose to MTD
    users the pairing scheme information.

    The pairing APIs allows one to query pairing information attached to a
    given page (here called wunit), or the other way around (the wunit
    pointed by pairing information).
    It also provides several helpers to help the conversion between absolute
    offsets and wunits, and query the number of pairing groups.

    Signed-off-by: Boris Brezillon
    Reviewed-by: Brian Norris

    Boris Brezillon
     

06 May, 2016

1 commit


20 Apr, 2016

2 commits

  • ECC layout definitions are currently exposed using the nand_ecclayout
    struct which embeds oobfree and eccpos arrays with predefined size.
    This approach was acceptable when NAND chips were providing relatively
    small OOB regions, but MLC and TLC now provide OOB regions of several
    hundreds of bytes, which implies a non negligible overhead for everybody
    even those who only need to support legacy NANDs.

    Create an mtd_ooblayout_ops interface providing the same functionality
    (expose the ECC and oobfree layout) without the need for this huge
    structure.

    The mtd->ecclayout is now deprecated and should be replaced by the
    equivalent mtd_ooblayout_ops. In the meantime we provide a wrapper around
    the ->ecclayout field to ease migration to this new model.

    Signed-off-by: Boris Brezillon

    Boris Brezillon
     
  • In order to make the ecclayout definition completely dynamic we need to
    rework the way the OOB layout are defined and iterated.

    Create a few mtd_ooblayout_xxx() helpers to ease OOB bytes manipulation
    and hide ecclayout internals to their users.

    Signed-off-by: Boris Brezillon

    Boris Brezillon
     

13 Apr, 2016

2 commits


06 Jan, 2016

1 commit


05 Jan, 2016

1 commit

  • Commit 807f16d4db95 ("mtd: core: set some defaults when dev.parent is
    set") attempted to provide some default settings for MTDs that
    (a) assign the parent device and
    (b) don't provide their own name or owner

    However, this isn't a perfect drop-in replacement for the boilerplate
    found in some drivers, because the MTD name is used by partition
    parsers like cmdlinepart, but the name isn't set until add_mtd_device(),
    after the parsing is completed. This means cmdlinepart sees a NULL name
    and therefore will not work properly.

    Fix this by moving the default name and owner assignment to be first in
    the MTD registration process.

    [Note: this does not fix all reported issues, particularly with NAND
    drivers. Will require an additional fix for drivers/mtd/nand/]

    Fixes: 807f16d4db95 ("mtd: core: set some defaults when dev.parent is set")
    Reported-by: Heiko Schocher
    Signed-off-by: Brian Norris
    Cc: Heiko Schocher
    Cc: Frans Klaver

    Brian Norris
     

10 Dec, 2015

3 commits

  • If partition parsers need to clean up their resources, we shouldn't
    assume that all memory will fit in a single kmalloc() that the caller
    can kfree(). We should allow the parser to provide a proper cleanup
    routine.

    Note that this means we need to keep a hold on the parser's module for a
    bit longer, and release it later with mtd_part_parser_put().

    Alongside this, define a default callback that we'll automatically use
    if the parser doesn't provide one, so we can still retain the old
    behavior.

    Signed-off-by: Brian Norris
    Reviewed-by: Boris Brezillon

    Brian Norris
     
  • For some of the core partitioning code, it helps to keep info about the
    parsed partition (and who parsed them) together in one place.

    Signed-off-by: Brian Norris

    Brian Norris
     
  • The use of kmemdup() complicates the error handling a bit. We don't
    actually need to allocate new memory, since this reference is treated as
    const, and it is copied into new memory by the partition registration
    code anyway. So remove it.

    Signed-off-by: Brian Norris
    Reviewed-by: Boris Brezillon

    Brian Norris
     

16 Nov, 2015

1 commit


13 Nov, 2015

1 commit


08 Nov, 2015

1 commit

  • Merge second patch-bomb from Andrew Morton:

    - most of the rest of MM

    - procfs

    - lib/ updates

    - printk updates

    - bitops infrastructure tweaks

    - checkpatch updates

    - nilfs2 update

    - signals

    - various other misc bits: coredump, seqfile, kexec, pidns, zlib, ipc,
    dma-debug, dma-mapping, ...

    * emailed patches from Andrew Morton : (102 commits)
    ipc,msg: drop dst nil validation in copy_msg
    include/linux/zutil.h: fix usage example of zlib_adler32()
    panic: release stale console lock to always get the logbuf printed out
    dma-debug: check nents in dma_sync_sg*
    dma-mapping: tidy up dma_parms default handling
    pidns: fix set/getpriority and ioprio_set/get in PRIO_USER mode
    kexec: use file name as the output message prefix
    fs, seqfile: always allow oom killer
    seq_file: reuse string_escape_str()
    fs/seq_file: use seq_* helpers in seq_hex_dump()
    coredump: change zap_threads() and zap_process() to use for_each_thread()
    coredump: ensure all coredumping tasks have SIGNAL_GROUP_COREDUMP
    signal: remove jffs2_garbage_collect_thread()->allow_signal(SIGCONT)
    signal: introduce kernel_signal_stop() to fix jffs2_garbage_collect_thread()
    signal: turn dequeue_signal_lock() into kernel_dequeue_signal()
    signals: kill block_all_signals() and unblock_all_signals()
    nilfs2: fix gcc uninitialized-variable warnings in powerpc build
    nilfs2: fix gcc unused-but-set-variable warnings
    MAINTAINERS: nilfs2: add header file for tracing
    nilfs2: add tracepoints for analyzing reading and writing metadata files
    ...

    Linus Torvalds
     

07 Nov, 2015

2 commits

  • …d avoiding waking kswapd

    __GFP_WAIT has been used to identify atomic context in callers that hold
    spinlocks or are in interrupts. They are expected to be high priority and
    have access one of two watermarks lower than "min" which can be referred
    to as the "atomic reserve". __GFP_HIGH users get access to the first
    lower watermark and can be called the "high priority reserve".

    Over time, callers had a requirement to not block when fallback options
    were available. Some have abused __GFP_WAIT leading to a situation where
    an optimisitic allocation with a fallback option can access atomic
    reserves.

    This patch uses __GFP_ATOMIC to identify callers that are truely atomic,
    cannot sleep and have no alternative. High priority users continue to use
    __GFP_HIGH. __GFP_DIRECT_RECLAIM identifies callers that can sleep and
    are willing to enter direct reclaim. __GFP_KSWAPD_RECLAIM to identify
    callers that want to wake kswapd for background reclaim. __GFP_WAIT is
    redefined as a caller that is willing to enter direct reclaim and wake
    kswapd for background reclaim.

    This patch then converts a number of sites

    o __GFP_ATOMIC is used by callers that are high priority and have memory
    pools for those requests. GFP_ATOMIC uses this flag.

    o Callers that have a limited mempool to guarantee forward progress clear
    __GFP_DIRECT_RECLAIM but keep __GFP_KSWAPD_RECLAIM. bio allocations fall
    into this category where kswapd will still be woken but atomic reserves
    are not used as there is a one-entry mempool to guarantee progress.

    o Callers that are checking if they are non-blocking should use the
    helper gfpflags_allow_blocking() where possible. This is because
    checking for __GFP_WAIT as was done historically now can trigger false
    positives. Some exceptions like dm-crypt.c exist where the code intent
    is clearer if __GFP_DIRECT_RECLAIM is used instead of the helper due to
    flag manipulations.

    o Callers that built their own GFP flags instead of starting with GFP_KERNEL
    and friends now also need to specify __GFP_KSWAPD_RECLAIM.

    The first key hazard to watch out for is callers that removed __GFP_WAIT
    and was depending on access to atomic reserves for inconspicuous reasons.
    In some cases it may be appropriate for them to use __GFP_HIGH.

    The second key hazard is callers that assembled their own combination of
    GFP flags instead of starting with something like GFP_KERNEL. They may
    now wish to specify __GFP_KSWAPD_RECLAIM. It's almost certainly harmless
    if it's missed in most cases as other activity will wake kswapd.

    Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
    Acked-by: Vlastimil Babka <vbabka@suse.cz>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Acked-by: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Christoph Lameter <cl@linux.com>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Vitaly Wool <vitalywool@gmail.com>
    Cc: Rik van Riel <riel@redhat.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

    Mel Gorman
     
  • There are multiple types of users of mtd->reboot_notifier.notifier_call:

    (1) A while back, the cfi_cmdset_000{1,2} chip drivers implemented a
    reboot notifier to (on a best effort basis) attempt to reset their flash
    chips before rebooting.

    (2) More recently, we implemented a common _reboot() hook so that MTD
    drivers (particularly, NAND flash) could better halt I/O operations
    without having to reimplement the same notifier boilerplate.

    Currently, the WARN_ONCE() condition here was written to handle (2), but
    at the same time it mis-diagnosed case (1) as an already-registered MTD.
    Let's fix this by having the WARN_ONCE() condition better imitate the
    condition that immediately follows it. (Wow, I don't know how I missed
    that one.)

    (Side note: Unfortunately, we can't yet combine the reboot notifier code
    for (1) and (2) with a patch like [1], because some users of (1) also
    use mtdconcat, and so the mtd_info struct from cfi_cmdset_000{1,2} won't
    actually get registered with mtdcore, and therefore their reboot
    notifier won't get registered.)

    [1] http://patchwork.ozlabs.org/patch/417981/

    Suggested-by: Guenter Roeck
    Signed-off-by: Brian Norris
    Cc: Jesper Nilsson
    Cc: linux-cris-kernel@axis.com
    Tested-by: Ezequiel Garcia
    Tested-by: Guenter Roeck
    Signed-off-by: Brian Norris

    Brian Norris
     

27 Oct, 2015

3 commits

  • Due to wrong assumption in ofpart ofpart fails on Exynos on SPI chips
    with no partitions because the subnode containing controller data
    confuses the ofpart parser.

    Thus compiling in ofpart support automatically fails probing any SPI NOR
    flash without partitions on Exynos.

    Compiling in a partitioning scheme should not cause probe of otherwise
    valid device to fail.

    Instead, let's do the following:
    * try parsers until one succeeds
    * if no parser succeeds, report the first error we saw
    * even in the failure case, allow MTD to probe, with fallback
    partitions or no partitions at all -- the master device will still be
    registered

    Issue report and comments initially by Michal Suchanek.

    Reported-by: Michal Suchanek
    Signed-off-by: Brian Norris

    Brian Norris
     
  • When CONFIG_MTD_PARTITIONED_MASTER=y, it is fatal to call
    mtd_device_parse_register() twice on the same MTD, as we try to register
    the same device/kobject multipile times.

    When CONFIG_MTD_PARTITIONED_MASTER=n, calling
    mtd_device_parse_register() is more of just a nuisance, as we can mostly
    navigate around any conflicting actions.

    But anyway, doing so is a Bad Thing (TM), and we should complain loudly
    for any drivers that try to do this.

    Signed-off-by: Brian Norris
    Reviewed-by: Richard Weinberger

    Brian Norris
     
  • Since commit 3efe41be224c ("mtd: implement common reboot notifier
    boilerplate"), we might try to register a reboot notifier for an MTD
    that failed to register. Let's avoid this by making the error path
    clearer.

    Signed-off-by: Brian Norris
    Reviewed-by: Richard Weinberger

    Brian Norris
     

14 Oct, 2015

2 commits

  • If a parent device is set, add_mtd_device() has enough knowledge to fill
    in some sane default values for the module name and owner. Do so if they
    aren't already set.

    Signed-off-by: Frans Klaver
    Signed-off-by: Brian Norris

    Frans Klaver
     
  • add_mtd_device() has a comment suggesting that the caller should have
    set dev.parent. This is required to have the parent device symlink show
    up in sysfs, but not for proper operation of the mtd device itself.
    Currently we have five drivers registering mtd devices during module
    initialization, so they don't actually provide a parent device to link
    to. That means we cannot WARN_ON() here, as it would trigger false
    positives.

    Make the comment a bit less firm in its assertion that dev.parent should
    be set.

    Signed-off-by: Frans Klaver
    Signed-off-by: Brian Norris

    Frans Klaver
     

29 Sep, 2015

1 commit

  • Destroy mtd_idr on module_exit, reclaiming the allocated memory.

    This was detected by the following semantic patch (written by Luis Rodriguez
    )

    @ defines_module_init @
    declarer name module_init, module_exit;
    declarer name DEFINE_IDR;
    identifier init;
    @@

    module_init(init);

    @ defines_module_exit @
    identifier exit;
    @@

    module_exit(exit);

    @ declares_idr depends on defines_module_init && defines_module_exit @
    identifier idr;
    @@

    DEFINE_IDR(idr);

    @ on_exit_calls_destroy depends on declares_idr && defines_module_exit @
    identifier declares_idr.idr, defines_module_exit.exit;
    @@

    exit(void)
    {
    ...
    idr_destroy(&idr);
    ...
    }

    @ missing_module_idr_destroy depends on declares_idr && defines_module_exit && !on_exit_calls_destroy @
    identifier declares_idr.idr, defines_module_exit.exit;
    @@

    exit(void)
    {
    ...
    +idr_destroy(&idr);
    }

    Signed-off-by: Johannes Thumshirn
    Signed-off-by: Brian Norris

    Johannes Thumshirn
     

17 Jun, 2015

1 commit


07 May, 2015

1 commit

  • Use dev_pm_ops instead of the legacy suspend/resume callbacks for the MTD
    class suspend and resume operations.

    While we are at it slightly reorder things to avoid the need for forward
    declarations.

    Signed-off-by: Lars-Peter Clausen
    Signed-off-by: Brian Norris

    Lars-Peter Clausen
     

06 Apr, 2015

1 commit

  • For many use cases, it helps to have a device node for the entire
    MTD device as well as device nodes for the individual partitions.
    For example, this allows querying the entire device's properties.
    A common idiom is to create an additional partition which spans
    over the whole device.

    This patch makes a config option, CONFIG_MTD_PARTITIONED_MASTER,
    which makes the master partition present even when the device is
    partitioned. This isn't turned on by default since it presents
    a backwards-incompatible device numbering.

    The patch also makes the parent of a partition device be the master,
    if the config flag is set, now that the master is a full device.

    Signed-off-by: Dan Ehrenberg
    Signed-off-by: Brian Norris

    Dan Ehrenberg
     

19 Feb, 2015

1 commit

  • Pull MTD updates from Brian Norris:
    "NAND:

    - Add new Hisilicon NAND driver for Hip04
    - Add default reboot handler, to ensure all outstanding erase
    transactions complete in time
    - jz4740: convert to use GPIO descriptor API
    - Atmel: add support for sama5d4
    - Change default bitflip threshold to 75% of correction strength
    - Miscellaneous cleanups and bugfixes

    SPI NOR:

    - Freescale QuadSPI:
    - Fix a few probe() and remove() issues
    - Add a MAINTAINERS entry for this driver
    - Tweak transfer size to increase read performance
    - Add suspend/resume support
    - Add Micron quad I/O support
    - ST FSM SPI: miscellaneous fixes

    JFFS2:

    - gracefully handle corrupted 'offset' field found on flash

    Other:

    - bcm47xxpart: add tweaks for a few new devices
    - mtdconcat: set return lengths properly for mtd_write_oob()
    - map_ram: enable use with mtdoops
    - maps: support fallback to ROM/UBI for write-protected NOR flash"

    * tag 'for-linus-20150216' of git://git.infradead.org/linux-mtd: (46 commits)
    mtd: hisilicon: && vs & typo
    jffs2: fix handling of corrupted summary length
    mtd: hisilicon: add device tree binding documentation
    mtd: hisilicon: add a new NAND controller driver for hisilicon hip04 Soc
    mtd: avoid registering reboot notifier twice
    mtd: concat: set the return lengths properly
    mtd: kconfig: replace PPC_OF with PPC
    mtd: denali: remove unnecessary stubs
    mtd: nand: remove redundant local variable
    MAINTAINERS: add maintainer entry for FREESCALE QUAD SPI driver
    mtd: fsl-quadspi: improve read performance by increase AHB transfer size
    mtd: fsl-quadspi: Remove unnecessary 'map_failed' label
    mtd: fsl-quadspi: Remove unneeded success/error messages
    mtd: fsl-quadspi: Fix the error paths
    mtd: nand: omap: drop condition with no effect
    mtd: nand: jz4740: Convert to GPIO descriptor API
    mtd: nand: Request strength instead of bytes for soft BCH
    mtd: nand: default bitflip-reporting threshold to 75% of correction strength
    mtd: atmel_nand: introduce a new compatible string for sama5d4 chip
    mtd: atmel_nand: return max bitflips in all sectors in pmecc_correction()
    ...

    Linus Torvalds
     

08 Feb, 2015

1 commit

  • Calling mtd_device_parse_register with the same mtd_info
    (e.g. registering several partitions on a single device)
    would add the same reboot notifier twice, causing an
    infinte loop in notifier_chain_register during boot up.

    Signed-off-by: Niklas Cassel
    [Brian: add FIXME comments]
    Signed-off-by: Brian Norris

    Signed-off-by: Brian Norris

    Niklas Cassel
     

29 Jan, 2015

1 commit

  • The recently added mtd_mmap_capabilities can be used from loadable
    modules, in particular romfs, but is not exported, so we get

    ERROR: "mtd_mmap_capabilities" [fs/romfs/romfs.ko] undefined!

    This adds the missing export.

    Signed-off-by: Arnd Bergmann
    Fixes: b4caecd48005f ("fs: introduce f_op->mmap_capabilities for nommu mmap support")
    Acked-by: Christoph Hellwig
    Acked-by: Brian Norris
    Signed-off-by: Jens Axboe

    Arnd Bergmann
     

21 Jan, 2015

1 commit

  • Since "BDI: Provide backing device capability information [try #3]" the
    backing_dev_info structure also provides flags for the kind of mmap
    operation available in a nommu environment, which is entirely unrelated
    to it's original purpose.

    Introduce a new nommu-only file operation to provide this information to
    the nommu mmap code instead. Splitting this from the backing_dev_info
    structure allows to remove lots of backing_dev_info instance that aren't
    otherwise needed, and entirely gets rid of the concept of providing a
    backing_dev_info for a character device. It also removes the need for
    the mtd_inodefs filesystem.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Tejun Heo
    Acked-by: Brian Norris
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

08 Jan, 2015

1 commit


20 Aug, 2014

2 commits

  • MTD used to allow compiling out character device support. This was
    dropped in the following commit, but some of the accompanying logic was
    never dropped:

    commit 660685d9d1b4730f0b5ca97fa95f272f99c63bce
    Author: Artem Bityutskiy
    Date: Thu Mar 14 13:27:40 2013 +0200

    mtd: merge mtdchar module with mtdcore

    The weird logic was flagged by Coverity.

    Signed-off-by: Brian Norris
    Cc: Artem Bityutskiy

    Brian Norris
     
  • When checking the upper boundary (i.e., whether an address is higher
    than the maximum size of the MTD), we should be doing an inclusive check
    (greater or equal). For instance, an address of 16MB (0x1000000) on a
    16MB device is invalid.

    The strengthening of this bounds check is redundant for those which
    already have a address+length check and ensure that the length is
    non-zero, but let's just fix them all, for completeness.

    Signed-off-by: Brian Norris

    Brian Norris