From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Abdiel Janulgue" <abdiel.janulgue@gmail.com>, <dakr@kernel.org>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Valentin Obst" <kernel@valentinobst.de>,
"open list" <linux-kernel@vger.kernel.org>,
"Marek Szyprowski" <m.szyprowski@samsung.com>,
"Robin Murphy" <robin.murphy@arm.com>,
airlied@redhat.com, rust-for-linux@vger.kernel.org,
"open list:DMA MAPPING HELPERS" <iommu@lists.linux.dev>,
"Petr Tesarik" <petr@tesarici.cz>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
"Sui Jingfeng" <sui.jingfeng@linux.dev>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Michael Kelley" <mhklinux@outlook.com>
Subject: Re: [PATCH v4 3/3] rust: dma: add as_slice/write functions for CoherentAllocation
Date: Sun, 15 Jun 2025 21:51:41 +0900 [thread overview]
Message-ID: <DAN4CT3UVC8K.1EZOFGQDUDWZF@nvidia.com> (raw)
In-Reply-To: <0b71832f-f3a9-4109-baa1-f29a8327d872@gmail.com>
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@kernel.org>
>>> Signed-off-by: Abdiel Janulgue <abdiel.janulgue@gmail.com>
>>
>> A couple remaining nits/questions below, but FWIW:
>>
>> Reviewed-by: Alexandre Courbot <acourbot@nvidia.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!
next prev parent reply other threads:[~2025-06-15 12:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-02 8:53 [PATCH v4 0/3] Additional improvements for dma coherent allocator Abdiel Janulgue
2025-06-02 8:53 ` [PATCH v4 1/3] rust: dma: clarify wording and be consistent in `coherent` nomenclature Abdiel Janulgue
2025-06-13 12:49 ` Andreas Hindborg
2025-06-02 8:53 ` [PATCH v4 2/3] rust: dma: convert the read/write macros to return Result Abdiel Janulgue
2025-06-02 8:53 ` [PATCH v4 3/3] rust: dma: add as_slice/write functions for CoherentAllocation Abdiel Janulgue
2025-06-02 13:05 ` Alexandre Courbot
2025-06-13 9:45 ` Abdiel Janulgue
2025-06-13 10:31 ` Abdiel Janulgue
2025-06-15 12:51 ` Alexandre Courbot [this message]
2025-06-23 15:42 ` [PATCH v4 0/3] Additional improvements for dma coherent allocator Danilo Krummrich
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=DAN4CT3UVC8K.1EZOFGQDUDWZF@nvidia.com \
--to=acourbot@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=abdiel.janulgue@gmail.com \
--cc=airlied@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=herbert@gondor.apana.org.au \
--cc=iommu@lists.linux.dev \
--cc=kernel@valentinobst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mhklinux@outlook.com \
--cc=ojeda@kernel.org \
--cc=petr@tesarici.cz \
--cc=rdunlap@infradead.org \
--cc=robin.murphy@arm.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=sui.jingfeng@linux.dev \
--cc=tmgross@umich.edu \
/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).