Commit 4ec193a567bf for kernel

commit 4ec193a567bf7f09a7a4b3eae4087ab1571f304e
Author: Arun Iyengar <aiyengar1990@gmail.com>
Date:   Fri Nov 13 20:04:36 2026 +0000

    iommu/vsi: Don't leak a runtime PM reference in the TLB flush

    pm_runtime_get() takes a usage reference even when it fails, e.g. with
    -EINPROGRESS while a resume runs, and vsi_iommu_flush_tlb() then skips
    the put. The IOMMU then never suspends again.

    Flush only an active IOMMU and flush the TLB when the IOMMU is enabled,
    which covers resume.

    Fixes: 917ace84b770 ("iommu: Add verisilicon IOMMU driver")
    Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
    Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
    Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

diff --git a/drivers/iommu/vsi-iommu.c b/drivers/iommu/vsi-iommu.c
index 4a25dc65c8e7..81f51ccf9fc8 100644
--- a/drivers/iommu/vsi-iommu.c
+++ b/drivers/iommu/vsi-iommu.c
@@ -369,7 +369,8 @@ static void vsi_iommu_flush_tlb(struct iommu_domain *domain)
 	struct vsi_iommu *iommu;

 	list_for_each_entry(iommu, &vsi_domain->iommus, node) {
-		if (pm_runtime_get(iommu->dev) < 0)
+		/* A suspended IOMMU is flushed when it resumes */
+		if (pm_runtime_get_if_active(iommu->dev) <= 0)
 			continue;

 		spin_lock(&iommu->lock);
@@ -545,6 +546,8 @@ static void vsi_iommu_enable(struct vsi_iommu *iommu, struct iommu_domain *domai
 	writel(VSI_MMU_OUT_OF_BOUND, iommu->regs + VSI_MMU_CONFIG1_BASE);
 	writel(VSI_MMU_BIT_ENABLE, iommu->regs + VSI_MMU_AHB_EXCEPTION_BASE);
 	writel(VSI_MMU_BIT_ENABLE, iommu->regs + VSI_MMU_AHB_CONTROL_BASE);
+	writel(VSI_MMU_BIT_FLUSH, iommu->regs + VSI_MMU_FLUSH_BASE);
+	writel(0, iommu->regs + VSI_MMU_FLUSH_BASE);
 	iommu->enable = true;
 }

@@ -564,8 +567,6 @@ static int vsi_iommu_attach_device(struct iommu_domain *domain,
 	spin_lock(&iommu->lock);

 	vsi_iommu_enable(iommu, domain);
-	writel(VSI_MMU_BIT_FLUSH, iommu->regs + VSI_MMU_FLUSH_BASE);
-	writel(0, iommu->regs + VSI_MMU_FLUSH_BASE);

 	list_del_init(&iommu->node);
 	list_add_tail(&iommu->node, &vsi_domain->iommus);