From: sashiko-bot@kernel.org
To: "Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 08/12] iommu: qcom_iommu: halt the micro-MMU while programming context banks
Date: Sun, 09 Aug 2026 20:33:51 +0000 [thread overview]
Message-ID: <20260809203351.9C22A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260809-msm8974-iommu-upstream-v1-8-87f5cd492560@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Concurrent domain attachments and context programming cause race conditions in the global micro-MMU halt state, leading to premature unhalting and data races on the control register.
- [Medium] Spinning for up to 100ms in a tight loop using `cpu_relax()` risks degrading system responsiveness on hardware timeout.
--
--- Patch [8]: [PATCH 08/12] iommu: qcom_iommu: halt the micro-MMU while programming context banks ---
commit b970b685e94c99403661414d09a198b270daac8a
Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
iommu: qcom_iommu: halt the micro-MMU while programming context banks
This commit adds a hardware handshake to halt the micro-MMU before
reprogramming context bank registers. It introduces qcom_iommu_halt()
and qcom_iommu_unhalt() to wrap the context programming sequence.
> diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
> index 8e9488c47d5c1..f27f8722ee640 100644
> --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c
> +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
[ ... ]
> @@ -339,9 +349,41 @@ static int qcom_iommu_reset_ns(struct qcom_iommu_dev *qcom_iommu)
> return 0;
> }
>
> +/*
> + * Halting the micro-MMU quiesces the translation front-end: it stops new
> + * client transactions being accepted and waits for the outstanding ones to
> + * retire, so that the context bank registers can be reprogrammed without
> + * in-flight traffic racing the change.
> + */
> +static void qcom_iommu_halt(struct qcom_iommu_dev *qcom_iommu)
> +{
> + void __iomem *reg = qcom_iommu->global_base + QCOM_IOMMU_MICRO_MMU_CTRL;
> + u32 val;
> +
> + if (!qcom_iommu->cfg || !qcom_iommu->cfg->halt)
> + return;
> +
> + writel_relaxed(readl_relaxed(reg) | MICRO_MMU_CTRL_HALT_REQ, reg);
[Severity: High]
Could this read-modify-write on the global MICRO_MMU_CTRL register race if
devices mapped to different IOMMU domains are probing or attaching
concurrently?
> +
> + if (readl_poll_timeout(reg, val, val & MICRO_MMU_CTRL_IDLE, 0, 100000))
[Severity: Medium]
Does setting the delay parameter to 0 cause this to spin continuously in a
tight cpu_relax() loop for up to 100ms?
If the hardware becomes unresponsive, especially in callers like
qcom_iommu_resume() which loop over multiple context banks, could this block
the CPU for over a second in a non-preemptible kernel?
> + dev_err(qcom_iommu->dev, "timeout waiting for micro-MMU halt\n");
> +}
> +
> +static void qcom_iommu_unhalt(struct qcom_iommu_dev *qcom_iommu)
> +{
> + void __iomem *reg = qcom_iommu->global_base + QCOM_IOMMU_MICRO_MMU_CTRL;
> +
> + if (!qcom_iommu->cfg || !qcom_iommu->cfg->halt)
> + return;
> +
> + writel_relaxed(readl_relaxed(reg) & ~MICRO_MMU_CTRL_HALT_REQ, reg);
[Severity: High]
If qcom_iommu_program_ctx() is called concurrently for different domains,
could this unconditional clear prematurely unhalt the micro-MMU while another
thread is still actively programming a different context bank?
Since this modifies the global micro-MMU state without a device-level lock or
reference count, does this risk allowing in-flight traffic to race against the
reconfiguration?
> +}
> +
> static void qcom_iommu_program_ctx(struct qcom_iommu_dev *qcom_iommu,
> struct qcom_iommu_ctx *ctx)
> {
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260809-msm8974-iommu-upstream-v1-0-87f5cd492560@oss.qualcomm.com?part=8
next prev parent reply other threads:[~2026-08-09 20:33 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-09 20:15 [PATCH 00/12] iommu: qcom_iommu: implement support for instances on MSM8974 Dmitry Baryshkov
2026-08-09 20:15 ` [PATCH 01/12] dt-bindings: iommu: qcom,iommu: document the MSM8974 IOMMUs Dmitry Baryshkov
2026-08-09 20:28 ` sashiko-bot
2026-08-09 20:15 ` [PATCH 02/12] iommu: arm-smmu: add global register definitions used by the QSMMU Dmitry Baryshkov
2026-08-09 20:15 ` [PATCH 03/12] iommu: qcom_iommu: extract context bank programming into a helper Dmitry Baryshkov
2026-08-09 20:27 ` sashiko-bot
2026-08-09 20:15 ` [PATCH 04/12] iommu: qcom_iommu: support the short-descriptor pagetable format Dmitry Baryshkov
2026-08-09 20:30 ` sashiko-bot
2026-08-09 20:15 ` [PATCH 05/12] iommu: qcom_iommu: handle the SMMU global register space Dmitry Baryshkov
2026-08-09 20:29 ` sashiko-bot
2026-08-09 20:15 ` [PATCH 06/12] iommu: qcom_iommu: support non-TZ-managed instances Dmitry Baryshkov
2026-08-09 20:39 ` sashiko-bot
2026-08-09 20:15 ` [PATCH 07/12] iommu: qcom_iommu: restore context bank state after power collapse Dmitry Baryshkov
2026-08-09 20:28 ` sashiko-bot
2026-08-09 20:15 ` [PATCH 08/12] iommu: qcom_iommu: halt the micro-MMU while programming context banks Dmitry Baryshkov
2026-08-09 20:33 ` sashiko-bot [this message]
2026-08-09 20:15 ` [PATCH 09/12] iommu: qcom_iommu: allow faulting transactions to terminate Dmitry Baryshkov
2026-08-09 20:28 ` sashiko-bot
2026-08-09 20:15 ` [PATCH 10/12] iommu: qcom_iommu: program BFP (prefetch) settings Dmitry Baryshkov
2026-08-09 20:28 ` sashiko-bot
2026-08-09 20:15 ` [PATCH 11/12] iommu: qcom_iommu: add the MSM8974 instances Dmitry Baryshkov
2026-08-09 20:28 ` sashiko-bot
2026-08-09 20:15 ` [PATCH 12/12] ARM: dts: qcom: msm8974: add the IOMMUs Dmitry Baryshkov
2026-08-10 10:16 ` [PATCH 00/12] iommu: qcom_iommu: implement support for instances on MSM8974 Luca Weiss
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=20260809203351.9C22A1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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