From: John Johnson <john.g.johnson@oracle.com>
To: qemu-devel@nongnu.org
Cc: alex.williamson@redhat.com, clg@redhat.com, philmd@linaro.org
Subject: [PATCH v2 21/23] vfio-user: pci reset
Date: Wed, 1 Feb 2023 21:55:57 -0800 [thread overview]
Message-ID: <564957e327a9d9a435b0544140ca97e09f7adb48.1675228037.git.john.g.johnson@oracle.com> (raw)
In-Reply-To: <cover.1675228037.git.john.g.johnson@oracle.com>
In-Reply-To: <cover.1675228037.git.john.g.johnson@oracle.com>
Message to tell the server to reset the device.
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Signed-off-by: John G Johnson <john.g.johnson@oracle.com>
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
---
hw/vfio/pci.h | 2 ++
hw/vfio/user.h | 1 +
hw/vfio/pci.c | 4 ++--
hw/vfio/user-pci.c | 15 +++++++++++++++
hw/vfio/user.c | 12 ++++++++++++
5 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index d3e5d5f..3607c6e 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -218,6 +218,8 @@ void vfio_teardown_msi(VFIOPCIDevice *vdev);
void vfio_bars_exit(VFIOPCIDevice *vdev);
void vfio_bars_finalize(VFIOPCIDevice *vdev);
int vfio_add_capabilities(VFIOPCIDevice *vdev, Error **errp);
+void vfio_pci_pre_reset(VFIOPCIDevice *vdev);
+void vfio_pci_post_reset(VFIOPCIDevice *vdev);
void vfio_put_device(VFIOPCIDevice *vdev);
void vfio_register_err_notifier(VFIOPCIDevice *vdev);
void vfio_register_req_notifier(VFIOPCIDevice *vdev);
diff --git a/hw/vfio/user.h b/hw/vfio/user.h
index ae7654f..b7a9f57 100644
--- a/hw/vfio/user.h
+++ b/hw/vfio/user.h
@@ -100,6 +100,7 @@ int vfio_user_validate_version(VFIOUserProxy *proxy, Error **errp);
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);
extern VFIODeviceIO vfio_dev_io_sock;
extern VFIOContainerIO vfio_cont_io_sock;
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 7b16f8f..52fbfe6 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2225,7 +2225,7 @@ int vfio_add_capabilities(VFIOPCIDevice *vdev, Error **errp)
return 0;
}
-static void vfio_pci_pre_reset(VFIOPCIDevice *vdev)
+void vfio_pci_pre_reset(VFIOPCIDevice *vdev)
{
PCIDevice *pdev = &vdev->pdev;
uint16_t cmd;
@@ -2262,7 +2262,7 @@ static void vfio_pci_pre_reset(VFIOPCIDevice *vdev)
vfio_pci_write_config(pdev, PCI_COMMAND, cmd, 2);
}
-static void vfio_pci_post_reset(VFIOPCIDevice *vdev)
+void vfio_pci_post_reset(VFIOPCIDevice *vdev)
{
VFIODevice *vbasedev = &vdev->vbasedev;
Error *err = NULL;
diff --git a/hw/vfio/user-pci.c b/hw/vfio/user-pci.c
index 6465b1c..ee018db 100644
--- a/hw/vfio/user-pci.c
+++ b/hw/vfio/user-pci.c
@@ -381,6 +381,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 Property vfio_user_pci_dev_properties[] = {
DEFINE_PROP_STRING("socket", VFIOUserPCIDevice, sock_name),
DEFINE_PROP_BOOL("no-direct-dma", VFIOUserPCIDevice, no_direct_dma, false),
@@ -394,6 +408,7 @@ static void vfio_user_pci_dev_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *pdc = PCI_DEVICE_CLASS(klass);
+ dc->reset = 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 3aabf6b..9b51686 100644
--- a/hw/vfio/user.c
+++ b/hw/vfio/user.c
@@ -1781,6 +1781,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, false);
+ if (msg.flags & VFIO_USER_ERROR) {
+ error_printf("reset reply error %d\n", msg.error_reply);
+ }
+}
+
/*
* Socket-based io_ops
--
1.9.4
next prev parent reply other threads:[~2023-02-02 5:49 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 5:55 [PATCH v2 00/23] vfio-user client John Johnson
2023-02-02 5:55 ` [PATCH v2 01/23] vfio-user: introduce vfio-user protocol specification John Johnson
2023-02-02 5:55 ` [PATCH v2 02/23] vfio-user: add VFIO base abstract class John Johnson
2023-02-02 5:55 ` [PATCH v2 03/23] vfio-user: add container IO ops vector John Johnson
2023-02-03 22:21 ` Alex Williamson
2023-02-03 22:33 ` Alex Williamson
2023-02-02 5:55 ` [PATCH v2 04/23] vfio-user: add region cache John Johnson
2023-02-02 5:55 ` [PATCH v2 05/23] vfio-user: add device IO ops vector John Johnson
2023-02-02 5:55 ` [PATCH v2 06/23] vfio-user: Define type vfio_user_pci_dev_info John Johnson
2023-02-02 5:55 ` [PATCH v2 07/23] vfio-user: connect vfio proxy to remote server John Johnson
2023-02-02 5:55 ` [PATCH v2 08/23] vfio-user: define socket receive functions John Johnson
2023-02-02 5:55 ` [PATCH v2 09/23] vfio-user: define socket send functions John Johnson
2023-02-02 5:55 ` [PATCH v2 10/23] vfio-user: get device info John Johnson
2023-02-02 5:55 ` [PATCH v2 11/23] vfio-user: get region info John Johnson
2023-02-03 23:11 ` Alex Williamson
2023-02-02 5:55 ` [PATCH v2 12/23] vfio-user: region read/write John Johnson
2023-02-06 19:07 ` Alex Williamson
2023-02-08 6:38 ` John Johnson
2023-02-08 20:33 ` Alex Williamson
2023-02-10 5:28 ` John Johnson
2023-02-02 5:55 ` [PATCH v2 13/23] vfio-user: pci_user_realize PCI setup John Johnson
2023-02-02 5:55 ` [PATCH v2 14/23] vfio-user: get and set IRQs John Johnson
2023-02-02 5:55 ` [PATCH v2 15/23] vfio-user: forward msix BAR accesses to server John Johnson
2023-02-06 20:33 ` Alex Williamson
2023-02-08 6:38 ` John Johnson
2023-02-08 21:30 ` Alex Williamson
2023-02-10 5:28 ` John Johnson
2023-02-02 5:55 ` [PATCH v2 16/23] vfio-user: proxy container connect/disconnect John Johnson
2023-02-02 5:55 ` [PATCH v2 17/23] vfio-user: dma map/unmap operations John Johnson
2023-02-03 21:28 ` Alex Williamson
2023-02-06 20:58 ` Alex Williamson
2023-02-02 5:55 ` [PATCH v2 18/23] vfio-user: add dma_unmap_all John Johnson
2023-02-06 21:29 ` Alex Williamson
2023-02-02 5:55 ` [PATCH v2 19/23] vfio-user: no-mmap DMA support John Johnson
2023-02-02 5:55 ` [PATCH v2 20/23] vfio-user: dma read/write operations John Johnson
2023-02-02 5:55 ` John Johnson [this message]
2023-02-02 5:55 ` [PATCH v2 22/23] vfio-user: add 'x-msg-timeout' option that specifies msg wait times John Johnson
2023-02-02 5:55 ` [PATCH v2 23/23] vfio-user: add coalesced posted writes John Johnson
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=564957e327a9d9a435b0544140ca97e09f7adb48.1675228037.git.john.g.johnson@oracle.com \
--to=john.g.johnson@oracle.com \
--cc=alex.williamson@redhat.com \
--cc=clg@redhat.com \
--cc=philmd@linaro.org \
--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).