Skip to content

feat: interrupt-driven xHCI keyboard — eliminate 20ms poll latency#241

Merged
ryanbreen merged 1 commit intomainfrom
feat/xhci-interrupt-latency
Mar 2, 2026
Merged

feat: interrupt-driven xHCI keyboard — eliminate 20ms poll latency#241
ryanbreen merged 1 commit intomainfrom
feat/xhci-interrupt-latency

Conversation

@ryanbreen
Copy link
Owner

Summary

  • Re-enable GIC SPI at end of handle_interrupt() after draining the event ring, so the next USB event gets a real MSI interrupt immediately instead of waiting for a timer poll
  • Remove the poll % 4 rate-limiting from poll_hid_events() — was throttling to 50 Hz (20ms), now runs every tick (200 Hz / 5ms) as pure housekeeping
  • One-shot SPI activation via SPI_ACTIVATED flag at 250ms post-init (down from 1 second)
  • Gate procfs xhci module behind cfg(target_arch = "aarch64") (fixes x86-64 build)
  • Graphics and page table performance experiments (WIP)

Test plan

  • ARM64 kernel builds with zero warnings
  • x86-64 kernel builds with zero warnings
  • Parallels VM boots cleanly, 148+ seconds stable with consistent heartbeats
  • No MSI interrupt storm observed

🤖 Generated with Claude Code

The xHCI MSI handler was disabling the GIC SPI after each interrupt and
relying on a rate-limited timer poll (50 Hz / 20ms) to re-enable it.
This meant every keystroke after the first waited up to 20ms+ for the
next poll tick, defeating the purpose of MSI interrupts entirely.

Now handle_interrupt() re-enables the SPI after draining the event ring,
so the next USB event gets a real interrupt immediately. The timer poll
remains as housekeeping (endpoint resets, deferred init) but no longer
gates keyboard responsiveness.

Changes:
- Re-enable GIC SPI at end of handle_interrupt() after event drain
- Remove poll % 4 rate-limiting from poll_hid_events() (every tick now)
- One-shot SPI activation via SPI_ACTIVATED flag (250ms after init)
- Reduce deferred doorbell re-ring from poll=300 to poll=75
- Gate procfs xhci module behind cfg(target_arch = "aarch64")
- Graphics and page table performance experiments (WIP)

Co-Authored-By: Ryan Breen <rbreen@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ryanbreen ryanbreen merged commit c619322 into main Mar 2, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant