net: phy: adin1100: Fix powerdown mode setting
Subsystems (3)
cover net: phy: adin1100: Fix powerdown mode setting
Hei hei,
while building a new device around the ADIN1100 I noticed some errors in kernel log when calling ifdown on the ethernet device. Series has a straight forward fix and an obvious follow-up code simplification.
Greets
Alex
Alexander Dahl (2):
net: phy: adin1100: Fix software power-down ready condition
net: phy: adin1100: Simplify register value passing
drivers/net/phy/adin1100.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
base-commit: 6a23ae0a96a600d1d12557add110e0bb6e32730c
Signature · 1 line
2.39.5
PATCH 1/2 net: phy: adin1100: Fix software power-down ready condition
Value CRSM_SFT_PD written to Software Power-Down Control Register (CRSM_SFT_PD_CNTRL) is 0x01 and therefor different to value CRSM_SFT_PD_RDY (0x02) read from System Status Register (CRSM_STAT) for confirmation powerdown has been reached.
The condition could have only worked when disabling powerdown (both 0x00), but never when enabling it (0x01 != 0x02).
Result is a timeout, like so:
$ ifdown eth0
macb f802c000.ethernet eth0: Link is Down
ADIN1100 f802c000.ethernet-ffffffff:01: adin_set_powerdown_mode failed: -110
ADIN1100 f802c000.ethernet-ffffffff:01: adin_set_powerdown_mode failed: -110--- drivers/net/phy/adin1100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/adin1100.c +1 -1
@@ -201,7 +201,7 @@ static int adin_set_powerdown_mode(struct phy_device *phydev, bool en)return ret;return phy_read_mmd_poll_timeout (phydev,MDIO_MMD_VEND1 ,ADIN_CRSM_STAT , ret, - (ret &ADIN_CRSM_SFT_PD_RDY ) == val, + !!(ret &ADIN_CRSM_SFT_PD_RDY ) == en,1000 ,30000 , true); }
Signature · 1 line
2.39.5
Re: [PATCH 1/2] net: phy: adin1100: Fix software power-down ready condition
Quoted 10 lines · Alexander Dahl
Value
CRSM_SFT_PDwritten to Software Power-Down Control Register (CRSM_SFT_PD_CNTRL) is0x01and therefor different to valueCRSM_SFT_PD_RDY(0x02) read from System Status Register (CRSM_STAT) for confirmation powerdown has been reached.The condition could have only worked when disabling powerdown (both
0x00), but never when enabling it (0x01!=0x02).Result is a timeout, like so:
Quoted 7 lines
$ ifdown eth0 macb f802c000.ethernet eth0: Link is Down ADIN1100 f802c000.ethernet-ffffffff:01: adin_set_powerdown_mode failed: -110 ADIN1100 f802c000.ethernet-ffffffff:01: adin_set_powerdown_mode failed: -110Fixes 7eaf9132996a ("net: phy: adin1100: Add initial support for ADIN1100 industrial PHY")Signed-off-by Alexander Dahl <[email protected]>
Thanks!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
PATCH 2/2 net: phy: adin1100: Simplify register value passing
In reply to Alexander DahlThe additional use case for that variable is gone, the expression is simple enough to pass it inline now.
--- drivers/net/phy/adin1100.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/phy/adin1100.c +2 -3
@@ -192,11 +192,10 @@ static irqreturn_t adin_phy_handle_interrupt(struct phy_device *phydev)static int adin_set_powerdown_mode (struct phy_device *phydev,bool en) {int ret; -int val; - val = en ?ADIN_CRSM_SFT_PD_CNTRL_EN :0 ; ret =phy_write_mmd (phydev,MDIO_MMD_VEND1 , -ADIN_CRSM_SFT_PD_CNTRL , val); +ADIN_CRSM_SFT_PD_CNTRL , + en ?ADIN_CRSM_SFT_PD_CNTRL_EN :0 );if (ret <0 )return ret;
Signature · 1 line
2.39.5
Russell King (Oracle)
reviewerRe: [PATCH 2/2] net: phy: adin1100: Simplify register value passing
Quoted 2 lines · Alexander Dahl
The additional use case for that variable is gone, the expression is simple enough to pass it inline now.
Looking at net-next, this patch is wrong. You remove "val" but the code after the context in this patch is:
return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, ADIN_CRSM_STAT, ret,
(ret & ADIN_CRSM_SFT_PD_RDY) == val,
1000, 30000, true);which also references "val".
Note that this code is buggy as things stand. "val" will be zero (when en is false) or 1 (when en is true), whereas ADIN_CRSM_SFT_PD_RDY is 2. Thus, if en is true, then the condition can never be true.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH 2/2] net: phy: adin1100: Simplify register value passing
Quoted 11 lines · Russell King (Oracle)
Quoted 2 lines · Alexander Dahl
The additional use case for that variable is gone, the expression is simple enough to pass it inline now.
Looking at net-next, this patch is wrong. You remove "val" but the code after the context in this patch is:
return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, ADIN_CRSM_STAT, ret, (ret & ADIN_CRSM_SFT_PD_RDY) == val, 1000, 30000, true);
Quoted 5 lines
which also references "val".
Note that this code is buggy as things stand. "val" will be zero (when en is false) or 1 (when en is true), whereas
ADIN_CRSM_SFT_PD_RDYis 2. Thus, if en is true, then the condition can never be true.
Sorry, missed the first patch (the two patches arrived in reverse order.) Please ignore this comment.
For the patch:
Thanks!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Quoted 13 lines · Alexander Dahl
Hei hei,
while building a new device around the ADIN1100 I noticed some errors in kernel log when calling
ifdownon the ethernet device. Series has a straight forward fix and an obvious follow-up code simplification.Greets
AlexAlexander Dahl (2):
net: phy: adin1100: Fix software power-down ready condition
net: phy: adin1100: Simplify register value passing
Quoted 5 lines
drivers/net/phy/adin1100.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)base-commit:
6a23ae0a96a600d1d12557add110e0bb6e32730c
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Wed, 19 Nov 2025 13:47:35 +0100 you wrote:
Hei hei,
while building a new device around the ADIN1100 I noticed some errors in kernel log when calling
ifdownon the ethernet device. Series has a straight forward fix and an obvious follow-up code simplification.Greets
Alex[...]
Here is the summary with links:
- [1/2] net: phy: adin1100: Fix software power-down ready condition
https://git.kernel.org/netdev/net-next/c/bccaf1fe08f2 - [2/2] net: phy: adin1100: Simplify register value passing https://git.kernel.org/netdev/net-next/c/5894cab4e1b9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html