mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Daniel Almeida <daniel.almeida@collabora.com>
Cc: "Robin Murphy" <robin.murphy@arm.com>,
	"Nicolas Dufresne" <nicolas.dufresne@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 10:31:51 -0400	[thread overview]
Message-ID: <20261119143151.GH3115493@ziepe.ca> (raw)
In-Reply-To: <CF2BE3BB-4F16-49FC-8421-B2B823BB7BB4@collabora.com>

On Thu, Nov 19, 2026 at 10:25:24AM -0300, Daniel Almeida wrote:
> > 
> > I can't speak for the actual intent of the Rust drivers, but
> > giving them the benefit of the doubt, none of that fearmongering
> > should apply: the valid use-case is just simple time-division
> > multiplexing.

To be clear, I think the use case is a reasonable thing to ask for,
but since when is this flow valid? Does something already do this???

And why didn't you disclose this immediately after my first question
"how do you intend to use this"? It would have saved alot of time.

Below is exactly something I think drivers should not be doing:
 
> > A = iommu_paging_domain_alloc(dev);
> > B = iommu_paging_domain_alloc(dev);
> > iommu_attach(dev, A);
> > iommu_map(A, iova_x, virt_to_phys(X));
> > dma_map(dev, X) //still needed for the underlying memory
> > ... //tell dev to do the work for context A using iova_x
> > dma_unmap(dev, X);
> > dma_map(dev, Y);
> > iommu_map(B, iova_y, virt_to_phys(Y));
> > iommu_detach(dev, A);
> > iommu_attach(dev, B);
> > ... //do some work in context B
> 
> Yeah, this is basically exactly what we want to do..yet Jason has been
> repeateadly saying you cannot call the dma api at all once you allocate paging
> domains. So now, I am confused.

Especially from Rust where we are supposed to be enforcing strong
safety invariants. This is not safe, and it is not following the
meaning of driver_managed_dma, it is not good if there are multi
device groups, cannot work DMABUF, and is exactly the sort of weird
stuff we keep breaking down the road :\

Sure with a lot of care this doesn't immediately explode today, but I
don't think we should be setting this as an API direction, especially
for safe rust.

All of this is very related to the PASID discussions from a while
back. The goal there was to allow the kernel to DMA map to a PASID
paging domain. IIRC the direction was to wrap the PASID in a struct
device, maybe a "fake/limited" struct device, so that the DMA API can
be used, dma-iommu.c manages the paging domain directly, and things
have a sensible driver API.

More like this:

 dma_dev = iommu_alloc_paging_dma_dev(dev)
 iommu_attach_pasid_paging_dma_dev(dev, dma_dev, pasid);
 dma_map(dma_dev, X)
 dma_umap(dma_dev)

With the additional twist that alot of embedded HW has apparently
choosen to not implement SSID but instead has a pool of SIDs that one
device can use, functionally similar to SSID.

We'd need also API support for unbundling the DT iommus=[] SID list
into something that the SIDs can be attached more like a PASID.  That
need, I think, has become clear with all the DT tricks and fake busses
to try to work around this issue. :|

Jason

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

Thread overview: 34+ 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-19 14:31               ` Jason Gunthorpe [this message]
2026-11-19 14:52                 ` Nicolas Dufresne
2026-11-19 15:08                   ` Jason Gunthorpe
2026-11-19 15:47                     ` Nicolas Dufresne
2026-11-19 16:36                       ` Jason Gunthorpe
2026-11-19 14:34             ` Jason Gunthorpe
2026-11-19 14:45               ` Robin Murphy
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
2026-11-19 14:55                 ` Jason Gunthorpe
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=20261119143151.GH3115493@ziepe.ca \
    --to=jgg@ziepe.ca \
    --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=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=nicolas.dufresne@collabora.com \
    --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

all inboxes | Powered by JetHome®