Skip to content

Commit

Permalink
drivers: irqchip: irq-bcm2835: Concurrency fix
Browse files Browse the repository at this point in the history
The commit shown in Fixes: aims to improve interrupt throughput by
getting the handlers invoked on different CPU cores. It does so (*) by
using an irq_ack hook to change the interrupt routing.

Unfortunately, the IRQ status bits must be cleared at source, which only
happens once the interrupt handler has run - there is no easy way for
one core to claim one of the IRQs before sending the remainder to the
next core on the list, so waking another core immediately results in a
race with a chance of both cores handling the same IRQ. It is probably
for this reason that the routing change is deferred to irq_ack, but that
doesn't guarantee no clashes - after irq_ack is called, control returns
to bcm2836_chained_handler_irq which proceeds to check for other pending
IRQs at a time when the next core is probably doing the same thing.

Since the whole point of the original commit is to distribute the IRQ
handling, there is no reason to attempt to handle multiple IRQs in one
interrupt callback, so the problem can be solved (or at least made much
harder to reproduce) by changing a "while" into an "if", so that each
invocation only handles one IRQ.

(*) I'm not convinced it's as effective as claimed since irq_ack is
called _after_ the interrupt handler, but the author thought it made a
difference.

See: #5214
     #1794

Fixes: fd4c978 ("ARM64: Round-Robin dispatch IRQs between CPUs.")
Signed-off-by: Phil Elwell <[email protected]>
  • Loading branch information
pelwell committed Aug 31, 2023
1 parent 9d9586d commit a5920b8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/irqchip/irq-bcm2835.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ static void bcm2836_chained_handle_irq(struct irq_desc *desc)
{
u32 hwirq;

while ((hwirq = get_next_armctrl_hwirq()) != ~0)
if ((hwirq = get_next_armctrl_hwirq()) != ~0)

Check failure on line 346 in drivers/irqchip/irq-bcm2835.c

View workflow job for this annotation

GitHub Actions / checkpatch review

ERROR: do not use assignment in if condition
generic_handle_domain_irq(intc.domain, hwirq);
}

Expand Down

0 comments on commit a5920b8

Please sign in to comment.