Re: [PATCH v3 19/22] iommu/amd: Add per-segment translate device ID pool

From: Jason Gunthorpe

Date: Tue Jul 07 2026 - 10:54:29 EST


On Mon, Jun 29, 2026 at 03:35:32PM +0000, Suravee Suthikulpanit wrote:
> Track translate-device-id slots per PCI segment so real PCI device IDs can
> be reserved for normal DTE programming and excluded from dynamic allocation
> for vIOMMU translation DTEs.

Why does it have to be per segment? The segment is encoded in the
devid isn't it?

This seems like a sketchy design to me, is it impossible to atomically
change the viommu used devids once they start being used? It seems
like this should be doable

If so the algorithm would be simpler, just maintain an xarray of all
dev ids, if the entry is marked as a VIOMMU and PCI needs it then move
the VIOMMU out of the way and use the entry for PCI.

No need to try to guess what ranges are usable or not.

Jason