* [PATCH net] net: spacemit: Hold RTNL lock in emac_resume() and emac_suspend()
@ 2026-11-05 12:34 Ali Tariq
2026-11-05 13:40 ` Breno Leitao
0 siblings, 1 reply; 2+ messages in thread
From: Ali Tariq @ 2026-11-05 12:34 UTC (permalink / raw)
To: netdev
Cc: Ali Tariq, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Yixun Lan, Troy Mitchell,
Vivian Wang, Chukun Pan, Siddharth Vadapalli, Tomas Hlavacek,
Muhammad Bilal, Vadim Fedorenko, Maxime Chevallier,
open list:RISC-V SPACEMIT SoC Support,
open list:RISC-V SPACEMIT SoC Support, open list
The emac_resume() calls the emac_open() and emac_suspend() calls
emac_stop() functions directly without holding the lock through
rtnl_lock(). These functions rely on phy_disconnect() which reads pointer
with rtnl_dereference(). But since no lock is being held,
rtnl_dereference throws a suspicious RCU usage on
Orange Pi RV2 (SpacemiT K1) warning when lockdep is enabled.
WARNING: suspicious RCU usage
drivers/net/phy/phy_device.c:1831 suspicious rcu_dereference_protected() usage!
Call Trace:
phy_detach_internal+0x490/0x5f2
phy_disconnect+0x90/0xc0
emac_stop+0x114/0x626
emac_suspend+0xac/0x126
platform_pm_suspend+0x72/0xe4
Hold RTNL lock before emac_open() and emac_stop() with rtnl_lock() and
release the lock when functions return with rtnl_unlock().
Fixes: bfec6d7f2001 ("net: spacemit: Add K1 Ethernet MAC")
Signed-off-by: Ali Tariq <alitariq45892@gmail.com>
---
Warning Log: https://kernelci.cloud-v.co/scheduler/job/549#L2168
Fixed Log: https://kernelci.cloud-v.co/scheduler/job/557
---
drivers/net/ethernet/spacemit/k1_emac.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/ethernet/spacemit/k1_emac.c b/drivers/net/ethernet/spacemit/k1_emac.c
index 71a80838bffd..aca25a9e1e9e 100644
--- a/drivers/net/ethernet/spacemit/k1_emac.c
+++ b/drivers/net/ethernet/spacemit/k1_emac.c
@@ -2033,7 +2033,10 @@ static int emac_resume(struct device *dev)
if (!netif_running(ndev))
return 0;
+ rtnl_lock();
ret = emac_open(ndev);
+ rtnl_unlock();
+
if (ret) {
clk_disable_unprepare(priv->bus_clk);
return ret;
@@ -2056,7 +2059,9 @@ static int emac_suspend(struct device *dev)
return 0;
}
+ rtnl_lock();
emac_stop(ndev);
+ rtnl_unlock();
clk_disable_unprepare(priv->bus_clk);
netif_device_detach(ndev);
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: spacemit: Hold RTNL lock in emac_resume() and emac_suspend()
2026-11-05 12:34 [PATCH net] net: spacemit: Hold RTNL lock in emac_resume() and emac_suspend() Ali Tariq
@ 2026-11-05 13:40 ` Breno Leitao
0 siblings, 0 replies; 2+ messages in thread
From: Breno Leitao @ 2026-11-05 13:40 UTC (permalink / raw)
To: Ali Tariq
Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Yixun Lan, Troy Mitchell,
Vivian Wang, Chukun Pan, Siddharth Vadapalli, Tomas Hlavacek,
Muhammad Bilal, Vadim Fedorenko, Maxime Chevallier,
open list:RISC-V SPACEMIT SoC Support,
open list:RISC-V SPACEMIT SoC Support, open list
On Thu, Nov 05, 2026 at 05:34:37PM +0500, Ali Tariq wrote:
> The emac_resume() calls the emac_open() and emac_suspend() calls
> emac_stop() functions directly without holding the lock through
> rtnl_lock(). These functions rely on phy_disconnect() which reads pointer
> with rtnl_dereference(). But since no lock is being held,
> rtnl_dereference throws a suspicious RCU usage on
> Orange Pi RV2 (SpacemiT K1) warning when lockdep is enabled.
>
> WARNING: suspicious RCU usage
> drivers/net/phy/phy_device.c:1831 suspicious rcu_dereference_protected() usage!
> Call Trace:
> phy_detach_internal+0x490/0x5f2
> phy_disconnect+0x90/0xc0
> emac_stop+0x114/0x626
> emac_suspend+0xac/0x126
> platform_pm_suspend+0x72/0xe4
>
> Hold RTNL lock before emac_open() and emac_stop() with rtnl_lock() and
> release the lock when functions return with rtnl_unlock().
This would work, but I am wondering if it would be possible to call rtnl
inside the _open function, when dealing with the PHY? in other words,
shrink the time rtnl is held.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-05 13:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-05 12:34 [PATCH net] net: spacemit: Hold RTNL lock in emac_resume() and emac_suspend() Ali Tariq
2026-11-05 13:40 ` Breno Leitao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®