lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230525211655.627415-4-evalenti@kernel.org>
Date:   Thu, 25 May 2023 14:16:55 -0700
From:   Eduardo Valentin <evalenti@...nel.org>
To:     daniel.lezcano@...aro.org, rafael@...nel.org,
        linux-pm@...r.kernel.org
Cc:     Eduardo Valentin <eduval@...zon.com>,
        Amit Kucheria <amitk@...nel.org>,
        Zhang Rui <rui.zhang@...el.com>,
        Jonathan Corbet <corbet@....net>, linux-doc@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH 3/3] thermal: core: register a crash callback

From: Eduardo Valentin <eduval@...zon.com>

This commit will register a crash callback for
the thermal subsystem, this way the thermal
core can tear down the thermal zones and ask
governors to leave the hardware in a known
safe state prior upon the event of a crash.

Cc: "Rafael J. Wysocki" <rafael@...nel.org> (supporter:THERMAL)
Cc: Daniel Lezcano <daniel.lezcano@...aro.org> (supporter:THERMAL)
Cc: Amit Kucheria <amitk@...nel.org> (reviewer:THERMAL)
Cc: Zhang Rui <rui.zhang@...el.com> (reviewer:THERMAL)
Cc: Jonathan Corbet <corbet@....net> (maintainer:DOCUMENTATION)
Cc: linux-pm@...r.kernel.org (open list:THERMAL)
Cc: linux-doc@...r.kernel.org (open list:DOCUMENTATION)
Cc: linux-kernel@...r.kernel.org (open list)

Signed-off-by: Eduardo Valentin <eduval@...zon.com>
---
 drivers/thermal/thermal_core.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 66a255fb650b..38b168b9245e 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -20,6 +20,7 @@
 #include <linux/string.h>
 #include <linux/of.h>
 #include <linux/suspend.h>
+#include <linux/panic_notifier.h>
 
 #define CREATE_TRACE_POINTS
 #include "thermal_trace.h"
@@ -1525,6 +1526,14 @@ static void thermal_reboot_prepare(void)
 	}
 }
 
+static int thermal_crash_notify(struct notifier_block *nb,
+				unsigned long mode, void *_unused)
+{
+	thermal_reboot_prepare();
+
+	return 0;
+}
+
 static int thermal_reboot_notify(struct notifier_block *nb,
 				 unsigned long mode, void *_unused)
 {
@@ -1569,6 +1578,10 @@ static struct notifier_block thermal_pm_nb = {
 	.notifier_call = thermal_pm_notify,
 };
 
+static struct notifier_block thermal_crash_nb = {
+	.notifier_call = thermal_crash_notify,
+};
+
 static struct notifier_block thermal_reboot_nb = {
 	.notifier_call = thermal_reboot_notify,
 };
@@ -1611,6 +1624,8 @@ static int __init thermal_init(void)
 		pr_warn("Thermal: Can not register reboot notifier, return %d\n",
 			result);
 
+	atomic_notifier_chain_register(&panic_notifier_list,
+				       &thermal_crash_nb);
 	return 0;
 
 unregister_governors:
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ