From: Abdiel Janulgue <abdiel.janulgue@gmail.com>
To: Daniel Almeida <daniel.almeida@collabora.com>
Cc: rust-for-linux@vger.kernel.org, a.hindborg@kernel.org,
linux-kernel@vger.kernel.org, dakr@redhat.com,
airlied@redhat.com, miguel.ojeda.sandonis@gmail.com,
wedsonaf@gmail.com, Andreas Hindborg <a.hindborg@samsung.com>
Subject: Re: [PATCH 2/2] rust: add dma coherent allocator abstraction.
Date: Thu, 31 Oct 2024 11:45:40 +0200 [thread overview]
Message-ID: <ee45ae5f-133d-4d38-bb4a-d3515790feb4@gmail.com> (raw)
In-Reply-To: <6CF29D3D-C930-4274-9BAC-365C0F32DF56@collabora.com>
Hi,
On 28/10/2024 17:38, Daniel Almeida wrote:
>
> This patch is not a v2, so was anybody against using a raw pointer at some time?
The original idea behind this was to improve a little bit from raw
pointer manipulation when indexing the data. But yeah, for the proper v2
I now reintroduced the raw pointer but dynamically created slice from it
as you suggested below. :)
>
> Not sure why there’s ’static here. The lifetime of `cpu_addr` is the lifetime of the object.
>
> This is why keeping a pointer and building the slice as needed is actually a better approach, IMHO.
> That will correctly express the lifetime we want to enforce, i.e.:
>
> ```
> pub fn cpu(&’a self) -> &’a mut [T];
> ```
>
> Where ‘a is automatically filled in, of course.
>
>> + /// # Examples
>> + ///
>> + /// ```
>> + /// use kernel::device::Device;
>> + /// use kernel::dma::CoherentAllocation;
>> + ///
>> + /// # fn dox(dev: &Device) -> Result<()> {
>> + /// let c: CoherentAllocation<u64> = CoherentAllocation::alloc_coherent(dev, 4, GFP_KERNEL)?;
>
> Have you considered ZSTs? What happens if someone writes down:
>
> ```
> let c = CoherentAllocation<()> = …
> ```
>
> This doesn’t really make sense and should be forbidden.
Would restricting it to a primitive type make sense?
e.g:
pub struct CoherentAllocation<T: BitAnd + BitOr>
I'm not sure, but are there other ways to enforce that restriction?
>
>> 2.43.0
>>
>>
>
> Everything else looks good to me!
Thanks,
Abdiel
>
> — Daniel
>
next prev parent reply other threads:[~2024-10-31 9:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <gOYx0SWgtHGMFdeca-cxwYWFvr0hwCWCLCyLndrSSh8p9dU1wFSDL3ssAL-zaCfEbUyQ49dpsn8XaGfSamF-Sw==@protonmail.internalid>
2024-10-23 11:32 ` [PATCH 0/2] Add dma coherent allocator abstraction Abdiel Janulgue
2024-10-23 11:32 ` [PATCH 1/2] rust: error: Add EOVERFLOW Abdiel Janulgue
2024-10-23 11:39 ` Alice Ryhl
2024-10-24 6:09 ` Abdiel Janulgue
2024-10-23 11:32 ` [PATCH 2/2] rust: add dma coherent allocator abstraction Abdiel Janulgue
2024-10-28 7:51 ` Abdiel Janulgue
2024-10-28 15:38 ` Daniel Almeida
2024-10-31 9:45 ` Abdiel Janulgue [this message]
2024-11-11 12:14 ` [PATCH 0/2] Add " Andreas Hindborg
2024-11-11 12:54 ` Abdiel Janulgue
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=ee45ae5f-133d-4d38-bb4a-d3515790feb4@gmail.com \
--to=abdiel.janulgue@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=a.hindborg@samsung.com \
--cc=airlied@redhat.com \
--cc=dakr@redhat.com \
--cc=daniel.almeida@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=wedsonaf@gmail.com \
/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).