* [PATCH 0/3] Add a new LED trigger for kernel panics (and use it)
@ 2016-03-29 20:35 Ezequiel Garcia
2016-03-29 20:35 ` [PATCH 1/3] leds: trigger: Introduce a kernel panic LED trigger Ezequiel Garcia
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Ezequiel Garcia @ 2016-03-29 20:35 UTC (permalink / raw)
To: linux-arm-kernel
This patchset adds a very simple kernel panic LED trigger,
by hooking into panic_blink. I've tested this trigger on
ARM Armada XP OpenBlocks AX3-4 machine.
The trigger is then used to replace the open-coded panic_blink
usage in GTA02 board.
Note that I don't have a GTA02 board, so the last patch is only
built tested.
Ezequiel Garcia (3):
leds: trigger: Introduce a kernel panic LED trigger
ARM: configs: Enable panic LED trigger on s3c2410
ARM: s3c24xx: Use the panic LED trigger for GTA02
arch/arm/configs/s3c2410_defconfig | 1 +
arch/arm/mach-s3c24xx/mach-gta02.c | 35 ++++++++++++++++-------------------
drivers/leds/trigger/Kconfig | 7 +++++++
drivers/leds/trigger/Makefile | 1 +
drivers/leds/trigger/ledtrig-panic.c | 30 ++++++++++++++++++++++++++++++
5 files changed, 55 insertions(+), 19 deletions(-)
create mode 100644 drivers/leds/trigger/ledtrig-panic.c
--
2.7.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/3] leds: trigger: Introduce a kernel panic LED trigger
2016-03-29 20:35 [PATCH 0/3] Add a new LED trigger for kernel panics (and use it) Ezequiel Garcia
@ 2016-03-29 20:35 ` Ezequiel Garcia
2016-03-30 9:29 ` Jacek Anaszewski
2016-03-29 20:35 ` [PATCH 2/3] ARM: configs: Enable panic LED trigger on s3c2410 Ezequiel Garcia
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Ezequiel Garcia @ 2016-03-29 20:35 UTC (permalink / raw)
To: linux-arm-kernel
This commit introduces a new LED trigger which allows to configure
a LED to blink on a kernel panic (through panic_blink).
Notice that currently the Openmoko FreeRunner (GTA02) mach code
sets panic_blink to blink a hard-coded LED. The new trigger is
meant to introduce a generic mechanism to achieve this.
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
---
drivers/leds/trigger/Kconfig | 7 +++++++
drivers/leds/trigger/Makefile | 1 +
drivers/leds/trigger/ledtrig-panic.c | 30 ++++++++++++++++++++++++++++++
3 files changed, 38 insertions(+)
create mode 100644 drivers/leds/trigger/ledtrig-panic.c
diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig
index 5bda6a9b56bb..554f5bfbeced 100644
--- a/drivers/leds/trigger/Kconfig
+++ b/drivers/leds/trigger/Kconfig
@@ -108,4 +108,11 @@ config LEDS_TRIGGER_CAMERA
This enables direct flash/torch on/off by the driver, kernel space.
If unsure, say Y.
+config LEDS_TRIGGER_PANIC
+ bool "LED Panic Trigger"
+ depends on LEDS_TRIGGERS
+ help
+ This allows LEDs to be configured to blink on a kernel panic.
+ If unsure, say Y.
+
endif # LEDS_TRIGGERS
diff --git a/drivers/leds/trigger/Makefile b/drivers/leds/trigger/Makefile
index 1abf48dacf7e..547bf5c80e52 100644
--- a/drivers/leds/trigger/Makefile
+++ b/drivers/leds/trigger/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_LEDS_TRIGGER_CPU) += ledtrig-cpu.o
obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o
obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT) += ledtrig-transient.o
obj-$(CONFIG_LEDS_TRIGGER_CAMERA) += ledtrig-camera.o
+obj-$(CONFIG_LEDS_TRIGGER_PANIC) += ledtrig-panic.o
diff --git a/drivers/leds/trigger/ledtrig-panic.c b/drivers/leds/trigger/ledtrig-panic.c
new file mode 100644
index 000000000000..627b350c5ec3
--- /dev/null
+++ b/drivers/leds/trigger/ledtrig-panic.c
@@ -0,0 +1,30 @@
+/*
+ * Kernel Panic LED Trigger
+ *
+ * Copyright 2016 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/leds.h>
+
+static struct led_trigger *trigger;
+
+static long led_panic_blink(int state)
+{
+ led_trigger_event(trigger, state ? LED_FULL : LED_OFF);
+ return 0;
+}
+
+static int __init ledtrig_panic_init(void)
+{
+ led_trigger_register_simple("panic", &trigger);
+ panic_blink = led_panic_blink;
+ return 0;
+}
+device_initcall(ledtrig_panic_init);
--
2.7.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/3] ARM: configs: Enable panic LED trigger on s3c2410
2016-03-29 20:35 [PATCH 0/3] Add a new LED trigger for kernel panics (and use it) Ezequiel Garcia
2016-03-29 20:35 ` [PATCH 1/3] leds: trigger: Introduce a kernel panic LED trigger Ezequiel Garcia
@ 2016-03-29 20:35 ` Ezequiel Garcia
2016-03-29 20:35 ` [PATCH 3/3] ARM: s3c24xx: Use the panic LED trigger for GTA02 Ezequiel Garcia
2016-03-29 20:44 ` [PATCH 0/3] Add a new LED trigger for kernel panics (and use it) Arnd Bergmann
3 siblings, 0 replies; 10+ messages in thread
From: Ezequiel Garcia @ 2016-03-29 20:35 UTC (permalink / raw)
To: linux-arm-kernel
Let's add the panic LED trigger, which will be used by
the GTA02 board.
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
---
arch/arm/configs/s3c2410_defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig
index b3ade552a2a5..81812bd5bcc7 100644
--- a/arch/arm/configs/s3c2410_defconfig
+++ b/arch/arm/configs/s3c2410_defconfig
@@ -385,6 +385,7 @@ CONFIG_LEDS_TRIGGER_TIMER=m
CONFIG_LEDS_TRIGGER_HEARTBEAT=m
CONFIG_LEDS_TRIGGER_GPIO=m
CONFIG_LEDS_TRIGGER_DEFAULT_ON=m
+CONFIG_LEDS_TRIGGER_PANIC=y
CONFIG_RTC_CLASS=y
CONFIG_RTC_DRV_S3C=y
CONFIG_EXT2_FS=y
--
2.7.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/3] ARM: s3c24xx: Use the panic LED trigger for GTA02
2016-03-29 20:35 [PATCH 0/3] Add a new LED trigger for kernel panics (and use it) Ezequiel Garcia
2016-03-29 20:35 ` [PATCH 1/3] leds: trigger: Introduce a kernel panic LED trigger Ezequiel Garcia
2016-03-29 20:35 ` [PATCH 2/3] ARM: configs: Enable panic LED trigger on s3c2410 Ezequiel Garcia
@ 2016-03-29 20:35 ` Ezequiel Garcia
2016-03-29 20:44 ` [PATCH 0/3] Add a new LED trigger for kernel panics (and use it) Arnd Bergmann
3 siblings, 0 replies; 10+ messages in thread
From: Ezequiel Garcia @ 2016-03-29 20:35 UTC (permalink / raw)
To: linux-arm-kernel
Let's take advantage of the recently introduced panic LED trigger,
and get rid of the open-coded panic_blink usage.
Built tested only.
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
---
arch/arm/mach-s3c24xx/mach-gta02.c | 35 ++++++++++++++++-------------------
1 file changed, 16 insertions(+), 19 deletions(-)
diff --git a/arch/arm/mach-s3c24xx/mach-gta02.c b/arch/arm/mach-s3c24xx/mach-gta02.c
index 27ae6877550f..e794d55abc9e 100644
--- a/arch/arm/mach-s3c24xx/mach-gta02.c
+++ b/arch/arm/mach-s3c24xx/mach-gta02.c
@@ -71,6 +71,7 @@
#include <linux/platform_data/touchscreen-s3c2410.h>
#include <linux/platform_data/usb-ohci-s3c2410.h>
#include <linux/platform_data/usb-s3c2410_udc.h>
+#include <linux/platform_data/leds-s3c24xx.h>
#include <mach/fb.h>
#include <mach/hardware.h>
@@ -89,22 +90,6 @@
static struct pcf50633 *gta02_pcf;
-/*
- * This gets called frequently when we paniced.
- */
-
-static long gta02_panic_blink(int state)
-{
- long delay = 0;
- char led;
-
- led = (state) ? 1 : 0;
- gpio_direction_output(GTA02_GPIO_AUX_LED, led);
-
- return delay;
-}
-
-
static struct map_desc gta02_iodesc[] __initdata = {
{
.virtual = 0xe0000000,
@@ -500,6 +485,20 @@ static struct platform_device gta02_buttons_device = {
},
};
+static struct s3c24xx_led_platdata gta02_panic_led_pdata = {
+ .name = "panic",
+ .gpio = GTA02_GPIO_AUX_LED,
+ .def_trigger = "panic",
+};
+
+static struct platform_device gta02_panic_led_device = {
+ .name = "s3c24xx_led",
+ .id = -1,
+ .dev = {
+ .platform_data = >a02_panic_led_pdata,
+ },
+};
+
static void __init gta02_map_io(void)
{
s3c24xx_init_io(gta02_iodesc, ARRAY_SIZE(gta02_iodesc));
@@ -563,9 +562,7 @@ static void gta02_poweroff(void)
static void __init gta02_machine_init(void)
{
- /* Set the panic callback to turn AUX LED on or off. */
- panic_blink = gta02_panic_blink;
-
+ platform_device_register(>a02_panic_led_device);
s3c_pm_init();
#ifdef CONFIG_CHARGER_PCF50633
--
2.7.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 0/3] Add a new LED trigger for kernel panics (and use it)
2016-03-29 20:35 [PATCH 0/3] Add a new LED trigger for kernel panics (and use it) Ezequiel Garcia
` (2 preceding siblings ...)
2016-03-29 20:35 ` [PATCH 3/3] ARM: s3c24xx: Use the panic LED trigger for GTA02 Ezequiel Garcia
@ 2016-03-29 20:44 ` Arnd Bergmann
3 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2016-03-29 20:44 UTC (permalink / raw)
To: linux-arm-kernel
On Tuesday 29 March 2016 17:35:46 Ezequiel Garcia wrote:
> This patchset adds a very simple kernel panic LED trigger,
> by hooking into panic_blink. I've tested this trigger on
> ARM Armada XP OpenBlocks AX3-4 machine.
>
> The trigger is then used to replace the open-coded panic_blink
> usage in GTA02 board.
>
> Note that I don't have a GTA02 board, so the last patch is only
> built tested.
>
> Ezequiel Garcia (3):
> leds: trigger: Introduce a kernel panic LED trigger
> ARM: configs: Enable panic LED trigger on s3c2410
> ARM: s3c24xx: Use the panic LED trigger for GTA02
>
> arch/arm/configs/s3c2410_defconfig | 1 +
> arch/arm/mach-s3c24xx/mach-gta02.c | 35 ++++++++++++++++-------------------
> drivers/leds/trigger/Kconfig | 7 +++++++
> drivers/leds/trigger/Makefile | 1 +
> drivers/leds/trigger/ledtrig-panic.c | 30 ++++++++++++++++++++++++++++++
> 5 files changed, 55 insertions(+), 19 deletions(-)
> create mode 100644 drivers/leds/trigger/ledtrig-panic.c
Now we just need to port this 13-year old patch:
https://lwn.net/Articles/21857/
;-)
Arnd
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/3] leds: trigger: Introduce a kernel panic LED trigger
2016-03-29 20:35 ` [PATCH 1/3] leds: trigger: Introduce a kernel panic LED trigger Ezequiel Garcia
@ 2016-03-30 9:29 ` Jacek Anaszewski
2016-03-30 19:11 ` Ezequiel Garcia
0 siblings, 1 reply; 10+ messages in thread
From: Jacek Anaszewski @ 2016-03-30 9:29 UTC (permalink / raw)
To: linux-arm-kernel
Hi Ezequiel,
Thanks for the patch. I've tested it on exynos4412-trats2 board
with leds-aat1290 driver, by executing:
echo "c" > /proc/sysrq-trigger
I was able to notice the blinking then.
Applied to the for-next branch of linux-leds.git.
Thanks,
Jacek Anaszewski
On 03/29/2016 10:35 PM, Ezequiel Garcia wrote:
> This commit introduces a new LED trigger which allows to configure
> a LED to blink on a kernel panic (through panic_blink).
>
> Notice that currently the Openmoko FreeRunner (GTA02) mach code
> sets panic_blink to blink a hard-coded LED. The new trigger is
> meant to introduce a generic mechanism to achieve this.
>
> Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
> ---
> drivers/leds/trigger/Kconfig | 7 +++++++
> drivers/leds/trigger/Makefile | 1 +
> drivers/leds/trigger/ledtrig-panic.c | 30 ++++++++++++++++++++++++++++++
> 3 files changed, 38 insertions(+)
> create mode 100644 drivers/leds/trigger/ledtrig-panic.c
>
> diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig
> index 5bda6a9b56bb..554f5bfbeced 100644
> --- a/drivers/leds/trigger/Kconfig
> +++ b/drivers/leds/trigger/Kconfig
> @@ -108,4 +108,11 @@ config LEDS_TRIGGER_CAMERA
> This enables direct flash/torch on/off by the driver, kernel space.
> If unsure, say Y.
>
> +config LEDS_TRIGGER_PANIC
> + bool "LED Panic Trigger"
> + depends on LEDS_TRIGGERS
> + help
> + This allows LEDs to be configured to blink on a kernel panic.
> + If unsure, say Y.
> +
> endif # LEDS_TRIGGERS
> diff --git a/drivers/leds/trigger/Makefile b/drivers/leds/trigger/Makefile
> index 1abf48dacf7e..547bf5c80e52 100644
> --- a/drivers/leds/trigger/Makefile
> +++ b/drivers/leds/trigger/Makefile
> @@ -8,3 +8,4 @@ obj-$(CONFIG_LEDS_TRIGGER_CPU) += ledtrig-cpu.o
> obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o
> obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT) += ledtrig-transient.o
> obj-$(CONFIG_LEDS_TRIGGER_CAMERA) += ledtrig-camera.o
> +obj-$(CONFIG_LEDS_TRIGGER_PANIC) += ledtrig-panic.o
> diff --git a/drivers/leds/trigger/ledtrig-panic.c b/drivers/leds/trigger/ledtrig-panic.c
> new file mode 100644
> index 000000000000..627b350c5ec3
> --- /dev/null
> +++ b/drivers/leds/trigger/ledtrig-panic.c
> @@ -0,0 +1,30 @@
> +/*
> + * Kernel Panic LED Trigger
> + *
> + * Copyright 2016 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <linux/leds.h>
> +
> +static struct led_trigger *trigger;
> +
> +static long led_panic_blink(int state)
> +{
> + led_trigger_event(trigger, state ? LED_FULL : LED_OFF);
> + return 0;
> +}
> +
> +static int __init ledtrig_panic_init(void)
> +{
> + led_trigger_register_simple("panic", &trigger);
> + panic_blink = led_panic_blink;
> + return 0;
> +}
> +device_initcall(ledtrig_panic_init);
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/3] leds: trigger: Introduce a kernel panic LED trigger
2016-03-30 9:29 ` Jacek Anaszewski
@ 2016-03-30 19:11 ` Ezequiel Garcia
2016-03-31 7:04 ` Jacek Anaszewski
2016-03-31 12:56 ` Holger Schurig
0 siblings, 2 replies; 10+ messages in thread
From: Ezequiel Garcia @ 2016-03-30 19:11 UTC (permalink / raw)
To: linux-arm-kernel
+lkml
On 30 Mar 11:29 AM, Jacek Anaszewski wrote:
> Hi Ezequiel,
>
> Thanks for the patch. I've tested it on exynos4412-trats2 board
> with leds-aat1290 driver, by executing:
>
> echo "c" > /proc/sysrq-trigger
>
> I was able to notice the blinking then.
>
> Applied to the for-next branch of linux-leds.git.
>
Notice that we currently need LEDs to be dedicated
to the panic trigger, which is pretty lame as LEDs
are scarce and are most likely assigned to something else.
So, here's a toy patch to switch all the installed LEDs
to the panic trigger on kernel panic. Patch is half-baked,
but it shows the idea.
(Interestingly, it also blinks the LEDs on a USB keyboard!)
Is there any value in polishing this and find a way upstream?
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index aa84e5b37593..caaf6161a7ae 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -321,6 +321,20 @@ void devm_led_classdev_unregister(struct device *dev,
}
EXPORT_SYMBOL_GPL(devm_led_classdev_unregister);
+static int led_panic_notifier(struct notifier_block *nb,
+ unsigned long code, void *unused)
+{
+ struct led_classdev *led_cdev;
+
+ list_for_each_entry(led_cdev, &leds_list, node)
+ led_trigger_set_at_panic(led_cdev, "panic");
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block led_panic_nb = {
+ .notifier_call = led_panic_notifier,
+};
+
static int __init leds_init(void)
{
leds_class = class_create(THIS_MODULE, "leds");
@@ -328,6 +342,8 @@ static int __init leds_init(void)
return PTR_ERR(leds_class);
leds_class->pm = &leds_class_dev_pm_ops;
leds_class->dev_groups = led_groups;
+ atomic_notifier_chain_register(&panic_notifier_list,
+ &led_panic_nb);
return 0;
}
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 2181581795d3..8c1d33acdfa8 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -148,6 +148,21 @@ void led_trigger_remove(struct led_classdev *led_cdev)
}
EXPORT_SYMBOL_GPL(led_trigger_remove);
+void led_trigger_set_at_panic(struct led_classdev *led_cdev, const char *name)
+{
+ struct led_trigger *trig;
+
+ list_for_each_entry(trig, &trigger_list, next_trig) {
+ if (strcmp(name, trig->name))
+ continue;
+ list_add_tail(&led_cdev->trig_list, &trig->led_cdevs);
+ led_cdev->trigger = trig;
+ if (trig->activate)
+ trig->activate(led_cdev);
+ break;
+ }
+}
+
void led_trigger_set_default(struct led_classdev *led_cdev)
{
struct led_trigger *trig;
diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h
index db3f20da7221..8cfa10f626a6 100644
--- a/drivers/leds/leds.h
+++ b/drivers/leds/leds.h
@@ -21,6 +21,7 @@ static inline int led_get_brightness(struct led_classdev *led_cdev)
return led_cdev->brightness;
}
+void led_trigger_set_at_panic(struct led_classdev *led_cdev, const char *name);
void led_init_core(struct led_classdev *led_cdev);
void led_stop_software_blink(struct led_classdev *led_cdev);
void led_set_brightness_nopm(struct led_classdev *led_cdev,
--
2.7.0
--
Ezequiel Garcia, VanguardiaSur
www.vanguardiasur.com.ar
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 1/3] leds: trigger: Introduce a kernel panic LED trigger
2016-03-30 19:11 ` Ezequiel Garcia
@ 2016-03-31 7:04 ` Jacek Anaszewski
2016-03-31 7:28 ` Jacek Anaszewski
2016-03-31 12:56 ` Holger Schurig
1 sibling, 1 reply; 10+ messages in thread
From: Jacek Anaszewski @ 2016-03-31 7:04 UTC (permalink / raw)
To: linux-arm-kernel
Hi Ezequiel,
On 03/30/2016 09:11 PM, Ezequiel Garcia wrote:
> +lkml
>
> On 30 Mar 11:29 AM, Jacek Anaszewski wrote:
>> Hi Ezequiel,
>>
>> Thanks for the patch. I've tested it on exynos4412-trats2 board
>> with leds-aat1290 driver, by executing:
>>
>> echo "c" > /proc/sysrq-trigger
>>
>> I was able to notice the blinking then.
>>
>> Applied to the for-next branch of linux-leds.git.
>>
>
> Notice that we currently need LEDs to be dedicated
> to the panic trigger, which is pretty lame as LEDs
> are scarce and are most likely assigned to something else.
>
> So, here's a toy patch to switch all the installed LEDs
> to the panic trigger on kernel panic. Patch is half-baked,
> but it shows the idea.
>
> (Interestingly, it also blinks the LEDs on a USB keyboard!)
>
> Is there any value in polishing this and find a way upstream?
I like the idea, but I'd rather explicitly mark LEDs as panic
indicators.
How about adding a "kernel-panic-indicator" Device Tree property to
common LED bindings? LED class device could be registered for the
panic trigger on kernel panic notification only when the property is
present.
Adding Rob, Mark and devicetree list.
> diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
> index aa84e5b37593..caaf6161a7ae 100644
> --- a/drivers/leds/led-class.c
> +++ b/drivers/leds/led-class.c
> @@ -321,6 +321,20 @@ void devm_led_classdev_unregister(struct device *dev,
> }
> EXPORT_SYMBOL_GPL(devm_led_classdev_unregister);
>
> +static int led_panic_notifier(struct notifier_block *nb,
> + unsigned long code, void *unused)
> +{
> + struct led_classdev *led_cdev;
> +
> + list_for_each_entry(led_cdev, &leds_list, node)
> + led_trigger_set_at_panic(led_cdev, "panic");
> + return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block led_panic_nb = {
> + .notifier_call = led_panic_notifier,
> +};
> +
> static int __init leds_init(void)
> {
> leds_class = class_create(THIS_MODULE, "leds");
> @@ -328,6 +342,8 @@ static int __init leds_init(void)
> return PTR_ERR(leds_class);
> leds_class->pm = &leds_class_dev_pm_ops;
> leds_class->dev_groups = led_groups;
> + atomic_notifier_chain_register(&panic_notifier_list,
> + &led_panic_nb);
> return 0;
> }
>
> diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
> index 2181581795d3..8c1d33acdfa8 100644
> --- a/drivers/leds/led-triggers.c
> +++ b/drivers/leds/led-triggers.c
> @@ -148,6 +148,21 @@ void led_trigger_remove(struct led_classdev *led_cdev)
> }
> EXPORT_SYMBOL_GPL(led_trigger_remove);
>
> +void led_trigger_set_at_panic(struct led_classdev *led_cdev, const char *name)
> +{
"name" parameter is not required, since setting other trigger than panic
on kernel panic doesn't make sense.
> + struct led_trigger *trig;
> +
> + list_for_each_entry(trig, &trigger_list, next_trig) {
> + if (strcmp(name, trig->name))
> + continue;
> + list_add_tail(&led_cdev->trig_list, &trig->led_cdevs);
> + led_cdev->trigger = trig;
> + if (trig->activate)
> + trig->activate(led_cdev);
> + break;
> + }
> +}
> +
> void led_trigger_set_default(struct led_classdev *led_cdev)
> {
> struct led_trigger *trig;
> diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h
> index db3f20da7221..8cfa10f626a6 100644
> --- a/drivers/leds/leds.h
> +++ b/drivers/leds/leds.h
> @@ -21,6 +21,7 @@ static inline int led_get_brightness(struct led_classdev *led_cdev)
> return led_cdev->brightness;
> }
>
> +void led_trigger_set_at_panic(struct led_classdev *led_cdev, const char *name);
> void led_init_core(struct led_classdev *led_cdev);
> void led_stop_software_blink(struct led_classdev *led_cdev);
> void led_set_brightness_nopm(struct led_classdev *led_cdev,
>
--
Best regards,
Jacek Anaszewski
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/3] leds: trigger: Introduce a kernel panic LED trigger
2016-03-31 7:04 ` Jacek Anaszewski
@ 2016-03-31 7:28 ` Jacek Anaszewski
0 siblings, 0 replies; 10+ messages in thread
From: Jacek Anaszewski @ 2016-03-31 7:28 UTC (permalink / raw)
To: linux-arm-kernel
On 03/31/2016 09:04 AM, Jacek Anaszewski wrote:
> Hi Ezequiel,
>
> On 03/30/2016 09:11 PM, Ezequiel Garcia wrote:
>> +lkml
>>
>> On 30 Mar 11:29 AM, Jacek Anaszewski wrote:
>>> Hi Ezequiel,
>>>
>>> Thanks for the patch. I've tested it on exynos4412-trats2 board
>>> with leds-aat1290 driver, by executing:
>>>
>>> echo "c" > /proc/sysrq-trigger
>>>
>>> I was able to notice the blinking then.
>>>
>>> Applied to the for-next branch of linux-leds.git.
>>>
>>
>> Notice that we currently need LEDs to be dedicated
>> to the panic trigger, which is pretty lame as LEDs
>> are scarce and are most likely assigned to something else.
>>
>> So, here's a toy patch to switch all the installed LEDs
>> to the panic trigger on kernel panic. Patch is half-baked,
>> but it shows the idea.
>>
>> (Interestingly, it also blinks the LEDs on a USB keyboard!)
>>
>> Is there any value in polishing this and find a way upstream?
>
> I like the idea, but I'd rather explicitly mark LEDs as panic
> indicators.
>
> How about adding a "kernel-panic-indicator" Device Tree property to
> common LED bindings? LED class device could be registered for the
> panic trigger on kernel panic notification only when the property is
> present.
Of course we would need similar solution for ACPI based platforms,
however I am not sure if this approach is feasible in that case, since
device configuration data is enclosed in firmware then.
Adding linux-acpi list.
> Adding Rob, Mark and devicetree list.
>
>> diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
>> index aa84e5b37593..caaf6161a7ae 100644
>> --- a/drivers/leds/led-class.c
>> +++ b/drivers/leds/led-class.c
>> @@ -321,6 +321,20 @@ void devm_led_classdev_unregister(struct device
>> *dev,
>> }
>> EXPORT_SYMBOL_GPL(devm_led_classdev_unregister);
>>
>> +static int led_panic_notifier(struct notifier_block *nb,
>> + unsigned long code, void *unused)
>> +{
>> + struct led_classdev *led_cdev;
>> +
>> + list_for_each_entry(led_cdev, &leds_list, node)
>> + led_trigger_set_at_panic(led_cdev, "panic");
>> + return NOTIFY_DONE;
>> +}
>> +
>> +static struct notifier_block led_panic_nb = {
>> + .notifier_call = led_panic_notifier,
>> +};
>> +
>> static int __init leds_init(void)
>> {
>> leds_class = class_create(THIS_MODULE, "leds");
>> @@ -328,6 +342,8 @@ static int __init leds_init(void)
>> return PTR_ERR(leds_class);
>> leds_class->pm = &leds_class_dev_pm_ops;
>> leds_class->dev_groups = led_groups;
>> + atomic_notifier_chain_register(&panic_notifier_list,
>> + &led_panic_nb);
>> return 0;
>> }
>>
>> diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
>> index 2181581795d3..8c1d33acdfa8 100644
>> --- a/drivers/leds/led-triggers.c
>> +++ b/drivers/leds/led-triggers.c
>> @@ -148,6 +148,21 @@ void led_trigger_remove(struct led_classdev
>> *led_cdev)
>> }
>> EXPORT_SYMBOL_GPL(led_trigger_remove);
>>
>> +void led_trigger_set_at_panic(struct led_classdev *led_cdev, const
>> char *name)
>> +{
>
> "name" parameter is not required, since setting other trigger than panic
> on kernel panic doesn't make sense.
>
>> + struct led_trigger *trig;
>> +
>> + list_for_each_entry(trig, &trigger_list, next_trig) {
>> + if (strcmp(name, trig->name))
>> + continue;
>> + list_add_tail(&led_cdev->trig_list, &trig->led_cdevs);
>> + led_cdev->trigger = trig;
>> + if (trig->activate)
>> + trig->activate(led_cdev);
>> + break;
>> + }
>> +}
>> +
>> void led_trigger_set_default(struct led_classdev *led_cdev)
>> {
>> struct led_trigger *trig;
>> diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h
>> index db3f20da7221..8cfa10f626a6 100644
>> --- a/drivers/leds/leds.h
>> +++ b/drivers/leds/leds.h
>> @@ -21,6 +21,7 @@ static inline int led_get_brightness(struct
>> led_classdev *led_cdev)
>> return led_cdev->brightness;
>> }
>>
>> +void led_trigger_set_at_panic(struct led_classdev *led_cdev, const
>> char *name);
>> void led_init_core(struct led_classdev *led_cdev);
>> void led_stop_software_blink(struct led_classdev *led_cdev);
>> void led_set_brightness_nopm(struct led_classdev *led_cdev,
>>
>
>
--
Best regards,
Jacek Anaszewski
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/3] leds: trigger: Introduce a kernel panic LED trigger
2016-03-30 19:11 ` Ezequiel Garcia
2016-03-31 7:04 ` Jacek Anaszewski
@ 2016-03-31 12:56 ` Holger Schurig
1 sibling, 0 replies; 10+ messages in thread
From: Holger Schurig @ 2016-03-31 12:56 UTC (permalink / raw)
To: linux-arm-kernel
> (Interestingly, it also blinks the LEDs on a USB keyboard!)
Assuming USB is still working after a kernel panic ...
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-03-31 12:56 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-29 20:35 [PATCH 0/3] Add a new LED trigger for kernel panics (and use it) Ezequiel Garcia
2016-03-29 20:35 ` [PATCH 1/3] leds: trigger: Introduce a kernel panic LED trigger Ezequiel Garcia
2016-03-30 9:29 ` Jacek Anaszewski
2016-03-30 19:11 ` Ezequiel Garcia
2016-03-31 7:04 ` Jacek Anaszewski
2016-03-31 7:28 ` Jacek Anaszewski
2016-03-31 12:56 ` Holger Schurig
2016-03-29 20:35 ` [PATCH 2/3] ARM: configs: Enable panic LED trigger on s3c2410 Ezequiel Garcia
2016-03-29 20:35 ` [PATCH 3/3] ARM: s3c24xx: Use the panic LED trigger for GTA02 Ezequiel Garcia
2016-03-29 20:44 ` [PATCH 0/3] Add a new LED trigger for kernel panics (and use it) Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox