From: Benjamin Gaignard <benjamin.gaignard@collabora.com>
To: aiyengar1990@gmail.com, "Joerg Roedel (AMD)" <joro@8bytes.org>,
Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] iommu/vsi: Don't leak a runtime PM reference in the TLB flush
Date: Mon, 16 Nov 2026 09:11:17 +0100 [thread overview]
Message-ID: <ae9d6425-21d0-405b-b0c3-c87e34d47d73@collabora.com> (raw)
In-Reply-To: <20261113-vsi-iommu-pm-ref-v1-1-fd917eebdf18@gmail.com>
Le 13/11/2026 à 21:04, Arun Iyengar via B4 Relay a écrit :
> From: Arun Iyengar <aiyengar1990@gmail.com>
>
> 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>
> ---
> drivers/iommu/vsi-iommu.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iommu/vsi-iommu.c b/drivers/iommu/vsi-iommu.c
> index 5dac20b143a5..5d581be95333 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);
>
next prev parent reply other threads:[~2026-11-16 8:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 20:04 [PATCH 0/2] iommu/vsi: Fix the runtime PM of the IOMMU Arun Iyengar via B4 Relay
2026-11-13 20:04 ` [PATCH 1/2] iommu/vsi: Don't leak a runtime PM reference in the TLB flush Arun Iyengar via B4 Relay
2026-11-16 8:11 ` Benjamin Gaignard [this message]
2026-11-13 20:04 ` [PATCH 2/2] iommu/vsi: Don't resume the IOMMU in its interrupt handler Arun Iyengar via B4 Relay
2026-11-16 8:11 ` Benjamin Gaignard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ae9d6425-21d0-405b-b0c3-c87e34d47d73@collabora.com \
--to=benjamin.gaignard@collabora.com \
--cc=aiyengar1990@gmail.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®