提交 d5762f88 编写于 作者: Y Yunsheng Lin 提交者: Xie XiuQi

net: hns3: minor optimization for barrier in IO patch

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

Currently the tx and rx ring in a queue is bounded to the
same irq, there may be unnecessary barrier op when only one of
the ring need to be processed.

This patch adjusts the location of rmb() in hns3_clean_tx_ring()
and adds a checking in hns3_clean_rx_ring() to avoid unnecessary
barrier op when there is nothing to do for the ring.
Signed-off-by: NYunsheng Lin <linyunsheng@huawei.com>
Reviewed-by: Nlipeng <lipeng321@huawei.com>
Reviewed-by: NWeiwei Deng <dengweiwei@huawei.com>
Reviewed-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 5f64f90e
...@@ -2471,11 +2471,12 @@ void hns3_clean_tx_ring(struct hns3_enet_ring *ring) ...@@ -2471,11 +2471,12 @@ void hns3_clean_tx_ring(struct hns3_enet_ring *ring)
int head; int head;
head = readl_relaxed(ring->tqp->io_base + HNS3_RING_TX_RING_HEAD_REG); head = readl_relaxed(ring->tqp->io_base + HNS3_RING_TX_RING_HEAD_REG);
rmb(); /* Make sure head is ready before touch any data */
if (is_ring_empty(ring) || head == ring->next_to_clean) if (is_ring_empty(ring) || head == ring->next_to_clean)
return; /* no data to poll */ return; /* no data to poll */
rmb(); /* Make sure head is ready before touch any data */
if (unlikely(!is_valid_clean_head(ring, head))) { if (unlikely(!is_valid_clean_head(ring, head))) {
netdev_err(netdev, "wrong head (%d, %d-%d)\n", head, netdev_err(netdev, "wrong head (%d, %d-%d)\n", head,
ring->next_to_use, ring->next_to_clean); ring->next_to_use, ring->next_to_clean);
...@@ -3098,11 +3099,14 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget, ...@@ -3098,11 +3099,14 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget,
int err, num; int err, num;
num = readl_relaxed(ring->tqp->io_base + HNS3_RING_RX_RING_FBDNUM_REG); num = readl_relaxed(ring->tqp->io_base + HNS3_RING_RX_RING_FBDNUM_REG);
rmb(); /* Make sure num taken effect before the other data is touched */
num -= unused_count; num -= unused_count;
unused_count -= ring->pending_buf; unused_count -= ring->pending_buf;
if (num <= 0)
goto out;
rmb(); /* Make sure num taken effect before the other data is touched */
while (recv_pkts < budget && recv_bds < num) { while (recv_pkts < budget && recv_bds < num) {
/* Reuse or realloc buffers */ /* Reuse or realloc buffers */
if (unused_count >= RCB_NOF_ALLOC_RX_BUFF_ONCE) { if (unused_count >= RCB_NOF_ALLOC_RX_BUFF_ONCE) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册