diff mbox series

[v2] platform/chrome: cros_ec: Report EC panic as uevent

Message ID 20230509222201.3013970-1-robbarnes@google.com (mailing list archive)
State Superseded
Headers show
Series [v2] platform/chrome: cros_ec: Report EC panic as uevent | expand

Commit Message

Rob Barnes May 9, 2023, 10:22 p.m. UTC
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(+)

Comments

Prashant Malani May 9, 2023, 10:59 p.m. UTC | #1
Hi Rob,

On Tue, May 9, 2023 at 3:22 PM Rob Barnes <robbarnes@google.com> wrote:
>
> 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>

I listed a couple of nits, but once those are fixed, please feel free to add:
Reviewed-by: Prashant Malani <pmalani@chromium.org>

> ---
> 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 };
The convention in this file is to have variable declarations at the
beginning of the function block,
so please follow that here.

>                 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 */
I don't think this comment is necessary. uevents are for use by
userspace (by definition).

Best regards,

-Prashant
diff mbox series

Patch

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 */