From: Andreas Hindborg <a.hindborg@kernel.org>
To: "Danilo Krummrich" <dakr@kernel.org>
Cc: <bhelgaas@google.com>, <gregkh@linuxfoundation.org>,
<rafael@kernel.org>, <ojeda@kernel.org>,
<alex.gaynor@gmail.com>, <boqun.feng@gmail.com>,
<gary@garyguo.net>, <bjorn3_gh@protonmail.com>,
<benno.lossin@proton.me>, <aliceryhl@google.com>,
<tmgross@umich.edu>, <linux-pci@vger.kernel.org>,
<rust-for-linux@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] rust: platform: impl Send + Sync for platform::Device
Date: Wed, 19 Mar 2025 12:20:09 +0100 [thread overview]
Message-ID: <87iko5gtcm.fsf@kernel.org> (raw)
In-Reply-To: <20250318212940.137577-2-dakr@kernel.org> (Danilo Krummrich's message of "Tue, 18 Mar 2025 22:29:22 +0100")
"Danilo Krummrich" <dakr@kernel.org> writes:
> Commit 4d320e30ee04 ("rust: platform: fix unrestricted &mut
> platform::Device") changed the definition of platform::Device and
> discarded the implicitly derived Send and Sync traits.
>
> This isn't required by upstream code yet, and hence did not cause any
> issues. However, it is relied on by upcoming drivers, hence add it back
> in.
>
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
> ---
> rust/kernel/platform.rs | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs
> index c77c9f2e9aea..2811ca53d8b6 100644
> --- a/rust/kernel/platform.rs
> +++ b/rust/kernel/platform.rs
> @@ -233,3 +233,10 @@ fn as_ref(&self) -> &device::Device {
> unsafe { device::Device::as_ref(dev) }
> }
> }
> +
> +// SAFETY: A `Device` is always reference-counted and can be released from any thread.
> +unsafe impl Send for Device {}
> +
> +// SAFETY: `Device` can be shared among threads because all methods of `Device`
> +// (i.e. `Device<Normal>) are thread safe.
> +unsafe impl Sync for Device {}
Same as for 1/2:
# git am --show-current-patch=diff | patch -p1
patching file rust/kernel/platform.rs
Hunk #1 succeeded at 198 with fuzz 1 (offset -35 lines).
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Best regards,
Andreas Hindborg
next prev parent reply other threads:[~2025-03-19 11:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <ddLRqqXuFiaRVyCNUWk5k3cc0pJCteUQ5tBxGr5_7QXDeygE0d-YFc9nbJD0pNJ8RjZ3nCaWOCM56r0ZWmWdJw==@protonmail.internalid>
2025-03-18 21:29 ` [PATCH 1/2] rust: pci: impl Send + Sync for pci::Device Danilo Krummrich
2025-03-18 21:29 ` [PATCH 2/2] rust: platform: impl Send + Sync for platform::Device Danilo Krummrich
2025-03-19 11:20 ` Andreas Hindborg [this message]
2025-03-19 12:05 ` Alice Ryhl
2025-03-19 11:18 ` [PATCH 1/2] rust: pci: impl Send + Sync for pci::Device Andreas Hindborg
2025-03-19 11:25 ` Danilo Krummrich
2025-03-19 12:05 ` Alice Ryhl
2025-03-19 12:47 ` Danilo Krummrich
2025-03-19 13:16 ` Alice Ryhl
2025-03-19 13:30 ` Danilo Krummrich
2025-03-19 13:50 ` Danilo Krummrich
2025-03-19 14:08 ` 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=87iko5gtcm.fsf@kernel.org \
--to=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.