Patchwork [2/3] msi: Cleanup uninit

login
register
mail settings
Submitter Alex Williamson
Date Nov. 2, 2010, 5:37 a.m.
Message ID <20101102053738.10424.81682.stgit@s20.home>
Download mbox | patch
Permalink /patch/69863/
State New
Headers show

Comments

Alex Williamson - Nov. 2, 2010, 5:37 a.m.
This makes msi_uninit more similar to msix_uninit, doing nothing if not
enable, clearing msi_cap and capability flag.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 hw/msi.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

Patch

diff --git a/hw/msi.c b/hw/msi.c
index 0ad4e38..110859b 100644
--- a/hw/msi.c
+++ b/hw/msi.c
@@ -170,9 +170,15 @@  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);
+    uint8_t cap_size;
+
+    if (!(dev->cap_present & QEMU_PCI_CAP_MSI))
+        return;
+
+    cap_size = msi_cap_sizeof(pci_get_word(dev->config + msi_flags_off(dev)));
     pci_del_capability(dev, PCI_CAP_ID_MSIX, cap_size);
+    dev->msi_cap = 0;
+    dev->cap_present &= ~QEMU_PCI_CAP_MSI;
     MSI_DEV_PRINTF(dev, "uninit\n");
 }