Commit 828dec15 authored by Boris Brezillon's avatar Boris Brezillon

mtd: nand: sunxi: make OOB retrieval optional

sunxi_nfc_hw_ecc_read_chunk() always retrieves the ECC and protected free
bytes, no matter if the user really asked for it or not. This can take a
non negligible amount of time, especially on NAND chips exposing large OOB
areas (> 1KB). Make it optional.
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
parent cc6822fb
...@@ -868,7 +868,7 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct mtd_info *mtd, ...@@ -868,7 +868,7 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct mtd_info *mtd,
u8 *oob, int oob_off, u8 *oob, int oob_off,
int *cur_off, int *cur_off,
unsigned int *max_bitflips, unsigned int *max_bitflips,
bool bbm, int page) bool bbm, bool oob_required, int page)
{ {
struct nand_chip *nand = mtd_to_nand(mtd); struct nand_chip *nand = mtd_to_nand(mtd);
struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller);
...@@ -900,7 +900,8 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct mtd_info *mtd, ...@@ -900,7 +900,8 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct mtd_info *mtd,
*cur_off = oob_off + ecc->bytes + 4; *cur_off = oob_off + ecc->bytes + 4;
ret = sunxi_nfc_hw_ecc_correct(mtd, data, oob, 0, &erased); ret = sunxi_nfc_hw_ecc_correct(mtd, data, oob_required ? oob : NULL, 0,
&erased);
if (erased) if (erased)
return 1; return 1;
...@@ -928,12 +929,14 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct mtd_info *mtd, ...@@ -928,12 +929,14 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct mtd_info *mtd,
} else { } else {
memcpy_fromio(data, nfc->regs + NFC_RAM0_BASE, ecc->size); memcpy_fromio(data, nfc->regs + NFC_RAM0_BASE, ecc->size);
nand->cmdfunc(mtd, NAND_CMD_RNDOUT, oob_off, -1); if (oob_required) {
sunxi_nfc_randomizer_read_buf(mtd, oob, ecc->bytes + 4, nand->cmdfunc(mtd, NAND_CMD_RNDOUT, oob_off, -1);
true, page); sunxi_nfc_randomizer_read_buf(mtd, oob, ecc->bytes + 4,
true, page);
sunxi_nfc_hw_ecc_get_prot_oob_bytes(mtd, oob, 0, sunxi_nfc_hw_ecc_get_prot_oob_bytes(mtd, oob, 0,
bbm, page); bbm, page);
}
} }
sunxi_nfc_hw_ecc_update_stats(mtd, max_bitflips, ret); sunxi_nfc_hw_ecc_update_stats(mtd, max_bitflips, ret);
...@@ -1047,7 +1050,7 @@ static int sunxi_nfc_hw_ecc_read_page(struct mtd_info *mtd, ...@@ -1047,7 +1050,7 @@ static int sunxi_nfc_hw_ecc_read_page(struct mtd_info *mtd,
ret = sunxi_nfc_hw_ecc_read_chunk(mtd, data, data_off, oob, ret = sunxi_nfc_hw_ecc_read_chunk(mtd, data, data_off, oob,
oob_off + mtd->writesize, oob_off + mtd->writesize,
&cur_off, &max_bitflips, &cur_off, &max_bitflips,
!i, page); !i, oob_required, page);
if (ret < 0) if (ret < 0)
return ret; return ret;
else if (ret) else if (ret)
...@@ -1085,8 +1088,8 @@ static int sunxi_nfc_hw_ecc_read_subpage(struct mtd_info *mtd, ...@@ -1085,8 +1088,8 @@ static int sunxi_nfc_hw_ecc_read_subpage(struct mtd_info *mtd,
ret = sunxi_nfc_hw_ecc_read_chunk(mtd, data, data_off, ret = sunxi_nfc_hw_ecc_read_chunk(mtd, data, data_off,
oob, oob,
oob_off + mtd->writesize, oob_off + mtd->writesize,
&cur_off, &max_bitflips, &cur_off, &max_bitflips, !i,
!i, page); false, page);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
...@@ -1148,7 +1151,9 @@ static int sunxi_nfc_hw_syndrome_ecc_read_page(struct mtd_info *mtd, ...@@ -1148,7 +1151,9 @@ static int sunxi_nfc_hw_syndrome_ecc_read_page(struct mtd_info *mtd,
ret = sunxi_nfc_hw_ecc_read_chunk(mtd, data, data_off, oob, ret = sunxi_nfc_hw_ecc_read_chunk(mtd, data, data_off, oob,
oob_off, &cur_off, oob_off, &cur_off,
&max_bitflips, !i, page); &max_bitflips, !i,
oob_required,
page);
if (ret < 0) if (ret < 0)
return ret; return ret;
else if (ret) else if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment