Re: [PATCH v3 20/22] iommu/amd: Reserve translate-device-id for PCI requestor aliases

"Suthikulpanit, Suravee" <[email protected]>
Newsgroups dev.linux.lists.iommu,org.kernel.vger.linux-kernel
Message-ID <[email protected]>

On 7/7/2026 9:39 PM, Jason Gunthorpe wrote:
> On Mon, Jun 29, 2026 at 03:35:33PM +0000, Suravee Suthikulpanit wrote:
>> The per-segment translate-device-id (trans_devid) pool hands out numeric
>> device-table indices used by the AMD vIOMMU / iommufd path (e.g. mapping a
>> KVM file descriptor to a shared trans_devid).
> 
> Nothing to do with kvm

Noted. I'll update this in v4.

>> Introduce amd_iommu_trans_devid_reserve_pci_aliases() in trans_devid.c and
>> invoke it from amd_iommu_attach_device() immediately after the primary
>> amd_iommu_trans_devid_reserve() succeeds.  For PCI devices the helper
>> reserves the IVRS alias when it differs from the device BDF, then walks
>> pci_for_each_dma_alias() and reserves each alias BDF.  Repeated attach and
>> overlap with the primary BDF in the PCI walk are handled by the existing
>> idempotency of amd_iommu_trans_devid_reserve() (a second reserve of an
>> already-reserved id succeeds).
> 
> It would be so nice if the AMD driver could get fixed up to work more
> like ARM with the alais devids.
> 
> ie on probe you allocate an array of all the alias dev ids, fill it in
> with the information from PCI and then never touch the PCI again.
> 
> Then you'd just dump the whole array into the allocator in one clean
> shot and this would all be simpler.
> 
> Instead we have these endless pci walks every where :\
> 
> But its fine like this I suppose

I agree. Let me look into this in following this series, and propose change.

Thanks,
Suravee
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.