From: Pranjal Shrivastava <praan@google.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Daniel Mentz <danielmentz@google.com>,
iommu@lists.linux.dev, Will Deacon <will@kernel.org>,
Joerg Roedel <joro@8bytes.org>,
Robin Murphy <robin.murphy@arm.com>,
Mostafa Saleh <smostafa@google.com>,
Nicolin Chen <nicolinc@nvidia.com>,
Ashish Mhetre <amhetre@nvidia.com>
Subject: Re: [PATCH v6 07/10] iommu/arm-smmu-v3: Implement pm_runtime & system sleep ops
Date: Mon, 4 May 2026 09:01:38 +0000 [thread overview]
Message-ID: <afhgcog-Cizp_Rag@google.com> (raw)
In-Reply-To: <20260424151639.GE3611611@ziepe.ca>
On Fri, Apr 24, 2026 at 12:16:39PM -0300, Jason Gunthorpe wrote:
> On Thu, Apr 23, 2026 at 10:24:30PM -0700, Daniel Mentz wrote:
> > On Wed, Apr 22, 2026 at 6:41 AM Pranjal Shrivastava <praan@google.com> wrote:
> > > > > + /* Clear the STOP FLAG to allow CMDQ Submissions */
> > > >
> > > > Clearing the STOP flag here seems premature. I propose the following sequence:
> > > >
> > > > * Set up command queue (SMMU_CR1, SMMU_CMDQ_BASE etc.)
> > > > * Enable command queue
> > > > * Clear STOP flag
> > > > * Enable SMMU
> > > >
> > > > By clearing the STOP flag, you allow arm_smmu_cmdq_issue_cmdlist() to
> > > > write to SMMU_CMDQ_PROD which then races against
> > > > arm_smmu_device_reset() which also writes to SMMU_CMDQ_PROD.
> > > >
> > >
> > > I agree, IIUC you're suggesting to clear the stop flag before the
> > > TLBI_ALL and CFGI_ALL commands are issued by device_reset? We'll need
> > > to clear the flag before device_reset issues the TLBI_ALL AND CFGI_ALL.
> > > Thus the sequence should be:
> > >
> > > * Set up CMDQ
> > > * Enable CMDQ
> > > * Clear STOP flag
> > > * Issue TLBI_ALL + CFGI_ALL
> > > * Enable SMMU
> > >
> > > Right?
> >
> > Yes
>
> This is making a very similar fencing argument to how Nicolin's series
> works.
>
The invs array series?
> After clearing stop but before enablie SMMU you have to acquire all
> concurrent threads updated data structure memory into this thread
> because as soon as enable SMMU happens it will start reading that
> memory and it must be 'either we see the latest copy' or 'we see an
> old copy and guarenteed to see the invalidation'
>
> Exactly the same as the reasoning used for attach with the
> invalidation list. So I think you should look at the barrier design
> there and ensure it exists here too.
>
Hmm.. I see your point. We need to ensure that any structure updates
(like STE/CD or page table changes) made by concurrent threads are
globally visible before we send the MMIO write to enable the SMMU,
i.e. we're talking about memory ordering between other CPUs and
the Resume CPU (CPU running resume), without a barrier on the Resume
CPU, the SMMUEN=1 write could potentially beat a client thread's memory
update. If the SMMU is enabled and fetches a stale configuration before
the RAM update lands, it could cache an inconsistent state.
I guess I'll add an smp_mb() before the SMMUEN enable to act as a
system-wide synchronization point.
Thanks,
Praan
next prev parent reply other threads:[~2026-05-04 9:01 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 [this message]
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
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=afhgcog-Cizp_Rag@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 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.