From: Viresh Kumar <viresh.kumar@linaro.org>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
Stephen Boyd <sboyd@kernel.org>
Cc: "Michael Turquette" <mturquette@baylibre.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Russell King" <linux@armlinux.org.uk>,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>
Subject: Re: [PATCH V3 2/2] rust: Add initial clk abstractions
Date: Fri, 7 Mar 2025 12:53:22 +0530 [thread overview]
Message-ID: <20250307072322.5w2i7dxtcaani2ok@vireshk-i7> (raw)
In-Reply-To: <1ad3e7e2f8f2fc375b472d7676e47f5d.sboyd@kernel.org>
On 06-03-25, 12:58, Stephen Boyd wrote:
> Quoting Viresh Kumar (2025-03-05 20:40:28)
> > 2. clk is enabled / disabled from different routines:
> >
> > In this case the caller needs to call dismiss to avoid the automatic freeing
> > of resource. Alternatively the returned value can be stored too somewhere,
> > but I am not sure if it what users will end up doing.
> >
> > fn probe(...) -> Result {
> > clk.enable()?.dismiss();
>
> Yuck. Can't we tie the lifetime of the clk to the consumer device driver
> so that when the driver is unbound the clk is dropped
Yes, that is how it would work right now, the driver needs to store the clk
instance locally. As soon as Clk would be dropped, clk_put() will be called.
> and it decrements all the enables/prepares and puts the clk with clk_put()?
Miguel, how do you suggest we do this ?
> A ScopeGuard could probably be used for that on the struct Clk itself,
Not sure if I misunderstood that, but as soon as Clk goes out of scope,
clk_put() will be called from drop() anyway.
> but we would
> want to track the enables and prepares in the rust wrapper code until
> the struct clk can be inspected directly.
So Rust abstraction needs to do some sort of refcounting for this I believe. Not
sure if we want to do it and if yes, then how.
> The problem is we don't know how a platform may implement the clk API,
> and CCF hasn't taken over the entire kernel yet so we can't rely on some
> private API between the CCF and the rust wrapper to know how many
> clk_disable()s to call, or even rely on clk_put() to do the work for us.
> Can the rust wrappers depend on CONFIG_COMMON_CLK? If they did then we
> could have some private API between rust and CCF. We probably don't want
> rust code to _not_ use COMMON_CLK underneath so we can encourage the
> last few holdouts to migrate to CCF. I'd lean towards depending on
> COMMON_CLK for the rust wrappers in this case.
Sure.
--
viresh
next prev parent reply other threads:[~2025-03-07 7:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 9:58 [PATCH V3 0/2] rust: Add basic clock abstractions Viresh Kumar
2025-03-03 9:58 ` [PATCH V3 1/2] rust: Add clk helpers Viresh Kumar
2025-03-03 10:05 ` Alice Ryhl
2025-03-03 11:15 ` Viresh Kumar
2025-03-03 9:58 ` [PATCH V3 2/2] rust: Add initial clk abstractions Viresh Kumar
2025-03-03 10:04 ` Alice Ryhl
2025-03-03 11:32 ` Viresh Kumar
2025-03-03 10:16 ` Miguel Ojeda
2025-03-03 11:44 ` Viresh Kumar
2025-03-03 15:50 ` Miguel Ojeda
2025-03-04 8:53 ` Viresh Kumar
2025-03-04 9:37 ` Miguel Ojeda
2025-03-05 11:46 ` Viresh Kumar
2025-03-05 22:31 ` Stephen Boyd
2025-03-06 4:40 ` Viresh Kumar
2025-03-06 20:58 ` Stephen Boyd
2025-03-07 7:23 ` Viresh Kumar [this message]
2025-03-06 12:33 ` Danilo Krummrich
2025-03-08 2:03 ` Daniel Almeida
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=20250307072322.5w2i7dxtcaani2ok@vireshk-i7 \
--to=viresh.kumar@linaro.org \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=mturquette@baylibre.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=tmgross@umich.edu \
--cc=vincent.guittot@linaro.org \
/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
all inboxes | Powered by JetHome®