[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aHVGdG275Kcf14uJ@yilunxu-OptiPlex-7050>
Date: Tue, 15 Jul 2025 02:03:32 +0800
From: Xu Yilun <yilun.xu@...ux.intel.com>
To: Nicolin Chen <nicolinc@...dia.com>
Cc: Jason Gunthorpe <jgg@...dia.com>, kevin.tian@...el.com, will@...nel.org,
aneesh.kumar@...nel.org, iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org, joro@...tes.org, robin.murphy@....com,
shuah@...nel.org, aik@....com, dan.j.williams@...el.com,
baolu.lu@...ux.intel.com, yilun.xu@...el.com
Subject: Re: [PATCH v4 4/7] iommufd: Destroy vdevice on idevice destroy
On Mon, Jul 14, 2025 at 10:34:21AM -0700, Nicolin Chen wrote:
> On Mon, Jul 14, 2025 at 01:53:46PM -0300, Jason Gunthorpe wrote:
> > On Tue, Jul 15, 2025 at 12:40:40AM +0800, Xu Yilun wrote:
> > > diff --git a/drivers/iommu/iommufd/viommu.c b/drivers/iommu/iommufd/viommu.c
> > > index 702ae248df17..bdd5a5227cbf 100644
> > > --- a/drivers/iommu/iommufd/viommu.c
> > > +++ b/drivers/iommu/iommufd/viommu.c
> > > @@ -128,7 +128,8 @@ void iommufd_vdevice_destroy(struct iommufd_object *obj)
> > > mutex_lock(&idev->igroup->lock);
> > > iommufd_vdevice_abort(obj);
> > > mutex_unlock(&idev->igroup->lock);
> > > - iommufd_put_object(idev->ictx, &idev->obj);
> > > + refcount_dec(&idev->obj.shortterm_users);
> > > + wake_up_interruptible_all(&vdev->viommu->ictx->destroy_wait);
> > > }
> >
> > I think the main point of keeping both refcounts is to keep the above
> > hidden in the main functions and out of the object functions.
>
> I see. Maybe we can just update the comments that we are keeping
> both refcounts but using shortterm_users only to do the trick.
I don't think we need special comments. The new usage is not a trick.
It follows the existing mechanism of iommufd_get/put_object().
https://lore.kernel.org/linux-iommu/20250707122502.GS1410929@nvidia.com/
Adding a patch to rename shortterm_users -> wait_cnt should make
thing clear.
Thanks,
Yilun
>
> Otherwise, we'd need an iommufd_lock_obj_shortterm..
>
> Thanks
> Nicolin
Powered by blists - more mailing lists