Implement Send and Sync for clk
Subsystems (8)
Alice Ryhl
maintainerv5 cover Implement Send and Sync for clk
The Clk type is thread-safe, so let's mark it as thread-safe in the type system. This lets us get rid of hacks in drivers.
For Stephen's clk tree.
---
Changes in v5:
- Rebase on v7.0-rc1.
- Pick up Reviewed-by tags.
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Pick up Reviewed-by tags.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Rebase on v6.19-rc1.
- Pick up tags.
- Add fix for pwm driver as well.
- Link to v2: https://lore.kernel.org/r/[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 (3):
rust: clk: implement Send and Sync
tyr: remove impl Send/Sync for TyrData
pwm: th1520: remove impl Send/Sync for Th1520PwmDriverData
drivers/gpu/drm/tyr/driver.rs | 12 ------------ drivers/pwm/pwm_th1520.rs | 15 --------------- rust/kernel/clk.rs | 7 +++++++ 3 files changed, 7 insertions(+), 27 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20250904-clk-send-sync-3cfa7f4e1ce2
Best regards,
Signature · 1 line
Alice Ryhl <[email protected]>
Alice Ryhl
maintainerPATCH v5 1/3 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
@@ -128,6 +128,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.53.0.345.g96ddfc5eaa-goog
Alice Ryhl
maintainerPATCH v5 2/3 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.53.0.345.g96ddfc5eaa-goog
Alice Ryhl
maintainerPATCH v5 3/3 pwm: th1520: remove impl Send/Sync for Th1520PwmDriverData
In reply to Alice RyhlNow that clk implements Send and Sync, we no longer need to manually implement these traits for Th1520PwmDriverData. Thus remove the implementations.
--- drivers/pwm/pwm_th1520.rs | 15 --------------- 1 file changed, 15 deletions(-)
drivers/pwm/pwm_th1520.rs +0 -15
@@ -99,21 +99,6 @@ struct Th1520PwmDriverData { clk: Clk, } -// This `unsafe` implementation is a temporary necessity because the underlying `kernel::clk::Clk` -// type does not yet expose `Send` and `Sync` implementations. This block should be removed -// as soon as the clock abstraction provides these guarantees directly. -// TODO: Remove those unsafe impl's when Clk will support them itself. - -// SAFETY: The `devres` framework requires the driver's private data to be `Send` and `Sync`. -// We can guarantee this because the PWM core synchronizes all callbacks, preventing concurrent -// access to the contained `iomem` and `clk` resources. -unsafe impl Send for Th1520PwmDriverData {} - -// SAFETY: The same reasoning applies as for `Send`. The PWM core's synchronization -// guarantees that it is safe for multiple threads to have shared access (`&self`) -// to the driver data during callbacks. -unsafe impl Sync for Th1520PwmDriverData {} -impl pwm::PwmOps for Th1520PwmDriverData {type WfHw =Th1520WfHw ;
Signature · 1 line
2.53.0.345.g96ddfc5eaa-goog
Danilo Krummrich
maintainerHi Stephen,
Quoted 22 lines · Alice Ryhl
The Clk type is thread-safe, so let's mark it as thread-safe in the type system. This lets us get rid of hacks in drivers.
For Stephen's clk tree.
Signed-off-by Alice Ryhl <[email protected]>---
Changes in v5:
- Rebase on v7.0-rc1.
- Pick up Reviewed-by tags.
- Link to v4: https://lore.kernel.org/r/[email protected]Changes in v4:
- Pick up Reviewed-by tags.
- Link to v3: https://lore.kernel.org/r/[email protected]Changes in v3:
- Rebase on v6.19-rc1.
- Pick up tags.
- Add fix for pwm driver as well.
- Link to v2: https://lore.kernel.org/r/[email protected]
Quoted 4 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 has resent this over the past three cycles, but it hasn't been picked up yet. Please let me know if there are any concerns -- otherwise, I plan to take it through the drm-rust tree in a few days.
Thanks,
Danilo
Quoted 4 lines · Danilo Krummrich
Alice has resent this over the past three cycles, but it hasn't been picked up yet. Please let me know if there are any concerns -- otherwise, I plan to take it through the drm-rust tree in a few days.
+1, it will keep accumulating changes otherwise. Alice asked me about this one too; I can pick it up if needed too.
Cheers,
Miguel
Hi Danilo,
Quoted 25 lines · Danilo Krummrich
Hi Stephen,
Quoted 22 lines · Alice Ryhl
The Clk type is thread-safe, so let's mark it as thread-safe in the type system. This lets us get rid of hacks in drivers.
For Stephen's clk tree.
Signed-off-by Alice Ryhl <[email protected]>---
Changes in v5:
- Rebase on v7.0-rc1.
- Pick up Reviewed-by tags.
- Link to v4: https://lore.kernel.org/r/[email protected]Changes in v4:
- Pick up Reviewed-by tags.
- Link to v3: https://lore.kernel.org/r/[email protected]Changes in v3:
- Rebase on v6.19-rc1.
- Pick up tags.
- Add fix for pwm driver as well.
- Link to v2: https://lore.kernel.org/r/[email protected]
Quoted 8 lines
Quoted 4 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 has resent this over the past three cycles, but it hasn't been picked up yet. Please let me know if there are any concerns -- otherwise, I plan to take it through the drm-rust tree in a few days.
Stephen hasn't really been active lately, but Brian (in Cc) has been trying to pick up the patches falling through the cracks. It looks like such a candidate to me.
Maxime
Hi Danilo and Alice,
Quoted 29 lines · Maxime Ripard
Quoted 28 lines · Danilo Krummrich
Quoted 26 lines · Alice Ryhl
The Clk type is thread-safe, so let's mark it as thread-safe in the type system. This lets us get rid of hacks in drivers.
For Stephen's clk tree.
Signed-off-by Alice Ryhl <[email protected]>---
Changes in v5:
- Rebase on v7.0-rc1.
- Pick up Reviewed-by tags.
- Link to v4: https://lore.kernel.org/r/[email protected]Changes in v4:
- Pick up Reviewed-by tags.
- Link to v3: https://lore.kernel.org/r/[email protected]Changes in v3:
- Rebase on v6.19-rc1.
- Pick up tags.
- Add fix for pwm driver as well.
- Link to v2: https://lore.kernel.org/r/[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]
Quoted 7 lines
Quoted 3 lines
Alice has resent this over the past three cycles, but it hasn't been picked up yet. Please let me know if there are any concerns -- otherwise, I plan to take it through the drm-rust tree in a few days.
Stephen hasn't really been active lately, but Brian (in Cc) has been trying to pick up the patches falling through the cracks. It looks like such a candidate to me.
I'm planning to send another clk pull at the end of this week and I'll include this series.
Brian
Quoted 3 lines · Brian Masney
I'm planning to send another clk pull at the end of this week and I'll include this series.
Thanks Brian!
Cheers,
Miguel
Hi Danilo / Alice / Miguel,
Quoted 34 lines · Brian Masney
Quoted 33 lines · Maxime Ripard
Quoted 31 lines · Danilo Krummrich
Quoted 22 lines · Alice Ryhl
The Clk type is thread-safe, so let's mark it as thread-safe in the type system. This lets us get rid of hacks in drivers.
For Stephen's clk tree.
Signed-off-by Alice Ryhl <[email protected]>---
Changes in v5:
- Rebase on v7.0-rc1.
- Pick up Reviewed-by tags.
- Link to v4: https://lore.kernel.org/r/[email protected]Changes in v4:
- Pick up Reviewed-by tags.
- Link to v3: https://lore.kernel.org/r/[email protected]Changes in v3:
- Rebase on v6.19-rc1.
- Pick up tags.
- Add fix for pwm driver as well.
- Link to v2: https://lore.kernel.org/r/[email protected]Quoted 4 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 has resent this over the past three cycles, but it hasn't been picked up yet. Please let me know if there are any concerns -- otherwise, I plan to take it through the drm-rust tree in a few days.
Quoted 6 lines
Quoted 3 lines
Stephen hasn't really been active lately, but Brian (in Cc) has been trying to pick up the patches falling through the cracks. It looks like such a candidate to me.
I'm planning to send another clk pull at the end of this week and I'll include this series.
Stephen came on the list and started to merge this things this week. I was going to collect up more patches for him if he wasn't around, and intended to include this. However, since he's starting to collect things, I'm not going to send him a clk pull today.
It's up to you if you want to send this in via drm-rust or wait for Stephen.
Brian
Quoted 7 lines · Brian Masney
Stephen came on the list and started to merge this things this week. I was going to collect up more patches for him if he wasn't around, and intended to include this. However, since he's starting to collect things, I'm not going to send him a clk pull today.
It's up to you if you want to send this in via drm-rust or wait for Stephen.
I guess it depends if he plans to pick it up this cycle or not.
If he doesn't, then it may be best to just go forward with your Acked-bys -- Danilo can pick it up if DRM needs it in their branch, otherwise I can pick it up.
Thanks!
Cheers,
Miguel
Quoted 7 lines · Miguel Ojeda
Quoted 6 lines · Brian Masney
Stephen came on the list and started to merge this things this week. I was going to collect up more patches for him if he wasn't around, and intended to include this. However, since he's starting to collect things, I'm not going to send him a clk pull today.
Quoted 7 lines
Quoted 1 line
It's up to you if you want to send this in via drm-rust or wait for Stephen.
I guess it depends if he plans to pick it up this cycle or not.
If he doesn't, then it may be best to just go forward with your Acked-bys -- Danilo can pick it up if DRM needs it in their branch, otherwise I can pick it up.
I am not a clk maintainer, so I can't leave an Acked-by for you to pick this up unfortunately. I've been quite active in the clk subsystem though the last 6 months or so.
Brian
Danilo Krummrich
maintainerQuoted 3 lines · Brian Masney
I am not a clk maintainer, so I can't leave an Acked-by for you to pick this up unfortunately. I've been quite active in the clk subsystem though the last 6 months or so.
I'm not involved in the CLK subsystem, but maybe it would be a good chance to offer stepping up as co-maintainer (also given that Michael seems to be inactive for a couple of years now). :)
Quoted 8 lines · Danilo Krummrich
Quoted 3 lines · Brian Masney
I am not a clk maintainer, so I can't leave an Acked-by for you to pick this up unfortunately. I've been quite active in the clk subsystem though the last 6 months or so.
I'm not involved in the CLK subsystem, but maybe it would be a good chance to offer stepping up as co-maintainer (also given that Michael seems to be inactive for a couple of years now). :)
I mentioned to Stephen at the last LPC in Tokyo that I am interested in becoming a clk co-maintainer. I've sent him some git pulls for some of my work the last few development cycles, and he's pulled them. For this development cycle, I collected up some patches from others that I feel are ready, however I didn't hear back from Stephen yet:
https://lore.kernel.org/linux-clk/[email protected]/
He separately pulled some of that work via the posted patches into clk-next this week. I don't know if there was something he didn't like in my git pull.
To be honest, I initially helped with reviews trying to free up time for him to give feedback about my work to address some long-standing issues related to clk scaling that affect DRM and sound:
https://lore.kernel.org/linux-clk/[email protected]/
The kunit tests in patch 2 and 4 clearly show the issues. (I'm working on some fixes to this series right now based on feedback from Sashiko.)
I've become more interested in the clk subsystem as I learn more about it. There are other improvements that I am willing to make to the clk subsystem, however the current situation has been quite challenging to be honest. I will help with the linux-clk subsystem for the long term if there is the possibility of me eventually becoming a co-maintainer. Stephen can have veto power over what goes in.
Brian
Quoted 3 lines · Brian Masney
I mentioned to Stephen at the last LPC in Tokyo that I am interested in becoming a clk co-maintainer.
Thanks for the context, that sounds great -- more maintainers and reviewers are needed in the kernel.
But, of course, it is up to Stephen.
Another possibility Stephen could perhaps like if he doesn't want a co-maintainer for everything is having a sub-maintainer for the Rust side, possibly in a sub-entry (e.g. "COMMON CLK FRAMEWORK [RUST]", i.e. with the usual square brackets we use for that), assuming you are interested in that.
It is an approach that we have seen works well, because it is usually a win-win for maintainers that cannot commit time to review new Rust stuff, i.e. they get more people in their subsystem, they can use the opportunity to learn Rust (assuming they don't know it yet) and they can assess how often Rust changes are needed, yet they still control the changes (e.g. in cases a change on both sides needs to happen at once).
[ In any case, I don't know the context behind all this -- if I can help with anything, please let me know. ]
Thanks!
Cheers,
Miguel
Quoted 4 lines · Brian Masney
I am not a clk maintainer, so I can't leave an Acked-by for you to pick this up unfortunately. I've been quite active in the clk subsystem though the last 6 months or so.
In that case, I could take your Acked-by as an active contributor of clk if you are willing to provide it, i.e. with the "# Suffix" notation I introduced a year ago:
https://docs.kernel.org/process/submitting-patches.html#when-to-use-acked-by-cc-and-co-developed-by
cd9123eeb224 ("docs: submitting-patches: clarify Acked-by and
introduce "# Suffix"")
i.e. Acked-bys can nowadays be provided by other stakeholders apart from maintainers, e.g. people with domain knowledge, userspace reviewers of uAPI patches, key users and so on.
Especially so since you offered to be a co-maintainer long term, so I think having your Acked-by is way better that having no tag at all :)
Cheers,
Miguel
Brian Masney
Acked-byQuoted 14 lines · Brian Masney
Quoted 4 lines
I am not a clk maintainer, so I can't leave an Acked-by for you to pick this up unfortunately. I've been quite active in the clk subsystem though the last 6 months or so.
In that case, I could take your Acked-by as an active contributor of clk if you are willing to provide it, i.e. with the "# Suffix" notation I introduced a year ago:
https://docs.kernel.org/process/submitting-patches.html#when-to-use-acked-by-cc-and-co-developed-by
cd9123eeb224("docs: submitting-patches: clarify Acked-by and
introduce "# Suffix"")
Quoted 6 lines
i.e. Acked-bys can nowadays be provided by other stakeholders apart from maintainers, e.g. people with domain knowledge, userspace reviewers of uAPI patches, key users and so on.
Especially so since you offered to be a co-maintainer long term, so I think having your Acked-by is way better that having no tag at all :)
Sure...
Alice Ryhl
maintainerQuoted 7 lines · Miguel Ojeda
Quoted 6 lines · Brian Masney
Stephen came on the list and started to merge this things this week. I was going to collect up more patches for him if he wasn't around, and intended to include this. However, since he's starting to collect things, I'm not going to send him a clk pull today.
Quoted 7 lines
Quoted 1 line
It's up to you if you want to send this in via drm-rust or wait for Stephen.
I guess it depends if he plans to pick it up this cycle or not.
If he doesn't, then it may be best to just go forward with your Acked-bys -- Danilo can pick it up if DRM needs it in their branch, otherwise I can pick it up.
The drm-rust-next branch has closed now that -rc6 is out. If we don't hear from Stephen, do you mind picking it up Miguel?
Alice
Quoted 3 lines · Alice Ryhl
The drm-rust-next branch has closed now that -rc6 is out. If we don't hear from Stephen, do you mind picking it up Miguel?
Yeah, I will pick them -- I talked with Danilo about it a few days ago.
Cheers,
Miguel
Miguel Ojeda
AppliedQuoted 3 lines · Alice Ryhl
The Clk type is thread-safe, so let's mark it as thread-safe in the type system. This lets us get rid of hacks in drivers.
Applied to rust-next -- thanks everyone!
(Given we heard nothing this week either)
Cheers,
Miguel