[PATCH 10/11] iommu: Split iommu_group_add_device()

Jason Gunthorpe jgg at nvidia.com
Thu Apr 20 23:09:02 AEST 2023


On Thu, Apr 20, 2023 at 12:25:11PM +0800, Baolu Lu wrote:
> On 4/20/23 12:11 AM, Jason Gunthorpe wrote:
> > @@ -451,16 +454,17 @@ static int __iommu_probe_device(struct device *dev, struct list_head *group_list
> >   		goto out_unlock;
> >   	group = dev->iommu_group;
> > -	ret = iommu_group_add_device(group, dev);
> > +	gdev = iommu_group_alloc_device(group, dev);
> >   	mutex_lock(&group->mutex);
> > -	if (ret)
> > +	if (IS_ERR(gdev)) {
> > +		ret = PTR_ERR(gdev);
> >   		goto err_put_group;
> > +	}
> > +	list_add_tail(&gdev->list, &group->devices);
> 
> Do we need to put
> 
> 	dev->iommu_group = group;
> 
> here?

It is done in iommu_init_driver() and iommu_deinit_driver() NULL's it

	group = ops->device_group(dev);
	if (WARN_ON_ONCE(group == NULL))
		group = ERR_PTR(-EINVAL);
	if (IS_ERR(group)) {
		ret = PTR_ERR(group);
		goto err_unlink;
	}
	dev->iommu_group = group;

Jason


More information about the Linuxppc-dev mailing list