From patchwork Tue Mar 20 02:42:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10296067 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 06791602C2 for ; Tue, 20 Mar 2018 02:49:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBB8628DA8 for ; Tue, 20 Mar 2018 02:49:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFEC128E44; Tue, 20 Mar 2018 02:49:43 +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 65F5428DA8 for ; Tue, 20 Mar 2018 02:49:43 +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=TewzkyrmZbYiWmZBbYdZVbjxMhTW/uJIPfzo0sWES3k=; b=CGahFqQ1eHWHbe Ai+rgbDPtawJ/anLN554fzjmb2htVbtYbFknDBiyJ7wZ0+i3fX4dH+4IEX8a/YFrW5RnQ2o+Nc4fY UjSj61EawWx1UCbdyXlHDIHtcTQms8i05MpUWgAKsIcqTpHdDvxUQgiN1l+I2CAgADzLTselvS7DW hrfBX7TGvQBLRE1d3BI3sAJxUATJXrwqH5/VHo3NE+RjrSnPHWvfo5votxDlXE4C/Eq4x+18Z1S8B 5RPpYBXxhpuiD9cB1O6vO5IVGVLvySIczonvgExF/SpYFk4FgggElrQ3H5k4+CP6XLVPLZIHa9ABE rWxgvNAUeX+s9InGaZPQ==; 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 1ey7LE-0005Um-Tp; Tue, 20 Mar 2018 02:49:36 +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 1ey7F4-0000L4-J5 for linux-arm-kernel@lists.infradead.org; Tue, 20 Mar 2018 02:43:24 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C288560F8F; Tue, 20 Mar 2018 02:43:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521513793; bh=4vO4Hbs1my4wmNuUXQjuAheElAHcZ/h1hB3wV3KjQYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XdtvgRrX+KPau1J3Wx5N1+j798LorS+DneiS7vF8jJnOQqGx5l82I0JuHXoLPyIhK ALvp4MQ8x7RkeLi+zrEwCvtyqBfWjHuuJdUwxfaj0SmQUPdARX/dGMkR8OCyRZ5fNZ YiVN3OZcpGlwdMCR1M3xwZrBb5auh83UggED7/1Q= 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 916B561111; Tue, 20 Mar 2018 02:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521513781; bh=4vO4Hbs1my4wmNuUXQjuAheElAHcZ/h1hB3wV3KjQYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eVMn7S0Yx1Sl1weuB77hB9VD9SDWGrSv1G/X9hDdAXqpmgdUWbnvWSteRpiykmaie xlYnDgo+5p4ZLbtYPic8T6YdzxdqVIawyC6pWdVHMYuSgYrVHTMdM+W3ZxTW7Jh752 SFKu7Ke9x8yiH/BPdVBjjI2mUs6kxXWcYFqpNcQ8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 916B561111 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 13/17] net: cxgb3: Eliminate duplicate barriers on weakly-ordered archs Date: Mon, 19 Mar 2018 22:42:28 -0400 Message-Id: <1521513753-7325-14-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_194315_470125_919C1A49 X-CRM114-Status: GOOD ( 12.74 ) 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, Santosh Raspatur , 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(). Signed-off-by: Sinan Kaya --- drivers/net/ethernet/chelsio/cxgb3/adapter.h | 7 +++++++ drivers/net/ethernet/chelsio/cxgb3/sge.c | 19 ++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb3/adapter.h b/drivers/net/ethernet/chelsio/cxgb3/adapter.h index 087ff0f..0e21e66 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/adapter.h +++ b/drivers/net/ethernet/chelsio/cxgb3/adapter.h @@ -281,6 +281,13 @@ static inline void t3_write_reg(struct adapter *adapter, u32 reg_addr, u32 val) writel(val, adapter->regs + reg_addr); } +static inline void t3_write_reg_relaxed(struct adapter *adapter, u32 reg_addr, + u32 val) +{ + CH_DBG(adapter, MMIO, "setting register 0x%x to 0x%x\n", reg_addr, val); + writel_relaxed(val, adapter->regs + reg_addr); +} + static inline struct port_info *adap2pinfo(struct adapter *adap, int idx) { return netdev_priv(adap->port[idx]); diff --git a/drivers/net/ethernet/chelsio/cxgb3/sge.c b/drivers/net/ethernet/chelsio/cxgb3/sge.c index e988caa..0baab06 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb3/sge.c @@ -487,7 +487,8 @@ static inline void ring_fl_db(struct adapter *adap, struct sge_fl *q) if (q->pend_cred >= q->credits / 4) { q->pend_cred = 0; wmb(); - t3_write_reg(adap, A_SG_KDOORBELL, V_EGRCNTX(q->cntxt_id)); + t3_write_reg_relaxed(adap, A_SG_KDOORBELL, + V_EGRCNTX(q->cntxt_id)); } } @@ -1058,8 +1059,8 @@ static inline void check_ring_tx_db(struct adapter *adap, struct sge_txq *q) } #else wmb(); /* write descriptors before telling HW */ - t3_write_reg(adap, A_SG_KDOORBELL, - F_SELEGRCNTX | V_EGRCNTX(q->cntxt_id)); + t3_write_reg_relaxed(adap, A_SG_KDOORBELL, + F_SELEGRCNTX | V_EGRCNTX(q->cntxt_id)); #endif } @@ -1510,8 +1511,8 @@ static int ctrl_xmit(struct adapter *adap, struct sge_txq *q, } spin_unlock(&q->lock); wmb(); - t3_write_reg(adap, A_SG_KDOORBELL, - F_SELEGRCNTX | V_EGRCNTX(q->cntxt_id)); + t3_write_reg_relaxed(adap, A_SG_KDOORBELL, + F_SELEGRCNTX | V_EGRCNTX(q->cntxt_id)); return NET_XMIT_SUCCESS; } @@ -1554,8 +1555,8 @@ static void restart_ctrlq(unsigned long data) spin_unlock(&q->lock); wmb(); - t3_write_reg(qs->adap, A_SG_KDOORBELL, - F_SELEGRCNTX | V_EGRCNTX(q->cntxt_id)); + t3_write_reg_relaxed(qs->adap, A_SG_KDOORBELL, + F_SELEGRCNTX | V_EGRCNTX(q->cntxt_id)); } /* @@ -1793,8 +1794,8 @@ again: reclaim_completed_tx(adap, q, TX_RECLAIM_CHUNK); #endif wmb(); if (likely(written)) - t3_write_reg(adap, A_SG_KDOORBELL, - F_SELEGRCNTX | V_EGRCNTX(q->cntxt_id)); + t3_write_reg_relaxed(adap, A_SG_KDOORBELL, + F_SELEGRCNTX | V_EGRCNTX(q->cntxt_id)); } /**