* [PATCH] mmc: use usleep_range() in mmc_delay()
@ 2011-12-21 6:56 Dmitry Antipov
2011-12-21 11:25 ` Sujit Reddy Thumma
2012-01-13 13:22 ` Aaro Koskinen
0 siblings, 2 replies; 7+ messages in thread
From: Dmitry Antipov @ 2011-12-21 6:56 UTC (permalink / raw)
To: linaro-dev; +Cc: patches, linux-mmc, linux-kernel
From f447d78db65c6675e69466e8ed08364ff065ac08 Mon Sep 17 00:00:00 2001
From: Dmitry Antipov <dmitry.antipov@linaro.org>
Date: Wed, 21 Dec 2011 10:51:03 +0400
Subject: [PATCH] mmc: use usleep_range() in mmc_delay()
---
drivers/mmc/core/core.h | 8 ++------
1 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index 14664f1..a77851e 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -47,12 +47,8 @@ void mmc_power_off(struct mmc_host *host);
static inline void mmc_delay(unsigned int ms)
{
- if (ms < 1000 / HZ) {
- cond_resched();
- mdelay(ms);
- } else {
- msleep(ms);
- }
+ unsigned long us = ms * USEC_PER_MSEC;
+ usleep_range(us, us + 1000);
}
void mmc_rescan(struct work_struct *work);
--
1.7.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: use usleep_range() in mmc_delay()
2011-12-21 6:56 [PATCH] mmc: use usleep_range() in mmc_delay() Dmitry Antipov
@ 2011-12-21 11:25 ` Sujit Reddy Thumma
2011-12-21 13:05 ` Dmitry Antipov
2012-01-13 13:22 ` Aaro Koskinen
1 sibling, 1 reply; 7+ messages in thread
From: Sujit Reddy Thumma @ 2011-12-21 11:25 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: linaro-dev, patches, linux-mmc, linux-kernel
On 12/21/2011 12:26 PM, Dmitry Antipov wrote:
> From f447d78db65c6675e69466e8ed08364ff065ac08 Mon Sep 17 00:00:00 2001
> From: Dmitry Antipov <dmitry.antipov@linaro.org>
> Date: Wed, 21 Dec 2011 10:51:03 +0400
> Subject: [PATCH] mmc: use usleep_range() in mmc_delay()
>
> ---
> drivers/mmc/core/core.h | 8 ++------
> 1 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
> index 14664f1..a77851e 100644
> --- a/drivers/mmc/core/core.h
> +++ b/drivers/mmc/core/core.h
> @@ -47,12 +47,8 @@ void mmc_power_off(struct mmc_host *host);
>
> static inline void mmc_delay(unsigned int ms)
> {
> - if (ms < 1000 / HZ) {
> - cond_resched();
> - mdelay(ms);
> - } else {
> - msleep(ms);
> - }
> + unsigned long us = ms * USEC_PER_MSEC;
> + usleep_range(us, us + 1000);
I have posted similar patch some time back.
http://comments.gmane.org/gmane.linux.ports.arm.msm/2119.
Would you like to comment on that?
Thanks,
Sujit
> }
>
> void mmc_rescan(struct work_struct *work);
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: use usleep_range() in mmc_delay()
2011-12-21 11:25 ` Sujit Reddy Thumma
@ 2011-12-21 13:05 ` Dmitry Antipov
2011-12-27 4:40 ` Sujit Reddy Thumma
0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Antipov @ 2011-12-21 13:05 UTC (permalink / raw)
To: Sujit Reddy Thumma; +Cc: linaro-dev, patches, linux-mmc, linux-kernel
On 12/21/2011 03:25 PM, Sujit Reddy Thumma wrote:
> I have posted similar patch some time back.
> http://comments.gmane.org/gmane.linux.ports.arm.msm/2119.
>
> Would you like to comment on that?
- I believe we should forget about jiffies, HZ and other similar obsolete
timekeeping stuff;
- I have no ideas where did you get 'most typical' 20 ms. MMC subsystem uses
mmc_delay() with two compile-time fixed values 1 and 10 ms, with the only
exception of card-dependent sleep/awake timeout. I was unable to find a table
with typical values, but it's rounded up to >= 1 ms anyway.
Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: use usleep_range() in mmc_delay()
2011-12-21 13:05 ` Dmitry Antipov
@ 2011-12-27 4:40 ` Sujit Reddy Thumma
0 siblings, 0 replies; 7+ messages in thread
From: Sujit Reddy Thumma @ 2011-12-27 4:40 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: linaro-dev, patches, linux-mmc, linux-kernel
Hi Antipov,
Sorry for the delayed response. Please find some comments below:
On 12/21/2011 6:35 PM, Dmitry Antipov wrote:
> On 12/21/2011 03:25 PM, Sujit Reddy Thumma wrote:
>
>> I have posted similar patch some time back.
>> http://comments.gmane.org/gmane.linux.ports.arm.msm/2119.
>>
>> Would you like to comment on that?
>
> - I believe we should forget about jiffies, HZ and other similar obsolete
> timekeeping stuff;
>
> - I have no ideas where did you get 'most typical' 20 ms. MMC subsystem
> uses
> mmc_delay() with two compile-time fixed values 1 and 10 ms, with the only
> exception of card-dependent sleep/awake timeout. I was unable to find a
> table
> with typical values, but it's rounded up to >= 1 ms anyway.
The main aim of my patch was to fix mmc_delay() to give accurate delay.
You might want to refer to Documentation/timers/timers-howto.txt
(Section: SLEEPING FOR ~USECS OR SMALL MSECS) to know why usleep_range()
must be used instead of msleep for delays less than 20ms (or more
accurately two jiffies, since in HZ=100 systems this comes to 20ms).
Also, in the documentation it is suggested that for delays greater than
10ms+ use msleep(). Although MMC subsystem doesn't use mmc_delay() for
greater than 10ms today but I guess we should keep it for future purpose
and just not have only usleep_range() as your patch did.
>
> Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: use usleep_range() in mmc_delay()
2011-12-21 6:56 [PATCH] mmc: use usleep_range() in mmc_delay() Dmitry Antipov
2011-12-21 11:25 ` Sujit Reddy Thumma
@ 2012-01-13 13:22 ` Aaro Koskinen
2012-01-13 13:51 ` Dmitry Antipov
1 sibling, 1 reply; 7+ messages in thread
From: Aaro Koskinen @ 2012-01-13 13:22 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: linaro-dev, patches, linux-mmc, linux-kernel
Hi,
On Wed, 21 Dec 2011, Dmitry Antipov wrote:
> From f447d78db65c6675e69466e8ed08364ff065ac08 Mon Sep 17 00:00:00 2001
> From: Dmitry Antipov <dmitry.antipov@linaro.org>
> Date: Wed, 21 Dec 2011 10:51:03 +0400
> Subject: [PATCH] mmc: use usleep_range() in mmc_delay()
>
> ---
Shouldn't you add a proper patch description and a signed-off-by line?
> drivers/mmc/core/core.h | 8 ++------
> 1 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
> index 14664f1..a77851e 100644
> --- a/drivers/mmc/core/core.h
> +++ b/drivers/mmc/core/core.h
> @@ -47,12 +47,8 @@ void mmc_power_off(struct mmc_host *host);
>
> static inline void mmc_delay(unsigned int ms)
> {
> - if (ms < 1000 / HZ) {
> - cond_resched();
> - mdelay(ms);
> - } else {
> - msleep(ms);
> - }
> + unsigned long us = ms * USEC_PER_MSEC;
> + usleep_range(us, us + 1000);
> }
Anyway, I think the change is good. On systems with multiple MMC devices
the boot/probe can spend 100-200 ms alone just doing busylooping delays. I
think e.g. in mmc_rescan() the code uses frequently mmc_delay(10).
> void mmc_rescan(struct work_struct *work);
> --
> 1.7.7.4
A.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: use usleep_range() in mmc_delay()
2012-01-13 13:22 ` Aaro Koskinen
@ 2012-01-13 13:51 ` Dmitry Antipov
2012-01-13 14:52 ` Aaro Koskinen
0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Antipov @ 2012-01-13 13:51 UTC (permalink / raw)
To: Aaro Koskinen; +Cc: linaro-dev, linux-mmc, linux-kernel
On 01/13/2012 05:22 PM, Aaro Koskinen wrote:
> Anyway, I think the change is good. On systems with multiple MMC devices
> the boot/probe can spend 100-200 ms alone just doing busylooping delays. I
> think e.g. in mmc_rescan() the code uses frequently mmc_delay(10).
I'm worrying about this:
mmc_delay(DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000))
since I have no ideas about typical values for this timeout.
If it may be too small (<=10 us), using usleep_range() makes no sense.
Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: use usleep_range() in mmc_delay()
2012-01-13 13:51 ` Dmitry Antipov
@ 2012-01-13 14:52 ` Aaro Koskinen
0 siblings, 0 replies; 7+ messages in thread
From: Aaro Koskinen @ 2012-01-13 14:52 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: linaro-dev, linux-mmc, linux-kernel
Hi,
On Fri, 13 Jan 2012, Dmitry Antipov wrote:
> On 01/13/2012 05:22 PM, Aaro Koskinen wrote:
>
>> Anyway, I think the change is good. On systems with multiple MMC devices
>> the boot/probe can spend 100-200 ms alone just doing busylooping delays. I
>> think e.g. in mmc_rescan() the code uses frequently mmc_delay(10).
>
> I'm worrying about this:
>
> mmc_delay(DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000))
>
> since I have no ideas about typical values for this timeout.
> If it may be too small (<=10 us), using usleep_range() makes no sense.
Hmm, but the code above is rounding it up to at least 1 ms?
A.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-01-13 14:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-21 6:56 [PATCH] mmc: use usleep_range() in mmc_delay() Dmitry Antipov
2011-12-21 11:25 ` Sujit Reddy Thumma
2011-12-21 13:05 ` Dmitry Antipov
2011-12-27 4:40 ` Sujit Reddy Thumma
2012-01-13 13:22 ` Aaro Koskinen
2012-01-13 13:51 ` Dmitry Antipov
2012-01-13 14:52 ` Aaro Koskinen
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).