From: Cindy Lu <lulu@redhat.com>
To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com,
qemu-devel@nongnu.org
Subject: [PATCH v5 4/6] vhost-vdpa: add support for configure interrupt
Date: Thu, 8 Apr 2021 17:38:22 +0800 [thread overview]
Message-ID: <20210408093824.14985-5-lulu@redhat.com> (raw)
In-Reply-To: <20210408093824.14985-1-lulu@redhat.com>
Add support for configure interrupt. Set the notifier's fd to
the kernel driver when vdpa start. also set -1 while vdpa stop.
then the kernel will release the related resource
Signed-off-by: Cindy Lu <lulu@redhat.com>
---
hw/virtio/vhost-vdpa.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 9ba2a2bed4..7825366f64 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -467,11 +467,33 @@ static int vhost_vdpa_get_config(struct vhost_dev *dev, uint8_t *config,
}
return ret;
}
-
+static void vhost_vdpa_config_notify_start(struct vhost_dev *dev,
+ struct VirtIODevice *vdev, bool start)
+{
+ int fd = 0;
+ int r = 0;
+ if (!(dev->features & (0x1ULL << VIRTIO_NET_F_STATUS))) {
+ return;
+ }
+ if (start) {
+ fd = event_notifier_get_fd(&vdev->config_notifier);
+ r = dev->vhost_ops->vhost_set_config_call(dev, &fd);
+ if (!r) {
+ vdev->use_config_notifier = true;
+ event_notifier_set(&vdev->config_notifier);
+ }
+ } else {
+ fd = -1;
+ vdev->use_config_notifier = false;
+ r = dev->vhost_ops->vhost_set_config_call(dev, &fd);
+ }
+ return;
+}
static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started)
{
struct vhost_vdpa *v = dev->opaque;
trace_vhost_vdpa_dev_start(dev, started);
+ VirtIODevice *vdev = dev->vdev;
if (started) {
uint8_t status = 0;
memory_listener_register(&v->listener, &address_space_memory);
@@ -479,8 +501,10 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started)
vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &status);
+ vhost_vdpa_config_notify_start(dev, vdev, true);
return !(status & VIRTIO_CONFIG_S_DRIVER_OK);
} else {
+ vhost_vdpa_config_notify_start(dev, vdev, false);
vhost_vdpa_reset_device(dev);
vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE |
VIRTIO_CONFIG_S_DRIVER);
--
2.21.3
next prev parent reply other threads:[~2021-04-08 9:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-08 9:38 [PATCH v5 0/6] vhost-vdpa: add support for configure interrupt Cindy Lu
2021-04-08 9:38 ` [PATCH v5 1/6] virtio: introduce new type in interrupt process Cindy Lu
2021-04-09 6:57 ` Jason Wang
2021-04-12 8:09 ` Cindy Lu
2021-04-08 9:38 ` [PATCH v5 2/6] vhost: add new call back function for config interrupt Cindy Lu
2021-04-09 7:12 ` Jason Wang
2021-04-12 8:06 ` Cindy Lu
2021-04-08 9:38 ` [PATCH v5 3/6] virtio:add support in configure interrupt Cindy Lu
2021-04-09 7:21 ` Jason Wang
2021-04-12 8:05 ` Cindy Lu
2021-04-08 9:38 ` Cindy Lu [this message]
2021-04-09 7:24 ` [PATCH v5 4/6] vhost-vdpa: add support for " Jason Wang
2021-04-12 8:18 ` Cindy Lu
2021-04-08 9:38 ` [PATCH v5 5/6] virtio-mmio: " Cindy Lu
2021-04-09 7:27 ` Jason Wang
2021-04-08 9:38 ` [PATCH v5 6/6] virtio-pci: " Cindy Lu
2021-04-09 7:39 ` Jason Wang
2021-04-12 8:27 ` Cindy Lu
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=20210408093824.14985-5-lulu@redhat.com \
--to=lulu@redhat.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.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).