Skip to content

Commit 968fde8

Browse files
Jie Wangdavem330
authored andcommitted
net: hns3: add cond_resched() to hns3 ring buffer init process
Currently hns3 ring buffer init process would hold cpu too long with big Tx/Rx ring depth. This could cause soft lockup. So this patch adds cond_resched() to the process. Then cpu can break to run other tasks instead of busy looping. Fixes: a723fb8 ("net: hns3: refine for set ring parameters") Signed-off-by: Jie Wang <[email protected]> Signed-off-by: Jijie Shao <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 12cda92 commit 968fde8

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3535,6 +3535,9 @@ static int hns3_alloc_ring_buffers(struct hns3_enet_ring *ring)
35353535
ret = hns3_alloc_and_attach_buffer(ring, i);
35363536
if (ret)
35373537
goto out_buffer_fail;
3538+
3539+
if (!(i % HNS3_RESCHED_BD_NUM))
3540+
cond_resched();
35383541
}
35393542

35403543
return 0;
@@ -5107,6 +5110,7 @@ int hns3_init_all_ring(struct hns3_nic_priv *priv)
51075110
}
51085111

51095112
u64_stats_init(&priv->ring[i].syncp);
5113+
cond_resched();
51105114
}
51115115

51125116
return 0;

drivers/net/ethernet/hisilicon/hns3/hns3_enet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ enum hns3_nic_state {
214214
#define HNS3_CQ_MODE_EQE 1U
215215
#define HNS3_CQ_MODE_CQE 0U
216216

217+
#define HNS3_RESCHED_BD_NUM 1024
218+
217219
enum hns3_pkt_l2t_type {
218220
HNS3_L2_TYPE_UNICAST,
219221
HNS3_L2_TYPE_MULTICAST,

0 commit comments

Comments
 (0)