Re: [PATCH 0/6] iommu/amd: Refactors for ATS updates

From: Jason Gunthorpe

Date: Tue Jun 02 2026 - 08:17:38 EST


On Tue, Jun 02, 2026 at 02:19:54PM +0530, Vasant Hegde wrote:
> -static int iommu_init_device(struct amd_iommu *iommu, struct device *dev)
> +static struct iommu_dev_data *iommu_init_device(struct amd_iommu *iommu,
> + struct device *dev, u16 devid)
> {
> struct iommu_dev_data *dev_data;
> - int devid, sbdf;
> -
> - if (dev_iommu_priv_get(dev))
> - return 0;
>
> - sbdf = get_device_sbdf_id(dev);
> - if (sbdf < 0)
> - return sbdf;
> -
> - devid = PCI_SBDF_TO_DEVID(sbdf);
> dev_data = find_dev_data(iommu, devid);
> if (!dev_data)
> - return -ENOMEM;
> + return ERR_PTR(-ENOMEM);

Why does the AMD driver do this? The dev data is supposed to be
allocated during probe and freed during remove, it doesn't make sense
to search for it in probe - it should not exist if the kernel is
working right.

Jason