diff mbox series

[2/3] firmware: arm_scmi: perf: Add notify_supported for scmi_perf_proto_ops

Message ID 20250611-scmi-perf-v1-2-df2b548ba77c@nxp.com
State New
Headers show
Series firmware: arm_scmi: perf/cpufreq: Enable notification only if supported by platform | expand

Commit Message

Peng Fan (OSS) June 11, 2025, 7:52 a.m. UTC
From: Peng Fan <peng.fan@nxp.com>

PERFORMANCE_NOTIFY_LIMITS and PERFORMANCE_NOTIFY_LEVEL are optional
commands which are not implemented in i.MX95 SCMI firmware. Provide
a hook to query whether they are supported, before invoke
event_notifier_register.

scmi_perf_notify_supported could be directly used here, so just
move scmi_perf_notify_supported above perf_proto_ops and use it
in perf_proto_ops.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/firmware/arm_scmi/perf.c | 37 +++++++++++++++++++------------------
 include/linux/scmi_protocol.h    |  3 +++
 2 files changed, 22 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c
index c7e5a34b254bf4e9c51c7be56803b6d851f0e1d6..ba990643edf0bcb5fc25253b4f52a5dc93b62a77 100644
--- a/drivers/firmware/arm_scmi/perf.c
+++ b/drivers/firmware/arm_scmi/perf.c
@@ -1068,24 +1068,6 @@  scmi_power_scale_get(const struct scmi_protocol_handle *ph)
 	return pi->power_scale;
 }
 
-static const struct scmi_perf_proto_ops perf_proto_ops = {
-	.num_domains_get = scmi_perf_num_domains_get,
-	.info_get = scmi_perf_info_get,
-	.limits_set = scmi_perf_limits_set,
-	.limits_get = scmi_perf_limits_get,
-	.level_set = scmi_perf_level_set,
-	.level_get = scmi_perf_level_get,
-	.transition_latency_get = scmi_dvfs_transition_latency_get,
-	.rate_limit_get = scmi_dvfs_rate_limit_get,
-	.device_opps_add = scmi_dvfs_device_opps_add,
-	.freq_set = scmi_dvfs_freq_set,
-	.freq_get = scmi_dvfs_freq_get,
-	.est_power_get = scmi_dvfs_est_power_get,
-	.fast_switch_possible = scmi_fast_switch_possible,
-	.fast_switch_rate_limit = scmi_fast_switch_rate_limit,
-	.power_scale_get = scmi_power_scale_get,
-};
-
 static bool scmi_perf_notify_supported(const struct scmi_protocol_handle *ph,
 				       u8 evt_id, u32 src_id)
 {
@@ -1107,6 +1089,25 @@  static bool scmi_perf_notify_supported(const struct scmi_protocol_handle *ph,
 	return supported;
 }
 
+static const struct scmi_perf_proto_ops perf_proto_ops = {
+	.num_domains_get = scmi_perf_num_domains_get,
+	.info_get = scmi_perf_info_get,
+	.limits_set = scmi_perf_limits_set,
+	.limits_get = scmi_perf_limits_get,
+	.level_set = scmi_perf_level_set,
+	.level_get = scmi_perf_level_get,
+	.transition_latency_get = scmi_dvfs_transition_latency_get,
+	.rate_limit_get = scmi_dvfs_rate_limit_get,
+	.device_opps_add = scmi_dvfs_device_opps_add,
+	.freq_set = scmi_dvfs_freq_set,
+	.freq_get = scmi_dvfs_freq_get,
+	.est_power_get = scmi_dvfs_est_power_get,
+	.fast_switch_possible = scmi_fast_switch_possible,
+	.fast_switch_rate_limit = scmi_fast_switch_rate_limit,
+	.power_scale_get = scmi_power_scale_get,
+	.notify_supported = scmi_perf_notify_supported,
+};
+
 static int scmi_perf_set_notify_enabled(const struct scmi_protocol_handle *ph,
 					u8 evt_id, u32 src_id, bool enable)
 {
diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
index aafaac1496b06a6e4f0ca32eee58a9edf7d4a70f..91865f0ebcbd4b15b55afd8c1a0d0614d6985daf 100644
--- a/include/linux/scmi_protocol.h
+++ b/include/linux/scmi_protocol.h
@@ -155,6 +155,7 @@  struct scmi_perf_domain_info {
  *	successive fast_switching requests
  * @power_scale_get: indicates if the power values provided are in milliWatts
  *	or in some other (abstract) scale
+ * @notify_supported: indicates if the event is supported
  */
 struct scmi_perf_proto_ops {
 	int (*num_domains_get)(const struct scmi_protocol_handle *ph);
@@ -185,6 +186,8 @@  struct scmi_perf_proto_ops {
 	int (*fast_switch_rate_limit)(const struct scmi_protocol_handle *ph,
 				      u32 domain, u32 *rate_limit);
 	enum scmi_power_scale (*power_scale_get)(const struct scmi_protocol_handle *ph);
+	bool (*notify_supported)(const struct scmi_protocol_handle *ph, u8 evt_id,
+				 u32 src_id);
 };
 
 /**