From ce33ef997cfeb7b77300227a6ffab9936ea51940 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Thu, 11 Jun 2020 09:07:04 +0200 Subject: [PATCH] bcm63xx: switch to upstream NAND patches MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Fernández Rojas --- ...nand-brcmnand-fix-hamming-oob-layout.patch | 40 +++++++++++++++++++ ...brcmnand-improve-hamming-oob-layout.patch} | 40 +++++++++++++++++++ ...mnand-correctly-verify-erased-pages.patch} | 21 ++++++++++ ...awnand-brcmnand-rename-v4-registers.patch} | 19 +++++++++ ...-mtd-rawnand-brcmnand-fix-CS0-layout.patch | 34 ++++++++++++++++ ...-rawnand-brcmnand-rename-page-sizes.patch} | 18 +++++++++ ...mnand-support-v2.1-v2.2-controllers.patch} | 19 +++++++++ ...nand-brcmnand-fix-hamming-oob-layout.patch | 21 ---------- ...-mtd-rawnand-brcmnand-fix-CS0-layout.patch | 14 ------- 9 files changed, 191 insertions(+), 35 deletions(-) create mode 100644 target/linux/bcm63xx/patches-5.4/020-v5.8-mtd-rawnand-brcmnand-fix-hamming-oob-layout.patch rename target/linux/bcm63xx/patches-5.4/{437-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch => 021-v5.8-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch} (58%) rename target/linux/bcm63xx/patches-5.4/{435-mtd-rawnand-brcmnand-correctly-verify-erased-pages.patch => 022-v5.8-mtd-rawnand-brcmnand-correctly-verify-erased-pages.patch} (54%) rename target/linux/bcm63xx/patches-5.4/{438-mtd-rawnand-brcmnand-rename-v4-registers.patch => 023-v5.8-mtd-rawnand-brcmnand-rename-v4-registers.patch} (50%) create mode 100644 target/linux/bcm63xx/patches-5.4/024-v5.8-mtd-rawnand-brcmnand-fix-CS0-layout.patch rename target/linux/bcm63xx/patches-5.4/{440-mtd-rawnand-brcmnand-rename-page-sizes.patch => 025-v5.8-mtd-rawnand-brcmnand-rename-page-sizes.patch} (53%) rename target/linux/bcm63xx/patches-5.4/{441-mtd-rawnand-brcmnand-support-v2.1-v2.2-controllers.patch => 026-v5.8-mtd-rawnand-brcmnand-support-v2.1-v2.2-controllers.patch} (87%) delete mode 100644 target/linux/bcm63xx/patches-5.4/436-mtd-rawnand-brcmnand-fix-hamming-oob-layout.patch delete mode 100644 target/linux/bcm63xx/patches-5.4/439-mtd-rawnand-brcmnand-fix-CS0-layout.patch diff --git a/target/linux/bcm63xx/patches-5.4/020-v5.8-mtd-rawnand-brcmnand-fix-hamming-oob-layout.patch b/target/linux/bcm63xx/patches-5.4/020-v5.8-mtd-rawnand-brcmnand-fix-hamming-oob-layout.patch new file mode 100644 index 0000000000..7e8713ea1d --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/020-v5.8-mtd-rawnand-brcmnand-fix-hamming-oob-layout.patch @@ -0,0 +1,40 @@ +From 130bbde4809b011faf64f99dddc14b4b01f440c3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Tue, 12 May 2020 09:57:32 +0200 +Subject: [PATCH] mtd: rawnand: brcmnand: fix hamming oob layout +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +First 2 bytes are used in large-page nand. + +Fixes: ef5eeea6e911 ("mtd: nand: brcm: switch to mtd_ooblayout_ops") +Cc: stable@vger.kernel.org +Signed-off-by: Álvaro Fernández Rojas +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20200512075733.745374-2-noltari@gmail.com +--- + drivers/mtd/nand/raw/brcmnand/brcmnand.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c ++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c +@@ -1019,11 +1019,14 @@ static int brcmnand_hamming_ooblayout_fr + if (!section) { + /* + * Small-page NAND use byte 6 for BBI while large-page +- * NAND use byte 0. ++ * NAND use bytes 0 and 1. + */ +- if (cfg->page_size > 512) +- oobregion->offset++; +- oobregion->length--; ++ if (cfg->page_size > 512) { ++ oobregion->offset += 2; ++ oobregion->length -= 2; ++ } else { ++ oobregion->length--; ++ } + } + } + diff --git a/target/linux/bcm63xx/patches-5.4/437-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch b/target/linux/bcm63xx/patches-5.4/021-v5.8-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch similarity index 58% rename from target/linux/bcm63xx/patches-5.4/437-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch rename to target/linux/bcm63xx/patches-5.4/021-v5.8-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch index 68bbc7ad19..1df2411035 100644 --- a/target/linux/bcm63xx/patches-5.4/437-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch +++ b/target/linux/bcm63xx/patches-5.4/021-v5.8-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch @@ -1,3 +1,43 @@ +From d00358d7a1c50718232799e1ee10955bcd73795a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Tue, 12 May 2020 09:57:33 +0200 +Subject: [PATCH] mtd: rawnand: brcmnand: improve hamming oob layout +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The current code generates 8 oob sections: +S1 1-5 +ECC 6-8 +S2 9-15 +S3 16-21 +ECC 22-24 +S4 25-31 +S5 32-37 +ECC 38-40 +S6 41-47 +S7 48-53 +ECC 54-56 +S8 57-63 + +Change it by merging continuous sections: +S1 1-5 +ECC 6-8 +S2 9-21 +ECC 22-24 +S3 25-37 +ECC 38-40 +S4 41-53 +ECC 54-56 +S5 57-63 + +Signed-off-by: Álvaro Fernández Rojas +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20200512075733.745374-3-noltari@gmail.com +--- + drivers/mtd/nand/raw/brcmnand/brcmnand.c | 35 +++++++++++------------- + 1 file changed, 16 insertions(+), 19 deletions(-) + --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -1003,33 +1003,30 @@ static int brcmnand_hamming_ooblayout_fr diff --git a/target/linux/bcm63xx/patches-5.4/435-mtd-rawnand-brcmnand-correctly-verify-erased-pages.patch b/target/linux/bcm63xx/patches-5.4/022-v5.8-mtd-rawnand-brcmnand-correctly-verify-erased-pages.patch similarity index 54% rename from target/linux/bcm63xx/patches-5.4/435-mtd-rawnand-brcmnand-correctly-verify-erased-pages.patch rename to target/linux/bcm63xx/patches-5.4/022-v5.8-mtd-rawnand-brcmnand-correctly-verify-erased-pages.patch index cbd9e9e147..e8a9f14881 100644 --- a/target/linux/bcm63xx/patches-5.4/435-mtd-rawnand-brcmnand-correctly-verify-erased-pages.patch +++ b/target/linux/bcm63xx/patches-5.4/022-v5.8-mtd-rawnand-brcmnand-correctly-verify-erased-pages.patch @@ -1,3 +1,24 @@ +From dcb351c03f2fa6a599de1061b174167e03ee312b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Tue, 12 May 2020 10:24:51 +0200 +Subject: [PATCH] mtd: rawnand: brcmnand: correctly verify erased pages +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The current code checks that the whole OOB area is erased. +This is a problem when JFFS2 cleanmarkers are added to the OOB, since it will +fail due to the usable OOB bytes not being 0xff. +Correct this by only checking that data and ECC bytes aren't 0xff. + +Fixes: 02b88eea9f9c ("mtd: brcmnand: Add check for erased page bitflips") +Signed-off-by: Álvaro Fernández Rojas +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20200512082451.771212-1-noltari@gmail.com +--- + drivers/mtd/nand/raw/brcmnand/brcmnand.c | 19 +++++++++++-------- + 1 file changed, 11 insertions(+), 8 deletions(-) + --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -1787,28 +1787,31 @@ static int brcmnand_read_by_pio(struct m diff --git a/target/linux/bcm63xx/patches-5.4/438-mtd-rawnand-brcmnand-rename-v4-registers.patch b/target/linux/bcm63xx/patches-5.4/023-v5.8-mtd-rawnand-brcmnand-rename-v4-registers.patch similarity index 50% rename from target/linux/bcm63xx/patches-5.4/438-mtd-rawnand-brcmnand-rename-v4-registers.patch rename to target/linux/bcm63xx/patches-5.4/023-v5.8-mtd-rawnand-brcmnand-rename-v4-registers.patch index 091f63f663..0c956b36d1 100644 --- a/target/linux/bcm63xx/patches-5.4/438-mtd-rawnand-brcmnand-rename-v4-registers.patch +++ b/target/linux/bcm63xx/patches-5.4/023-v5.8-mtd-rawnand-brcmnand-rename-v4-registers.patch @@ -1,3 +1,22 @@ +From 4fd639092b17d4252368b6009573339aeab5c7bd Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Fri, 22 May 2020 14:15:20 +0200 +Subject: [PATCH] mtd: rawnand: brcmnand: rename v4 registers +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +These registers are also used on v3.3. + +Signed-off-by: Álvaro Fernández Rojas +Reviewed-by: Miquel Raynal +Acked-by: Florian Fainelli +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20200522121524.4161539-2-noltari@gmail.com +--- + drivers/mtd/nand/raw/brcmnand/brcmnand.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -269,8 +269,8 @@ enum brcmnand_reg { diff --git a/target/linux/bcm63xx/patches-5.4/024-v5.8-mtd-rawnand-brcmnand-fix-CS0-layout.patch b/target/linux/bcm63xx/patches-5.4/024-v5.8-mtd-rawnand-brcmnand-fix-CS0-layout.patch new file mode 100644 index 0000000000..0eeefe12de --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/024-v5.8-mtd-rawnand-brcmnand-fix-CS0-layout.patch @@ -0,0 +1,34 @@ +From 3d3fb3c5be9ce07fa85d8f67fb3922e4613b955b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Fri, 22 May 2020 14:15:21 +0200 +Subject: [PATCH] mtd: rawnand: brcmnand: fix CS0 layout +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Only v3.3-v5.0 have a different CS0 layout. +Controllers before v3.3 use the same layout for every CS. + +Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller") +Signed-off-by: Álvaro Fernández Rojas +Acked-by: Florian Fainelli +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20200522121524.4161539-3-noltari@gmail.com +--- + drivers/mtd/nand/raw/brcmnand/brcmnand.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c ++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c +@@ -537,8 +537,9 @@ static int brcmnand_revision_init(struct + } else { + ctrl->cs_offsets = brcmnand_cs_offsets; + +- /* v5.0 and earlier has a different CS0 offset layout */ +- if (ctrl->nand_version <= 0x0500) ++ /* v3.3-5.0 have a different CS0 offset layout */ ++ if (ctrl->nand_version >= 0x0303 && ++ ctrl->nand_version <= 0x0500) + ctrl->cs0_offsets = brcmnand_cs_offsets_cs0; + } + diff --git a/target/linux/bcm63xx/patches-5.4/440-mtd-rawnand-brcmnand-rename-page-sizes.patch b/target/linux/bcm63xx/patches-5.4/025-v5.8-mtd-rawnand-brcmnand-rename-page-sizes.patch similarity index 53% rename from target/linux/bcm63xx/patches-5.4/440-mtd-rawnand-brcmnand-rename-page-sizes.patch rename to target/linux/bcm63xx/patches-5.4/025-v5.8-mtd-rawnand-brcmnand-rename-page-sizes.patch index cdf8d3d4d6..5671bce397 100644 --- a/target/linux/bcm63xx/patches-5.4/440-mtd-rawnand-brcmnand-rename-page-sizes.patch +++ b/target/linux/bcm63xx/patches-5.4/025-v5.8-mtd-rawnand-brcmnand-rename-page-sizes.patch @@ -1,3 +1,21 @@ +From eeeac9cbc4ca5b8c245972f3a765d1cb5b7ef038 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Fri, 22 May 2020 14:15:22 +0200 +Subject: [PATCH] mtd: rawnand: brcmnand: rename page sizes +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Current pages sizes apply to controllers after v3.4 + +Signed-off-by: Álvaro Fernández Rojas +Acked-by: Florian Fainelli +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20200522121524.4161539-4-noltari@gmail.com +--- + drivers/mtd/nand/raw/brcmnand/brcmnand.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -502,7 +502,7 @@ static int brcmnand_revision_init(struct diff --git a/target/linux/bcm63xx/patches-5.4/441-mtd-rawnand-brcmnand-support-v2.1-v2.2-controllers.patch b/target/linux/bcm63xx/patches-5.4/026-v5.8-mtd-rawnand-brcmnand-support-v2.1-v2.2-controllers.patch similarity index 87% rename from target/linux/bcm63xx/patches-5.4/441-mtd-rawnand-brcmnand-support-v2.1-v2.2-controllers.patch rename to target/linux/bcm63xx/patches-5.4/026-v5.8-mtd-rawnand-brcmnand-support-v2.1-v2.2-controllers.patch index 0d68a61ade..b48f4b9b2a 100644 --- a/target/linux/bcm63xx/patches-5.4/441-mtd-rawnand-brcmnand-support-v2.1-v2.2-controllers.patch +++ b/target/linux/bcm63xx/patches-5.4/026-v5.8-mtd-rawnand-brcmnand-support-v2.1-v2.2-controllers.patch @@ -1,3 +1,22 @@ +From 7e7c7df5d50fe06469be106967fc5b5d62be8868 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Fri, 22 May 2020 14:15:24 +0200 +Subject: [PATCH] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +v2.1: tested on Netgear DGND3700v1 (BCM6368) +v2.2: tested on Netgear DGND3700v2 (BCM6362) + +Signed-off-by: Álvaro Fernández Rojas +Acked-by: Florian Fainelli +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20200522121524.4161539-6-noltari@gmail.com +--- + drivers/mtd/nand/raw/brcmnand/brcmnand.c | 85 +++++++++++++++++++++--- + 1 file changed, 76 insertions(+), 9 deletions(-) + --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -196,6 +196,7 @@ struct brcmnand_controller { diff --git a/target/linux/bcm63xx/patches-5.4/436-mtd-rawnand-brcmnand-fix-hamming-oob-layout.patch b/target/linux/bcm63xx/patches-5.4/436-mtd-rawnand-brcmnand-fix-hamming-oob-layout.patch deleted file mode 100644 index 40536c282f..0000000000 --- a/target/linux/bcm63xx/patches-5.4/436-mtd-rawnand-brcmnand-fix-hamming-oob-layout.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c -+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c -@@ -1019,11 +1019,14 @@ static int brcmnand_hamming_ooblayout_fr - if (!section) { - /* - * Small-page NAND use byte 6 for BBI while large-page -- * NAND use byte 0. -+ * NAND use bytes 0 and 1. - */ -- if (cfg->page_size > 512) -- oobregion->offset++; -- oobregion->length--; -+ if (cfg->page_size > 512) { -+ oobregion->offset += 2; -+ oobregion->length -= 2; -+ } else { -+ oobregion->length--; -+ } - } - } - diff --git a/target/linux/bcm63xx/patches-5.4/439-mtd-rawnand-brcmnand-fix-CS0-layout.patch b/target/linux/bcm63xx/patches-5.4/439-mtd-rawnand-brcmnand-fix-CS0-layout.patch deleted file mode 100644 index fdeff8734d..0000000000 --- a/target/linux/bcm63xx/patches-5.4/439-mtd-rawnand-brcmnand-fix-CS0-layout.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c -+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c -@@ -537,8 +537,9 @@ static int brcmnand_revision_init(struct - } else { - ctrl->cs_offsets = brcmnand_cs_offsets; - -- /* v5.0 and earlier has a different CS0 offset layout */ -- if (ctrl->nand_version <= 0x0500) -+ /* v3.3-5.0 have a different CS0 offset layout */ -+ if (ctrl->nand_version >= 0x0303 && -+ ctrl->nand_version <= 0x0500) - ctrl->cs0_offsets = brcmnand_cs_offsets_cs0; - } - -- 2.30.2