diff mbox series

[8/8] ubi: Relax the 'no MLC' rule and allow MLCs operating in SLC mode

Message ID 20191230165129.11925-9-miquel.raynal@bootlin.com
State Changes Requested
Delegated to: Miquel Raynal
Headers show
Series MLC in SLC mode | expand

Commit Message

Miquel Raynal Dec. 30, 2019, 4:51 p.m. UTC
From: Boris Brezillon <boris.brezillon@bootlin.com>

The MTD layer provides an SLC mode (purely software emulation of SLC
behavior) addressing the paired-pages corruption issue, which was the
main reason for refusing attaching MLC NANDs to UBI.

Relax this rule and allow partitions that have the MTD_MLC_IN_SLC_MODE
flag set to be attached.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/ubi/build.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Richard Weinberger Jan. 8, 2020, 11:50 p.m. UTC | #1
----- Ursprüngliche Mail -----
> Von: "Miquel Raynal" <miquel.raynal@bootlin.com>
> An: "richard" <richard@nod.at>, "Vignesh Raghavendra" <vigneshr@ti.com>, "Tudor Ambarus" <Tudor.Ambarus@microchip.com>,
> "linux-mtd" <linux-mtd@lists.infradead.org>
> CC: "Boris Brezillon" <boris.brezillon@collabora.com>, "Thomas Petazzoni" <thomas.petazzoni@bootlin.com>, "Boris
> Brezillon" <boris.brezillon@bootlin.com>, "Miquel Raynal" <miquel.raynal@bootlin.com>
> Gesendet: Montag, 30. Dezember 2019 17:51:29
> Betreff: [PATCH 8/8] ubi: Relax the 'no MLC' rule and allow MLCs operating in SLC mode

> From: Boris Brezillon <boris.brezillon@bootlin.com>
> 
> The MTD layer provides an SLC mode (purely software emulation of SLC
> behavior) addressing the paired-pages corruption issue, which was the
> main reason for refusing attaching MLC NANDs to UBI.
> 
> Relax this rule and allow partitions that have the MTD_MLC_IN_SLC_MODE
> flag set to be attached.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
> drivers/mtd/ubi/build.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index d636bbe214cb..d917cc4cd937 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -846,8 +846,11 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
> 	 * Both UBI and UBIFS have been designed for SLC NAND and NOR flashes.
> 	 * MLC NAND is different and needs special care, otherwise UBI or UBIFS
> 	 * will die soon and you will lose all your data.
> +	 * Relax this rule if the partition we're attaching to operates in SLC
> +	 * mode.
> 	 */
> -	if (mtd->type == MTD_MLCNANDFLASH) {
> +	if (mtd->type == MTD_MLCNANDFLASH &&
> +	    !(mtd->flags & MTD_MLC_IN_SLC_MODE)) {
> 		pr_err("ubi: refuse attaching mtd%d - MLC NAND is not supported\n",
> 			mtd->index);
> 		return -EINVAL;

Acked-by: Richard Weinberger <richard@nod.at>

Thanks,
//richard
diff mbox series

Patch

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index d636bbe214cb..d917cc4cd937 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -846,8 +846,11 @@  int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
 	 * Both UBI and UBIFS have been designed for SLC NAND and NOR flashes.
 	 * MLC NAND is different and needs special care, otherwise UBI or UBIFS
 	 * will die soon and you will lose all your data.
+	 * Relax this rule if the partition we're attaching to operates in SLC
+	 * mode.
 	 */
-	if (mtd->type == MTD_MLCNANDFLASH) {
+	if (mtd->type == MTD_MLCNANDFLASH &&
+	    !(mtd->flags & MTD_MLC_IN_SLC_MODE)) {
 		pr_err("ubi: refuse attaching mtd%d - MLC NAND is not supported\n",
 			mtd->index);
 		return -EINVAL;