Re: [PATCH 0/6] iommu/amd: Refactors for ATS updates
From: Vasant Hegde
Date: Thu Jun 04 2026 - 04:32:21 EST
Jason,
On 6/2/2026 5:38 PM, Jason Gunthorpe wrote:
> 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.
Digging into git history and how its all evolved, I agree. We should fix up
find_dev_data() stuff. we should separate out search from allocation. I will add
separate fix once this series settles.
-Vasant