From: Cindy Lu <lulu@redhat.com>
To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org
Cc: lulu@redhat.com
Subject: [PATCH v3 1/5] virtio: add support for configure interrupt
Date: Tue, 26 Jan 2021 15:42:50 +0800 [thread overview]
Message-ID: <20210126074254.3225-2-lulu@redhat.com> (raw)
In-Reply-To: <20210126074254.3225-1-lulu@redhat.com>
Add configure notifier and virtio_set_config_notifier_fd_handler
in virtio
Signed-off-by: Cindy Lu <lulu@redhat.com>
---
hw/virtio/virtio.c | 26 ++++++++++++++++++++++++++
include/hw/virtio/virtio-bus.h | 2 ++
include/hw/virtio/virtio.h | 6 ++++++
3 files changed, 34 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index ceb58fda6c..25e164cf8a 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -3502,6 +3502,16 @@ static void virtio_queue_guest_notifier_read(EventNotifier *n)
}
}
+static void virtio_config_read(EventNotifier *n)
+{
+ VirtIODevice *vdev = container_of(n, VirtIODevice, config_notifier);
+ if (!vdev->use_config_notifier) {
+ return;
+ }
+ if (event_notifier_test_and_clear(n)) {
+ virtio_notify_config(vdev);
+ }
+}
void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
bool with_irqfd)
{
@@ -3518,6 +3528,17 @@ void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
}
}
+void virtio_set_config_notifier_fd_handler(VirtIODevice *vdev, bool assign,
+ bool with_irqfd)
+{
+ if (assign && !with_irqfd) {
+ event_notifier_set_handler(&vdev->config_notifier,
+ virtio_config_read);
+ } else {
+ event_notifier_set_handler(&vdev->config_notifier, NULL);
+ }
+}
+
EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq)
{
return &vq->guest_notifier;
@@ -3591,6 +3612,11 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq)
return &vq->host_notifier;
}
+EventNotifier *virtio_get_config_notifier(VirtIODevice *vdev)
+{
+ return &vdev->config_notifier;
+
+}
void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled)
{
vq->host_notifier_enabled = enabled;
diff --git a/include/hw/virtio/virtio-bus.h b/include/hw/virtio/virtio-bus.h
index ef8abe49c5..97e13ec484 100644
--- a/include/hw/virtio/virtio-bus.h
+++ b/include/hw/virtio/virtio-bus.h
@@ -93,6 +93,8 @@ struct VirtioBusClass {
*/
bool has_variable_vring_alignment;
AddressSpace *(*get_dma_as)(DeviceState *d);
+ int (*set_config_notifiers)(DeviceState *d, bool assign);
+
};
struct VirtioBusState {
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index b7ece7a6a8..79f2f78625 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -108,6 +108,8 @@ struct VirtIODevice
bool use_guest_notifier_mask;
AddressSpace *dma_as;
QLIST_HEAD(, VirtQueue) *vector_queues;
+ EventNotifier config_notifier;
+ bool use_config_notifier;
};
struct VirtioDeviceClass {
@@ -310,11 +312,15 @@ uint16_t virtio_get_queue_index(VirtQueue *vq);
EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq);
void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
bool with_irqfd);
+void virtio_set_config_notifier_fd_handler(VirtIODevice *vdev, bool assign,
+ bool with_irqfd);
+
int virtio_device_start_ioeventfd(VirtIODevice *vdev);
int virtio_device_grab_ioeventfd(VirtIODevice *vdev);
void virtio_device_release_ioeventfd(VirtIODevice *vdev);
bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev);
EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
+EventNotifier *virtio_get_config_notifier(VirtIODevice *vdev);
void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled);
void virtio_queue_host_notifier_read(EventNotifier *n);
void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
--
2.21.3
next prev parent reply other threads:[~2021-01-26 7:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-26 7:42 [PATCH v3 0/5] vhost-vdpa: add support for configure interrupt Cindy Lu
2021-01-26 7:42 ` Cindy Lu [this message]
2021-01-27 5:35 ` [PATCH v3 1/5] virtio: " Jason Wang
2021-01-26 7:42 ` [PATCH v3 2/5] vhost_net: enable configure interrupt when vhost_net start Cindy Lu
2021-01-27 5:38 ` Jason Wang
2021-01-27 7:25 ` Cindy Lu
2021-01-26 7:42 ` [PATCH v3 3/5] virtio-pci: add support for configure interrupt Cindy Lu
2021-01-27 5:44 ` Jason Wang
2021-01-27 7:39 ` Cindy Lu
2021-01-26 7:42 ` [PATCH v3 4/5] virtio-mmio: " Cindy Lu
2021-01-26 7:42 ` [PATCH v3 5/5] vhost-vdpa: add callback function " Cindy Lu
2021-01-26 14:53 ` Stefano Garzarella
2021-01-27 2:51 ` Cindy Lu
2021-01-27 5:47 ` Jason Wang
2021-01-27 7:51 ` Cindy Lu
2021-01-27 8:16 ` Jason Wang
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=20210126074254.3225-2-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).