[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DAC20AXGABW2.X147X4JPMRBS@nvidia.com>
Date: Mon, 02 Jun 2025 21:41:59 +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 Mon Jun 2, 2025 at 8:40 PM JST, Jason Gunthorpe wrote:
> On Sat, May 31, 2025 at 09:54:20PM +0900, Alexandre Courbot wrote:
>
>> So if I understood your idea correctly, this would mean creating the
>> SGTable and mapping it in one call, eschewing the typestate entirely?
>
> Probably no need for a type state
No need indeed, nice and simple.
>
>> And the `SGTable` would own the backing data, and only release it upon
>> destruction and unmapping?
>
> But I don't think you can do this, it is not allowed to pin kmalloc
> memory for instance so you have to do something as you showed to tie
> the lifetime to the kmalloc across the sgtable lifetime.
The caller would have to pass already-pinned memory. And to allow both
the owner and borrowed patterns we could leverage the `Borrow` trait I
think.
Powered by blists - more mailing lists