Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH 09/12] iommu: qcom_iommu: allow faulting transactions to terminate
Date: Sun, 09 Aug 2026 20:28:38 +0000	[thread overview]
Message-ID: <20260809202838.D7BF21F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260809-msm8974-iommu-upstream-v1-9-87f5cd492560@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] The `qcom_iommu_fault` interrupt handler unconditionally writes to `ARM_SMMU_CB_RESUME`, causing CONSTRAINED UNPREDICTABLE behavior when `no_stall` is enabled.

Pre-existing issues:
- [High] The driver ignores the return value of `pm_runtime_get_sync()`, risking a synchronous external abort on QCOM platforms if power enablement fails.
--

--- Patch [9]: [PATCH 09/12] iommu: qcom_iommu: allow faulting transactions to terminate ---
commit 7786a25b4251a5907f3352e2d3045ccfe7aefaab
Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>

iommu: qcom_iommu: allow faulting transactions to terminate

This commit introduces a no_stall flag to qcom_iommu_cfg. When set, this
flag clears the CFCFG bit in SCTLR so that faulting transactions terminate
instead of stalling. The interrupt handler remains unchanged.

> through the existing interrupt handler; only the stall goes away, and
> with it the handler's RESUME write becomes a formality.

[Severity: High]
Does this write actually become a formality, or could it cause a regression
with unpredictable behavior?

If stalling is disabled, FSR.SS will remain 0 when a context fault occurs.
According to the ARM SMMUv2 spec, writing to CB_RESUME when the stall status
(FSR.SS) is 0 is constrained unpredictable and can trigger a synchronous
abort.

The qcom_iommu_fault() interrupt handler unconditionally writes to
ARM_SMMU_CB_RESUME:

drivers/iommu/arm/arm-smmu/qcom_iommu.c:qcom_iommu_fault() {
    ...
	iommu_writel(ctx, ARM_SMMU_CB_FSR, fsr);
	iommu_writel(ctx, ARM_SMMU_CB_RESUME, ARM_SMMU_RESUME_TERMINATE);
    ...
}

Should the unconditional write to CB_RESUME be guarded by a check for
FSR.SS?

> diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
> index f27f8722ee640..2b2cf665c39db 100644
> --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c
> +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
[ ... ]
> @@ -500,6 +502,9 @@ static int qcom_iommu_init_domain(struct iommu_domain *domain,
>  		if (qcom_iommu->cfg && qcom_iommu->cfg->no_afe)
>  			reg &= ~ARM_SMMU_SCTLR_AFE;
>  
> +		if (qcom_iommu->cfg && qcom_iommu->cfg->no_stall)
> +			reg &= ~ARM_SMMU_SCTLR_CFCFG;
> +
>  		ctx->sctlr = reg;
>  
>  		qcom_iommu_program_ctx(qcom_iommu, ctx);

[Severity: High]
This is a pre-existing issue, but is it safe to proceed with initializing
the domain without checking if power enablement succeeded?

This function is called by qcom_iommu_attach_dev(), which ignores the return
value of pm_runtime_get_sync():

drivers/iommu/arm/arm-smmu/qcom_iommu.c:qcom_iommu_attach_dev() {
    ...
	pm_runtime_get_sync(qcom_iommu->dev);
	ret = qcom_iommu_init_domain(domain, qcom_iommu, dev);
	pm_runtime_put_sync(qcom_iommu->dev);
    ...
}

If pm_runtime_get_sync() fails, qcom_iommu_init_domain() will perform MMIO
accesses on unpowered hardware. On Qualcomm platforms, accessing unclocked or
unpowered IOMMU hardware registers causes a synchronous external abort.

Should qcom_iommu_attach_dev() check the return value and safely abort before
attempting to access unclocked registers?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260809-msm8974-iommu-upstream-v1-0-87f5cd492560@oss.qualcomm.com?part=9

  reply	other threads:[~2026-08-09 20:28 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
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 [this message]
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=20260809202838.D7BF21F00A3A@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