From: Andrew Lunn <andrew@lunn.ch>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>, Pavel Machek <pavel@ucw.cz>,
Lee Jones <lee@kernel.org>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-leds@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH 08/11] leds: trigger: netdev: add support for LED hw control
Date: Sun, 30 Apr 2023 19:55:13 +0200 [thread overview]
Message-ID: <d2c86cf0-d57f-4358-9765-3983a145e1ab@lunn.ch> (raw)
In-Reply-To: <20230427001541.18704-9-ansuelsmth@gmail.com>
On Thu, Apr 27, 2023 at 02:15:38AM +0200, Christian Marangi wrote:
> Add support for LED hw control for the netdev trigger.
>
> The trigger on calling set_baseline_state to configure a new mode, will
> do various check to verify if hw control can be used for the requested
> mode in the validate_requested_mode() function.
>
> It will first check if the LED driver supports hw control for the netdev
> trigger, then will check if the requested mode are in the trigger mode
> mask and finally will call hw_control_set() to apply the requested mode.
>
> To use such mode, interval MUST be set to the default value and net_dev
> MUST be empty. If one of these 2 value are not valid, hw control will
> never be used and normal software fallback is used.
>
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> ---
> drivers/leds/trigger/ledtrig-netdev.c | 52 +++++++++++++++++++++++++++
> 1 file changed, 52 insertions(+)
>
> diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
> index 8cd876647a27..61bc19fd0c7a 100644
> --- a/drivers/leds/trigger/ledtrig-netdev.c
> +++ b/drivers/leds/trigger/ledtrig-netdev.c
> @@ -68,6 +68,13 @@ static void set_baseline_state(struct led_netdev_data *trigger_data)
> int current_brightness;
> struct led_classdev *led_cdev = trigger_data->led_cdev;
>
> + /* Already validated, hw control is possible with the requested mode */
> + if (trigger_data->hw_control) {
> + led_cdev->hw_control_set(led_cdev, trigger_data->mode);
> +
> + return;
> + }
> +
> current_brightness = led_cdev->brightness;
> if (current_brightness)
> led_cdev->blink_brightness = current_brightness;
> @@ -95,6 +102,51 @@ static void set_baseline_state(struct led_netdev_data *trigger_data)
> static int validate_requested_mode(struct led_netdev_data *trigger_data,
> unsigned long mode, bool *can_use_hw_control)
> {
> + unsigned int interval = atomic_read(&trigger_data->interval);
> + unsigned long hw_supported_mode, hw_mode = 0, sw_mode = 0;
> + struct led_classdev *led_cdev = trigger_data->led_cdev;
> + unsigned long default_interval = msecs_to_jiffies(50);
> + bool force_sw = false;
> + int i, ret;
> +
> + hw_supported_mode = led_cdev->trigger_supported_flags_mask;
> +
> + if (interval == default_interval && !trigger_data->net_dev &&
> + !force_sw && test_bit(i, &hw_supported_mode))
> + set_bit(i, &hw_mode);
> + else
> + set_bit(i, &sw_mode);
> + }
> +
> + /* Check if the requested mode is supported */
> + ret = led_cdev->hw_control_is_supported(led_cdev, hw_mode);
> + if (ret)
> + return ret;
Hi Christian
What is the purpose of led_cdev->trigger_supported_flags_mask? I don't
see why it is needed when you are also going to ask the PHY if it can
support the specific blink pattern the user is requesting.
The problem i have with the Marvell PHY, and other PHYs i've looked at
datasheets for, is that hardware does not work like this. It has a
collection of blinking modes, which are a mixture of link speeds, rx
activity, and tx activity. It supports just a subset of all
possibilities.
I think this function can be simplified. Simply ask the LED via
hw_control_is_supported() does it support this mode. If yes, offload
it, if not use software blinking.
Andrew
next prev parent reply other threads:[~2023-04-30 17:55 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-27 0:15 [PATCH 00/11] leds: introduce new LED hw control APIs Christian Marangi
2023-04-27 0:15 ` [PATCH 01/11] leds: add binding for LEDs hw control Christian Marangi
2023-04-27 0:15 ` [PATCH 02/11] leds: add binding to check support for LED " Christian Marangi
2023-04-30 18:08 ` Andrew Lunn
2023-04-27 0:15 ` [PATCH 03/11] leds: add helper function to use trigger in hw blink mode Christian Marangi
2023-04-27 0:15 ` [PATCH 04/11] Documentation: leds: leds-class: Document new Hardware driven LEDs APIs Christian Marangi
2023-05-11 3:06 ` Bagas Sanjaya
2023-04-27 0:15 ` [PATCH 05/11] leds: trigger: netdev: introduce validating requested mode Christian Marangi
2023-04-30 22:42 ` Andrew Lunn
2023-04-27 0:15 ` [PATCH 06/11] leds: trigger: netdev: add knob to set hw control possible Christian Marangi
2023-04-27 0:15 ` [PATCH 07/11] leds: trigger: netdev: reject interval and device store for hw_control Christian Marangi
2023-05-08 11:31 ` Sascha Hauer
2023-04-27 0:15 ` [PATCH 08/11] leds: trigger: netdev: add support for LED hw control Christian Marangi
2023-04-30 17:55 ` Andrew Lunn [this message]
2023-05-02 16:00 ` Christian Marangi
2023-04-27 0:15 ` [PATCH 09/11] leds: trigger: netdev: init mode if hw control already active Christian Marangi
2023-04-27 0:15 ` [PATCH 10/11] leds: trigger: netdev: expose netdev trigger modes in linux include Christian Marangi
2023-04-27 0:15 ` [PATCH 11/11] net: dsa: qca8k: implement hw_control ops Christian Marangi
2023-05-08 12:25 ` [PATCH 00/11] leds: introduce new LED hw control APIs Sascha Hauer
2023-05-08 12:33 ` Christian Marangi
2023-05-08 12:52 ` Sascha Hauer
2023-05-08 13:11 ` Andrew Lunn
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=d2c86cf0-d57f-4358-9765-3983a145e1ab@lunn.ch \
--to=andrew@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=lee@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=pavel@ucw.cz \
/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
all inboxes | Powered by JetHome®