Re: [PATCH v5 4/6] powercap: dtpm: Use generic powercap hierarchy helpers
From: Lukasz Luba
Date: Mon Nov 09 2026 - 04:12:56 EST
On 11/3/26 04:48, Daniel Lezcano wrote:
DTPM implements its own hierarchy creation and destruction logic while
the powercap core now provides generic helpers for this purpose.
Convert DTPM to use the generic powercap hierarchy infrastructure.
Duplicate the platform hierarchy before creating it, and use
powercap_hierarchy_create() and powercap_hierarchy_destroy() to manage
the DTPM zones.
Add DTPM callbacks to create and destroy the zones associated with each
powercap hierarchy node. Adapt the CPU and devfreq backends to return
the created DTPM instance and use the node name provided by the
hierarchy.
Convert the Rockchip RK3399 description to struct powercap_hierarchy
and keep the device tree path as DTPM-specific node data.
This removes the DTPM-specific hierarchy traversal and destruction code
and leaves the hierarchy management to the powercap core.
Preserve best-effort creation: an unavailable backend returns NULL to
skip its branch, and setup failures are warned about and skipped rather
than rolling back independent zones. Invalid node descriptors remain
fatal. Reject a DT node with a NULL path before calling
of_find_node_by_path(), treating it as an invalid descriptor rather
than an unavailable backend.
When the representative CPU is offline, find an active policy through an
online sibling whose related_cpus mask contains it. Hold the CPU hotplug
read lock during selection and setup, and initialize the zone through the
policy's active CPU while keeping the hierarchy-provided name. An entirely
offline policy still has no active CPU to initialize through.
Signed-off-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxxxxxxxx>
---
Changes in v5 (since v4):
- Reject a NULL DT node path with -EINVAL before invoking
dtpm_setup_dt(), as suggested by Lukasz Luba.
- Document that a missing path is an invalid hierarchy descriptor.
Changes in v4 (since v3):
- Rebase on v7.3; no code or commit-description changes.
Changes in v3 (since v2):
- Rebase on v7.3-rc7.
- Preserve best-effort branch creation using the generic NULL result.
- Find an online policy sibling for offline CPU representatives and
protect policy selection and setup against CPU hotplug.
- Keep generic API behavior and documentation in patch 1.
- Fix __initdata placement; match-table indentation is handled in patch 3.
- Name setup callback arguments and remove whitespace-only lines.
- Update the description.
drivers/powercap/dtpm.c | 180 +++++++++++++++-----------------
drivers/powercap/dtpm_cpu.c | 62 ++++++++---
drivers/powercap/dtpm_devfreq.c | 22 ++--
drivers/soc/rockchip/dtpm.c | 67 +++++++++---
include/linux/dtpm.h | 6 +-
5 files changed, 198 insertions(+), 139 deletions(-)
Thank you Daniel for addressing that, LGTM
Reviewed-by: Lukasz Luba <lukasz.luba@xxxxxxx>