From patchwork Tue Mar 20 02:42:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10296091 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 7ACDF602C2 for ; Tue, 20 Mar 2018 02:50:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B36428F20 for ; Tue, 20 Mar 2018 02:50:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FABF28F76; Tue, 20 Mar 2018 02:50:45 +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 DB8EB28F20 for ; Tue, 20 Mar 2018 02:50:44 +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=Oeb/d4wAOytls8CmdRlG4idKcaGz6cJG4rzWTj1k/Sk=; b=QxvVmW+phnNvMY rJ5yyxjVf0z2QrV0EDgzat4p1CS0YQ+D3PSiQXkKGm9ya6P1NRr2hB8kBLi29QbNiZzBn1jZtT9Bt ntLTf6CsyLG/hGbo+2K8gOgMXPObTj24KaAHVNerWBe+Jk0nt+tu4aKCCoQRXw0qDvqAa93iaaoGx BosZOB70NA9dImORhTfPJ+C6PtzIbxzfQdhHgeb5nL5jfjlwg74cV48AMmmOoWfc/n93Pb16fexMG 9BY+9MLRGuO3gxo/o59WS0vKlrBPzdl4tCT+KeFoG5Jz/zxEJ8+1QsuNwnIL3Q83uRe62VLjK1IvC 1gC43G6j31LOWajl9nvw==; 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 1ey7MD-0006Jm-DQ; Tue, 20 Mar 2018 02:50:37 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ey7FL-0000RD-3p for linux-arm-kernel@lists.infradead.org; Tue, 20 Mar 2018 02:43:36 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 224ED60C54; Tue, 20 Mar 2018 02:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521513800; bh=I5HEqRhdW/osz4IfMq1JnW5hVNTrKUp6sEhK7jw6cjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=myEAQbML3iJCKlDuhMq5D5cV/BttOS/zuZqFgS0amqKVeHtHsXlVj/yNOabYoe/Ul Zv25q75zo9KsFiu0QxnppMNgDNEiGe9K0Tx1gLxb2YA0a6hN5EWKSWNuiKniYQcmUC 88HjEfjMEHk7OTf+PWhjqsnfxNMYxJyI0EfsnAdM= 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 3262761155; Tue, 20 Mar 2018 02:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521513785; bh=I5HEqRhdW/osz4IfMq1JnW5hVNTrKUp6sEhK7jw6cjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d7/ec80mQ3fXby9TZbRCTvepmYJXpM5FOx7LkzjjVNbHNfUo/zMOEhZ6T18eiaf+g fNU7vxrMosabLcNeRVTXyWWUIXmKGPnhIH7Mhczmsh1wAkBOKSeeNwqJeuS2OU7/Vd 1TU+NLHy0spbXzwuCWyrXCmyXsis0yG2kmtiBuzA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3262761155 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 v4 15/17] bnxt_en: Eliminate duplicate barriers on weakly-ordered archs Date: Mon, 19 Mar 2018 22:42:30 -0400 Message-Id: <1521513753-7325-16-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521513753-7325-1-git-send-email-okaya@codeaurora.org> References: <1521513753-7325-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-20180319_194331_776525_587F9D84 X-CRM114-Status: GOOD ( 12.92 ) 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: Sinan Kaya , linux-arm-msm@vger.kernel.org, Michael Chan , linux-kernel@vger.kernel.org, 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 wmb() 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 wmb(). Since code already has an explicit barrier call, changing writel() to writel_relaxed(). Signed-off-by: Sinan Kaya --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 11 ++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 1500243..befb538 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -1922,7 +1922,7 @@ static int bnxt_poll_work(struct bnxt *bp, struct bnxt_napi *bnapi, int budget) /* Sync BD data before updating doorbell */ wmb(); - bnxt_db_write(bp, db, DB_KEY_TX | prod); + bnxt_db_write_relaxed(bp, db, DB_KEY_TX | prod); } cpr->cp_raw_cons = raw_cons; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 1989c47..4c0d048 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1402,11 +1402,20 @@ static inline u32 bnxt_tx_avail(struct bnxt *bp, struct bnxt_tx_ring_info *txr) } /* For TX and RX ring doorbells */ +static inline void bnxt_db_write_relaxed(struct bnxt *bp, void __iomem *db, + u32 val) +{ + writel_relaxed(val, db); + if (bp->flags & BNXT_FLAG_DOUBLE_DB) + writel_relaxed(val, db); +} + +/* For TX and RX ring doorbells */ static inline void bnxt_db_write(struct bnxt *bp, void __iomem *db, u32 val) { writel(val, db); if (bp->flags & BNXT_FLAG_DOUBLE_DB) - writel(val, db); + writel_relaxed(val, db); } extern const u16 bnxt_lhint_arr[]; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 1801582..a1b1060 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -2403,7 +2403,7 @@ static int bnxt_run_loopback(struct bnxt *bp) /* Sync BD data before updating doorbell */ wmb(); - bnxt_db_write(bp, txr->tx_doorbell, DB_KEY_TX | txr->tx_prod); + bnxt_db_write_relaxed(bp, txr->tx_doorbell, DB_KEY_TX | txr->tx_prod); rc = bnxt_poll_loopback(bp, pkt_size); dma_unmap_single(&bp->pdev->dev, map, pkt_size, PCI_DMA_TODEVICE);