From patchwork Fri Mar 23 22:23:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10305701 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 AADF660385 for ; Fri, 23 Mar 2018 22:26:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B8BD29178 for ; Fri, 23 Mar 2018 22:26:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7EC88291CA; Fri, 23 Mar 2018 22:26:42 +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 1AC1829178 for ; Fri, 23 Mar 2018 22:26:42 +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=uy+dYwEoJw8rpZU8TP1sJgYQ3pFjpdghP29KIAibf1Y=; b=QjEsEY1n75+PNk 83czLlaYA0wosqrG3gTBSPVcvUNBPYpG/dbL9i28+spXXc8Ca4Z9zBdfZbcM0bYlLzxLanM4DACQ7 NRa3NMo0QK/vwT+9s0GmL8+UJ53g+YXilcwZiXRK1xoQZMztZIf6AIg3kygTopXgtdCOQoAT5ykcg j2Pn9sy8Abfp+UMYAkY1YQixUGGV363ak9wK/EVZ0CYzOtWuRKfTGMshyJorYAHf6wdSlj6IiiDuI hmyELM8QCTbDzP2PvjBeoX57lytixnM5dNSFrprFOQnI8poHJBeLCs36JrCAPRBlM7HZpepF3shkc maAxezTCAWIrpBLKaxOQ==; 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 1ezV8s-0007t4-DZ; Fri, 23 Mar 2018 22:26:34 +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 1ezV63-0005O3-4h for linux-arm-kernel@lists.infradead.org; Fri, 23 Mar 2018 22:23:44 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id CF26C60F92; Fri, 23 Mar 2018 22:23:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521843805; bh=D96YlfEiyLWZM1uPPaglTZrrOTW2zgYr9TxIgng2H24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VdAb4xRk6XhHA2ZgC63jyDTUhkmxKqbF0FgvGEE2iEbBf6/l0hxjq0mwGxjOaLH+t Nhqax7PgHvR6STu3JA0rMHPeSGxUD4GxFLYmaB2MFkVX+V0skNrRAuuTe+ksKKsNoz IZd3ETWkKWL9zfwbTreDc6Gcl3TCL4y1Gt2lYKWY= 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 5426B60F6D; Fri, 23 Mar 2018 22:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521843805; bh=D96YlfEiyLWZM1uPPaglTZrrOTW2zgYr9TxIgng2H24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VdAb4xRk6XhHA2ZgC63jyDTUhkmxKqbF0FgvGEE2iEbBf6/l0hxjq0mwGxjOaLH+t Nhqax7PgHvR6STu3JA0rMHPeSGxUD4GxFLYmaB2MFkVX+V0skNrRAuuTe+ksKKsNoz IZd3ETWkKWL9zfwbTreDc6Gcl3TCL4y1Gt2lYKWY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5426B60F6D 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 v6 6/6] bnxt_en: Eliminate duplicate barriers on weakly-ordered archs Date: Fri, 23 Mar 2018 18:23:11 -0400 Message-Id: <1521843791-21201-7-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521843791-21201-1-git-send-email-okaya@codeaurora.org> References: <1521843791-21201-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-20180323_152340_003720_8AD8F531 X-CRM114-Status: GOOD ( 12.50 ) 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 | 3 ++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 1500243..fc8ea0d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -1922,7 +1922,8 @@ 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); + mmiowb(); } 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) {