r8169: fix deadlock on RTL8125 in jumbo mtu mode
Heiner Kallweit
maintainerPATCH 1/1 r8169: fix deadlock on RTL8125 in jumbo mtu mode
The original change results in a deadlock if jumbo mtu mode is used. Reason is that the phydev lock is held when rtl_reset_work() is called here, and rtl_jumbo_config() calls phy_start_aneg() which also tries to acquire the phydev lock. Fix this by calling rtl_reset_work() asynchronously.
--- drivers/net/ethernet/realtek/r8169_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/realtek/r8169_main.c +4 -1
@@ -575,6 +575,7 @@ struct rtl8169_tc_offsets {enum rtl_flag {RTL_FLAG_TASK_ENABLED =0 ,RTL_FLAG_TASK_RESET_PENDING , +RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE ,RTL_FLAG_TASK_TX_TIMEOUT ,RTL_FLAG_MAX };
@@ -4494,6 +4495,8 @@ static void rtl_task(struct work_struct *work) reset:rtl_reset_work (tp);netif_wake_queue (tp->dev); + }else if (test_and_clear_bit (RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE , tp->wk.flags)) { +rtl_reset_work (tp); } out_unlock:rtnl_unlock ();
@@ -4527,7 +4530,7 @@ static void r8169_phylink_handler(struct net_device *ndev) }else {/* In few cases rx is broken after link-down otherwise */ if (rtl_is_8125 (tp)) -rtl_reset_work (tp); +rtl_schedule_task (tp,RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE );pm_runtime_idle (d); }
Signature · 1 line
2.43.0
Heiner Kallweit
maintainerQuoted 37 lines · Heiner Kallweit
The original change results in a deadlock if jumbo mtu mode is used. Reason is that the phydev lock is held when
rtl_reset_work()is called here, andrtl_jumbo_config()callsphy_start_aneg()which also tries to acquire the phydev lock. Fix this by callingrtl_reset_work()asynchronously.Fixes 621735f59064 ("r8169: fix rare issue with broken rx after link-down on RTL8125")Reported-by Ian Chen <[email protected]>Tested-by Ian Chen <[email protected]>Signed-off-by Heiner Kallweit <[email protected]>--- drivers/net/ethernet/realtek/r8169_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/net/ethernet/realtek/r8169_main.c +3
-0@@ -575,6 +575,7 @@ struct rtl8169_tc_offsets {enum rtl_flag {RTL_FLAG_TASK_ENABLED =0 ,RTL_FLAG_TASK_RESET_PENDING , +RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE ,RTL_FLAG_TASK_TX_TIMEOUT ,RTL_FLAG_MAX };@@ -4494,6 +4495,8 @@ static void rtl_task(struct work_struct *work) reset:rtl_reset_work (tp);netif_wake_queue (tp->dev); + }else if (test_and_clear_bit (RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE , tp->wk.flags)) { +rtl_reset_work (tp); } out_unlock:rtnl_unlock ();
drivers/net/ethernet/realtek/r8169_main.c static void r8169_phylink_handler(struct net_device *ndev) · line 4536
Quoted 8 lines
drivers/net/ethernet/realtek/r8169_main.c +1
-1@@ -4527,7 +4530,7 @@ static void r8169_phylink_handler(struct net_device *ndev) }else {/* In few cases rx is broken after link-down otherwise */ if (rtl_is_8125 (tp)) -rtl_reset_work (tp); +rtl_schedule_task (tp,RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE );pm_runtime_idle (d); }
I noticed there's a potential issue with my approach. So I have to rework this, please do not apply.
Heiner Kallweit
maintainerQuoted 41 lines · Heiner Kallweit
Quoted 40 lines · Heiner Kallweit
The original change results in a deadlock if jumbo mtu mode is used. Reason is that the phydev lock is held when
rtl_reset_work()is called here, andrtl_jumbo_config()callsphy_start_aneg()which also tries to acquire the phydev lock. Fix this by callingrtl_reset_work()asynchronously.Fixes 621735f59064 ("r8169: fix rare issue with broken rx after link-down on RTL8125")Reported-by Ian Chen <[email protected]>Tested-by Ian Chen <[email protected]>Signed-off-by Heiner Kallweit <[email protected]>--- drivers/net/ethernet/realtek/r8169_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/net/ethernet/realtek/r8169_main.c +3
-0@@ -575,6 +575,7 @@ struct rtl8169_tc_offsets {enum rtl_flag {RTL_FLAG_TASK_ENABLED =0 ,RTL_FLAG_TASK_RESET_PENDING , +RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE ,RTL_FLAG_TASK_TX_TIMEOUT ,RTL_FLAG_MAX };@@ -4494,6 +4495,8 @@ static void rtl_task(struct work_struct *work) reset:rtl_reset_work (tp);netif_wake_queue (tp->dev); + }else if (test_and_clear_bit (RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE , tp->wk.flags)) { +rtl_reset_work (tp); } out_unlock:rtnl_unlock ();@@ -4527,7 +4530,7 @@ static void r8169_phylink_handler(struct net_device *ndev) }else {/* In few cases rx is broken after link-down otherwise */ if (rtl_is_8125 (tp))
Quoted 9 lines
drivers/net/ethernet/realtek/r8169_main.c static void r8169_phylink_handler(struct net_device *ndev) · line 4536
Quoted 5 lines
drivers/net/ethernet/realtek/r8169_main.c +1
-1-rtl_reset_work (tp); +rtl_schedule_task (tp,RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE );pm_runtime_idle (d); }I noticed there's a potential issue with my approach. So I have to rework this, please do not apply.
The mentioned issue has an impact on patch "r8169: prevent potential deadlock in rtl8169_close" only. The patch here can remain as it is and is ready to be applied. Sorry for the noise.
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 6 lines · On Sun, 26 Nov 2023 19:36:46 +0100 you wrote:
The original change results in a deadlock if jumbo mtu mode is used. Reason is that the phydev lock is held when
rtl_reset_work()is called here, andrtl_jumbo_config()callsphy_start_aneg()which also tries to acquire the phydev lock. Fix this by callingrtl_reset_work()asynchronously.
Quoted 7 lines
Fixes 621735f59064 ("r8169: fix rare issue with broken rx after link-down on RTL8125")Reported-by Ian Chen <[email protected]>Tested-by Ian Chen <[email protected]>Signed-off-by Heiner Kallweit <[email protected]>[...]
Here is the summary with links:
- [net] r8169: fix deadlock on RTL8125 in jumbo mtu mode
https://git.kernel.org/netdev/net/c/59d395ed606d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html