Re: [PATCH v5] iommu/amd: Enable PerfOpt automatically for integrated GPUs
From: Jason Gunthorpe
Date: Wed Nov 18 2026 - 13:51:08 EST
> PerfOpt is usable by integrated GPUs in identity mode. Enable it from
> the IOMMU driver's domain attachment paths instead of requiring an
> amdgpu policy knob and exported enable/disable interfaces.
>
> Mark supported integrated GPUs as PerfOpt-eligible when selecting their
> default identity domain. Skip GCR3 setup and ATS/PRI/PASID enablement for
> these identity attachments, then enable PerfOpt after installing the DTE.
> Clear PerfOpt before attaching an eligible GPU to a translated or blocked
> domain, including unmanaged domains used by VFIO. Propagate failures to
> clear bypass, but keep a completed identity attachment successful if the
> optional PerfOpt enable fails.
>
> Clear inherited PerfOpt state during initialization, including when a crash
> kernel reuses device tables. Read feature support directly from hardware
> because cached features may not be available yet, and stop initialization
> if the initial clear fails.
>
> Each IOMMU has at most one PerfOpt-eligible GPU, so track activation with a
> boolean under the IOMMU lock. Preserve this state while clearing hardware
> at suspend and shutdown, and restore the bit on resume only where it was
> active. Do not enable PerfOpt unconditionally during early IOMMU
> initialization.
>
> Remove the amdgpu parameter, driver callbacks, and exported interfaces.
> Translated attachments retain their normal device capability setup.
>
> Suggested-by: Jason Gunthorpe <jgg@xxxxxxxx>
> Signed-off-by: Mario Limonciello (AMD) <superm1@xxxxxxxxxx>
> ---
> Changes in v5:
> * Enable PerfOpt after identity attachment instead of during early IOMMU init
> * Clear PerfOpt before translated or blocked attachments, allowing VFIO use
> * Drop require_direct and retain normal capability setup for translated domains
> * Replace refcounting with a per-IOMMU activation boolean protected by its lock
> * Clear inherited PerfOpt during init, including crash-kernel device-table reuse
> * Read hardware feature support before cached features are available and fail
> initialization if the initial clear fails
> * Preserve activation across suspend and restore it on resume only if active
> * Keep identity attachment successful if optional PerfOpt enablement fails
> * Link to v4: https://lore.kernel.org/linux-iommu/20261001182410.1525285-1-superm1@xxxxxxxxxx/
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 -
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 50 ------
> drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 --
> drivers/iommu/amd/amd_iommu.h | 3 +-
> drivers/iommu/amd/amd_iommu_types.h | 6 +-
> drivers/iommu/amd/init.c | 91 ++++++-----
> drivers/iommu/amd/iommu.c | 252 +++++------------------------
> include/linux/amd-iommu.h | 11 --
> 8 files changed, 95 insertions(+), 331 deletions(-)
Vasant are you going to pick this up? It seems good to me
Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
--
Jason