On Sat, Dec 5, 2026 at 11:46 AM <netd…@kernel.org> wrote:
>
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>
> 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] dap8211r_led_hw_control_get() (drivers/net/phy/dap8211r.c:343)
> can return a set of hardware-control rules that the hardware is not…
>
> --
>
> net: phy: dap8211r: add PHY LED control support
>
> This adds LED support for the three LEDs on the DAP8211R PHY. It adds a
> dap8211r_write_ext() helper and the led_brightness_set, led_hw_is_supported,
> led_hw_control_set and led_hw_control_get callbacks. Brightness is driven
> through the force mode bits in LED_COMCON, and hardware control is driven
> through the per-LED LED_x_CON rule registers.
>
> > diff --git a/drivers/net/phy/dap8211r.c b/drivers/net/phy/dap8211r.c
> > index 1fe20efd394d7..c6d18312c8c34 100644
> > --- a/drivers/net/phy/dap8211r.c
> > +++ b/drivers/net/phy/dap8211r.c
>
> [ ... ]
>
> > @@ -114,6 +190,196 @@ static int dap8211r_modify_ext(struct phy_device *phydev, u16 reg, u16 mask, u16
> > return ret;
> > }
> >
>
> [ ... ]
>
> > +static int dap8211r_led_hw_control_get(struct phy_device *phydev, u8 index, unsigned long *rules)
> > +{
> > + u16 led_reg;
> > + int led_mode = 0;
> > +
> > + switch (index) {
> > + case DAP8211R_LED_ID_0 ... DAP8211R_LED_ID_2:
> > + led_reg = DAP8211R_LED_0_CON + index;
> > + break;
> > + default:
> > + return -EINVAL;
> > + }
> > +
> > + led_mode = dap8211r_read_ext(phydev, led_reg);
> > + if (led_mode < 0)
> > + return led_mode;
>
> [Severity: Medium]
> Can this return rules that the hardware is not actually following?
>
> This function only reads LED_x_CON. It never checks FORCE_EN(index) in
> DAP8211R_LED_COMCON. So when the LED is in force mode, it still returns 0
> along with whatever LED_x_CON happens to hold.
>
> The led_hw_control_get description in include/linux/phy.h says the callback
> should "Set …@rules to how the HW is currently blinking" and return an error
> "if the current blinking cannot be represented in rules". The kernel-doc
> above this function also promises -EOPNOTSUPP for that case.
>
> netdev_trig_activate() trusts a 0 return:
>
> drivers/leds/trigger/ledtrig-netdev.c:netdev_trig_activate() {
> ...
> trigger_data->hw_control = true;
> set_device_name(trigger_data, name, strlen(name));
>
> rc = led_cdev->hw_control_get(led_cdev, &mode);
> if (!rc)
> trigger_data->mode = mode;
> ...
> }
>
> On this path, set_device_name() skips set_baseline_state(). That means
> hw_control_set() is never called and FORCE_EN is never cleared.
>
> This sequence looks like it would hit the problem:
>
> echo none > trigger
> echo 1 > brightness
> dap8211r_led_brightness_set()
> LED_x_CON = 0, FORCE_EN | FORCE_ON set
> echo netdev > trigger (PHY attached)
> netdev_trig_activate()
> hw_control_get() reads LED_x_CON = 0, returns 0 with mode = 0
>
> After that, the trigger reports hardware control with no rules, but the LED
> stays forced on. This lasts until a later mode, device_name or netdev event
> calls hw_control_set().
>
> The same thing would happen if firmware or a bootloader leaves FORCE_EN set
> with non-zero LED_x_CON rules. Those rules would be reported as active while
> the LED is forced.
>
> Would it make sense to also read DAP8211R_LED_COMCON here and return
> -EOPNOTSUPP when FORCE_EN(index) is set?
>
> A related question is what happens when only half of a two-register update
> succeeds. In dap8211r_led_hw_control_set():
>
> ret = dap8211r_write_ext(phydev, led_reg, led_mode);
> if (ret)
> return ret;
>
> return dap8211r_modify_ext(phydev, DAP8211R_LED_COMCON,
> DAP8211R_LED_FORCE_EN(index), 0);
>
> If the COMCON modify fails, the LED stays forced, but hw_control_get()
> reports the new rules. set_baseline_state() also ignores the return value
> of hw_control_set().
>
> In dap8211r_led_brightness_set(), LED_x_CON is zeroed before the COMCON
> modify. If that modify fails, the LED has lost its rules and is not in
> force mode either.
>
> Should either of these restore the first register when the second access
> fails?
ok
Checking DAP8211R_LED_FORCE_EN(index) in dap8211r_led_hw_control_get()
and retrning -EOPNOTSUPP when force mode is active makes complete
sense. I will add this check in v10.
Regarding rolling back the first MDIO write if the second access
fails: an MDIO error indicates a bus failure.
pw-bot: cr