From: Pranjal Shrivastava <praan@google.com>
To: Daniel Mentz <danielmentz@google.com>
Cc: iommu@lists.linux.dev, Will Deacon <will@kernel.org>,
Joerg Roedel <joro@8bytes.org>,
Robin Murphy <robin.murphy@arm.com>,
Jason Gunthorpe <jgg@ziepe.ca>,
Mostafa Saleh <smostafa@google.com>,
Nicolin Chen <nicolinc@nvidia.com>,
Ashish Mhetre <amhetre@nvidia.com>
Subject: Re: [PATCH v6 10/10] iommu/arm-smmu-v3: Invoke pm_runtime before hw access
Date: Mon, 25 May 2026 19:53:44 +0000 [thread overview]
Message-ID: <ahSoyIh_QFvDCor5@google.com> (raw)
In-Reply-To: <CAE2F3rApNZbpxhRSKircaERMDUUtBOhjTjUSahcpV7Z6Cy8oEQ@mail.gmail.com>
On Tue, May 19, 2026 at 11:31:58AM -0700, Daniel Mentz wrote:
> On Tue, Apr 14, 2026 at 12:47 PM Pranjal Shrivastava <praan@google.com> wrote:
> > /* IO_PGTABLE API */
> > @@ -2823,7 +2883,16 @@ static void __arm_smmu_domain_inv_range(struct arm_smmu_invs *invs,
> >
> > if (cmds.num &&
> > (next == end || arm_smmu_invs_end_batch(cur, next))) {
> > - arm_smmu_cmdq_batch_submit(smmu, &cmds);
> > + bool active = arm_smmu_rpm_get_if_active(smmu);
> > +
> > + if (arm_smmu_inv_is_ats(cur))
> > + WARN_ON_ONCE(!active);
> > +
> > + if (active) {
> > + arm_smmu_cmdq_batch_submit(smmu, &cmds);
> > + arm_smmu_rpm_put(smmu);
> > + }
> > + /* Drop this batch to ensure the next one's fresh */
> > cmds.num = 0;
> > }
> > cur = next;
>
> Correct me if I'm wrong, but I don't think this is safe.
>
> Let's say arm_smmu_is_active() returns true and
> pm_runtime_get_if_active() returns 0 because dev->power.runtime_status
> != RPM_ACTIVE. In this situation, is it safe to skip
> arm_smmu_cmdq_batch_submit()? I think the answer is no.
>
> My understanding is that it is only safe to elide invalidations when
> SMMUEN in SMMU_CR0 is cleared. Imagine runtime_status is
> RPM_SUSPENDING. pm_runtime_get_if_active() returns 0, we elide
> invalidations despite SMMU still being enabled.
>
> I think that to decide whether to elide invalidations, we should
> exclusively rely on the Q_STOP test in arm_smmu_cmdq_issue_cmdlist(),
> not on the RPM framework.
Hmm.. the Q_STOP flag indicates the SMMUEN state 1:1.
Alright, I'll drop reliance on get_if_active everywhere and simply elide
based on Q_STOP. Even if we race with suspend/resume we should be safe
in that case because of the Q_STOP checks within the issue_cmdlist
(point of commitment).
Thanks,
Praan
prev parent reply other threads:[~2026-05-25 19:53 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-14 19:46 [PATCH v6 00/10] iommu/arm-smmu-v3: Implement Runtime/System Sleep ops Pranjal Shrivastava
2026-04-14 19:46 ` [PATCH v6 01/10] iommu/arm-smmu-v3: Refactor arm_smmu_setup_irqs Pranjal Shrivastava
2026-04-14 19:46 ` [PATCH v6 02/10] iommu/arm-smmu-v3: Add a helper to drain cmd queues Pranjal Shrivastava
2026-04-14 19:46 ` [PATCH v6 03/10] iommu/tegra241-cmdqv: Add a helper to drain VCMDQs Pranjal Shrivastava
2026-04-14 19:46 ` [PATCH v6 04/10] iommu/tegra241-cmdqv: Restore PROD and CONS after resume Pranjal Shrivastava
2026-04-14 19:46 ` [PATCH v6 05/10] iommu/arm-smmu-v3: Cache and restore MSI config Pranjal Shrivastava
2026-04-14 19:46 ` [PATCH v6 06/10] iommu/arm-smmu-v3: Add CMDQ_PROD_STOP_FLAG to gate CMDQ submissions Pranjal Shrivastava
2026-04-22 4:31 ` Daniel Mentz
2026-04-22 12:18 ` Pranjal Shrivastava
2026-04-14 19:46 ` [PATCH v6 07/10] iommu/arm-smmu-v3: Implement pm_runtime & system sleep ops Pranjal Shrivastava
2026-04-21 4:47 ` Daniel Mentz
2026-04-22 12:20 ` Pranjal Shrivastava
2026-04-21 15:46 ` Daniel Mentz
2026-04-22 12:23 ` Pranjal Shrivastava
2026-04-22 4:25 ` Daniel Mentz
2026-04-22 13:40 ` Pranjal Shrivastava
2026-04-24 5:24 ` Daniel Mentz
2026-04-24 15:16 ` Jason Gunthorpe
2026-05-04 9:01 ` Pranjal Shrivastava
2026-04-24 15:13 ` Jason Gunthorpe
2026-05-04 11:15 ` Pranjal Shrivastava
2026-05-19 20:50 ` Daniel Mentz
2026-04-14 19:47 ` [PATCH v6 08/10] iommu/arm-smmu-v3: Handle gerror during suspend Pranjal Shrivastava
2026-04-14 19:47 ` [PATCH v6 09/10] iommu/arm-smmu-v3: Enable pm_runtime and setup devlinks Pranjal Shrivastava
2026-04-14 19:47 ` [PATCH v6 10/10] iommu/arm-smmu-v3: Invoke pm_runtime before hw access Pranjal Shrivastava
2026-05-19 18:31 ` Daniel Mentz
2026-05-25 19:53 ` Pranjal Shrivastava [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=ahSoyIh_QFvDCor5@google.com \
--to=praan@google.com \
--cc=amhetre@nvidia.com \
--cc=danielmentz@google.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=nicolinc@nvidia.com \
--cc=robin.murphy@arm.com \
--cc=smostafa@google.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