From: Scott Collyer <scollyer@google.com>
To: Benson Leung <bleung@chromium.org>, Tzung-Bi Shih <tzungbi@kernel.org>
Cc: Guenter Roeck <groeck@chromium.org>,
chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org,
Scott Collyer <scollyer@google.com>
Subject: [PATCH] platform/chrome: cros_ec: trigger kernel_restart on EC_HOST_EVENT_PANIC
Date: Thu, 8 Oct 2026 10:22:08 -0700 [thread overview]
Message-ID: <20261008172208.1139281-1-scollyer@google.com> (raw)
When an attached EC or ISH device reports an EC_HOST_EVENT_PANIC host
event, the EC/ISH subsystem has encountered a fatal exception.
Handle the EC_HOST_EVENT_PANIC event by:
1. Logging an emergency message (dev_emerg) with the device name.
2. Calling the panic notifier chain (panic_notifier).
3. Emitting a uevent (ERROR=PANIC) to userspace.
4. Triggering kernel_restart("CrOS EC Panic") to cleanly restart the AP
so that panic logs are preserved and collected by crash reporting
services across reboot.
Signed-off-by: Scott Collyer <scollyer@google.com>
---
drivers/platform/chrome/cros_ec.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c
index 1da79e3d215b..cee7018a2d7d 100644
--- a/drivers/platform/chrome/cros_ec.c
+++ b/drivers/platform/chrome/cros_ec.c
@@ -11,11 +11,13 @@
#include <linux/cleanup.h>
#include <linux/interrupt.h>
+#include <linux/kobject.h>
#include <linux/module.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/platform_data/cros_ec_commands.h>
#include <linux/platform_data/cros_ec_proto.h>
+#include <linux/reboot.h>
#include <linux/slab.h>
#include <linux/suspend.h>
@@ -109,8 +111,10 @@ static irqreturn_t cros_ec_irq_handler(int irq, void *data)
*/
static bool cros_ec_handle_event(struct cros_ec_device *ec_dev)
{
+ static const char * const panic_env[] = { "ERROR=PANIC", NULL };
bool wake_event;
bool ec_has_more_events;
+ u32 host_event;
int ret;
ret = cros_ec_get_next_event(ec_dev, &wake_event, &ec_has_more_events);
@@ -123,9 +127,21 @@ static bool cros_ec_handle_event(struct cros_ec_device *ec_dev)
if (wake_event && device_may_wakeup(ec_dev->dev))
pm_wakeup_event(ec_dev->dev, 0);
- if (ret > 0)
+ if (ret > 0) {
+ if (ec_dev->event_data.event_type == EC_MKBP_EVENT_HOST_EVENT) {
+ host_event = cros_ec_get_host_event(ec_dev);
+ if (host_event & EC_HOST_EVENT_MASK(EC_HOST_EVENT_PANIC)) {
+ dev_emerg(ec_dev->dev, "CrOS EC Panic Reported (%s). Reboot is imminent!\n",
+ dev_name(ec_dev->dev));
+ blocking_notifier_call_chain(&ec_dev->panic_notifier, 0, ec_dev);
+ kobject_uevent_env(&ec_dev->dev->kobj, KOBJ_CHANGE,
+ (char **)panic_env);
+ kernel_restart("CrOS EC Panic");
+ }
+ }
blocking_notifier_call_chain(&ec_dev->event_notifier,
0, ec_dev);
+ }
return ec_has_more_events;
}
--
2.56.0.385.gd3acb90ef8-goog
next reply other threads:[~2026-10-08 17:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 17:22 Scott Collyer [this message]
2026-10-14 7:17 ` Tzung-Bi Shih
2026-10-14 21:30 ` Scott Collyer
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=20261008172208.1139281-1-scollyer@google.com \
--to=scollyer@google.com \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tzungbi@kernel.org \
/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
all inboxes | Powered by JetHome®