[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DAAD0NZOCHS5.9FTVJIOI12QI@nvidia.com>
Date: Sat, 31 May 2025 21:54:20 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Jason Gunthorpe" <jgg@...pe.ca>
Cc: "Abdiel Janulgue" <abdiel.janulgue@...il.com>, <dakr@...nel.org>,
<lyude@...hat.com>, "Miguel Ojeda" <ojeda@...nel.org>, "Alex Gaynor"
<alex.gaynor@...il.com>, "Boqun Feng" <boqun.feng@...il.com>, "Gary Guo"
<gary@...yguo.net>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, "Benno Lossin" <benno.lossin@...ton.me>,
"Andreas Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl"
<aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>, "Valentin Obst"
<kernel@...entinobst.de>, "open list" <linux-kernel@...r.kernel.org>,
"Marek Szyprowski" <m.szyprowski@...sung.com>, "Robin Murphy"
<robin.murphy@....com>, <airlied@...hat.com>,
<rust-for-linux@...r.kernel.org>, "open list:DMA MAPPING HELPERS"
<iommu@...ts.linux.dev>, "Petr Tesarik" <petr@...arici.cz>, "Andrew Morton"
<akpm@...ux-foundation.org>, "Herbert Xu" <herbert@...dor.apana.org.au>,
"Sui Jingfeng" <sui.jingfeng@...ux.dev>, "Randy Dunlap"
<rdunlap@...radead.org>, "Michael Kelley" <mhklinux@...look.com>
Subject: Re: [PATCH 1/2] rust: add initial scatterlist bindings
On Fri May 30, 2025 at 11:50 PM JST, Jason Gunthorpe wrote:
> On Fri, May 30, 2025 at 11:44:26PM +0900, Alexandre Courbot wrote:
>
>> I would be fully on board with a simpler design, definitely. The reason
>> why I've tried to keep some doors open is that as you mentioned
>> scatterlist is used in many different ways, and I am not familiar enough
>> with all these uses to draw a line and say "we will never ever need to
>> do that".
>
> I think it would be better to grow as needed. It is hard to speculate.
>
> We also have the new two step DMA API, so it may very well be the only
> use for this stuff is very simple mappings of VVec like things for
> DMA, and maybe this all gets rewritten to use the new DMA API and not
> scatterlist.
>
> Having a rust user facing API that allows for that would be a great
> thing.
>
> IOW I would maybe reframe the task here, it is not to create simple
> naive wrappers around scatterlist but to provide a nice rust API to go
> from VVec/etc to DMA mapping of that VVec/etc.
I like this focus on the practical instead of abstracting the C APIs as
closely as possible. Maybe we have been too focused on the tool rather
than the goal.
So if I understood your idea correctly, this would mean creating the
SGTable and mapping it in one call, eschewing the typestate entirely?
And the `SGTable` would own the backing data, and only release it upon
destruction and unmapping?
I guess the `SGTablePages` (or some renamed variant) would still be useful
to build the list and make sure the core types (e.g. `VVec`) are
ready-to-use with this new API.
One interesting thing to look at after a first version is available
would be a mechanism to ensure only one device (or only the CPU) can
access a buffer that has multiple mappings at any given time, with the
required synchronization performed transparently.
But for now I agree the simple use-case of single-device mapping is a
good way to get started.
Powered by blists - more mailing lists