ARM: imx: clk-pllv3: change wait method for PLL lock
Subsystems (3)
PATCH v2 1/1 ARM: imx: clk-pllv3: change wait method for PLL lock
For some unknown reasons, the jiffies will be updated more
than one tick at every short time. Eg, at this code:
After timeout = jiffies + msecs_to_jiffies(10),
the interrupt occurs, and the softirq 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.
---
Changes for v2:
- According to Russell King's suggestion, change code for more reasonable for timeout condition.
- Change commit log.
arch/arm/mach-imx/clk-pllv3.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
arch/arm/mach-imx/clk-pllv3.c +10 -4
@@ -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
@@ -48,7 +49,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);
@@ -60,9 +61,14 @@ 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)) -return -ETIMEDOUT ; +do { +if (readl_relaxed (pll->base) &BM_PLL_LOCK ) +break ; +udelay (100 ); + }while (count--); + +if (count ==0 && !(readl_relaxed (pll->base) &BM_PLL_LOCK )) +return -ETIMEDOUT ;return 0 ; }
Signature · 1 line
1.7.0.4
PATCH v2 1/1 ARM: imx: clk-pllv3: change wait method for PLL lock
Quoted 8 lines · Peter Chen
For some unknown reasons, the jiffies will be updated more
than one tick at every short time. Eg, at this code:
After timeout = jiffies +msecs_to_jiffies(10),
the interrupt occurs, and the softirq 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 <[email protected]>
Does this mean my patch doesn't solve the issue for you?
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 1/1 ARM: imx: clk-pllv3: change wait method for PLL lock
Quoted 10 lines · Uwe Kleine-K?nig
Quoted 8 lines · Peter Chen
For some unknown reasons, the jiffies will be updated more
than one tick at every short time. Eg, at this code:
After timeout = jiffies +msecs_to_jiffies(10),
the interrupt occurs, and the softirq 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 <[email protected]>Does this mean my patch doesn't solve the issue for you?
Not try, but your patch just delay timeout assignment, if there is jiffies update after that but before timeout check, it still has problem.
Quoted 9 lines
Best regards
UweSignature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
Signature · 2 lines
Best Regards, Peter Chen
PATCH v2 1/1 ARM: imx: clk-pllv3: change wait method for PLL lock
Quoted 9 lines · Peter Chen
Quoted 8 lines · Uwe Kleine-K?nig
Quoted 7 lines · Peter Chen
For some unknown reasons, the jiffies will be updated more
than one tick at every short time. Eg, at this code:
After timeout = jiffies +msecs_to_jiffies(10),
the interrupt occurs, and the softirq 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.
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Peter Chen <[email protected]>Does this mean my patch doesn't solve the issue for you?
Not try, but your patch just delay timeout assignment, if there is jiffies update after that but before timeout check, it still has problem.
But if that large update happens because there was a long preemption the pll should be locked because I only start counting when the pll is programmed.
IMHO you should try my patch as it is the better fix (assuming it fixes it for you).
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 1/1 ARM: imx: clk-pllv3: change wait method for PLL lock
Quoted 16 lines · Uwe Kleine-K?nig
Quoted 9 lines · Peter Chen
Quoted 8 lines · Uwe Kleine-K?nig
Quoted 7 lines · Peter Chen
For some unknown reasons, the jiffies will be updated more
than one tick at every short time. Eg, at this code:
After timeout = jiffies +msecs_to_jiffies(10),
the interrupt occurs, and the softirq 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.Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Peter Chen <[email protected]>Does this mean my patch doesn't solve the issue for you?
Not try, but your patch just delay timeout assignment, if there is jiffies update after that but before timeout check, it still has problem.
Quoted 6 lines
But if that large update happens because there was a long preemption the pll should be locked because I only start counting when the pll is programmed.
IMHO you should try my patch as it is the better fix (assuming it fixes it for you).
I will try your fix, but still it just reduces the possibilities. The problem is not the preemption takes too long, it is the jiffies updates more than one tick at one short preemption.
Signature · 2 lines
Best Regards, Peter Chen
PATCH v2 1/1 ARM: imx: clk-pllv3: change wait method for PLL lock
Hello Peter,
Quoted 21 lines · Peter Chen
Quoted 20 lines · Uwe Kleine-K?nig
Quoted 9 lines · Peter Chen
Quoted 8 lines · Uwe Kleine-K?nig
Quoted 7 lines · Peter Chen
For some unknown reasons, the jiffies will be updated more
than one tick at every short time. Eg, at this code:
After timeout = jiffies +msecs_to_jiffies(10),
the interrupt occurs, and the softirq 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.Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Peter Chen <[email protected]>Does this mean my patch doesn't solve the issue for you?
Not try, but your patch just delay timeout assignment, if there is jiffies update after that but before timeout check, it still has problem.
But if that large update happens because there was a long preemption the pll should be locked because I only start counting when the pll is programmed.
Quoted 6 lines
Quoted 2 lines
IMHO you should try my patch as it is the better fix (assuming it fixes it for you).
I will try your fix, but still it just reduces the possibilities. The problem is not the preemption takes too long, it is the jiffies updates more than one tick at one short preemption.
If that is really the problem that many more instances that use the same incarnation need the same fix. I would be surprised if that was the case.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 1/1 ARM: imx: clk-pllv3: change wait method for PLL lock
Quoted 6 lines · Uwe Kleine-K?nig
Quoted 3 lines
I will try your fix, but still it just reduces the possibilities. The problem is not the preemption takes too long, it is the jiffies updates more than one tick at one short preemption.
If that is really the problem that many more instances that use the same incarnation need the same fix. I would be surprised if that was the case.
+1
We have plenty of timeout code written like that in the kernel.
Shawn
PATCH v2 1/1 ARM: imx: clk-pllv3: change wait method for PLL lock
Quoted 10 lines · Shawn Guo
Quoted 6 lines · Uwe Kleine-K?nig
Quoted 3 lines
I will try your fix, but still it just reduces the possibilities. The problem is not the preemption takes too long, it is the jiffies updates more than one tick at one short preemption.
If that is really the problem that many more instances that use the same incarnation need the same fix. I would be surprised if that was the case.
+1
Using uwe's patch, the pll lock timeout hasn't appeared during the overtime test, usually, it will occur 4 or 5 times during overnight test. The reason why I suspect jiffies update problem that is we meet the similiar issue at other drivers which timeout is 2 jiffies, but it is satisfied within 1ms.
I will do more test, if it is passed, I will send patch with uwe's suggestion. Thanks.
Signature · 2 lines
Best Regards, Peter Chen
PATCH v2 1/1 ARM: imx: clk-pllv3: change wait method for PLL lock
Quoted 12 lines · Peter Chen
Quoted 10 lines · Shawn Guo
Quoted 6 lines · Uwe Kleine-K?nig
Quoted 3 lines
I will try your fix, but still it just reduces the possibilities. The problem is not the preemption takes too long, it is the jiffies updates more than one tick at one short preemption.
If that is really the problem that many more instances that use the same incarnation need the same fix. I would be surprised if that was the case.
+1
Quoted 8 lines
Using uwe's patch, the pll lock timeout hasn't appeared during the overtime test, usually, it will occur 4 or 5 times during overnight test. The reason why I suspect jiffies update problem that is we meet the similiar issue at other drivers which timeout is 2 jiffies, but it is satisfied within 1ms.
I will do more test, if it is passed, I will send patch with uwe's suggestion. Thanks.
The root cause of this problem is timer problem, Jason has already submitted a patch to fix this problem.
http://marc.info/?l=linux-arm-kernel&m=137109340222931&w=2
I will send a improvement patch with uwe's suggestion.
Signature · 2 lines
Best Regards, Peter Chen