mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Almeida <daniel.almeida@collabora.com>
To: Abdiel Janulgue <abdiel.janulgue@gmail.com>
Cc: "Robin Murphy" <robin.murphy@arm.com>,
	"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>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Valentin Obst" <kernel@valentinobst.de>,
	"open list:RUST" <rust-for-linux@vger.kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>,
	"Christoph Hellwig" <hch@lst.de>,
	"Marek Szyprowski" <m.szyprowski@samsung.com>,
	airlied@redhat.com,
	"open list:DMA MAPPING HELPERS" <iommu@lists.linux.dev>
Subject: Re: [PATCH v6 2/2] rust: add dma coherent allocator abstraction.
Date: Thu, 5 Dec 2024 13:41:38 -0300	[thread overview]
Message-ID: <F62F742D-B373-43D1-B527-9B9D3E5DB211@collabora.com> (raw)
In-Reply-To: <c9baa4bb-81db-42ae-98be-d8cb7d57f237@gmail.com>

Hi Abdiel,

> On 5 Dec 2024, at 11:25, Abdiel Janulgue <abdiel.janulgue@gmail.com> wrote:
> 
> On 05/12/2024 15:07, Robin Murphy wrote:
>>> +    pub fn alloc_coherent(
>>> +        dev: &Device,
>>> +        count: usize,
>>> +        flags: kernel::alloc::Flags,
>> Might it be worth adding at least a placeholder type and argument for "attrs" as well, so there's less churn involved in coming back and adding it later? Or is the intention to have a separate dma_alloc_attrs() constructor for such users?
> 
> It certainly is possible to include attrs in the constructor using Option:
> ```
>    pub fn alloc_coherent(
>        dev: &Device,
>        count: usize,
>        flags: kernel::alloc::Flags,
>        attrs: Option<u64>,
>    ) -> Result<CoherentAllocation<T>> {
> 
> <cut>
>        let ret = unsafe {
>            bindings::dma_alloc_attrs(
>                dev.as_raw(),
>                size,
>                &mut dma_handle, flags.as_raw(),
>                attrs.unwrap_or(0),
>            )
>        };
> <cut>
>    }
> 
> ```
> So the signature of the constructor could be:
> 
> let c = CoherentAllocation::alloc_coherent(dev, 4, GFP_KERNEL, None)?;
> 
> Andreas, Miguel, Daniel, any thoughts?
> 
> Regards,
> Abdiel
> 

Instead of a raw u64, you should take inspiration from the work in the Alloc crate and elsewhere to define
a proper `flags` type, which you can name `attr` in this case.

— Daniel




  reply	other threads:[~2024-12-05 16:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-05 11:32 [PATCH v6 1/2] rust: error: Add EOVERFLOW Abdiel Janulgue
2024-12-05 11:32 ` [PATCH v6 2/2] rust: add dma coherent allocator abstraction Abdiel Janulgue
2024-12-05 13:07   ` Robin Murphy
2024-12-05 14:25     ` Abdiel Janulgue
2024-12-05 16:41       ` Daniel Almeida [this message]
2024-12-05 16:47         ` Robin Murphy

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=F62F742D-B373-43D1-B527-9B9D3E5DB211@collabora.com \
    --to=daniel.almeida@collabora.com \
    --cc=a.hindborg@kernel.org \
    --cc=abdiel.janulgue@gmail.com \
    --cc=airlied@redhat.com \
    --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=hch@lst.de \
    --cc=iommu@lists.linux.dev \
    --cc=kernel@valentinobst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=ojeda@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=rust-for-linux@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®