summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdcore.c
Commit message (Collapse)AuthorAgeFilesLines
* mtd: Fix some function description mismatches in mtdcore.cXiaolei Li2018-03-291-4/+4
| | | | | | | | In mtdcore.c, some function descriptions do not match function definitions. Just fix these mismatches. Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
* mtd: update documentation of mtd_device_parse_register()Rafał Miłecki2018-03-291-4/+3
| | | | | | | | | | | In the commit 2c77c57d22adb ("mtd: move code adding master MTD out of mtd_add_device_partitions()") behavior of mtd_device_parse_register() has very slightly changed. It's a pretty non-significant order change to match updated function behavior. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Reviewed-by: Richard Weinberger <richard@nod.at> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
* mtd: Stop updating erase_info->state and calling mtd_erase_callback()Boris Brezillon2018-03-211-4/+2
| | | | | | | | | | | | | | | | | | | | MTD users are no longer checking erase_info->state to determine if the erase operation failed or succeeded. Moreover, mtd_erase_callback() is now a NOP. We can safely get rid of all mtd_erase_callback() calls and all erase_info->state assignments. While at it, get rid of the erase_info->state field, all MTD_ERASE_XXX definitions and the mtd_erase_callback() function. Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Richard Weinberger <richard@nod.at> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Bert Kenward <bkenward@solarflare.com> --- Changes in v2: - Address a few coding style issues (reported by Miquel) - Remove comments that are no longer valid (reported by Miquel)
* mtd: Stop assuming mtd_erase() is asynchronousBoris Brezillon2018-03-151-5/+3
| | | | | | | | | | None of the mtd->_erase() implementations work in an asynchronous manner, so let's simplify MTD users that call mtd_erase(). All they need to do is check the value returned by mtd_erase() and assume that != 0 means failure. Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Richard Weinberger <richard@nod.at>
* mtd: Initialize ->fail_addr early in mtd_erase()Boris Brezillon2018-03-151-1/+2
| | | | | | | | | mtd_erase() can return an error before ->fail_addr is initialized to MTD_FAIL_ADDR_UNKNOWN. Move this initialization at the very beginning of the function. Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Richard Weinberger <richard@nod.at>
* mtd: get rid of the mtd_add_device_partitions()Rafał Miłecki2018-02-121-31/+12
| | | | | | | | | | | | | | | This simplifies code a bit by: 1) Avoiding an extra (tiny) function 2) Checking for amount of parsed (found) partitions just once 3) Avoiding clearing/filling struct mtd_partitions manually With this commit proper functions are called directly from the mtd_device_parse_register(). It doesn't need to use minor tricks like memsetting struct to 0 to trigger an expected mtd_add_device_partitions() behavior. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
* mtd: move code adding master MTD out of mtd_add_device_partitions()Rafał Miłecki2018-02-121-12/+13
| | | | | | | | | | | | | | This change is a small cleanup of mtd_device_parse_register(). When using MTD_PARTITIONED_MASTER it makes sure a master MTD is registered before dealing with partitions. The advantage of this is not mixing code handling master MTD with code handling partitions. This commit doesn't change any behavior except from a slightly different failure code path. The new code may need to call del_mtd_device when something goes wrong. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
* mtd: Make sure the device supports erase operations in mtd_erase()Boris Brezillon2018-02-121-0/+4
| | | | | | | | | | | | | | | Some devices do not implement ->_erase() or have an invalid ->erasesize value. In this case, mtd_erase() should return -ENOTSUPP. Note that the test is not done on the MTD_NO_ERASE flag because this flag means 'erasing a block before writing to it is unnecessary', not 'the erase operation is not supported'. Actually, some drivers are setting the MTD_NO_ERASE flag but still implementing the ->_erase() hook and setting a valid ->erasesize value. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Reviewed-by: Miquel Raynal <miquel.raynal@free-electrons.com> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
* Merge tag 'mtd/for-4.16' of git://git.infradead.org/linux-mtdLinus Torvalds2018-01-291-2/+34
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pull MTD updates from Boris Brezillon: "MTD core changes: - Rework core functions to avoid duplicating generic checks in NAND/OneNAND sub-layers - Update the MAINTAINERS entry to reflect the fact that MTD maintainers now use a single git tree MTD driver changes: - CFI: use macros instead of inline functions to limit stack usage and make KASAN happy NAND core changes: - Fix NAND_CMD_NONE handling in nand_command[_lp]() hooks - Introduce the ->exec_op() infrastructure - Rework NAND buffers handling - Fix ECC requirements for K9F4G08U0D - Fix nand_do_read_oob() to return the number of bitflips - Mark K9F1G08U0E as not supporting subpage writes NAND driver changes: - MTK: Rework the driver to support new IP versions - OMAP OneNAND: Full rework to use new APIs (libgpio, dmaengine) and fix DT support - Marvell: Add a new driver to replace the pxa3xx one SPI NOR core changes: - Add support to new ISSI and Cypress/Spansion memory parts. - Fix support of Micron memories by checking error bits in the FSR. - Fix update of block-protection bits by reading back the SR. - Restore the internal state of the SPI flash memory when removing the device. SPI NOR driver changes: - Maintenance for Freescale, Intel and Metiatek drivers. - Add support of the direct access mode for the Cadence QSPI controller" * tag 'mtd/for-4.16' of git://git.infradead.org/linux-mtd: (93 commits) mtd: nand: sunxi: Fix ECC strength choice mtd: nand: gpmi: Fix subpage reads mtd: nand: Fix build issues due to an anonymous union mtd: nand: marvell: Fix missing memory allocation modifier mtd: nand: marvell: remove redundant variable 'oob_len' mtd: nand: marvell: fix spelling mistake: "suceed"-> "succeed" mtd: onenand: omap2: Remove redundant dev_err call in omap2_onenand_probe() mtd: Remove duplicate checks on mtd_oob_ops parameter mtd: Fallback to ->_read/write_oob() when ->_read/write() is missing mtd: mtdpart: Make ECC stat handling consistent mtd: onenand: omap2: print resource using %pR format string mtd: mtk-nor: modify functions' name more generally mtd: onenand: samsung: remove incorrect __iomem annotation MAINTAINERS: Add entry for Marvell NAND controller driver ARM: OMAP2+: Remove gpmc-onenand mtd: onenand: omap2: Configure driver from DT mtd: onenand: omap2: Decouple DMA enabling from INT pin availability mtd: onenand: omap2: Do not make delay for GPIO OMAP3 specific mtd: onenand: omap2: Convert to use dmaengine for memcpy mtd: onenand: omap2: Unify OMAP2 and OMAP3 DMA implementation ...
| * mtd: Fallback to ->_read/write_oob() when ->_read/write() is missingBoris Brezillon2018-01-161-2/+29
| | | | | | | | | | | | | | | | | | | | | | | | Some MTD sublayers/drivers are implementing ->_read/write_oob() and provide dummy wrappers for their ->_read/write() implementations. Let the core handle this case instead of duplicating the logic. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr> Acked-by: Brian Norris <computersforpeace@gmail.com> Reviewed-by: Miquel Raynal <miquel.raynal@free-electrons.com> Tested-by: Ladislav Michl <ladis@linux-mips.org>
| * mtd: Do not allow MTD devices with inconsistent erase propertiesBoris Brezillon2018-01-061-0/+5
| | | | | | | | | | | | | | | | | | When mtd->erasesize is 0 or mtd->_erase is NULL, that means the device does not support the erase operation, which in turn means it should have the MTD_NO_ERASE flag set. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Reviewed-by: Miquel Raynal <miquel.raynal@free-electrons.com>
* | mtd: Fix mtd_check_oob_ops()Miquel Raynal2017-12-181-1/+1
|/ | | | | | | | | | | | | | The mtd_check_oob_ops() helper verifies if the operation defined by the user is correct. Fix the check that verifies if the entire requested area exists. This check is too restrictive and will fail anytime the last data byte of the very last page is included in an operation. Fixes: 5cdd929da53d ("mtd: Add sanity checks in mtd_write/read_oob()") Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
* mtd: Add sanity checks in mtd_write/read_oob()Boris Brezillon2017-11-131-0/+44
| | | | | | | | | | | | | Unlike what's done in mtd_read/write(), there are no checks to make sure the parameters passed to mtd_read/write_oob() are consistent, which forces implementers of ->_read/write_oob() to do it, which in turn leads to code duplication and possibly errors in the logic. Do general sanity checks, like ops fields consistency and range checking. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Cc: Peter Pan <peterpandong@micron.com> Signed-off-by: Richard Weinberger <richard@nod.at>
* mtd: implement mtd_get_unmapped_area() using the point methodNicolas Pitre2017-11-131-5/+12
| | | | | | | | | | | | | | | | The mtd->_point method is a superset of mtd->_get_unmapped_area. Especially in the NOR flash case, the point method ensures the flash memory is in array (data) mode and that it will stay that way which is precisely what callers of mtd_get_unmapped_area() would expect. Implement mtd_get_unmapped_area() in terms of mtd->_point now that all drivers that provided a _get_unmapped_area method also have the _point method implemented. Signed-off-by: Nicolas Pitre <nico@linaro.org> Reviewed-by: Richard Weinberger <richard@nod.at> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
* mtd: make device_type constBhumika Goyal2017-08-211-1/+1
| | | | | | | | | Make this const as it is only stored in the type field of a device structure, which is const. Done using Coccinelle. Signed-off-by: Bhumika Goyal <bhumirks@gmail.com> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
* mtd: create per-device and module-scope debugfs entriesMario Rugiero2017-07-211-0/+16
| | | | | | | | | | | | | | | | Several MTD devices are using debugfs entries created in the root. This commit provides the means for a standardized subtree, creating one "mtd" entry at root, and one entry per device inside it, named after the device. The tree is registered in add_mtd_device, and released in del_mtd_device. Devices docg3, mtdswap and nandsim were updated to use this subtree instead of custom ones, and their entries were prefixed with the drivers' names. Signed-off-by: Mario J. Rugiero <mrugiero@gmail.com> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: Fix check in mtd_unpoint()Boris Brezillon2017-07-071-1/+1
| | | | | | | | The code checks that ->_point is not NULL, but we should actually check ->_unpoint value which is dereferenced a few lines after the check. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* bdi: Drop 'parent' argument from bdi_register[_va]()Jan Kara2017-04-201-1/+1
| | | | | | | | | Drop 'parent' argument of bdi_register() and bdi_register_va(). It is always NULL. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Jens Axboe <axboe@fb.com>
* mtd: Convert to dynamically allocated bdi infrastructureJan Kara2017-04-201-11/+12
| | | | | | | | | | | | | | | | 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 <dwmw2@infradead.org> CC: Brian Norris <computersforpeace@gmail.com> CC: linux-mtd@lists.infradead.org Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Jens Axboe <axboe@fb.com>
* mtd: fix typos in ooblayout comment blocksMasahiro Yamada2017-02-081-3/+3
| | | | | | | | | - "This functions return ..." -> "This function returns ..." - "I you want ..." -> "If you want ..." Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: Allocate bdi objects dynamicallySteve Longerbeam2016-12-011-12/+18
| | | | | | | | | | | | | | | | | | | | | | 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 <steve_longerbeam@mentor.com> Signed-off-by: Jim Baxter <jim_baxter@mentor.com> Signed-off-by: Sandeep Jain <Sandeep_Jain@mentor.com> Reviewed-by: Richard Weinberger <richard@nod.at> Reviewed-by: Marek Vasut <marek.vasut@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: remove unneeded initializer in mtd_ooblayout_count_bytes()Masahiro Yamada2016-11-191-1/+1
| | | | | | | | | | | | There is no need to initialize oobregion since it will be filled by the iterator. This function is called with mtd_ooblayout_free or mtd_ooblayout_ecc for the iterator; both of them calls memset() to clear the oobregion. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Marek Vasut <marek.vasut@gmail.com> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
* mtd: use min_t() to refactor mtd_ooblayout_{get, set}_bytes()Masahiro Yamada2016-11-191-2/+2
| | | | | | | | I hope this will make the code a little more readable. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Marek Vasut <marek.vasut@gmail.com> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
* mtd: remove unneeded initializer in mtd_ooblayout_{get, set}_bytes()Masahiro Yamada2016-11-191-4/+4
| | | | | | | | | There is no need to initialize oobregion and section since they will be filled by mtd_ooblayout_find_region(). Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Marek Vasut <marek.vasut@gmail.com> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
* treewide: remove redundant #include <linux/kconfig.h>Masahiro Yamada2016-10-111-1/+0
| | | | | | | | | | | | | | | | | | | Kernel source files need not include <linux/kconfig.h> 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 <yamada.masahiro@socionext.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* mtd: introduce the mtd_pairing_scheme conceptBoris Brezillon2016-09-151-0/+104
| | | | | | | | | | | | | | | | | | | | | 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 <boris.brezillon@free-electrons.com> Reviewed-by: Brian Norris <computersforpeace@gmail.com>
* mtd: kill the nand_ecclayout structBoris Brezillon2016-05-051-117/+0
| | | | | | | | Now that all MTD drivers have moved to the mtd_ooblayout_ops model we can safely remove the struct nand_ecclayout definition, and all the remaining places where it was still used. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
* mtd: create an mtd_ooblayout_ops struct to ease ECC layout definitionBoris Brezillon2016-04-191-44/+121
| | | | | | | | | | | | | | | | | | | 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@free-electrons.com>
* mtd: add mtd_ooblayout_xxx() helper functionsBoris Brezillon2016-04-191-0/+400
| | | | | | | | | | 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@free-electrons.com>
* mtd: Hook I/O activity to the MTD LED triggerEzequiel Garcia2016-04-131-0/+7
| | | | | | | | | Now that we've added the MTD LED trigger, we need to call each I/O path to ledtrig_mtd_activity. Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
* mtd: Uninline mtd_write_oob and move it to mtdcore.cEzequiel Garcia2016-04-131-0/+12
| | | | | | | | | There's no reason for having mtd_write_oob inlined in mtd.h header. Move it to mtdcore.c where it belongs. Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
* mtd: merge MTD development from v4.4 into for-v4.5 developmentBrian Norris2016-01-051-9/+17
|\ | | | | | | | | | | | | Small conflict between some bugfixes for 4.4 and some refactoring for 4.5. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
| * mtd: fix cmdlinepart parser, early naming for auto-filled MTDBrian Norris2016-01-041-9/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <hs@denx.de> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Cc: Heiko Schocher <hs@denx.de> Cc: Frans Klaver <fransklaver@gmail.com>
* | mtd: partitions: support a cleanup callback for parsersBrian Norris2015-12-091-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <computersforpeace@gmail.com> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
* | mtd: partitions: pass around 'mtd_partitions' wrapper structBrian Norris2015-12-091-14/+19
| | | | | | | | | | | | | | 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 <computersforpeace@gmail.com>
* | mtd: partitions: remove kmemdup()Brian Norris2015-12-091-9/+7
| | | | | | | | | | | | | | | | | | | | 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 <computersforpeace@gmail.com> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
* | Merge v4.4-rc1 into MTD developmentBrian Norris2015-11-151-2/+1
|\ \ | |/ | | | | | | | | Sync up with the upstream development. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
| * Merge branch 'akpm' (patches from Andrew)Linus Torvalds2015-11-071-2/+1
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <akpm@linux-foundation.org>: (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 ...
| | * mm, page_alloc: distinguish between being unable to sleep, unwilling to ↵Mel Gorman2015-11-061-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sleep and 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>
* | | mtd: grab a reference to the MTD of_node before registering itBrian Norris2015-11-121-0/+4
|/ / | | | | | | | | | | | | | | | | We now stick the device node representing the current MTD (if any) into sysfs, so let's make sure we have a reference to it before doing that. Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
* | mtd: don't WARN about overloaded users of mtd->reboot_notifier.notifier_callBrian Norris2015-11-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <linux@roeck-us.net> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Cc: Jesper Nilsson <jespern@axis.com> Cc: linux-cris-kernel@axis.com Tested-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Tested-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* | mtd: mtdpart: Do not fail mtd probe when parsing partitions failsBrian Norris2015-10-261-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <hramrach@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* | mtd: warn when registering the same master many timesBrian Norris2015-10-261-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <computersforpeace@gmail.com> Reviewed-by: Richard Weinberger <richard@nod.at>
* | mtd: fixup corner case error handling in mtd_device_parse_register()Brian Norris2015-10-261-2/+9
| | | | | | | | | | | | | | | | | | | | 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 <computersforpeace@gmail.com> Reviewed-by: Richard Weinberger <richard@nod.at>
* | mtd: core: set some defaults when dev.parent is setFrans Klaver2015-10-131-0/+9
| | | | | | | | | | | | | | | | | | 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 <fransklaver@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* | mtd: core: tone down suggestion that dev.parent should be setFrans Klaver2015-10-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <fransklaver@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* | mtd: Destroy mtd_idr on module_exitJohannes Thumshirn2015-09-281-0/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Destroy mtd_idr on module_exit, reclaiming the allocated memory. This was detected by the following semantic patch (written by Luis Rodriguez <mcgrof@suse.com>) <SmPL> @ 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); } </SmPL> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: propagate error codes from add_mtd_device()Brian Norris2015-06-161-7/+11
| | | | | | | It makes more sense to return error statuses, not 1/0. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Reviewed-by: Richard Weinberger <richard@nod.at>
* mtd: Switch to PM opsLars-Peter Clausen2015-05-071-20/+24
| | | | | | | | | | | 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 <lars@metafoo.de> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: part: Create the master device node when partitionedDan Ehrenberg2015-04-051-16/+36
| | | | | | | | | | | | | | | | | | | 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 <dehrenberg@chromium.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
OpenPOWER on IntegriCloud