Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7184836ybp; Wed, 16 Oct 2019 05:10:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVbcCCJoi/7jjz/lMCwYpPL2409OxPBhL4n2UTfi3hPFMGsJaTKX0k74cr7prwpyB+kX44 X-Received: by 2002:a50:ed90:: with SMTP id h16mr38705217edr.185.1571227824535; Wed, 16 Oct 2019 05:10:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571227824; cv=none; d=google.com; s=arc-20160816; b=L3iT8GOeutdJoQogx60+lYvMBz5f8pOsunD+FkTrWs3v8T52j2nskEHUmfFlq2epHm 0ZgtSYkzh1/d36KJG1sG1aUbGQpZWZ6Y8x8ERtmis5yWQzLKbPYdiv5dNRsF91Y5tiAh Coa8f/wwKhBq9ilPn8l2TQEcKn0yPKfQCBhknS9SJxbI8HD9RK9imdDykGVbUdQ/POpX iHSgYssnLdq0Gff7BpwhR1wDUEWMUy+/DdbmtP6v5/lHAiuHC6gKdEeUIMxEJzi3+FZ2 Uzk3G3OqtNx6ZUe7A91CzpFel18Xk5kPJJu3fH6K/0Is4YmIfsfDrHfA5KT0dFYz2x5S O3Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=wSL1JCRKxS04ssPXfvPp9MZoWDYsXWJWxpkGGYDQ9jo=; b=cmN9mT2S8j/BOBLJdqRaY32zhPFDFiS0u7RyyyprtqbjfhLnTJlIb/erfRxxrzNLsL pOhxbe38SzRrlgwxfBNStObOz3CXcR3frfgu2p8ZVw88v9v/KNHpi+hNS3k5f9OPQcup r8UZVLBVCPL50T4JIXVHbu3BW7UB03nsPne0jdnAkCVxpIUzZKViC3HTj9Xt15aFyC+Y NjP3+HharUj5JPNa/CtT/KWXeBg1bQuykq4Lse3Y8+l0GcJYLfMrBvYDyIY/1oAeVtz6 cKYB9jFYIsNWzVzNT1tNFfG79/5vL6n9Ka+EQG1VGVECtRkkLVkks+lt3Re4n02spZvB z4cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i15si18262956ede.196.2019.10.16.05.10.01; Wed, 16 Oct 2019 05:10:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403992AbfJPHVC (ORCPT + 99 others); Wed, 16 Oct 2019 03:21:02 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4165 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730688AbfJPHUL (ORCPT ); Wed, 16 Oct 2019 03:20:11 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7EBF153484A00E12795A; Wed, 16 Oct 2019 15:20:08 +0800 (CST) Received: from localhost.localdomain (10.67.212.132) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.439.0; Wed, 16 Oct 2019 15:19:59 +0800 From: Huazhong Tan To: CC: , , , , , , Yunsheng Lin , Huazhong Tan Subject: [PATCH net-next 07/12] net: hns3: minor optimization for barrier in IO path Date: Wed, 16 Oct 2019 15:17:06 +0800 Message-ID: <1571210231-29154-8-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571210231-29154-1-git-send-email-tanhuazhong@huawei.com> References: <1571210231-29154-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.212.132] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin 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: Yunsheng Lin Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 5a237f94..a0810b3 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2488,11 +2488,12 @@ void hns3_clean_tx_ring(struct hns3_enet_ring *ring) int head; 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) return; /* no data to poll */ + rmb(); /* Make sure head is ready before touch any data */ + if (unlikely(!is_valid_clean_head(ring, head))) { netdev_err(netdev, "wrong head (%d, %d-%d)\n", head, ring->next_to_use, ring->next_to_clean); @@ -3108,11 +3109,14 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget, int err, num; 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; 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) { /* Reuse or realloc buffers */ if (unused_count >= RCB_NOF_ALLOC_RX_BUFF_ONCE) { -- 2.7.4