LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Disk activity trigger: keeps blinking under full load
@ 2019-05-23 21:43 Pavel Machek
  2019-05-25 17:02 ` Jacek Anaszewski
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2019-05-23 21:43 UTC (permalink / raw)
  To: linux-leds, linux-kernel, jacek.anaszewski; +Cc: linus.walleij, linz, rpurdie

[-- Attachment #1: Type: text/plain, Size: 2118 bytes --]

Hi!

I'm trying to use disk activity trigger on a scrollock LED... but it
significantly differs from "usual" disk LED: even under "full" disk
activity (linear read) where it should be solidly "on", it keeps
blinking.

I guess that's what led_trigger_blink_oneshot() does. I tried to
change the parameters... off_delay == 0 breaks it completely, and even
with delay of 1 it behaves very weirdly.

Is there better helper I should use?

								Pavel

diff --git a/drivers/leds/trigger/ledtrig-disk.c b/drivers/leds/trigger/ledtrig-disk.c
index 9816b0d..cf40ef2 100644
--- a/drivers/leds/trigger/ledtrig-disk.c
+++ b/drivers/leds/trigger/ledtrig-disk.c
@@ -15,7 +15,7 @@
 #include <linux/init.h>
 #include <linux/leds.h>
 
-#define BLINK_DELAY 30
+#define BLINK_DELAY 10
 
 DEFINE_LED_TRIGGER(ledtrig_disk);
 DEFINE_LED_TRIGGER(ledtrig_disk_read);
@@ -25,17 +25,18 @@ DEFINE_LED_TRIGGER(ledtrig_ide);
 void ledtrig_disk_activity(bool write)
 {
 	unsigned long blink_delay = BLINK_DELAY;
+	unsigned long off_delay = 1;
 
 	led_trigger_blink_oneshot(ledtrig_disk,
-				  &blink_delay, &blink_delay, 0);
+				  &blink_delay, &off_delay, 0);
 	led_trigger_blink_oneshot(ledtrig_ide,
-				  &blink_delay, &blink_delay, 0);
+				  &blink_delay, &off_delay, 0);
 	if (write)
 		led_trigger_blink_oneshot(ledtrig_disk_write,
-					  &blink_delay, &blink_delay, 0);
+					  &blink_delay, &off_delay, 0);
 	else
 		led_trigger_blink_oneshot(ledtrig_disk_read,
-					  &blink_delay, &blink_delay, 0);
+					  &blink_delay, &off_delay, 0);
 }
 EXPORT_SYMBOL(ledtrig_disk_activity);
 
@@ -44,6 +45,7 @@ static int __init ledtrig_disk_init(void)
 	led_trigger_register_simple("disk-activity", &ledtrig_disk);
 	led_trigger_register_simple("disk-read", &ledtrig_disk_read);
 	led_trigger_register_simple("disk-write", &ledtrig_disk_write);
+	/* deprecate? */
 	led_trigger_register_simple("ide-disk", &ledtrig_ide);
 
 	return 0;




-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Disk activity trigger: keeps blinking under full load
  2019-05-23 21:43 Disk activity trigger: keeps blinking under full load Pavel Machek
@ 2019-05-25 17:02 ` Jacek Anaszewski
  2019-05-26  8:18   ` Pavel Machek
  0 siblings, 1 reply; 3+ messages in thread
From: Jacek Anaszewski @ 2019-05-25 17:02 UTC (permalink / raw)
  To: Pavel Machek, linux-leds, linux-kernel; +Cc: linus.walleij, linz, rpurdie

Hi,

On 5/23/19 11:43 PM, Pavel Machek wrote:
> Hi!
> 
> I'm trying to use disk activity trigger on a scrollock LED... but it
> significantly differs from "usual" disk LED: even under "full" disk
> activity (linear read) where it should be solidly "on", it keeps
> blinking.
> 
> I guess that's what led_trigger_blink_oneshot() does. I tried to
> change the parameters... off_delay == 0 breaks it completely, and even
> with delay of 1 it behaves very weirdly.
> 
> Is there better helper I should use?

It seems this is the way how led_blink_set_oneshot() works.
It initially checks whether timer is pending and doesn't
reset the timer in this case:

         if (test_bit(LED_BLINK_ONESHOT, &led_cdev->work_flags) &&
              timer_pending(&led_cdev->blink_timer))
                 return;

In effect you get gaps between timer expiration and setting of a new
blink shot.

Best regards,
Jacek Anaszewski

> 
> 								Pavel
> 
> diff --git a/drivers/leds/trigger/ledtrig-disk.c b/drivers/leds/trigger/ledtrig-disk.c
> index 9816b0d..cf40ef2 100644
> --- a/drivers/leds/trigger/ledtrig-disk.c
> +++ b/drivers/leds/trigger/ledtrig-disk.c
> @@ -15,7 +15,7 @@
>   #include <linux/init.h>
>   #include <linux/leds.h>
>   
> -#define BLINK_DELAY 30
> +#define BLINK_DELAY 10
>   
>   DEFINE_LED_TRIGGER(ledtrig_disk);
>   DEFINE_LED_TRIGGER(ledtrig_disk_read);
> @@ -25,17 +25,18 @@ DEFINE_LED_TRIGGER(ledtrig_ide);
>   void ledtrig_disk_activity(bool write)
>   {
>   	unsigned long blink_delay = BLINK_DELAY;
> +	unsigned long off_delay = 1;
>   
>   	led_trigger_blink_oneshot(ledtrig_disk,
> -				  &blink_delay, &blink_delay, 0);
> +				  &blink_delay, &off_delay, 0);
>   	led_trigger_blink_oneshot(ledtrig_ide,
> -				  &blink_delay, &blink_delay, 0);
> +				  &blink_delay, &off_delay, 0);
>   	if (write)
>   		led_trigger_blink_oneshot(ledtrig_disk_write,
> -					  &blink_delay, &blink_delay, 0);
> +					  &blink_delay, &off_delay, 0);
>   	else
>   		led_trigger_blink_oneshot(ledtrig_disk_read,
> -					  &blink_delay, &blink_delay, 0);
> +					  &blink_delay, &off_delay, 0);
>   }
>   EXPORT_SYMBOL(ledtrig_disk_activity);
>   
> @@ -44,6 +45,7 @@ static int __init ledtrig_disk_init(void)
>   	led_trigger_register_simple("disk-activity", &ledtrig_disk);
>   	led_trigger_register_simple("disk-read", &ledtrig_disk_read);
>   	led_trigger_register_simple("disk-write", &ledtrig_disk_write);
> +	/* deprecate? */
>   	led_trigger_register_simple("ide-disk", &ledtrig_ide);
>   
>   	return 0;
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Disk activity trigger: keeps blinking under full load
  2019-05-25 17:02 ` Jacek Anaszewski
@ 2019-05-26  8:18   ` Pavel Machek
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2019-05-26  8:18 UTC (permalink / raw)
  To: Jacek Anaszewski; +Cc: linux-leds, linux-kernel, linus.walleij, linz, rpurdie

[-- Attachment #1: Type: text/plain, Size: 1302 bytes --]

On Sat 2019-05-25 19:02:47, Jacek Anaszewski wrote:
> Hi,
> 
> On 5/23/19 11:43 PM, Pavel Machek wrote:
> >Hi!
> >
> >I'm trying to use disk activity trigger on a scrollock LED... but it
> >significantly differs from "usual" disk LED: even under "full" disk
> >activity (linear read) where it should be solidly "on", it keeps
> >blinking.
> >
> >I guess that's what led_trigger_blink_oneshot() does. I tried to
> >change the parameters... off_delay == 0 breaks it completely, and even
> >with delay of 1 it behaves very weirdly.
> >
> >Is there better helper I should use?
> 
> It seems this is the way how led_blink_set_oneshot() works.
> It initially checks whether timer is pending and doesn't
> reset the timer in this case:
> 
>         if (test_bit(LED_BLINK_ONESHOT, &led_cdev->work_flags) &&
>              timer_pending(&led_cdev->blink_timer))
>                 return;
> 
> In effect you get gaps between timer expiration and setting of a new
> blink shot.

Yep. I consider it a bug (it differs from hardware disk activity LEDs
and looks horrible).

Is there someone who considers it a feature?
								Pavel
								
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-26  8:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-23 21:43 Disk activity trigger: keeps blinking under full load Pavel Machek
2019-05-25 17:02 ` Jacek Anaszewski
2019-05-26  8:18   ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).