From: Nicolin Chen <nicolinc@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>, "Liu, Yi L" <yi.l.liu@intel.com>
Cc: "mjrosato@linux.ibm.com" <mjrosato@linux.ibm.com>,
"jasowang@redhat.com" <jasowang@redhat.com>,
"Hao, Xudong" <xudong.hao@intel.com>,
"peterx@redhat.com" <peterx@redhat.com>,
"Xu, Terrence" <terrence.xu@intel.com>,
"chao.p.peng@linux.intel.com" <chao.p.peng@linux.intel.com>,
"linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"lulu@redhat.com" <lulu@redhat.com>,
"joro@8bytes.org" <joro@8bytes.org>,
"jgg@nvidia.com" <jgg@nvidia.com>,
"Zhao, Yan Y" <yan.y.zhao@intel.com>,
"intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>,
"eric.auger@redhat.com" <eric.auger@redhat.com>,
"alex.williamson@redhat.com" <alex.williamson@redhat.com>,
"intel-gvt-dev@lists.freedesktop.org"
<intel-gvt-dev@lists.freedesktop.org>,
"yi.y.sun@linux.intel.com" <yi.y.sun@linux.intel.com>,
"cohuck@redhat.com" <cohuck@redhat.com>,
"shameerali.kolothum.thodi@huawei.com"
<shameerali.kolothum.thodi@huawei.com>,
"suravee.suthikulpanit@amd.com" <suravee.suthikulpanit@amd.com>,
"robin.murphy@arm.com" <robin.murphy@arm.com>
Subject: Re: [PATCH v1 1/5] iommufd: Create access in vfio_iommufd_emulated_bind()
Date: Tue, 14 Mar 2023 23:21:36 -0700 [thread overview]
Message-ID: <ZBFj8AZ4gWOW1PQs@Asurada-Nvidia> (raw)
In-Reply-To: <BN9PR11MB52766160C546FA5075B191258CBF9@BN9PR11MB5276.namprd11.prod.outlook.com>
On Wed, Mar 15, 2023 at 06:16:37AM +0000, Tian, Kevin wrote:
> External email: Use caution opening links or attachments
>
>
> > From: Nicolin Chen
> > Sent: Wednesday, March 15, 2023 2:51 AM
> >
> > On Fri, Mar 10, 2023 at 02:08:15AM +0000, Tian, Kevin wrote:
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > > From: Liu, Yi L <yi.l.liu@intel.com>
> > > > Sent: Wednesday, March 8, 2023 9:14 PM
> > > >
> > > > @@ -449,33 +450,18 @@ iommufd_access_create(struct iommufd_ctx
> > *ictx,
> > > > u32 ioas_id,
> > > > access->data = data;
> > > > access->ops = ops;
> > > >
> > > > - obj = iommufd_get_object(ictx, ioas_id, IOMMUFD_OBJ_IOAS);
> > > > - if (IS_ERR(obj)) {
> > > > - rc = PTR_ERR(obj);
> > > > - goto out_abort;
> > > > - }
> > > > - access->ioas = container_of(obj, struct iommufd_ioas, obj);
> > > > - iommufd_ref_to_users(obj);
> > > > -
> > > > if (ops->needs_pin_pages)
> > > > access->iova_alignment = PAGE_SIZE;
> > > > else
> > > > access->iova_alignment = 1;
> > > > - rc = iopt_add_access(&access->ioas->iopt, access);
> > > > - if (rc)
> > > > - goto out_put_ioas;
> > > >
> > > > /* The calling driver is a user until iommufd_access_destroy() */
> > > > refcount_inc(&access->obj.users);
> > > > + mutex_init(&access->ioas_lock);
> > > > access->ictx = ictx;
> > > > iommufd_ctx_get(ictx);
> > >
> > > this refcnt get should be moved to the start given next patch
> > > removes the reference in the caller side.
> >
> > I don't feel quite convincing to justify for moving it in this
> > patch. Perhaps we should do that in the following patch, where
> > it needs this? Or another individual patch moving this alone?
> >
>
> Next patch. I just tried to point out the required change caused
> by next patch. 😊
OK. I made a small individual patch. Posting here so Yi can just
squash it into the next patch:
From dbfe7457d35ea9a4da9c8e6daa838b101bc8f621 Mon Sep 17 00:00:00 2001
From: Nicolin Chen <nicolinc@nvidia.com>
Date: Tue, 14 Mar 2023 12:51:07 -0700
Subject: [PATCH] iommufd/device: Do iommufd_ctx_get() at the top of
iommufd_access_create()
The following patch will remove the iommufd_ctx_get() call prior to the
iommufd_access_create() call in vfio_iommufd_emulated_bind(), expecting
iommufd_access_create() call covers the iommufd_ctx_get(). However, the
iommufd_access_create() only does iommufd_ctx_get() at the end. Thus,
move the iommufd_ctx_get() call to the top of iommufd_access_create().
Suggested-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
drivers/iommu/iommufd/device.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index 0132803449be..dc1015b02a53 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -649,13 +649,16 @@ iommufd_access_create(struct iommufd_ctx *ictx,
{
struct iommufd_access *access;
+ iommufd_ctx_get(ictx);
/*
* There is no uAPI for the access object, but to keep things symmetric
* use the object infrastructure anyhow.
*/
access = iommufd_object_alloc(ictx, access, IOMMUFD_OBJ_ACCESS);
- if (IS_ERR(access))
+ if (IS_ERR(access)) {
+ iommufd_ctx_put(ictx);
return access;
+ }
access->data = data;
access->ops = ops;
@@ -668,7 +671,6 @@ iommufd_access_create(struct iommufd_ctx *ictx,
/* The calling driver is a user until iommufd_access_destroy() */
refcount_inc(&access->obj.users);
access->ictx = ictx;
- iommufd_ctx_get(ictx);
iommufd_object_finalize(ictx, &access->obj);
return access;
}
--
2.39.2
WARNING: multiple messages have this Message-ID (diff)
From: Nicolin Chen <nicolinc@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>, "Liu, Yi L" <yi.l.liu@intel.com>
Cc: "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
"suravee.suthikulpanit@amd.com" <suravee.suthikulpanit@amd.com>,
"Zhao, Yan Y" <yan.y.zhao@intel.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"mjrosato@linux.ibm.com" <mjrosato@linux.ibm.com>,
"intel-gvt-dev@lists.freedesktop.org"
<intel-gvt-dev@lists.freedesktop.org>,
"jasowang@redhat.com" <jasowang@redhat.com>,
"cohuck@redhat.com" <cohuck@redhat.com>,
"Hao, Xudong" <xudong.hao@intel.com>,
"robin.murphy@arm.com" <robin.murphy@arm.com>,
"peterx@redhat.com" <peterx@redhat.com>,
"eric.auger@redhat.com" <eric.auger@redhat.com>,
"Xu, Terrence" <terrence.xu@intel.com>,
"yi.y.sun@linux.intel.com" <yi.y.sun@linux.intel.com>,
"shameerali.kolothum.thodi@huawei.com"
<shameerali.kolothum.thodi@huawei.com>,
"jgg@nvidia.com" <jgg@nvidia.com>,
"chao.p.peng@linux.intel.com" <chao.p.peng@linux.intel.com>,
"lulu@redhat.com" <lulu@redhat.com>,
"intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>,
"joro@8bytes.org" <joro@8bytes.org>
Subject: Re: [Intel-gfx] [PATCH v1 1/5] iommufd: Create access in vfio_iommufd_emulated_bind()
Date: Tue, 14 Mar 2023 23:21:36 -0700 [thread overview]
Message-ID: <ZBFj8AZ4gWOW1PQs@Asurada-Nvidia> (raw)
In-Reply-To: <BN9PR11MB52766160C546FA5075B191258CBF9@BN9PR11MB5276.namprd11.prod.outlook.com>
On Wed, Mar 15, 2023 at 06:16:37AM +0000, Tian, Kevin wrote:
> External email: Use caution opening links or attachments
>
>
> > From: Nicolin Chen
> > Sent: Wednesday, March 15, 2023 2:51 AM
> >
> > On Fri, Mar 10, 2023 at 02:08:15AM +0000, Tian, Kevin wrote:
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > > From: Liu, Yi L <yi.l.liu@intel.com>
> > > > Sent: Wednesday, March 8, 2023 9:14 PM
> > > >
> > > > @@ -449,33 +450,18 @@ iommufd_access_create(struct iommufd_ctx
> > *ictx,
> > > > u32 ioas_id,
> > > > access->data = data;
> > > > access->ops = ops;
> > > >
> > > > - obj = iommufd_get_object(ictx, ioas_id, IOMMUFD_OBJ_IOAS);
> > > > - if (IS_ERR(obj)) {
> > > > - rc = PTR_ERR(obj);
> > > > - goto out_abort;
> > > > - }
> > > > - access->ioas = container_of(obj, struct iommufd_ioas, obj);
> > > > - iommufd_ref_to_users(obj);
> > > > -
> > > > if (ops->needs_pin_pages)
> > > > access->iova_alignment = PAGE_SIZE;
> > > > else
> > > > access->iova_alignment = 1;
> > > > - rc = iopt_add_access(&access->ioas->iopt, access);
> > > > - if (rc)
> > > > - goto out_put_ioas;
> > > >
> > > > /* The calling driver is a user until iommufd_access_destroy() */
> > > > refcount_inc(&access->obj.users);
> > > > + mutex_init(&access->ioas_lock);
> > > > access->ictx = ictx;
> > > > iommufd_ctx_get(ictx);
> > >
> > > this refcnt get should be moved to the start given next patch
> > > removes the reference in the caller side.
> >
> > I don't feel quite convincing to justify for moving it in this
> > patch. Perhaps we should do that in the following patch, where
> > it needs this? Or another individual patch moving this alone?
> >
>
> Next patch. I just tried to point out the required change caused
> by next patch. 😊
OK. I made a small individual patch. Posting here so Yi can just
squash it into the next patch:
From dbfe7457d35ea9a4da9c8e6daa838b101bc8f621 Mon Sep 17 00:00:00 2001
From: Nicolin Chen <nicolinc@nvidia.com>
Date: Tue, 14 Mar 2023 12:51:07 -0700
Subject: [PATCH] iommufd/device: Do iommufd_ctx_get() at the top of
iommufd_access_create()
The following patch will remove the iommufd_ctx_get() call prior to the
iommufd_access_create() call in vfio_iommufd_emulated_bind(), expecting
iommufd_access_create() call covers the iommufd_ctx_get(). However, the
iommufd_access_create() only does iommufd_ctx_get() at the end. Thus,
move the iommufd_ctx_get() call to the top of iommufd_access_create().
Suggested-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
drivers/iommu/iommufd/device.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index 0132803449be..dc1015b02a53 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -649,13 +649,16 @@ iommufd_access_create(struct iommufd_ctx *ictx,
{
struct iommufd_access *access;
+ iommufd_ctx_get(ictx);
/*
* There is no uAPI for the access object, but to keep things symmetric
* use the object infrastructure anyhow.
*/
access = iommufd_object_alloc(ictx, access, IOMMUFD_OBJ_ACCESS);
- if (IS_ERR(access))
+ if (IS_ERR(access)) {
+ iommufd_ctx_put(ictx);
return access;
+ }
access->data = data;
access->ops = ops;
@@ -668,7 +671,6 @@ iommufd_access_create(struct iommufd_ctx *ictx,
/* The calling driver is a user until iommufd_access_destroy() */
refcount_inc(&access->obj.users);
access->ictx = ictx;
- iommufd_ctx_get(ictx);
iommufd_object_finalize(ictx, &access->obj);
return access;
}
--
2.39.2
next prev parent reply other threads:[~2023-03-15 6:22 UTC|newest]
Thread overview: 95+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 13:13 [PATCH v1 0/5] vfio: Make emulated devices prepared for vfio device cdev Yi Liu
2023-03-08 13:13 ` [Intel-gfx] " Yi Liu
2023-03-08 13:13 ` [PATCH v1 1/5] iommufd: Create access in vfio_iommufd_emulated_bind() Yi Liu
2023-03-08 13:13 ` [Intel-gfx] " Yi Liu
2023-03-10 2:08 ` Tian, Kevin
2023-03-10 2:08 ` [Intel-gfx] " Tian, Kevin
2023-03-14 18:50 ` Nicolin Chen
2023-03-14 18:50 ` [Intel-gfx] " Nicolin Chen
2023-03-15 6:16 ` Tian, Kevin
2023-03-15 6:16 ` [Intel-gfx] " Tian, Kevin
2023-03-15 6:21 ` Nicolin Chen [this message]
2023-03-15 6:21 ` Nicolin Chen
2023-03-15 6:52 ` Tian, Kevin
2023-03-15 6:52 ` [Intel-gfx] " Tian, Kevin
2023-03-15 8:52 ` Liu, Yi L
2023-03-15 8:52 ` [Intel-gfx] " Liu, Yi L
2023-03-16 0:17 ` Tian, Kevin
2023-03-16 0:17 ` [Intel-gfx] " Tian, Kevin
2023-03-16 0:28 ` Nicolin Chen
2023-03-16 0:28 ` [Intel-gfx] " Nicolin Chen
2023-03-10 17:36 ` Jason Gunthorpe
2023-03-10 17:36 ` [Intel-gfx] " Jason Gunthorpe
2023-03-14 8:20 ` Nicolin Chen
2023-03-14 8:20 ` [Intel-gfx] " Nicolin Chen
2023-03-15 1:01 ` Nicolin Chen
2023-03-15 1:01 ` [Intel-gfx] " Nicolin Chen
2023-03-15 6:15 ` Tian, Kevin
2023-03-15 6:15 ` [Intel-gfx] " Tian, Kevin
2023-03-15 6:32 ` Nicolin Chen
2023-03-15 6:32 ` [Intel-gfx] " Nicolin Chen
2023-03-15 6:50 ` Tian, Kevin
2023-03-15 6:50 ` [Intel-gfx] " Tian, Kevin
2023-03-15 9:03 ` Nicolin Chen
2023-03-15 9:03 ` [Intel-gfx] " Nicolin Chen
2023-03-15 12:18 ` Liu, Yi L
2023-03-15 12:18 ` [Intel-gfx] " Liu, Yi L
2023-03-16 0:32 ` Nicolin Chen
2023-03-16 0:32 ` [Intel-gfx] " Nicolin Chen
2023-03-16 2:53 ` Tian, Kevin
2023-03-16 2:53 ` [Intel-gfx] " Tian, Kevin
2023-03-16 3:25 ` Nicolin Chen
2023-03-16 3:25 ` [Intel-gfx] " Nicolin Chen
2023-03-16 5:33 ` Nicolin Chen
2023-03-16 5:33 ` [Intel-gfx] " Nicolin Chen
2023-03-16 5:38 ` Tian, Kevin
2023-03-16 5:38 ` [Intel-gfx] " Tian, Kevin
2023-03-16 5:43 ` Nicolin Chen
2023-03-16 5:43 ` [Intel-gfx] " Nicolin Chen
2023-03-16 5:49 ` Tian, Kevin
2023-03-16 5:49 ` [Intel-gfx] " Tian, Kevin
2023-03-16 5:56 ` Nicolin Chen
2023-03-16 5:56 ` [Intel-gfx] " Nicolin Chen
2023-03-16 6:01 ` Liu, Yi L
2023-03-16 6:01 ` [Intel-gfx] " Liu, Yi L
2023-03-20 14:49 ` Jason Gunthorpe
2023-03-20 14:49 ` [Intel-gfx] " Jason Gunthorpe
2023-03-20 15:11 ` Yi Liu
2023-03-20 15:11 ` [Intel-gfx] " Yi Liu
2023-03-20 15:33 ` Jason Gunthorpe
2023-03-20 15:33 ` [Intel-gfx] " Jason Gunthorpe
2023-03-08 13:13 ` [PATCH v1 2/5] vfio-iommufd: No need to record iommufd_ctx in vfio_device Yi Liu
2023-03-08 13:13 ` [Intel-gfx] " Yi Liu
2023-03-10 17:37 ` Jason Gunthorpe
2023-03-10 17:37 ` [Intel-gfx] " Jason Gunthorpe
2023-03-08 13:13 ` [PATCH v1 3/5] vfio-iommufd: Make vfio_iommufd_emulated_bind() return iommufd_access ID Yi Liu
2023-03-08 13:13 ` [Intel-gfx] " Yi Liu
2023-03-10 2:08 ` Tian, Kevin
2023-03-10 2:08 ` [Intel-gfx] " Tian, Kevin
2023-03-10 17:37 ` Jason Gunthorpe
2023-03-10 17:37 ` [Intel-gfx] " Jason Gunthorpe
2023-03-08 13:13 ` [PATCH v1 4/5] Samples/mdev: Uses the vfio emulated iommufd ops set in the mdev sample drivers Yi Liu
2023-03-08 13:13 ` [Intel-gfx] " Yi Liu
2023-03-10 2:10 ` Tian, Kevin
2023-03-10 2:10 ` [Intel-gfx] " Tian, Kevin
2023-03-10 17:39 ` Jason Gunthorpe
2023-03-10 17:39 ` [Intel-gfx] " Jason Gunthorpe
2023-03-08 13:13 ` [PATCH v1 5/5] vfio: Check the presence for iommufd callbacks in __vfio_register_dev() Yi Liu
2023-03-08 13:13 ` [Intel-gfx] " Yi Liu
2023-03-10 2:15 ` Tian, Kevin
2023-03-10 2:15 ` [Intel-gfx] " Tian, Kevin
2023-03-10 14:04 ` Jason Gunthorpe
2023-03-10 14:04 ` [Intel-gfx] " Jason Gunthorpe
2023-03-10 14:12 ` Liu, Yi L
2023-03-10 14:12 ` [Intel-gfx] " Liu, Yi L
2023-03-10 15:25 ` Jason Gunthorpe
2023-03-10 15:25 ` [Intel-gfx] " Jason Gunthorpe
2023-03-13 1:49 ` Tian, Kevin
2023-03-13 1:49 ` [Intel-gfx] " Tian, Kevin
2023-03-10 17:39 ` Jason Gunthorpe
2023-03-10 17:39 ` [Intel-gfx] " Jason Gunthorpe
2023-03-15 12:15 ` Liu, Yi L
2023-03-15 12:15 ` [Intel-gfx] " 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=ZBFj8AZ4gWOW1PQs@Asurada-Nvidia \
--to=nicolinc@nvidia.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=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.l.liu@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.