Implement Send and Sync for clk
Subsystems (5)
Alice Ryhl
maintainerv2 cover Implement Send and Sync for clk
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/[email protected]/
---
Changes in v2:
- Rebase on v6.18-rc1.
- Add patch to tyr driver.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
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,
Signature · 1 line
Alice Ryhl <[email protected]>
Alice Ryhl
maintainerPATCH v2 1/2 rust: clk: implement Send and Sync
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.
--- rust/kernel/clk.rs | 7 +++++++ 1 file changed, 7 insertions(+)
rust/kernel/clk.rs +7 -0
@@ -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. ///
Signature · 1 line
2.51.0.915.g61a8936c21-goog
Re: [PATCH v2 1/2] rust: clk: implement Send and Sync
Quoted 18 lines · 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 <[email protected]>--- rust/kernel/clk.rs | 7 +++++++ 1 file changed, 7 insertions(+)rust/kernel/clk.rs +0
-0@@ -129,6 +129,13 @@ mod common_clk {#[repr(transparent)] pub struct Clk (*mut bindings::clk );
rust/kernel/clk.rs mod common_clk { · line 141
Quoted 10 lines
rust/kernel/clk.rs +7
-0+// 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. ///
Signature · 1 line
viresh
Alice Ryhl
maintainerRe: [PATCH v2 1/2] rust: clk: implement Send and Sync
Quoted 19 lines · Viresh Kumar
Quoted 18 lines · 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 <[email protected]>--- rust/kernel/clk.rs | 7 +++++++ 1 file changed, 7 insertions(+)rust/kernel/clk.rs +0
-0@@ -129,6 +129,13 @@ mod common_clk {#[repr(transparent)] pub struct Clk (*mut bindings::clk );
Quoted 12 lines
rust/kernel/clk.rs mod common_clk { · line 141
Quoted 10 lines
rust/kernel/clk.rs +7
-0+// 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 <[email protected]>
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
Re: [PATCH v2 1/2] rust: clk: implement Send and Sync
Quoted 2 lines · Alice Ryhl
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.
Signature · 1 line
viresh
Alice Ryhl
maintainerRe: [PATCH v2 1/2] rust: clk: implement Send and Sync
Quoted 5 lines · Viresh Kumar
Quoted 2 lines · Alice Ryhl
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
Re: [PATCH v2 1/2] rust: clk: implement Send and Sync
In reply to Alice RyhlQuoted 6 lines · 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 <[email protected]>
Alice Ryhl
maintainerPATCH v2 2/2 tyr: remove impl Send/Sync for TyrData
In reply to Alice RyhlNow 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.
--- drivers/gpu/drm/tyr/driver.rs | 12 ------------ 1 file changed, 12 deletions(-)
drivers/gpu/drm/tyr/driver.rs +0 -12
@@ -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 )?;
Signature · 1 line
2.51.0.915.g61a8936c21-goog
Re: [PATCH v2 2/2] tyr: remove impl Send/Sync for TyrData
Quoted 8 lines · 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 <[email protected]>
Quoted 6 lines · Alice Ryhl
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.
Quoted 7 lines
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/[email protected]/
Signed-off-by Alice Ryhl <[email protected]>
For the whole series:
Regards,
Boqun
Quoted 22 lines
---
Changes in v2:
- Rebase on v6.18-rc1.
- Add patch to tyr driver.
- Link to v1: https://lore.kernel.org/r/[email protected]---
Alice Ryhl (2):
rust: clk: implement Send and Sync
tyr: remove impl Send/Sync for TyrDatadrivers/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-3cfa7f4e1ce2Best regards,
Signature · 1 line
Alice Ryhl <[email protected]>
Alice Ryhl
maintainerQuoted 6 lines · Alice Ryhl
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.
Quoted 7 lines
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/[email protected]/
Signed-off-by Alice Ryhl <[email protected]>
Stephen, any chance you could pick up this series? Thanks!
Alice