>From 66fa730460875ac99e81d7db2334cd16bb1d2b27 Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Mon, 24 Feb 2020 12:00:10 +0800 Subject: [PATCH] virtio: turn on IOMMU_PLATFORM properly When transport does not support IOMMU, we should clear IOMMU_PLATFORM even if the device and vhost claims to support that. This help to avoid the performance overhead caused by unnecessary IOTLB miss/update transactions on such platform. Signed-off-by: Jason Wang --- hw/virtio/virtio-bus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index d6332d45c3..2741b9fdd2 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -47,7 +47,6 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp) VirtioBusState *bus = VIRTIO_BUS(qbus); VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus); VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); - bool has_iommu = virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM); Error *local_err = NULL; DPRINTF("%s: plug device.\n", qbus->name); @@ -77,10 +76,11 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp) return; } - if (klass->get_dma_as != NULL && has_iommu) { - virtio_add_feature(&vdev->host_features, VIRTIO_F_IOMMU_PLATFORM); + if (false && klass->get_dma_as != NULL && + virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM)) { vdev->dma_as = klass->get_dma_as(qbus->parent); } else { + virtio_clear_feature(&vdev->host_features, VIRTIO_F_IOMMU_PLATFORM); vdev->dma_as = &address_space_memory; } } -- 2.19.1