From: Robin Murphy <robin.murphy@arm.com>
To: Jason Gunthorpe <jgg@ziepe.ca>,
Nicolas Dufresne <nicolas.dufresne@collabora.com>
Cc: "Daniel Almeida" <daniel.almeida@collabora.com>,
"Joerg Roedel (AMD)" <joro@8bytes.org>,
"Will Deacon" <will@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Abdiel Janulgue" <abdiel.janulgue@gmail.com>,
iommu@lists.linux.dev, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
"Detlev Casanova" <detlev.casanova@collabora.com>
Subject: Re: [PATCH 0/6] rust: iommu: add a paging domain abstraction
Date: Thu, 19 Nov 2026 13:03:52 +0000 [thread overview]
Message-ID: <06d4eead-b765-44b9-94a8-6ec2d71d172a@arm.com> (raw)
In-Reply-To: <20261118210626.GF3115493@ziepe.ca>
On 18/11/2026 9:06 pm, Jason Gunthorpe wrote:
> On Wed, Nov 18, 2026 at 02:41:32PM -0500, Nicolas Dufresne wrote:
>> Jason,
>>
>> Le mercredi 18 novembre 2026 à 15:35 -0400, Jason Gunthorpe a écrit :
>>>> No, not OK :/ We want to use GEM shmem, which calls into the DMA API internally
>>>> through drm_gem_shmem_get_pages_sgt() -> dma_map_sgtable().
>>>
>>> You cannot continue to use DMA API once you start touching a paging
>>> domain directly. It is why driver_managed exist.
>>
>> You are building a strong argument around something that is not what we intent
>> this binding to be used for. If you had cared about the context you'd know we
>> don't want to touch paging from userspace in this type of drivers.
>
> Go re-read Daniel's answer and perhaps you can understand my confusion:
>
> https://lore.kernel.org/all/3EB4C2ED-B699-4532-A562-68B78F6E29C6@collabora.com/
>
> If you want to
>
> "We plan to alloc a paging domain when a video encoder session is created. Then
> we call iommu_attach_device() before a job runs"
>
> You cannot use the DMA API.
>
> You absolutely CANNOT attach a brand new driver controlled domain, use
> the DMA API to populate it, and then detach it.
>
> Then we have the issue that the rust bindings expose iommu_map, which
> cannot even be used on any non-coherent arch due to lack of cache
> flushing.
>
> Further, from a Rust binding perspective all these unsafe things I
> talked about have to be blocked by the Rust compiler:
> 1) You cannot attach a domain to a driver_managed_dma=false device
> 2) You cannot call DMA API functions on a driver_managed_dma=true device
> 3) I object to exposing iommu_get_domain_for_dev()/etc to Rust
> due to how unsafe it is, but if you were to do it then the
> returned pointer must never be used with attach or iommu_map/unmap
> functions.
> 4) Since there is no cache flushing a non-coherent arch must never be
> allowed to call iommu_map(), since it is unsafe to create memory
> incoherence.
>
> Thus, what exactly is the plan here? Do you see my concern?
Yes, your concern is a restriction that you largely made up :)
This is very much *not* driver_managed_dma, which TBH is poorly named
since it really means either "no DMA at all and thus fine to nominally
hotplug into live domains" or "userspace-managed DMA with no chance of
ever inserting DMA API calls at the right points". The model here is
basically just dma_link except you run your own explicit IOVA allocator,
and you have to make the IOMMU and DMA API calls separately because
there are no bundled helpers. Sure it's a relatively specialist use-case
that's not for any old driver, and isn't without its own caveats, mostly
that extra care would be needed if the device also had reserved regions
and/or IOMMU-translated MSIs, but for the typical embedded media devices
(in which I firmly include embedded NPUs, since from this perspective
the way they work is still about the same) which do want to operate this
way, those do not apply so it's fine and pretty straightforward.
Thanks,
Robin.
next prev parent reply other threads:[~2026-11-19 13:04 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 17:00 Daniel Almeida
2026-11-12 17:00 ` [PATCH 1/6] rust: iommu: move the protection flags to the module root Daniel Almeida
2026-11-12 17:00 ` [PATCH 2/6] rust: scatterlist: make SGTable::as_raw() visible to the crate Daniel Almeida
2026-11-12 17:00 ` [PATCH 3/6] rust: iommu: add the paging domain abstraction Daniel Almeida
2026-11-12 17:00 ` [PATCH 4/6] rust: iommu: add Domain::attach() Daniel Almeida
2026-11-16 21:54 ` Detlev Casanova
2026-11-12 17:00 ` [PATCH 5/6] rust: iommu: add Domain::map() Daniel Almeida
2026-11-12 17:00 ` [PATCH 6/6] rust: iommu: add Domain::with_fault_handler() Daniel Almeida
2026-11-16 19:38 ` [PATCH 0/6] rust: iommu: add a paging domain abstraction Jason Gunthorpe
2026-11-17 20:09 ` Daniel Almeida
2026-11-17 20:20 ` Jason Gunthorpe
2026-11-18 15:25 ` Nicolas Dufresne
2026-11-18 15:55 ` Daniel Almeida
2026-11-18 15:59 ` Daniel Almeida
2026-11-18 16:09 ` Jason Gunthorpe
2026-11-18 19:31 ` Nicolas Dufresne
2026-11-18 19:51 ` Jason Gunthorpe
2026-11-18 21:56 ` Nicolas Dufresne
2026-11-19 12:24 ` Robin Murphy
2026-11-19 13:25 ` Daniel Almeida
2026-11-18 19:11 ` Daniel Almeida
2026-11-18 19:35 ` Jason Gunthorpe
2026-11-18 19:41 ` Nicolas Dufresne
2026-11-18 21:06 ` Jason Gunthorpe
2026-11-19 13:03 ` Robin Murphy [this message]
2026-11-16 21:54 ` Detlev Casanova
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=06d4eead-b765-44b9-94a8-6ec2d71d172a@arm.com \
--to=robin.murphy@arm.com \
--cc=a.hindborg@kernel.org \
--cc=abdiel.janulgue@gmail.com \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=detlev.casanova@collabora.com \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nicolas.dufresne@collabora.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=will@kernel.org \
--cc=work@onurozkan.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
all inboxes | Powered by JetHome®