linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Vignesh Raghavendra <vigneshr@ti.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	Marek Vasut <marek.vasut@gmail.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	linux-mtd@lists.infradead.org
Subject: Re: [PATCH 2/2] mtd: cfi_cmdset_0002: fix delayed error detection on HyperFlash
Date: Mon, 28 Oct 2019 22:15:16 +0300	[thread overview]
Message-ID: <0526aa49-0649-b0d1-e72f-9b5bb8f284a5@cogentembedded.com> (raw)
In-Reply-To: <e5124cbf-c9bd-ec0e-b68f-1882646eb264@ti.com>

Hello!

On 10/16/2019 09:33 AM, Vignesh Raghavendra wrote:

>> The commit 4844ef80305d ("mtd: cfi_cmdset_0002: Add support for polling
>> status register") added checking for the status register error bits into
>> chip_good() to only return 1 if these bits are zero. Unfortunately, this
>> means that polling using chip_good() always reaches a time-out condition
>> when erase or program failure bits are set. I think the status register
>> error checking should be fully delegated to cfi_check_err_status() that
>> should return whether any error bits were set or not...
>>
> 
> Please reword last sentence to drop "I think". Something like:
> 
> Lets fully delegate the function of determining error condition to
> cfi_check_err_status() and make chip_good() only look for Device
> Ready/Busy condition.

   OK. :-)

>> Fixes: 4844ef80305d ("mtd: cfi_cmdset_0002: Add support for polling status register")
>> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
>>
>> ---
>>  drivers/mtd/chips/cfi_cmdset_0002.c |   55 +++++++++++++++++++-----------------
>>  1 file changed, 30 insertions(+), 25 deletions(-)
>>
>> Index: linux/drivers/mtd/chips/cfi_cmdset_0002.c
>> ===================================================================
>> --- linux.orig/drivers/mtd/chips/cfi_cmdset_0002.c
>> +++ linux/drivers/mtd/chips/cfi_cmdset_0002.c
>> @@ -123,14 +123,14 @@ static int cfi_use_status_reg(struct cfi
>>  		(extp->SoftwareFeatures & poll_mask) == CFI_POLL_STATUS_REG;
>>  }
>>  
>> -static void cfi_check_err_status(struct map_info *map, struct flchip *chip,
>> -				 unsigned long adr)
>> +static int cfi_check_err_status(struct map_info *map, struct flchip *chip,
>> +				unsigned long adr)
>>  {
>>  	struct cfi_private *cfi = map->fldrv_priv;
>>  	map_word status;
>>  
>>  	if (!cfi_use_status_reg(cfi))
>> -		return;
>> +		return 0;
>>  
>>  	cfi_send_gen_cmd(0x70, cfi->addr_unlock1, chip->start, map, cfi,
>>  			 cfi->device_type, NULL);
>> @@ -138,7 +138,7 @@ static void cfi_check_err_status(struct
>>  
>>  	/* The error bits are invalid while the chip's busy */
>>  	if (!map_word_bitsset(map, status, CMD(CFI_SR_DRB)))
>> -		return;
>> +		return 0;
>>  
>>  	if (map_word_bitsset(map, status, CMD(0x3a))) {
>>  		unsigned long chipstatus = MERGESTATUS(status);
>> @@ -155,7 +155,9 @@ static void cfi_check_err_status(struct
>>  		if (chipstatus & CFI_SR_SLSB)
>>  			pr_err("%s sector write protected, status %lx\n",
>>  			       map->name, chipstatus);
>> +		return 1;

   So are you OK with extending the set of the error signalling bits I
did here, or I should really have accounted only for ESB and PSB bits
being error signals?

>>  	}
>> +	return 0;
>>  }
>>  
>>  /* #define DEBUG_CFI_FEATURES */
[...]
>> @@ -1703,8 +1701,11 @@ static int __xipram do_write_oneword_onc
> 
> Nit: for some reason, your diff has function names truncated abruptly
> which makes its slightly harder to locate the context. I use git
> format-patch that produces better readable contexts.

   I use quilt for development, not a big fan of git in this role. :-)

[...]
>> @@ -1974,12 +1974,17 @@ static int __xipram do_write_buffer_wait
>>  		 */
>>  		if (time_after(jiffies, timeo) &&
>>  		    !chip_good(map, chip, adr, datum)) {
>> +			pr_warn("MTD %s(): software timeout, address:0x%.8lx.\n",
>> +				__func__, adr);
> 
> Since we are returning an error condition, this should be pr_err() (I
> know that rest of the file does not follow this convention, but lets
> make sure new code does)

   OK, I was looking at the other timeout code and failed to notice
that this printk() was converted to pr_err() by Ikegami-san... 

> Rest looks fine to me. Thanks for the patch!

   TY for the review.

MBR, Sergei

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

  reply	other threads:[~2019-10-28 19:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-03 18:29 [PATCH 0/2] Fix the HyperFlash support in the AMD/Fujitsu/Spansion CFI driver Sergei Shtylyov
2019-10-03 18:32 ` [PATCH 1/2] mtd: cfi_cmdset_0002: only check errors when ready in cfi_check_err_status() Sergei Shtylyov
2019-10-03 18:34 ` [PATCH 2/2] mtd: cfi_cmdset_0002: fix delayed error detection on HyperFlash Sergei Shtylyov
2019-10-06 20:54   ` Tokunori Ikegami
2019-10-11 12:03     ` Sergei Shtylyov
2019-10-13  3:35       ` Tokunori Ikegami
2019-10-16  6:33   ` Vignesh Raghavendra
2019-10-28 19:15     ` Sergei Shtylyov [this message]
2019-10-30 15:35       ` Vignesh Raghavendra

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=0526aa49-0649-b0d1-e72f-9b5bb8f284a5@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.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).