Re: [PATCH v7 02/19] iommufd: Add iommufd_group

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 16, 2023 at 10:43:23AM +0800, Baolu Lu wrote:
> On 5/15/23 10:00 PM, Jason Gunthorpe wrote:
> >   void iommufd_device_destroy(struct iommufd_object *obj)
> >   {
> >   	struct iommufd_device *idev =
> >   		container_of(obj, struct iommufd_device, obj);
> >   	iommu_device_release_dma_owner(idev->dev);
> > -	iommu_group_put(idev->group);
> > +	iommufd_put_group(idev->igroup);
> >   	if (!iommufd_selftest_is_mock_dev(idev->dev))
> >   		iommufd_ctx_put(idev->ictx);
> >   }
> > @@ -46,7 +154,7 @@ struct iommufd_device *iommufd_device_bind(struct iommufd_ctx *ictx,
> >   					   struct device *dev, u32 *id)
> >   {
> >   	struct iommufd_device *idev;
> > -	struct iommu_group *group;
> > +	struct iommufd_group *igroup;
> >   	int rc;
> >   	/*
> > @@ -56,9 +164,9 @@ struct iommufd_device *iommufd_device_bind(struct iommufd_ctx *ictx,
> >   	if (!device_iommu_capable(dev, IOMMU_CAP_CACHE_COHERENCY))
> >   		return ERR_PTR(-EINVAL);
> > -	group = iommu_group_get(dev);
> > -	if (!group)
> > -		return ERR_PTR(-ENODEV);
> > +	igroup = iommufd_get_group(ictx, dev);
> > +	if (IS_ERR(igroup))
> > +		return ERR_CAST(igroup);
> >   	/*
> >   	 * For historical compat with VFIO the insecure interrupt path is
> 
> Hi Jason,
> 
> Perhaps I am asking a silly question. The iommufd_group is get in
> iommufd_device_bind(), but put in iommufd_device_destroy(). Why not put
> it in iommufd_device_unbind()?

It basically is like that, iommufd_device_destroy() is a helper that
is only called by iommufd_device_unbind() through the usual
destruction mechanism.

Jason



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux