public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* Re: [PATCH] Fixed a endless loop problem in CFI when value was written but corrupted.
       [not found] <20190107213407.GA103132@dev-dsk-psobon-2c-1dd9f399.us-west-2.amazon.com>
@ 2019-01-08 11:50 ` Boris Brezillon
  0 siblings, 0 replies; only message in thread
From: Boris Brezillon @ 2019-01-08 11:50 UTC (permalink / raw)
  To: Przemyslaw Sobon
  Cc: David Woodhouse, Brian Norris, Marek Vasut, Richard Weinberger,
	Tokunori Ikegami, linux-mtd@lists.infradead.org

+MTD ML and Tokunori who fixed something similar IIRC.

Hi Przemyslaw,

Can you resend the patch with the ML in Cc please (so that the patch
appears in our patchwork)?

Thanks,

Boris

On Mon, 7 Jan 2019 21:34:07 +0000
Przemyslaw Sobon <psobon@amazon.com> wrote:

> There was an endless loop in CFI Flash driver when a value was written
> incorrectly. In such case chip_ready returns true but chip_good returns
> false and we never get out of the loop.
> 
> The solution was to break the loop in 2 cases, either device is ready or
> device is not ready and timeout elapsed. The correctness of the write is
> checked after the loop ended. That way we ensure the loop always ends.
> 
> Signed-off-by: Przemyslaw Sobon <psobon@amazon.com>
> ---
>  drivers/mtd/chips/cfi_cmdset_0002.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
> index 72428b6bfc47..6cc31d2057e9 100644
> --- a/drivers/mtd/chips/cfi_cmdset_0002.c
> +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
> @@ -1879,15 +1879,18 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
>  		if (time_after(jiffies, timeo) && !chip_ready(map, adr))
>  			break;
>  
> -		if (chip_good(map, adr, datum)) {
> -			xip_enable(map, chip, adr);
> -			goto op_done;
> -		}
> +		if (chip_ready(map, adr))
> +			break;
>  
>  		/* Latency issues. Drop the lock, wait a while and retry */
>  		UDELAY(map, chip, adr, 1);
>  	}
>  
> +	if (chip_good(map, adr, datum)) {
> +		xip_enable(map, chip, adr);
> +		goto op_done;
> +	}
> +
>  	/*
>  	 * Recovery from write-buffer programming failures requires
>  	 * the write-to-buffer-reset sequence.  Since the last part

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-01-08 11:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20190107213407.GA103132@dev-dsk-psobon-2c-1dd9f399.us-west-2.amazon.com>
2019-01-08 11:50 ` [PATCH] Fixed a endless loop problem in CFI when value was written but corrupted Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox