Commit 5a0e2410 authored by Fabio Estevam's avatar Fabio Estevam Committed by Daniel Lezcano

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: default avatarFabio Estevam <festevam@denx.de>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20231129124330.519423-2-festevam@gmail.com
parent 87f67d17
...@@ -311,18 +311,24 @@ static void handle_non_critical_trips(struct thermal_zone_device *tz, ...@@ -311,18 +311,24 @@ static void handle_non_critical_trips(struct thermal_zone_device *tz,
def_governor->throttle(tz, trip); 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. * poweroff_delay_ms must be a carefully profiled positive value.
* Its a must for forced_emergency_poweroff_work to be scheduled. * Its a must for forced_emergency_poweroff_work to be scheduled.
*/ */
int poweroff_delay_ms = CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS; int poweroff_delay_ms = CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS;
const char *msg = "Temperature too high";
dev_emerg(&tz->device, "%s: critical temperature reached\n", tz->type);
dev_emerg(&tz->device, "%s: critical temperature reached, " if (shutdown)
"shutting down\n", tz->type); hw_protection_shutdown(msg, poweroff_delay_ms);
}
hw_protection_shutdown("Temperature too high", 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); EXPORT_SYMBOL(thermal_zone_device_critical);
......
...@@ -177,7 +177,12 @@ void ctrl_alt_del(void); ...@@ -177,7 +177,12 @@ void ctrl_alt_del(void);
extern void orderly_poweroff(bool force); extern void orderly_poweroff(bool force);
extern void orderly_reboot(void); 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. * Emergency restart, callable from an interrupt handler.
......
...@@ -957,7 +957,7 @@ static void hw_failure_emergency_poweroff(int poweroff_delay_ms) ...@@ -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. * @reason: Reason of emergency shutdown to be printed.
* @ms_until_forced: Time to wait for orderly shutdown before tiggering a * @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) ...@@ -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. * if the previous request has given a large timeout for forced shutdown.
* Can be called from any context. * 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); static atomic_t allow_proceed = ATOMIC_INIT(1);
...@@ -986,9 +986,9 @@ void hw_protection_shutdown(const char *reason, int ms_until_forced) ...@@ -986,9 +986,9 @@ void hw_protection_shutdown(const char *reason, int ms_until_forced)
* orderly_poweroff failure * orderly_poweroff failure
*/ */
hw_failure_emergency_poweroff(ms_until_forced); 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) static int __init reboot_setup(char *str)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment