On 10/23/25 10:21, Nicolin Chen wrote:
The IOMMU core attaches each device to a default domain on probe(). Then,
every new "attach" operation has a fundamental meaning of two-fold:
  - detach from its currently attached (old) domain
  - attach to a given new domain

Modern IOMMU drivers following this pattern usually want to clean up the
things related to the old domain, so they call iommu_get_domain_for_dev()
to fetch the old domain.

Pass in the old domain pointer from the core to drivers, aligning with the
set_dev_pasid op that does so already.

Ensure all low-level attach fcuntions in the core can forward the correct
old domain pointer. Thus, rework those functions as well.

Suggested-by: Jason Gunthorpe<[email protected]>
Reviewed-by: Kevin Tian<[email protected]>
Reviewed-by: Jason Gunthorpe<[email protected]>
Signed-off-by: Nicolin Chen<[email protected]>
---
  include/linux/iommu.h                         |  3 ++-
  arch/powerpc/kernel/iommu.c                   |  5 ++--
  drivers/iommu/amd/iommu.c                     | 11 ++++----
  drivers/iommu/apple-dart.c                    |  9 ++++---
  .../arm/arm-smmu-v3/arm-smmu-v3-iommufd.c     |  5 ++--
  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c   | 24 +++++++++++-------
  drivers/iommu/arm/arm-smmu/arm-smmu.c         |  9 ++++---
  drivers/iommu/arm/arm-smmu/qcom_iommu.c       | 11 ++++----
  drivers/iommu/exynos-iommu.c                  |  8 +++---
  drivers/iommu/fsl_pamu_domain.c               | 12 ++++-----
  drivers/iommu/intel/iommu.c                   | 10 +++++---
  drivers/iommu/intel/nested.c                  |  2 +-
  drivers/iommu/iommu.c                         | 25 +++++++++++--------
  drivers/iommu/iommufd/selftest.c              |  2 +-
  drivers/iommu/ipmmu-vmsa.c                    | 10 ++++----
  drivers/iommu/msm_iommu.c                     | 11 ++++----
  drivers/iommu/mtk_iommu.c                     |  8 +++---
  drivers/iommu/mtk_iommu_v1.c                  |  7 ++++--
  drivers/iommu/omap-iommu.c                    | 12 ++++-----
  drivers/iommu/riscv/iommu.c                   |  9 ++++---
  drivers/iommu/rockchip-iommu.c                | 20 +++++++++++----
  drivers/iommu/s390-iommu.c                    | 13 ++++++----
  drivers/iommu/sprd-iommu.c                    |  3 ++-
  drivers/iommu/sun50i-iommu.c                  |  8 +++---
  drivers/iommu/tegra-smmu.c                    | 10 ++++----
  drivers/iommu/virtio-iommu.c                  |  6 +++--
  26 files changed, 153 insertions(+), 100 deletions(-)

Reviewed-by: Lu Baolu <[email protected]>

Reply via email to