ANDROID: thermal: Add vendor thermal_pm_notify_suspend function

Currently, most of the thermal_zones are IRQ capable and they do not
need to be updated while resuming. To improve the system performance
and reduce the resume time. Add a vendor function to check if the
thermal_zone is not IRQ capable and needs to be updated.

It also helps to avoid stability issues in case thermal violation is
triggered after SUSPEND_PREPARE callback.

It cherry picked from base commit d8755d12582f and made required
changes to port it into latest code.

Bug: 349071578
Change-Id: I9389985bba29b551a7a20b55e1ed26b6c4da9b3d
Signed-off-by: David Chao <davidchao@google.com>
Signed-off-by: Dylan Chang <dylan.chang@nothing.tech>
Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
This commit is contained in:
Manaf Meethalavalappu Pallikunhi
2025-03-21 20:52:04 +05:30
parent 61c7d5b080
commit 34c8308614
3 changed files with 30 additions and 4 deletions
+1
View File
@@ -350,6 +350,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tcp_update_rtt);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sk_alloc);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sk_free);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_enable_thermal_genl_check);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_thermal_pm_notify_suspend);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_entry);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_watermark_fast_ok);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_count_workingset_refault);
+24 -4
View File
@@ -22,6 +22,8 @@
#include <linux/of.h>
#include <linux/suspend.h>
#include <trace/hooks/thermal.h>
#define CREATE_TRACE_POINTS
#include "thermal_trace.h"
@@ -1343,6 +1345,8 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp);
static void thermal_zone_init_complete(struct thermal_zone_device *tz)
{
int irq_wakeable = 0;
mutex_lock(&tz->lock);
tz->state &= ~TZ_STATE_FLAG_INIT;
@@ -1351,8 +1355,11 @@ static void thermal_zone_init_complete(struct thermal_zone_device *tz)
* new thermal zone needs to be marked as suspended because
* thermal_pm_notify() has run already.
*/
if (thermal_pm_suspended)
tz->state |= TZ_STATE_FLAG_SUSPENDED;
if (thermal_pm_suspended) {
trace_android_vh_thermal_pm_notify_suspend(tz, &irq_wakeable);
if (!irq_wakeable)
tz->state |= TZ_STATE_FLAG_SUSPENDED;
}
__thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
@@ -1754,6 +1761,7 @@ static int thermal_pm_notify(struct notifier_block *nb,
unsigned long mode, void *_unused)
{
struct thermal_zone_device *tz;
int irq_wakeable = 0;
switch (mode) {
case PM_HIBERNATION_PREPARE:
@@ -1763,8 +1771,14 @@ static int thermal_pm_notify(struct notifier_block *nb,
thermal_pm_suspended = true;
list_for_each_entry(tz, &thermal_tz_list, node)
list_for_each_entry(tz, &thermal_tz_list, node) {
trace_android_vh_thermal_pm_notify_suspend(tz, &irq_wakeable);
if (irq_wakeable)
continue;
thermal_zone_pm_prepare(tz);
}
mutex_unlock(&thermal_list_lock);
break;
@@ -1775,8 +1789,14 @@ static int thermal_pm_notify(struct notifier_block *nb,
thermal_pm_suspended = false;
list_for_each_entry(tz, &thermal_tz_list, node)
list_for_each_entry(tz, &thermal_tz_list, node) {
trace_android_vh_thermal_pm_notify_suspend(tz, &irq_wakeable);
if (irq_wakeable)
continue;
thermal_zone_pm_complete(tz);
}
mutex_unlock(&thermal_list_lock);
break;
+5
View File
@@ -13,6 +13,11 @@ DECLARE_HOOK(android_vh_enable_thermal_genl_check,
TP_PROTO(int event, int tz_id, int *enable_thermal_genl),
TP_ARGS(event, tz_id, enable_thermal_genl));
struct thermal_zone_device;
DECLARE_HOOK(android_vh_thermal_pm_notify_suspend,
TP_PROTO(struct thermal_zone_device *tz, int *irq_wakeable),
TP_ARGS(tz, irq_wakeable));
#endif /* _TRACE_HOOK_THERMAL_H */
/* This part must be outside protection */
#include <trace/define_trace.h>