[PATCH v6 06/12] firmware: arm_scmi: Extend powercap report to include MAI
Philip Radford
philip.radford at arm.com
Mon May 18 06:52:28 PDT 2026
Extend scmi_powercap_meas_changed_report to include MAI change
notifications.
Signed-off-by: Philip Radford <philip.radford at arm.com>
---
V5->V6
- Re-worded existing comment for POWERCAP_MEASUREMENTS_NOTIFY
- Added define for V2/V3 sizes
- Used new definitions
---
drivers/firmware/arm_scmi/powercap.c | 28 +++++++++++++++-------------
include/linux/scmi_protocol.h | 1 +
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/drivers/firmware/arm_scmi/powercap.c b/drivers/firmware/arm_scmi/powercap.c
index 1d1188e98d49..fdfaf03277ab 100644
--- a/drivers/firmware/arm_scmi/powercap.c
+++ b/drivers/firmware/arm_scmi/powercap.c
@@ -11,6 +11,7 @@
#include <linux/io.h>
#include <linux/module.h>
#include <linux/scmi_protocol.h>
+#include <linux/stddef.h>
#include <trace/events/scmi.h>
@@ -21,6 +22,8 @@
#define SCMI_PROTOCOL_SUPPORTED_VERSION 0x30000
#define CPL0 0
+#define SZ_V2 (sizeof(struct scmi_powercap_meas_changed_notify_payld))
+#define SZ_V3 (SZ_V2 - sizeof(__le32))
enum scmi_powercap_protocol_cmd {
POWERCAP_DOMAIN_ATTRIBUTES = 0x3,
@@ -164,6 +167,7 @@ struct scmi_powercap_meas_changed_notify_payld {
__le32 agent_id;
__le32 domain_id;
__le32 power;
+ __le32 mai;
};
struct scmi_msg_powercap_cpc {
@@ -1201,24 +1205,18 @@ static int scmi_powercap_notify(const struct scmi_protocol_handle *ph,
struct scmi_msg_powercap_notify_thresh *notify;
/*
- * Note that we have to pick the most recently configured
- * thresholds to build a proper POWERCAP_MEASUREMENTS_NOTIFY
- * enable request and we fail, complaining, if no thresholds
- * were ever set, since this is an indication the API has been
- * used wrongly.
+ * Build the POWERCAP_MEASUREMENTS_NOTIFY enable request using the
+ * most recently configured thresholds.
+ *
+ * The absence of thresholds is not considered an error:
+ * notifications can still be generated to report MAI changes, even
+ * when low and high are set to zero.
*/
ret = scmi_powercap_measurements_threshold_get(ph, domain,
&low, &high);
if (ret)
return ret;
- if (enable && !low && !high) {
- dev_err(ph->dev,
- "Invalid Measurements Notify thresholds: %u/%u\n",
- low, high);
- return -EINVAL;
- }
-
ret = ph->xops->xfer_get_init(ph, message_id,
sizeof(*notify), 0, &t);
if (ret)
@@ -1334,13 +1332,17 @@ scmi_powercap_fill_custom_report(const struct scmi_protocol_handle *ph,
const struct scmi_powercap_meas_changed_notify_payld *p = payld;
struct scmi_powercap_meas_changed_report *r = report;
- if (sizeof(*p) != payld_sz)
+ if (payld_sz != SZ_V2 && payld_sz != SZ_V3)
break;
r->timestamp = timestamp;
r->agent_id = le32_to_cpu(p->agent_id);
r->domain_id = le32_to_cpu(p->domain_id);
r->power = le32_to_cpu(p->power);
+ r->mai = 0;
+ if (payld_sz == SZ_V3 && PROTOCOL_REV_MAJOR(ph->version) >= 0x3)
+ r->mai = le32_to_cpu(p->mai);
+
*src_id = r->domain_id;
rep = r;
break;
diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
index 299fa8499b3f..d0f6c0102559 100644
--- a/include/linux/scmi_protocol.h
+++ b/include/linux/scmi_protocol.h
@@ -1134,5 +1134,6 @@ struct scmi_powercap_meas_changed_report {
unsigned int agent_id;
unsigned int domain_id;
unsigned int power;
+ unsigned int mai;
};
#endif /* _LINUX_SCMI_PROTOCOL_H */
--
2.47.3
More information about the linux-arm-kernel
mailing list