Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp220480pxk; Wed, 16 Sep 2020 02:39:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeJGpLgoqUwMrXwaK0Iog0itgzKnAWBUY0bqYoUvsYIzKcb9bhiRWcv6CtQOG7OCve7ugJ X-Received: by 2002:a17:906:5452:: with SMTP id d18mr25266608ejp.163.1600249174160; Wed, 16 Sep 2020 02:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600249174; cv=none; d=google.com; s=arc-20160816; b=nU02OdsZp5TFAfDaVl6p3ihGzxuWOkdnc4eXY451vMdinx5ii4KNuQr6Nr6PJF4W96 pX+Cf9DXyG6VR8KRAQrPc9TkR+wqlXrcjp9kXR81cT+tzv6G6OCfTeCFWuQHycFQRn8D 7iDMKhwBPUakR/Lll960oSmUohYz0i0gLwhfNbMESxYQ0v4sdbVbn3DseWpB8DkMyDIT RMILwoHx0dA8L5nA2jIebIEglZnyZvq3a8XcII0YQysLe4hEjbGL0EbJV0zUvE6/FgWa V5s+whTgPoFVjpRjKnKHCtCU6sZxHeG5RmD5TepR/IKrmF/t2ag3HVYJvUJ0BS/LussP TOiA== 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=Zdj8H2TiOikgrryAt9X24sYV4SqXo3Yj/Aj1l9Ibcxk=; b=eY+1aAEnmo6xPRyaE0XKZsRghJHjD/YrEXTMwJUT9wt8Gjh+q61F3P/ThgaQmYbaEG EQwThwIRcw5nOwlQhOH1vGTFutKg/5x3TZ3NhBB38+p//DjHsIlycfwJOk3vu2Zrtm1L nPtq9QsgrAlP+2LginKWeoXvhhpnmL3Ue46WLxQ1r1SUfC4bWqKGAMvd5d3QItI6UWaz ptgyuqiwWdF+sAj3H3m2q41gKvb0S4gLk4d+ciPdzBBDqljOZ1rAxZlL9eK8qjO1JrCU H0safh7m29aeUbcg+ST7DAyhrgTbUfqNPmFOYpjfBMOtVB7XH8V9MUfmGhnu+KhMuGbO fdxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h11si11861405edt.462.2020.09.16.02.39.12; Wed, 16 Sep 2020 02:39:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726742AbgIPJhk (ORCPT + 99 others); Wed, 16 Sep 2020 05:37:40 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:54002 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726727AbgIPJgy (ORCPT ); Wed, 16 Sep 2020 05:36:54 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 85235E417FF980579737; Wed, 16 Sep 2020 17:36:48 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Wed, 16 Sep 2020 17:36:39 +0800 From: Huazhong Tan To: CC: , , , , , , , Yunsheng Lin , Huazhong Tan Subject: [PATCH V2 net-next 5/6] net: hns3: use writel() to optimize the barrier operation Date: Wed, 16 Sep 2020 17:33:49 +0800 Message-ID: <1600248830-59477-6-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600248830-59477-1-git-send-email-tanhuazhong@huawei.com> References: <1600248830-59477-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] 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 writel() can be used to order I/O vs memory by default when writing portable drivers. Use writel() to replace wmb() + writel_relaxed(), and writel() is dma_wmb() + writel_relaxed() for ARM64, so there is an optimization here because dma_wmb() is a lighter barrier than wmb(). Signed-off-by: Yunsheng Lin Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 8 +++----- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 3 --- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 8490754..4a49a76 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1398,9 +1398,8 @@ static void hns3_tx_doorbell(struct hns3_enet_ring *ring, int num, if (!ring->pending_buf) return; - wmb(); /* Commit all data before submit */ - - hnae3_queue_xmit(ring->tqp, ring->pending_buf); + 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); } @@ -2618,8 +2617,7 @@ static void hns3_nic_alloc_rx_buffers(struct hns3_enet_ring *ring, ring_ptr_move_fw(ring, next_to_use); } - wmb(); /* Make all data has been write before submit */ - writel_relaxed(i, ring->tqp->io_base + HNS3_RING_RX_RING_HEAD_REG); + writel(i, ring->tqp->io_base + HNS3_RING_RX_RING_HEAD_REG); } static bool hns3_page_is_reusable(struct page *page) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 876dc09..20e62ce 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -539,9 +539,6 @@ static inline bool hns3_nic_resetting(struct net_device *netdev) #define hns3_write_dev(a, reg, value) \ hns3_write_reg((a)->io_base, (reg), (value)) -#define hnae3_queue_xmit(tqp, buf_num) writel_relaxed(buf_num, \ - (tqp)->io_base + HNS3_RING_TX_RING_TAIL_REG) - #define ring_to_dev(ring) ((ring)->dev) #define ring_to_netdev(ring) ((ring)->tqp_vector->napi.dev) -- 2.7.4