Commit 18c4e5ac authored by Jian Shen's avatar Jian Shen Committed by Yonglong Liu
Browse files

net: hns3: fix tx timeout issue

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7OS1B


CVE: NA

----------------------------

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: 62ef41eb ("net: hns3: optimize the tx clean process")
Signed-off-by: default avatarJian Shen <shenjian15@huawei.com>
parent 447625d2
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -1440,10 +1440,14 @@ static void hns3_tx_doorbell(struct hns3_enet_ring *ring, int num,
	if (!ring->pending_buf)
		return;

	/* This smp_store_release() pairs with smp_load_aquire() in
	 * hns3_nic_reclaim_desc(). Ensure that the BD valid bit is updated.
	 */
	smp_store_release(&ring->last_to_use, ring->next_to_use);

	writel(ring->pending_buf,
	       ring->tqp->io_base + HNS3_RING_TX_RING_TAIL_REG);
	ring->pending_buf = 0;
	WRITE_ONCE(ring->last_to_use, ring->next_to_use);
}

netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
@@ -2629,9 +2633,8 @@ static void hns3_reuse_buffer(struct hns3_enet_ring *ring, int i)
static bool hns3_nic_reclaim_desc(struct hns3_enet_ring *ring,
				  int *bytes, int *pkts, int budget)
{
	/* pair with ring->last_to_use update in hns3_tx_doorbell(),
	 * smp_store_release() is not used in hns3_tx_doorbell() because
	 * the doorbell operation already have the needed barrier operation.
	/* This smp_load_acquire() pairs with smp_store_release() in
	 * hns3_tx_doorbell().
	 */
	int ltu = smp_load_acquire(&ring->last_to_use);
	int ntc = ring->next_to_clean;