linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mfd: ti_am335x_tscadc: avoid possible deadlock of reg_lock
@ 2013-10-22 14:12 Sebastian Andrzej Siewior
  2013-10-22 17:13 ` Lee Jones
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2013-10-22 14:12 UTC (permalink / raw)
  To: Lee Jones
  Cc: Samuel Ortiz, linux-kernel, Zubair Lutfullah, Felipe Balbi,
	kishon, Sebastian Andrzej Siewior

Since the addition of continuous sampling mode and shared irq support,
the reg_lock lock can be taken with and without interrupts. This patch
uses the *_irq* variant which should be used in order to avaoid a deadlock.

Cc: Zubair Lutfullah <zubair.lutfullah@gmail.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/mfd/ti_am335x_tscadc.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index baaf5a8..912a41f 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -56,21 +56,25 @@ EXPORT_SYMBOL_GPL(am335x_tsc_se_update);
 
 void am335x_tsc_se_set(struct ti_tscadc_dev *tsadc, u32 val)
 {
-	spin_lock(&tsadc->reg_lock);
+	unsigned long flags;
+
+	spin_lock_irqsave(&tsadc->reg_lock, flags);
 	tsadc->reg_se_cache = tscadc_readl(tsadc, REG_SE);
 	tsadc->reg_se_cache |= val;
 	am335x_tsc_se_update(tsadc);
-	spin_unlock(&tsadc->reg_lock);
+	spin_unlock_irqrestore(&tsadc->reg_lock, flags);
 }
 EXPORT_SYMBOL_GPL(am335x_tsc_se_set);
 
 void am335x_tsc_se_clr(struct ti_tscadc_dev *tsadc, u32 val)
 {
-	spin_lock(&tsadc->reg_lock);
+	unsigned long flags;
+
+	spin_lock_irqsave(&tsadc->reg_lock, flags);
 	tsadc->reg_se_cache = tscadc_readl(tsadc, REG_SE);
 	tsadc->reg_se_cache &= ~val;
 	am335x_tsc_se_update(tsadc);
-	spin_unlock(&tsadc->reg_lock);
+	spin_unlock_irqrestore(&tsadc->reg_lock, flags);
 }
 EXPORT_SYMBOL_GPL(am335x_tsc_se_clr);
 
-- 
1.8.4.rc3


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

* Re: [PATCH] mfd: ti_am335x_tscadc: avoid possible deadlock of reg_lock
  2013-10-22 14:12 [PATCH] mfd: ti_am335x_tscadc: avoid possible deadlock of reg_lock Sebastian Andrzej Siewior
@ 2013-10-22 17:13 ` Lee Jones
  2013-10-25 15:29   ` Zubair Lutfullah :
  0 siblings, 1 reply; 3+ messages in thread
From: Lee Jones @ 2013-10-22 17:13 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Samuel Ortiz, linux-kernel, Zubair Lutfullah, Felipe Balbi,
	kishon

On Tue, 22 Oct 2013, Sebastian Andrzej Siewior wrote:

> Since the addition of continuous sampling mode and shared irq support,
> the reg_lock lock can be taken with and without interrupts. This patch
> uses the *_irq* variant which should be used in order to avaoid a deadlock.
> 
> Cc: Zubair Lutfullah <zubair.lutfullah@gmail.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  drivers/mfd/ti_am335x_tscadc.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)

Good catch. Applied, thanks.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH] mfd: ti_am335x_tscadc: avoid possible deadlock of reg_lock
  2013-10-22 17:13 ` Lee Jones
@ 2013-10-25 15:29   ` Zubair Lutfullah :
  0 siblings, 0 replies; 3+ messages in thread
From: Zubair Lutfullah : @ 2013-10-25 15:29 UTC (permalink / raw)
  To: Lee Jones
  Cc: Sebastian Andrzej Siewior, Samuel Ortiz, linux-kernel,
	Zubair Lutfullah, Felipe Balbi, kishon

On Tue, Oct 22, 2013 at 06:13:59PM +0100, Lee Jones wrote:
> On Tue, 22 Oct 2013, Sebastian Andrzej Siewior wrote:
> 
> > Since the addition of continuous sampling mode and shared irq support,
> > the reg_lock lock can be taken with and without interrupts. This patch
> > uses the *_irq* variant which should be used in order to avaoid a deadlock.
> > 
> > Cc: Zubair Lutfullah <zubair.lutfullah@gmail.com>
> > Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> > ---
> >  drivers/mfd/ti_am335x_tscadc.c | 12 ++++++++----
> >  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> Good catch. Applied, thanks.

Had noticed this and forgot. My bad..

Thanks for catching it.

Zubair

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

end of thread, other threads:[~2013-10-25 15:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-22 14:12 [PATCH] mfd: ti_am335x_tscadc: avoid possible deadlock of reg_lock Sebastian Andrzej Siewior
2013-10-22 17:13 ` Lee Jones
2013-10-25 15:29   ` Zubair Lutfullah :

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