aboutsummaryrefslogtreecommitdiff
path: root/hw/msi.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/msi.c')
-rw-r--r--hw/msi.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/hw/msi.c b/hw/msi.c
index 3dc3a24b77..b0795bd708 100644
--- a/hw/msi.c
+++ b/hw/msi.c
@@ -164,9 +164,17 @@ int msi_init(struct PCIDevice *dev, uint8_t offset,
void msi_uninit(struct PCIDevice *dev)
{
- uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));
- uint8_t cap_size = msi_cap_sizeof(flags);
+ uint16_t flags;
+ uint8_t cap_size;
+
+ if (!(dev->cap_present & QEMU_PCI_CAP_MSI)) {
+ return;
+ }
+ flags = pci_get_word(dev->config + msi_flags_off(dev));
+ cap_size = msi_cap_sizeof(flags);
pci_del_capability(dev, PCI_CAP_ID_MSIX, cap_size);
+ dev->cap_present &= ~QEMU_PCI_CAP_MSI;
+
MSI_DEV_PRINTF(dev, "uninit\n");
}