From: Viresh Kumar <viresh.kumar@linaro.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
"Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>,
"Danilo Krummrich" <dakr@redhat.com>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Benno Lossin" <benno.lossin@proton.me>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Gary Guo" <gary@garyguo.net>,
"Michael Turquette" <mturquette@baylibre.com>,
"Miguel Ojeda" <ojeda@kernel.org>, "Nishanth Menon" <nm@ti.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Stephen Boyd" <sboyd@kernel.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Trevor Gross" <tmgross@umich.edu>,
"Viresh Kumar" <vireshk@kernel.org>,
"Viresh Kumar" <viresh.kumar@linaro.org>,
"Yury Norov" <yury.norov@gmail.com>
Cc: linux-pm@vger.kernel.org,
"Vincent Guittot" <vincent.guittot@linaro.org>,
rust-for-linux@vger.kernel.org,
"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Joakim Bech" <joakim.bech@linaro.org>,
"Rob Herring" <robh@kernel.org>, "Burak Emir" <bqe@google.com>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Russell King" <linux@armlinux.org.uk>,
linux-clk@vger.kernel.org, "Anisse Astier" <anisse@astier.eu>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH V11 00/15] Rust abstractions for clk, cpumask, cpufreq, OPP
Date: Mon, 21 Apr 2025 12:52:07 +0530 [thread overview]
Message-ID: <cover.1745218975.git.viresh.kumar@linaro.org> (raw)
Hello,
This series introduces initial Rust abstractions for a few subsystems: clk,
cpumask, cpufreq and Operating Performance Points (OPP).
The abstractions cover most of the interfaces exposed by cpufreq and OPP
subsystems. It also includes minimal abstractions for the clk and cpumask
frameworks, which are required by the cpufreq / OPP abstractions.
Additionally, a sample `rcpufreq-dt` driver is included. This is a
duplicate of the existing `cpufreq-dt` driver, which is a
platform-agnostic, device-tree based cpufreq driver commonly used on ARM
platforms.
The implementation has been tested using QEMU, ensuring that frequency
transitions, various configurations, and driver binding/unbinding work as
expected. However, performance measurements have not been conducted yet.
For those interested in testing these patches, they can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.git rust/cpufreq-dt
Based on 6.15-rc1.
V10->V11:
- cpufreq: Add TableIndex and make table methods safe.
- opp: Add freq module to keep all cfg stuff together.
- Use /// instead of // for documentation comments, even for private
definitions.
- Switch back to heap allocation for `struct cpufreq_driver` as it needs to be a
mutable object.
- Remove allow(dead_code)
- Improve few safety comments.
- Danilo: I haven't added your RBY tag to patch 13/15 as there were significant
changes from the initial version.
V9->V10:
- Don't remove atomic cpumask bindings from rust/helpers/cpumask.c
- Rename from_raw/from_raw_mut to as_ref/as_mut_ref (cpumask).
- Improved comments for non-atomic methods (cpumask).
- s/new/new_zero/ and s/new_uninit/new/ (cpumask).
- Avoid using explicit casts `as *const` or `as *mut`.
- Renamed `cpumask_box` to `cpumask_var` and `cpus`.
- Add local types in Rust for cpufreq flags that use BIT().
- Add const initializer for cpufreq::Registration and simplify new().
- Improved few safety comments.
V8->V9:
- clk (changes since V4):
- V4: https://lore.kernel.org/all/cover.1742276963.git.viresh.kumar@linaro.org/
- Add more methods in Hertz (as_khz/mhz/ghz).
- Reword a comment.
- cpumask (changes since V4):
- V4: https://lore.kernel.org/all/cover.1743572195.git.viresh.kumar@linaro.org/
- Add support for cpumask_{test_cpu|empty|full} and switch to using non-atomic
helpers for set/clear.
- s/CpumaskBox/CpumaskVar/
- s/set_all/setall/
- Improved examples, comments and commit logs.
- cpufreq/opp:
- V8: https://lore.kernel.org/all/cover.1738832118.git.viresh.kumar@linaro.org/
- Based on review comments received for clk/cpumask, a lot of changes were
made to cpufreq/opp bindings in code, comments, examples, etc..
- `attr` fields were dropped from cpufreq support, not required anymore
because of latest changes in cpufreq core.
- Use Hertz/MicroVolt/MicroWatt as units.
- Lots of other cleanups.
- Dropped Reviewed-by from Manos (there were too many changes).
V7->V8:
- Updated cpumask bindings to work with !CONFIG_CPUMASK_OFFSTACK case.
- Dropped few patches (property_present() and opp helpers), as they are already
merged.
- from_cpu() is marked unsafe.
- Included a patch by Anisse Astier, to solve a long standing issue with this
series.
- Dropped: "DO-NOT_MERGE: cpufreq: Rename cpufreq-dt platdev."
- Updated MAINTAINERS for new files.
- Other minor changes / cleanups.
V6->V7:
- from_cpu() is moved to cpu.rs and doesn't return ARef anymore, but just a
reference.
- Dropped cpufreq_table_len() and related validation in cpufreq core.
- Solved the issue with BIT() macro differently, using an enum now.
- Few patches are broken into smaller / independent patches.
- Improved Commit logs and SAFETY comments at few places.
- Removed print message from cpufreq driver.
- Rebased over linux-next/master.
- Few other minor changes.
V5->V6:
- Rebase over latest rust/dev branch, which changed few interfaces that the
patches were using.
- Included all other patches, which weren't included until now to focus only on
core APIs.
- Other minor cleanups, additions.
V4->V5:
- Rename Registration::register() as new().
- Provide a new API: Registration::new_foreign_owned() and use it for
rcpufreq_dt driver.
- Update MAINTAINERS file.
V3->V4:
- Fix bugs with freeing of OPP structure. Dropped the Drop routine and fixed
reference counting.
- Registration object of the cpufreq core is modified a bit to remove the
registered field, and few other cleanups.
- Use Devres for instead of platform data.
- Improve SAFETY comments.
V2->V3:
- Rebased on latest rust-device changes, which removed `Data` and so few changes
were required to make it work.
- use srctree links (Alice Ryhl).
- Various changes the OPP creation APIs, new APIs: from_raw_opp() and
from_raw_opp_owned() (Alice Ryhl).
- Inline as_raw() helpers (Alice Ryhl).
- Add new interface (`OPP::Token`) for dynamically created OPPs.
- Add Reviewed-by tag from Manos.
- Modified/simplified cpufreq registration structure / method a bit.
V1->V2:
- Create and use separate bindings for OF, clk, cpumask, etc (not included in
this patchset but pushed to the above branch). This helped removing direct
calls from the driver.
- Fix wrong usage of Pinning + Vec.
- Use Token for OPP Config.
- Use Opaque, transparent and Aref for few structures.
- Broken down into smaller patches to make it easy for reviewers.
- Based over staging/rust-device.
--
Viresh
Anisse Astier (1):
rust: macros: enable use of hyphens in module names
Viresh Kumar (14):
rust: cpumask: Add few more helpers
rust: cpumask: Add initial abstractions
MAINTAINERS: Add entry for Rust cpumask API
rust: clk: Add helpers for Rust code
rust: clk: Add initial abstractions
rust: cpu: Add from_cpu()
rust: opp: Add initial abstractions for OPP framework
rust: opp: Add abstractions for the OPP table
rust: opp: Add abstractions for the configuration options
rust: cpufreq: Add initial abstractions for cpufreq framework
rust: cpufreq: Extend abstractions for policy and driver ops
rust: cpufreq: Extend abstractions for driver registration
rust: opp: Extend OPP abstractions with cpufreq support
cpufreq: Add Rust-based cpufreq-dt driver
MAINTAINERS | 11 +
drivers/cpufreq/Kconfig | 12 +
drivers/cpufreq/Makefile | 1 +
drivers/cpufreq/rcpufreq_dt.rs | 229 ++++++
rust/bindings/bindings_helper.h | 4 +
rust/helpers/clk.c | 66 ++
rust/helpers/cpufreq.c | 10 +
rust/helpers/cpumask.c | 25 +
rust/helpers/helpers.c | 2 +
rust/kernel/clk.rs | 318 ++++++++
rust/kernel/cpu.rs | 30 +
rust/kernel/cpufreq.rs | 1305 +++++++++++++++++++++++++++++++
rust/kernel/cpumask.rs | 330 ++++++++
rust/kernel/lib.rs | 8 +
rust/kernel/opp.rs | 1143 +++++++++++++++++++++++++++
rust/macros/module.rs | 20 +-
16 files changed, 3506 insertions(+), 8 deletions(-)
create mode 100644 drivers/cpufreq/rcpufreq_dt.rs
create mode 100644 rust/helpers/clk.c
create mode 100644 rust/helpers/cpufreq.c
create mode 100644 rust/kernel/clk.rs
create mode 100644 rust/kernel/cpu.rs
create mode 100644 rust/kernel/cpufreq.rs
create mode 100644 rust/kernel/cpumask.rs
create mode 100644 rust/kernel/opp.rs
--
2.31.1.272.g89b43f80a514
next reply other threads:[~2025-04-21 7:22 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-21 7:22 Viresh Kumar [this message]
2025-04-21 7:22 ` [PATCH V11 01/15] rust: cpumask: Add few more helpers Viresh Kumar
2025-05-02 16:56 ` Yury Norov
2025-04-21 7:22 ` [PATCH V11 02/15] rust: cpumask: Add initial abstractions Viresh Kumar
2025-05-02 17:01 ` Yury Norov
2025-04-21 7:22 ` [PATCH V11 03/15] MAINTAINERS: Add entry for Rust cpumask API Viresh Kumar
2025-04-21 7:22 ` [PATCH V11 04/15] rust: clk: Add helpers for Rust code Viresh Kumar
2025-04-21 7:22 ` [PATCH V11 05/15] rust: clk: Add initial abstractions Viresh Kumar
2025-04-21 7:22 ` [PATCH V11 06/15] rust: macros: enable use of hyphens in module names Viresh Kumar
2025-04-21 7:22 ` [PATCH V11 07/15] rust: cpu: Add from_cpu() Viresh Kumar
2025-04-21 7:22 ` [PATCH V11 08/15] rust: opp: Add initial abstractions for OPP framework Viresh Kumar
2025-04-21 7:22 ` [PATCH V11 09/15] rust: opp: Add abstractions for the OPP table Viresh Kumar
2025-04-21 7:22 ` [PATCH V11 10/15] rust: opp: Add abstractions for the configuration options Viresh Kumar
2025-04-21 7:22 ` [PATCH V11 11/15] rust: cpufreq: Add initial abstractions for cpufreq framework Viresh Kumar
2025-04-21 7:22 ` [PATCH V11 12/15] rust: cpufreq: Extend abstractions for policy and driver ops Viresh Kumar
2025-04-21 7:22 ` [PATCH V11 13/15] rust: cpufreq: Extend abstractions for driver registration Viresh Kumar
2025-04-23 12:05 ` Danilo Krummrich
2025-04-24 6:01 ` Viresh Kumar
2025-04-23 12:08 ` Danilo Krummrich
2025-04-24 6:29 ` Viresh Kumar
2025-04-24 8:03 ` Danilo Krummrich
2025-04-24 10:51 ` Viresh Kumar
2025-04-21 7:22 ` [PATCH V11 14/15] rust: opp: Extend OPP abstractions with cpufreq support Viresh Kumar
2025-04-21 7:22 ` [PATCH V11 15/15] cpufreq: Add Rust-based cpufreq-dt driver Viresh Kumar
2025-05-02 7:01 ` [PATCH V11 00/15] Rust abstractions for clk, cpumask, cpufreq, OPP Viresh Kumar
2025-05-06 10:13 ` Andrew Ballance
2025-05-06 10:25 ` Miguel Ojeda
2025-05-08 2:10 ` Viresh Kumar
2025-05-08 2:52 ` Philip Li
2025-05-19 5:12 ` Viresh Kumar
2025-05-09 8:43 ` Miguel Ojeda
2025-05-13 11:15 ` Viresh Kumar
2025-05-19 5:00 ` Viresh Kumar
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=cover.1745218975.git.viresh.kumar@linaro.org \
--to=viresh.kumar@linaro.org \
--cc=a.hindborg@kernel.org \
--cc=alex.bennee@linaro.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=anisse@astier.eu \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=bqe@google.com \
--cc=dakr@kernel.org \
--cc=dakr@redhat.com \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=joakim.bech@linaro.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linux@rasmusvillemoes.dk \
--cc=manos.pitsidianakis@linaro.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=mturquette@baylibre.com \
--cc=nm@ti.com \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
--cc=tmgross@umich.edu \
--cc=vincent.guittot@linaro.org \
--cc=vireshk@kernel.org \
--cc=yury.norov@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).