Skip to contentSkip to conversation

net: phy: handle the active-high LED polarity mode

PATCH In review Donggeun Yoo 4 participants 10 messages Sep 8 – Sep 10

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v3 cover net: phy: handle the active-high LED polarity mode

Commit a274465cc3be ("net: phy: support 'active-high' property for PHY LEDs") let a device tree LED node request PHY_LED_ACTIVE_HIGH, but a ->led_polarity_set() that only handles PHY_LED_ACTIVE_LOW returns -EINVAL for it. of_phy_leds() propagates that, phy_probe() fails, the mdio device is left unbound, and phy_attach_direct() falls back to the genphy driver, so the PHY loses its driver-specific configuration. Three in-tree drivers still have that gap; each already programs active high as its default, so the fix is one case label per driver.

Unlike commit eb89c79c1b8f ("net: phy: mxl-gpy: correctly describe LED polarity") and commit 9d55e68b19f2 ("net: phy: aquantia: correctly describe LED polarity override"), which restructured their callbacks to fix inverted polarity, these three program active high correctly at reset and only lack the case label, so each fix is a single case label.

The three drivers take different Fixes: tags. dp83867 and qca808x had their LED callbacks before a274465cc3be and should have been updated by it, so they point at that commit. dp83td510 gained its callback later and was born rejecting active high, so it points at its own introducing commit.

Compile tested only; I have no affected hardware. The failure path was traced by inspection through of_phy_led(), of_phy_leds(), phy_probe() and phy_attach_direct().

Changes in v3:
- Cc: stable on all three, and state the observable consequence (fall back to genphy, driver configuration lost) rather than only "phy_probe fails".
- Drop the mxl-gpy/aquantia reference from patch 1; contrast the two at the series level here instead.

Changes in v2:
- Add dp83td510 and qca808x, so the a274465cc3be regression class is
fully closed.
- Link: https://lore.kernel.org/all/[email protected]/

Donggeun Yoo (3):
net: phy: dp83867: handle the active-high LED polarity mode
net: phy: dp83td510: handle the active-high LED polarity mode
net: phy: qca808x: handle the active-high LED polarity mode

 drivers/net/phy/dp83867.c      | 3 +++
 drivers/net/phy/dp83td510.c    | 3 +++
 drivers/net/phy/qcom/qca808x.c | 3 +++
 3 files changed, 9 insertions(+)
Signature · 1 line
2.53.0
#1 lore raw

PATCH v3 1/3 net: phy: dp83867: handle the active-high LED polarity mode

Commit a274465cc3be ("net: phy: support 'active-high' property for PHY LEDs") added PHY_LED_ACTIVE_HIGH and made of_phy_led() set the matching bit in the modes mask when a LED node carries the 'active-high' property. dp83867 was not part of that series.

dp83867_led_polarity_set() only recognizes PHY_LED_ACTIVE_LOW, so PHY_LED_ACTIVE_HIGH falls through to the default case and returns -EINVAL. of_phy_led() propagates the error, of_phy_leds() drops the LEDs registered so far and passes it on, and phy_probe() returns it. A device tree marking a DP83867 LED as 'active-high', which leds/common.yaml allows and ethernet-phy.yaml references for led@N nodes, thus leaves the mdio device unbound, so phy_attach_direct() falls back to the genphy driver: the PHY comes up without its DP83867 configuration and loses the RGMII internal delay setup.

Active high is what the function programs when no polarity mode is requested at all, so the initial value of polarity already satisfies the request and only the case label is missing.

Fixes a274465cc3be ("net: phy: support 'active-high' property for PHY LEDs")
Assisted-by Claude:claude-fable-5
---
 drivers/net/phy/dp83867.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/phy/dp83867.c +3 -0
index 88255e92b4cd..61a941aa02d9 100644
@@ -1150,6 +1150,9 @@ static int dp83867_led_polarity_set(struct phy_device *phydev, int index,
 		case PHY_LED_ACTIVE_LOW:
 			polarity = 0;
 			break;
+		case PHY_LED_ACTIVE_HIGH:
+			polarity = DP83867_LED_POLARITY(index);
+			break;
 		default:
 			return -EINVAL;
 		}
Signature · 1 line
2.53.0
maintainer Reviewed-by on v3 1/3
#2 lore raw

Re: [PATCH net v3 1/3] net: phy: dp83867: handle the active-high LED polarity mode

Quoted 15 lines · Donggeun Yoo

Commit a274465cc3be ("net: phy: support 'active-high' property for PHY LEDs") added PHY_LED_ACTIVE_HIGH and made of_phy_led() set the matching bit in the modes mask when a LED node carries the 'active-high' property. dp83867 was not part of that series.

dp83867_led_polarity_set() only recognizes PHY_LED_ACTIVE_LOW, so PHY_LED_ACTIVE_HIGH falls through to the default case and returns -EINVAL. of_phy_led() propagates the error, of_phy_leds() drops the LEDs registered so far and passes it on, and phy_probe() returns it. A device tree marking a DP83867 LED as 'active-high', which leds/common.yaml allows and ethernet-phy.yaml references for led@N nodes, thus leaves the mdio device unbound, so phy_attach_direct() falls back to the genphy driver: the PHY comes up without its DP83867 configuration and loses the RGMII internal delay setup.

Quoted 8 lines

Active high is what the function programs when no polarity mode is requested at all, so the initial value of polarity already satisfies the request and only the case label is missing.

Fixes a274465cc3be ("net: phy: support 'active-high' property for PHY LEDs")
Assisted-by Claude:claude-fable-5

Andrew

#3 lore raw

PATCH v3 2/3 net: phy: dp83td510: handle the active-high LED polarity mode

In reply to Donggeun Yoo

dp83td510_led_polarity_set() only recognizes PHY_LED_ACTIVE_LOW, so PHY_LED_ACTIVE_HIGH falls through to the default case and returns -EINVAL. of_phy_led() propagates the error, of_phy_leds() drops the LEDs registered so far and passes it on, and phy_probe() returns it. A device tree marking a DP83TD510 LED as 'active-high', which leds/common.yaml allows and ethernet-phy.yaml references for led@N nodes, thus leaves the mdio device unbound, so phy_attach_direct() falls back to the genphy driver, which cannot drive this 10BASE-T1L single-mode PHY, so the interface has no usable link.

The callback initializes polarity to DP83TD510E_LED_POLARITY(index), which is the active-high setting, so the request is already satisfied and only the case label is missing.

Fixes 5b281fe7e396 ("net: phy: dp83td510: introduce LED framework support")
Assisted-by Claude:claude-fable-5
---
 drivers/net/phy/dp83td510.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/phy/dp83td510.c +3 -0
index d75dae6071ad..9e9a41bf6457 100644
@@ -439,6 +439,9 @@ static int dp83td510_led_polarity_set(struct phy_device *phydev, int index,
 		case PHY_LED_ACTIVE_LOW:
 			polarity = 0;
 			break;
+		case PHY_LED_ACTIVE_HIGH:
+			polarity = DP83TD510E_LED_POLARITY(index);
+			break;
 		default:
 			return -EINVAL;
 		}
Signature · 1 line
2.53.0
maintainer Reviewed-by on v3 2/3
#4 lore raw

Re: [PATCH net v3 2/3] net: phy: dp83td510: handle the active-high LED polarity mode

Quoted 10 lines · Donggeun Yoo

dp83td510_led_polarity_set() only recognizes PHY_LED_ACTIVE_LOW, so PHY_LED_ACTIVE_HIGH falls through to the default case and returns -EINVAL. of_phy_led() propagates the error, of_phy_leds() drops the LEDs registered so far and passes it on, and phy_probe() returns it. A device tree marking a DP83TD510 LED as 'active-high', which leds/common.yaml allows and ethernet-phy.yaml references for led@N nodes, thus leaves the mdio device unbound, so phy_attach_direct() falls back to the genphy driver, which cannot drive this 10BASE-T1L single-mode PHY, so the interface has no usable link.

Quoted 8 lines

The callback initializes polarity to DP83TD510E_LED_POLARITY(index), which is the active-high setting, so the request is already satisfied and only the case label is missing.

Fixes 5b281fe7e396 ("net: phy: dp83td510: introduce LED framework support")
Assisted-by Claude:claude-fable-5

Andrew

#5 lore raw

PATCH v3 3/3 net: phy: qca808x: handle the active-high LED polarity mode

In reply to Donggeun Yoo

Commit a274465cc3be ("net: phy: support 'active-high' property for PHY LEDs") added PHY_LED_ACTIVE_HIGH and made of_phy_led() set the matching bit in the modes mask when a LED node carries the 'active-high' property. qca808x was not part of that series.

qca808x_led_polarity_set() only recognizes PHY_LED_ACTIVE_LOW, so PHY_LED_ACTIVE_HIGH falls through to the default case and returns -EINVAL. of_phy_led() propagates the error, of_phy_leds() drops the LEDs registered so far and passes it on, and phy_probe() returns it. A device tree marking a QCA808x LED as 'active-high', which leds/common.yaml allows and ethernet-phy.yaml references for led@N nodes, thus leaves the mdio device unbound, so phy_attach_direct() falls back to the genphy driver and the PHY loses its QCA808x-specific configuration.

active_low is already false when no polarity mode is requested, which programs QCA808X_LED_ACTIVE_HIGH, so the request is already satisfied and only the case label is missing.

Fixes a274465cc3be ("net: phy: support 'active-high' property for PHY LEDs")
Assisted-by Claude:claude-fable-5
---
 drivers/net/phy/qcom/qca808x.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/phy/qcom/qca808x.c +3 -0
index 8eb51b1a006c..3ba58f14e248 100644
@@ -603,6 +603,9 @@ static int qca808x_led_polarity_set(struct phy_device *phydev, int index,
 		case PHY_LED_ACTIVE_LOW:
 			active_low = true;
 			break;
+		case PHY_LED_ACTIVE_HIGH:
+			active_low = false;
+			break;
 		default:
 			return -EINVAL;
 		}
Signature · 1 line
2.53.0
maintainer Reviewed-by on v3 3/3
#6 lore raw

Re: [PATCH net v3 3/3] net: phy: qca808x: handle the active-high LED polarity mode

Quoted 14 lines · Donggeun Yoo

Commit a274465cc3be ("net: phy: support 'active-high' property for PHY LEDs") added PHY_LED_ACTIVE_HIGH and made of_phy_led() set the matching bit in the modes mask when a LED node carries the 'active-high' property. qca808x was not part of that series.

qca808x_led_polarity_set() only recognizes PHY_LED_ACTIVE_LOW, so PHY_LED_ACTIVE_HIGH falls through to the default case and returns -EINVAL. of_phy_led() propagates the error, of_phy_leds() drops the LEDs registered so far and passes it on, and phy_probe() returns it. A device tree marking a QCA808x LED as 'active-high', which leds/common.yaml allows and ethernet-phy.yaml references for led@N nodes, thus leaves the mdio device unbound, so phy_attach_direct() falls back to the genphy driver and the PHY loses its QCA808x-specific configuration.

Quoted 8 lines

active_low is already false when no polarity mode is requested, which programs QCA808X_LED_ACTIVE_HIGH, so the request is already satisfied and only the case label is missing.

Fixes a274465cc3be ("net: phy: support 'active-high' property for PHY LEDs")
Assisted-by Claude:claude-fable-5

Andrew

#7 lore raw

Re: [PATCH net v3 3/3] net: phy: qca808x: handle the active-high LED polarity mode

In reply to Donggeun Yoo
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Critical: 0 · High: 1 · Medium: 0 · Low: 0

- [High] Incomplete fix in drivers/net/phy/qcom/qca808x.c: the new `case
PHY_LED_ACTIVE_HIGH: active_low = false;` in…

--

net: phy: qca808x: handle the active-high LED polarity mode

This adds a PHY_LED_ACTIVE_HIGH case to qca808x_led_polarity_set() so that a device tree LED node carrying the 'active-high' property no longer makes the switch fall into the default case and return -EINVAL, which previously failed phy_probe().

Quoted 5 lines
drivers/net/phy/qcom/qca808x.c +0 -0
index 8eb51b1a006c..3ba58f14e248 100644

drivers/net/phy/qcom/qca808x.c static int qca808x_led_polarity_set(struct phy_device *phydev, int index, · line 611

Quoted 9 lines
drivers/net/phy/qcom/qca808x.c +3 -0
@@ -603,6 +603,9 @@ static int qca808x_led_polarity_set(struct phy_device *phydev, int index,
 		case PHY_LED_ACTIVE_LOW:
 			active_low = true;
 			break;
+		case PHY_LED_ACTIVE_HIGH:
+			active_low = false;
+			break;
 		default:
 			return -EINVAL;
 		}

[Severity: High]
Does this new case leave the LED driven active-low, i.e. the inverse of what the device tree asked for?

Before this change priv->led_polarity_mode could only hold -1 (never requested) or 1 (active-low requested). With the new case an explicit 'active-high' node now stores 0:

drivers/net/phy/qcom/qca808x.c:qca808x_led_polarity_set() {
	...
	/* Save the last PHY polarity mode */
	priv->led_polarity_mode = active_low;

	return phy_modify_mmd(phydev, MDIO_MMD_AN,
			      QCA808X_MMD7_LED_POLARITY_CTRL,
			      QCA808X_LED_ACTIVE_HIGH,
			      active_low ? 0 : QCA808X_LED_ACTIVE_HIGH);
}

The only other place QCA808X_LED_ACTIVE_HIGH gets programmed tests for -1 specifically:

drivers/net/phy/qcom/qca808x.c:qca808x_config_init() {
	/* Default to LED Active High if active-low not in DT */
	if (priv->led_polarity_mode == -1) {
		ret = phy_set_bits_mmd(phydev, MDIO_MMD_AN,
				       QCA808X_MMD7_LED_POLARITY_CTRL,
				       QCA808X_LED_ACTIVE_HIGH);
	...
}

so the newly reachable value 0 skips that write.

phy_init_hw() runs drv->soft_reset (qca808x_soft_reset -> genphy_soft_reset, BMCR_RESET) before drv->config_init, and it is called from phy_attach_direct() and again from mdio_bus_phy_resume(). Since BIT(6) has to be set explicitly for active high:

drivers/net/phy/qcom/qca808x.c:
/* QSDK sets by default 0x46 to this reg that sets BIT 6 for
* LED to active high. It's not clear what BIT 3 and BIT 4 does. */
#define QCA808X_LED_ACTIVE_HIGH BIT(6)

isn't the single probe-time phy_modify_mmd() write discarded by that reset and then never restored, leaving the LED active-low?

That would make a device tree that explicitly states 'active-high' behave worse than one that omits the property entirely, since the omitted case keeps led_polarity_mode == -1 and does get the bit re-asserted from config_init.

There is a second effect of the overloaded value: with priv->led_polarity_mode == 0 the driver's global-polarity bookkeeping records "active high" while the register says active low, so a second LED also requesting active-high passes the mismatch check against state that does not reflect the hardware.

Should qca808x_config_init() also cover the explicit active-high case, for example by re-asserting the bit whenever led_polarity_mode != 1, or by using a distinct sentinel for "not requested" rather than overloading -1 and 0?

Related to this, could the commit message paragraph:

"active_low is already false when no polarity mode is requested, which programs QCA808X_LED_ACTIVE_HIGH, so the request is already satisfied and only the case label is missing."

be revisited? In the no-property case led_polarity_set is not called at all (of_phy_led() only calls it when modes is non-zero), so what programs QCA808X_LED_ACTIVE_HIGH there is the led_polarity_mode == -1 branch of qca808x_config_init(), which the new case label makes unreachable for an explicit active-high request.

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260908105959.70453-1-donggeunyoo.kernel%40gmail.com
#8 lore raw
In reply to Donggeun Yoo
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Tue, 8 Sep 2026 19:59:56 +0900 you wrote:

Commit a274465cc3be ("net: phy: support 'active-high' property for PHY LEDs") let a device tree LED node request PHY_LED_ACTIVE_HIGH, but a ->led_polarity_set() that only handles PHY_LED_ACTIVE_LOW returns -EINVAL for it. of_phy_leds() propagates that, phy_probe() fails, the mdio device is left unbound, and phy_attach_direct() falls back to the genphy driver, so the PHY loses its driver-specific configuration. Three in-tree drivers still have that gap; each already programs active high as its default, so the fix is one case label per driver.

[...]

Here is the summary with links:
- [net,v3,1/3] net: phy: dp83867: handle the active-high LED polarity mode

    https://git.kernel.org/netdev/net/c/36a45facedd5

- [net,v3,2/3] net: phy: dp83td510: handle the active-high LED polarity mode (no matching commit)
- [net,v3,3/3] net: phy: qca808x: handle the active-high LED polarity mode (no matching commit)

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#9 lore raw
In reply to Donggeun Yoo
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Tue, 8 Sep 2026 19:59:56 +0900 you wrote:

Commit a274465cc3be ("net: phy: support 'active-high' property for PHY LEDs") let a device tree LED node request PHY_LED_ACTIVE_HIGH, but a ->led_polarity_set() that only handles PHY_LED_ACTIVE_LOW returns -EINVAL for it. of_phy_leds() propagates that, phy_probe() fails, the mdio device is left unbound, and phy_attach_direct() falls back to the genphy driver, so the PHY loses its driver-specific configuration. Three in-tree drivers still have that gap; each already programs active high as its default, so the fix is one case label per driver.

[...]

Here is the summary with links:
- [net,v3,1/3] net: phy: dp83867: handle the active-high LED polarity mode (no matching commit)
- [net,v3,2/3] net: phy: dp83td510: handle the active-high LED polarity mode

    https://git.kernel.org/netdev/net/c/6ca81bbc31cd

- [net,v3,3/3] net: phy: qca808x: handle the active-high LED polarity mode (no matching commit)

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html