Re: [PATCH v2 12/53] mtd: nand: denali: support HW_ECC_FIXUP capability
From: Boris Brezillon
Date: Wed Mar 22 2017 - 17:12:29 EST
On Wed, 22 Mar 2017 23:07:19 +0900
Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx> wrote:
> +static int denali_hw_ecc_fixup(struct mtd_info *mtd,
> + struct denali_nand_info *denali)
> +{
> + int bank = denali->flash_bank;
> + uint32_t ecc_cor;
> + unsigned int max_bitflips;
> +
> + ecc_cor = ioread32(denali->flash_reg + ECC_COR_INFO(bank));
> + ecc_cor >>= ECC_COR_INFO__SHIFT(bank);
> +
> + if (ecc_cor & ECC_COR_INFO__UNCOR_ERR)
> + return -EBADMSG;
As previously mentioned, just increment ecc_stats.failed.
> +
> + max_bitflips = ecc_cor & ECC_COR_INFO__MAX_ERRORS;
> +
> + /*
> + * The register holds the maximum of the number of corrected bitflips
> + * per sector. This can be returned from ecc->read_page() as-is.
> + * Unfortunately, we can not know the total number of corrected bits
> + * in the page. mtd->ecc_stats.corrected is compromised here.
> + */
> + mtd->ecc_stats.corrected += max_bitflips;
> +
> + return max_bitflips;
> +}