linux/drivers/net/phy/mediatek
Ahmed Naseef bde5212360 net: phy: mediatek: do not report link and per-speed LED rules together
mtk_phy_led_hw_ctrl_get() reports TRIGGER_NETDEV_LINK whenever any of the
speed bits in on_set is on, and in addition reports every individual
TRIGGER_NETDEV_LINK_* bit that is set. The netdev trigger refuses that
combination: netdev_led_attr_store() rejects TRIGGER_NETDEV_LINK together
with any per-speed rule, and it validates the whole resulting mode rather
than just the bit being written. Once the hardware has any link bit
programmed, every write to the trigger attributes of that LED therefore
fails with -EINVAL and the LED can no longer be configured.

The rules are also fed back into the hardware: the trigger stores what is
read back, and a later write of device_name programs it again, expanding
TRIGGER_NETDEV_LINK to every speed in on_set. An LED configured for a
single speed is thereby silently widened to "on at any link speed".

Both are easy to see on the EcoNet EN7528, whose four PHYs share one LED
block. The first LED programs the block correctly, the second reads those
rules back and rewrites them widened, and the remaining two then read the
widened value, so an LED configured for "link_10 link_100" ends up lit on a
1000 Mbps link.

on_set holds every speed the LED can indicate and is exactly what
mtk_phy_led_hw_ctrl_set() programs for TRIGGER_NETDEV_LINK, so report the
speed independent rule only when all of them are on, and the individual
speeds otherwise. The mapping is then the inverse of the one used when
programming the LED and round trips without changing the register.

Fixes: c66937b0f8 ("net: phy: mediatek-ge-soc: support PHY LEDs")
Cc: stable@vger.kernel.org
Signed-off-by: Ahmed Naseef <naseefkm@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20260912134306.3544329-1-naseefkm@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-14 19:01:51 -07:00
..
Kconfig net: phy: mediatek: add phy driver for MT7628 built-in Fast Ethernet PHYs 2026-08-18 15:50:13 +02:00
Makefile net: phy: mediatek: add phy driver for MT7628 built-in Fast Ethernet PHYs 2026-08-18 15:50:13 +02:00
mtk-2p5ge.c net: phy: mtk-2p5ge: Add LED support for MT7988 2025-08-28 16:43:21 -07:00
mtk-fe-soc.c net: phy: mediatek: add phy driver for MT7628 built-in Fast Ethernet PHYs 2026-08-18 15:50:13 +02:00
mtk-ge-soc.c net: phy: mediatek: add EcoNet EN7528 PHY support 2026-08-07 16:30:28 -07:00
mtk-ge.c net: phy: mediatek-ge: disable EEE on the MT7530 PHY 2026-09-10 14:48:21 +02:00
mtk-phy-lib.c net: phy: mediatek: do not report link and per-speed LED rules together 2026-09-14 19:01:51 -07:00
mtk.h net: phy: mediatek: fix TX blink masks using the RX bits 2026-08-06 14:53:16 +02:00