From patchwork Sun Mar 25 14:39:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10306999 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A0CDF60212 for ; Sun, 25 Mar 2018 23:19:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94C8228DA9 for ; Sun, 25 Mar 2018 23:19:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86F3429038; Sun, 25 Mar 2018 23:19:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1CDD428DA9 for ; Sun, 25 Mar 2018 23:19:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vM6IXQV3UBvdAAxQB3EoLVvPsPT5roel4vkLyI4AEOU=; b=VJA1G2A3CErNEy kw3F5FPG+1lUVkDMijuT1qrUSjj/0wJcgWjWGU+gQdbQ2+yH9LUBwgGLUdUEXUy40/EGTnc42MXr3 WxyugL6YwcY371Z9fHdo8eaQsbnperTjtLLIlLx0WVMn43sN3FFEhTcHVH+Lei1fmbu5qgtbaBvxG Q2jTcSZoBxre5e/QuRyRRSGvvVTLW7Bgmje/pW6vigpuNOj0vkWnbTbWG61CPW9nrRkRp8BvQZ75b gqjg0/giTPyj23Pe6vJ9iPsCkf5C7Y1Hqj8mJkee6AbS00zMkB+tXILnstQLi5G51hWq5nfftToBh yHR7r6mVKxFXP3ttiZUQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0Euk-00072b-J9; Sun, 25 Mar 2018 23:19:02 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0EmV-0006ba-Uu for linux-arm-kernel@bombadil.infradead.org; Sun, 25 Mar 2018 23:10:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=gt8XVkG3SvkQbWMqGAJ0KXGcrC64BNWjHX9zGkHVruM=; b=wqV7YVDrhpvLQljl5GkcovebJc 1jcD9bmvyH/Gap8cbqyu/qsc5+sTgFxnrbSPABvOad9tqn6tySQ+23SMzYGvwHbhqPB6OVsHu2xsa c9LRi9yon6Z/bC/E/KVZtHF4649NMJUugCgrQHkAHiZD71W9t+2wltcdWqlzGJf9+i31yPW9FJvdX gHd4oCQzYJBzTf1GtdxhlXerZOSlluaI2t6t2hmBpGbJuVWLsS4D7e8XufyqI4E4rLmbRHVtOCLC3 spBQw3D6Gd/9/OLWiLAV6t8If9BFlt2s2DzbUUgply96JLXi9TBCmHxAuA7R95jpFAY1SUPiKPlSU McnILOFQ==; Received: from smtp.codeaurora.org ([198.145.29.96]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f06pH-00038y-6f for linux-arm-kernel@lists.infradead.org; Sun, 25 Mar 2018 14:40:52 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B6F3160807; Sun, 25 Mar 2018 14:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521988791; bh=8hMjSv5miS58mapSBDKZufE4YDJkH2D8RQ+VOBGww/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=frpCuad/ctiUlEpLlp7+DlM1NgbIXUkzDu8w1s2nAfJ4/Uh12lBzdan0rWBa9ufd6 ytKFQ/Gtg5oiW9IhXDQEs4tGm8uNG2VUT1I4WPivNns4V1Y3PiluwUQeex8RCg9tvx dHX7L49RdYvSkadz78AO20lS94wTBzcWJSAGjmak= Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 96AAA6030F; Sun, 25 Mar 2018 14:39:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521988788; bh=8hMjSv5miS58mapSBDKZufE4YDJkH2D8RQ+VOBGww/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LZnlqHvkgHl16UN6kJJ85KXqPeNyCGVYt2/+MUO8TltTc8HlNz+OIGFYOhQx92oyB ea3YXymjEk4wVmzUy2rMdLZS6qU7iIuGH/VeHFJxTfW0oO+RMz+6oBpyYU2bXeToWS QS6A8ZPI0BmxDAmLWshxy0nDwJcTv8BMBc1i4iac= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 96AAA6030F Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: netdev@vger.kernel.org, timur@codeaurora.org, sulrich@codeaurora.org Subject: [PATCH v7 7/7] net: ena: Eliminate duplicate barriers on weakly-ordered archs Date: Sun, 25 Mar 2018 10:39:21 -0400 Message-Id: <1521988761-30344-8-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521988761-30344-1-git-send-email-okaya@codeaurora.org> References: <1521988761-30344-1-git-send-email-okaya@codeaurora.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180325_104051_533687_43089784 X-CRM114-Status: GOOD ( 15.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zorik Machulsky , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Sinan Kaya , Netanel Belgazal , Saeed Bishara , Tobias Klauser , "David S. Miller" , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Code includes barrier() followed by writel(). writel() already has a barrier on some architectures like arm64. This ends up CPU observing two barriers back to back before executing the register write. Create a new wrapper function with relaxed write operator. Use the new wrapper when a write is following a barrier(). Since code already has an explicit barrier call, changing writel() to writel_relaxed() and adding mmiowb() for ordering protection. Signed-off-by: Sinan Kaya --- drivers/net/ethernet/amazon/ena/ena_com.c | 8 ++++++-- drivers/net/ethernet/amazon/ena/ena_eth_com.h | 8 ++++++-- drivers/net/ethernet/amazon/ena/ena_netdev.c | 5 +++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c index bf2de52..1b9d3130 100644 --- a/drivers/net/ethernet/amazon/ena/ena_com.c +++ b/drivers/net/ethernet/amazon/ena/ena_com.c @@ -631,8 +631,10 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev *ena_dev, u16 offset) */ wmb(); - writel(mmio_read_reg, ena_dev->reg_bar + ENA_REGS_MMIO_REG_READ_OFF); + writel_relaxed(mmio_read_reg, + ena_dev->reg_bar + ENA_REGS_MMIO_REG_READ_OFF); + mmiowb(); for (i = 0; i < timeout; i++) { if (read_resp->req_id == mmio_read->seq_num) break; @@ -1826,7 +1828,9 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data) /* write the aenq doorbell after all AENQ descriptors were read */ mb(); - writel((u32)aenq->head, dev->reg_bar + ENA_REGS_AENQ_HEAD_DB_OFF); + writel_relaxed((u32)aenq->head, + dev->reg_bar + ENA_REGS_AENQ_HEAD_DB_OFF); + mmiowb(); } int ena_com_dev_reset(struct ena_com_dev *ena_dev, diff --git a/drivers/net/ethernet/amazon/ena/ena_eth_com.h b/drivers/net/ethernet/amazon/ena/ena_eth_com.h index 2f76572..6fdc753 100644 --- a/drivers/net/ethernet/amazon/ena/ena_eth_com.h +++ b/drivers/net/ethernet/amazon/ena/ena_eth_com.h @@ -107,7 +107,8 @@ static inline int ena_com_sq_empty_space(struct ena_com_io_sq *io_sq) return io_sq->q_depth - 1 - cnt; } -static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq) +static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq, + bool relaxed) { u16 tail; @@ -116,7 +117,10 @@ static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq) pr_debug("write submission queue doorbell for queue: %d tail: %d\n", io_sq->qid, tail); - writel(tail, io_sq->db_addr); + if (relaxed) + writel_relaxed(tail, io_sq->db_addr); + else + writel(tail, io_sq->db_addr); return 0; } diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index 6975150..a822e70 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -556,7 +556,8 @@ static int ena_refill_rx_bufs(struct ena_ring *rx_ring, u32 num) * issue a doorbell */ wmb(); - ena_com_write_sq_doorbell(rx_ring->ena_com_io_sq); + ena_com_write_sq_doorbell(rx_ring->ena_com_io_sq, true); + mmiowb(); } rx_ring->next_to_use = next_to_use; @@ -2151,7 +2152,7 @@ static netdev_tx_t ena_start_xmit(struct sk_buff *skb, struct net_device *dev) if (netif_xmit_stopped(txq) || !skb->xmit_more) { /* trigger the dma engine */ - ena_com_write_sq_doorbell(tx_ring->ena_com_io_sq); + ena_com_write_sq_doorbell(tx_ring->ena_com_io_sq, false); u64_stats_update_begin(&tx_ring->syncp); tx_ring->tx_stats.doorbells++; u64_stats_update_end(&tx_ring->syncp);