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

From: Jason Gunthorpe

Date: Tue Jul 07 2026 - 10:57:33 EST


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

> 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

Jason