ANDROID: thermal: Add vendor hooks for thermal
Need to get the request frequency and target frequency
use it to do frequency check and modify it according to
the platform thermal requirements.
Bug: 208166320
Signed-off-by: Jeson Gao <jeson.gao@unisoc.com>
Signed-off-by: Di Shen <di.shen@unisoc.com>
Change-Id: I776b43c8f559b8a072abd8d3abcb3528348b2c5d
(cherry picked from commit fc827b344f76709dc7f242c7db32e1828f510fdd)
(cherry picked from commit 11f1be4453c40385c5825e90b2a447c745cff852)
diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c
index 686e77d..e7a90f7 100644
--- a/drivers/android/vendor_hooks.c
+++ b/drivers/android/vendor_hooks.c
@@ -245,3 +245,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_event);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_group);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpufreq_acct_update_power);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_exit_signal);
+EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_modify_thermal_request_freq);
+EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_modify_thermal_target_freq);
diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c
index 9f8b438..74938a1 100644
--- a/drivers/thermal/cpufreq_cooling.c
+++ b/drivers/thermal/cpufreq_cooling.c
@@ -24,6 +24,7 @@
#include <linux/units.h>
#include <trace/events/thermal.h>
+#include <trace/hooks/thermal.h>
/*
* Cooling state <-> CPUFreq frequency
@@ -226,6 +227,8 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev,
freq = cpufreq_quick_get(policy->cpu);
+ trace_android_vh_modify_thermal_request_freq(policy, &freq);
+
for_each_cpu(cpu, policy->related_cpus) {
u32 load;
@@ -305,6 +308,8 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev,
normalised_power = (power * 100) / last_load;
target_freq = cpu_power_to_freq(cpufreq_cdev, normalised_power);
+ trace_android_vh_modify_thermal_target_freq(policy, &target_freq);
+
*state = get_level(cpufreq_cdev, target_freq);
trace_thermal_power_cpu_limit(policy->related_cpus, target_freq, *state,
power);
diff --git a/include/trace/hooks/thermal.h b/include/trace/hooks/thermal.h
index 6d115a0..8a71ffd 100644
--- a/include/trace/hooks/thermal.h
+++ b/include/trace/hooks/thermal.h
@@ -23,6 +23,15 @@ DECLARE_HOOK(android_vh_disable_thermal_cooling_stats,
TP_PROTO(struct thermal_cooling_device *cdev, bool *disable_stats),
TP_ARGS(cdev, disable_stats));
+struct cpufreq_policy;
+DECLARE_HOOK(android_vh_modify_thermal_request_freq,
+ TP_PROTO(struct cpufreq_policy *policy, unsigned long *request_freq),
+ TP_ARGS(policy, request_freq));
+
+DECLARE_HOOK(android_vh_modify_thermal_target_freq,
+ TP_PROTO(struct cpufreq_policy *policy, unsigned int *target_freq),
+ TP_ARGS(policy, target_freq));
+
#endif /* _TRACE_HOOK_THERMAL_H */
/* This part must be outside protection */
#include <trace/define_trace.h>