From: Viktor Prutyanov <viktor@daynix.com>
To: mst@redhat.com, jasowang@redhat.com, peterx@redhat.com,
marcel.apfelbaum@gmail.com
Cc: qemu-devel@nongnu.org, viktor@daynix.com, yan@daynix.com,
yuri.benditovich@daynix.com
Subject: [RFC PATCH v2 2/4] virtio-pci: add handling of ATS and Device-TLB enable
Date: Mon, 1 May 2023 05:02:19 +0300 [thread overview]
Message-ID: <20230501020221.188376-3-viktor@daynix.com> (raw)
In-Reply-To: <20230501020221.188376-1-viktor@daynix.com>
Guest may enable or disable PCI ATS and, accordingly, Device-TLB for
the device. Add a flag and a trigger function to handle Device-TLB
enable/disable in VirtIO devices and hook it to ATS enable/disable for
PCI transport.
Signed-off-by: Viktor Prutyanov <viktor@daynix.com>
---
hw/virtio/virtio-pci.c | 17 +++++++++++++++++
include/hw/virtio/virtio.h | 2 ++
2 files changed, 19 insertions(+)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 247325c193..ccd8c4efa1 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -716,6 +716,18 @@ virtio_address_space_read(VirtIOPCIProxy *proxy, 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);
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
+
+ vdev->device_iotlb_enabled = enable;
+
+ if (k->toggle_device_iotlb)
+ k->toggle_device_iotlb(vdev, enable);
+}
+
static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
uint32_t val, int len)
{
@@ -729,6 +741,11 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
pcie_cap_flr_write_config(pci_dev, address, val, len);
}
+ if (proxy->flags & VIRTIO_PCI_FLAG_ATS) {
+ pcie_ats_config_write(pci_dev, address, val, len,
+ virtio_pci_ats_ctrl_trigger);
+ }
+
if (range_covers_byte(address, len, PCI_COMMAND)) {
if (!(pci_dev->config[PCI_COMMAND] & PCI_COMMAND_MASTER)) {
virtio_set_disabled(vdev, true);
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index f236e94ca6..83d07bb6b7 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -155,6 +155,7 @@ struct VirtIODevice
QLIST_HEAD(, VirtQueue) *vector_queues;
QTAILQ_ENTRY(VirtIODevice) next;
EventNotifier config_notifier;
+ bool device_iotlb_enabled;
};
struct VirtioDeviceClass {
@@ -212,6 +213,7 @@ struct VirtioDeviceClass {
const VMStateDescription *vmsd;
bool (*primary_unplug_pending)(void *opaque);
struct vhost_dev *(*get_vhost)(VirtIODevice *vdev);
+ void (*toggle_device_iotlb)(VirtIODevice *vdev, bool enable);
};
void virtio_instance_init_common(Object *proxy_obj, void *data,
--
2.35.1
next prev parent reply other threads:[~2023-05-01 2:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-01 2:02 [RFC PATCH v2 0/4] vhost: register and change IOMMU flag depending on ATS state Viktor Prutyanov
2023-05-01 2:02 ` [RFC PATCH v2 1/4] pci: add handling of Enable bit in ATS Control Register Viktor Prutyanov
2023-05-01 2:02 ` Viktor Prutyanov [this message]
2023-05-08 4:14 ` [RFC PATCH v2 2/4] virtio-pci: add handling of ATS and Device-TLB enable Jason Wang
2023-05-01 2:02 ` [RFC PATCH v2 3/4] vhost: register and change IOMMU flag depending on Device-TLB state Viktor Prutyanov
2023-05-08 5:25 ` Jason Wang
2023-05-08 5:28 ` Jason Wang
2023-05-12 14:13 ` Viktor Prutyanov
2023-05-01 2:02 ` [RFC PATCH v2 4/4] virtio-net: pass Device-TLB enable/disable events to vhost Viktor Prutyanov
2023-05-08 5:26 ` Jason Wang
2023-05-12 14:06 ` Viktor Prutyanov
2023-05-08 4:09 ` [RFC PATCH v2 0/4] vhost: register and change IOMMU flag depending on ATS state Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230501020221.188376-3-viktor@daynix.com \
--to=viktor@daynix.com \
--cc=jasowang@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yan@daynix.com \
--cc=yuri.benditovich@daynix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).