Disk activity trigger: keeps blinking under full load
diff mbox series

Message ID 20190523214301.GA14788@amd
State New
Headers show
Series
  • Disk activity trigger: keeps blinking under full load
Related show

Commit Message

Pavel Machek May 23, 2019, 9:43 p.m. UTC
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

Comments

Jacek Anaszewski May 25, 2019, 5:02 p.m. UTC | #1
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;
> 
> 
> 
>
Pavel Machek May 26, 2019, 8:18 a.m. UTC | #2
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

Patch
diff mbox series

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;