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

Baolu Lu
2023-04-20T04:25:25Z

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?

> if (group_list && !group->default_domain && list_empty(&group->entry))
> list_add_tail(&group->entry, group_list);
> mutex_unlock(&group->mutex);
> - iommu_group_put(group);
> -
> mutex_unlock(&iommu_probe_device_lock);
>
> return 0;

Best regards,
baolu