]> git.ipfire.org Git - thirdparty/linux.git/commit
iommu: Generic support for RMRs during device release
authorJason Gunthorpe <jgg@nvidia.com>
Thu, 23 Oct 2025 02:21:04 +0000 (19:21 -0700)
committerJoerg Roedel <joerg.roedel@amd.com>
Mon, 27 Oct 2025 12:55:34 +0000 (13:55 +0100)
commite94160488e65ef801d27c1b626fb1632c16e7d56
tree3faff8e2e433f9ddca2b5058123db53b0d54992f
parentdb340b02b27c7bd7e5e9a55c700058a7789d8935
iommu: Generic support for RMRs during device release

Generally an IOMMU driver should leave the translation as BLOCKED until the
translation entry is probed onto a struct device. When the struct device is
removed, the translation should be put back to BLOCKED.

Drivers that are able to work like this can set their release_domain to the
blocking domain, and the core code handles this work.

The exception is when the device has an IOMMU_RESV_DIRECT region, in which
case the OS should continuously allow translations for the given range. And
the core code generally prevents using a BLOCKED domain with this device.

Continue this logic for the device release and hoist some open coding from
drivers. If the device has dev->iommu->require_direct and the driver uses a
BLOCKED release_domain, override it to IDENTITY to preserve the semantics.

The only remaining required driver code for IOMMU_RESV_DIRECT should preset
an IDENTITY translation during early IOMMU startup for those devices.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/iommu.c