Skip to content

Commit d0ca3b9

Browse files
Johan Jonkermiquelraynal
authored andcommitted
mtd: rawnand: rockchip: fix oobfree offset and description
Rockchip boot blocks are written per 4 x 512 byte sectors per page. Each page with boot blocks must have a page address (PA) pointer in OOB to the next page. The currently advertised free OOB area starts at offset 6, like if 4 PA bytes were located right after the BBM. This is wrong as the PA bytes are located right before the ECC bytes. Fix the layout by allowing access to all bytes between the BBM and the PA bytes instead of reserving 4 bytes right after the BBM. This change breaks existing jffs2 users. Fixes: 058e0e8 ("mtd: rawnand: rockchip: NFC driver for RK3308, RK2928 and others") Signed-off-by: Johan Jonker <jbx6244@gmail.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/d202f12d-188c-20e8-f2c2-9cc874ad4d22@gmail.com
1 parent 7e6b04f commit d0ca3b9

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

drivers/mtd/nand/raw/rockchip-nand-controller.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,10 @@ static int rk_nfc_write_page_raw(struct nand_chip *chip, const u8 *buf,
562562
* BBM OOB1 OOB2 OOB3 |......| PA0 PA1 PA2 PA3
563563
*
564564
* The rk_nfc_ooblayout_free() function already has reserved
565-
* these 4 bytes with:
565+
* these 4 bytes together with 2 bytes for BBM
566+
* by reducing it's length:
566567
*
567-
* oob_region->offset = NFC_SYS_DATA_SIZE + 2;
568+
* oob_region->length = rknand->metadata_size - NFC_SYS_DATA_SIZE - 2;
568569
*/
569570
if (!i)
570571
memcpy(rk_nfc_oob_ptr(chip, i),
@@ -933,12 +934,8 @@ static int rk_nfc_ooblayout_free(struct mtd_info *mtd, int section,
933934
if (section)
934935
return -ERANGE;
935936

936-
/*
937-
* The beginning of the OOB area stores the reserved data for the NFC,
938-
* the size of the reserved data is NFC_SYS_DATA_SIZE bytes.
939-
*/
940937
oob_region->length = rknand->metadata_size - NFC_SYS_DATA_SIZE - 2;
941-
oob_region->offset = NFC_SYS_DATA_SIZE + 2;
938+
oob_region->offset = 2;
942939

943940
return 0;
944941
}

0 commit comments

Comments
 (0)