Skip to content

Commit 3998a46

Browse files
smaeulmiquelraynal
authored andcommitted
mtd: rawnand: sunxi: Update OOB layout to match hardware
When using the hardware ECC engine, the OOB data is made available in the NFC_REG_USER_DATA registers, as one 32-bit word per ECC step. Any additional bytes are only accessible through raw reads and software descrambling. For efficiency, and to match the vendor driver, ignore these extra bytes when using hardware ECC. Note that until commit 34569d8 ("mtd: rawnand: sunxi: Fix the size of the last OOB region"), this extra free area was reported with length zero, so this is not a functional change for any stable kernel user. Signed-off-by: Samuel Holland <samuel@sholland.org> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20230204143520.9682-2-samuel@sholland.org
1 parent 4d21176 commit 3998a46

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

drivers/mtd/nand/raw/sunxi_nand.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,6 +1604,13 @@ static int sunxi_nand_ooblayout_free(struct mtd_info *mtd, int section,
16041604
return 0;
16051605
}
16061606

1607+
/*
1608+
* The controller does not provide access to OOB bytes
1609+
* past the end of the ECC data.
1610+
*/
1611+
if (section == ecc->steps && ecc->engine_type == NAND_ECC_ENGINE_TYPE_ON_HOST)
1612+
return -ERANGE;
1613+
16071614
oobregion->offset = section * (ecc->bytes + 4);
16081615

16091616
if (section < ecc->steps)

0 commit comments

Comments
 (0)