Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2340660pxk; Mon, 14 Sep 2020 10:39:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy79J61UgEsV42sBqrZiarBczXngY7Fhx9jycagDiA+EWF2JNdoOBWtn6Va8wbJrWyVJv7c X-Received: by 2002:a17:906:ae45:: with SMTP id lf5mr15399436ejb.339.1600105188752; Mon, 14 Sep 2020 10:39:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600105188; cv=none; d=google.com; s=arc-20160816; b=seih8/iNQJFZR6jCZwMlzwOMhHKBWmk7tXvqXlT8b1NYMtkzdRuafMafTEYNsWnPVv h5V0Mo1UL76Z0Wpoz217l0ECvGy6ARyc75MuPFSnXgFFGXa5MlHc6kPq44CyWNZeyzUI HzCPrPgnsHIr5ME1t5G/jasN/aobByTnEEkw/wdXwJrmhZgZ9L9NC/ED5cy3cOYj2Y06 4F/m9up84qx/vLZWGFmPKMYCEBPSsUyXcd5ug3gbbbWkkknjVQtWBj0AuQmfMk3M2poI QMgejRv8Saquawo6Y3Yi/ch3+SDZZPDkKdzRZbj6MEsSszTAhYi6jeGoYPXq47I53xd3 S5OA== 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=0jpdryKSYbbdEXWz0Kp8sZSfTx6UEh1+ODCcZWsRfvQEf16IC179/s9zjQJJBsq5fL tzchHSG480fn2VwsQb+v1YndKk8bzb52iWRKu+oQYz15gii3Jg+5iDDqphvCt241fZjT teyZdC8bidjlmiqvuPMZs3X5UJ97/CUmOkj3ps1gYbV3N99VOH7JjZk9VgUpLnJKj6n3 8C1Lob9aFp80LpSRmlj2f99bsh1v6IV2VE2ZQiX+z5qCSqEABs5kRoRGnBZP7K0BVPB3 Khit5cHGm+f1dohwuNovwnz7llr5LzILtihbZFxUVBornwppiFiRaYeqO2qlIARfjACI Qd8g== 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 l7si7871147eds.471.2020.09.14.10.39.25; Mon, 14 Sep 2020 10:39:48 -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 S1725999AbgINRhI (ORCPT + 99 others); Mon, 14 Sep 2020 13:37:08 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:11840 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726412AbgINM1S (ORCPT ); Mon, 14 Sep 2020 08:27:18 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id E89D4CC0FA7189630C02; Mon, 14 Sep 2020 20:09:33 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Mon, 14 Sep 2020 20:09:23 +0800 From: Huazhong Tan To: CC: , , , , , , Yunsheng Lin , Huazhong Tan Subject: [PATCH net-next 5/6] net: hns3: use writel() to optimize the barrier operation Date: Mon, 14 Sep 2020 20:06:56 +0800 Message-ID: <1600085217-26245-6-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600085217-26245-1-git-send-email-tanhuazhong@huawei.com> References: <1600085217-26245-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