netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Luiz Angelo Daros de Luca <luizluca@gmail.com>,
	Christian Marangi <ansuelsmth@gmail.com>
Cc: linus.walleij@linaro.org, alsi@bang-olufsen.dk, andrew@lunn.ch,
	f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	arinc.unal@arinc9.com, netdev@vger.kernel.org
Subject: Re: [RFC net-next 0/2] net: dsa: realtek: fix LED support for rtl8366rb
Date: Sat, 13 Jan 2024 15:31:58 +0100	[thread overview]
Message-ID: <92eff1db-004c-4c08-9dd3-ae094d8dd316@gmail.com> (raw)
In-Reply-To: <CAJq09z5SEqCxC5jQ7mPS+rqr-U-eXgWH=mjcpHpWT7UF_7twxA@mail.gmail.com>

On 13.01.2024 15:24, Luiz Angelo Daros de Luca wrote:
>> 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:
> 
This is addressed by the following patch, it should show up in linux-next
after the merge window.

https://git.kernel.org/pub/scm/linux/kernel/git/lee/leds.git/commit/?h=for-leds-next-next&id=5df2b4ed10a4ea636bb5ace99712a7d0c6226a55

> 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
> 


  reply	other threads:[~2024-01-13 14:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-06 18:40 [RFC net-next 0/2] net: dsa: realtek: fix LED support for rtl8366rb Luiz Angelo Daros de Luca
2024-01-06 18:40 ` [RFC net-next 1/2] net: dsa: realtek: keep default LED state in rtl8366rb Luiz Angelo Daros de Luca
2024-01-06 18:40 ` [RFC net-next 2/2] net: dsa: realtek: add LED drivers for rtl8366rb Luiz Angelo Daros de Luca
2024-01-06 19:47 ` [RFC net-next 0/2] net: dsa: realtek: fix LED support " Luiz Angelo Daros de Luca
2024-01-07 20:51   ` Christian Marangi
2024-01-08  5:47     ` Luiz Angelo Daros de Luca
2024-01-08 13:09       ` Christian Marangi
2024-01-13  4:06         ` Luiz Angelo Daros de Luca
2024-01-13 14:24           ` Luiz Angelo Daros de Luca
2024-01-13 14:31             ` Heiner Kallweit [this message]
2024-01-13 14:41               ` Luiz Angelo Daros de Luca
2024-01-07 20:16 ` Linus Walleij

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=92eff1db-004c-4c08-9dd3-ae094d8dd316@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=alsi@bang-olufsen.dk \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=arinc.unal@arinc9.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=luizluca@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    /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 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).