* [PATCH] platform/chrome: cros_ec: trigger kernel_restart on EC_HOST_EVENT_PANIC
@ 2026-10-08 17:22 Scott Collyer
2026-10-14 7:17 ` Tzung-Bi Shih
0 siblings, 1 reply; 3+ messages in thread
From: Scott Collyer @ 2026-10-08 17:22 UTC (permalink / raw)
To: Benson Leung, Tzung-Bi Shih
Cc: Guenter Roeck, chrome-platform, linux-kernel, Scott Collyer
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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] platform/chrome: cros_ec: trigger kernel_restart on EC_HOST_EVENT_PANIC
2026-10-08 17:22 [PATCH] platform/chrome: cros_ec: trigger kernel_restart on EC_HOST_EVENT_PANIC Scott Collyer
@ 2026-10-14 7:17 ` Tzung-Bi Shih
2026-10-14 21:30 ` Scott Collyer
0 siblings, 1 reply; 3+ messages in thread
From: Tzung-Bi Shih @ 2026-10-14 7:17 UTC (permalink / raw)
To: Scott Collyer; +Cc: Benson Leung, Guenter Roeck, chrome-platform, linux-kernel
On Thu, Oct 08, 2026 at 10:22:08AM -0700, Scott Collyer wrote:
> 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.
If the EC crashed, wouldn't the AP be reset anyway?
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] platform/chrome: cros_ec: trigger kernel_restart on EC_HOST_EVENT_PANIC
2026-10-14 7:17 ` Tzung-Bi Shih
@ 2026-10-14 21:30 ` Scott Collyer
0 siblings, 0 replies; 3+ messages in thread
From: Scott Collyer @ 2026-10-14 21:30 UTC (permalink / raw)
To: Tzung-Bi Shih; +Cc: Benson Leung, Guenter Roeck, chrome-platform, linux-kernel
When the EC crashes, the AP will be reset as you mentioned. There is a
slight benefit for the EC case with this change in that a controlled
shutdown of the AP gets triggered. But, the primary motivation for
this change is for ISH panic handling. When the ISH resets, there is
currently nothing in place to trigger an AP reboot, and this results
in the sensor stack getting out of sync. So when the ISH panics, we
need the AP to reboot as well.
On Wed, Oct 14, 2026 at 12:17 AM Tzung-Bi Shih <tzungbi@kernel.org> wrote:
>
> On Thu, Oct 08, 2026 at 10:22:08AM -0700, Scott Collyer wrote:
> > 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.
>
> If the EC crashed, wouldn't the AP be reset anyway?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-14 21:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-08 17:22 [PATCH] platform/chrome: cros_ec: trigger kernel_restart on EC_HOST_EVENT_PANIC Scott Collyer
2026-10-14 7:17 ` Tzung-Bi Shih
2026-10-14 21:30 ` Scott Collyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox