Register for limit change notifications if supported with the help of
perf_notify_support interface and determine the throttled frequency
using the perf_opp_xlate to apply HW pressure.
Signed-off-by: Sibi Sankar <quic_sibis@xxxxxxxxxxx>
---
drivers/cpufreq/scmi-cpufreq.c | 42 +++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index 4ee23f4ebf4a..53bc8868455d 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -25,9 +25,13 @@ struct scmi_data {
int domain_id;
int nr_opp;
struct device *cpu_dev;
+ struct cpufreq_policy *policy;
cpumask_var_t opp_shared_cpus;
+ struct notifier_block limit_notify_nb;
};
+const struct scmi_handle *handle;
+static struct scmi_device *scmi_dev;
static struct scmi_protocol_handle *ph;
static const struct scmi_perf_proto_ops *perf_ops;
@@ -144,6 +148,22 @@ scmi_get_cpu_power(struct device *cpu_dev, unsigned long *power,
return 0;
}
+static int scmi_limit_notify_cb(struct notifier_block *nb, unsigned long event, void *data)
+{
+ unsigned long freq_hz;
+ struct scmi_perf_limits_report *limit_notify = data;
+ struct scmi_data *priv = container_of(nb, struct scmi_data, limit_notify_nb);
+ struct cpufreq_policy *policy = priv->policy;
+
+ if (perf_ops->perf_opp_xlate(ph, priv->domain_id, limit_notify->range_max, &freq_hz))
+ return NOTIFY_OK;
+
+ /* Update HW pressure (the boost frequencies are accepted) */
+ arch_update_hw_pressure(policy->related_cpus, (freq_hz / HZ_PER_KHZ));