--- a/drivers/pcid/src/main.rs +++ b/drivers/pcid/src/main.rs @@ -162,20 +162,32 @@ | CommandRegister::IO_ENABLE }); - // Disable MSI and MSI-X in case a previous driver instance enabled them. - for capability in capabilities { + // Detect MSI capabilities for logging + let has_msix = capabilities.iter().any(|c| matches!(c, PciCapability::MsiX(_))); + let has_msi = capabilities.iter().any(|c| matches!(c, PciCapability::Msi(_))); + + // Disable MSI and MSI-X to start from a clean state. + // Drivers that support MSI will re-enable it via the pcid scheme interface + // using irq_helpers::pci_allocate_interrupt_vector(), which handles + // MSI-X -> MSI -> legacy fallback automatically. + for capability in capabilities.iter_mut() { match capability { - PciCapability::Msi(capability) => { - capability.set_enabled(false, pcie); - } - PciCapability::MsiX(capability) => { - capability.set_enabled(false, pcie); - } + PciCapability::Msi(cap) => cap.set_enabled(false, pcie), + PciCapability::MsiX(cap) => cap.set_enabled(false, pcie), _ => {} } } - // Set IRQ line to 9 if not set + // Log MSI capability for debugging. Legacy IRQ is still configured as + // a baseline — drivers without MSI support (e.g., ahcid) need it. + // Drivers with MSI support will switch away from legacy via the scheme interface. + if has_msix { + info!(" has MSI-X capability (legacy IRQ as fallback)"); + } else if has_msi { + info!(" has MSI capability (legacy IRQ as fallback)"); + } + + // Legacy IRQ baseline for all devices let mut irq = 0xFF; let mut interrupt_pin = 0xFF;