Skip to contentSkip to conversation

msix: add helper to mark all msix entries

PATCH New Michael S. Tsirkin 1 participant 2 messages Nov 24, 2009 1 message not in the archive

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 msix: add helper to mark all msix entries

In reply to a message not in the archive

will be used by virtio on soft reset

---
 hw/msix.c |    7 +++++++
 hw/msix.h |    1 +
 2 files changed, 8 insertions(+), 0 deletions(-)
hw/msix.c +7 -0
index 548ffd5..d499441 100644
@@ -378,3 +378,10 @@ void msix_vector_unuse(PCIDevice *dev, unsigned vector)
     if (vector < dev->msix_entries_nr && dev->msix_entry_used[vector])
         --dev->msix_entry_used[vector];
 }
+
+void msix_unuse_all_vectors(PCIDevice *dev)
+{
+    if (!(dev->cap_present & QEMU_PCI_CAP_MSIX))
+        return;
+    msix_free_irq_entries(dev);
+}
hw/msix.h +1 -0
index 39fa568..a9f7993 100644
@@ -25,6 +25,7 @@ uint32_t msix_bar_size(PCIDevice *dev);
 
 int msix_vector_use(PCIDevice *dev, unsigned vector);
 void msix_vector_unuse(PCIDevice *dev, unsigned vector);
+void msix_unuse_all_vectors(PCIDevice *dev);
 
 void msix_notify(PCIDevice *dev, unsigned vector);
 
Signature · 1 line
1.6.5.2.143.g8cc62
#2 lore raw

PATCH 2/2 virtio: do not reset msix state on soft reset

In reply to a message not in the archive

msix state is managed by OS, not the
driver, so it's wrong to touch it
on io from driver

---
 hw/virtio-pci.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
hw/virtio-pci.c +8 -4
index aebcf9d..d222ce0 100644
@@ -185,8 +185,10 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
         break;
     case VIRTIO_PCI_QUEUE_PFN:
         pa = (target_phys_addr_t)val << VIRTIO_PCI_QUEUE_ADDR_SHIFT;
-        if (pa == 0)
-            virtio_pci_reset(&proxy->pci_dev.qdev);
+        if (pa == 0) {
+            virtio_reset(proxy->vdev);
+            msix_unuse_all_vectors(&proxy->pci_dev);
+        }
         else
             virtio_queue_set_addr(vdev, vdev->queue_sel, pa);
         break;
@@ -199,8 +201,10 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
         break;
     case VIRTIO_PCI_STATUS:
         vdev->status = val & 0xFF;
-        if (vdev->status == 0)
-            virtio_pci_reset(&proxy->pci_dev.qdev);
+        if (vdev->status == 0) {
+            virtio_reset(proxy->vdev);
+            msix_unuse_all_vectors(&proxy->pci_dev);
+        }
         break;
     case VIRTIO_MSI_CONFIG_VECTOR:
         msix_vector_unuse(&proxy->pci_dev, vdev->config_vector);
Signature · 1 line
1.6.5.2.143.g8cc62