diff options
author | Christian Hemp <c.hemp@phytec.de> | 2016-10-20 15:40:07 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-11-11 09:54:42 +0100 |
commit | 7159d9d8e9dece428c8a3759af73d051df827ab1 (patch) | |
tree | 09a3c415cc1835b163dfa9c0e19fba1c3aa56eb8 /drivers/mtd | |
parent | 0d68468c9613d0307f1d05f4dce6e583edd3cf07 (diff) | |
download | barebox-7159d9d8e9dece428c8a3759af73d051df827ab1.tar.gz barebox-7159d9d8e9dece428c8a3759af73d051df827ab1.tar.xz |
mtd: nand: nand_mxs: Fix readtotal calculation
The calculation of readtotal must be bit alligend. If not the bch core
finds bit flips in every page, because readtotal is too small.
This bug was mostly introduced since commit "51061a9 mtd: nand: nand_mxs:
Add subpage read support".
Tested with:
nand: NAND device: Manufacturer ID: 0x01, Chip ID: 0xd3 (AMD/Spansion
S34ML08G2), 1024MiB, page size: 2048, OOB size: 128
nand: NAND device: Manufacturer ID: 0x2c, Chip ID: 0xdc (Micron
MT29F4G08ABADAWP), 512MiB, page size: 2048, OOB size: 64
nand: NAND device: Manufacturer ID: 0xec, Chip ID: 0xd3 (Samsung NAND
1GiB 3,3V 8-bit), 1024MiB, page size: 2048, OOB size: 64
Signed-off-by: Christian Hemp <c.hemp@phytec.de>
Signed-off-by: Stefan Lengfeld <s.lengfeld@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/nand/nand_mxs.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c index fe955e8af4..cba0beedbb 100644 --- a/drivers/mtd/nand/nand_mxs.c +++ b/drivers/mtd/nand/nand_mxs.c @@ -728,15 +728,15 @@ static int __mxs_nand_ecc_read_page(struct mtd_info *mtd, struct nand_chip *nand uint32_t corrected = 0, failed = 0; uint8_t *status; unsigned int max_bitflips = 0; - int i, ret, readtotal, nchunks, eccstrength, ecc_parity_size; + int i, ret, readtotal, nchunks, eccstrength; eccstrength = mxs_nand_get_ecc_strength(mtd->writesize, mtd->oobsize); readlen = roundup(readlen, MXS_NAND_CHUNK_DATA_CHUNK_SIZE); nchunks = mxs_nand_ecc_chunk_cnt(readlen); - ecc_parity_size = 13 * eccstrength / 8; - readtotal = MXS_NAND_METADATA_SIZE + - (MXS_NAND_CHUNK_DATA_CHUNK_SIZE + ecc_parity_size) * nchunks; + readtotal = MXS_NAND_METADATA_SIZE; + readtotal += MXS_NAND_CHUNK_DATA_CHUNK_SIZE * nchunks; + readtotal += DIV_ROUND_UP(13 * eccstrength * nchunks, 8); mxs_nand_config_bch(mtd, readtotal); |