[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <DAN4CT3UVC8K.1EZOFGQDUDWZF@nvidia.com>
Date: Sun, 15 Jun 2025 21:51:41 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Abdiel Janulgue" <abdiel.janulgue@...il.com>, <dakr@...nel.org>
Cc: "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 v4 3/3] rust: dma: add as_slice/write functions for
CoherentAllocation
On Fri Jun 13, 2025 at 6:45 PM JST, Abdiel Janulgue wrote:
> On 02/06/2025 16:05, Alexandre Courbot wrote:
>> On Mon Jun 2, 2025 at 5:53 PM JST, Abdiel Janulgue wrote:
>>> Add unsafe accessors for the region for reading or writing large
>>> blocks of data.
>>>
>>> Reviewed-by: Andreas Hindborg <a.hindborg@...nel.org>
>>> Signed-off-by: Abdiel Janulgue <abdiel.janulgue@...il.com>
>>
>> A couple remaining nits/questions below, but FWIW:
>>
>> Reviewed-by: Alexandre Courbot <acourbot@...dia.com>
>>> +
>>> + /// Writes data to the region starting from `offset`. `offset` is in units of `T`, not the
>>> + /// number of bytes.
>>
>> Reading this sentence it occured to me that `offset` may be ambiguous
>> here, as in my mind it rings as being in bytes unit. How about using
>> `index` throughout the file?
>
> Thanks! I don't have any strong opinion about this, I think it's enough
> that the subsequent paragraph makes it clear that the unit is in bytes
> unit? In any case, this could this be updated later after the merge?
I agree this can be its own follow-up change, especially since `offset`
is already used elsewhere in the code and this patch is consistent with
the existing nomenclature - let's fix them all together as a separate
patch.
>
>>> + /// ```
>>> + pub unsafe fn write(&self, src: &[T], offset: usize) -> Result {
>>
>> Can this function be written by leveraging `as_slice_mut` and
>> `clone_from_slice`?
>
> using `slice::clone_from_slice` would enforce the length of the coherent
> allocation to be always the same as src data. Not sure if that is what
> we want. Also, instead of just a straight memcpy, this would go through
> a 2-step layer (a call to `slice::from_raw_parts_mut` and then the
> `slice::clone_from_slice` itself)?.
Ack, thanks for the explanation!
Powered by blists - more mailing lists