From: Cindy Lu <lulu@redhat.com>
To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com,
qemu-devel@nongnu.org
Subject: [RFC 6/7] vhost-vdpa: init iommufd function in vhost_vdpa start
Date: Wed, 3 May 2023 17:13:36 +0800 [thread overview]
Message-ID: <20230503091337.2130631-7-lulu@redhat.com> (raw)
In-Reply-To: <20230503091337.2130631-1-lulu@redhat.com>
Add support for iommufd, init the vdpa_iommufd in vdpa_start
in this step, driver will bind to the iommufd device
and attach the default ASID(asid 0) to iommufd
Signed-off-by: Cindy Lu <lulu@redhat.com>
---
hw/virtio/vhost-vdpa.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 85240926b2..6c01e3b44f 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -1158,6 +1158,24 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started)
trace_vhost_vdpa_dev_start(dev, started);
if (started) {
+ if ((v->enable_iommufd) && (vhost_vdpa_first_dev(dev))) {
+ struct vdpa_iommufd *vdpa_iommufd;
+
+ vdpa_backend_iommufd_ops_class_init(v);
+
+ if (dev->vdev->iommufd_ptr == NULL) {
+ vdpa_iommufd = g_malloc(sizeof(VDPAIOMMUFDState));
+
+ vdpa_iommufd->iommufd = g_malloc(sizeof(IOMMUFDBackend));
+ dev->vdev->iommufd_ptr = vdpa_iommufd;
+
+ qemu_mutex_init(&vdpa_iommufd->iommufd->lock);
+ iommufd_backend_connect(vdpa_iommufd->iommufd, NULL);
+
+ v->ops->attach_device(v, dev->vdev->dma_as, NULL);
+ }
+ }
+
vhost_vdpa_host_notifiers_init(dev);
ok = vhost_vdpa_svqs_start(dev);
if (unlikely(!ok)) {
--
2.34.3
next prev parent reply other threads:[~2023-05-03 9:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-03 9:13 [RFC 0/7] vhost-vdpa: add support for iommufd Cindy Lu
2023-05-03 9:13 ` [RFC 1/7] vhost: introduce new UAPI to support IOMMUFD Cindy Lu
2023-05-03 9:13 ` [RFC 2/7] qapi: support iommufd in vdpa Cindy Lu
2023-05-03 9:13 ` [RFC 3/7] virtio : add a ptr for vdpa_iommufd in VirtIODevice Cindy Lu
2023-05-03 9:13 ` [RFC 4/7] net/vhost-vdpa: Add the check for iommufd Cindy Lu
2023-05-03 9:13 ` [RFC 5/7] vhost-vdpa: Add the iommufd support in the map/unmap function Cindy Lu
2023-05-03 9:13 ` Cindy Lu [this message]
2023-05-03 9:13 ` [RFC 7/7] vhost-vdpa-iommufd: Add iommufd support for vdpa Cindy Lu
2023-05-05 3:29 ` [RFC 0/7] vhost-vdpa: add support for iommufd Jason Wang
2023-05-05 6:29 ` Cindy Lu
2023-06-05 5:41 ` Michael S. Tsirkin
2023-06-05 8:04 ` Cindy Lu
2023-09-13 13:31 ` Michael S. Tsirkin
2023-09-14 5:44 ` 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=20230503091337.2130631-7-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).