Skip to content

Commit e441fd6

Browse files
Keerthyjzhang-rui
authored andcommitted
thermal: core: Allow orderly_poweroff to be called only once
thermal_zone_device_check --> thermal_zone_device_update --> handle_thermal_trip --> handle_critical_trips --> orderly_poweroff The above sequence happens every 250/500 mS based on the configuration. The orderly_poweroff function is getting called every 250/500 mS. With a full fledged file system it takes at least 5-10 Seconds to power off gracefully. In that period due to the thermal_zone_device_check triggering periodically the thermal work queues bombard with orderly_poweroff calls multiple times eventually leading to failures in gracefully powering off the system. Make sure that orderly_poweroff is called only once. Signed-off-by: Keerthy <j-keerthy@ti.com> Acked-by: Eduardo Valentin <edubezval@gmail.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
1 parent 39da7c5 commit e441fd6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/thermal/thermal_core.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ static LIST_HEAD(thermal_governor_list);
4545

4646
static DEFINE_MUTEX(thermal_list_lock);
4747
static DEFINE_MUTEX(thermal_governor_lock);
48+
static DEFINE_MUTEX(poweroff_lock);
4849

4950
static atomic_t in_suspend;
51+
static bool power_off_triggered;
5052

5153
static struct thermal_governor *def_governor;
5254

@@ -342,7 +344,12 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
342344
dev_emerg(&tz->device,
343345
"critical temperature reached(%d C),shutting down\n",
344346
tz->temperature / 1000);
345-
orderly_poweroff(true);
347+
mutex_lock(&poweroff_lock);
348+
if (!power_off_triggered) {
349+
orderly_poweroff(true);
350+
power_off_triggered = true;
351+
}
352+
mutex_unlock(&poweroff_lock);
346353
}
347354
}
348355

@@ -1463,6 +1470,7 @@ static int __init thermal_init(void)
14631470
{
14641471
int result;
14651472

1473+
mutex_init(&poweroff_lock);
14661474
result = thermal_register_governors();
14671475
if (result)
14681476
goto error;
@@ -1497,6 +1505,7 @@ static int __init thermal_init(void)
14971505
ida_destroy(&thermal_cdev_ida);
14981506
mutex_destroy(&thermal_list_lock);
14991507
mutex_destroy(&thermal_governor_lock);
1508+
mutex_destroy(&poweroff_lock);
15001509
return result;
15011510
}
15021511

0 commit comments

Comments
 (0)