thermal/core: Prepare for introduction of thermal reboot

Add some helper functions to make it easier introducing the support
for thermal reboot.

No functional change.

Signed-off-by: Fabio Estevam <festevam@denx.de>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20231129124330.519423-2-festevam@gmail.com
This commit is contained in:
Fabio Estevam 2023-11-29 09:43:28 -03:00 committed by Daniel Lezcano
parent 87f67d1747
commit 5a0e241003
3 changed files with 20 additions and 9 deletions

View File

@ -311,18 +311,24 @@ static void handle_non_critical_trips(struct thermal_zone_device *tz,
def_governor->throttle(tz, trip);
}
void thermal_zone_device_critical(struct thermal_zone_device *tz)
static void thermal_zone_device_halt(struct thermal_zone_device *tz, bool shutdown)
{
/*
* poweroff_delay_ms must be a carefully profiled positive value.
* Its a must for forced_emergency_poweroff_work to be scheduled.
*/
int poweroff_delay_ms = CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS;
const char *msg = "Temperature too high";
dev_emerg(&tz->device, "%s: critical temperature reached, "
"shutting down\n", tz->type);
dev_emerg(&tz->device, "%s: critical temperature reached\n", tz->type);
hw_protection_shutdown("Temperature too high", poweroff_delay_ms);
if (shutdown)
hw_protection_shutdown(msg, poweroff_delay_ms);
}
void thermal_zone_device_critical(struct thermal_zone_device *tz)
{
thermal_zone_device_halt(tz, true);
}
EXPORT_SYMBOL(thermal_zone_device_critical);

View File

@ -177,7 +177,12 @@ void ctrl_alt_del(void);
extern void orderly_poweroff(bool force);
extern void orderly_reboot(void);
void hw_protection_shutdown(const char *reason, int ms_until_forced);
void __hw_protection_shutdown(const char *reason, int ms_until_forced, bool shutdown);
static inline void hw_protection_shutdown(const char *reason, int ms_until_forced)
{
__hw_protection_shutdown(reason, ms_until_forced, true);
}
/*
* Emergency restart, callable from an interrupt handler.

View File

@ -957,7 +957,7 @@ static void hw_failure_emergency_poweroff(int poweroff_delay_ms)
}
/**
* hw_protection_shutdown - Trigger an emergency system poweroff
* __hw_protection_shutdown - Trigger an emergency system poweroff
*
* @reason: Reason of emergency shutdown to be printed.
* @ms_until_forced: Time to wait for orderly shutdown before tiggering a
@ -971,7 +971,7 @@ static void hw_failure_emergency_poweroff(int poweroff_delay_ms)
* if the previous request has given a large timeout for forced shutdown.
* Can be called from any context.
*/
void hw_protection_shutdown(const char *reason, int ms_until_forced)
void __hw_protection_shutdown(const char *reason, int ms_until_forced, bool shutdown)
{
static atomic_t allow_proceed = ATOMIC_INIT(1);
@ -986,9 +986,9 @@ void hw_protection_shutdown(const char *reason, int ms_until_forced)
* orderly_poweroff failure
*/
hw_failure_emergency_poweroff(ms_until_forced);
orderly_poweroff(true);
if (shutdown)
orderly_poweroff(true);
}
EXPORT_SYMBOL_GPL(hw_protection_shutdown);
static int __init reboot_setup(char *str)
{