Skip to content

Commit e1d0b52

Browse files
Jijie Shaokuba-moo
authored andcommitted
net: hibmcge: fix multiple phy_stop() issue
After detecting the np_link_fail exception, the driver attempts to fix the exception by using phy_stop() and phy_start() in the scheduled task. However, hbg_fix_np_link_fail() and .ndo_stop() may be concurrently executed. As a result, phy_stop() is executed twice, and the following Calltrace occurs: hibmcge 0000:84:00.2 enp132s0f2: Link is Down hibmcge 0000:84:00.2: failed to link between MAC and PHY, try to fix... ------------[ cut here ]------------ called from state HALTED WARNING: CPU: 71 PID: 23391 at drivers/net/phy/phy.c:1503 phy_stop... ... pc : phy_stop+0x138/0x180 lr : phy_stop+0x138/0x180 sp : ffff8000c76bbd40 x29: ffff8000c76bbd40 x28: 0000000000000000 x27: 0000000000000000 x26: ffff2020047358c0 x25: ffff202004735940 x24: ffff20200000e405 x23: ffff2020060e5178 x22: ffff2020060e4000 x21: ffff2020060e49c0 x20: ffff2020060e5170 x19: ffff20202538e000 x18: 0000000000000020 x17: 0000000000000000 x16: ffffcede02e28f40 x15: ffffffffffffffff x14: 0000000000000000 x13: 205d313933333254 x12: 5b5d393430303233 x11: ffffcede04555958 x10: ffffcede04495918 x9 : ffffcede0274fee0 x8 : 00000000000bffe8 x7 : c0000000ffff7fff x6 : 0000000000000001 x5 : 00000000002bffa8 x4 : 0000000000000000 x3 : 0000000000000000 x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff20202e429480 Call trace: phy_stop+0x138/0x180 hbg_fix_np_link_fail+0x4c/0x90 [hibmcge] hbg_service_task+0xfc/0x148 [hibmcge] process_one_work+0x180/0x398 worker_thread+0x210/0x328 kthread+0xe0/0xf0 ret_from_fork+0x10/0x20 ---[ end trace 0000000000000000 ]--- This patch adds the rtnl_lock to hbg_fix_np_link_fail() to ensure that other operations are not performed concurrently. In addition, np_link_fail exception can be fixed only when the PHY is link. Fixes: e030663 ("net: hibmcge: Add support for mac link exception handling feature") Signed-off-by: Jijie Shao <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ae6c1dc commit e1d0b52

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright (c) 2024 Hisilicon Limited.
33

44
#include <linux/phy.h>
5+
#include <linux/rtnetlink.h>
56
#include "hbg_common.h"
67
#include "hbg_hw.h"
78
#include "hbg_mdio.h"
@@ -133,12 +134,17 @@ void hbg_fix_np_link_fail(struct hbg_priv *priv)
133134
{
134135
struct device *dev = &priv->pdev->dev;
135136

137+
rtnl_lock();
138+
136139
if (priv->stats.np_link_fail_cnt >= HBG_NP_LINK_FAIL_RETRY_TIMES) {
137140
dev_err(dev, "failed to fix the MAC link status\n");
138141
priv->stats.np_link_fail_cnt = 0;
139-
return;
142+
goto unlock;
140143
}
141144

145+
if (!priv->mac.phydev->link)
146+
goto unlock;
147+
142148
priv->stats.np_link_fail_cnt++;
143149
dev_err(dev, "failed to link between MAC and PHY, try to fix...\n");
144150

@@ -147,6 +153,9 @@ void hbg_fix_np_link_fail(struct hbg_priv *priv)
147153
*/
148154
hbg_phy_stop(priv);
149155
hbg_phy_start(priv);
156+
157+
unlock:
158+
rtnl_unlock();
150159
}
151160

152161
static void hbg_phy_adjust_link(struct net_device *netdev)

0 commit comments

Comments
 (0)