public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] clocksource: timer-econet-en751221: fix IRQ ack storm on interrupt handler
@ 2026-04-13 10:12 kpursoty
  2026-04-13 14:52 ` Sergey Shtylyov
  0 siblings, 1 reply; 2+ messages in thread
From: kpursoty @ 2026-04-13 10:12 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org, daniel.lezcano@linaro.org,
	tglx@linutronix.de
  Cc: linux-mips@vger.kernel.org, tsbogend@alpha.franken.de,
	cjd@cjdns.fr

The interrupt handler acked by writing the current count back to compare:

  iowrite32(ioread32(reg_count(cpu)), reg_compare(cpu));

Since the interrupt fires when count >= compare, and the counter advances
past the written value before the MMIO write reaches the peripheral, the
condition re-asserts on the same bus cycle. This causes a tight IRQ storm
on CPU0, stalling boot at T=62s (measured: boot never progresses past
clockevents registration).

The EcoNet GPL kernel (arch/mips/econet/time2.c, cputmr_timer_ack()) acks
by writing the *next* deadline, which puts count < compare and clears the
pending condition. Write U32_MAX (unreachable before set_next_event()
programs the real deadline), consistent with cevt_dev_init() which also
writes U32_MAX to park the compare register at init.

Fixes: 3b4c33ac87d0 ("clocksource/drivers: Add EcoNet Timer HPT driver")
Signed-off-by: Kervin Pursoty <kpursoty@proton.me>
---
 drivers/clocksource/timer-econet-en751221.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/clocksource/timer-econet-en751221.c b/drivers/clocksource/timer-econet-en751221.c
--- a/drivers/clocksource/timer-econet-en751221.c
+++ b/drivers/clocksource/timer-econet-en751221.c
@@ -68,7 +68,9 @@ static irqreturn_t cevt_interrupt(int irq, void *dev_id)
 	if (!cevt_is_pending(cpu))
 		return IRQ_NONE;

-	iowrite32(ioread32(reg_count(cpu)), reg_compare(cpu));
+	/* Ack: write a future value so count < compare, clearing the pending
+	 * condition. set_next_event() will program the real deadline. */
+	iowrite32(U32_MAX, reg_compare(cpu));
 	dev->event_handler(dev);
 	return IRQ_HANDLED;
 }


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

* Re: [PATCH 2/2] clocksource: timer-econet-en751221: fix IRQ ack storm on interrupt handler
  2026-04-13 10:12 [PATCH 2/2] clocksource: timer-econet-en751221: fix IRQ ack storm on interrupt handler kpursoty
@ 2026-04-13 14:52 ` Sergey Shtylyov
  0 siblings, 0 replies; 2+ messages in thread
From: Sergey Shtylyov @ 2026-04-13 14:52 UTC (permalink / raw)
  To: kpursoty, linux-kernel@vger.kernel.org, daniel.lezcano@linaro.org,
	tglx@linutronix.de
  Cc: linux-mips@vger.kernel.org, tsbogend@alpha.franken.de,
	cjd@cjdns.fr

On 4/13/26 1:12 PM, kpursoty@proton.me wrote:

> The interrupt handler acked by writing the current count back to compare:
> 
>   iowrite32(ioread32(reg_count(cpu)), reg_compare(cpu));
> 
> Since the interrupt fires when count >= compare, and the counter advances
> past the written value before the MMIO write reaches the peripheral, the
> condition re-asserts on the same bus cycle. This causes a tight IRQ storm
> on CPU0, stalling boot at T=62s (measured: boot never progresses past
> clockevents registration).
> 
> The EcoNet GPL kernel (arch/mips/econet/time2.c, cputmr_timer_ack()) acks
> by writing the *next* deadline, which puts count < compare and clears the
> pending condition. Write U32_MAX (unreachable before set_next_event()
> programs the real deadline), consistent with cevt_dev_init() which also
> writes U32_MAX to park the compare register at init.
> 
> Fixes: 3b4c33ac87d0 ("clocksource/drivers: Add EcoNet Timer HPT driver")
> Signed-off-by: Kervin Pursoty <kpursoty@proton.me>
> ---
>  drivers/clocksource/timer-econet-en751221.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/clocksource/timer-econet-en751221.c b/drivers/clocksource/timer-econet-en751221.c
> --- a/drivers/clocksource/timer-econet-en751221.c
> +++ b/drivers/clocksource/timer-econet-en751221.c
> @@ -68,7 +68,9 @@ static irqreturn_t cevt_interrupt(int irq, void *dev_id)
>  	if (!cevt_is_pending(cpu))
>  		return IRQ_NONE;
> 
> -	iowrite32(ioread32(reg_count(cpu)), reg_compare(cpu));
> +	/* Ack: write a future value so count < compare, clearing the pending
> +	 * condition. set_next_event() will program the real deadline. */

   The multiline comments in the kernel (with a little exception of the networking)
should be formatter like this:

	/*
	 * blah blah blah
	 */

[...]

MBR, Sergey


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

end of thread, other threads:[~2026-04-13 14:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-13 10:12 [PATCH 2/2] clocksource: timer-econet-en751221: fix IRQ ack storm on interrupt handler kpursoty
2026-04-13 14:52 ` Sergey Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox