Kernel: Cleanup and fix xHCI interrupt handling

Always clear EventHandlerBusy bit and remove unnecessary nesting
This commit is contained in:
Bananymous 2024-11-22 22:19:53 +02:00
parent c1d8790623
commit 480368c878
1 changed files with 75 additions and 78 deletions

View File

@ -463,16 +463,14 @@ namespace Kernel
void XHCIController::handle_irq() void XHCIController::handle_irq()
{ {
auto& primary_interrupter = runtime_regs().irs[0];
primary_interrupter.iman = primary_interrupter.iman | XHCI::IMAN::InterruptPending | XHCI::IMAN::InterruptEnable;
auto& operational = operational_regs(); auto& operational = operational_regs();
if (!(operational.usbsts & XHCI::USBSTS::EventInterrupt)) if (!(operational.usbsts & XHCI::USBSTS::EventInterrupt))
return; return;
operational.usbsts = XHCI::USBSTS::EventInterrupt; operational.usbsts = XHCI::USBSTS::EventInterrupt;
auto& primary_interrupter = runtime_regs().irs[0];
primary_interrupter.iman = primary_interrupter.iman | XHCI::IMAN::InterruptPending | XHCI::IMAN::InterruptEnable;
if (current_event_trb().cycle == m_event_cycle)
{
for (;;) for (;;)
{ {
auto& trb = current_event_trb(); auto& trb = current_event_trb();
@ -555,7 +553,6 @@ namespace Kernel
primary_interrupter.erdp = (m_event_ring_region->paddr() + (m_event_dequeue * sizeof(XHCI::TRB))) | XHCI::ERDP::EventHandlerBusy; primary_interrupter.erdp = (m_event_ring_region->paddr() + (m_event_dequeue * sizeof(XHCI::TRB))) | XHCI::ERDP::EventHandlerBusy;
} }
}
volatile XHCI::CapabilityRegs& XHCIController::capability_regs() volatile XHCI::CapabilityRegs& XHCIController::capability_regs()
{ {