linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yijing Wang <wangyijing@huawei.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: <linux-pci@vger.kernel.org>
Subject: Re: [PATCH 3/3] PCI: Use usleep_range() instead of msleep() for better accuracy
Date: Wed, 24 Jun 2015 09:47:11 +0800	[thread overview]
Message-ID: <558A0C1F.6010405@huawei.com> (raw)
In-Reply-To: <20150619171249.GK7710@google.com>

On 2015/6/20 1:12, Bjorn Helgaas wrote:
> On Fri, Jun 19, 2015 at 03:57:46PM +0800, Yijing Wang wrote:
>> Msleep < 20ms can sleep for up to 20ms, see
>> Documentation/timers/timers-howto.txt, so we could
>> use usleep_range instead.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> ---
>>  drivers/pci/hotplug/pciehp_hpc.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
>> index daf54be..4553728 100644
>> --- a/drivers/pci/hotplug/pciehp_hpc.c
>> +++ b/drivers/pci/hotplug/pciehp_hpc.c
>> @@ -118,7 +118,7 @@ static int pcie_poll_cmd(struct controller *ctrl, int timeout)
>>  		}
>>  		if (timeout < 0)
>>  			break;
>> -		msleep(10);
>> +		usleep_range(10000, 11000);
> 
> timers-howto.txt also says to use msleep for 10ms+ delays, so the guidance
> is a bit ambiguous.
> 
> This particular delay does not need to be precise, and if we delay 20ms
> instead of 10ms (1/50th of a second vs 1/100th of a second), I don't think
> it makes any difference at all.
> 
> If we *did* make a change here, I think we should use a range of at least
> 10ms.  There's no need to tighten the wakeup time to the 1ms window between
> 10ms and 11ms.  Any time in the range of 10ms to 50ms would probably be
> fine.
> 
> But I don't think a change here is necessary, and it does make it a bit
> harder to analyze the code because we have some things in microseconds and
> others in milliseconds.

OK, I got it, thanks for your explanation.

Thanks!
Yijing.


> 
>>  		timeout -= 10;
>>  	}
>>  	return 0;	/* timeout */
>> -- 
>> 1.7.1
>>
> 
> 


-- 
Thanks!
Yijing


  reply	other threads:[~2015-06-24  1:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-19  7:57 [PATCH 0/3] Trivial pci hotplug changes Yijing Wang
2015-06-19  7:57 ` [PATCH 1/3] PCI: Use "slot" and "pci_slot" for struct hotplug_slot and struct pci_slot Yijing Wang
2015-06-19  7:57 ` [PATCH 2/3] PCI: Simplify pcie_poll_cmd() Yijing Wang
2015-06-19  7:57 ` [PATCH 3/3] PCI: Use usleep_range() instead of msleep() for better accuracy Yijing Wang
2015-06-19 17:12   ` Bjorn Helgaas
2015-06-24  1:47     ` Yijing Wang [this message]
2015-06-19 17:14 ` [PATCH 0/3] Trivial pci hotplug changes Bjorn Helgaas
2015-06-24  1:47   ` Yijing Wang

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=558A0C1F.6010405@huawei.com \
    --to=wangyijing@huawei.com \
    --cc=bhelgaas@google.com \
    --cc=linux-pci@vger.kernel.org \
    /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).