From: netdev-bot+sashiko@kernel.org
To: olek2@wp.pl
Cc: andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: dsa: mv88e6xxx: Enable LED control on 88E6171
Date: Mon, 16 Nov 2026 18:28:03 +0000 [thread overview]
Message-ID: <179485368308.3136.7792285463770201069@kernel.org> (raw)
In-Reply-To: <20261115181305.2860498-1-olek2@wp.pl>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 (1) · Medium: 1 · Low: 1 (1)
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] mv88e6xxx_port_setup_leds() (drivers/net/dsa/mv88e6xxx/leds.c)
now installs the four hw_control_* callbacks only when the chip has…
- [Low] The commit message only talks about enabling LEDs on the 88E6171.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch
extends it to the 88E6171 and adds new callbacks that hit it.
- [Low] mv88e6xxx_led_set_blinking_period() ignores its `led` argument
and rewrites the per-port Stretch/Blink register (pointer 0x6, "for…
--
net: dsa: mv88e6xxx: Enable LED control on 88E6171
This patch enables LED control on the 88E6171. That switch has four LEDs
per port and a register layout similar to the 6352 family. The patch also
adds per-chip num_leds and led_hw_triggers fields, LED2/LED3 register
definitions and callbacks, and installs the hw_control callbacks only
when led_hw_triggers is set.
> diff --git a/drivers/net/dsa/mv88e6xxx/leds.c b/drivers/net/dsa/mv88e6xxx/leds.c
> index ab3bc645da566..925c120afba33 100644
> --- a/drivers/net/dsa/mv88e6xxx/leds.c
> +++ b/drivers/net/dsa/mv88e6xxx/leds.c
[ ... ]
> @@ -526,24 +573,40 @@ static int mv88e6xxx_led_blink_set(struct mv88e6xxx_port *p, int led,
> if (err)
> return err;
>
> - err = mv88e6xxx_port_led_read(p->chip, p->port,
> - MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL,
> - ®);
> + if (led == 2 || led == 3)
> + err = mv88e6xxx_port_led_read(p->chip, p->port,
> + MV88E6XXX_PORT_LED_CONTROL_POINTER_LED23_CTRL,
> + ®);
[Severity: Low]
This isn't a bug introduced by this patch, but it now affects up to four
LEDs per port instead of two.
The mv88e6xxx_led_set_blinking_period() call just above this ignores its
led argument. It rebuilds the per-port Stretch/Blink register from
scratch:
drivers/net/dsa/mv88e6xxx/leds.c:mv88e6xxx_led_set_blinking_period() {
...
reg = 0;
...
/* Set up blink rate */
reg |= MV88E6XXX_PORT_LED_CONTROL_POINTER_STRETCH_BLINK;
return mv88e6xxx_port_led_write(p->chip, p->port, reg);
}
On the 6171, a blink_set on LED2 can change the blink rate and pulse
stretch of LED0, LED1 or LED3 on the same port. That happens when the
other LED is in forced blink or a hardware activity mode, and the LED
core still holds that LED's old blink_delay_on/off values.
Is it intended that one LED's blink period changes the other LEDs on the
port? The result is only a wrong blink rate. Nothing crashes.
[ ... ]
> @@ -576,6 +639,34 @@ static int mv88e6xxx_led1_blink_set(struct led_classdev *ldev,
> return err;
> }
>
> +static int mv88e6xxx_led2_blink_set(struct led_classdev *ldev,
> + unsigned long *delay_on,
> + unsigned long *delay_off)
> +{
> + struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led2);
> + int err;
> +
> + mv88e6xxx_reg_lock(p->chip);
> + err = mv88e6xxx_led_blink_set(p, 2, delay_on, delay_off);
> + mv88e6xxx_reg_unlock(p->chip);
> +
> + return err;
> +}
[Severity: High]
This is a pre-existing issue, but this patch extends it to the 88E6171
by adding .port_setup_leds to mv88e6171_ops. The new LED2/LED3
callbacks also hit it.
mv88e6xxx_setup() takes chip->reg_lock and keeps it held during port
setup, LED classdev registration included. If a DT LED node has
linux,default-trigger = "timer", the trigger is activated synchronously
inside registration:
mv88e6xxx_setup()
mv88e6xxx_reg_lock(chip)
mv88e6xxx_setup_port()
mv88e6xxx_port_setup_leds()
devm_led_classdev_register_ext()
led_classdev_register_ext()
led_trigger_set_default()
timer_trig_activate()
led_blink_set()
led_blink_setup()
mv88e6xxx_led2_blink_set()
mv88e6xxx_reg_lock(p->chip)
Can this deadlock probe on the non-recursive reg_lock that the same task
already holds? The LED core's trigger locks would stay held too.
With linux,default-trigger = "netdev", netdev_trig_activate() calls
register_netdevice_notifier(). That takes rtnl while reg_lock is held,
which is the reverse of the rtnl -> reg_lock order used elsewhere in
the driver.
Could the LED classdevs be registered outside the reg_lock section, or
could the lock be dropped around registration?
[ ... ]
> @@ -771,13 +862,13 @@ int mv88e6xxx_port_setup_leds(struct mv88e6xxx_chip *chip, int port)
> }
>
> fwnode_for_each_child_node(leds, led) {
> - /* Reg represent the led number of the port, max 2
> + /* Reg represent the led number of the port, max 4
> * LEDs can be connected to each port, in some designs
> * only one LED is connected.
> */
> if (fwnode_property_read_u32(led, "reg", &led_num))
> continue;
> - if (led_num > 1) {
> + if (led_num >= mv88e6xxx_num_leds(chip)) {
[Severity: Low]
This isn't a bug, but the commit message only says "Enable LED control
on the Marvell 88E6171". The patch also adds the num_leds and
led_hw_triggers fields, edits the 6172/6176/6240/6352 table entries, and
replaces the fixed led_num > 1 check with this table-driven bound.
Should the commit message mention these changes?
Also, a future chip could set .port_setup_leds and leave .num_leds at its
default of 0. Every DT LED would then be rejected with -EINVAL, and
mv88e6xxx_setup_port() would pass that up:
err = chip->info->ops->port_setup_leds(chip, port);
if (err && err != -EOPNOTSUPP)
return err;
All current users of mv88e6xxx_port_setup_leds() set num_leds, so
nothing changes today.
[ ... ]
> @@ -805,17 +900,27 @@ int mv88e6xxx_port_setup_leds(struct mv88e6xxx_chip *chip, int port)
> if (led_num == 0) {
> l->brightness_set_blocking = mv88e6xxx_led0_brightness_set_blocking;
> l->blink_set = mv88e6xxx_led0_blink_set;
> - l->hw_control_is_supported = mv88e6xxx_led0_hw_control_is_supported;
> - l->hw_control_set = mv88e6xxx_led0_hw_control_set;
> - l->hw_control_get = mv88e6xxx_led0_hw_control_get;
> - l->hw_control_get_device = mv88e6xxx_led0_hw_control_get_device;
> - } else {
> + if (mv88e6xxx_has_led_hw_triggers(chip)) {
> + l->hw_control_is_supported = mv88e6xxx_led0_hw_control_is_supported;
> + l->hw_control_set = mv88e6xxx_led0_hw_control_set;
> + l->hw_control_get = mv88e6xxx_led0_hw_control_get;
> + l->hw_control_get_device = mv88e6xxx_led0_hw_control_get_device;
> + }
> + } else if (led_num == 1) {
[ ... ]
> + } else if (led_num == 2) {
> + l->brightness_set_blocking = mv88e6xxx_led2_brightness_set_blocking;
> + l->blink_set = mv88e6xxx_led2_blink_set;
> + } else {
> + l->brightness_set_blocking = mv88e6xxx_led3_brightness_set_blocking;
> + l->blink_set = mv88e6xxx_led3_blink_set;
> }
> l->hw_control_trigger = "netdev";
[Severity: Medium]
The hw_control_* callbacks are now only installed for LED 0 and LED 1 on
chips with led_hw_triggers. hw_control_trigger is still set to "netdev"
for every LED, though.
Two groups of LEDs end up with hw_control_trigger set and all four
hw_control_* callbacks NULL:
- every LED on the 88E6171, which has no .led_hw_triggers in its
mv88e6xxx_table entry
- LED 2 and LED 3 on any chip
The LED core decides whether to expose the offload attribute only from
hw_control_trigger:
drivers/leds/led-triggers.c:led_trigger_is_visible() {
...
if (attr == &dev_attr_trigger_may_offload_to_hw.attr)
return led_cdev->hw_control_trigger ? attr->mode : 0;
...
}
Won't these LEDs show /sys/class/leds/<led>/trigger_may_offload_to_hw and
report "netdev"? The netdev trigger can never offload to them, because
supports_hw_control() fails when the callbacks are NULL.
Documentation/ABI/testing/sysfs-class-led says this file "Only exists
when the LED supports trigger offload".
Could the hw_control_trigger assignment move inside the
mv88e6xxx_has_led_hw_triggers() blocks for LED 0 and LED 1?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115181305.2860498-1-olek2%40wp.pl
prev parent reply other threads:[~2026-11-16 18:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 18:12 Aleksander Jan Bajkowski
2026-11-15 18:54 ` Andrew Lunn
2026-11-16 18:28 ` netdev-bot+sashiko [this message]
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=179485368308.3136.7792285463770201069@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olek2@wp.pl \
--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
all inboxes | Powered by JetHome®