[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 21/27] vfio-user: implement VFIO_USER_DEVICE_RESET
From: |
John Levon |
Subject: |
[PATCH 21/27] vfio-user: implement VFIO_USER_DEVICE_RESET |
Date: |
Thu, 15 May 2025 16:44:06 +0100 |
Hook this call up to the legacy reset handler for vfio-user-pci.
Originally-by: John Johnson <john.g.johnson@oracle.com>
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
Signed-off-by: John Levon <john.levon@nutanix.com>
---
hw/vfio-user/device.h | 2 ++
hw/vfio-user/device.c | 12 ++++++++++++
hw/vfio-user/pci.c | 15 +++++++++++++++
3 files changed, 29 insertions(+)
diff --git a/hw/vfio-user/device.h b/hw/vfio-user/device.h
index a5a2aa9ba6..25cd4c8a00 100644
--- a/hw/vfio-user/device.h
+++ b/hw/vfio-user/device.h
@@ -20,6 +20,8 @@
int vfio_user_get_device_info(VFIOUserProxy *proxy,
struct vfio_device_info *info);
+void vfio_user_device_reset(VFIOUserProxy *proxy);
+
extern VFIODeviceIOOps vfio_user_device_io_ops_sock;
#endif /* VFIO_USER_DEVICE_H */
diff --git a/hw/vfio-user/device.c b/hw/vfio-user/device.c
index 45b91d22f0..b37f7329a1 100644
--- a/hw/vfio-user/device.c
+++ b/hw/vfio-user/device.c
@@ -49,6 +49,18 @@ int vfio_user_get_device_info(VFIOUserProxy *proxy,
return 0;
}
+void vfio_user_device_reset(VFIOUserProxy *proxy)
+{
+ VFIOUserHdr msg;
+
+ vfio_user_request_msg(&msg, VFIO_USER_DEVICE_RESET, sizeof(msg), 0);
+
+ vfio_user_send_wait(proxy, &msg, NULL, 0);
+ if (msg.flags & VFIO_USER_ERROR) {
+ error_printf("reset reply error %d\n", msg.error_reply);
+ }
+}
+
static int vfio_user_get_region_info(VFIOUserProxy *proxy,
struct vfio_region_info *info,
VFIOUserFDs *fds)
diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c
index a6921a8f2e..55cc811d3c 100644
--- a/hw/vfio-user/pci.c
+++ b/hw/vfio-user/pci.c
@@ -251,6 +251,20 @@ static void vfio_user_instance_finalize(Object *obj)
}
}
+static void vfio_user_pci_reset(DeviceState *dev)
+{
+ VFIOPCIDevice *vdev = VFIO_PCI_BASE(dev);
+ VFIODevice *vbasedev = &vdev->vbasedev;
+
+ vfio_pci_pre_reset(vdev);
+
+ if (vbasedev->reset_works) {
+ vfio_user_device_reset(vbasedev->proxy);
+ }
+
+ vfio_pci_post_reset(vdev);
+}
+
static const Property vfio_user_pci_dev_properties[] = {
DEFINE_PROP_UINT32("x-pci-vendor-id", VFIOPCIDevice,
vendor_id, PCI_ANY_ID),
@@ -269,6 +283,7 @@ static void vfio_user_pci_dev_class_init(ObjectClass
*klass, const void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *pdc = PCI_DEVICE_CLASS(klass);
+ device_class_set_legacy_reset(dc, vfio_user_pci_reset);
device_class_set_props(dc, vfio_user_pci_dev_properties);
dc->desc = "VFIO over socket PCI device assignment";
pdc->realize = vfio_user_pci_realize;
--
2.43.0
- [PATCH 24/27] vfio-user: add 'x-msg-timeout' option, (continued)
- [PATCH 24/27] vfio-user: add 'x-msg-timeout' option, John Levon, 2025/05/15
- [PATCH 14/27] vfio-user: implement VFIO_USER_DEVICE_GET_INFO, John Levon, 2025/05/15
- [PATCH 13/27] vfio-user: implement message send infrastructure, John Levon, 2025/05/15
- [PATCH 10/27] vfio-user: add vfio-user class and container, John Levon, 2025/05/15
- [PATCH 09/27] vfio-user: introduce vfio-user protocol specification, John Levon, 2025/05/15
- [PATCH 12/27] vfio-user: implement message receive infrastructure, John Levon, 2025/05/15
- [PATCH 15/27] vfio-user: implement VFIO_USER_DEVICE_GET_REGION_INFO, John Levon, 2025/05/15
- [PATCH 16/27] vfio-user: implement VFIO_USER_REGION_READ/WRITE, John Levon, 2025/05/15
- [PATCH 17/27] vfio-user: set up PCI in vfio_user_pci_realize(), John Levon, 2025/05/15
- [PATCH 18/27] vfio-user: implement VFIO_USER_DEVICE_GET/SET_IRQ*, John Levon, 2025/05/15
- [PATCH 21/27] vfio-user: implement VFIO_USER_DEVICE_RESET,
John Levon <=
- [PATCH 11/27] vfio-user: connect vfio proxy to remote server, John Levon, 2025/05/15
- [PATCH 20/27] vfio-user: set up container access to the proxy, John Levon, 2025/05/15
- [PATCH 25/27] vfio-user: support posted writes, John Levon, 2025/05/15
- [PATCH 27/27] docs: add vfio-user documentation, John Levon, 2025/05/15
- [PATCH 26/27] vfio-user: add coalesced posted writes, John Levon, 2025/05/15
- [PATCH 23/27] vfio-user: implement VFIO_USER_DMA_READ/WRITE, John Levon, 2025/05/15