[openwrt/openwrt] ath79: ar934x: fix mounting issues if subpage is not supported

LEDE Commits lede-commits at lists.infradead.org
Fri Jul 9 08:14:35 PDT 2021


xback pushed a commit to openwrt/openwrt.git, branch openwrt-21.02:
https://git.openwrt.org/ffa943f0b913f0f26018df7eebddab2f0a1daada

commit ffa943f0b913f0f26018df7eebddab2f0a1daada
Author: Koen Vandeputte <koen.vandeputte at ncentric.com>
AuthorDate: Mon May 17 17:52:53 2021 +0200

    ath79: ar934x: fix mounting issues if subpage is not supported
    
    Currently, the option to disable subpage writing is only set
    when a HW ECC engine is used.
    
    Some boards lack a HW ECC engine and use software for that.
    In this case, this NAND option does not get set when the NAND chip
    does not support it, resulting in mounting errors.
    
    Move the setting of this option to a generic init location so it
    gets set for all types where required.
    
    While at it, also OR the option instead of just setting it
    so we don't overwrite potential flags being set somewhere else.
    
    Before:
    
    [    1.681273] UBI: auto-attach mtd2
    [    1.684669] ubi0: attaching mtd2
    [    1.688877] ubi0 error: validate_ec_hdr: bad VID header offset 2048, expected 512
    [    1.696469] ubi0 error: validate_ec_hdr: bad EC header
    [    1.701712] Erase counter header dump:
    [    1.705512]  magic          0x55424923
    [    1.709322]  version        1
    [    1.712330]  ec             1
    [    1.715331]  vid_hdr_offset 2048
    [    1.718610]  data_offset    4096
    [    1.721880]  image_seq      1462320675
    [    1.725680]  hdr_crc        0x12255a15
    
    After:
    
        1.680917] UBI: auto-attach mtd2
    [    1.684308] ubi0: attaching mtd2
    [    2.954504] random: crng init done
    [    3.142813] ubi0: scanning is finished
    [    3.163455] ubi0: attached mtd2 (name "ubi", size 124 MiB)
    [    3.169069] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
    [    3.176037] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
    [    3.182942] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
    [    3.190013] ubi0: good PEBs: 992, bad PEBs: 0, corrupted PEBs: 0
    [    3.196102] ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
    [    3.203434] ubi0: max/mean erase counter: 2/0, WL threshold: 4096, image sequence number: 1462320675
    [    3.212700] ubi0: available PEBs: 0, total reserved PEBs: 992, PEBs reserved for bad PEB handling: 20
    [    3.222124] ubi0: background thread "ubi_bgt0d" started, PID 317
    [    3.230246] block ubiblock0_1: created from ubi0:1(rootfs)
    [    3.235819] ubiblock: device ubiblock0_1 (rootfs) set to be root filesystem
    [    3.256830] VFS: Mounted root (squashfs filesystem) readonly on device 254:0.
    
    Signed-off-by: Koen Vandeputte <koen.vandeputte at ncentric.com>
    (cherry-picked from commit 6561ca1fa510003a19ea7f8800535f12e5098ce2)
---
 target/linux/ath79/files/drivers/mtd/nand/raw/ar934x_nand.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/target/linux/ath79/files/drivers/mtd/nand/raw/ar934x_nand.c b/target/linux/ath79/files/drivers/mtd/nand/raw/ar934x_nand.c
index 5f0026b475..7ba7b68d57 100644
--- a/target/linux/ath79/files/drivers/mtd/nand/raw/ar934x_nand.c
+++ b/target/linux/ath79/files/drivers/mtd/nand/raw/ar934x_nand.c
@@ -1266,7 +1266,6 @@ static int ar934x_nfc_setup_hwecc(struct ar934x_nfc *nfc)
 		 * Writing a subpage separately is not supported, because
 		 * the controller only does ECC on full-page accesses.
 		 */
-		nand->options = NAND_NO_SUBPAGE_WRITE;
 
 		nand->ecc.size = 512;
 		nand->ecc.bytes = 7;
@@ -1325,6 +1324,9 @@ static int ar934x_nfc_attach_chip(struct nand_chip *nand)
 	if (ret)
 		return ret;
 
+	if (mtd->writesize == 2048)
+		nand->options |= NAND_NO_SUBPAGE_WRITE;
+
 	if (nand->ecc.mode == NAND_ECC_HW) {
 		ret = ar934x_nfc_setup_hwecc(nfc);
 		if (ret)



More information about the lede-commits mailing list