Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

thermal: core: allow user configuration of hardware protection action

In the general case, we don't know which of system shutdown or reboot is
the better action to take to protect hardware in an emergency situation.
We thus allow the policy to come from the device-tree in the form of an
optional critical-action OF property, but so far there was no way for the
end user to configure this.

With recent addition of the hw_protection parameter, the user can now
choose a default action for the case, where the driver isn't fully sure
what's the better course of action.

Let's make use of this by passing HWPROT_ACT_DEFAULT in absence of the
critical-action OF property.

As HWPROT_ACT_DEFAULT is shutdown by default, this introduces no
functional change for users, unless they start using the new parameter.

Link: https://lkml.kernel.org/r/20250217-hw_protection-reboot-v3-11-e1c09b090c0c@pengutronix.de
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Cc: Benson Leung <bleung@chromium.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Fabio Estevam <festevam@denx.de>
Cc: Guenter Roeck <groeck@chromium.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Lukasz Luba <lukasz.luba@arm.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Matteo Croce <teknoraver@meta.com>
Cc: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Rob Herring (Arm) <robh@kernel.org>
Cc: Rui Zhang <rui.zhang@intel.com>
Cc: Sascha Hauer <kernel@pengutronix.de>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Ahmad Fatoum and committed by
Andrew Morton
941a07ca 738b7856

+16 -9
+10 -7
drivers/thermal/thermal_core.c
··· 369 369 tz->governor->update_tz(tz, reason); 370 370 } 371 371 372 - static void thermal_zone_device_halt(struct thermal_zone_device *tz, bool shutdown) 372 + static void thermal_zone_device_halt(struct thermal_zone_device *tz, 373 + enum hw_protection_action action) 373 374 { 374 375 /* 375 376 * poweroff_delay_ms must be a carefully profiled positive value. ··· 381 380 382 381 dev_emerg(&tz->device, "%s: critical temperature reached\n", tz->type); 383 382 384 - if (shutdown) 385 - hw_protection_shutdown(msg, poweroff_delay_ms); 386 - else 387 - hw_protection_reboot(msg, poweroff_delay_ms); 383 + __hw_protection_trigger(msg, poweroff_delay_ms, action); 388 384 } 389 385 390 386 void thermal_zone_device_critical(struct thermal_zone_device *tz) 391 387 { 392 - thermal_zone_device_halt(tz, true); 388 + thermal_zone_device_halt(tz, HWPROT_ACT_DEFAULT); 393 389 } 394 390 EXPORT_SYMBOL(thermal_zone_device_critical); 395 391 392 + void thermal_zone_device_critical_shutdown(struct thermal_zone_device *tz) 393 + { 394 + thermal_zone_device_halt(tz, HWPROT_ACT_SHUTDOWN); 395 + } 396 + 396 397 void thermal_zone_device_critical_reboot(struct thermal_zone_device *tz) 397 398 { 398 - thermal_zone_device_halt(tz, false); 399 + thermal_zone_device_halt(tz, HWPROT_ACT_REBOOT); 399 400 } 400 401 401 402 static void handle_critical_trips(struct thermal_zone_device *tz,
+1
drivers/thermal/thermal_core.h
··· 262 262 void __thermal_zone_device_update(struct thermal_zone_device *tz, 263 263 enum thermal_notify_event event); 264 264 void thermal_zone_device_critical_reboot(struct thermal_zone_device *tz); 265 + void thermal_zone_device_critical_shutdown(struct thermal_zone_device *tz); 265 266 void thermal_governor_update_tz(struct thermal_zone_device *tz, 266 267 enum thermal_notify_event reason); 267 268
+5 -2
drivers/thermal/thermal_of.c
··· 405 405 of_ops.should_bind = thermal_of_should_bind; 406 406 407 407 ret = of_property_read_string(np, "critical-action", &action); 408 - if (!ret) 409 - if (!of_ops.critical && !strcasecmp(action, "reboot")) 408 + if (!ret && !of_ops.critical) { 409 + if (!strcasecmp(action, "reboot")) 410 410 of_ops.critical = thermal_zone_device_critical_reboot; 411 + else if (!strcasecmp(action, "shutdown")) 412 + of_ops.critical = thermal_zone_device_critical_shutdown; 413 + } 411 414 412 415 tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips, 413 416 data, &of_ops, &tzp,