qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH 2/4] virtio-pci: add handling of ATS state change


From: Jason Wang
Subject: Re: [RFC PATCH 2/4] virtio-pci: add handling of ATS state change
Date: Wed, 26 Apr 2023 13:50:36 +0800
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.10.0


在 2023/4/24 19:21, Viktor Prutyanov 写道:
Guest may enable or disable ATS for the device. Add logic for handling
these events.

Signed-off-by: Viktor Prutyanov <viktor@daynix.com>
---
  hw/virtio/virtio-pci.c     | 12 ++++++++++++
  include/hw/virtio/virtio.h |  2 ++
  2 files changed, 14 insertions(+)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 247325c193..70f63a4986 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1731,6 +1731,17 @@ static void virtio_pci_device_write(void *opaque, hwaddr 
addr,
      }
  }
+static void virtio_pci_ats_ctrl_trigger(PCIDevice *pci_dev, bool enable)
+{
+    VirtIOPCIProxy *proxy = VIRTIO_PCI(pci_dev);
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
+
+    vdev->ats_enabled = enable;
+
+    if (vdev->ats_ctrl_trigger)
+        vdev->ats_ctrl_trigger(enable, vdev);
+}
+
  static void virtio_pci_modern_regions_init(VirtIOPCIProxy *proxy,
                                             const char *vdev_name)
  {
@@ -2166,6 +2177,7 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error 
**errp)
          if (proxy->flags & VIRTIO_PCI_FLAG_ATS) {
              pcie_ats_init(pci_dev, last_pcie_cap_offset,
                            proxy->flags & VIRTIO_PCI_FLAG_ATS_PAGE_ALIGNED);
+            pci_dev->ats_ctrl_trigger = virtio_pci_ats_ctrl_trigger;
              last_pcie_cap_offset += PCI_EXT_CAP_ATS_SIZEOF;
          }
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 77c6c55929..2812561aae 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -155,6 +155,8 @@ struct VirtIODevice
      QLIST_HEAD(, VirtQueue) *vector_queues;
      QTAILQ_ENTRY(VirtIODevice) next;
      EventNotifier config_notifier;
+    void (*ats_ctrl_trigger)(bool enable, VirtIODevice *vdev);
+    bool ats_enabled;


ATS is pci specific in the virtio layer we might use something more general like "device-iotlb"?

And this method needs to go in VirtioDeviceClass.

Thanks


  };
struct VirtioDeviceClass {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]