9d43649a | 19-Dec-2018 |
Masahiro Yamada <yamada.masahiro@socionext.com> |
mtd: rawnand: denali: fix a race condition when DMA is kicked
Based on Linux commit cf51e4b9c34407bf0c3d9b582b7837e047e1df47
Add the register read-back, commenting why this is necessary.
Signed-of
mtd: rawnand: denali: fix a race condition when DMA is kicked
Based on Linux commit cf51e4b9c34407bf0c3d9b582b7837e047e1df47
Add the register read-back, commenting why this is necessary.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
show more ...
|
8ccfbfb3 | 19-Dec-2018 |
Masahiro Yamada <yamada.masahiro@socionext.com> |
mtd: rawnand: denali: optimize timing parameters for data interface
Based on Linux commit 1dfac31a5a63ac04a9b5fbc3f5105a586560f191
This commit improves the ->setup_data_interface() hook.
The denal
mtd: rawnand: denali: optimize timing parameters for data interface
Based on Linux commit 1dfac31a5a63ac04a9b5fbc3f5105a586560f191
This commit improves the ->setup_data_interface() hook.
The denali_setup_data_interface() needs the frequency of clk_x and the ratio of clk_x / clk.
The latter is currently hardcoded in the driver, like this:
#define DENALI_CLK_X_MULT 6
The IP datasheet requires that clk_x / clk be 4, 5, or 6. I just chose 6 because it is the most defensive value, but it is not optimal. By getting the clock rate of both "clk" and "clk_x", the driver can compute the timing values more precisely.
To not break the existing platforms, the fallback value, 50 MHz is provided. It is true for all upstreamed platforms.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
show more ...
|
08898e8b | 02-Dec-2018 |
Boris Brezillon <boris.brezillon@bootlin.com> |
mtd: sf: Make sf_mtd.c more robust
SPI flash based MTD devs can be registered/unregistered at any time through the sf probe command or the spi_flash_free() function.
This commit does not try to fix
mtd: sf: Make sf_mtd.c more robust
SPI flash based MTD devs can be registered/unregistered at any time through the sf probe command or the spi_flash_free() function.
This commit does not try to fix the root cause as it would probably require rewriting most of the code and have an mtd_info object instance per spi_flash object (not to mention that the the spi-flash layer is likely to be replaced by a spi-nor layer ported from Linux).
Instead, we try to be as safe as can be by checking the code returned by del_mtd_device() and complain loudly when there's nothing we can do about the deregistration failure. When that happens we also reset sf_mtd_info.priv to NULL, and check for NULL pointer in the mtd hooks so that -ENODEV is returned instead of hitting a NULL pointer dereference exception when the MTD instance is later accessed by a user.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
show more ...
|
7371944a | 02-Dec-2018 |
Boris Brezillon <boris.brezillon@bootlin.com> |
mtd: sf: Unregister the MTD device prior to removing the spi_flash obj
The DM implementation of spi_flash_free() does not unregister the MTD device before removing the spi dev object. This leads to
mtd: sf: Unregister the MTD device prior to removing the spi_flash obj
The DM implementation of spi_flash_free() does not unregister the MTD device before removing the spi dev object. This leads to a use-after-free bug when the MTD device is later accessed by a MTD user (observed when attaching the device to UBI after env_sf_load() has called spi_flash_free()).
Implement ->remove() and call spi_flash_mtd_unregister() from there.
Fixes: 9fe6d8716e09 ("mtd, spi: Add MTD layer driver") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de> Reviewed-by: Jagan Teki <jagan@openedev.com>
show more ...
|
4a5594fa | 02-Dec-2018 |
Boris Brezillon <boris.brezillon@bootlin.com> |
mtd: Don't stop MTD partition creation when it fails on one device
MTD partition creation code is a bit tricky. It tries to figure out when things have changed (either MTD dev list or mtdparts/mtdid
mtd: Don't stop MTD partition creation when it fails on one device
MTD partition creation code is a bit tricky. It tries to figure out when things have changed (either MTD dev list or mtdparts/mtdids vars) and when that happens it first deletes all the partitions that had been previously created and then creates the new ones based on the new mtdparts/mtdids values. But before deleting the old partitions, it ensures that none of the currently registered parts are being used and bails out when that's not the case. So, we end up in a situation where, if at least one MTD dev has one of its partitions used by someone (UBI for instance), the partitions update logic no longer works for other devs.
Rework the code to relax the logic and allow updates of MTD parts on devices that are not being used (we still refuse to updates parts on devices who have at least one of their partitions used by someone).
Fixes: 5db66b3aee6f ("cmd: mtd: add 'mtd' command") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
show more ...
|
2428d916 | 02-Dec-2018 |
Boris Brezillon <boris.brezillon@bootlin.com> |
mtd: Make sure we don't parse MTD partitions belonging to another dev
The mtdparts variable might contain partition definitions for several MTD devices. Each partition layout is separated by a ';',
mtd: Make sure we don't parse MTD partitions belonging to another dev
The mtdparts variable might contain partition definitions for several MTD devices. Each partition layout is separated by a ';', so let's make sure we don't pick a wrong name when mtdparts is malformed.
Fixes: 5db66b3aee6f ("cmd: mtd: add 'mtd' command") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
show more ...
|
772aa979 | 02-Dec-2018 |
Boris Brezillon <boris.brezillon@bootlin.com> |
mtd: Make sure the name passed in mtdparts fits in mtd_name[]
The local mtd_name[] variable is limited in size. Return an error if the name passed in mtdparts does not fit in this local var.
Fixes:
mtd: Make sure the name passed in mtdparts fits in mtd_name[]
The local mtd_name[] variable is limited in size. Return an error if the name passed in mtdparts does not fit in this local var.
Fixes: 5db66b3aee6f ("cmd: mtd: add 'mtd' command") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
show more ...
|
429e048e | 02-Dec-2018 |
Boris Brezillon <boris.brezillon@bootlin.com> |
mtd: Be more strict on the "mtdparts=" prefix check
strstr() does not guarantee that the string we're searching for is placed at the beginning. Use strncmp() instead.
Fixes: 5db66b3aee6f ("cmd: mtd
mtd: Be more strict on the "mtdparts=" prefix check
strstr() does not guarantee that the string we're searching for is placed at the beginning. Use strncmp() instead.
Fixes: 5db66b3aee6f ("cmd: mtd: add 'mtd' command") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
show more ...
|
96b06434 | 02-Dec-2018 |
Boris Brezillon <boris.brezillon@bootlin.com> |
mtd: Use get_mtdids() instead of env_get("mtdids") in mtd_search_alternate_name()
The environment is not guaranteed to contain a valid mtdids variable when called from mtd_search_alternate_name(). C
mtd: Use get_mtdids() instead of env_get("mtdids") in mtd_search_alternate_name()
The environment is not guaranteed to contain a valid mtdids variable when called from mtd_search_alternate_name(). Call get_mtdids() instead of env_get("mtdids").
Fixes: ff4afa8a981e ("mtd: uboot: search for an equivalent MTD name with the mtdids") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
show more ...
|
492151b2 | 02-Dec-2018 |
Boris Brezillon <boris.brezillon@bootlin.com> |
mtd: sf: Make sure we don't register the same device twice
spi_flash_mtd_register() can be called several times and each time it will register the same mtd_info instance like if it was a new one. Th
mtd: sf: Make sure we don't register the same device twice
spi_flash_mtd_register() can be called several times and each time it will register the same mtd_info instance like if it was a new one. The MTD ID allocation gets crazy when that happens, so let's track the status of the sf_mtd_info object to avoid that.
Fixes: 9fe6d8716e09 ("mtd, spi: Add MTD layer driver") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de> Reviewed-by: Jagan Teki <jagan@openedev.com>
show more ...
|
a02820fc | 02-Dec-2018 |
Boris Brezillon <boris.brezillon@bootlin.com> |
mtd: Delete partitions attached to the device when a device is deleted
If we don't do that, partitions might still be exposed while the underlying device is gone.
Fixes: 2a74930da57f ("mtd: mtdpart
mtd: Delete partitions attached to the device when a device is deleted
If we don't do that, partitions might still be exposed while the underlying device is gone.
Fixes: 2a74930da57f ("mtd: mtdpart: implement proper partition handling") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
show more ...
|
779c9c05 | 02-Dec-2018 |
Boris Brezillon <boris.brezillon@bootlin.com> |
mtd: Parse mtdparts/mtdids again when the MTD list has been updated
Updates to the MTD device list should trigger a new parsing of the mtdids/mtdparts vars even if those vars haven't changed.
Fixes
mtd: Parse mtdparts/mtdids again when the MTD list has been updated
Updates to the MTD device list should trigger a new parsing of the mtdids/mtdparts vars even if those vars haven't changed.
Fixes: 5db66b3aee6f ("cmd: mtd: add 'mtd' command") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
show more ...
|
c907464a | 11-Oct-2018 |
Miquel Raynal <miquel.raynal@bootlin.com> |
mtd: rawnand: pxa3xx: fix 2kiB pages with 8b strength chips layout
The initial layout for such NAND chips was the following:
+-----------------------------------------------------------------------
mtd: rawnand: pxa3xx: fix 2kiB pages with 8b strength chips layout
The initial layout for such NAND chips was the following:
+----------------------------------------------------------------------------+ | 1024 (data) | 30 (ECC) | 1024 (data) | 30 (ECC) | 32 (free OOB) | 30 (ECC) | +----------------------------------------------------------------------------+
This layout has a weakness: reading empty pages trigger ECC errors (this is expected), but the hardware ECC engine tries to correct the data anyway and creates itself bitflips, hence bitflips are detected in erased pages while actually there are none in the NAND chip.
Two solutions have been found at the same time. One was to enlarge the free OOB area to 64 bytes, changing the layout to be:
+----------------------------------------------------------------------------+ | 1024 (data) | 30 (ECC) | 1024 (data) | 30 (ECC) | 64 (free OOB) | 30 (ECC) | +----------------------------------------------------------------------------+ ^^
The very big drawbacks of this solution are: 1/ It prevents booting from NAND. 2/ The current Linux driver (marvell_nand) does not have such problem because it already re-reads possible empty pages in raw mode before checking for bitflips. Using different layouts in U-Boot and Linux would simply not work.
As this driver does support raw reads now and uses it to check for empty pages, let's forget about this broken hack and return to the initial layout with only 32 free OOB bytes.
Fixes: ac56a3b30c ("mtd: nand: pxa3xx: add support for 2KB 8-bit flash") Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jagan Teki <jagan@openedev.com>
show more ...
|
af61ea27 | 11-Oct-2018 |
Miquel Raynal <miquel.raynal@bootlin.com> |
mtd: nand: pxa3xx: re-read a page in raw mode on uncorrectable error
This only applies on BCH path.
When an empty page is read, it triggers an uncorrectable error. While this is expected, the ECC e
mtd: nand: pxa3xx: re-read a page in raw mode on uncorrectable error
This only applies on BCH path.
When an empty page is read, it triggers an uncorrectable error. While this is expected, the ECC engine might produce itself bitflips in the read data under certain layouts. To overcome this situation, always re-read the entire page in raw mode and check for the whole page to be empty.
Also report the right number of bitflips if there are any.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jagan Teki <jagan@openedev.com>
show more ...
|
44cdfc0e | 18-Oct-2018 |
Vladimir Zapolskiy <vz@mleia.com> |
mtd: nand: lpc32xx slc: disable DMA support in SPL builds
Testing and analysis shows that at the moment LPC32xx NAND SLC driver can not get PL080 DMA backbone support in SPL build, because SPL NAND
mtd: nand: lpc32xx slc: disable DMA support in SPL builds
Testing and analysis shows that at the moment LPC32xx NAND SLC driver can not get PL080 DMA backbone support in SPL build, because SPL NAND loaders operate with subpage (ECC step to be precisely) reads, and this is not supported in the NAND SLC + DMA + hardware ECC calculation bundle.
The change removes a cautious build time warning and explicitly disables DMA flavour of the driver for SPL builds, to reduce the amound of #ifdef sections the code blocks are minimally reorganized.
Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
show more ...
|
1f758b79 | 13-Nov-2018 |
Boris Brezillon <boris.brezillon@bootlin.com> |
mtd: Drop duplicate MTD_PARTITIONS Kconfig option
Commit 9c5b00973bce ("Convert CONFIG_MTD_PARTITIONS et al to Kconfig") introduced a publicly visible Kconfig entry for the CONFIG_MTD_PARTITIONS opt
mtd: Drop duplicate MTD_PARTITIONS Kconfig option
Commit 9c5b00973bce ("Convert CONFIG_MTD_PARTITIONS et al to Kconfig") introduced a publicly visible Kconfig entry for the CONFIG_MTD_PARTITIONS option, while the rework on MTD partitioning was in progress, and we somehow did not notice that the same Kconfig entry was added by commit 4048a5c519a8 ("mtd: declare MTD_PARTITIONS symbol in Kconfig"), but this time as an invisible entry (this can only be selected by other options).
Keep the non-visible version of this symbol, since MTD_PARTITIONS is not something the user should be able to enable/disable directly.
Fixes: 4048a5c519a8 ("mtd: declare MTD_PARTITIONS symbol in Kconfig") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Jagan Teki <jagan@openedev.com>
show more ...
|