* [PATCH v2 1/2] rust: clk: implement Send and Sync
2025-10-20 9:35 [PATCH v2 0/2] Implement Send and Sync for clk Alice Ryhl
@ 2025-10-20 9:35 ` Alice Ryhl
2025-10-22 3:51 ` Viresh Kumar
2025-10-22 9:16 ` Danilo Krummrich
2025-10-20 9:35 ` [PATCH v2 2/2] tyr: remove impl Send/Sync for TyrData Alice Ryhl
2025-10-22 3:54 ` [PATCH v2 0/2] Implement Send and Sync for clk Boqun Feng
2 siblings, 2 replies; 10+ messages in thread
From: Alice Ryhl @ 2025-10-20 9:35 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd
Cc: Viresh Kumar, Miguel Ojeda, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, linux-clk,
rust-for-linux, linux-kernel, Alice Ryhl
These traits are required for drivers to embed the Clk type in their own
data structures because driver data structures are usually required to
be Send. Since the Clk type is thread-safe, implement the relevant
traits.
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
rust/kernel/clk.rs | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/rust/kernel/clk.rs b/rust/kernel/clk.rs
index 1e6c8c42fb3a321951e275101848b35e1ae5c2a8..0a290202da69669d670ddad2b6762a1d5f1d912e 100644
--- a/rust/kernel/clk.rs
+++ b/rust/kernel/clk.rs
@@ -129,6 +129,13 @@ mod common_clk {
#[repr(transparent)]
pub struct Clk(*mut bindings::clk);
+ // SAFETY: It is safe to call `clk_put` on another thread than where `clk_get` was called.
+ unsafe impl Send for Clk {}
+
+ // SAFETY: It is safe to call any combination of the `&self` methods in parallel, as the
+ // methods are synchronized internally.
+ unsafe impl Sync for Clk {}
+
impl Clk {
/// Gets [`Clk`] corresponding to a [`Device`] and a connection id.
///
--
2.51.0.915.g61a8936c21-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v2 1/2] rust: clk: implement Send and Sync
2025-10-20 9:35 ` [PATCH v2 1/2] rust: clk: implement Send and Sync Alice Ryhl
@ 2025-10-22 3:51 ` Viresh Kumar
2025-10-22 8:19 ` Alice Ryhl
2025-10-22 9:16 ` Danilo Krummrich
1 sibling, 1 reply; 10+ messages in thread
From: Viresh Kumar @ 2025-10-22 3:51 UTC (permalink / raw)
To: Alice Ryhl
Cc: Michael Turquette, Stephen Boyd, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, linux-clk,
rust-for-linux, linux-kernel
On 20-10-25, 09:35, Alice Ryhl wrote:
> These traits are required for drivers to embed the Clk type in their own
> data structures because driver data structures are usually required to
> be Send. Since the Clk type is thread-safe, implement the relevant
> traits.
>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
> ---
> rust/kernel/clk.rs | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/rust/kernel/clk.rs b/rust/kernel/clk.rs
> index 1e6c8c42fb3a321951e275101848b35e1ae5c2a8..0a290202da69669d670ddad2b6762a1d5f1d912e 100644
> --- a/rust/kernel/clk.rs
> +++ b/rust/kernel/clk.rs
> @@ -129,6 +129,13 @@ mod common_clk {
> #[repr(transparent)]
> pub struct Clk(*mut bindings::clk);
>
> + // SAFETY: It is safe to call `clk_put` on another thread than where `clk_get` was called.
> + unsafe impl Send for Clk {}
> +
> + // SAFETY: It is safe to call any combination of the `&self` methods in parallel, as the
> + // methods are synchronized internally.
> + unsafe impl Sync for Clk {}
> +
> impl Clk {
> /// Gets [`Clk`] corresponding to a [`Device`] and a connection id.
> ///
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v2 1/2] rust: clk: implement Send and Sync
2025-10-22 3:51 ` Viresh Kumar
@ 2025-10-22 8:19 ` Alice Ryhl
2025-10-22 9:33 ` Viresh Kumar
0 siblings, 1 reply; 10+ messages in thread
From: Alice Ryhl @ 2025-10-22 8:19 UTC (permalink / raw)
To: Viresh Kumar
Cc: Michael Turquette, Stephen Boyd, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, linux-clk,
rust-for-linux, linux-kernel
On Wed, Oct 22, 2025 at 09:21:38AM +0530, Viresh Kumar wrote:
> On 20-10-25, 09:35, Alice Ryhl wrote:
> > These traits are required for drivers to embed the Clk type in their own
> > data structures because driver data structures are usually required to
> > be Send. Since the Clk type is thread-safe, implement the relevant
> > traits.
> >
> > Signed-off-by: Alice Ryhl <aliceryhl@google.com>
> > ---
> > rust/kernel/clk.rs | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/rust/kernel/clk.rs b/rust/kernel/clk.rs
> > index 1e6c8c42fb3a321951e275101848b35e1ae5c2a8..0a290202da69669d670ddad2b6762a1d5f1d912e 100644
> > --- a/rust/kernel/clk.rs
> > +++ b/rust/kernel/clk.rs
> > @@ -129,6 +129,13 @@ mod common_clk {
> > #[repr(transparent)]
> > pub struct Clk(*mut bindings::clk);
> >
> > + // SAFETY: It is safe to call `clk_put` on another thread than where `clk_get` was called.
> > + unsafe impl Send for Clk {}
> > +
> > + // SAFETY: It is safe to call any combination of the `&self` methods in parallel, as the
> > + // methods are synchronized internally.
> > + unsafe impl Sync for Clk {}
> > +
> > impl Clk {
> > /// Gets [`Clk`] corresponding to a [`Device`] and a connection id.
> > ///
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
I'm guessing this means you want me to take it through drm-rust? See
what I put in the cover letter about choice of tree.
Alice
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v2 1/2] rust: clk: implement Send and Sync
2025-10-22 8:19 ` Alice Ryhl
@ 2025-10-22 9:33 ` Viresh Kumar
2025-10-22 14:08 ` Alice Ryhl
0 siblings, 1 reply; 10+ messages in thread
From: Viresh Kumar @ 2025-10-22 9:33 UTC (permalink / raw)
To: Alice Ryhl
Cc: Michael Turquette, Stephen Boyd, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, linux-clk,
rust-for-linux, linux-kernel
On 22-10-25, 08:19, Alice Ryhl wrote:
> I'm guessing this means you want me to take it through drm-rust? See
> what I put in the cover letter about choice of tree.
I was expecting Stephen to pick it up directly.
--
viresh
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] rust: clk: implement Send and Sync
2025-10-22 9:33 ` Viresh Kumar
@ 2025-10-22 14:08 ` Alice Ryhl
0 siblings, 0 replies; 10+ messages in thread
From: Alice Ryhl @ 2025-10-22 14:08 UTC (permalink / raw)
To: Viresh Kumar
Cc: Michael Turquette, Stephen Boyd, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, linux-clk,
rust-for-linux, linux-kernel
On Wed, Oct 22, 2025 at 03:03:26PM +0530, Viresh Kumar wrote:
> On 22-10-25, 08:19, Alice Ryhl wrote:
> > I'm guessing this means you want me to take it through drm-rust? See
> > what I put in the cover letter about choice of tree.
>
> I was expecting Stephen to pick it up directly.
Ah, that's fine, thanks.
Alice
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] rust: clk: implement Send and Sync
2025-10-20 9:35 ` [PATCH v2 1/2] rust: clk: implement Send and Sync Alice Ryhl
2025-10-22 3:51 ` Viresh Kumar
@ 2025-10-22 9:16 ` Danilo Krummrich
1 sibling, 0 replies; 10+ messages in thread
From: Danilo Krummrich @ 2025-10-22 9:16 UTC (permalink / raw)
To: Alice Ryhl
Cc: Michael Turquette, Stephen Boyd, Viresh Kumar, Miguel Ojeda,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Trevor Gross, Daniel Almeida, linux-clk,
rust-for-linux, linux-kernel
On 10/20/25 11:35 AM, Alice Ryhl wrote:
> These traits are required for drivers to embed the Clk type in their own
> data structures because driver data structures are usually required to
> be Send. Since the Clk type is thread-safe, implement the relevant
> traits.
>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 2/2] tyr: remove impl Send/Sync for TyrData
2025-10-20 9:35 [PATCH v2 0/2] Implement Send and Sync for clk Alice Ryhl
2025-10-20 9:35 ` [PATCH v2 1/2] rust: clk: implement Send and Sync Alice Ryhl
@ 2025-10-20 9:35 ` Alice Ryhl
2025-10-22 9:16 ` Danilo Krummrich
2025-10-22 3:54 ` [PATCH v2 0/2] Implement Send and Sync for clk Boqun Feng
2 siblings, 1 reply; 10+ messages in thread
From: Alice Ryhl @ 2025-10-20 9:35 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd
Cc: Viresh Kumar, Miguel Ojeda, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, linux-clk,
rust-for-linux, linux-kernel, Alice Ryhl
Now that clk implements Send and Sync, we no longer need to manually
implement these traits for TyrData. Thus remove the implementations.
The comment also mentions the regulator. However, the regulator had the
traits added in commit 9a200cbdb543 ("rust: regulator: implement Send
and Sync for Regulator<T>"), which is already in mainline.
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
drivers/gpu/drm/tyr/driver.rs | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
index d5625dd1e41c8406494b267d4ac560c442a8012c..574b85bbc497f8d1053d16a11f77ecbe2c87bfb2 100644
--- a/drivers/gpu/drm/tyr/driver.rs
+++ b/drivers/gpu/drm/tyr/driver.rs
@@ -53,18 +53,6 @@ pub(crate) struct TyrData {
pub(crate) gpu_info: GpuInfo,
}
-// Both `Clk` and `Regulator` do not implement `Send` or `Sync`, but they
-// should. There are patches on the mailing list to address this, but they have
-// not landed yet.
-//
-// For now, add this workaround so that this patch compiles with the promise
-// that it will be removed in a future patch.
-//
-// SAFETY: This will be removed in a future patch.
-unsafe impl Send for TyrData {}
-// SAFETY: This will be removed in a future patch.
-unsafe impl Sync for TyrData {}
-
fn issue_soft_reset(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {
regs::GPU_CMD.write(dev, iomem, regs::GPU_CMD_SOFT_RESET)?;
--
2.51.0.915.g61a8936c21-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v2 2/2] tyr: remove impl Send/Sync for TyrData
2025-10-20 9:35 ` [PATCH v2 2/2] tyr: remove impl Send/Sync for TyrData Alice Ryhl
@ 2025-10-22 9:16 ` Danilo Krummrich
0 siblings, 0 replies; 10+ messages in thread
From: Danilo Krummrich @ 2025-10-22 9:16 UTC (permalink / raw)
To: Alice Ryhl
Cc: Michael Turquette, Stephen Boyd, Viresh Kumar, Miguel Ojeda,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Trevor Gross, Daniel Almeida, linux-clk,
rust-for-linux, linux-kernel
On 10/20/25 11:35 AM, Alice Ryhl wrote:
> Now that clk implements Send and Sync, we no longer need to manually
> implement these traits for TyrData. Thus remove the implementations.
>
> The comment also mentions the regulator. However, the regulator had the
> traits added in commit 9a200cbdb543 ("rust: regulator: implement Send
> and Sync for Regulator<T>"), which is already in mainline.
>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/2] Implement Send and Sync for clk
2025-10-20 9:35 [PATCH v2 0/2] Implement Send and Sync for clk Alice Ryhl
2025-10-20 9:35 ` [PATCH v2 1/2] rust: clk: implement Send and Sync Alice Ryhl
2025-10-20 9:35 ` [PATCH v2 2/2] tyr: remove impl Send/Sync for TyrData Alice Ryhl
@ 2025-10-22 3:54 ` Boqun Feng
2 siblings, 0 replies; 10+ messages in thread
From: Boqun Feng @ 2025-10-22 3:54 UTC (permalink / raw)
To: Alice Ryhl
Cc: Michael Turquette, Stephen Boyd, Viresh Kumar, Miguel Ojeda,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, linux-clk,
rust-for-linux, linux-kernel
On Mon, Oct 20, 2025 at 09:35:33AM +0000, Alice Ryhl wrote:
> I added a patch to remove the Send/Sync impl for the Tyr driver as well.
> I think it's fine for the Tyr patch to land through whichever tree takes
> the clk patch, as there should be no non-trivial merge conflicts. Or we
> can also take the clk patch through drm-rust where tyr patches normally
> go if preferred by clk maintainers.
>
> Regarding Daniel's patch [1], I suggest that Daniel sends his type-state
> change rebased on top of this series (without including the patches in
> this series in his).
>
> [1]: https://lore.kernel.org/rust-for-linux/20250910-clk-type-state-v2-2-1b97c11bb631@collabora.com/
>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
For the whole series:
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Regards,
Boqun
> ---
> Changes in v2:
> - Rebase on v6.18-rc1.
> - Add patch to tyr driver.
> - Link to v1: https://lore.kernel.org/r/20250904-clk-send-sync-v1-1-48d023320eb8@google.com
>
> ---
> Alice Ryhl (2):
> rust: clk: implement Send and Sync
> tyr: remove impl Send/Sync for TyrData
>
> drivers/gpu/drm/tyr/driver.rs | 12 ------------
> rust/kernel/clk.rs | 7 +++++++
> 2 files changed, 7 insertions(+), 12 deletions(-)
> ---
> base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
> change-id: 20250904-clk-send-sync-3cfa7f4e1ce2
>
> Best regards,
> --
> Alice Ryhl <aliceryhl@google.com>
>
^ permalink raw reply [flat|nested] 10+ messages in thread