Re: [PATCH net-next v4 3/3] net: phy: dap8211r: add PHY LED control support
From: Artem Shimko
Date: Mon Nov 23 2026 - 11:24:36 EST
On Mon, Nov 23, 2026 at 4:19 PM <netdev-bot+sashiko@xxxxxxxxxx> wrote:
>
> Thank you for your contribution! Sashiko AI review found 2 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 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] In drivers/net/phy/dap8211r.c, dap8211r_led_hw_control_get()
> (lines 312-351) does not undo what dap8211r_led_hw_control_set()…
> - [Low] dap8211r_led_hw_control_set() in drivers/net/phy/dap8211r.c first
> clears FORCE_EN(index) in LED_COMCON (0xA00B) with…
>
> --
>
> net: phy: dap8211r: add PHY LED control support
>
> This adds PHY LED support for the three LEDs on the DAP8211R. It adds a
> dap8211r_write_ext() helper for indirect extended register writes. It also
> implements the led_brightness_set, led_hw_is_supported, led_hw_control_set
> and led_hw_control_get callbacks, using force mode for brightness and the
> LED_x_CON registers for hardware triggers.
>
> > diff --git a/drivers/net/phy/dap8211r.c b/drivers/net/phy/dap8211r.c
> > index 1fe20efd394d7..b0fb3cf89b55a 100644
> > --- a/drivers/net/phy/dap8211r.c
> > +++ b/drivers/net/phy/dap8211r.c
>
> [ ... ]
>
> > +static int dap8211r_led_hw_control_set(struct phy_device *phydev, u8 index, unsigned long rules)
> > +{
> > + u16 led_mode = 0, led_reg;
> > + int ret;
> > +
> > + switch (index) {
> > + case DAP8211R_LED_ID_0 ... DAP8211R_LED_ID_2:
> > + led_reg = DAP8211R_LED_0_CON + index;
> > + break;
> > + default:
> > + return -EINVAL;
> > + }
> > +
> > + ret = dap8211r_modify_ext(phydev, DAP8211R_LED_COMCON, DAP8211R_LED_FORCE_EN(index), 0);
> > + if (ret)
> > + return ret;
>
> [Severity: Low]
>
> Force mode is cleared in LED_COMCON here, but the new rules are only
> written to LED_x_CON later by a separate dap8211r_write_ext() call. Each
> helper takes and drops the MDIO bus lock on its own. In between, won't the
> LED follow whatever LED_x_CON held before (power-on, bootloader, or
> previous trigger rules)?
>
> If the final dap8211r_write_ext() fails, the function returns an error but
> leaves force mode off and the stale rules active. set_baseline_state() in
> drivers/leds/trigger/ledtrig-netdev.c ignores the return value:
>
> led_cdev->hw_control_set(led_cdev, trigger_data->mode);
>
> so the trigger would assume the new mode is in effect.
>
> Would it work to write LED_x_CON first and clear FORCE_EN afterwards? The
> rule register has no visible effect while force mode is on.
Agreed. mxl86110_led_hw_control_set() does exactly this. I'll reorder the calls
in dap8211r_led_hw_control_set() the same way in v5,
> [Severity: Medium]
>
> Does dap8211r_led_hw_control_get() return the same rules that
> dap8211r_led_hw_control_set() writes? I see three mismatches.
>
> First, hw_control_set() turns TRIGGER_NETDEV_LINK into LINK_10 | LINK_100 |
> LINK_1000. This function only reports the three speed bits and never
> reports TRIGGER_NETDEV_LINK.
i'll add it, thanks
> Second, hw_control_set() always sets DAP8211R_LED_ACT_BLINK along with
> TX/RX, but bit 13 is never checked here. The kernel-doc on hw_control_set()
> says the LED does not blink on traffic without ACT_BLINK unless another
> rule is active. A register with TX/RX set, ACT_BLINK clear and no
> link/duplex bit would still be reported as tx/rx offload.
i.e., if ACT_BLINK == 0 but txrx are active (by some reason), then
-EOPNOTSUPP should be
returned, because the register state does not correspond to an
operational state. Oh, that's
important i think. Yes, it should be fixed.
> Third, any other LED_x_CON bits are silently ignored, and 0 is returned
> anyway.
>
ok
> rtl8211f_led_hw_control_get() in the realtek driver reports
> TRIGGER_NETDEV_LINK when all three speed bits are set. Could the same
> approach be used here?
Yes, i think so
--
Best regards,
artem
pw-bot: cr