From: netdev-bot+sashiko@kernel.org
To: a.shimko.dev@gmail.com
Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, maxime.chevallier@bootlin.com, pavel@ucw.cz,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-leds@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net-next v9 2/2] net: phy: dap8211r: add PHY LED control support
Date: Sat, 05 Dec 2026 08:46:44 +0000 [thread overview]
Message-ID: <179646040477.3146.15286579704926683101@kernel.org> (raw)
In-Reply-To: <20261204081448.3199171-3-a.shimko.dev@gmail.com>
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?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204081448.3199171-1-a.shimko.dev%40gmail.com
next prev parent reply other threads:[~2026-12-05 8:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 8:14 [PATCH net-next v9 0/2] net: phy: dap8211r: add LED control support Artem Shimko
2026-12-04 8:14 ` [PATCH net-next v9 1/2] net: phy: dap8211r: fix kernel-doc comments for extended register helpers Artem Shimko
2026-12-04 8:14 ` [PATCH net-next v9 2/2] net: phy: dap8211r: add PHY LED control support Artem Shimko
2026-12-05 8:15 ` sashiko-bot
2026-12-05 8:42 ` Artem Shimko
2026-12-05 8:46 ` netdev-bot+sashiko [this message]
2026-12-05 8:56 ` Artem Shimko
2026-12-05 8:15 ` [PATCH net-next v9 0/2] net: phy: dap8211r: add " sashiko-bot
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=179646040477.3146.15286579704926683101@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=a.shimko.dev@gmail.com \
--cc=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavel@ucw.cz \
--cc=robh@kernel.org \
/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