From f1a2b5bbbc46084b64c36f2b665a60f2317bddc0 Mon Sep 17 00:00:00 2001 From: Koen Vandeputte Date: Thu, 18 Oct 2018 14:23:36 +0200 Subject: [PATCH] kernel: tolerate using UBI/UBIFS on MLC flash (FS#1830) starting from upstream commit 577b4eb23811 ("ubi: Reject MLC NAND") it is not allowed to use UBI and UBIFS on a MLC flavoured NAND flash chip. [1] According to David Oberhollenzer [2]: The real problem is that on MLC NAND, pages come in pairs. Multiple voltage levels inside a single, physical memory cell are used to encode more than one bit. Instead of just having pages that are twice as big, the flash exposes them as two different pages. Those pages are usually not ordered sequentially either, but according to a vendor/device specific pairing scheme. Within OpenWrt, devices utilizing this type of flash, combined with UBI(fs) will be bricked when a user upgrades from 17.01.4 to a newer version as the MLC will be refused. As these devices are currently advertised as supported by OpenWrt, we should at least maintain the original state during the lifecycle of the current releases. Support can be gracefully ended when a new release-branch is created. Signed-off-by: Koen Vandeputte Acked-by: Hauke Mehrtens [1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v4.14.77&id=577b4eb23811dfc8e38924dc476dbc866be74253 [2] https://lore.kernel.org/patchwork/patch/920344/ --- .../hack-4.14/420-allow-ubi-mlc-support.patch | 13 +++++++++++++ .../hack-4.9/420-allow-ubi-mlc-support.patch | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 target/linux/generic/hack-4.14/420-allow-ubi-mlc-support.patch create mode 100644 target/linux/generic/hack-4.9/420-allow-ubi-mlc-support.patch diff --git a/target/linux/generic/hack-4.14/420-allow-ubi-mlc-support.patch b/target/linux/generic/hack-4.14/420-allow-ubi-mlc-support.patch new file mode 100644 index 0000000000..595936f137 --- /dev/null +++ b/target/linux/generic/hack-4.14/420-allow-ubi-mlc-support.patch @@ -0,0 +1,13 @@ +--- a/drivers/mtd/ubi/build.c ++++ b/drivers/mtd/ubi/build.c +@@ -851,9 +851,8 @@ int ubi_attach_mtd_dev(struct mtd_info * + * will die soon and you will lose all your data. + */ + if (mtd->type == MTD_MLCNANDFLASH) { +- pr_err("ubi: refuse attaching mtd%d - MLC NAND is not supported\n", ++ pr_warn("ubi: mtd%d has been identified as a MLC NAND!! - MLC is not supported by UBI and UBIFS and _WILL_ cause corruption in the near future!\n", + mtd->index); +- return -EINVAL; + } + + if (ubi_num == UBI_DEV_NUM_AUTO) { diff --git a/target/linux/generic/hack-4.9/420-allow-ubi-mlc-support.patch b/target/linux/generic/hack-4.9/420-allow-ubi-mlc-support.patch new file mode 100644 index 0000000000..552ae5da75 --- /dev/null +++ b/target/linux/generic/hack-4.9/420-allow-ubi-mlc-support.patch @@ -0,0 +1,13 @@ +--- a/drivers/mtd/ubi/build.c ++++ b/drivers/mtd/ubi/build.c +@@ -900,9 +900,8 @@ int ubi_attach_mtd_dev(struct mtd_info * + * will die soon and you will lose all your data. + */ + if (mtd->type == MTD_MLCNANDFLASH) { +- pr_err("ubi: refuse attaching mtd%d - MLC NAND is not supported\n", ++ pr_warn("ubi: mtd%d has been identified as a MLC NAND!! - MLC is not supported by UBI and UBIFS and _WILL_ cause corruption in the near future!\n", + mtd->index); +- return -EINVAL; + } + + if (ubi_num == UBI_DEV_NUM_AUTO) { -- 2.30.2