linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clockevents/drivers/timer-atmel-pit: fix double free_irq
@ 2016-03-17 20:09 Alexandre Belloni
  2016-03-18  8:20 ` Nicolas Ferre
  2016-03-29 13:32 ` Sebastian Andrzej Siewior
  0 siblings, 2 replies; 5+ messages in thread
From: Alexandre Belloni @ 2016-03-17 20:09 UTC (permalink / raw)
  To: linux-arm-kernel

clockevents_exchange_device() changes the state from detached to shutdown
and so at that point the IRQ has not yet been requested.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---

Hi Sebastian,

This patch fixes the last warning for preempt-rt on at91. It applies on
v4.4.4-rt11. Note that the whome PIT/TCB mess will be fixed in another way in
the mainline as we are reworking the tcb driver to avoid using the pit when
booting.

 drivers/clocksource/timer-atmel-pit.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index a7abdb6638cd..7a40f7e88468 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -46,6 +46,7 @@ struct pit_data {
 	u32		cycle;
 	u32		cnt;
 	unsigned int	irq;
+	bool		irq_requested;
 	struct clk	*mck;
 };
 
@@ -96,7 +97,10 @@ static int pit_clkevt_shutdown(struct clock_event_device *dev)
 
 	/* disable irq, leaving the clocksource active */
 	pit_write(data->base, AT91_PIT_MR, (data->cycle - 1) | AT91_PIT_PITEN);
-	free_irq(data->irq, data);
+	if (data->irq_requested) {
+		free_irq(data->irq, data);
+		data->irq_requested = false;
+	}
 	return 0;
 }
 
@@ -115,6 +119,8 @@ static int pit_clkevt_set_periodic(struct clock_event_device *dev)
 	if (ret)
 		panic(pr_fmt("Unable to setup IRQ\n"));
 
+	data->irq_requested = true;
+
 	/* update clocksource counter */
 	data->cnt += data->cycle * PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR));
 	pit_write(data->base, AT91_PIT_MR,
-- 
2.7.0

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

* [PATCH] clockevents/drivers/timer-atmel-pit: fix double free_irq
  2016-03-17 20:09 [PATCH] clockevents/drivers/timer-atmel-pit: fix double free_irq Alexandre Belloni
@ 2016-03-18  8:20 ` Nicolas Ferre
  2016-03-29 13:32 ` Sebastian Andrzej Siewior
  1 sibling, 0 replies; 5+ messages in thread
From: Nicolas Ferre @ 2016-03-18  8:20 UTC (permalink / raw)
  To: linux-arm-kernel

Le 17/03/2016 21:09, Alexandre Belloni a ?crit :
> clockevents_exchange_device() changes the state from detached to shutdown
> and so at that point the IRQ has not yet been requested.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
> 
> Hi Sebastian,
> 
> This patch fixes the last warning for preempt-rt on at91. It applies on
> v4.4.4-rt11. Note that the whome PIT/TCB mess will be fixed in another way in
> the mainline as we are reworking the tcb driver to avoid using the pit when
> booting.

Yes, it's the plan!

Thanks Alexandre. Bye.

> 
>  drivers/clocksource/timer-atmel-pit.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
> index a7abdb6638cd..7a40f7e88468 100644
> --- a/drivers/clocksource/timer-atmel-pit.c
> +++ b/drivers/clocksource/timer-atmel-pit.c
> @@ -46,6 +46,7 @@ struct pit_data {
>  	u32		cycle;
>  	u32		cnt;
>  	unsigned int	irq;
> +	bool		irq_requested;
>  	struct clk	*mck;
>  };
>  
> @@ -96,7 +97,10 @@ static int pit_clkevt_shutdown(struct clock_event_device *dev)
>  
>  	/* disable irq, leaving the clocksource active */
>  	pit_write(data->base, AT91_PIT_MR, (data->cycle - 1) | AT91_PIT_PITEN);
> -	free_irq(data->irq, data);
> +	if (data->irq_requested) {
> +		free_irq(data->irq, data);
> +		data->irq_requested = false;
> +	}
>  	return 0;
>  }
>  
> @@ -115,6 +119,8 @@ static int pit_clkevt_set_periodic(struct clock_event_device *dev)
>  	if (ret)
>  		panic(pr_fmt("Unable to setup IRQ\n"));
>  
> +	data->irq_requested = true;
> +
>  	/* update clocksource counter */
>  	data->cnt += data->cycle * PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR));
>  	pit_write(data->base, AT91_PIT_MR,
> 


-- 
Nicolas Ferre

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

* [PATCH] clockevents/drivers/timer-atmel-pit: fix double free_irq
  2016-03-17 20:09 [PATCH] clockevents/drivers/timer-atmel-pit: fix double free_irq Alexandre Belloni
  2016-03-18  8:20 ` Nicolas Ferre
@ 2016-03-29 13:32 ` Sebastian Andrzej Siewior
  2016-03-29 13:34   ` Nicolas Ferre
  2016-03-29 13:52   ` Alexandre Belloni
  1 sibling, 2 replies; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-03-29 13:32 UTC (permalink / raw)
  To: linux-arm-kernel

* Alexandre Belloni | 2016-03-17 21:09:43 [+0100]:

>Hi Sebastian,
Hi Alexandre,

>This patch fixes the last warning for preempt-rt on at91. It applies on
>v4.4.4-rt11. Note that the whome PIT/TCB mess will be fixed in another way in
>the mainline as we are reworking the tcb driver to avoid using the pit when
>booting.

oh, okay. I just sent the "arm: at91: do not disable/enable clocks in a
row" patch as you asked me a while ago. It applied cleanly against the
next tree of today.
So I will apply this to get rid of the warning. And if you manage not to
use the PIT during boot then we won't have the free_irq() mess which is
good.

Sebastian

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

* [PATCH] clockevents/drivers/timer-atmel-pit: fix double free_irq
  2016-03-29 13:32 ` Sebastian Andrzej Siewior
@ 2016-03-29 13:34   ` Nicolas Ferre
  2016-03-29 13:52   ` Alexandre Belloni
  1 sibling, 0 replies; 5+ messages in thread
From: Nicolas Ferre @ 2016-03-29 13:34 UTC (permalink / raw)
  To: linux-arm-kernel

Le 29/03/2016 15:32, Sebastian Andrzej Siewior a ?crit :
> * Alexandre Belloni | 2016-03-17 21:09:43 [+0100]:
> 
>> Hi Sebastian,
> Hi Alexandre,
> 
>> This patch fixes the last warning for preempt-rt on at91. It applies on
>> v4.4.4-rt11. Note that the whome PIT/TCB mess will be fixed in another way in
>> the mainline as we are reworking the tcb driver to avoid using the pit when
>> booting.
> 
> oh, okay. I just sent the "arm: at91: do not disable/enable clocks in a
> row" patch as you asked me a while ago. It applied cleanly against the
> next tree of today.

Sure, we can still take it now. We will certainly embed it in a future
TC rework.

Thanks.


> So I will apply this to get rid of the warning. And if you manage not to
> use the PIT during boot then we won't have the free_irq() mess which is
> good.
> 
> Sebastian
> 


-- 
Nicolas Ferre

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

* [PATCH] clockevents/drivers/timer-atmel-pit: fix double free_irq
  2016-03-29 13:32 ` Sebastian Andrzej Siewior
  2016-03-29 13:34   ` Nicolas Ferre
@ 2016-03-29 13:52   ` Alexandre Belloni
  1 sibling, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2016-03-29 13:52 UTC (permalink / raw)
  To: linux-arm-kernel

On 29/03/2016 at 15:32:06 +0200, Sebastian Andrzej Siewior wrote :
> * Alexandre Belloni | 2016-03-17 21:09:43 [+0100]:
> 
> >Hi Sebastian,
> Hi Alexandre,
> 
> >This patch fixes the last warning for preempt-rt on at91. It applies on
> >v4.4.4-rt11. Note that the whome PIT/TCB mess will be fixed in another way in
> >the mainline as we are reworking the tcb driver to avoid using the pit when
> >booting.
> 
> oh, okay. I just sent the "arm: at91: do not disable/enable clocks in a
> row" patch as you asked me a while ago. It applied cleanly against the
> next tree of today.

Yeah, actually, it was not needed anymore. I forgot about it at the time
but f02b4b72d12c (clockevents/tcb_clksrc: Prevent disabling an already
disabled clock) was sufficient to remove the warning. Your patch is
still Ok but maybe it can get rid of the
"if (!clockevent_state_detached(d))" in tc_shutdown_clk_off()

I'll test and take care of that.

> So I will apply this to get rid of the warning. And if you manage not to
> use the PIT during boot then we won't have the free_irq() mess which is
> good.
> 

Yeah, this will definitively happen (hopefully sooner than later ;) )

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

end of thread, other threads:[~2016-03-29 13:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-17 20:09 [PATCH] clockevents/drivers/timer-atmel-pit: fix double free_irq Alexandre Belloni
2016-03-18  8:20 ` Nicolas Ferre
2016-03-29 13:32 ` Sebastian Andrzej Siewior
2016-03-29 13:34   ` Nicolas Ferre
2016-03-29 13:52   ` Alexandre Belloni

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