linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Tokunori Ikegami" <ikegami.t@gmail.com>
To: "'Przemyslaw Sobon'" <psobon@amazon.com>, <bbrezillon@kernel.org>,
	<Joakim.Tjernlund@infinera.com>, <linux-mtd@lists.infradead.org>,
	<chris.packham@alliedtelesis.co.nz>, <fbettoni@gmail.com>,
	<liujian56@huawei.com>
Cc: ikegami_to@yahoo.co.jp
Subject: RE: [PATCH] mtd: cfi: Fixed endless loop problem in CFI when value was written but corrupted.
Date: Sat, 9 Feb 2019 00:01:53 +0900	[thread overview]
Message-ID: <149301d4bfbf$48c4c1e0$da4e45a0$@gmail.com> (raw)
In-Reply-To: <20190207235806.GA39580@dev-dsk-psobon-2c-1dd9f399.us-west-2.amazon.com>

Hi Przemek-san,

I think that for the error case it should be done to retry at first.
It can be implemented separately but it is possible to be not enough.

Since the flash write error causes the user data corruption I think.
File systems and applications do not execute any recovery usually.
In the past I saw a similar write error actually and fixed as below.

  dfeae1073583d ("mtd: cfi_cmdset_0002: Change write buffer to check correct
value")

I am also seeing a similar flash write error for the word write case.
In the case the retry with the reset recovery does not work fully.
After the repeated retry with the reset the flash is not able to work.
There is a possibility for the buffer write also but sorry not sure.
Since there is a difference to execute the recovery command.

As Jocke-san mentioned I also think the chip_ready() does not work.
It is followed correctly basically the flash chip specification.
But actually it does not check the chip state correctly I think.
So for the flash write error cases I saw the chip_good() is necessary.

Regards,
Ikegami

> -----Original Message-----
> From: linux-mtd [mailto:linux-mtd-bounces@lists.infradead.org] On Behalf
> Of Przemyslaw Sobon
> Sent: Friday, February 8, 2019 8:58 AM
> To: bbrezillon@kernel.org; Joakim.Tjernlund@infinera.com;
> linux-mtd@lists.infradead.org; chris.packham@alliedtelesis.co.nz;
> fbettoni@gmail.com; ikegami@allied-telesis.co.jp; liujian56@huawei.com
> Cc: psobon@amazon.com
> Subject: [PATCH] mtd: cfi: Fixed endless loop problem in CFI when value
> was written but corrupted.
> 
> Fixes: dfeae1073583(mtd: cfi_cmdset_0002: Change write buffer to
>        check correct value)
> 
> 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
> --
> 2.16.5
> 
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2019-02-08 15:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-07 23:58 [PATCH] mtd: cfi: Fixed endless loop problem in CFI when value was written but corrupted Przemyslaw Sobon
2019-02-08 15:01 ` Tokunori Ikegami [this message]
2019-02-14  0:39 ` Chris Packham
2019-02-19  8:00   ` Boris Brezillon
2019-02-19 20:02     ` Mark Tomlinson
2019-02-20  8:03       ` Boris Brezillon
2019-02-20 20:50         ` Mark Tomlinson
  -- strict thread matches above, loose matches on Subject: below --
2019-01-16  0:32 [PATCH] " Przemyslaw Sobon
2019-01-16  8:33 ` Joakim Tjernlund
2019-01-16  8:50   ` Joakim Tjernlund
2019-01-16  8:54   ` Sobon, Przemyslaw

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='149301d4bfbf$48c4c1e0$da4e45a0$@gmail.com' \
    --to=ikegami.t@gmail.com \
    --cc=Joakim.Tjernlund@infinera.com \
    --cc=bbrezillon@kernel.org \
    --cc=chris.packham@alliedtelesis.co.nz \
    --cc=fbettoni@gmail.com \
    --cc=ikegami_to@yahoo.co.jp \
    --cc=linux-mtd@lists.infradead.org \
    --cc=liujian56@huawei.com \
    --cc=psobon@amazon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).