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]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux