All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Amita Mishra" <amitamishra@google.com>
Cc: linux-perf-users@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 2/2] perf/smmuv3: Add runtime PM support
Date: Wed, 18 Nov 2026 10:44:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-220738@kernel.org> (raw)
In-Reply-To: <20261118101913.3135869-3-amitamishra@google.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] perf/smmuv3: missing MSI register restore in
  smmu_pmu_runtime_resume()
- [High] perf/smmuv3: unpowered MMIO writes in smmu_pmu_write_msi_msg()
--

commit 3367ecb885d7f9e9f0717d0698079ca0810697a6
Author: Amita Mishra <amitamishra@google.com>

perf/smmuv3: Add runtime PM support

This commit adds runtime PM support for SMMUv3 PMCG devices attached to a
power domain so that idle PMCGs can be powered off when no perf events are
active.

> diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c
> index 97440b6233c6e..e9da99b4a0866 100644
> --- a/drivers/perf/arm_smmuv3_pmu.c
> +++ b/drivers/perf/arm_smmuv3_pmu.c

[ ... ]

> @@ -975,15 +1040,45 @@ static void smmu_pmu_remove(struct platform_device *pdev)
>  
>  	perf_pmu_unregister(&smmu_pmu->pmu);
>  	cpuhp_state_remove_instance_nocalls(cpuhp_state_num, &smmu_pmu->node);
> +	if (pdev->dev.pm_domain)
> +		pm_runtime_disable(&pdev->dev);
>  }

[Severity: High]
Can tearing down or retargeting the MSI while the PMCG is runtime-suspended
write to SMMU_PMCG_IRQ_CFG0, SMMU_PMCG_IRQ_CFG1, and SMMU_PMCG_IRQ_CFG2
while the power domain is off?

When the driver is unbound with no active events, __device_release_driver()
leaves the device runtime-suspended and smmu_pmu_remove() disables runtime
PM.  devres_release_all() then frees the devm_request_irq() handler via
free_irq() -> irq_domain_deactivate_irq() -> msi_domain_deactivate() ->
smmu_pmu_write_msi_msg(), which writes to the unpowered PMCG registers and
triggers an external abort or SError.  The same unpowered write happens if
smmu_pmu->on_cpu is offlined while suspended and smmu_pmu_offline_cpu()
calls irq_set_affinity() -> msi_domain_set_affinity() ->
smmu_pmu_write_msi_msg().

>  
>  static void smmu_pmu_shutdown(struct platform_device *pdev)
>  {
>  	struct smmu_pmu *smmu_pmu = platform_get_drvdata(pdev);
>  
> -	smmu_pmu_disable(&smmu_pmu->pmu);
> +	if (pdev->dev.pm_domain) {
> +		if (pm_runtime_get_if_active(&pdev->dev) <= 0)
> +			return;
> +		__smmu_pmu_disable(smmu_pmu);
> +		pm_runtime_put(&pdev->dev);
> +		return;
> +	}
> +
> +	__smmu_pmu_disable(smmu_pmu);
>  }
>  
> +static int smmu_pmu_runtime_suspend(struct device *dev)
> +{
> +	struct smmu_pmu *smmu_pmu = dev_get_drvdata(dev);
> +
> +	__smmu_pmu_disable(smmu_pmu);
> +	return 0;
> +}
>  
> +static int smmu_pmu_runtime_resume(struct device *dev)
> +{
> +	struct smmu_pmu *smmu_pmu = dev_get_drvdata(dev);
> +
> +	smmu_pmu_reset(smmu_pmu);
> +	return 0;
> +}

[Severity: High]
Does smmu_pmu_runtime_resume() lose the MSI configuration programmed in
SMMU_PMCG_IRQ_CFG0, SMMU_PMCG_IRQ_CFG1, and SMMU_PMCG_IRQ_CFG2 when the
power domain is powered off and back on?

During probe, smmu_pmu_setup_irq() clears SMMU_PMCG_IRQ_CFG0 and
devm_request_irq() activates the MSI via smmu_pmu_write_msi_msg(), before
pm_runtime_put_sync() at the end of smmu_pmu_probe() suspends the device
and drops power to those registers:

drivers/perf/arm_smmuv3_pmu.c:smmu_pmu_write_msi_msg() {
	...
	writeq_relaxed(doorbell, pmu->reg_base + SMMU_PMCG_IRQ_CFG0);
	writel_relaxed(msg->data, pmu->reg_base + SMMU_PMCG_IRQ_CFG1);
	writel_relaxed(MSI_CFG2_MEMATTR_DEVICE_nGnRE,
		       pmu->reg_base + SMMU_PMCG_IRQ_CFG2);
}

When smmu_pmu_event_init() later resumes the device,
smmu_pmu_runtime_resume() only calls smmu_pmu_reset(), leaving the MSI
registers unprogrammed (or leaving SMMU_PMCG_IRQ_CFG0 at its UNKNOWN reset
value when wired interrupts are used on an MSI-capable PMCG) so counter
overflow interrupts do not work.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118101913.3135869-1-amitamishra@google.com?part=2

      reply	other threads:[~2026-11-18 10:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 10:19 [PATCH 0/2] perf/smmuv3: Add runtime PM support Amita Mishra
2026-11-18 10:19 ` [PATCH 1/2] dt-bindings: perf: arm,smmu-v3-pmcg: Allow power-domains Amita Mishra
2026-11-18 10:24   ` sashiko-bot
2026-11-18 10:19 ` [PATCH 2/2] perf/smmuv3: Add runtime PM support Amita Mishra
2026-11-18 10:44   ` sashiko-bot [this message]

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=sashiko-outbox-220738@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=amitamishra@google.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.