Skip to content

Commit 61a1dea

Browse files
IronShenPaolo Abeni
authored andcommitted
net: hns3: fix tx timeout issue
Currently, the driver knocks the ring doorbell before updating the ring->last_to_use in tx flow. if the hardware transmiting packet and napi poll scheduling are fast enough, it may get the old ring->last_to_use in drivers' napi poll. In this case, the driver will think the tx is not completed, and return directly without clear the flag __QUEUE_STATE_STACK_XOFF, which may cause tx timeout. Fixes: 20d06ca ("net: hns3: optimize the tx clean process") Signed-off-by: Jian Shen <shenjian15@huawei.com> Signed-off-by: Jijie Shao <shaojijie@huawei.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 08c6d8b commit 61a1dea

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,8 +2103,12 @@ static void hns3_tx_doorbell(struct hns3_enet_ring *ring, int num,
21032103
*/
21042104
if (test_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state) && num &&
21052105
!ring->pending_buf && num <= HNS3_MAX_PUSH_BD_NUM && doorbell) {
2106+
/* This smp_store_release() pairs with smp_load_aquire() in
2107+
* hns3_nic_reclaim_desc(). Ensure that the BD valid bit
2108+
* is updated.
2109+
*/
2110+
smp_store_release(&ring->last_to_use, ring->next_to_use);
21062111
hns3_tx_push_bd(ring, num);
2107-
WRITE_ONCE(ring->last_to_use, ring->next_to_use);
21082112
return;
21092113
}
21102114

@@ -2115,14 +2119,18 @@ static void hns3_tx_doorbell(struct hns3_enet_ring *ring, int num,
21152119
return;
21162120
}
21172121

2122+
/* This smp_store_release() pairs with smp_load_aquire() in
2123+
* hns3_nic_reclaim_desc(). Ensure that the BD valid bit is updated.
2124+
*/
2125+
smp_store_release(&ring->last_to_use, ring->next_to_use);
2126+
21182127
if (ring->tqp->mem_base)
21192128
hns3_tx_mem_doorbell(ring);
21202129
else
21212130
writel(ring->pending_buf,
21222131
ring->tqp->io_base + HNS3_RING_TX_RING_TAIL_REG);
21232132

21242133
ring->pending_buf = 0;
2125-
WRITE_ONCE(ring->last_to_use, ring->next_to_use);
21262134
}
21272135

21282136
static void hns3_tsyn(struct net_device *netdev, struct sk_buff *skb,
@@ -3563,9 +3571,8 @@ static void hns3_reuse_buffer(struct hns3_enet_ring *ring, int i)
35633571
static bool hns3_nic_reclaim_desc(struct hns3_enet_ring *ring,
35643572
int *bytes, int *pkts, int budget)
35653573
{
3566-
/* pair with ring->last_to_use update in hns3_tx_doorbell(),
3567-
* smp_store_release() is not used in hns3_tx_doorbell() because
3568-
* the doorbell operation already have the needed barrier operation.
3574+
/* This smp_load_acquire() pairs with smp_store_release() in
3575+
* hns3_tx_doorbell().
35693576
*/
35703577
int ltu = smp_load_acquire(&ring->last_to_use);
35713578
int ntc = ring->next_to_clean;

0 commit comments

Comments
 (0)