linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alice Ryhl <aliceryhl@google.com>
To: Danilo Krummrich <dakr@kernel.org>
Cc: abdiel.janulgue@gmail.com, daniel.almeida@collabora.com,
	 robin.murphy@arm.com, a.hindborg@kernel.org, ojeda@kernel.org,
	 alex.gaynor@gmail.com, boqun.feng@gmail.com, gary@garyguo.net,
	 bjorn3_gh@protonmail.com, lossin@kernel.org, tmgross@umich.edu,
	 acourbot@nvidia.com, rust-for-linux@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: dma: require mutable reference for as_slice_mut() and write()
Date: Tue, 1 Jul 2025 10:24:33 +0000	[thread overview]
Message-ID: <aGO3QgrGSgN5X2hz@google.com> (raw)
In-Reply-To: <20250628165120.90149-1-dakr@kernel.org>

On Sat, Jun 28, 2025 at 06:49:54PM +0200, Danilo Krummrich wrote:
> Given the safety requirements of as_slice_mut() and write() taking an
> immutable reference is technically not incorrect.
> 
> However, let's leverage the compiler's capabilities and require a
> mutable reference to ensure exclusive access.
> 
> This also fixes a clippy warning introduced with 1.88:
> 
>   warning: mutable borrow from immutable input(s)
>      --> rust/kernel/dma.rs:297:78
>       |
>   297 |     pub unsafe fn as_slice_mut(&self, offset: usize, count: usize) -> Result<&mut [T]> {
>       |                                                                              ^^^^^^^^
> 
> Fixes: d37a39f607c4 ("rust: dma: add as_slice/write functions for CoherentAllocation")
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>

I'm not sure if `as_slice_mut()` is exactly the right API we want
long-term, but this is a step in the right direction.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

  parent reply	other threads:[~2025-07-01 10:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <VIEdXN6CCu8vh_24Ew2HvHggO8rA-9Vg6BHi7y6kj3Wh2W-s1If1YITFfHta4MCYR3GQbYhffNc81E0AjI1AUg==@protonmail.internalid>
2025-06-28 16:49 ` [PATCH] rust: dma: require mutable reference for as_slice_mut() and write() Danilo Krummrich
2025-06-29  1:10   ` Alexandre Courbot
2025-06-30  7:48   ` Abdiel Janulgue
2025-06-30 10:33   ` Andreas Hindborg
2025-07-01 10:24   ` Alice Ryhl [this message]
2025-07-01 12:17   ` 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=aGO3QgrGSgN5X2hz@google.com \
    --to=aliceryhl@google.com \
    --cc=a.hindborg@kernel.org \
    --cc=abdiel.janulgue@gmail.com \
    --cc=acourbot@nvidia.com \
    --cc=alex.gaynor@gmail.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).