[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJq09z5SEqCxC5jQ7mPS+rqr-U-eXgWH=mjcpHpWT7UF_7twxA@mail.gmail.com>
Date: Sat, 13 Jan 2024 11:24:27 -0300
From: Luiz Angelo Daros de Luca <luizluca@...il.com>
To: Christian Marangi <ansuelsmth@...il.com>
Cc: linus.walleij@...aro.org, alsi@...g-olufsen.dk, andrew@...n.ch,
f.fainelli@...il.com, olteanv@...il.com, davem@...emloft.net,
edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
arinc.unal@...nc9.com, netdev@...r.kernel.org
Subject: Re: [RFC net-next 0/2] net: dsa: realtek: fix LED support for rtl8366rb
> I'll try to get who scheduled the work and the stack from there. It
> might already pinpoint the cause. Checking if the work is pending
> during netdev trigger activation might also help. I'll also try to
> flush (or cancel) the work before activating the new trigger. I just
> don't know if I can flush (and that way, blocking) inside
> led_set_brightness().
>
Hi Christian,
I got it. It was actually from the netdev trigger. During activation we have:
/* Check if hw control is active by default on the LED.
* Init already enabled mode in hw control.
*/
if (supports_hw_control(led_cdev)) {
dev = led_cdev->hw_control_get_device(led_cdev);
if (dev) {
const char *name = dev_name(dev);
set_device_name(trigger_data, name, strlen(name));
trigger_data->hw_control = true;
rc = led_cdev->hw_control_get(led_cdev, &mode);
if (!rc)
trigger_data->mode = mode;
}
}
The set_device_name calls set_baseline_state() that, at this point,
will start to monitor the device using sw control
(trigger_data->hw_control is only set afterwards). In
set_baseline_state(), it will call led_set_brightness in most
codepaths (all of them if trigger_data->hw_control is false). With
link down (and other situations), it will call
led_set_brightness(led_cdev, LED_OFF). If that led_set_brightness
takes some time to be processed, it will happen after the hw control
was configured, undoing what it previously just did.
Is there any good reason to call set_device_name before the led mode
and hw_control are defined? Will this break anything?
diff --git a/drivers/leds/trigger/ledtrig-netdev.c
b/drivers/leds/trigger/ledtrig-netdev.c
index d76214fa9ad8..6f72d55c187a 100644
--- a/drivers/leds/trigger/ledtrig-netdev.c
+++ b/drivers/leds/trigger/ledtrig-netdev.c
@@ -572,12 +572,13 @@ static int netdev_trig_activate(struct
led_classdev *led_cdev)
if (dev) {
const char *name = dev_name(dev);
- set_device_name(trigger_data, name, strlen(name));
trigger_data->hw_control = true;
rc = led_cdev->hw_control_get(led_cdev, &mode);
if (!rc)
trigger_data->mode = mode;
+
+ set_device_name(trigger_data, name, strlen(name));
}
}
With this patch, it will not undo the trigger setting in hardware
anymore. However, it now calls the hw_control_set 3 times during
activation:
1) set_device_name
2) register_netdevice_notifier on NETDEV_REGISTER
3) register_netdevice_notifier on NETDEV_UP
Anyway, calling it multiple times doesn't break anything.
Regards,
Luiz
Powered by blists - more mailing lists