[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 1/6] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as p
From: |
Phil Dennis-Jordan |
Subject: |
[PATCH v2 1/6] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec |
Date: |
Fri, 13 Dec 2024 17:06:14 +0100 |
QEMU would crash with a failed assertion if the XHCI controller
attempted to raise the interrupt on a higher vector than the
highest configured for the device by the guest driver.
It turns out the XHCI spec (Implementation Note in section 4.17,
"Interrupters") requires that the host controller signal the MSI
vector with the number computed by taking the interrupter number
modulo the number of enabled MSI vectors.
This change introduces that modulo calculation, fixing the
failed assertion and making the device work correctly in MSI mode
with macOS's XHCI driver.
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
---
v2:
* Switch to modulo arithmetic for MSI vector number rather than dropping,
as per spec.
hw/usb/hcd-xhci-pci.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
index a039f5778a6..516e6909d20 100644
--- a/hw/usb/hcd-xhci-pci.c
+++ b/hw/usb/hcd-xhci-pci.c
@@ -74,6 +74,7 @@ static bool xhci_pci_intr_raise(XHCIState *xhci, int n, bool
level)
}
if (msi_enabled(pci_dev) && level) {
+ n %= msi_nr_vectors_allocated(pci_dev);
msi_notify(pci_dev, n);
return true;
}
--
2.39.5 (Apple Git-154)
- [PATCH v2 0/6] hw/usb/hcd-xhci: Fixes, improvements, and macOS workaround, Phil Dennis-Jordan, 2024/12/13
- [PATCH v2 2/6] hw/usb/hcd-xhci-pci: Move msi/msix properties from NEC to superclass, Phil Dennis-Jordan, 2024/12/13
- [PATCH v2 3/6] hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported, Phil Dennis-Jordan, 2024/12/13
- [PATCH v2 6/6] hw/vmapple: XHCI controller's interrupt mapping workaround for macOS, Phil Dennis-Jordan, 2024/12/13
- [PATCH v2 1/6] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec,
Phil Dennis-Jordan <=
- [PATCH v2 5/6] hw/usb/hcd-xhci-pci: Indentation fix, Phil Dennis-Jordan, 2024/12/13
- [PATCH v2 4/6] hw/usb/hcd-xhci-pci: Adds property for disabling mapping in IRQ mode, Phil Dennis-Jordan, 2024/12/13