ARM: SAMSUNG: Bug fix spin_lock recursion in clk_enable() and clk_disable()
Subsystems (3)
PATCH 1/1 ARM: SAMSUNG: Bug fix spin_lock recursion in clk_enable() and clk_disable()
From: Minho Ban <[email protected]>
The clk_enable() and clk_disable() can be used process and ISR either. So spin_lock_irqsave should be used instead.
--- arch/arm/plat-samsung/clock.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)
arch/arm/plat-samsung/clock.c +8 -4
@@ -138,31 +138,35 @@ void clk_put(struct clk *clk)int clk_enable (struct clk *clk) { +unsigned long flags; +if (IS_ERR (clk) || clk ==NULL )return -EINVAL ;clk_enable (clk->parent); -spin_lock (&clocks_lock); +spin_lock_irqsave (&clocks_lock, flags);if ((clk->usage++) ==0 ) (clk->enable)(clk,1 ); -spin_unlock (&clocks_lock); +spin_unlock_irqrestore (&clocks_lock, flags);return 0 ; }void clk_disable (struct clk *clk) { +unsigned long flags; +if (IS_ERR (clk) || clk ==NULL )return ; -spin_lock (&clocks_lock); +spin_lock_irqsave (&clocks_lock, flags);if ((--clk->usage) ==0 ) (clk->enable)(clk,0 ); -spin_unlock (&clocks_lock); +spin_unlock_irqrestore (&clocks_lock, flags);clk_disable (clk->parent); }
Signature · 1 line
1.6.2.5
PATCH 1/1 ARM: SAMSUNG: Bug fix spin_lock recursion in clk_enable() and clk_disable()
Quoted 43 lines · Jaecheol Lee
From: Minho Ban <[email protected]>
The
clk_enable()andclk_disable()can be used process and ISR either. Sospin_lock_irqsaveshould be used instead.Signed-off-by Minho Ban <[email protected]>Signed-off-by Jaecheol Lee <[email protected]>--- arch/arm/plat-samsung/clock.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)arch/arm/plat-samsung/clock.c +6
-2@@ -138,31 +138,35 @@ void clk_put(struct clk *clk)int clk_enable (struct clk *clk) { +unsigned long flags; +if (IS_ERR (clk) || clk ==NULL )return -EINVAL ;clk_enable (clk->parent); -spin_lock (&clocks_lock); +spin_lock_irqsave (&clocks_lock, flags);if ((clk->usage++) ==0 ) (clk->enable)(clk,1 ); -spin_unlock (&clocks_lock); +spin_unlock_irqrestore (&clocks_lock, flags);return 0 ; }void clk_disable (struct clk *clk) { +unsigned long flags; +if (IS_ERR (clk) || clk ==NULL )return ;
arch/arm/plat-samsung/clock.c void clk_put(struct clk *clk) · line 170
Quoted 10 lines
arch/arm/plat-samsung/clock.c +2
-2-spin_lock (&clocks_lock); +spin_lock_irqsave (&clocks_lock, flags);if ((--clk->usage) ==0 ) (clk->enable)(clk,0 ); -spin_unlock (&clocks_lock); +spin_unlock_irqrestore (&clocks_lock, flags);clk_disable (clk->parent);
I'm not sure, but I don't belive that the clk_ api has ever been callable from non-sleepable contexts such as interrupt handlers.
I would welcome RMK's response (or any other response) about this issue?
Personally, given that some clk_ calls may sleep esp. for pll enables, I would prefer to see this patch dropped in favour of fixing the users.
Signature · 1 line
Ben
PATCH 1/1 ARM: SAMSUNG: Bug fix spin_lock recursion in clk_enable() and clk_disable()
Quoted 59 lines · Ben Dooks
Quoted 43 lines · Jaecheol Lee
From: Minho Ban <[email protected]>
The
clk_enable()andclk_disable()can be used process and ISR either. Sospin_lock_irqsaveshould be used instead.Signed-off-by Minho Ban <[email protected]>Signed-off-by Jaecheol Lee <[email protected]>---
?arch/arm/plat-samsung/clock.c | ? 12 ++++++++---- ?1 files changed, 8 insertions(+), 4 deletions(-)arch/arm/plat-samsung/clock.c +6
-2@@ -138,31 +138,35 @@ void clk_put(struct clk *clk) ?int clk_enable(struct clk *clk) ?{ + ? ? unsigned long flags; + ? ? ? if (IS_ERR(clk) || clk == NULL) ? ? ? ? ? ? ? return -EINVAL; ? ? ? clk_enable(clk->parent); - ? ? spin_lock(&clocks_lock); + ? ? spin_lock_irqsave(&clocks_lock, flags); ? ? ? if ((clk->usage++) == 0) ? ? ? ? ? ? ? (clk->enable)(clk, 1); - ? ? spin_unlock(&clocks_lock); + ? ? spin_unlock_irqrestore(&clocks_lock, flags); ? ? ? return 0; ?} ?void clk_disable(struct clk *clk) ?{ + ? ? unsigned long flags; + ? ? ? if (IS_ERR(clk) || clk == NULL) ? ? ? ? ? ? ? return;arch/arm/plat-samsung/clock.c void clk_put(struct clk *clk) · line 170
Quoted 10 lines
arch/arm/plat-samsung/clock.c +2
-2- ? ? spin_lock(&clocks_lock); + ? ? spin_lock_irqsave(&clocks_lock, flags); ? ? ? if ((--clk->usage) == 0) ? ? ? ? ? ? ? (clk->enable)(clk, 0); - ? ? spin_unlock(&clocks_lock); + ? ? spin_unlock_irqrestore(&clocks_lock, flags); ? ? ? clk_disable(clk->parent);I'm not sure, but I don't belive that the
clk_api has ever been callable from non-sleepable contexts such as interrupt handlers.
Quoted 6 lines
I would welcome RMK's response (or any other response) about this issue?
Personally, given that some
clk_calls may sleep esp. for pll enables, I would prefer to see this patch dropped in favour of fixing the users.
I tend to agree.
I would like to know any such case where enabling/disabling of some clock is so urgent as to require doing from ISR and not from a tasklet scheduled from ISR.
Also let us not make it impossible in future to switch to common clock api by Jeremy Kerr, that doesn't allow calls from IRQ context.
PATCH 1/1 ARM: SAMSUNG: Bug fix spin_lock recursion in clk_enable() and clk_disable()
Quoted 67 lines · Jassi Brar
Quoted 59 lines · Ben Dooks
Quoted 43 lines · Jaecheol Lee
From: Minho Ban <[email protected]>
The
clk_enable()andclk_disable()can be used process and ISR either. Sospin_lock_irqsaveshould be used instead.Signed-off-by Minho Ban <[email protected]>Signed-off-by Jaecheol Lee <[email protected]>--- arch/arm/plat-samsung/clock.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)arch/arm/plat-samsung/clock.c +6
-2@@ -138,31 +138,35 @@ void clk_put(struct clk *clk)int clk_enable (struct clk *clk) { +unsigned long flags; +if (IS_ERR (clk) || clk ==NULL )return -EINVAL ;clk_enable (clk->parent); -spin_lock (&clocks_lock); +spin_lock_irqsave (&clocks_lock, flags);if ((clk->usage++) ==0 ) (clk->enable)(clk,1 ); -spin_unlock (&clocks_lock); +spin_unlock_irqrestore (&clocks_lock, flags);return 0 ; }void clk_disable (struct clk *clk) { +unsigned long flags; +if (IS_ERR (clk) || clk ==NULL )return ;arch/arm/plat-samsung/clock.c void clk_put(struct clk *clk) · line 170
Quoted 10 lines
arch/arm/plat-samsung/clock.c +2
-2-spin_lock (&clocks_lock); +spin_lock_irqsave (&clocks_lock, flags);if ((--clk->usage) ==0 ) (clk->enable)(clk,0 ); -spin_unlock (&clocks_lock); +spin_unlock_irqrestore (&clocks_lock, flags);clk_disable (clk->parent);I'm not sure, but I don't belive that the
clk_api has ever been callable from non-sleepable contexts such as interrupt handlers.Quoted 6 lines
I would welcome RMK's response (or any other response) about this issue?
Personally, given that some
clk_calls may sleep esp. for pll enables, I would prefer to see this patch dropped in favour of fixing the users.
Quoted 10 lines
I tend to agree.
I would like to know any such case where enabling/disabling of some clock is so urgent as to require doing from ISR and not from a tasklet scheduled from ISR.
Also let us not make it impossible in future to switch to common clock api by Jeremy Kerr, that doesn't allow calls from IRQ context.
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello,
Mostly you are right but it would require some explicit comment in clk.h (eg, clk_get/put) not to be confusing to the driver developer.
Thanks.
Regards,
Minho Ban
Signature · 4 lines
Minho Ban (mhban at samsung.com) Senior Engineer Platform R&D Team, Mobile Comm. SAMSUNG ELECTRONICS Co.Ltd.
PATCH 1/1 ARM: SAMSUNG: Bug fix spin_lock recursion in clk_enable() and clk_disable()
In reply to Ben DooksQuoted 6 lines · Ben Dooks
I'm not sure, but I don't belive that the
clk_api has ever been callable from non-sleepable contexts such as interrupt handlers.I would welcome RMK's response (or any other response) about this issue?
We have traditionally allowed it from non-sleepable contexts, mainly because the platforms I've been using it with have had such simple clock implementations that it's not worth artifically restricting it, or the implementation only requires a few us delay after enabling a clock.
PATCH 1/1 ARM: SAMSUNG: Bug fix spin_lock recursion in clk_enable() and clk_disable()
Quoted 5 lines · Russell King - ARM Linux
Quoted 4 lines · Ben Dooks
I'm not sure, but I don't belive that the
clk_api has ever been callable from non-sleepable contexts such as interrupt handlers.
Quoted 8 lines
Quoted 2 lines
I would welcome RMK's response (or any other response) about this issue?
We have traditionally allowed it from non-sleepable contexts, mainly because the platforms I've been using it with have had such simple clock implementations that it's not worth artifically restricting it, or the implementation only requires a few us delay after enabling a clock.
Some on chip PLLs can be 150-300uS to get running.
Signature · 1 line
Ben