Commit 501d7038 authored by Uwe Kleine-König's avatar Uwe Kleine-König

arm/at91: Don't disable irqs in set_next_event and set_mode callbacks

on AT91 the timer irq is shared, so the handler might be entered without
irqs being disabled.  Though this should not happen as the timer irq is
registered early, there have been some reports on the mailing list.

To make debugging that problem easier next time it pops up a
WARN_ON_ONCE is added to the handler if irqs are not off.
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent 066000dd
...@@ -58,6 +58,12 @@ static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id) ...@@ -58,6 +58,12 @@ static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)
{ {
u32 sr = at91_sys_read(AT91_ST_SR) & irqmask; u32 sr = at91_sys_read(AT91_ST_SR) & irqmask;
/*
* irqs should be disabled here, but as the irq is shared they are only
* guaranteed to be off if the timer irq is registered first.
*/
WARN_ON_ONCE(!irqs_disabled());
/* simulate "oneshot" timer with alarm */ /* simulate "oneshot" timer with alarm */
if (sr & AT91_ST_ALMS) { if (sr & AT91_ST_ALMS) {
clkevt.event_handler(&clkevt); clkevt.event_handler(&clkevt);
...@@ -132,24 +138,11 @@ clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev) ...@@ -132,24 +138,11 @@ clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev)
static int static int
clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev) clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)
{ {
unsigned long flags;
u32 alm; u32 alm;
int status = 0; int status = 0;
BUG_ON(delta < 2); BUG_ON(delta < 2);
/* Use "raw" primitives so we behave correctly on RT kernels. */
raw_local_irq_save(flags);
/*
* According to Thomas Gleixner irqs are already disabled here. Simply
* removing raw_local_irq_save above (and the matching
* raw_local_irq_restore) was not accepted. See
* http://thread.gmane.org/gmane.linux.ports.arm.kernel/41174
* So for now (2008-11-20) just warn once if irqs were not disabled ...
*/
WARN_ON_ONCE(!raw_irqs_disabled_flags(flags));
/* The alarm IRQ uses absolute time (now+delta), not the relative /* The alarm IRQ uses absolute time (now+delta), not the relative
* time (delta) in our calling convention. Like all clockevents * time (delta) in our calling convention. Like all clockevents
* using such "match" hardware, we have a race to defend against. * using such "match" hardware, we have a race to defend against.
...@@ -169,7 +162,6 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev) ...@@ -169,7 +162,6 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)
alm += delta; alm += delta;
at91_sys_write(AT91_ST_RTAR, alm); at91_sys_write(AT91_ST_RTAR, alm);
raw_local_irq_restore(flags);
return status; return status;
} }
......
...@@ -62,16 +62,12 @@ static struct clocksource pit_clk = { ...@@ -62,16 +62,12 @@ static struct clocksource pit_clk = {
static void static void
pit_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev) pit_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev)
{ {
unsigned long flags;
switch (mode) { switch (mode) {
case CLOCK_EVT_MODE_PERIODIC: case CLOCK_EVT_MODE_PERIODIC:
/* update clocksource counter, then enable the IRQ */ /* update clocksource counter */
raw_local_irq_save(flags);
pit_cnt += pit_cycle * PIT_PICNT(at91_sys_read(AT91_PIT_PIVR)); pit_cnt += pit_cycle * PIT_PICNT(at91_sys_read(AT91_PIT_PIVR));
at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN
| AT91_PIT_PITIEN); | AT91_PIT_PITIEN);
raw_local_irq_restore(flags);
break; break;
case CLOCK_EVT_MODE_ONESHOT: case CLOCK_EVT_MODE_ONESHOT:
BUG(); BUG();
...@@ -100,6 +96,11 @@ static struct clock_event_device pit_clkevt = { ...@@ -100,6 +96,11 @@ static struct clock_event_device pit_clkevt = {
*/ */
static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id) static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
{ {
/*
* irqs should be disabled here, but as the irq is shared they are only
* guaranteed to be off if the timer irq is registered first.
*/
WARN_ON_ONCE(!irqs_disabled());
/* The PIT interrupt may be disabled, and is shared */ /* The PIT interrupt may be disabled, and is shared */
if ((pit_clkevt.mode == CLOCK_EVT_MODE_PERIODIC) if ((pit_clkevt.mode == CLOCK_EVT_MODE_PERIODIC)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment