[PATCH v10 09/13] powercap: arm_scmi: Enable multiple constraints support

From: Philip Radford

Date: Tue Nov 03 2026 - 18:14:06 EST


From: Cristian Marussi <cristian.marussi@xxxxxxx>

Initialize the domains with all the discovered available constraints,
making available multiple per-domain constraints when the platform has
advertised support for multiple concurrent power limits.

CC: "Rafael J. Wysocki" <rafael@xxxxxxxxxx>
CC: linux-pm@xxxxxxxxxxxxxxx
Signed-off-by: Cristian Marussi <cristian.marussi@xxxxxxx>
[Philip: Amended Copyright]
Signed-off-by: Philip Radford <philip.radford@xxxxxxx>
---
V9->V10
- clamp exposed constraints to MAX_CONSTRAINTS_PER_ZONE instead of failing probe
- warn when firmware advertises more CPLs than the powercap core can expose
---
drivers/powercap/arm_scmi_powercap.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/powercap/arm_scmi_powercap.c b/drivers/powercap/arm_scmi_powercap.c
index 0753a6938512..0c2a20f06979 100644
--- a/drivers/powercap/arm_scmi_powercap.c
+++ b/drivers/powercap/arm_scmi_powercap.c
@@ -2,7 +2,7 @@
/*
* SCMI Powercap support.
*
- * Copyright (C) 2022 ARM Ltd.
+ * Copyright (C) 2022-2026 ARM Ltd.
*/

#include <linux/device.h>
@@ -461,15 +461,23 @@ static int scmi_powercap_register_zone(struct scmi_powercap_root *pr,
{
int ret = 0;
struct powercap_zone *z;
+ unsigned int nr_constraints;

if (spz->invalid) {
list_del(&spz->node);
return -EINVAL;
}

+ nr_constraints = min_t(unsigned int, spz->info->num_cpli,
+ MAX_CONSTRAINTS_PER_ZONE);
+
+ if (spz->info->num_cpli > MAX_CONSTRAINTS_PER_ZONE)
+ dev_warn(spz->dev, "Powercap domain %s advertises %u CPLs, exposing only %u constraints\n",
+ spz->info->name, spz->info->num_cpli, nr_constraints);
+
z = powercap_register_zone(&spz->zone, scmi_top_pcntrl, spz->info->name,
parent ? &parent->zone : NULL,
- &zone_ops, 1, &constraint_ops);
+ &zone_ops, nr_constraints, &constraint_ops);
if (!IS_ERR(z)) {
spz->height = scmi_powercap_get_zone_height(spz);
spz->registered = true;
--
2.34.1