public inbox for chrome-platform@lists.linux.dev
 help / color / mirror / Atom feed
From: Rob Barnes <robbarnes@google.com>
To: chrome-platform@lists.linux.dev
Cc: dnojiri@chromium.org, tzungbi@kernel.org, pmalani@chromium.org,
	 Rob Barnes <robbarnes@google.com>
Subject: [PATCH v2] platform/chrome: cros_ec: Report EC panic as uevent
Date: Tue,  9 May 2023 22:22:01 +0000	[thread overview]
Message-ID: <20230509222201.3013970-1-robbarnes@google.com> (raw)
In-Reply-To: <CA+Dqm32q5oDiHgAFQzMi12H-hd+f=v-NL6F5Bx9r2Jh6THNZrw@mail.gmail.com>

Create a uevent when an EC panic is detected. This will allow udev rules
to trigger when a panic occurs. E.g. a udev rule could be added to
capture an EC coredump. This approach avoids the need to stuff all the
processing into the driver.

Signed-off-by: Rob Barnes <robbarnes@google.com>
---
Changlog since v1:
- Inline uevent call

 drivers/platform/chrome/cros_ec_lpc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index b399f7cbf17be..fbce9898dc7e1 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -16,6 +16,7 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/interrupt.h>
+#include <linux/kobject.h>
 #include <linux/module.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_data/cros_ec_proto.h>
@@ -322,8 +323,11 @@ static void cros_ec_lpc_acpi_notify(acpi_handle device, u32 value, void *data)
 	ec_dev->last_event_time = cros_ec_get_time_ns();
 
 	if (value == ACPI_NOTIFY_CROS_EC_PANIC) {
+		static const char *env[] = { "ERROR=PANIC", NULL };
 		dev_emerg(ec_dev->dev, "CrOS EC Panic Reported. Shutdown is imminent!");
 		blocking_notifier_call_chain(&ec_dev->panic_notifier, 0, ec_dev);
+		/* Publish uevent for userspace handlers */
+		kobject_uevent_env(&ec_dev->dev->kobj, KOBJ_CHANGE, (char **)env);
 		/* Begin orderly shutdown. Force shutdown after 1 second. */
 		hw_protection_shutdown("CrOS EC Panic", 1000);
 		/* Do not query for other events after a panic is reported */
-- 
2.39.2


  reply	other threads:[~2023-05-09 22:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-20 17:46 [PATCH] platform/chrome: cros_ec: Report EC panic as uevent Rob Barnes
2023-04-20 21:08 ` Prashant Malani
2023-04-24 16:44   ` Rob Barnes
2023-05-09 22:22     ` Rob Barnes [this message]
2023-05-09 22:59       ` [PATCH v2] " Prashant Malani
2023-05-09 23:19         ` [PATCH v3] " Rob Barnes
2023-05-09 23:25           ` Prashant Malani
2023-05-09 23:26           ` [PATCH v4] " Rob Barnes
2023-05-15  5:20             ` patchwork-bot+chrome-platform
2023-05-19  2:00             ` patchwork-bot+chrome-platform

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=20230509222201.3013970-1-robbarnes@google.com \
    --to=robbarnes@google.com \
    --cc=chrome-platform@lists.linux.dev \
    --cc=dnojiri@chromium.org \
    --cc=pmalani@chromium.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