feat(pci,virtio): read x86 legacy IRQ via PCI config space#18
feat(pci,virtio): read x86 legacy IRQ via PCI config space#18sunhaosheng wants to merge 2 commits intoarceos-org:mainfrom
Conversation
Add PciConfigAccess to axdriver_pci so drivers can read arbitrary PCI config registers, and use it in axdriver_virtio to fetch the legacy IRQ from the Interrupt Line register on x86. This avoids hardcoded IRQ derivation and matches the platform-assigned legacy INTx routing.
|
Merge to https://github.com/arceos-org/axdriver_crates/tree/dev first? Note that you can change the target branch without re-creating the PR. |
It seems I don't have permission to change the target branch. Could you help me make that change? |
I can't operate it either. I don't know why. Something might be wrong. |
| unsafe impl Send for PciConfigAccess {} | ||
| unsafe impl Sync for PciConfigAccess {} | ||
|
|
||
| impl PciConfigAccess { |
There was a problem hiding this comment.
Why not reuse Transport::read_config_space from the virtio-drivers crate?
There was a problem hiding this comment.
This change needs the PCI config-space Interrupt Line register (0x3C), not the VirtIO device-specific config space exposed by the transport. Transport::config_space is for VirtIO device config, while PciConfigAccess is for PCI header/config-space access during PCI probe.
|
This PR is moved to |
Related Issue
Starry-OS/StarryOS#129
On x86_64, a host-side TCP client could not complete a TCP echo exchange with a server running inside the system. The server never reported an accepted connection, the client blocked indefinitely, and the server could not be terminated with
Ctrl+C. See the issue for full reproduction steps.Description
This PR fixes x86 legacy IRQ discovery for VirtIO PCI devices.
Previously, the x86 path relied on derived or hardcoded IRQ assumptions, which do not reliably match the actual platform-assigned legacy INTx routing. On x86, the correct legacy IRQ should be taken from the PCI configuration space
Interrupt Lineregister instead.To support this, this PR adds a small PCI config-space accessor in
axdriver_pciand uses it inaxdriver_virtioto fetch the IRQ from PCI config space during device probing.Implementation
This PR includes two changes:
Add
PciConfigAccesstoaxdriver_pcivirtio-drivers.Update
axdriver_virtio::probe_pci_device()on x86PciConfigAccessreference.0x3C(Interrupt Line).0and0xff) on x86 instead of treating them as usable IRQs.Additional Context
This change is based on the same fix direction used in
x-kernelcommit, where x86 VirtIO probing was changed to use the PCIInterrupt Lineregister instead of hardcoded IRQ derivation.I kept this PR intentionally small so it can be reviewed independently from any follow-up work around MSI-X or higher-level interrupt handling.