Rust for Linux List
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: "Daniel Almeida" <daniel.almeida@collabora.com>,
	"Joerg Roedel (AMD)" <joro@8bytes.org>,
	"Will Deacon" <will@kernel.org>,
	"Robin Murphy" <robin.murphy@arm.com>,
	"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: Wed, 18 Nov 2026 14:31:28 -0500	[thread overview]
Message-ID: <ede3b421d419a35c115ed584e60e74bfd6b91dff.camel@collabora.com> (raw)
In-Reply-To: <20261118160909.GC3115493@ziepe.ca>

[-- Attachment #1: Type: text/plain, Size: 5576 bytes --]

Hi,

Le mercredi 18 novembre 2026 à 12:09 -0400, Jason Gunthorpe a écrit :
> On Wed, Nov 18, 2026 at 10:25:58AM -0500, Nicolas Dufresne wrote:
> > Hi,
> > 
> > Le mardi 17 novembre 2026 à 16:20 -0400, Jason Gunthorpe a écrit :
> > > On Tue, Nov 17, 2026 at 05:09:11PM -0300, Daniel Almeida wrote:
> > > > Hi Jason,
> > > > 
> > > > > On 16 Nov 2026, at 16:38, Jason Gunthorpe <jgg@ziepe.ca> wrote:
> > > > > 
> > > > > On Thu, Nov 12, 2026 at 02:00:07PM -0300, Daniel Almeida wrote:
> > > > > > This series adds a Rust abstraction for IOMMU paging domains. A driver
> > > > > > can allocate a domain, attach it to its device, map pages into it, and
> > > > > > install a handler for its faults.
> > > > > > 
> > > > > > This will be used by the upcoming rkvenc driver that my colleagues
> > > > > > Detlev Casanova, Nicolas Dufresne and I are working on. More details on
> > > > > > this driver can be found by watching Nicolas Dufresne's talk at LPC 2026
> > > > > > [0].
> > > > > > 
> > > > > > As part of the security model, each client will have its own IOMMU
> > > > > > domain. This is needed as the submission model will let userspace set
> > > > > > most of the encoder's registers directly, so the kernel cannot check
> > > > > > every memory access that a job makes the encoder do. With a single
> > > > > > domain, one client could make the encoder read or write the memory of
> > > > > > another client.
> > > > > 
> > > > > How do you plan to get the paging domain in the first place?
> > > > 
> > > > We plan to alloc a paging domain when a video encoder session is created. Then
> > > > we call iommu_attach_device() before a job runs, and detach back to the default
> > > > domain after it finishes so the next job can attach its own session's domain.
> > > > This is so each session is isolated from each other.
> > > 
> > > If you do that you can't use the DMA API at all in your driver as you
> > > have to set 'driver_managed = true'. Is it OK? If it is why not just
> > > use VFIO?
> > > 
> > > Or are you planning DT horrors to get yourself a DT created "DMA
> > > struct" ?
> > 
> > This seem to digress. All we want to do is use the iommu subsystem as intended
> > for the case the iommu driver is not inside the DRM driver (which seems to have
> > never been the case so far in DRM).
> 
> "As intended" means you use the DMA API and you do not touch
> the paging domain.
> 
> "As intended" means you use iommufd if you want a domain full of user
> controlled mappings.

As discussed at LPC, we believe its pointless for this type of device to give
any direct page choices to userspace. Can you explain why you believe
differently?

> 
> > The existing infra for that (in C) is pretty abstract an simple in
> > my opinion, and built into the DMA API if you manage which domain to
> > attach to your device at the right time.
> 
> What does this even mean? The DMA API owns the domain, not the
> driver.
> 
> All the cases using these APIs in DRM and media are troubled in one
> way or another.
> 
> For example the recent revelation they have always been using DMABUF entirely wrong:
> 
> https://lore.kernel.org/all/20261009125338.GB13920@nvidia.com/
> 
> Tegra desires to undo their abuses.
> 
> It was never intended for things to work like this, there is missing
> infrastructure.
> 
> > To me, it fits CODEC HW driver which are also simple. The DT horrors
> > you refer to seems totally unfounded, you just describe the iommu
> > and the iommu subsystem will manage it for your device.
> 
> "unfounded? You are not following along, I've written about this now
> many times to many different people. Follow the links and discussion
> from here:
> 
> https://lore.kernel.org/all/20260917144804.GI3196566@ziepe.ca/
> 
> If you use DT correctly there is no place to attach an iommu_domain to
> and you can't even use these APIs. You get DMA API only and that's it.
> 
> You have to do something "wrong" in DT to create fake HW devices to
> even give you a struct device to even attach something to.
> 
> Or you have to entirely give up DMA API and attach to your only struct
> device.

I'm not sure how this applies to our work. But since they are all broken
according to you, let me give example of cores/iommu mapping we are using, and
perhaps you'll be able to explain us correctly? I've picked the Rockchip video
decoder, which is upstream but expose through V4L2 stateless API, but from a
hardware point of view is pretty much identical:

The DT (which I read you must be broken and in violation of everything, yet all
reviewed by DT maintainers):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi#n1400

The multi-core support proposal, its not doing process isolation, its not
strictly needed in higher level abstraction (though could be better), but its
using domains so that each core can actually see the same memory:
https://lore.kernel.org/all/20260810-rkvdec-multicore-v2-0-986f89d22cdc@collabora.com/

The DMA abstraction that is used by the above driver:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/media/common/videobuf2/videobuf2-dma-contig.c

GEM kind of offer similar high level abstraction to DMA (with important
behaviour changes in of course, specially for write combine delivery), so this
is what we have for now in the WIP driver. Check the LPC presentation for the
rest of the context.

Nicolas

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-11-18 19:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 17:00 [PATCH 0/6] rust: iommu: add a paging domain abstraction 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 [this message]
2026-11-18 19:51             ` Jason Gunthorpe
2026-11-18 19:11       ` Daniel Almeida
2026-11-18 19:35         ` Jason Gunthorpe
2026-11-18 19:41           ` Nicolas Dufresne
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=ede3b421d419a35c115ed584e60e74bfd6b91dff.camel@collabora.com \
    --to=nicolas.dufresne@collabora.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=ojeda@kernel.org \
    --cc=robin.murphy@arm.com \
    --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