[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 24/26] vfio-user: pci reset
From: |
John Levon |
Subject: |
[PATCH 24/26] vfio-user: pci reset |
Date: |
Wed, 8 Jan 2025 11:50:30 +0000 |
From: Jagannathan Raman <jag.raman@oracle.com>
Message to tell the server to reset the device.
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-pci.c | 15 +++++++++++++++
hw/vfio/user.c | 12 ++++++++++++
hw/vfio/user.h | 1 +
3 files changed, 28 insertions(+)
diff --git a/hw/vfio/user-pci.c b/hw/vfio/user-pci.c
index 8cd397b75a..84802556e9 100644
--- a/hw/vfio/user-pci.c
+++ b/hw/vfio/user-pci.c
@@ -393,6 +393,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_reset(vbasedev->proxy);
+ }
+
+ vfio_pci_post_reset(vdev);
+}
+
static const Property vfio_user_pci_dev_properties[] = {
DEFINE_PROP_STRING("socket", VFIOUserPCIDevice, sock_name),
DEFINE_PROP_BOOL("no-direct-dma", VFIOUserPCIDevice, no_direct_dma, false),
@@ -405,6 +419,7 @@ static void vfio_user_pci_dev_class_init(ObjectClass
*klass, 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;
diff --git a/hw/vfio/user.c b/hw/vfio/user.c
index 6f0358bd8f..9fba36e196 100644
--- a/hw/vfio/user.c
+++ b/hw/vfio/user.c
@@ -1491,6 +1491,18 @@ static int vfio_user_region_write(VFIOUserProxy *proxy,
uint8_t index,
return ret;
}
+void vfio_user_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);
+ }
+}
+
/*
* Socket-based io_ops
diff --git a/hw/vfio/user.h b/hw/vfio/user.h
index fa6bc9a9d6..d9aa1759df 100644
--- a/hw/vfio/user.h
+++ b/hw/vfio/user.h
@@ -119,5 +119,6 @@ void vfio_user_send_wait(VFIOUserProxy *proxy, VFIOUserHdr
*hdr,
void vfio_user_send_reply(VFIOUserProxy *proxy, VFIOUserHdr *hdr, int size);
void vfio_user_send_error(VFIOUserProxy *proxy, VFIOUserHdr *hdr, int error);
void vfio_user_putfds(VFIOUserMsg *msg);
+void vfio_user_reset(VFIOUserProxy *proxy);
#endif /* VFIO_USER_H */
--
2.34.1
- [PATCH 12/26] vfio-user: define socket receive functions, (continued)
- [PATCH 12/26] vfio-user: define socket receive functions, John Levon, 2025/01/08
- [PATCH 07/26] vfio: add VFIO base abstract class, John Levon, 2025/01/08
- [PATCH 13/26] vfio-user: define socket send functions, John Levon, 2025/01/08
- [PATCH 17/26] vfio-user: pci_user_realize PCI setup, John Levon, 2025/01/08
- [PATCH 15/26] vfio-user: get region info, John Levon, 2025/01/08
- [PATCH 20/26] vfio-user: proxy container connect/disconnect, John Levon, 2025/01/08
- [PATCH 22/26] vfio-user: no-mmap DMA support, John Levon, 2025/01/08
- [PATCH 19/26] vfio-user: forward msix BAR accesses to server, John Levon, 2025/01/08
- [PATCH 06/26] vfio: add region cache, John Levon, 2025/01/08
- [PATCH 01/26] vfio/container: pass MemoryRegion to DMA operations, John Levon, 2025/01/08
- [PATCH 24/26] vfio-user: pci reset,
John Levon <=
- [PATCH 03/26] vfio/container: support VFIO_DMA_UNMAP_FLAG_ALL, John Levon, 2025/01/08
- [PATCH 16/26] vfio-user: region read/write, John Levon, 2025/01/08
- [PATCH 18/26] vfio-user: get and set IRQs, John Levon, 2025/01/08
- [PATCH 23/26] vfio-user: dma read/write operations, John Levon, 2025/01/08
- [PATCH 21/26] vfio-user: dma map/unmap operations, John Levon, 2025/01/08
- [PATCH 25/26] vfio-user: add 'x-msg-timeout' option that specifies msg wait times, John Levon, 2025/01/08
- [PATCH 26/26] vfio-user: add coalesced posted writes, John Levon, 2025/01/08