[PATCH] nand gpmi fix erased block bitflip counting
Marek Vasut
marek.vasut at gmail.com
Tue Nov 15 12:54:32 PST 2016
On 11/09/2016 01:35 PM, w.cappelle at televic.com wrote:
> From: Wouter Cappelle <w.cappelle at televic.com>
Please add commit message explaining the purpose of the patch.
CCing some more interested people.
> ---
> drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index 8339d4f..6ae118c 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -1217,6 +1217,7 @@ static bool gpmi_erased_check(struct gpmi_nand_data *this,
> int base = geo->ecc_chunkn_size * chunk;
> unsigned int flip_bits = 0, flip_bits_noecc = 0;
> uint64_t *buf = (uint64_t *)this->data_buffer_dma;
> + unsigned char *chunkbuf =(unsigned char*) this->data_buffer_dma;
> unsigned int threshold;
> int i;
>
> @@ -1224,13 +1225,6 @@ static bool gpmi_erased_check(struct gpmi_nand_data *this,
> if (threshold > geo->ecc_strength)
> threshold = geo->ecc_strength;
>
> - /* Count bitflips */
> - for (i = 0; i < geo->ecc_chunkn_size; i++) {
> - flip_bits += hweight8(~data[base + i]);
> - if (flip_bits > threshold)
> - return false;
> - }
> -
> /*
> * Read out the whole page with ECC disabled, and check it again,
> * This is more strict then just read out a chunk, and it makes
> @@ -1246,6 +1240,12 @@ static bool gpmi_erased_check(struct gpmi_nand_data *this,
> return false;
> }
>
> + /* Count bitflips in the current chunk for correct stats reporting */
> + for (i = 0; i < geo->ecc_chunkn_size; i++) {
> + flip_bits += hweight8(~chunkbuf[base + i]);
> + }
> +
> +
> /* Tell the upper layer the bitflips we corrected. */
> mtd->ecc_stats.corrected += flip_bits;
> *max_bitflips = max_t(unsigned int, *max_bitflips, flip_bits);
>
--
Best regards,
Marek Vasut
More information about the linux-mtd
mailing list