[PATCH 3/3] mtd: nand: omap_gpmc: preserve OOB data during BCH reads
Wagner Popov dos Santos <[email protected]>
| Newsgroups | gmane.comp.boot-loaders.u-boot.general,gmane.comp.boot-loaders.u-boot |
|---|---|
| Message-ID | <52f8eead4540725d4c44d794d9c1d4a54696e036.1787320113.git.wpopov@gmail.com> |
The BCH page-read callback only populates the ECC bytes in chip->oob_poi. Non-ECC OOB data, including JFFS2 cleanmarkers, is therefore discarded during page reads. Read the complete OOB area when requested before processing the ECC steps. The ECC loop then overwrites the ECC positions with the values used for error correction, while preserving the remaining OOB data. Signed-off-by: Wagner Popov dos Santos <[email protected]> --- drivers/mtd/nand/raw/omap_gpmc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/mtd/nand/raw/omap_gpmc.c b/drivers/mtd/nand/raw/omap_gpmc.c index b3c046f2abc..9e99647058a 100644 --- a/drivers/mtd/nand/raw/omap_gpmc.c +++ b/drivers/mtd/nand/raw/omap_gpmc.c @@ -719,6 +719,17 @@ static int omap_read_page_bch(struct mtd_info *mtd, struct nand_chip *chip, uint32_t oob_pos; u32 data_pos = 0; + /* + * Read the full OOB first so that non-ECC bytes (bad-block markers + * and the free area where JFFS2 cleanmarkers are stored) are filled + * into chip->oob_poi from the physical device. The ECC loop below + * will overwrite the ECC positions with the same hardware-read values. + */ + if (oob_required) { + chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1); + chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); + } + /* oob area start */ oob_pos = (eccsize * eccsteps) + chip->ecc.layout->eccpos[0]; oob += chip->ecc.layout->eccpos[0]; -- 2.43.0