* [PATCH RFC] clk: wm831x: fix usleep_range with bad range
@ 2016-12-12 7:40 Nicholas Mc Guire
2016-12-13 9:16 ` Charles Keepax
2016-12-21 23:27 ` Stephen Boyd
0 siblings, 2 replies; 3+ messages in thread
From: Nicholas Mc Guire @ 2016-12-12 7:40 UTC (permalink / raw)
To: Michael Turquette, Mark Brown
Cc: Stephen Boyd, patches, linux-clk, linux-kernel, Nicholas Mc Guire
The delay here is not in atomic context and does not seem critical with
respect to precision, but usleep_range(min,max) with min==max results in
giving the timer subsystem no room to optimize uncritical delays. Fix
this by setting the range to 2000,3000 us.
Fixes: commit f05259a6ffa4 ("clk: wm831x: Add initial WM831x clock driver")
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---
problem was located by coccinelle spatch
The problem is that usleep_range is calculating the delay by
exp = ktime_add_us(ktime_get(), min)
delta = (u64)(max - min) * NSEC_PER_USEC
so delta is set to 0
and then calls
schedule_hrtimeout_range(exp, 0,...)
effectively this means that the clock subsystem has no room to
optimize and the behavior is no better than using usleep().
As this is not a critical delay it is set to a range of 2 to 3
milliseconds - this change needs a review by someone that knows
the details of the device though.
Q:It might actually be possible to just use msleep(2) here rather
than using a hrtimer, at least I do not see what a hrtimer would be
needed here for - a longer delay e.g. on a HZ100 box should not hurt ?
Patch was only compile tested with: i386_defconfig + CONFIG_X86_INTEL_QUARK=y
CONFIG_MFD_WM831X_I2C=y, COMMON_CLK=y, CONFIG_COMMON_CLK_WM831X=m
Patch is against: 4.9.0-rc8 (localversion-next is -next-20161209)
drivers/clk/clk-wm831x.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk-wm831x.c b/drivers/clk/clk-wm831x.c
index f4fdac5..fe42d46 100644
--- a/drivers/clk/clk-wm831x.c
+++ b/drivers/clk/clk-wm831x.c
@@ -97,7 +97,8 @@ static int wm831x_fll_prepare(struct clk_hw *hw)
if (ret != 0)
dev_crit(wm831x->dev, "Failed to enable FLL: %d\n", ret);
- usleep_range(2000, 2000);
+ /* wait 2-3 ms for new frequency taking effect */
+ usleep_range(2000, 3000);
return ret;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] clk: wm831x: fix usleep_range with bad range
2016-12-12 7:40 [PATCH RFC] clk: wm831x: fix usleep_range with bad range Nicholas Mc Guire
@ 2016-12-13 9:16 ` Charles Keepax
2016-12-21 23:27 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2016-12-13 9:16 UTC (permalink / raw)
To: Nicholas Mc Guire
Cc: Michael Turquette, Mark Brown, Stephen Boyd, patches, linux-clk,
linux-kernel
On Mon, Dec 12, 2016 at 08:40:09AM +0100, Nicholas Mc Guire wrote:
> The delay here is not in atomic context and does not seem critical with
> respect to precision, but usleep_range(min,max) with min==max results in
> giving the timer subsystem no room to optimize uncritical delays. Fix
> this by setting the range to 2000,3000 us.
>
> Fixes: commit f05259a6ffa4 ("clk: wm831x: Add initial WM831x clock driver")
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> ---
Yeah looks fine waiting longer for the FLL to lock won't cause
any issues.
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Thanks,
Charles
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] clk: wm831x: fix usleep_range with bad range
2016-12-12 7:40 [PATCH RFC] clk: wm831x: fix usleep_range with bad range Nicholas Mc Guire
2016-12-13 9:16 ` Charles Keepax
@ 2016-12-21 23:27 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2016-12-21 23:27 UTC (permalink / raw)
To: Nicholas Mc Guire
Cc: Michael Turquette, Mark Brown, patches, linux-clk, linux-kernel
On 12/12, Nicholas Mc Guire wrote:
> The delay here is not in atomic context and does not seem critical with
> respect to precision, but usleep_range(min,max) with min==max results in
> giving the timer subsystem no room to optimize uncritical delays. Fix
> this by setting the range to 2000,3000 us.
>
> Fixes: commit f05259a6ffa4 ("clk: wm831x: Add initial WM831x clock driver")
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> ---
Applied to clk-next
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-12-21 23:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-12 7:40 [PATCH RFC] clk: wm831x: fix usleep_range with bad range Nicholas Mc Guire
2016-12-13 9:16 ` Charles Keepax
2016-12-21 23:27 ` Stephen Boyd
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).