[PATCH v3 1/2] mtd: spi-nand: Add read retry support

Miquel Raynal miquel.raynal at bootlin.com
Thu Feb 6 09:13:25 PST 2025


Hello Cheng,

> @@ -687,18 +691,43 @@ static int spinand_mtd_regular_page_read(struct mtd_info *mtd, loff_t from,
>  		if (ret)
>  			break;
>  
> +read_retry:
>  		ret = spinand_read_page(spinand, &iter.req);
>  		if (ret < 0 && ret != -EBADMSG)
>  			break;
>  
> -		if (ret == -EBADMSG)
> +		if (ret == -EBADMSG && spinand->set_read_retry) {
> +			if (spinand->read_retries && (++retry_mode < spinand->read_retries)) {

I believe the condition should be:

                        if (spinand->read_retries && (++retry_mode <= spinand->read_retries)) {

So if you have 5 retry modes, you can provide 5 in the manufacturer driver,
and not 6.

> +				ret = spinand->set_read_retry(spinand, retry_mode);
> +				if (ret < 0) {
> +					ecc_failed = true;
> +					return ret;

Shall we try to set the read_retry level to 0 upon:

      if (ret < 0 && retry_mode > 1)

?

> +				}
> +
> +				/* Reset ecc_stats; retry */
> +				mtd->ecc_stats = old_stats;
> +				goto read_retry;
> +			} else {
> +				/* No more retry modes; real failure */
> +				ecc_failed = true;
> +			}
> +		} else if (ret == -EBADMSG) {

Rest lgtm.

Thanks,
Miquèl



More information about the linux-mtd mailing list