All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
To: Jacek Anaszewski <j.anaszewski@samsung.com>,
	Arnd Bergmann <arnd@arndb.de>
Cc: linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Richard Purdie <rpurdie@rpsys.net>,
	kgene@kernel.org, k.kozlowski@samsung.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] leds: trigger: Introduce a kernel panic LED trigger
Date: Wed, 30 Mar 2016 16:11:09 -0300	[thread overview]
Message-ID: <20160330191109.GA27372@laptop.cereza> (raw)
In-Reply-To: <56FB9C6A.2090402@samsung.com>

+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

WARNING: multiple messages have this Message-ID (diff)
From: ezequiel@vanguardiasur.com.ar (Ezequiel Garcia)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] leds: trigger: Introduce a kernel panic LED trigger
Date: Wed, 30 Mar 2016 16:11:09 -0300	[thread overview]
Message-ID: <20160330191109.GA27372@laptop.cereza> (raw)
In-Reply-To: <56FB9C6A.2090402@samsung.com>

+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

  reply	other threads:[~2016-03-30 19:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-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-30  9:29   ` Jacek Anaszewski
2016-03-30  9:29     ` Jacek Anaszewski
2016-03-30 19:11     ` Ezequiel Garcia [this message]
2016-03-30 19:11       ` Ezequiel Garcia
2016-03-31  7:04       ` Jacek Anaszewski
2016-03-31  7:04         ` Jacek Anaszewski
2016-03-31  7:28         ` Jacek Anaszewski
2016-03-31  7:28           ` Jacek Anaszewski
2016-03-31 12:56       ` Holger Schurig
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   ` 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:35   ` Ezequiel Garcia
2016-03-29 20:44 ` [PATCH 0/3] Add a new LED trigger for kernel panics (and use it) Arnd Bergmann
2016-03-29 20:44   ` Arnd Bergmann

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=20160330191109.GA27372@laptop.cereza \
    --to=ezequiel@vanguardiasur.com.ar \
    --cc=arnd@arndb.de \
    --cc=j.anaszewski@samsung.com \
    --cc=k.kozlowski@samsung.com \
    --cc=kgene@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=rpurdie@rpsys.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.