public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Amit Virdi <amit.virdi@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 03/11] st_smi: Return error in case TFF is not set
Date: Wed, 29 Feb 2012 14:40:20 +0530	[thread overview]
Message-ID: <4F4DEB7C.9010307@st.com> (raw)
In-Reply-To: <201202271126.18256.sr@denx.de>

Hello Stefan,

On 2/27/2012 3:56 PM, Stefan Roese wrote:
> On Friday 24 February 2012 13:23:06 Amit Virdi wrote:
>> Curently the code makes wrong assumption that the Transfer finished flag
>> shall be set within the stipulated time. However, there may occur a
>> scenario in which the TFF flag is not set. Return error in that case.
>>
>> Signed-off-by: Vipin Kumar<vipin.kumar@st.com>
>> Signed-off-by: Amit Virdi<amit.virdi@st.com>
>> ---
>>   drivers/mtd/st_smi.c |   22 ++++++++++++++--------
>>   1 files changed, 14 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/mtd/st_smi.c b/drivers/mtd/st_smi.c
>> index 82f1fe1..ec19b0d 100644
>> --- a/drivers/mtd/st_smi.c
>> +++ b/drivers/mtd/st_smi.c
>> @@ -58,13 +58,15 @@ static struct flash_dev flash_ids[] = {
>>    *
>>    * Wait until TFF is set in status register
>>    */
>> -static void smi_wait_xfer_finish(int timeout)
>> +static int smi_wait_xfer_finish(int timeout)
>>   {
>> -	while (timeout--) {
>> +	do {
>>   		if (readl(&smicntl->smi_sr)&  TFF)
>> -			break;
>> +			return 0;
>>   		udelay(1000);
>> -	}
>> +	} while (timeout--);
>> +
>> +	return -1;
>
> Somewhat unrelated to the patch topic, but I don't really like this kind of
> timeout loops. Since it always adds at least 1ms delay after initial failing
> test. Better use something like this:
>
> static int smi_wait_xfer_finish(int timeout)
> {
> 	ulong start = get_timer(0);
>
> 	while (get_timer(start)<  timeout) {
> 		if (readl(&smicntl->smi_sr)&  TFF)
> 			return 0;
>
> 		/* Try again after 100usec */
> 		udelay(100);
> 	}
>
> 	return -1;
> }
>
> You could tune this udelay(100) down more or even remove it completely.
>
> But such a change could be done in a addon cleanup patch, changing all timeout
> loops this way. I suggest you take a look at my version, here these loops are
> changes. In the designware networking driver as well, iirc.
>

Thanks for pointing out. In a separate cleanup patch, I shall be 
changing all the timeout loops for smi driver. I'll check other ST 
drivers too and change the timer implementation there too.

Regards
Amit Virdi

  reply	other threads:[~2012-02-29  9:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-24 12:23 [U-Boot] [PATCH 00/11] mtd/SMI: Add support for ST SMI controller Amit Virdi
2012-02-24 12:23 ` [U-Boot] [PATCH 01/11] st_smi: Add support for SPEAr SMI driver Amit Virdi
2012-04-20  7:47   ` Stefan Roese
2012-02-24 12:23 ` [U-Boot] [PATCH 02/11] st_smi: Remove compilation warning Amit Virdi
2012-02-24 12:23 ` [U-Boot] [PATCH 03/11] st_smi: Return error in case TFF is not set Amit Virdi
2012-02-27 10:26   ` Stefan Roese
2012-02-29  9:10     ` Amit Virdi [this message]
2012-03-02 13:32       ` Stefan Roese
2012-02-24 12:23 ` [U-Boot] [PATCH 04/11] st_smi: Change SMI timeout values Amit Virdi
2012-02-24 12:23 ` [U-Boot] [PATCH 05/11] st_smi: Enhance the error handling Amit Virdi
2012-02-24 12:23 ` [U-Boot] [PATCH 06/11] st_smi: Read status until timeout happens Amit Virdi
2012-02-24 12:23 ` [U-Boot] [PATCH 07/11] st_smi: Move status register read before modifying ctrl register Amit Virdi
2012-02-24 12:23 ` [U-Boot] [PATCH 08/11] st_smi: Fix smi read status Amit Virdi
2012-02-24 12:23 ` [U-Boot] [PATCH 09/11] st_smi: Removed no needed dependency on ST_M25Pxx_ID Amit Virdi
2012-02-24 12:23 ` [U-Boot] [PATCH 10/11] st_smi: Change the flash probing method Amit Virdi
2012-02-24 12:23 ` [U-Boot] [PATCH 11/11] st_smi: Fix bug in flash_print_info() Amit Virdi
2012-03-07 10:02 ` [U-Boot] [PATCH 00/11] mtd/SMI: Add support for ST SMI controller Amit Virdi
2012-03-07 11:27   ` Stefan Roese
2012-03-07 11:46     ` Amit Virdi
2012-03-07 11:49       ` Stefan Roese
2012-03-30  6:12 ` [U-Boot] [PATCH] st_smi: Fixed page size for Winbond W25Q128FV flash Amit Virdi

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=4F4DEB7C.9010307@st.com \
    --to=amit.virdi@st.com \
    --cc=u-boot@lists.denx.de \
    /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