From: Philip Radford <philip.radford@arm.com>
To: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, arm-scmi@vger.kernel.org,
linux-pm@vger.kernel.org
Cc: sudeep.holla@arm.com, james.quinlan@broadcom.com,
f.fainelli@gmail.com, vincent.guittot@linaro.org,
etienne.carriere@st.com, peng.fan@oss.nxp.com,
michal.simek@amd.com, quic_sibis@quicinc.com,
dan.carpenter@linaro.org, d-gole@ti.com,
souvik.chakravarty@arm.com, philip.radford@arm.com
Subject: [PATCH v9 12/13] powercap: arm_scmi: Add get_power_uw to synthetic node
Date: Wed, 9 Sep 2026 22:04:36 +0000 [thread overview]
Message-ID: <20260909220437.1254412-13-philip.radford@arm.com> (raw)
In-Reply-To: <20260909220437.1254412-1-philip.radford@arm.com>
Exposes the current power usage from the immediate children of the
synthetic (root) powercap node. Iterates over pr->spzones and sums per-zone
power.
Signed-off-by: Philip Radford <philip.radford@arm.com>
---
V8->V9
- Removed redundant if (!pr) check from instance_root_get_power_uw()
- Stopped returning a partial sum if one child read fails
---
drivers/powercap/arm_scmi_powercap.c | 34 ++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/drivers/powercap/arm_scmi_powercap.c b/drivers/powercap/arm_scmi_powercap.c
index b5397d7675e6..aac0b00490b2 100644
--- a/drivers/powercap/arm_scmi_powercap.c
+++ b/drivers/powercap/arm_scmi_powercap.c
@@ -17,6 +17,9 @@
#define to_scmi_powercap_zone(z) \
container_of(z, struct scmi_powercap_zone, zone)
+#define to_scmi_powercap_root(z) \
+ container_of(z, struct scmi_powercap_root, instance_root.zone)
+
static const struct scmi_powercap_proto_ops *powercap_ops;
struct scmi_powercap_zone {
@@ -453,9 +456,36 @@ static int instance_root_release(struct powercap_zone *pz)
return 0;
}
-static int instance_root_get_power_uw(struct powercap_zone *pz, u64 *v)
+static int instance_root_get_power_uw(struct powercap_zone *pz, u64 *power_uw)
{
- *v = 0;
+ struct scmi_powercap_root *pr = to_scmi_powercap_root(pz);
+ struct scmi_powercap_zone *child;
+
+ u64 p, acc = 0;
+ int i, ret;
+
+ if (!pz || !power_uw)
+ return -EINVAL;
+
+ for (i = 0; i < pr->num_zones; i++) {
+ child = &pr->spzones[i];
+
+ if (!child->registered || child->invalid)
+ continue;
+
+ if (child->info->parent_id != SCMI_POWERCAP_ROOT_ZONE_ID)
+ continue;
+
+ ret = scmi_powercap_get_power_uw(&child->zone, &p);
+ if (ret) {
+ dev_dbg(child->dev, "Failed to read child power: %d\n", ret);
+ return ret;
+ }
+
+ acc += p;
+ }
+
+ *power_uw = acc;
return 0;
}
--
2.25.1
next prev parent reply other threads:[~2026-09-09 22:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 22:04 [PATCH v9 00/13] Add support for SCMIv4.0 Powercap Extensions Philip Radford
2026-09-09 22:04 ` [PATCH v9 01/13] powercap: Add enable disable control-type Philip Radford
2026-09-09 22:04 ` [PATCH v9 02/13] firmware: arm_scmi: Add an optional custom parameter to fastchannel helpers Philip Radford
2026-09-09 22:04 ` [PATCH v9 03/13] firmware: arm_scmi: Refactor powercap domain layout Philip Radford
2026-09-09 22:04 ` [PATCH v9 04/13] firmware: arm_scmi: Add SCMIv4.0 Powercap basic support Philip Radford
2026-09-09 22:04 ` [PATCH v9 05/13] firmware: arm_scmi: Add SCMIv4.0 Powercap FCs support Philip Radford
2026-09-09 22:04 ` [PATCH v9 06/13] firmware: arm_scmi: Add SCMIV4.0 Powercap notifications support Philip Radford
2026-09-09 22:04 ` [PATCH v9 07/13] firmware: arm_scmi: Extend powercap report to include MAI Philip Radford
2026-09-09 22:04 ` [PATCH v9 08/13] include: trace: Add new parameter to trace_scmi_fc_call Philip Radford
2026-09-09 22:04 ` [PATCH v9 09/13] powercap: arm_scmi: Enable multiple constraints support Philip Radford
2026-09-09 22:04 ` [PATCH v9 10/13] firmware: arm_scmi: add Powercap MAI get/set support Philip Radford
2026-09-09 22:04 ` [PATCH v9 11/13] powercap: arm_scmi: Create synthetic parent node for multi-instance Philip Radford
2026-09-09 22:04 ` Philip Radford [this message]
2026-09-09 22:04 ` [PATCH v9 13/13] powercap: arm_scmi: Synthetic zone enable/disable Philip Radford
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=20260909220437.1254412-13-philip.radford@arm.com \
--to=philip.radford@arm.com \
--cc=arm-scmi@vger.kernel.org \
--cc=d-gole@ti.com \
--cc=dan.carpenter@linaro.org \
--cc=etienne.carriere@st.com \
--cc=f.fainelli@gmail.com \
--cc=james.quinlan@broadcom.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=peng.fan@oss.nxp.com \
--cc=quic_sibis@quicinc.com \
--cc=souvik.chakravarty@arm.com \
--cc=sudeep.holla@arm.com \
--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