Re: [PATCH 2/8] staging: omap-thermal: use spin_lock_irqsave inside IRQ handler

2013-03-18 Thread Dan Carpenter
On Mon, Mar 18, 2013 at 03:38:38PM -0400, Eduardo Valentin wrote:
> On 18-03-2013 15:16, Dan Carpenter wrote:
> >On Mon, Mar 18, 2013 at 10:59:10AM -0400, Eduardo Valentin wrote:
> >>Even if the IRQ is not firing because it is ONE_SHOT and disable
> >>at INTC level, the IRQ handler must use spin_lock_irqsave.
> >>It is necessary to disable IRQs from the current
> >>CPU while it is holding a spin_lock which is need.
> >>
> >
> >Gar...  I think I was just totally wrong on this.  I think your
> >original code was fine.  Sorry Eduardo and Greg.
> >
> >This is a threaded IRQ so the regular spin_lock is fine or even the
> >mutex would have been.
> 
> In fact it is. But I rather prefer to use spinlocks there, just to
> keep the irq handler sane, even if it is moved to non-threaded IRQ.

Yep.  I'd agree there.

> 
> >
> >IRQ_ONESHOT is about triggering a second IRQ before the first one
> >has been finished, btw.
> 
> It is, and that gets done by masking the IRQ at INTC level.
> 
> >
> >I am an idiot.
> 
> 
> Not really. Thanks for your time reviewing the driver.
> 
>  I will resend this series. Drop this one and split patch 4/8 into
> two I think (one for moving files, one for renaming functions)

Great.  Much appreciated.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/8] staging: omap-thermal: use spin_lock_irqsave inside IRQ handler

2013-03-18 Thread Eduardo Valentin

On 18-03-2013 15:16, Dan Carpenter wrote:

On Mon, Mar 18, 2013 at 10:59:10AM -0400, Eduardo Valentin wrote:

Even if the IRQ is not firing because it is ONE_SHOT and disable
at INTC level, the IRQ handler must use spin_lock_irqsave.
It is necessary to disable IRQs from the current
CPU while it is holding a spin_lock which is need.



Gar...  I think I was just totally wrong on this.  I think your
original code was fine.  Sorry Eduardo and Greg.

This is a threaded IRQ so the regular spin_lock is fine or even the
mutex would have been.


In fact it is. But I rather prefer to use spinlocks there, just to keep 
the irq handler sane, even if it is moved to non-threaded IRQ.




IRQ_ONESHOT is about triggering a second IRQ before the first one
has been finished, btw.


It is, and that gets done by masking the IRQ at INTC level.



I am an idiot.



Not really. Thanks for your time reviewing the driver.

 I will resend this series. Drop this one and split patch 4/8 into two 
I think (one for moving files, one for renaming functions)




regards,
dan carpenter





--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/8] staging: omap-thermal: use spin_lock_irqsave inside IRQ handler

2013-03-18 Thread Dan Carpenter
On Mon, Mar 18, 2013 at 10:59:10AM -0400, Eduardo Valentin wrote:
> Even if the IRQ is not firing because it is ONE_SHOT and disable
> at INTC level, the IRQ handler must use spin_lock_irqsave.
> It is necessary to disable IRQs from the current
> CPU while it is holding a spin_lock which is need.
> 

Gar...  I think I was just totally wrong on this.  I think your
original code was fine.  Sorry Eduardo and Greg.

This is a threaded IRQ so the regular spin_lock is fine or even the
mutex would have been.

IRQ_ONESHOT is about triggering a second IRQ before the first one
has been finished, btw.

I am an idiot.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/8] staging: omap-thermal: use spin_lock_irqsave inside IRQ handler

2013-03-18 Thread Eduardo Valentin
Even if the IRQ is not firing because it is ONE_SHOT and disable
at INTC level, the IRQ handler must use spin_lock_irqsave.
It is necessary to disable IRQs from the current
CPU while it is holding a spin_lock which is need.

Cc: Dan Carpenter 

Signed-off-by: Eduardo Valentin 

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c 
b/drivers/staging/omap-thermal/omap-bandgap.c
index cb7aa35..a4ac06c 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -168,9 +168,10 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int 
irq, void *data)
struct omap_bandgap *bg_ptr = data;
struct temp_sensor_registers *tsr;
u32 t_hot = 0, t_cold = 0, ctrl;
+   unsigned long flags;
int i;
 
-   spin_lock(_ptr->lock);
+   spin_lock_irqsave(_ptr->lock, flags);
for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
tsr = bg_ptr->conf->sensors[i].registers;
ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_status);
@@ -209,7 +210,7 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, 
void *data)
if (bg_ptr->conf->report_temperature)
bg_ptr->conf->report_temperature(bg_ptr, i);
}
-   spin_unlock(_ptr->lock);
+   spin_unlock_irqrestore(_ptr->lock, flags);
 
return IRQ_HANDLED;
 }
-- 
1.7.7.1.488.ge8e1c

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/8] staging: omap-thermal: use spin_lock_irqsave inside IRQ handler

2013-03-18 Thread Eduardo Valentin
Even if the IRQ is not firing because it is ONE_SHOT and disable
at INTC level, the IRQ handler must use spin_lock_irqsave.
It is necessary to disable IRQs from the current
CPU while it is holding a spin_lock which is need.

Cc: Dan Carpenter dan.carpen...@oracle.com

Signed-off-by: Eduardo Valentin eduardo.valen...@ti.com

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c 
b/drivers/staging/omap-thermal/omap-bandgap.c
index cb7aa35..a4ac06c 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -168,9 +168,10 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int 
irq, void *data)
struct omap_bandgap *bg_ptr = data;
struct temp_sensor_registers *tsr;
u32 t_hot = 0, t_cold = 0, ctrl;
+   unsigned long flags;
int i;
 
-   spin_lock(bg_ptr-lock);
+   spin_lock_irqsave(bg_ptr-lock, flags);
for (i = 0; i  bg_ptr-conf-sensor_count; i++) {
tsr = bg_ptr-conf-sensors[i].registers;
ctrl = omap_bandgap_readl(bg_ptr, tsr-bgap_status);
@@ -209,7 +210,7 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, 
void *data)
if (bg_ptr-conf-report_temperature)
bg_ptr-conf-report_temperature(bg_ptr, i);
}
-   spin_unlock(bg_ptr-lock);
+   spin_unlock_irqrestore(bg_ptr-lock, flags);
 
return IRQ_HANDLED;
 }
-- 
1.7.7.1.488.ge8e1c

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/8] staging: omap-thermal: use spin_lock_irqsave inside IRQ handler

2013-03-18 Thread Dan Carpenter
On Mon, Mar 18, 2013 at 10:59:10AM -0400, Eduardo Valentin wrote:
 Even if the IRQ is not firing because it is ONE_SHOT and disable
 at INTC level, the IRQ handler must use spin_lock_irqsave.
 It is necessary to disable IRQs from the current
 CPU while it is holding a spin_lock which is need.
 

Gar...  I think I was just totally wrong on this.  I think your
original code was fine.  Sorry Eduardo and Greg.

This is a threaded IRQ so the regular spin_lock is fine or even the
mutex would have been.

IRQ_ONESHOT is about triggering a second IRQ before the first one
has been finished, btw.

I am an idiot.

regards,
dan carpenter

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/8] staging: omap-thermal: use spin_lock_irqsave inside IRQ handler

2013-03-18 Thread Eduardo Valentin

On 18-03-2013 15:16, Dan Carpenter wrote:

On Mon, Mar 18, 2013 at 10:59:10AM -0400, Eduardo Valentin wrote:

Even if the IRQ is not firing because it is ONE_SHOT and disable
at INTC level, the IRQ handler must use spin_lock_irqsave.
It is necessary to disable IRQs from the current
CPU while it is holding a spin_lock which is need.



Gar...  I think I was just totally wrong on this.  I think your
original code was fine.  Sorry Eduardo and Greg.

This is a threaded IRQ so the regular spin_lock is fine or even the
mutex would have been.


In fact it is. But I rather prefer to use spinlocks there, just to keep 
the irq handler sane, even if it is moved to non-threaded IRQ.




IRQ_ONESHOT is about triggering a second IRQ before the first one
has been finished, btw.


It is, and that gets done by masking the IRQ at INTC level.



I am an idiot.



Not really. Thanks for your time reviewing the driver.

 I will resend this series. Drop this one and split patch 4/8 into two 
I think (one for moving files, one for renaming functions)




regards,
dan carpenter





--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/8] staging: omap-thermal: use spin_lock_irqsave inside IRQ handler

2013-03-18 Thread Dan Carpenter
On Mon, Mar 18, 2013 at 03:38:38PM -0400, Eduardo Valentin wrote:
 On 18-03-2013 15:16, Dan Carpenter wrote:
 On Mon, Mar 18, 2013 at 10:59:10AM -0400, Eduardo Valentin wrote:
 Even if the IRQ is not firing because it is ONE_SHOT and disable
 at INTC level, the IRQ handler must use spin_lock_irqsave.
 It is necessary to disable IRQs from the current
 CPU while it is holding a spin_lock which is need.
 
 
 Gar...  I think I was just totally wrong on this.  I think your
 original code was fine.  Sorry Eduardo and Greg.
 
 This is a threaded IRQ so the regular spin_lock is fine or even the
 mutex would have been.
 
 In fact it is. But I rather prefer to use spinlocks there, just to
 keep the irq handler sane, even if it is moved to non-threaded IRQ.

Yep.  I'd agree there.

 
 
 IRQ_ONESHOT is about triggering a second IRQ before the first one
 has been finished, btw.
 
 It is, and that gets done by masking the IRQ at INTC level.
 
 
 I am an idiot.
 
 
 Not really. Thanks for your time reviewing the driver.
 
  I will resend this series. Drop this one and split patch 4/8 into
 two I think (one for moving files, one for renaming functions)

Great.  Much appreciated.

regards,
dan carpenter

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/