Skip to content

Commit 5a0e241

Browse files
Fabio Estevamdlezcano
authored andcommitted
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 <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 87f67d1 commit 5a0e241

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

drivers/thermal/thermal_core.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,18 +311,24 @@ static void handle_non_critical_trips(struct thermal_zone_device *tz,
311311
def_governor->throttle(tz, trip);
312312
}
313313

314-
void thermal_zone_device_critical(struct thermal_zone_device *tz)
314+
static void thermal_zone_device_halt(struct thermal_zone_device *tz, bool shutdown)
315315
{
316316
/*
317317
* poweroff_delay_ms must be a carefully profiled positive value.
318318
* Its a must for forced_emergency_poweroff_work to be scheduled.
319319
*/
320320
int poweroff_delay_ms = CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS;
321+
const char *msg = "Temperature too high";
322+
323+
dev_emerg(&tz->device, "%s: critical temperature reached\n", tz->type);
321324

322-
dev_emerg(&tz->device, "%s: critical temperature reached, "
323-
"shutting down\n", tz->type);
325+
if (shutdown)
326+
hw_protection_shutdown(msg, poweroff_delay_ms);
327+
}
324328

325-
hw_protection_shutdown("Temperature too high", poweroff_delay_ms);
329+
void thermal_zone_device_critical(struct thermal_zone_device *tz)
330+
{
331+
thermal_zone_device_halt(tz, true);
326332
}
327333
EXPORT_SYMBOL(thermal_zone_device_critical);
328334

include/linux/reboot.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,12 @@ void ctrl_alt_del(void);
177177

178178
extern void orderly_poweroff(bool force);
179179
extern void orderly_reboot(void);
180-
void hw_protection_shutdown(const char *reason, int ms_until_forced);
180+
void __hw_protection_shutdown(const char *reason, int ms_until_forced, bool shutdown);
181+
182+
static inline void hw_protection_shutdown(const char *reason, int ms_until_forced)
183+
{
184+
__hw_protection_shutdown(reason, ms_until_forced, true);
185+
}
181186

182187
/*
183188
* Emergency restart, callable from an interrupt handler.

kernel/reboot.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ static void hw_failure_emergency_poweroff(int poweroff_delay_ms)
957957
}
958958

959959
/**
960-
* hw_protection_shutdown - Trigger an emergency system poweroff
960+
* __hw_protection_shutdown - Trigger an emergency system poweroff
961961
*
962962
* @reason: Reason of emergency shutdown to be printed.
963963
* @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)
971971
* if the previous request has given a large timeout for forced shutdown.
972972
* Can be called from any context.
973973
*/
974-
void hw_protection_shutdown(const char *reason, int ms_until_forced)
974+
void __hw_protection_shutdown(const char *reason, int ms_until_forced, bool shutdown)
975975
{
976976
static atomic_t allow_proceed = ATOMIC_INIT(1);
977977

@@ -986,9 +986,9 @@ void hw_protection_shutdown(const char *reason, int ms_until_forced)
986986
* orderly_poweroff failure
987987
*/
988988
hw_failure_emergency_poweroff(ms_until_forced);
989-
orderly_poweroff(true);
989+
if (shutdown)
990+
orderly_poweroff(true);
990991
}
991-
EXPORT_SYMBOL_GPL(hw_protection_shutdown);
992992

993993
static int __init reboot_setup(char *str)
994994
{

0 commit comments

Comments
 (0)