ANDROID: thermal: Fix cases for vendor hook function not accounted correctly

As part of commit 12b275d2f9, new vendor function is added to reduce
resume time line. But this change has couple of issues.

1. It is not unlocking lock if vendor hook function returns true.
   It could lead to a dead lock for those thermal zones those are
   triggered post resume.
2. It tries to avoid resume thermal zone evaluation by assuming
   it can interrupt / wakeup system even if it is in thermal condition
   during suspend or suspend is in process. But if thermal violation
   happens post SUSPEND_PREPARE callback, it is not allowing to
   handle mitigation since suspend flag is set to true. It bails out
   of thermal_zone_device_update function. It can lead to different
   scenarios / issues depending on how vendor sensor driver is
   implemented.
   a. If sensor driver is not disabling trip threshold on violation:
      It causes multiple interrupts and every time it notifies thermal
      core, it bails out and it can eventually abort suspend as well.
   b. If sensor driver is disabling current trip on violation and
      waiting for thermal core to update new trip:
      In this case, it bails out from thermal core notification during
      suspend in process and at the same time ignore trip evaluation
      during resume due to new vendor function. It eventually leads
      to a case where trip will be disabled forever for that zone.

Add same vendor function in suspend prepare callback and if it returns
true, bail out from suspend callback without setting suspend flag.
Also unlock thermal zone lock while vendor function returns true.

Bug: 349071578
Fixes: 12b275d2f9 ("ANDROID: thermal: Add vendor thermal_pm_notify_suspend function")
Change-Id: I3bd4b3b18225ca1b81475228f1e45cf5667e4f63
Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
This commit is contained in:
Manaf Meethalavalappu Pallikunhi 2024-06-24 20:40:38 +05:30 committed by Treehugger Robot
parent 23f02fa409
commit d8755d1258

View File

@ -1538,6 +1538,12 @@ static int thermal_pm_notify(struct notifier_block *nb,
list_for_each_entry(tz, &thermal_tz_list, node) {
mutex_lock(&tz->lock);
trace_android_vh_thermal_pm_notify_suspend(tz, &irq_wakeable);
if (irq_wakeable) {
mutex_unlock(&tz->lock);
continue;
}
tz->suspended = true;
mutex_unlock(&tz->lock);
@ -1553,11 +1559,13 @@ static int thermal_pm_notify(struct notifier_block *nb,
list_for_each_entry(tz, &thermal_tz_list, node) {
mutex_lock(&tz->lock);
tz->suspended = false;
trace_android_vh_thermal_pm_notify_suspend(tz, &irq_wakeable);
if (irq_wakeable)
if (irq_wakeable) {
mutex_unlock(&tz->lock);
continue;
}
tz->suspended = false;
thermal_zone_device_init(tz);
__thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);