From: Yi Liu <yi.l.liu@intel.com>
To: alex.williamson@redhat.com, jgg@nvidia.com, kevin.tian@intel.com
Cc: linux-s390@vger.kernel.org, yi.l.liu@intel.com,
yi.y.sun@linux.intel.com, mjrosato@linux.ibm.com,
kvm@vger.kernel.org, intel-gvt-dev@lists.freedesktop.org,
joro@8bytes.org, cohuck@redhat.com, xudong.hao@intel.com,
peterx@redhat.com, yan.y.zhao@intel.com, eric.auger@redhat.com,
terrence.xu@intel.com, nicolinc@nvidia.com,
shameerali.kolothum.thodi@huawei.com,
suravee.suthikulpanit@amd.com, intel-gfx@lists.freedesktop.org,
chao.p.peng@linux.intel.com, lulu@redhat.com,
robin.murphy@arm.com, jasowang@redhat.com
Subject: [Intel-gfx] [PATCH v1 3/5] vfio-iommufd: Make vfio_iommufd_emulated_bind() return iommufd_access ID
Date: Wed, 8 Mar 2023 05:13:38 -0800 [thread overview]
Message-ID: <20230308131340.459224-4-yi.l.liu@intel.com> (raw)
In-Reply-To: <20230308131340.459224-1-yi.l.liu@intel.com>
vfio device cdev needs to return iommufd_access ID to userspace if
bind_iommufd succeeds.
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
---
drivers/iommu/iommufd/device.c | 4 +++-
drivers/iommu/iommufd/selftest.c | 3 ++-
drivers/vfio/iommufd.c | 2 +-
include/linux/iommufd.h | 2 +-
4 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index 71c4d38994b3..9087cd8ed3ea 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -426,6 +426,7 @@ void iommufd_access_destroy_object(struct iommufd_object *obj)
* @ioas_id: ID for a IOMMUFD_OBJ_IOAS
* @ops: Driver's ops to associate with the access
* @data: Opaque data to pass into ops functions
+ * @id: Output ID number to return to userspace for this access
*
* An iommufd_access allows a driver to read/write to the IOAS without using
* DMA. The underlying CPU memory can be accessed using the
@@ -435,7 +436,7 @@ void iommufd_access_destroy_object(struct iommufd_object *obj)
*/
struct iommufd_access *
iommufd_access_create(struct iommufd_ctx *ictx,
- const struct iommufd_access_ops *ops, void *data)
+ const struct iommufd_access_ops *ops, void *data, u32 *id)
{
struct iommufd_access *access;
@@ -461,6 +462,7 @@ iommufd_access_create(struct iommufd_ctx *ictx,
access->ictx = ictx;
iommufd_ctx_get(ictx);
iommufd_object_finalize(ictx, &access->obj);
+ *id = access->obj.id;
return access;
}
EXPORT_SYMBOL_NS_GPL(iommufd_access_create, IOMMUFD);
diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
index db4011bdc8a9..b796fd13a417 100644
--- a/drivers/iommu/iommufd/selftest.c
+++ b/drivers/iommu/iommufd/selftest.c
@@ -554,6 +554,7 @@ static int iommufd_test_create_access(struct iommufd_ucmd *ucmd,
struct iommu_test_cmd *cmd = ucmd->cmd;
struct selftest_access *staccess;
struct iommufd_access *access;
+ u32 id;
int fdno;
int rc;
@@ -575,7 +576,7 @@ static int iommufd_test_create_access(struct iommufd_ucmd *ucmd,
(flags & MOCK_FLAGS_ACCESS_CREATE_NEEDS_PIN_PAGES) ?
&selftest_access_ops_pin :
&selftest_access_ops,
- staccess);
+ staccess, &id);
if (IS_ERR(access)) {
rc = PTR_ERR(access);
goto out_put_fdno;
diff --git a/drivers/vfio/iommufd.c b/drivers/vfio/iommufd.c
index b55f94271cc7..7a4458a10656 100644
--- a/drivers/vfio/iommufd.c
+++ b/drivers/vfio/iommufd.c
@@ -142,7 +142,7 @@ int vfio_iommufd_emulated_bind(struct vfio_device *vdev,
lockdep_assert_held(&vdev->dev_set->lock);
- user = iommufd_access_create(ictx, &vfio_user_ops, vdev);
+ user = iommufd_access_create(ictx, &vfio_user_ops, vdev, out_device_id);
if (IS_ERR(user))
return PTR_ERR(user);
vdev->iommufd_access = user;
diff --git a/include/linux/iommufd.h b/include/linux/iommufd.h
index 247b11609c79..365f11e8e615 100644
--- a/include/linux/iommufd.h
+++ b/include/linux/iommufd.h
@@ -41,7 +41,7 @@ enum {
struct iommufd_access *
iommufd_access_create(struct iommufd_ctx *ictx,
- const struct iommufd_access_ops *ops, void *data);
+ const struct iommufd_access_ops *ops, void *data, u32 *id);
void iommufd_access_destroy(struct iommufd_access *access);
int iommufd_access_set_ioas(struct iommufd_access *access, u32 ioas_id);
--
2.34.1
next prev parent reply other threads:[~2023-03-08 13:14 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 13:13 [Intel-gfx] [PATCH v1 0/5] vfio: Make emulated devices prepared for vfio device cdev Yi Liu
2023-03-08 13:13 ` [Intel-gfx] [PATCH v1 1/5] iommufd: Create access in vfio_iommufd_emulated_bind() Yi Liu
2023-03-10 2:08 ` Tian, Kevin
2023-03-14 18:50 ` Nicolin Chen
2023-03-15 6:16 ` Tian, Kevin
2023-03-15 6:21 ` Nicolin Chen
2023-03-15 6:52 ` Tian, Kevin
2023-03-15 8:52 ` Liu, Yi L
2023-03-16 0:17 ` Tian, Kevin
2023-03-16 0:28 ` Nicolin Chen
2023-03-10 17:36 ` Jason Gunthorpe
2023-03-14 8:20 ` Nicolin Chen
2023-03-15 1:01 ` Nicolin Chen
2023-03-15 6:15 ` Tian, Kevin
2023-03-15 6:32 ` Nicolin Chen
2023-03-15 6:50 ` Tian, Kevin
2023-03-15 9:03 ` Nicolin Chen
2023-03-15 12:18 ` Liu, Yi L
2023-03-16 0:32 ` Nicolin Chen
2023-03-16 2:53 ` Tian, Kevin
2023-03-16 3:25 ` Nicolin Chen
2023-03-16 5:33 ` Nicolin Chen
2023-03-16 5:38 ` Tian, Kevin
2023-03-16 5:43 ` Nicolin Chen
2023-03-16 5:49 ` Tian, Kevin
2023-03-16 5:56 ` Nicolin Chen
2023-03-16 6:01 ` Liu, Yi L
2023-03-20 14:49 ` Jason Gunthorpe
2023-03-20 15:11 ` Yi Liu
2023-03-20 15:33 ` Jason Gunthorpe
2023-03-08 13:13 ` [Intel-gfx] [PATCH v1 2/5] vfio-iommufd: No need to record iommufd_ctx in vfio_device Yi Liu
2023-03-10 17:37 ` Jason Gunthorpe
2023-03-08 13:13 ` Yi Liu [this message]
2023-03-10 2:08 ` [Intel-gfx] [PATCH v1 3/5] vfio-iommufd: Make vfio_iommufd_emulated_bind() return iommufd_access ID Tian, Kevin
2023-03-10 17:37 ` Jason Gunthorpe
2023-03-08 13:13 ` [Intel-gfx] [PATCH v1 4/5] Samples/mdev: Uses the vfio emulated iommufd ops set in the mdev sample drivers Yi Liu
2023-03-10 2:10 ` Tian, Kevin
2023-03-10 17:39 ` Jason Gunthorpe
2023-03-08 13:13 ` [Intel-gfx] [PATCH v1 5/5] vfio: Check the presence for iommufd callbacks in __vfio_register_dev() Yi Liu
2023-03-10 2:15 ` Tian, Kevin
2023-03-10 14:04 ` Jason Gunthorpe
2023-03-10 14:12 ` Liu, Yi L
2023-03-10 15:25 ` Jason Gunthorpe
2023-03-13 1:49 ` Tian, Kevin
2023-03-10 17:39 ` Jason Gunthorpe
2023-03-15 12:15 ` Liu, Yi L
2023-03-08 14:28 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for vfio: Make emulated devices prepared for vfio device cdev Patchwork
2023-03-08 14:54 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2023-03-15 6:25 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for vfio: Make emulated devices prepared for vfio device cdev (rev2) Patchwork
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=20230308131340.459224-4-yi.l.liu@intel.com \
--to=yi.l.liu@intel.com \
--cc=alex.williamson@redhat.com \
--cc=chao.p.peng@linux.intel.com \
--cc=cohuck@redhat.com \
--cc=eric.auger@redhat.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=jasowang@redhat.com \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=lulu@redhat.com \
--cc=mjrosato@linux.ibm.com \
--cc=nicolinc@nvidia.com \
--cc=peterx@redhat.com \
--cc=robin.murphy@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=terrence.xu@intel.com \
--cc=xudong.hao@intel.com \
--cc=yan.y.zhao@intel.com \
--cc=yi.y.sun@linux.intel.com \
/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).