From: Eduardo Valentin <evalenti@kernel.org>
To: daniel.lezcano@linaro.org, rafael@kernel.org, linux-pm@vger.kernel.org
Cc: Eduardo Valentin <eduval@amazon.com>,
Amit Kucheria <amitk@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
Jonathan Corbet <corbet@lwn.net>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] thermal: core: register a crash callback
Date: Thu, 25 May 2023 14:16:55 -0700 [thread overview]
Message-ID: <20230525211655.627415-4-evalenti@kernel.org> (raw)
In-Reply-To: <20230525211655.627415-1-evalenti@kernel.org>
From: Eduardo Valentin <eduval@amazon.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@kernel.org> (supporter:THERMAL)
Cc: Daniel Lezcano <daniel.lezcano@linaro.org> (supporter:THERMAL)
Cc: Amit Kucheria <amitk@kernel.org> (reviewer:THERMAL)
Cc: Zhang Rui <rui.zhang@intel.com> (reviewer:THERMAL)
Cc: Jonathan Corbet <corbet@lwn.net> (maintainer:DOCUMENTATION)
Cc: linux-pm@vger.kernel.org (open list:THERMAL)
Cc: linux-doc@vger.kernel.org (open list:DOCUMENTATION)
Cc: linux-kernel@vger.kernel.org (open list)
Signed-off-by: Eduardo Valentin <eduval@amazon.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
prev parent reply other threads:[~2023-05-25 21:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230525211655.627415-1-evalenti@kernel.org>
2023-05-25 21:16 ` [PATCH 1/3] thermal: core: introduce governor .reboot_prepare() Eduardo Valentin
2023-05-25 21:16 ` [PATCH 2/3] thermal: core: register reboot nb Eduardo Valentin
2023-05-25 21:16 ` Eduardo Valentin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230525211655.627415-4-evalenti@kernel.org \
--to=evalenti@kernel.org \
--cc=amitk@kernel.org \
--cc=corbet@lwn.net \
--cc=daniel.lezcano@linaro.org \
--cc=eduval@amazon.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).