linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] ARM: imx: clk-pllv3: change wait method for PLL lock
@ 2013-06-06  6:55 Peter Chen
  2013-06-06  9:21 ` Russell King - ARM Linux
  2013-06-06 12:16 ` Uwe Kleine-König
  0 siblings, 2 replies; 9+ messages in thread
From: Peter Chen @ 2013-06-06  6:55 UTC (permalink / raw)
  To: linux-arm-kernel

For tickless system, the jiffies may be updated long time (>20ms).
At high loading system, the current waiting method will cause waiting
timeout, and cause a kernel dump at below case.
After timeout = jiffies + msecs_to_jiffies(10),
the timer interrupt occurs, it updates jiffies (eg,  + 2 jiffies),
then return back from interrupt, the time between above operations
are tiny, the PLL is still not locked, but the timeout condition is satisfied.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 arch/arm/mach-imx/clk-pllv3.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-imx/clk-pllv3.c b/arch/arm/mach-imx/clk-pllv3.c
index 36aac94..eefc6c2 100644
--- a/arch/arm/mach-imx/clk-pllv3.c
+++ b/arch/arm/mach-imx/clk-pllv3.c
@@ -16,6 +16,7 @@
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/err.h>
+#include <linux/delay.h>
 #include "clk.h"
 
 #define PLL_NUM_OFFSET		0x10
@@ -50,7 +51,7 @@ struct clk_pllv3 {
 static int clk_pllv3_prepare(struct clk_hw *hw)
 {
 	struct clk_pllv3 *pll = to_clk_pllv3(hw);
-	unsigned long timeout = jiffies + msecs_to_jiffies(10);
+	int count = 100;
 	u32 val;
 
 	val = readl_relaxed(pll->base);
@@ -62,9 +63,11 @@ static int clk_pllv3_prepare(struct clk_hw *hw)
 	writel_relaxed(val, pll->base);
 
 	/* Wait for PLL to lock */
-	while (!(readl_relaxed(pll->base) & BM_PLL_LOCK))
-		if (time_after(jiffies, timeout))
+	while (!(readl_relaxed(pll->base) & BM_PLL_LOCK)) {
+		udelay(100);
+		if (--count == 0)
 			return -ETIMEDOUT;
+	}
 
 	return 0;
 }
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-06-13 13:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-06  6:55 [PATCH 1/1] ARM: imx: clk-pllv3: change wait method for PLL lock Peter Chen
2013-06-06  9:21 ` Russell King - ARM Linux
2013-06-07  3:28   ` Peter Chen
2013-06-06 12:16 ` Uwe Kleine-König
2013-06-07  2:53   ` Peter Chen
2013-06-07  3:33     ` Peter Chen
2013-06-07  7:49       ` Uwe Kleine-König
2013-06-07 16:47   ` John Stultz
2013-06-13 13:32     ` Frederic Weisbecker

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).