From: Rob Barnes <robbarnes@google.com>
To: chrome-platform@lists.linux.dev
Cc: dnojiri@chromium.org, tzungbi@kernel.org,
Rob Barnes <robbarnes@google.com>
Subject: [PATCH] platform/chrome: cros_ec: Report EC panic as uevent
Date: Thu, 20 Apr 2023 17:46:23 +0000 [thread overview]
Message-ID: <20230420174623.2794634-1-robbarnes@google.com> (raw)
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
create an EC coredump. This approach allows more code to be moved out
of the kernel drivers.
Change-Id: I4fe7e4e603dcbf0ae6d4c4506f8978b0486abbbf
Signed-off-by: Rob Barnes <robbarnes@google.com>
---
drivers/platform/chrome/cros_ec_lpc.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index b399f7cbf17be..f2d5b00e6c3a0 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>
@@ -313,6 +314,23 @@ static int cros_ec_lpc_readmem(struct cros_ec_device *ec, unsigned int offset,
return cnt;
}
+/**
+ * cros_ec_lpc_panic_uevent() - Publish EC panic uevent
+ * @ec_dev: Device that panic'd
+ *
+ * This function will generate a uevent to notify userspace.
+ * Typically the system will be reset shortly after an EC panic occurs.
+ *
+ * Return: 0 on success or <0 on error.
+ */
+static int cros_ec_lpc_panic_uevent(struct cros_ec_device *ec_dev)
+{
+ struct device *dev = ec_dev->dev;
+ static char *env[] = { "ERROR=PANIC", NULL };
+
+ return kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, env);
+}
+
static void cros_ec_lpc_acpi_notify(acpi_handle device, u32 value, void *data)
{
struct cros_ec_device *ec_dev = data;
@@ -324,6 +342,8 @@ static void cros_ec_lpc_acpi_notify(acpi_handle device, u32 value, void *data)
if (value == ACPI_NOTIFY_CROS_EC_PANIC) {
dev_emerg(ec_dev->dev, "CrOS EC Panic Reported. Shutdown is imminent!");
blocking_notifier_call_chain(&ec_dev->panic_notifier, 0, ec_dev);
+ cros_ec_lpc_panic_uevent(ec_dev);
+
/* 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
next reply other threads:[~2023-04-20 17:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 17:46 Rob Barnes [this message]
2023-04-20 21:08 ` [PATCH] platform/chrome: cros_ec: Report EC panic as uevent Prashant Malani
2023-04-24 16:44 ` Rob Barnes
2023-05-09 22:22 ` [PATCH v2] " Rob Barnes
2023-05-09 22:59 ` 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=20230420174623.2794634-1-robbarnes@google.com \
--to=robbarnes@google.com \
--cc=chrome-platform@lists.linux.dev \
--cc=dnojiri@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