mtd: gpmi: Always report ECC stats and return max_bitflips
Always report corrected and failed ECC stats back up to the MTD layer. Also return max_bitflips from read_page() as is expected from NAND drivers now. Signed-off-by: Zach Sadecki <zsadecki@itwatchdogs.com> Acked-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
This commit is contained in:
parent
e830342ef3
commit
b23b746cdc
|
@ -920,8 +920,7 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
|
||||||
dma_addr_t auxiliary_phys;
|
dma_addr_t auxiliary_phys;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned char *status;
|
unsigned char *status;
|
||||||
unsigned int failed;
|
unsigned int max_bitflips = 0;
|
||||||
unsigned int corrected;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pr_debug("page number is : %d\n", page);
|
pr_debug("page number is : %d\n", page);
|
||||||
|
@ -945,35 +944,25 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
|
||||||
payload_virt, payload_phys);
|
payload_virt, payload_phys);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
pr_err("Error in ECC-based read: %d\n", ret);
|
pr_err("Error in ECC-based read: %d\n", ret);
|
||||||
goto exit_nfc;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handle the block mark swapping */
|
/* handle the block mark swapping */
|
||||||
block_mark_swapping(this, payload_virt, auxiliary_virt);
|
block_mark_swapping(this, payload_virt, auxiliary_virt);
|
||||||
|
|
||||||
/* Loop over status bytes, accumulating ECC status. */
|
/* Loop over status bytes, accumulating ECC status. */
|
||||||
failed = 0;
|
status = auxiliary_virt + nfc_geo->auxiliary_status_offset;
|
||||||
corrected = 0;
|
|
||||||
status = auxiliary_virt + nfc_geo->auxiliary_status_offset;
|
|
||||||
|
|
||||||
for (i = 0; i < nfc_geo->ecc_chunk_count; i++, status++) {
|
for (i = 0; i < nfc_geo->ecc_chunk_count; i++, status++) {
|
||||||
if ((*status == STATUS_GOOD) || (*status == STATUS_ERASED))
|
if ((*status == STATUS_GOOD) || (*status == STATUS_ERASED))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (*status == STATUS_UNCORRECTABLE) {
|
if (*status == STATUS_UNCORRECTABLE) {
|
||||||
failed++;
|
mtd->ecc_stats.failed++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
corrected += *status;
|
mtd->ecc_stats.corrected += *status;
|
||||||
}
|
max_bitflips = max_t(unsigned int, max_bitflips, *status);
|
||||||
|
|
||||||
/*
|
|
||||||
* Propagate ECC status to the owning MTD only when failed or
|
|
||||||
* corrected times nearly reaches our ECC correction threshold.
|
|
||||||
*/
|
|
||||||
if (failed || corrected >= (nfc_geo->ecc_strength - 1)) {
|
|
||||||
mtd->ecc_stats.failed += failed;
|
|
||||||
mtd->ecc_stats.corrected += corrected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oob_required) {
|
if (oob_required) {
|
||||||
|
@ -995,8 +984,8 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
|
||||||
this->payload_virt, this->payload_phys,
|
this->payload_virt, this->payload_phys,
|
||||||
nfc_geo->payload_size,
|
nfc_geo->payload_size,
|
||||||
payload_virt, payload_phys);
|
payload_virt, payload_phys);
|
||||||
exit_nfc:
|
|
||||||
return ret;
|
return max_bitflips;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gpmi_ecc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
|
static int gpmi_ecc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
|
||||||
|
|
Loading…
Reference in New Issue