From: "Cédric Le Goater" <clg@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Alex Williamson" <alex.williamson@redhat.com>,
"John Levon" <john.levon@nutanix.com>,
"Cédric Le Goater" <clg@redhat.com>
Subject: [PULL 09/27] vfio: mark posted writes in region write callbacks
Date: Wed, 11 Jun 2025 17:06:01 +0200 [thread overview]
Message-ID: <20250611150620.701903-10-clg@redhat.com> (raw)
In-Reply-To: <20250611150620.701903-1-clg@redhat.com>
From: John Levon <john.levon@nutanix.com>
For vfio-user, the region write implementation needs to know if the
write is posted; add the necessary plumbing to support this.
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20250607001056.335310-5-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
include/hw/vfio/vfio-device.h | 4 ++--
include/hw/vfio/vfio-region.h | 1 +
hw/vfio/device.c | 3 ++-
hw/vfio/pci.c | 5 ++++-
hw/vfio/region.c | 3 ++-
5 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h
index bf54fc69205a713263a666b480b2399e2a91f552..9793b2dba0ced9e87b1641ae783867ce1b41e71a 100644
--- a/include/hw/vfio/vfio-device.h
+++ b/include/hw/vfio/vfio-device.h
@@ -205,10 +205,10 @@ struct VFIODeviceIOOps {
* @region_write
*
* Write @size bytes to the region @nr at offset @off from the buffer
- * @data.
+ * @data; if @post, the write is posted.
*/
int (*region_write)(VFIODevice *vdev, uint8_t nr, off_t off, uint32_t size,
- void *data);
+ void *data, bool post);
};
void vfio_device_prepare(VFIODevice *vbasedev, VFIOContainerBase *bcontainer,
diff --git a/include/hw/vfio/vfio-region.h b/include/hw/vfio/vfio-region.h
index cbffb269628cc89fbbdb060ce3ce6e45bd701bad..ede6e0c8f992caa3292d280474c90ddef27eb3dd 100644
--- a/include/hw/vfio/vfio-region.h
+++ b/include/hw/vfio/vfio-region.h
@@ -29,6 +29,7 @@ typedef struct VFIORegion {
uint32_t nr_mmaps;
VFIOMmap *mmaps;
uint8_t nr; /* cache the region number for debug */
+ bool post_wr; /* writes can be posted */
} VFIORegion;
diff --git a/hw/vfio/device.c b/hw/vfio/device.c
index a4bdde8e8bd49c82923d0d29a44f18fd71a44204..d32600eda1a282adaa4c58cfeb80c19c6489ee92 100644
--- a/hw/vfio/device.c
+++ b/hw/vfio/device.c
@@ -543,7 +543,8 @@ static int vfio_device_io_region_read(VFIODevice *vbasedev, uint8_t index,
}
static int vfio_device_io_region_write(VFIODevice *vbasedev, uint8_t index,
- off_t off, uint32_t size, void *data)
+ off_t off, uint32_t size, void *data,
+ bool post)
{
struct vfio_region_info *info;
int ret;
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 2901cedf6f3e4e1283cb59a1ff6c8ddb99a41b56..89f9246416a700ecbfb21ec3921b5a71cadf9981 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -989,7 +989,7 @@ static int vfio_pci_config_space_write(VFIOPCIDevice *vdev, off_t offset,
{
return vdev->vbasedev.io_ops->region_write(&vdev->vbasedev,
VFIO_PCI_CONFIG_REGION_INDEX,
- offset, size, data);
+ offset, size, data, false);
}
static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size)
@@ -1793,6 +1793,9 @@ static void vfio_bar_prepare(VFIOPCIDevice *vdev, int nr)
bar->type = pci_bar & (bar->ioport ? ~PCI_BASE_ADDRESS_IO_MASK :
~PCI_BASE_ADDRESS_MEM_MASK);
bar->size = bar->region.size;
+
+ /* IO regions are sync, memory can be async */
+ bar->region.post_wr = (bar->ioport == 0);
}
static void vfio_bars_prepare(VFIOPCIDevice *vdev)
diff --git a/hw/vfio/region.c b/hw/vfio/region.c
index cb172f2136dab7d5e649e588bda16b0e4821079d..f5b8e3cbf100f4f1b9fb916075653d3a6e1ca8d4 100644
--- a/hw/vfio/region.c
+++ b/hw/vfio/region.c
@@ -66,7 +66,7 @@ void vfio_region_write(void *opaque, hwaddr addr,
}
ret = vbasedev->io_ops->region_write(vbasedev, region->nr,
- addr, size, &buf);
+ addr, size, &buf, region->post_wr);
if (ret != size) {
error_report("%s(%s:region%d+0x%"HWADDR_PRIx", 0x%"PRIx64
",%d) failed: %s",
@@ -200,6 +200,7 @@ int vfio_region_setup(Object *obj, VFIODevice *vbasedev, VFIORegion *region,
region->size = info->size;
region->fd_offset = info->offset;
region->nr = index;
+ region->post_wr = false;
if (region->size) {
region->mem = g_new0(MemoryRegion, 1);
--
2.49.0
next prev parent reply other threads:[~2025-06-11 15:09 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 15:05 [PULL 00/27] vfio queue Cédric Le Goater
2025-06-11 15:05 ` [PULL 01/27] vfio/container: Fix vfio_listener_commit() Cédric Le Goater
2025-06-11 15:05 ` [PULL 02/27] vfio/pci: Fix instance_size of VFIO_PCI_BASE Cédric Le Goater
2025-06-11 15:05 ` [PULL 03/27] hw/vfio/ap: notification handler for AP config changed event Cédric Le Goater
2025-06-11 15:05 ` [PULL 04/27] hw/vfio/ap: store object indicating AP config changed in a queue Cédric Le Goater
2025-06-11 15:05 ` [PULL 05/27] hw/vfio/ap: Storing event information for an AP configuration change event Cédric Le Goater
2025-06-11 15:05 ` [PULL 06/27] s390: implementing CHSC SEI for AP config change Cédric Le Goater
2025-06-11 15:05 ` [PULL 07/27] vfio: export PCI helpers needed for vfio-user Cédric Le Goater
2025-06-11 15:06 ` [PULL 08/27] vfio: add per-region fd support Cédric Le Goater
2025-06-11 15:06 ` Cédric Le Goater [this message]
2025-06-11 15:06 ` [PULL 10/27] migration: cpr helpers Cédric Le Goater
2025-06-11 15:06 ` [PULL 11/27] migration: lower handler priority Cédric Le Goater
2025-06-11 15:06 ` [PULL 12/27] vfio/container: register container for cpr Cédric Le Goater
2025-06-11 15:06 ` [PULL 13/27] vfio/container: preserve descriptors Cédric Le Goater
2025-06-11 15:06 ` [PULL 14/27] vfio/container: discard old DMA vaddr Cédric Le Goater
2025-06-11 15:06 ` [PULL 15/27] vfio/container: restore " Cédric Le Goater
2025-06-11 15:06 ` [PULL 16/27] vfio/container: mdev cpr blocker Cédric Le Goater
2025-06-11 15:06 ` [PULL 17/27] vfio/container: recover from unmap-all-vaddr failure Cédric Le Goater
2025-06-11 15:06 ` [PULL 18/27] pci: export msix_is_pending Cédric Le Goater
2025-06-11 15:06 ` [PULL 19/27] pci: skip reset during cpr Cédric Le Goater
2025-06-11 15:06 ` [PULL 20/27] vfio-pci: " Cédric Le Goater
2025-06-11 15:06 ` [PULL 21/27] vfio/pci: vfio_pci_vector_init Cédric Le Goater
2025-06-11 15:06 ` [PULL 22/27] vfio/pci: vfio_notifier_init Cédric Le Goater
2025-06-11 15:06 ` [PULL 23/27] vfio/pci: pass vector to virq functions Cédric Le Goater
2025-06-11 15:06 ` [PULL 24/27] vfio/pci: vfio_notifier_init cpr parameters Cédric Le Goater
2025-06-11 15:06 ` [PULL 25/27] vfio/pci: vfio_notifier_cleanup Cédric Le Goater
2025-06-11 15:06 ` [PULL 26/27] vfio/pci: export MSI functions Cédric Le Goater
2025-06-11 15:06 ` [PULL 27/27] vfio: improve VFIODeviceIOOps docs Cédric Le Goater
2025-06-11 18:22 ` [PULL 00/27] vfio queue Stefan Hajnoczi
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=20250611150620.701903-10-clg@redhat.com \
--to=clg@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=john.levon@nutanix.com \
--cc=qemu-devel@nongnu.org \
/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).