10 Jul, 2016

1 commit

  • This function compiles to 2554 bytes of machine code.
    In C, the function is almost 200 lines long.

    It has only one callsite, but forced inlining that much code
    makes gcc generate significantly worse code. Let gcc itself decide
    what to do.

    Signed-off-by: Denys Vlasenko
    CC: David Woodhouse
    CC: Dan Carpenter
    CC: Artem Bityutskiy
    CC: linux-mtd@lists.infradead.org
    CC: linux-kernel@vger.kernel.org
    Signed-off-by: Brian Norris

    Denys Vlasenko
     

04 Apr, 2016

1 commit

  • When map_word gets too large, we use a lot of kernel stack, and for
    MTD_MAP_BANK_WIDTH_32, this means we use more than the recommended
    1024 bytes in a number of functions:

    drivers/mtd/chips/cfi_cmdset_0020.c: In function 'cfi_staa_write_buffers':
    drivers/mtd/chips/cfi_cmdset_0020.c:651:1: warning: the frame size of 1336 bytes is larger than 1024 bytes [-Wframe-larger-than=]
    drivers/mtd/chips/cfi_cmdset_0020.c: In function 'cfi_staa_erase_varsize':
    drivers/mtd/chips/cfi_cmdset_0020.c:972:1: warning: the frame size of 1208 bytes is larger than 1024 bytes [-Wframe-larger-than=]
    drivers/mtd/chips/cfi_cmdset_0001.c: In function 'do_write_buffer':
    drivers/mtd/chips/cfi_cmdset_0001.c:1835:1: warning: the frame size of 1240 bytes is larger than 1024 bytes [-Wframe-larger-than=]

    This can be avoided if all operations on the map word are done
    indirectly and the stack gets reused between the calls. We can
    mostly achieve this by selecting MTD_COMPLEX_MAPPINGS whenever
    MTD_MAP_BANK_WIDTH_32 is set, but for the case that no other
    bank width is enabled, we also need to use a non-constant
    map_bankwidth() to convince the compiler to use less stack.

    Signed-off-by: Arnd Bergmann
    [Brian: this patch mostly achieves its goal by forcing
    MTD_COMPLEX_MAPPINGS (and the accompanying indirection) for 256-bit
    mappings; the rest of the change is mostly a wash, though it helps
    reduce stack size slightly. If we really care about supporting
    256-bit mappings though, we should consider rewriting some of this
    code to avoid keeping and assigning so many 256-bit objects on the
    stack.]
    Signed-off-by: Brian Norris

    Arnd Bergmann
     

07 Jan, 2016

1 commit


19 Dec, 2015

1 commit


01 Dec, 2015

1 commit

  • MTD allows compile-time configuration of the possible CFI geometry
    settings that are allowed by the kernel, but that includes a couple of
    invalid configurations, where no bank width or no interleave setting
    is allowed. These are then caught with a compile-time warning:

    include/linux/mtd/cfi.h:76:2: warning: #warning No CONFIG_MTD_CFI_Ix selected. No NOR chip support can work.
    include/linux/mtd/map.h:145:2: warning: #warning "No CONFIG_MTD_MAP_BANK_WIDTH_xx selected. No NOR chip support can work"

    This is a bit annoying for randconfig tests, and can be avoided if
    we change the Kconfig logic to always select the simplest configuration
    when no other one is enabled.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Brian Norris

    Arnd Bergmann
     

29 May, 2015

1 commit

  • Commit 4612c715a6ea ("mtd: cfi: deinline large functions") moved some
    code into the cfi_util library without creating a new dependency. So we
    can get build failures like the following, when CONFIG_MTD_JEDECPROBE=y
    and CONFIG_MTD_CFI_UTIL=m.

    drivers/built-in.o: In function `jedec_read_id':
    >> jedec_probe.c:(.text+0x187ed8): undefined reference to `cfi_build_cmd_addr'
    drivers/built-in.o: In function `jedec_read_mfr':
    >> jedec_probe.c:(.text+0x187f4a): undefined reference to `cfi_build_cmd_addr'
    drivers/built-in.o: In function `jedec_reset':
    >> jedec_probe.c:(.text+0x187fe0): undefined reference to `cfi_send_gen_cmd'
    >> jedec_probe.c:(.text+0x188004): undefined reference to `cfi_send_gen_cmd'
    >> jedec_probe.c:(.text+0x18802b): undefined reference to `cfi_send_gen_cmd'
    >> jedec_probe.c:(.text+0x18804e): undefined reference to `cfi_send_gen_cmd'
    drivers/built-in.o: In function `jedec_probe_chip':
    >> jedec_probe.c:(.text+0x188130): undefined reference to `cfi_build_cmd_addr'
    >> jedec_probe.c:(.text+0x18814d): undefined reference to `cfi_build_cmd_addr'
    >> jedec_probe.c:(.text+0x1881dc): undefined reference to `cfi_send_gen_cmd'
    >> jedec_probe.c:(.text+0x188203): undefined reference to `cfi_send_gen_cmd'
    >> jedec_probe.c:(.text+0x18822d): undefined reference to `cfi_send_gen_cmd'
    >> jedec_probe.c:(.text+0x1884c0): undefined reference to `cfi_send_gen_cmd'
    >> jedec_probe.c:(.text+0x1884e7): undefined reference to `cfi_send_gen_cmd'
    drivers/built-in.o:jedec_probe.c:(.text+0x188511): more undefined references to `cfi_send_gen_cmd' follow
    drivers/built-in.o: In function `jedec_probe_chip':
    >> jedec_probe.c:(.text+0x188618): undefined reference to `cfi_build_cmd'

    So let's express the dependency properly.

    Reported-by: kbuild test robot
    Signed-off-by: Brian Norris

    Brian Norris
     

28 May, 2015

2 commits

  • In do_otp_write we must initialize the variable datum before calling
    map_word_load_partial. Otherwise the upper bits of datum may be undefined,
    which later causes problems in chip_good called by do_write_oneword.

    Signed-off-by: Christian Riesch
    Signed-off-by: Brian Norris

    Christian Riesch
     
  • With this .config: http://busybox.net/~vda/kernel_config,
    after uninlining these functions have sizes and callsite counts
    as follows:

    cfi_udelay(): 74 bytes, 26 callsites
    cfi_send_gen_cmd(): 153 bytes, 95 callsites
    cfi_build_cmd(): 274 bytes, 123 callsites
    cfi_build_cmd_addr(): 49 bytes, 15 callsites
    cfi_merge_status(): 230 bytes, 3 callsites

    Reduction in code size is about 50,000:

    text data bss dec hex filename
    85842882 22294584 20627456 128764922 7accbfa vmlinux.before
    85789648 22294616 20627456 128711720 7abfc28 vmlinux

    Signed-off-by: Denys Vlasenko
    CC: Dan Carpenter
    CC: Jingoo Han
    CC: Brian Norris
    CC: Aaron Sierra
    CC: Artem Bityutskiy
    CC: David Woodhouse
    CC: linux-mtd@lists.infradead.org
    CC: linux-kernel@vger.kernel.org
    Signed-off-by: Brian Norris

    Denys Vlasenko
     

31 Mar, 2015

1 commit


10 Jan, 2015

2 commits

  • UBI needs to know the physical erase block size, even on read-only
    devices, since it defines the on-device layout. Use a device-tree
    provided value to support previously written UBI on read-only NOR.

    UBI also needs a non-zero writebufsize, so we set it to one.

    Note: This was implemented because hardware write-protected CFI
    NOR cannot be probed for the physical erase block size.

    Signed-off-by: Joe Schultz
    Signed-off-by: Aaron Sierra
    [Brian: removed unneeded #ifdef, note 'optional' erase-size property]
    Signed-off-by: Brian Norris

    Aaron Sierra
     
  • Signed-off-by: Alessio Igor Bogani
    Signed-off-by: Brian Norris

    Alessio Igor Bogani
     

26 Nov, 2014

1 commit


30 Oct, 2014

1 commit

  • After '#echo mem > /sys/power/state' some devices can not be properly resumed
    because apparently the MTD Partition Configuration Register has been reset
    to default thus the rootfs cannot be mounted cleanly on resume.
    An example of this can be found in the SA-1100 Developer's Manual at 9.5.3.3
    where the second step of the Sleep Shutdown Sequence is described:
    "An internal reset is applied to the SA-1100. All units are reset...".

    As workaround we refresh the PCR value as done initially on chip setup.

    This behavior and the fix are confirmed by our tests done on 2 different Zaurus
    collie units with kernel 3.17.

    Fixes: 812c5fa82bae: ("mtd: cfi_cmdset_0001.c: add support for Sharp LH28F640BF NOR")
    Signed-off-by: Dmitry Eremin-Solenikov
    Signed-off-by: Andrea Adami
    Cc: # 3.16+
    Signed-off-by: Brian Norris

    Dmitry Eremin-Solenikov
     

20 Aug, 2014

2 commits


16 Aug, 2014

1 commit


21 Jul, 2014

1 commit


17 Jul, 2014

1 commit

  • For some NOR flashes, the size of the buffer program has been increased
    from 256 bytes to 512 bytes, and so 2ms maximum timeout can may not be
    sufficient for all different vendor's NOR flash. There is maximum
    timeout information in the CFI area, so we instead of picking a fixed
    value, we can calculate this according to the standard CFI parameters
    parsed at probe time. If we haven't probed this information, or it is
    smaller than 2000us, then specify a minimum value 2000us.

    Tested with Micron JS28F512M29EWx and Micron MT28EW512ABA flash devices.

    Signed-off-by: Bean Huo
    [Brian: fix up comments, use 'max()']
    Signed-off-by: Brian Norris

    Bean Huo
     

14 Jul, 2014

1 commit

  • This family of chips was long ago supported by the pre-cfi driver.
    CFI code tested on several Zaurus SL-5500 (Collie) 2x16 on 32 bit bus.

    Function is_LH28F640BF() mimics is_m29ew() from cmdset_0002.c

    Buffer write fixes as seen in 2007 patch c/o
    Anti Sullin artecdesign.ee>
    http://comments.gmane.org/gmane.linux.ports.arm.kernel/36733

    [Brian: this patch is semi-urgent, because the following patch switches
    to using CFI detection for a chip which (until now) is unsupported by
    the CFI driver

    9218310 ARM: 8084/1: sa1100: collie: revert back to cfi_probe
    ]

    Signed-off-by: Andrea Adami
    Signed-off-by: Brian Norris

    Andrea Adami
     

12 Jul, 2014

4 commits


21 May, 2014

2 commits


11 Mar, 2014

4 commits


06 Aug, 2013

3 commits

  • Zaurus 5500 contains 2 LH28F640BFHE-PTTL90 (64M 4Mx16) and
    the LH28F640BFHE-PTTL90.pdf datasheet available on the net shows
    the exact erasesize and the OTP support.
    At the moment only jedec_probe can discover the chip and
    the NOR is mounted read only probably because of wrong vpp.

    Signed-off-by: Andrea Adami
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Andrea Adami
     
  • This reduces the size of the stack frame when calling request_module().
    Performing the sprintf before the call is not needed.

    Signed-off-by: Kees Cook
    Acked-by: Rusty Russell
    Reviewed-by: James Hogan
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Kees Cook
     
  • Print out the @adr when the write timeout occurs.
    This is useful to check if the write timeouts occur at the
    same address.

    Signed-off-by: Huang Shijie
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Huang Shijie
     

10 May, 2013

1 commit

  • Pull MTD update from David Woodhouse:

    - Lots of cleanups from Artem, including deletion of some obsolete
    drivers

    - Support partitions larger than 4GiB in device tree

    - Support for new SPI chips

    * tag 'for-linus-20130509' of git://git.infradead.org/linux-mtd: (83 commits)
    mtd: omap2: Use module_platform_driver()
    mtd: bf5xx_nand: Use module_platform_driver()
    mtd: denali_dt: Remove redundant use of of_match_ptr
    mtd: denali_dt: Change return value to fix smatch warning
    mtd: denali_dt: Use module_platform_driver()
    mtd: denali_dt: Fix incorrect error check
    mtd: nand: subpage write support for hardware based ECC schemes
    mtd: omap2: use msecs_to_jiffies()
    mtd: nand_ids: use size macros
    mtd: nand_ids: improve LEGACY_ID_NAND macro a bit
    mtd: add 4 Toshiba nand chips for the full-id case
    mtd: add the support to parse out the full-id nand type
    mtd: add new fields to nand_flash_dev{}
    mtd: sh_flctl: Use of_match_ptr() macro
    mtd: gpio: Use of_match_ptr() macro
    mtd: gpio: Use devm_kzalloc()
    mtd: davinci_nand: Use of_match_ptr()
    mtd: dataflash: Use of_match_ptr() macro
    mtd: remove h720x flash support
    mtd: onenand: remove OneNAND simulator
    ...

    Linus Torvalds
     

05 Apr, 2013

1 commit

  • The MTD subsystem has historically tried to be as configurable as possible. The
    side-effect of this is that its configuration menu is rather large, and we are
    gradually shrinking it. For example, we recently merged partitions support with
    the mtdcore.

    This patch does the next step - it merges the mtdchar module to mtdcore. And in
    this case this is not only about eliminating too fine-grained separation and
    simplifying the configuration menu. This is also about eliminating seemingly
    useless kernel module.

    Indeed, mtdchar is a module that allows user-space making use of MTD devices
    via /dev/mtd* character devices. If users do not enable it, they simply cannot
    use MTD devices at all. They cannot read or write the flash contents. Is it a
    sane and useful setup? I believe not. And everyone just enables mtdchar.

    Having mtdchar separate is also a little bit harmful. People sometimes miss the
    fact that they need to enable an additional configuration option to have
    user-space MTD interfaces, and then they wonder why on earth the kernel does
    not allow using the flash? They spend time asking around.

    Thus, let's just get rid of this module and make it part of mtd core.

    Note, mtdchar had additional configuration option to enable OTP interfaces,
    which are present on some flashes. I removed that option as well - it saves a
    really tiny amount space.

    [dwmw2: Strictly speaking, you can mount file systems on MTD devices just
    fine without the mtdchar (or mtdblock) devices; you just can't do
    other manipulations directly on the underlying device. But still I
    agree that it makes sense to make this unconditional. And Yay! we
    get to kill off an instance of checking CONFIG_foo_MODULE, which is
    an abomination that should never happen.]

    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Artem Bityutskiy
     

15 Mar, 2013

1 commit

  • We have CONFIG_SYMBOL_PREFIX, which three archs define to the string
    "_". But Al Viro broke this in "consolidate cond_syscall and
    SYSCALL_ALIAS declarations" (in linux-next), and he's not the first to
    do so.

    Using CONFIG_SYMBOL_PREFIX is awkward, since we usually just want to
    prefix it so something. So various places define helpers which are
    defined to nothing if CONFIG_SYMBOL_PREFIX isn't set:

    1) include/asm-generic/unistd.h defines __SYMBOL_PREFIX.
    2) include/asm-generic/vmlinux.lds.h defines VMLINUX_SYMBOL(sym)
    3) include/linux/export.h defines MODULE_SYMBOL_PREFIX.
    4) include/linux/kernel.h defines SYMBOL_PREFIX (which differs from #7)
    5) kernel/modsign_certificate.S defines ASM_SYMBOL(sym)
    6) scripts/modpost.c defines MODULE_SYMBOL_PREFIX
    7) scripts/Makefile.lib defines SYMBOL_PREFIX on the commandline if
    CONFIG_SYMBOL_PREFIX is set, so that we have a non-string version
    for pasting.

    (arch/h8300/include/asm/linkage.h defines SYMBOL_NAME(), too).

    Let's solve this properly:
    1) No more generic prefix, just CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX.
    2) Make linux/export.h usable from asm.
    3) Define VMLINUX_SYMBOL() and VMLINUX_SYMBOL_STR().
    4) Make everyone use them.

    Signed-off-by: Rusty Russell
    Reviewed-by: James Hogan
    Tested-by: James Hogan (metag)

    Rusty Russell
     

03 Mar, 2013

1 commit

  • Pull MTD update from David Woodhouse:
    "Fairly unexciting MTD merge for 3.9:

    - misc clean-ups in the MTD command-line partitioning parser
    (cmdlinepart)
    - add flash locking support for STmicro chips serial flash chips, as
    well as for CFI command set 2 chips.
    - new driver for the ELM error correction HW module found in various
    TI chips, enable the OMAP NAND driver to use the ELM HW error
    correction
    - added number of new serial flash IDs
    - various fixes and improvements in the gpmi NAND driver
    - bcm47xx NAND driver improvements
    - make the mtdpart module actually removable"

    * tag 'for-linus-20130301' of git://git.infradead.org/linux-mtd: (45 commits)
    mtd: map: BUG() in non handled cases
    mtd: bcm47xxnflash: use pr_fmt for module prefix in messages
    mtd: davinci_nand: Use managed resources
    mtd: mtd_torturetest can cause stack overflows
    mtd: physmap_of: Convert device allocation to managed devm_kzalloc()
    mtd: at91: atmel_nand: for PMECC, add code to check the ONFI parameter ECC requirement.
    mtd: atmel_nand: make pmecc-cap, pmecc-sector-size in dts is optional.
    mtd: atmel_nand: avoid to report an error when lookup table offset is 0.
    mtd: bcm47xxsflash: adjust names of bus-specific functions
    mtd: bcm47xxpart: improve probing of nvram partition
    mtd: bcm47xxpart: add support for other erase sizes
    mtd: bcm47xxnflash: register this as normal driver
    mtd: bcm47xxnflash: fix message
    mtd: bcm47xxsflash: register this as normal driver
    mtd: bcm47xxsflash: write number of written bytes
    mtd: gpmi: add sanity check for the ECC
    mtd: gpmi: set the Golois Field bit for mx6q's BCH
    mtd: devices: elm: Removes literals in elm DT node
    mtd: gpmi: fix a dereferencing freed memory error
    mtd: fix the wrong timeo for panic_nand_wait()
    ...

    Linus Torvalds
     

04 Feb, 2013

1 commit

  • Currently cfi_cmdset_0002.c does not support PPB locking of sectors. This
    patch adds support for this locking/unlocking mechanism. It is needed on
    some platforms, since newer U-Boot versions do support this PPB locking
    and protect for example their environment sector(s) this way.

    This PPB locking/unlocking will be enabled for all devices supported by
    cfi_cmdset_0002 reporting 8 in the CFI word 0x49 (Sector Protect/Unprotect
    scheme).

    Please note that PPB locking does support sector-by-sector locking. But
    the whole chip can only be unlocked together. So unlocking one sector
    will automatically unlock all sectors of this device. Because of this
    chip limitation, the PPB unlocking function saves the current locking
    status of all sectors before unlocking the whole device. After unlocking
    the saved locking status is re-configured. This way only the addressed
    sectors will be unlocked.

    To selectively enable this advanced sector protection mechanism, the
    device-tree property "use-advanced-sector-protection" has been created.
    To enable support for this locking this property needs to be present in the
    flash DT node. E.g.:

    nor_flash@0,0 {
    compatible = "amd,s29gl256n", "cfi-flash";
    bank-width = ;
    use-advanced-sector-protection;
    ...

    Tested with Spansion S29GL512S10THI and Micron JS28F512M29EWx flash
    devices.

    Signed-off-by: Stefan Roese
    Tested-by: Holger Brunck
    Signed-off-by: Artem Bityutskiy

    Stefan Roese
     

12 Jan, 2013

1 commit


03 Dec, 2012

1 commit

  • When working on a problem with some flash chips that lock up during
    write-buffer operations, I think there may be a bug in the linux
    handling of chips using cfi_cmdset_0002.c.

    The datasheets I have found for a number of these chips all specify that
    when aborting a write-buffer command, it is not enough to use the
    standard reset. Rather a "write-to-buffer-reset command" is needed.
    This command is quite similar for all chips, the main variance seem to
    be if the final 0xF0 can go to any address or must go to addr_unlock1.

    The bug is then in the recovery handling when timing out at the end of
    do_write_buffer, where using the normal reset command is not sufficient.

    Without this change, if the write-buffer command fails then any
    following operations on the flash also fail.

    Signed-off-by: Harald Nordgard-Hansen
    Signed-off-by: Artem Bityutskiy

    Harald Nordgard-Hansen
     

29 Sep, 2012

1 commit

  • Unlocking may take up to 1.4 seconds on some Intel flashes. So
    lets use a max. of 1.5 seconds (1500ms) as timeout.

    See "Clear Block Lock-Bits Time" on page 40 in
    "3 Volt Intel StrataFlash Memory" 28F128J3,28F640J3,28F320J3 manual
    from February 2003

    This patch also fixes some other problems with this timeout:

    - Don't use HZ in timeout "calculation"!
    While testing we noticed that an unlocking timeout occured with
    HZ=1000 and didn't occur with HZ=300. This was because the
    timeout parameter was calculated differently depending on the
    HZ value. Now a fixed value of 1500ms is used.

    - The last parameter of WAIT_TIMEOUT (defined to
    inval_cache_and_wait_for_operation) has to be passed in
    micro-seconds. So multiply the ms value with 1000 and not 100
    to calculate this value.

    - Use variable name "mdelay" instead of misleading "udelay".

    Signed-off-by: Stefan Roese
    Tested-by: Stephan Gatzka
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Stefan Roese