From: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
To: rafael@kernel.org
Cc: Daniel Lezcano <daniel.lezcano@kernel.org>,
Heiko Stuebner <heiko@sntech.de>, Shuah Khan <shuah@kernel.org>,
Manaf Meethalavalappu Pallikunhi
<manaf.pallikunhi@oss.qualcomm.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org,
linux-kselftest@vger.kernel.org
Subject: [PATCH v4 0/6] powercap: Add generic hierarchy support and convert DTPM
Date: Thu, 29 Oct 2026 17:56:44 +0100 [thread overview]
Message-ID: <cover.1793288783.git.daniel.lezcano@oss.qualcomm.com> (raw)
Powercap controllers may expose trees of power zones, such as packages,
clusters and CPUs. This series adds generic helpers to duplicate a static
hierarchy description, create its zones through backend callbacks, and
destroy them in reverse order. Parents must precede their children in the
node array; the helpers validate that ordering rather than sorting nodes.
Drivers supporting multiple platforms can place each platform's hierarchy
description and node array in initdata. powercap_hierarchy_dup() creates a
working copy of the selected hierarchy and rebases its parent pointers.
All original descriptions, including those for unused platforms, can then
be reclaimed automatically with init memory. Names and backend-private
data are not duplicated and must remain valid for the working hierarchy.
The controller supplies creation and destruction callbacks to connect the
generic hierarchy traversal to its backend. The creation callback receives
the control type, node name, private data and parent zone, registers the
zone with its operations and constraints, and returns it to the helper.
The destruction callback unregisters it during rollback or teardown.
The API supports both fatal creation errors, which roll back previously
created zones, and optional nodes: a NULL callback result skips a node and
its descendants while allowing independent branches to be created.
The helpers were motivated by the SPEL work and also let DTPM share the
same hierarchy infrastructure:
https://lore.kernel.org/lkml/20260702-qcom_spel_driver_upstream-v3-0-434d50f0c5b0@oss.qualcomm.com/
A kselftest exercises static and duplicated hierarchies, skipped branches,
reuse after partial destruction, and rejection of repeated creation. Its
userspace script checks the 16 exported zones and selected attribute
values, then removes the module with a sysfs attribute descriptor open.
DTPM is converted to the generic helpers while preserving best-effort
creation when individual backends are unavailable. The CPU backend finds
an online sibling when a hierarchy's representative CPU is offline.
Entirely offline policies remain unavailable during initialization.
The RK3399 description is reduced to one CPU entry per cpufreq policy.
The old backend already suppressed duplicate registration; the extra
entries were redundant descriptions, not additional registered zones.
Finally, a shared Rockchip virtual descriptor and an RK3588 CPU hierarchy
are added. RK3588's three frequency domains are represented by cpu@0,
cpu@400 and cpu@600 below a virtual package node; no GPU zone is added
for RK3588 in this series.
Changes in v4 (since v3):
- Rebase on v7.3.
- Address the selftest issues reported by Sashiko:
- Add a kselftest config fragment requesting CONFIG_POWERCAP,
CONFIG_MODULES and CONFIG_MODULE_UNLOAD, guard the module build with
CONFIG_POWERCAP, and skip building when prerequisites or Module.symvers
are missing instead of failing at modpost.
- Resolve the kernel output directory and pass absolute O=,
KBUILD_OUTPUT and module-output paths to Kbuild so cleanup works when
a relative O= is inherited from the parent selftest make invocation.
- Keep the statically initialized mutex in permanent module data so its
lockdep key does not point into freed module init memory. Retain a
separate init-only description for the hierarchy duplication test.
- Return KSFT_SKIP when powercap sysfs support or the test module is
unavailable, while retaining failures for actual module-load errors.
Changes in v3 (since v2):
- Rebase on v7.3-rc7.
- Add POWERCAP_HIERARCHY_INIT() and document static versus duplicated
hierarchy ownership and lock initialization.
- Explain how duplication retains the selected platform hierarchy while
init memory containing the original descriptions is reclaimed, and
describe the controller callbacks and their arguments.
- Reject populated hierarchies with -EBUSY before invoking callbacks.
- Validate names and parent ordering before zone creation, including for
static hierarchies; document the accepted hierarchy structure.
- Use explicit mutex locking, a signed reverse-loop index, and the clearer
powercap_node.zone member name.
- Define NULL creation results as skipped branches and retain rollback for
error pointers, preserving DTPM's best-effort behavior.
- Handle offline CPU representatives through an online policy sibling
while holding the CPU hotplug read lock.
- Fix selftest output-directory handling and module cleanup, use
powercap-owned zone allocations, and keep shell validation/counting in
the main shell so failures propagate.
- Extend and document selftest coverage for static creation, skipped
branches, hierarchy reuse, -EBUSY, and an open descriptor at teardown.
- Fix indentation, __initdata placement, unnamed setup callback arguments,
and whitespace-only lines reported by checkpatch and patch application.
- Correct descriptions of redundant CPU entries and actual sysfs checks.
Earlier generic hierarchy API and selftest submission:
https://lore.kernel.org/all/20260806110159.69690-1-daniel.lezcano@oss.qualcomm.com/
Daniel Lezcano (6):
powercap: Add generic zone hierarchy creation helpers
selftests/powercap: Add powercap hierarchy creation API tests
powercap: dtpm: Remove duplicate RK3399 CPU hierarchy nodes
powercap: dtpm: Use generic powercap hierarchy helpers
powercap: dtpm: Rename Rockchip virtual node descriptor
powercap: dtpm: Add RK3588 hierarchy
drivers/powercap/dtpm.c | 177 +++++-----
drivers/powercap/dtpm_cpu.c | 62 +++-
drivers/powercap/dtpm_devfreq.c | 22 +-
drivers/powercap/powercap_sys.c | 204 ++++++++++++
drivers/soc/rockchip/dtpm.c | 129 +++++--
include/linux/dtpm.h | 6 +-
include/linux/powercap.h | 205 ++++++++++++
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/powercap/Kbuild | 5 +
tools/testing/selftests/powercap/Makefile | 46 +++
tools/testing/selftests/powercap/config | 3 +
.../selftests/powercap/powercap_hierarchy.c | 314 ++++++++++++++++++
.../selftests/powercap/powercap_hierarchy.sh | 128 +++++++
13 files changed, 1150 insertions(+), 152 deletions(-)
create mode 100644 tools/testing/selftests/powercap/Kbuild
create mode 100644 tools/testing/selftests/powercap/Makefile
create mode 100644 tools/testing/selftests/powercap/config
create mode 100644 tools/testing/selftests/powercap/powercap_hierarchy.c
create mode 100755 tools/testing/selftests/powercap/powercap_hierarchy.sh
base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
--
2.43.0
WARNING: multiple messages have this Message-ID (diff)
From: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
To: rafael@kernel.org
Cc: Daniel Lezcano <daniel.lezcano@kernel.org>,
Heiko Stuebner <heiko@sntech.de>, Shuah Khan <shuah@kernel.org>,
Manaf Meethalavalappu Pallikunhi
<manaf.pallikunhi@oss.qualcomm.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org,
linux-kselftest@vger.kernel.org
Subject: [PATCH v4 0/6] powercap: Add generic hierarchy support and convert DTPM
Date: Thu, 29 Oct 2026 17:56:44 +0100 [thread overview]
Message-ID: <cover.1793288783.git.daniel.lezcano@oss.qualcomm.com> (raw)
Powercap controllers may expose trees of power zones, such as packages,
clusters and CPUs. This series adds generic helpers to duplicate a static
hierarchy description, create its zones through backend callbacks, and
destroy them in reverse order. Parents must precede their children in the
node array; the helpers validate that ordering rather than sorting nodes.
Drivers supporting multiple platforms can place each platform's hierarchy
description and node array in initdata. powercap_hierarchy_dup() creates a
working copy of the selected hierarchy and rebases its parent pointers.
All original descriptions, including those for unused platforms, can then
be reclaimed automatically with init memory. Names and backend-private
data are not duplicated and must remain valid for the working hierarchy.
The controller supplies creation and destruction callbacks to connect the
generic hierarchy traversal to its backend. The creation callback receives
the control type, node name, private data and parent zone, registers the
zone with its operations and constraints, and returns it to the helper.
The destruction callback unregisters it during rollback or teardown.
The API supports both fatal creation errors, which roll back previously
created zones, and optional nodes: a NULL callback result skips a node and
its descendants while allowing independent branches to be created.
The helpers were motivated by the SPEL work and also let DTPM share the
same hierarchy infrastructure:
https://lore.kernel.org/lkml/20260702-qcom_spel_driver_upstream-v3-0-434d50f0c5b0@oss.qualcomm.com/
A kselftest exercises static and duplicated hierarchies, skipped branches,
reuse after partial destruction, and rejection of repeated creation. Its
userspace script checks the 16 exported zones and selected attribute
values, then removes the module with a sysfs attribute descriptor open.
DTPM is converted to the generic helpers while preserving best-effort
creation when individual backends are unavailable. The CPU backend finds
an online sibling when a hierarchy's representative CPU is offline.
Entirely offline policies remain unavailable during initialization.
The RK3399 description is reduced to one CPU entry per cpufreq policy.
The old backend already suppressed duplicate registration; the extra
entries were redundant descriptions, not additional registered zones.
Finally, a shared Rockchip virtual descriptor and an RK3588 CPU hierarchy
are added. RK3588's three frequency domains are represented by cpu@0,
cpu@400 and cpu@600 below a virtual package node; no GPU zone is added
for RK3588 in this series.
Changes in v4 (since v3):
- Rebase on v7.3.
- Address the selftest issues reported by Sashiko:
- Add a kselftest config fragment requesting CONFIG_POWERCAP,
CONFIG_MODULES and CONFIG_MODULE_UNLOAD, guard the module build with
CONFIG_POWERCAP, and skip building when prerequisites or Module.symvers
are missing instead of failing at modpost.
- Resolve the kernel output directory and pass absolute O=,
KBUILD_OUTPUT and module-output paths to Kbuild so cleanup works when
a relative O= is inherited from the parent selftest make invocation.
- Keep the statically initialized mutex in permanent module data so its
lockdep key does not point into freed module init memory. Retain a
separate init-only description for the hierarchy duplication test.
- Return KSFT_SKIP when powercap sysfs support or the test module is
unavailable, while retaining failures for actual module-load errors.
Changes in v3 (since v2):
- Rebase on v7.3-rc7.
- Add POWERCAP_HIERARCHY_INIT() and document static versus duplicated
hierarchy ownership and lock initialization.
- Explain how duplication retains the selected platform hierarchy while
init memory containing the original descriptions is reclaimed, and
describe the controller callbacks and their arguments.
- Reject populated hierarchies with -EBUSY before invoking callbacks.
- Validate names and parent ordering before zone creation, including for
static hierarchies; document the accepted hierarchy structure.
- Use explicit mutex locking, a signed reverse-loop index, and the clearer
powercap_node.zone member name.
- Define NULL creation results as skipped branches and retain rollback for
error pointers, preserving DTPM's best-effort behavior.
- Handle offline CPU representatives through an online policy sibling
while holding the CPU hotplug read lock.
- Fix selftest output-directory handling and module cleanup, use
powercap-owned zone allocations, and keep shell validation/counting in
the main shell so failures propagate.
- Extend and document selftest coverage for static creation, skipped
branches, hierarchy reuse, -EBUSY, and an open descriptor at teardown.
- Fix indentation, __initdata placement, unnamed setup callback arguments,
and whitespace-only lines reported by checkpatch and patch application.
- Correct descriptions of redundant CPU entries and actual sysfs checks.
Earlier generic hierarchy API and selftest submission:
https://lore.kernel.org/all/20260806110159.69690-1-daniel.lezcano@oss.qualcomm.com/
Daniel Lezcano (6):
powercap: Add generic zone hierarchy creation helpers
selftests/powercap: Add powercap hierarchy creation API tests
powercap: dtpm: Remove duplicate RK3399 CPU hierarchy nodes
powercap: dtpm: Use generic powercap hierarchy helpers
powercap: dtpm: Rename Rockchip virtual node descriptor
powercap: dtpm: Add RK3588 hierarchy
drivers/powercap/dtpm.c | 177 +++++-----
drivers/powercap/dtpm_cpu.c | 62 +++-
drivers/powercap/dtpm_devfreq.c | 22 +-
drivers/powercap/powercap_sys.c | 204 ++++++++++++
drivers/soc/rockchip/dtpm.c | 129 +++++--
include/linux/dtpm.h | 6 +-
include/linux/powercap.h | 205 ++++++++++++
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/powercap/Kbuild | 5 +
tools/testing/selftests/powercap/Makefile | 46 +++
tools/testing/selftests/powercap/config | 3 +
.../selftests/powercap/powercap_hierarchy.c | 314 ++++++++++++++++++
.../selftests/powercap/powercap_hierarchy.sh | 128 +++++++
13 files changed, 1150 insertions(+), 152 deletions(-)
create mode 100644 tools/testing/selftests/powercap/Kbuild
create mode 100644 tools/testing/selftests/powercap/Makefile
create mode 100644 tools/testing/selftests/powercap/config
create mode 100644 tools/testing/selftests/powercap/powercap_hierarchy.c
create mode 100755 tools/testing/selftests/powercap/powercap_hierarchy.sh
base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
--
2.43.0
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
next reply other threads:[~2026-10-29 16:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 16:56 Daniel Lezcano [this message]
2026-10-29 16:56 ` [PATCH v4 0/6] powercap: Add generic hierarchy support and convert DTPM Daniel Lezcano
2026-10-29 16:56 ` [PATCH v4 1/6] powercap: Add generic zone hierarchy creation helpers Daniel Lezcano
2026-10-29 16:56 ` Daniel Lezcano
2026-10-29 16:56 ` [PATCH v4 2/6] selftests/powercap: Add powercap hierarchy creation API tests Daniel Lezcano
2026-10-29 16:56 ` Daniel Lezcano
2026-10-29 16:56 ` [PATCH v4 3/6] powercap: dtpm: Remove duplicate RK3399 CPU hierarchy nodes Daniel Lezcano
2026-10-29 16:56 ` Daniel Lezcano
2026-10-29 16:56 ` [PATCH v4 4/6] powercap: dtpm: Use generic powercap hierarchy helpers Daniel Lezcano
2026-10-29 16:56 ` Daniel Lezcano
2026-10-29 16:56 ` [PATCH v4 5/6] powercap: dtpm: Rename Rockchip virtual node descriptor Daniel Lezcano
2026-10-29 16:56 ` Daniel Lezcano
2026-10-29 16:56 ` [PATCH v4 6/6] powercap: dtpm: Add RK3588 hierarchy Daniel Lezcano
2026-10-29 16:56 ` Daniel Lezcano
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.1793288783.git.daniel.lezcano@oss.qualcomm.com \
--to=daniel.lezcano@oss.qualcomm.com \
--cc=daniel.lezcano@kernel.org \
--cc=heiko@sntech.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=manaf.pallikunhi@oss.qualcomm.com \
--cc=rafael@kernel.org \
--cc=shuah@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.