On 2/3/26 08:30, Vivek Kasireddy wrote:
Instead of iterating over all QOM devices to find the VFIODevice
associated with a memory region, it is faster to just use the
vfio_device_list to lookup the VFIODevice.
Cc: Alex Williamson <[email protected]>
Cc: Cédric Le Goater <[email protected]>
Signed-off-by: Vivek Kasireddy <[email protected]>
---
hw/vfio/device.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/hw/vfio/device.c b/hw/vfio/device.c
index 973fc35b59..ecb3581fcc 100644
--- a/hw/vfio/device.c
+++ b/hw/vfio/device.c
@@ -644,3 +644,26 @@ static VFIODeviceIOOps vfio_device_io_ops_ioctl = {
.region_read = vfio_device_io_region_read,
.region_write = vfio_device_io_region_write,
};
+
+static bool vfio_device_lookup(struct iovec *iov, VFIODevice **vbasedevp,
+ Error **errp)
+{
+ VFIODevice *vbasedev;
+ RAMBlock *first_rb;
+ ram_addr_t offset;
+
+ first_rb = qemu_ram_block_from_host(iov[0].iov_base, false, &offset);
+ if (!first_rb) {
+ error_setg(errp, "Could not find first ramblock\n");
+ return false;
+ }
+
+ QLIST_FOREACH(vbasedev, &vfio_device_list, next) {
+ if (vbasedev->dev == first_rb->mr->dev) {
+ *vbasedevp = vbasedev;
+ return true;
+ }
+ }
+ error_setg(errp, "No VFIO device found to create dmabuf from\n");
+ return false;
+}
This won't compile and break bisect. Please merge with the following patch.
Thanks,
C.