Skip to contentSkip to conversation

ARM: imx: clk-pllv3: improve the timeout waiting method

PATCH New Peter Chen 3 participants 3 messages Jul 16, 2013

Subsystems (3)
lore
Share & tools
lore

Peter Chen

author
#0 lore raw

PATCH v2 1/1 ARM: imx: clk-pllv3: improve the timeout waiting method

There are two improvements for this commit:

- Add comparing pll lock condition after while loop. It can fix potential fake timeout problem caused by the code is just scheduled out before compare the timeout, and the time of scheduling out are more than one jiffies.

- Move timeout assignment more close to compare the timeout. It can reduce the possibility the code is scheduled out, and the timeout can be more precise.

---

Changes for v2:
- Add more description for this improvement according to Fabio's suggstion.
- Add comparsion after while loop according to Sascha's suggestion.

 arch/arm/mach-imx/clk-pllv3.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
arch/arm/mach-imx/clk-pllv3.c +11 -4
index 36aac94..4499db5 100644
@@ -50,7 +50,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);
+	unsigned long timeout;
 	u32 val;
 
 	val = readl_relaxed(pll->base);
@@ -61,12 +61,19 @@ static int clk_pllv3_prepare(struct clk_hw *hw)
 		val &= ~BM_PLL_POWER;
 	writel_relaxed(val, pll->base);
 
+	timeout = jiffies + msecs_to_jiffies(10);
 	/* Wait for PLL to lock */
-	while (!(readl_relaxed(pll->base) & BM_PLL_LOCK))
+	do {
+		if (readl_relaxed(pll->base) & BM_PLL_LOCK)
+			break;
 		if (time_after(jiffies, timeout))
-			return -ETIMEDOUT;
+			break;
+	} while (1);
 
-	return 0;
+	if (readl_relaxed(pll->base) & BM_PLL_LOCK)
+		return 0;
+	else
+		return -ETIMEDOUT;
 }
 
 static void clk_pllv3_unprepare(struct clk_hw *hw)
Signature · 1 line
1.7.0.4
maintainer
#1 lore raw

PATCH v2 1/1 ARM: imx: clk-pllv3: improve the timeout waiting method

Quoted 7 lines · Peter Chen

There are two improvements for this commit:

- Add comparing pll lock condition after while loop. It can fix potential fake timeout problem caused by the code is just scheduled out before compare the timeout, and the time of scheduling out are more than one jiffies.

Quoted 5 lines

- Move timeout assignment more close to compare the timeout. It can reduce the possibility the code is scheduled out, and the timeout can be more precise.

Sascha

Quoted 57 lines

---

Changes for v2:
- Add more description for this improvement according to Fabio's suggstion.
- Add comparsion after while loop according to Sascha's suggestion.

 arch/arm/mach-imx/clk-pllv3.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
arch/arm/mach-imx/clk-pllv3.c +11 -4
index 36aac94..4499db5 100644
@@ -50,7 +50,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);
+	unsigned long timeout;
 	u32 val;
 
 	val = readl_relaxed(pll->base);
@@ -61,12 +61,19 @@ static int clk_pllv3_prepare(struct clk_hw *hw)
 		val &= ~BM_PLL_POWER;
 	writel_relaxed(val, pll->base);
 
+	timeout = jiffies + msecs_to_jiffies(10);
 	/* Wait for PLL to lock */
-	while (!(readl_relaxed(pll->base) & BM_PLL_LOCK))
+	do {
+		if (readl_relaxed(pll->base) & BM_PLL_LOCK)
+			break;
 		if (time_after(jiffies, timeout))
-			return -ETIMEDOUT;
+			break;
+	} while (1);
 
-	return 0;
+	if (readl_relaxed(pll->base) & BM_PLL_LOCK)
+		return 0;
+	else
+		return -ETIMEDOUT;
 }
 
 static void clk_pllv3_unprepare(struct clk_hw *hw)
Signature · 8 lines
1.7.0.4



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Applied
#2 lore raw

PATCH v2 1/1 ARM: imx: clk-pllv3: improve the timeout waiting method

In reply to Peter Chen
Quoted 7 lines · Peter Chen

There are two improvements for this commit:

- Add comparing pll lock condition after while loop. It can fix potential fake timeout problem caused by the code is just scheduled out before compare the timeout, and the time of scheduling out are more than one jiffies.

Quoted 5 lines

- Move timeout assignment more close to compare the timeout. It can reduce the possibility the code is scheduled out, and the timeout can be more precise.

Applied, thanks.