commit cc943c36faa192cd4b32af8fe5edb31894017d35
    pci: Use bus master address space for delivering MSI/MSI-X messages
breaks virtio-net for rhel6.[56] x86 guests because they don't
enable bus mastering for virtio PCI devices

Old guests forgot to enable bus mastering, enable it
automatically when driver discovers device.

Cc: [email protected]
Reported-by: Greg Kurz <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
---

OK, this should have better luck.
This also makes it possible to simplify code,
will do that in a follow-up patch.


 hw/virtio/virtio-pci.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index ddb5da1..a29d94f 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -303,6 +303,14 @@ static void virtio_ioport_write(void *opaque, uint32_t 
addr, uint32_t val)
             virtio_pci_stop_ioeventfd(proxy);
         }
 
+        /* Linux before 2.6.34 uses the device without enabling
+           the PCI device bus master bit. As a work-around, enable it
+           automatically when driver detects the device. */
+        if (val == VIRTIO_CONFIG_S_ACKNOWLEDGE) {
+            memory_region_set_enabled(&proxy->pci_dev.bus_master_enable_region,
+                                      true);
+        }
+
         virtio_set_status(vdev, val & 0xFF);
 
         if (val & VIRTIO_CONFIG_S_DRIVER_OK) {
-- 
MST

Reply via email to