rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: "Alice Ryhl" <aliceryhl@google.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Will Deacon" <will@kernel.org>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Joerg Roedel" <joro@8bytes.org>,
	"Robin Murphy" <robin.murphy@arm.com>,
	"Lorenzo Stoakes" <lorenzo.stoakes@oracle.com>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	"Asahi Lina" <lina+kernel@asahilina.net>,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
	iommu@lists.linux.dev, linux-mm@kvack.org
Subject: Re: [PATCH v3] io: add io_pgtable abstraction
Date: Fri, 12 Dec 2025 05:21:11 -0400	[thread overview]
Message-ID: <aTveh8c3RngvnIMp@nvidia.com> (raw)
In-Reply-To: <20251212094427.2ec0b31e@fedora>

On Fri, Dec 12, 2025 at 09:44:27AM +0100, Boris Brezillon wrote:

> > > +// These bindings are currently designed for use by GPU drivers, which use this page table together
> > > +// with GPUVM. When using GPUVM, a single mapping operation may be translated into many operations  
> > 
> > Now that we have the generic pt stuff I wonder if GPUVM should be
> > providing its own version of the page table implementation that
> > matches its semantics better.
> 
> Not too sure what you mean here. Are you saying that we should fork
> io-pgtable-arm.c (or rather a subset of it), and have it all
> implemented in panthor?

Not quite, probably next yearish some of iommu is going to stop using
io-pgtable-arm.c, and switch to the new stuff.

The new stuff has alot less duplication if you want to make your own
special stuff like this:

> against it. Now, I see good reasons to do that, like the fact we
> would be able to add features like batched repeat mapping updates
> (mapping the same page over a wide virtual range without having to
> duplicate the intermediate page table levels that are exactly the
> same), 

That's certainly a unique requirement and it could be implemented with
a gpusvm specific set of operations.

> or the ability to extend the mapping arguments with
> shareability/coherency info (that we can do by adding IOMMU_xx flags
> too). But there's also downsides to it, like the fact we wouldn't
> benefit from bugfixes materializing in io-pgtable-arm.c, if any.

The new stuff is significantly modular already so this risk is a lot
lower, and we could further modularize things that are actually
duplicated.

But doing something like repeating page table levels will require some
fairly different unmaping logic already...

You also had the special allocator asks (and presumably optimizations
are possible there too) and probably optimizations like taking page
lists directly out of GPU structures instead of multiple calls and so
on.

When 6.19 comes out go look in drivers/iommo/generic_pt and read the
documentation pages that will generate under the kernel docs site.

Then you can think about what is ideal for GPU and consider what the
work would be like. My uneducated feeling is with gpuvm trying to be
common code it could also have gpuvm provide shared common code that
directly builds page tables in CPU memory using the above framework.

> > IOW it doesn't seem right that common code would be making decisions
> > like this, the nature and requirements of the flushing are entirely up
> > to the driver binding to HW.
> 
> We're not saying this will work for everyone, but rather, this is a
> default implementation that does nothing, and if you need to do
> something, override it with your own. I guess if that's really
> problematic, we can force the user to provide one and keep the NOP
> implementation on Tyr's side.

In my view there is no possible correct way to use this page table
code with HW unless you also provide flushing ops. I can't remark what
is more rusty to do but having a default full of NOPS should at least
come with a comment explaining that the driver still need to provide
something.

Jason

  reply	other threads:[~2025-12-12  9:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-12 10:15 [PATCH v3] io: add io_pgtable abstraction Alice Ryhl
2025-11-12 12:57 ` Daniel Almeida
2025-11-17 16:34   ` Alice Ryhl
2025-11-19  8:59     ` Boris Brezillon
2025-11-19 10:53   ` Boris Brezillon
2025-11-19 10:56 ` Boris Brezillon
2025-11-28 11:56 ` Robin Murphy
2025-11-28 12:27   ` Alice Ryhl
2025-11-28 16:47     ` Robin Murphy
2025-12-01  9:58       ` Alice Ryhl
2025-12-01 13:55         ` Robin Murphy
2025-11-28 18:02 ` Jason Gunthorpe
2025-12-12  8:44   ` Boris Brezillon
2025-12-12  9:21     ` Jason Gunthorpe [this message]
2025-12-12  9:41       ` Boris Brezillon
2025-12-14  0:51         ` 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=aTveh8c3RngvnIMp@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=gary@garyguo.net \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=lina+kernel@asahilina.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).