Article View: linux.kernel.netdev
Article #21005Re: [PATCH net-next v4 3/3] net: phy: dap8211r: add PHY LED control support
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 13:19
Date: Mon, 23 Nov 2026 13:19
188 lines
14549 bytes
14549 bytes
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.
> +
> + if (test_bit(TRIGGER_NETDEV_LINK, &rules))
> + led_mode |= DAP8211R_LED_LINK;
> +
[ ... ]
> + if (test_bit(TRIGGER_NETDEV_RX, &rules))
> + led_mode |= DAP8211R_LED_RX | DAP8211R_LED_ACT_BLINK;
> +
> + if (test_bit(TRIGGER_NETDEV_TX, &rules))
> + led_mode |= DAP8211R_LED_TX | DAP8211R_LED_ACT_BLINK;
> +
[ ... ]
> + return dap8211r_write_ext(phydev, led_reg, led_mode);
> +}
[ ... ]
> +static int dap8211r_led_hw_control_get(struct phy_device *phydev, u8 index, unsigned long *rules)
> +{
[ ... ]
> + led_mode = dap8211r_read_ext(phydev, led_reg);
> + if (led_mode < 0)
> + return led_mode;
> +
> + if (led_mode & DAP8211R_LED_LINK_10)
> + __set_bit(TRIGGER_NETDEV_LINK_10, rules);
> +
> + if (led_mode & DAP8211R_LED_LINK_100)
> + __set_bit(TRIGGER_NETDEV_LINK_100, rules);
> +
> + if (led_mode & DAP8211R_LED_LINK_1000)
> + __set_bit(TRIGGER_NETDEV_LINK_1000, rules);
> +
> + if (led_mode & DAP8211R_LED_RX)
> + __set_bit(TRIGGER_NETDEV_RX, rules);
> +
> + if (led_mode & DAP8211R_LED_TX)
> + __set_bit(TRIGGER_NETDEV_TX, rules);
> +
> + if (led_mode & DAP8211R_LED_HALF_DUPLEX)
> + __set_bit(TRIGGER_NETDEV_HALF_DUPLEX, rules);
> +
> + if (led_mode & DAP8211R_LED_FULL_DUPLEX)
> + __set_bit(TRIGGER_NETDEV_FULL_DUPLEX, rules);
> +
> + return 0;
> +}
[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.
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.
Third, any other LED_x_CON bits are silently ignored, and 0 is returned
anyway.
The led_hw_control_get kernel-doc in include/linux/phy.h says:
Set *@rules to how the HW is currently blinking. Returns 0
on success, or a error code if the current blinking cannot
be represented in rules, or some other error happens.
Should this return an error when the register holds bits that cannot be
expressed as rules?
This matters because the netdev trigger reads the rules and then writes
them back:
netdev_trig_activate()
led_cdev->hw_control_get(led_cdev, &mode)
trigger_data->mode = mode
register_netdevice_notifier()
netdev_trig_notify(NETDEV_REGISTER)
set_baseline_state()
led_cdev->hw_control_set(led_cdev, trigger_data->mode)
hw_control_set() rebuilds led_mode from 0 and writes the whole register
with dap8211r_write_ext(), not a masked modify. Any hardware setting that
hw_control_get() could not express would then be lost just by activating
the trigger, for example via linux,default-trigger = "netdev".
In the ACT_BLINK case, the LED could start blinking on traffic when it did
not before. Whether this happens in practice depends on the power-on or
strap values of LED_x_CON.
In the LINK case, after the trigger is re-activated, sysfs would show
link=0 and link_10=link_100=link_1000=1. Writing link=1 is then rejected
with -EINVAL by this check in netdev_led_attr_store():
if (test_bit(TRIGGER_NETDEV_LINK, &mode) &&
(test_bit(TRIGGER_NETDEV_LINK_10, &mode) ||
test_bit(TRIGGER_NETDEV_LINK_100, &mode) ||
test_bit(TRIGGER_NETDEV_LINK_1000, &mode) ||
until the speed bits are cleared by hand.
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?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122131900.2951586-1-a.shimko.dev%40gmail.com
Technical Details
Message-ID:
<179543998366.3135.8537500779592480863@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369386-linux-kernel-netdev=dewy.ruReferences:
<20261122131900.2951586-4-a.shimko.dev@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369386-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v4 3/3] net: phy: dap8211r: add PHY LED control support Date: Mon, 23 Nov 2026 13:19:43 +0000 Organization: Usenet Network Message-ID: <179543998366.3135.8537500779592480863@kernel.org> References: <20261122131900.2951586-4-a.shimko.dev@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3886583"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Ix4rlqdJRU16+E3Uqew4/i5Y9Qc= sha256:RBoDSqiUUu8p+YMIsziIFjywAIFBj5kxCN+h412ArsQ= sha1:cercVFzWfIHOxVHB7iHbQGrdYNc= sha256:sNt4/4dffm0pYxZQosRxIhWyO/UuFVQX5DCcIzDSIzg= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 73C42125DB3; Mon, 23 Nov 2026 16:20:05 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ANrvsYU6JnZB; Mon, 23 Nov 2026 16:20:01 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-369386-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 14618125DB2; Mon, 23 Nov 2026 16:19:53 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id A480A2A88C; Mon, 23 Nov 2026 13:19:51 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795439991; b=Pc/C1aSExIxRlPiA/sMieGmFSfOyJe5rcDKtcP8sRfYvo7ZgK9KDBjZGaJ1NKKCEzH/F myUqN1TYos5srC8ELb/NFF5m2bqbBSROonDhXf2/ZF1NJVwyToQKqRT5B4Yq3RZ34hddM M0qYyJChjQw38TvoPS582Rzd2hqQI7PPdoU562kJjKRi1Dc3shHol82xO8ucWlgAC54hL dp4ZRk8zuSdys8Q3DNW+AGgVv0snpRmXdNv0U4ohyu7rAZTGM4+vvskVv/n3EA7L9pB7R BDPp8FJohok7+Zrunv+7RD7MNetP6jMV+fPr8BuJq+hz2amEKkOpPpRGdpXN197EfPQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795439991; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=JUjC5bDxeIH6pgJsh82wcERmlUdpDgIUO8ZfYtwi9FE=; b=mKJBnYTlx7Mn9WGmt+ChVVRVWLLETAIui6PstBkbBPi1CUzuE5A3xZP8bBT3kDp0sYqC KPXC8ul4GSkzTWWbBvkeunSKJ2nIB6q1f0cDIGonPd67inJKKCy6lEh5YeNDqnj07FVdS 3X1oeVGQEIKZzE4iyniyg4PrloA1m6BFraZRA0xn67O7yQmb8DWQgvrSJFvBvgZTaPFps ORi2Od4a/j5xqVH++fjyP62vXwPTDeNdc9gO+J7ZiBKi6pWmh1rYdlCoEuFrFS5kf9F9Q fPJdaZDsQUWP7ZchKO6Vqq+QznBZ8a5K+zRp7Ybk0vl2FxOk/P1DXGEPrKSimBjlY1w== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Qm2MIF6J; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 68F9D606A31E; Mon, 23 Nov 2026 13:19:51 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Qm2MIF6J X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795439985; b=R028Ga7Nwf9gfESkdjPUU55JpSn97pn02aYXyvx02VeDSoYgE7Iu+7fxBU+dz19fHcwl UkzzgoWMYeelYWrUSw0MuAHFRZSAY/IcLU6VodVCKQEo4FYpiZDKo/9QWOUpRY4LMBAbJ XryXCjNGnfZ8a+7NcS/GU3j16//YJxpsHlCtcf/MrQLFF8aalbrycUlivY//xT7+K0+m3 TPxkEcv2W+tp2kCoZQxThm6S1DhIFaC8Okr0gGUgykHCdr34CDSLIlxuD0xZLA0XYQf/j 2ndQeC4Sz/9cboXGfGUCP958St0cEOh1Cqe/tn50RG1BtZUSmi41AfNLS0srhYJR1pg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795439985; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=JUjC5bDxeIH6pgJsh82wcERmlUdpDgIUO8ZfYtwi9FE=; b=o7FNHf11FxVqFeCSttp+WmNL5G1dcuNQIAuZ8oJaWvaDTaoezqKatD7XyQ30O3OE8w+W DHvzf5icrU0vLvDlY7PZ5eiyujnGWlhOrYSOGWd43Lxhgk9mQzPRY/pMjWzOVkgaLjaMU w3Cd3nAEJ/XFA7KmoJ2xvXk4+tkWBPP6CzqX3J4kbfc3gEYFmyLoZh7mhaiQSwWG2SPT8 AuzLTWRsJi0dET0RVJsLsk/smDfahUHhiqNggqbj9RJDZWX56tHbwHkE+TPxDrYrHcvIe nqrDUANcTr8cV8+sXixZzgoCzpLQB82/REUUfcTsrhsi9fDJ+Z9S7rAjxzVkAT/1aOw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Qm2MIF6J; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85395606A32C; Mon, 23 Nov 2026 13:19:45 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 149E11F000C6; Mon, 23 Nov 2026 13:19:44 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795439984; bh=JUjC5bDxeIH6pgJsh82wcERmlUdpDgIUO8ZfYtwi9FE=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Qm2MIF6JOtMUGepoWneMNnxa/+CsvGSK7CxWi3IB2OJNDYRB9ECR50NNmA4Nzo3Xd dfhwH+EEXQ2BIgNpn16FDMV8exhnTPa7ZYAduhhy1ww9j0RUvo8P0BsGiyjelnrPYB sY1sVBQkT6H4yYfR4QOgcIASixesMQbePfLXwfewfnp7aLJrlpslB5tpyBp4WICyUC s0dxdFUeUYk5Z7npV6A4ivrqS0qj7CjTnd65NSqTc+o6WJcx+pRvb74jHWN/NYpn1r ZwvRc1h03Uo62W6aoeR6kQYzVzbXR2IcO1Y5bPhJz7I4trUEKCbuipSA8PNSKB7/pW JmBXQSwLIyeEQ== X-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 X-In-Reply-To: <20261122131900.2951586-4-a.shimko.dev@gmail.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list