From a01d3ce6e5248ee612d73ae7dffb0627a51fa410 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Mon, 13 Jul 2026 20:23:20 +0200 Subject: [PATCH] Fix a race condition when receiving events before unmasking interrupts --- drivers/usb/xhcid/src/xhci/irq_reactor.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/xhcid/src/xhci/irq_reactor.rs b/drivers/usb/xhcid/src/xhci/irq_reactor.rs index efe8f74610..1b27479527 100644 --- a/drivers/usb/xhcid/src/xhci/irq_reactor.rs +++ b/drivers/usb/xhcid/src/xhci/irq_reactor.rs @@ -240,9 +240,20 @@ impl IrqReactor { warn!("xhci: Received interrupt, but no event was found in the event ring. Ignoring interrupt.") } self.unmask_interrupts(); + + // Process any events received between the NoEvent and unmasking interrupts + loop { + match self.process_one_event(&mut event_ring, &mut event_trb_index) { + EventProcessResult::NoEvent => break, + EventProcessResult::EventRingFull + | EventProcessResult::RegularEvent => {} + } + } + continue 'trb_loop; } EventProcessResult::EventRingFull => { + // FIXME can this use the RegularEvent path? if self.hci.interrupt_is_pending(0) { warn!("After incrementing the dequeue pointer, the interrupt bit is still pending.") } else {