From patchwork Sun Mar 25 14:39:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10306997 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 CA7A260325 for ; Sun, 25 Mar 2018 23:18:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF82428B63 for ; Sun, 25 Mar 2018 23:18:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B429428B6E; Sun, 25 Mar 2018 23:18:18 +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 5A27428B63 for ; Sun, 25 Mar 2018 23:18:18 +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=tWmxsZ3HlX1g6uYQ2Z88jQxrKvmTxMTk+FXbutS20iI=; b=pDvM46QplTceGr ChR3lxnVSpFj4lhC5lugw5ztsYsjk3ddGEtsR9DaXrDK+YzbGSksBBc4duoVGfc7IquyhjwMOlIAU d9h5Pjbb6yUgjwv2ixe59rmEOy7iSJNCNzmmEkwqWhmlHEHiKnQKtU5Fj+3ZwixLpX2xy2/uzRk23 6JAWZ99qvHbY5pJh6zwUsMzxDKfp9uz0GsTGZF6FWFhePUBmErFpiIMEXCmpC3jUDqbdrK9dsMLeE 5m4Aqubq7ATIMJANqyHiBAFujr1qoAd7P5LUbcC8LioV5Q8nvIWc+CQBhdFi+QTpzEBFWtb1NBG1u rlUUWPxsWQXuGm+3+4cw==; 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 1f0Etv-0006QG-47; Sun, 25 Mar 2018 23:18:11 +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 1f0EmU-0006ba-Ew for linux-arm-kernel@bombadil.infradead.org; Sun, 25 Mar 2018 23:10:30 +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=K93sIxJaPER5CBymOo3R1NJXJWj681X9ZFCCgYwvgoc=; b=0Fu2E01dG5avC08FuSxy7gnvXi M1Sece6WLzKSzJMeyYlB26m/mhlxnzBpCbS93pW2dgThUz6dlSIYWaihamvcw8JscXRRx69OE48Uy aQkUgu3dGopYbfkzzMDYRo9+MfyRXHdA1/vrbSK5gbaJhGdfl+5Q4tplZxde0+AYYLwYibVg9RPda rIAZ/3RPzeBsUHLLgwLdkSGwAE1WGkZAPN6a+nQtHCqFhA6RQYDN3PyPFf5oWBJ4pAdYraUludyEq tJM87ovHQu7PPAxhE4oVVvInd97zeIpN2kIpYS1CqigqbL6Dy0gIIFMwmWOiniiqDnL63mlGZPtsZ r2/wdlow==; 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-00038x-6c 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 6393460390; Sun, 25 Mar 2018 14:39:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521988777; bh=dJLe4crswKcKInp5/XACikj5cN1X8z4XG7UnJF8YLMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g/tgS8gtHuhkiT8q3oZRWfQhM+r3hIFDhfq3dAlgxO7ke/qeWLexREZqvln063bsD /wHBxFrqDqU/1GWA4kb7HoDG/IGHOcd4LNmH8sxMHA5+OOsauvoFZwlDkDOmuG334d Mg9uunIbx5iJcC/Zuj4r5NTXdNrUjxSe8VdtbnQU= 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 8E1C160F8D; Sun, 25 Mar 2018 14:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521988775; bh=dJLe4crswKcKInp5/XACikj5cN1X8z4XG7UnJF8YLMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZxfSUTwD7GSQqjatqmqjlk/2UbGb6o6lqhsBpi+d/mnGqAKyU5WKTTKcnDo/w8G4W VirLY+/wUB2+K9U0GHZAuvy17B2Hzo7Oms6nv+9FK0TCr163uwMJvgTcHrRzaMgtP0 aTt+3Ud44harB/YVrePr+kAsXBPvwMK1lo9l4oN8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8E1C160F8D 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 6/7] bnxt_en: Eliminate duplicate barriers on weakly-ordered archs Date: Sun, 25 Mar 2018 10:39:20 -0400 Message-Id: <1521988761-30344-7-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_535003_B5CBCE52 X-CRM114-Status: GOOD ( 14.25 ) 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(). Also add mmiowb() so that write code doesn't move outside of scope. Signed-off-by: Sinan Kaya --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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..5e453b9 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1401,6 +1401,15 @@ static inline u32 bnxt_tx_avail(struct bnxt *bp, struct bnxt_tx_ring_info *txr) ((txr->tx_prod - txr->tx_cons) & bp->tx_ring_mask); } +/* For TX and RX ring doorbells with no ordering guarantee*/ +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) {