Skip to content

generic: pse-pd: replace notifier PSE patch to fix rtnl deadlock - #24945

Merged
openwrt-bot merged 1 commit into
openwrt:mainfrom
carlosz1986:pse-notifier-rtnl-deadlock-fix
Sep 6, 2026
Merged

openwrt-bot merged 1 commit into
openwrt:mainfrom
carlosz1986:pse-notifier-rtnl-deadlock-fix

Conversation

@carlosz1986

Copy link
Copy Markdown
Contributor

896-03-net-phy-own-phydev-psec-via-PSE-notifier-and-remove-.patch, added in 96ecf8d ("generic: pse-pd: add patches for module-based PSE drivers"), attaches phydev->psec under rtnl_lock() inside phy_device_register().

Drivers that register their MDIO bus from ndo_init() already hold rtnl at that point, so the attach takes rtnl a second time and the board deadlocks during boot. The lantiq etop driver does exactly this (ltq_etop_init() -> ltq_etop_mdio_init() -> mdiobus_register()), which is why it hangs there and not on the targets the patch was developed on.

Reported by @abajk in #24650 on an AVM FRITZ!Box 7320 (xway); bisected to 96ecf8d, and dropping 896-03 made the board boot.

This replaces 896-03 with v5 of the upstream series, which uses a dedicated mutex instead of rtnl for the psec attach, the notifier walks and the ethtool PSE paths. No rtnl recursion, so the deadlock is gone. The ethtool paths take the same lock, so the use-after-free that rtnl was also guarding against does not come back. The approach was discussed with kernel maintainers but has not been fully approved.

Upstream report: https://lore.kernel.org/netdev/[email protected]/
Upstream v5: https://lore.kernel.org/all/[email protected]/

Tested by @abajk on lantiq arx100.

@jonasjelonek should we wait for further feedback from the maintainers or do we merge this already to unblock @abajk ...?

@openwrt openwrt Bot added the kernel pull request/issue with Linux kernel related changes label Aug 29, 2026
@carlosz1986
carlosz1986 force-pushed the pse-notifier-rtnl-deadlock-fix branch from 1ed0e7b to d24f906 Compare August 29, 2026 11:42
@abajk abajk mentioned this pull request Aug 29, 2026
1 task done

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 new commit.


Generated by Claude Code

@carlosz1986
carlosz1986 marked this pull request as draft August 30, 2026 15:01
@openwrt openwrt Bot added the target/airoha pull request/issue for airoha target label Aug 30, 2026
@carlosz1986

Copy link
Copy Markdown
Contributor Author

@abajk - I changed it again to support the module builds... My first version was buggy. If you mind testing again - I would highly appreciate it :)

@carlosz1986
carlosz1986 requested a review from openwrt-ai August 30, 2026 15:06

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 new commit.


Generated by Claude Code

@carlosz1986
carlosz1986 force-pushed the pse-notifier-rtnl-deadlock-fix branch from 4165769 to ae19f98 Compare August 30, 2026 16:25
@carlosz1986
carlosz1986 requested a review from openwrt-ai August 30, 2026 16:29

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 new commit.


Generated by Claude Code

@jonasjelonek

Copy link
Copy Markdown
Member

Please fix these small issues raised by the AI. If it fixes the issue for lantiq, I think we can merge it as pending. Then you can take the review here upstream and once it's merged there, the pending patches can be replaced.

@carlosz1986

Copy link
Copy Markdown
Contributor Author

Thx for getting back to me! I am still waiting for @abajk next tests, because the latest version has too many changes...
After I will follow your steps :-)

@abajk

abajk commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Thx for getting back to me! I am still waiting for @abajk next tests, because the latest version has too many changes...
After I will follow your steps :-)

Will do a test. However, I can only verify that there is no deadlock during system boot. Unfortunately, I shorted some PHY pins, and the PHY on my board isn't fully functional. So there won't be a traffic test at this moment.

@abajk

abajk commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Thx for getting back to me! I am still waiting for @abajk next tests, because the latest version has too many changes...
After I will follow your steps :-)

v5 works fine :)

@carlosz1986

Copy link
Copy Markdown
Contributor Author

Thx for getting back to me! I am still waiting for @abajk next tests, because the latest version has too many changes...
After I will follow your steps :-)

v5 works fine :)

thx for your help!

@abajk

abajk commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

I forgot to mention that you should rebase these changes and resolve conflicts

@carlosz1986
carlosz1986 force-pushed the pse-notifier-rtnl-deadlock-fix branch from ae19f98 to 19a5218 Compare September 6, 2026 14:21
@carlosz1986 carlosz1986 changed the title generic: pse-pd: replace notifier PSE patch with v5 to fix rtnl deadlock generic: pse-pd: replace notifier PSE patch to fix rtnl deadlock Sep 6, 2026
@carlosz1986
carlosz1986 force-pushed the pse-notifier-rtnl-deadlock-fix branch from 19a5218 to ccae34b Compare September 6, 2026 14:26
@carlosz1986
carlosz1986 marked this pull request as ready for review September 6, 2026 14:26
@carlosz1986

Copy link
Copy Markdown
Contributor Author

ping @jonasjelonek :)

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 new commit.


Generated by Claude Code

…eadlock

The notifier patch attached phydev->psec under rtnl_lock() inside
phy_device_register(). Drivers that register their MDIO bus from
ndo_init() (like the lantiq etop) already hold rtnl at that point, so the
attach tried to take rtnl a second time and deadlocked on probe.
Aleksander hit this on lantiq arx100.

Rework 896-03 to use a dedicated mutex instead of rtnl for the psec
attach, the notifier walks and the ethtool PSE paths, so there is no rtnl
recursion any more.

The mutex lives in pse_core.c rather than in phylib: net/ethtool is always
built into vmlinux while PHYLIB is tristate, so net/ethtool/pse-pd.c must
not call a phylib export or CONFIG_PHYLIB=m fails to link. PSE_CONTROLLER
is bool, so pse_core is either in vmlinux or absent and every config can
reach pse_phy_lock()/pse_phy_unlock(); !PSE_CONTROLLER gets no-op stubs in
pse.h.

phy_device_register_locked() is gone with it. It only existed because the
attach took rtnl, and was identical to phy_device_register() apart from an
ASSERT_RTNL(), so sfp.c calls phy_device_register() again and
include/linux/phy.h stays untouched.

Also refresh 897-01 and 897-02, whose hunks shift.

Tested-by: Aleksander Jan Bajkowski <[email protected]>
Signed-off-by: Carlo Szelinsky <[email protected]>
Link: openwrt#24945
Signed-off-by: Jonas Jelonek <[email protected]>
@jonasjelonek
jonasjelonek force-pushed the pse-notifier-rtnl-deadlock-fix branch from ccae34b to e87bdaf Compare September 6, 2026 16:03
@openwrt-bot
openwrt-bot merged commit e87bdaf into openwrt:main Sep 6, 2026
5 checks passed
@jonasjelonek

Copy link
Copy Markdown
Member

Thanks! Rebased on top of main and merged!

cuechan pushed a commit to cuechan/openwrt that referenced this pull request Sep 19, 2026
…eadlock

The notifier patch attached phydev->psec under rtnl_lock() inside
phy_device_register(). Drivers that register their MDIO bus from
ndo_init() (like the lantiq etop) already hold rtnl at that point, so the
attach tried to take rtnl a second time and deadlocked on probe.
Aleksander hit this on lantiq arx100.

Rework 896-03 to use a dedicated mutex instead of rtnl for the psec
attach, the notifier walks and the ethtool PSE paths, so there is no rtnl
recursion any more.

The mutex lives in pse_core.c rather than in phylib: net/ethtool is always
built into vmlinux while PHYLIB is tristate, so net/ethtool/pse-pd.c must
not call a phylib export or CONFIG_PHYLIB=m fails to link. PSE_CONTROLLER
is bool, so pse_core is either in vmlinux or absent and every config can
reach pse_phy_lock()/pse_phy_unlock(); !PSE_CONTROLLER gets no-op stubs in
pse.h.

phy_device_register_locked() is gone with it. It only existed because the
attach took rtnl, and was identical to phy_device_register() apart from an
ASSERT_RTNL(), so sfp.c calls phy_device_register() again and
include/linux/phy.h stays untouched.

Also refresh 897-01 and 897-02, whose hunks shift.

Tested-by: Aleksander Jan Bajkowski <[email protected]>
Signed-off-by: Carlo Szelinsky <[email protected]>
Link: openwrt#24945
Signed-off-by: Jonas Jelonek <[email protected]>
xize pushed a commit to xize/openwrt-xsdk that referenced this pull request Sep 20, 2026
…eadlock

The notifier patch attached phydev->psec under rtnl_lock() inside
phy_device_register(). Drivers that register their MDIO bus from
ndo_init() (like the lantiq etop) already hold rtnl at that point, so the
attach tried to take rtnl a second time and deadlocked on probe.
Aleksander hit this on lantiq arx100.

Rework 896-03 to use a dedicated mutex instead of rtnl for the psec
attach, the notifier walks and the ethtool PSE paths, so there is no rtnl
recursion any more.

The mutex lives in pse_core.c rather than in phylib: net/ethtool is always
built into vmlinux while PHYLIB is tristate, so net/ethtool/pse-pd.c must
not call a phylib export or CONFIG_PHYLIB=m fails to link. PSE_CONTROLLER
is bool, so pse_core is either in vmlinux or absent and every config can
reach pse_phy_lock()/pse_phy_unlock(); !PSE_CONTROLLER gets no-op stubs in
pse.h.

phy_device_register_locked() is gone with it. It only existed because the
attach took rtnl, and was identical to phy_device_register() apart from an
ASSERT_RTNL(), so sfp.c calls phy_device_register() again and
include/linux/phy.h stays untouched.

Also refresh 897-01 and 897-02, whose hunks shift.

Tested-by: Aleksander Jan Bajkowski <[email protected]>
Signed-off-by: Carlo Szelinsky <[email protected]>
Link: openwrt#24945
Signed-off-by: Jonas Jelonek <[email protected]>
Quarx2k pushed a commit to Quarx2k/OpenWRT-BE7000 that referenced this pull request Sep 22, 2026
…eadlock

The notifier patch attached phydev->psec under rtnl_lock() inside
phy_device_register(). Drivers that register their MDIO bus from
ndo_init() (like the lantiq etop) already hold rtnl at that point, so the
attach tried to take rtnl a second time and deadlocked on probe.
Aleksander hit this on lantiq arx100.

Rework 896-03 to use a dedicated mutex instead of rtnl for the psec
attach, the notifier walks and the ethtool PSE paths, so there is no rtnl
recursion any more.

The mutex lives in pse_core.c rather than in phylib: net/ethtool is always
built into vmlinux while PHYLIB is tristate, so net/ethtool/pse-pd.c must
not call a phylib export or CONFIG_PHYLIB=m fails to link. PSE_CONTROLLER
is bool, so pse_core is either in vmlinux or absent and every config can
reach pse_phy_lock()/pse_phy_unlock(); !PSE_CONTROLLER gets no-op stubs in
pse.h.

phy_device_register_locked() is gone with it. It only existed because the
attach took rtnl, and was identical to phy_device_register() apart from an
ASSERT_RTNL(), so sfp.c calls phy_device_register() again and
include/linux/phy.h stays untouched.

Also refresh 897-01 and 897-02, whose hunks shift.

Tested-by: Aleksander Jan Bajkowski <[email protected]>
Signed-off-by: Carlo Szelinsky <[email protected]>
Link: openwrt/openwrt#24945
Signed-off-by: Jonas Jelonek <[email protected]>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Oct 10, 2026
…eadlock

The notifier patch attached phydev->psec under rtnl_lock() inside
phy_device_register(). Drivers that register their MDIO bus from
ndo_init() (like the lantiq etop) already hold rtnl at that point, so the
attach tried to take rtnl a second time and deadlocked on probe.
Aleksander hit this on lantiq arx100.

Rework 896-03 to use a dedicated mutex instead of rtnl for the psec
attach, the notifier walks and the ethtool PSE paths, so there is no rtnl
recursion any more.

The mutex lives in pse_core.c rather than in phylib: net/ethtool is always
built into vmlinux while PHYLIB is tristate, so net/ethtool/pse-pd.c must
not call a phylib export or CONFIG_PHYLIB=m fails to link. PSE_CONTROLLER
is bool, so pse_core is either in vmlinux or absent and every config can
reach pse_phy_lock()/pse_phy_unlock(); !PSE_CONTROLLER gets no-op stubs in
pse.h.

phy_device_register_locked() is gone with it. It only existed because the
attach took rtnl, and was identical to phy_device_register() apart from an
ASSERT_RTNL(), so sfp.c calls phy_device_register() again and
include/linux/phy.h stays untouched.

Also refresh 897-01 and 897-02, whose hunks shift.

Tested-by: Aleksander Jan Bajkowski <[email protected]>
Signed-off-by: Carlo Szelinsky <[email protected]>
Link: openwrt#24945
Signed-off-by: Jonas Jelonek <[email protected]>
xize pushed a commit to xize/openwrt-xsdk that referenced this pull request Oct 17, 2026
…eadlock

The notifier patch attached phydev->psec under rtnl_lock() inside
phy_device_register(). Drivers that register their MDIO bus from
ndo_init() (like the lantiq etop) already hold rtnl at that point, so the
attach tried to take rtnl a second time and deadlocked on probe.
Aleksander hit this on lantiq arx100.

Rework 896-03 to use a dedicated mutex instead of rtnl for the psec
attach, the notifier walks and the ethtool PSE paths, so there is no rtnl
recursion any more.

The mutex lives in pse_core.c rather than in phylib: net/ethtool is always
built into vmlinux while PHYLIB is tristate, so net/ethtool/pse-pd.c must
not call a phylib export or CONFIG_PHYLIB=m fails to link. PSE_CONTROLLER
is bool, so pse_core is either in vmlinux or absent and every config can
reach pse_phy_lock()/pse_phy_unlock(); !PSE_CONTROLLER gets no-op stubs in
pse.h.

phy_device_register_locked() is gone with it. It only existed because the
attach took rtnl, and was identical to phy_device_register() apart from an
ASSERT_RTNL(), so sfp.c calls phy_device_register() again and
include/linux/phy.h stays untouched.

Also refresh 897-01 and 897-02, whose hunks shift.

Tested-by: Aleksander Jan Bajkowski <[email protected]>
Signed-off-by: Carlo Szelinsky <[email protected]>
Link: openwrt#24945
Signed-off-by: Jonas Jelonek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel pull request/issue with Linux kernel related changes target/airoha pull request/issue for airoha target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants