From: Mostafa Saleh <smostafa@google.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>,
Pranjal Shrivastava <praan@google.com>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Nicolin Chen <nicolinc@nvidia.com>,
Daniel Mentz <danielmentz@google.com>,
iommu@lists.linux.dev
Subject: Re: [RFC PATCH 0/5] iommu/arm-smmu-v3: Implement Runtime/System Sleep ops
Date: Thu, 20 Mar 2025 22:25:52 +0000 [thread overview]
Message-ID: <Z9yV8KsdXnZg1Ppo@google.com> (raw)
In-Reply-To: <003f23d7-b829-4611-8dd3-35b56a7ca90e@arm.com>
On Wed, Mar 19, 2025 at 04:07:57PM +0000, Robin Murphy wrote:
> On 19/03/2025 11:57 am, Jason Gunthorpe wrote:
> > On Wed, Mar 19, 2025 at 12:42:49AM +0000, Pranjal Shrivastava wrote:
> >
> > > 3. Invoking runtime_pm_get/put
> > > Given that most of the configuration done by arm-smmu-v3 is stored in
> > > memory, the initial idea is to focus on areas where the driver accesses
> > > the hw via exposed ops, like iommmu_ops, iommu_flush_ops, sva_ops etc.
> >
> > This seems weird, if the SMMU is suspended doesn't it also fail DMA
> > transactions? Why would ops like flush even be called if the HW is
> > disabled?
>
> Because once the device has finished its operation, its driver is free to
> call rpm_put() before calling dma_unmap(), so by the time that gets as far
> as TLB maintenance, the SMMU may already be asleep as well if that device
> was the only thing keeping it awake.
>
> For direct IOMMU API users, pagetable update may be even more asynchronous
> from device activity, e.g. a GPU buffer might only be unmapped once
> userspace closes the last file handle referencing it, long after the GPU
> itself has moved on to other things.
>
> > flush is performance path stuff, so it doesn't seem great to be adding
> > extra calls there.
>
> That much is true - this really wants to be using pm_runtime_get_if_in_use()
> nearly everywhere such that at most it's just juggling refcounts. There's no
> point waking the SMMU up just to issue a CFGI or TLBI, if the act of doing
> so is inherently going to do a full arm_smmu_reset() and thus invalidate
> everything anyway.
AFAICT, there is no guarantees that caches are clean on system resume,
but as we do invalidate everything that should be fine, but I am not sure
how that works with distributed SMMUs where the TBU can still be powered
with some TLBs that can be invalid?
Thanks,
Mostafa
>
> > > Instead of wrapping every exposed op with an rpm_get/put, the idea is to
> > > follow through till a logical common point (lowest common ancestor in
> > > the call hierarchies) and wrap those with the rpm_get/put calls.
> >
> > Should the iommu core be doing this instead of hidden in drivers? It
> > seems like there might be better information there about when we
> > expect the IOMMU to be powered up and working and when it is OK to
> > have it shutdown?
>
> On the contrary, I would say it's very much driver-level knowledge as to
> which operations need the hardware accessible or not, and trying to do it at
> the core level would inevitably end up very pessimistic and inefficient, or
> at best just horribly complex.
>
> > And maybe in this direction we can do things like remove the
> > translation before doing a suspend so that flush ops are not a
> > problem.
>
> Case in point: that would be a load of extra work to do, make suspend/resume
> even slower, and even then for no benefit, since map_pages/umnmap_pages can
> still be called on the unattached domain (especially a default DMA domain),
> wherein drivers may still end up trying to touch their hardware for various
> reasons in ways invisible to the core API. Easy example: consider a driver
> calling dma_alloc_coherent() to prepare a buffer *before* it wakes up its
> client device (which would then also wake up the SMMU via the device link),
> and deep within that call, arm_lpae_init_pte() ends up calling back into
> arm_smmu_tlb_inv_walk() because it's laying down a block mapping where an
> old empty table PTE happens to be...
>
> Thanks,
> Robin.
next prev parent reply other threads:[~2025-03-20 22:25 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-19 0:42 [RFC PATCH 0/5] iommu/arm-smmu-v3: Implement Runtime/System Sleep ops Pranjal Shrivastava
2025-03-19 0:42 ` [RFC PATCH 1/5] iommu/arm-smmu-v3: Refactor arm_smmu_setup_irqs Pranjal Shrivastava
2025-03-19 4:50 ` Nicolin Chen
2025-03-19 7:43 ` Pranjal Shrivastava
2025-03-20 22:29 ` Mostafa Saleh
2025-03-21 7:26 ` Pranjal Shrivastava
2025-03-25 16:19 ` Daniel Mentz
2025-03-26 19:35 ` Pranjal Shrivastava
2025-03-19 0:42 ` [RFC PATCH 2/5] iommu/arm-smmu-v3: Add a helper to wait till cmdq drains Pranjal Shrivastava
2025-03-20 22:30 ` Mostafa Saleh
2025-03-21 8:09 ` Pranjal Shrivastava
2025-03-25 17:50 ` Daniel Mentz
2025-03-26 19:36 ` Pranjal Shrivastava
2025-03-26 4:51 ` Daniel Mentz
2025-03-26 20:10 ` Pranjal Shrivastava
2025-03-19 0:42 ` [RFC PATCH 3/5] iommu/arm-smmu-v3: Implement pm_runtime & system sleep ops Pranjal Shrivastava
2025-03-20 22:33 ` Mostafa Saleh
2025-03-21 8:13 ` Pranjal Shrivastava
2025-03-26 4:52 ` Daniel Mentz
2025-03-28 7:47 ` Pranjal Shrivastava
2025-04-14 17:57 ` Nicolin Chen
2025-04-14 21:26 ` Nicolin Chen
2025-04-15 20:47 ` Pranjal Shrivastava
2025-04-15 22:28 ` Nicolin Chen
2025-04-16 10:24 ` Pranjal Shrivastava
2025-04-16 12:02 ` Jason Gunthorpe
2025-04-16 12:29 ` Pranjal Shrivastava
2025-04-16 12:42 ` Jason Gunthorpe
2025-04-16 12:52 ` Pranjal Shrivastava
2025-04-16 13:07 ` Jason Gunthorpe
2025-04-16 14:32 ` Pranjal Shrivastava
2025-04-15 20:37 ` Pranjal Shrivastava
2025-04-15 22:13 ` Nicolin Chen
2025-04-16 8:29 ` Pranjal Shrivastava
2025-03-19 0:42 ` [RFC PATCH 4/5] iommu/arm-smmu-v3: Enable pm_runtime and setup devlinks Pranjal Shrivastava
2025-03-20 22:34 ` Mostafa Saleh
2025-03-19 0:42 ` [RFC PATCH 5/5] iommu/arm-smmu-v3: Invoke pm_runtime before hw access Pranjal Shrivastava
2025-03-19 12:04 ` Jason Gunthorpe
2025-03-20 7:25 ` Pranjal Shrivastava
2025-03-20 12:54 ` Jason Gunthorpe
2025-03-20 13:22 ` Robin Murphy
2025-03-20 14:21 ` Pranjal Shrivastava
2025-03-20 22:36 ` Mostafa Saleh
2025-03-19 11:57 ` [RFC PATCH 0/5] iommu/arm-smmu-v3: Implement Runtime/System Sleep ops Jason Gunthorpe
2025-03-19 16:07 ` Robin Murphy
2025-03-20 22:25 ` Mostafa Saleh [this message]
2025-03-21 14:18 ` Pranjal Shrivastava
2025-03-21 17:35 ` Robin Murphy
2025-03-24 17:36 ` Pranjal Shrivastava
2025-03-27 17:27 ` Mostafa Saleh
2025-03-28 9:13 ` Pranjal Shrivastava
2025-03-28 9:19 ` Pranjal Shrivastava
2025-03-28 13:18 ` Jason Gunthorpe
2025-03-28 15:08 ` Pranjal Shrivastava
2025-03-28 18:21 ` Jason Gunthorpe
2025-03-19 18:22 ` Robin Murphy
2025-03-19 19:46 ` Jason Gunthorpe
2025-03-20 21:00 ` Pranjal Shrivastava
2025-03-20 23:08 ` Jason Gunthorpe
2025-03-21 14:36 ` Pranjal Shrivastava
2025-03-22 0:00 ` Jason Gunthorpe
2025-03-20 22:28 ` Mostafa Saleh
2025-03-20 23:05 ` Jason Gunthorpe
2025-03-21 14:44 ` Pranjal Shrivastava
2025-03-21 15:30 ` Jason Gunthorpe
2025-03-24 17:53 ` Pranjal Shrivastava
2025-03-25 13:55 ` Jason Gunthorpe
2025-03-27 17:39 ` Mostafa Saleh
2025-03-28 13:21 ` Jason Gunthorpe
2025-03-20 14:13 ` Pranjal Shrivastava
2025-03-20 14:54 ` Jason Gunthorpe
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=Z9yV8KsdXnZg1Ppo@google.com \
--to=smostafa@google.com \
--cc=danielmentz@google.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=nicolinc@nvidia.com \
--cc=praan@google.com \
--cc=robin.murphy@arm.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.