device/arm: clear pending interrupts before enabling them

Without this change, a pending interrupt would spuriously trigger
immediately after enabling. This happens if an interrupt is triggered
during flashing (e.g. by DMA), which survives the subsequent reset.

This behaviour matches e.g. `machine.irqSet` in machine_rp2_rp2350.go.

See 7f970a45, whose symptoms were likely caused by spurious interrupts.
This commit is contained in:
Elias Naur
2025-04-11 21:40:56 +02:00
committed by Ron Evans
parent 0fdf08d14f
commit 0f06f59c6e
3 changed files with 10 additions and 2 deletions
@@ -9,6 +9,9 @@ import (
// Enable enables this interrupt. Right after calling this function, the
// interrupt may be invoked if it was already pending.
func (irq Interrupt) Enable() {
// Clear the ARM pending bit, an asserting device may still
// trigger the interrupt once enabled.
arm.ClearPendingIRQ(uint32(irq.num))
arm.EnableIRQ(uint32(irq.num))
}