Received: by 10.213.65.68 with SMTP id h4csp63885imn; Mon, 19 Mar 2018 19:45:19 -0700 (PDT) X-Google-Smtp-Source: AG47ELsOz2/h5hneZUBMcmeOjiDd03xlYJ18efdW0uVHNdF2ALE/PWczYL+NRofBLR7fVk3PtA1S X-Received: by 10.101.64.197 with SMTP id u5mr10984013pgp.23.1521513919550; Mon, 19 Mar 2018 19:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521513919; cv=none; d=google.com; s=arc-20160816; b=Th2pdXwKjyJKHB3YyJxgOW1gjp9DrFUNI/WMMzt+6tQgnHDQVsONq0RYZtln7siO3U R2B8c7qic/qnKDYNYFpx3w4BCWfYbcH94SosEYaBRDcw9QSaEW4siYwuHRiAkFDGgdqb RI7JJYq45HYg++d04c8CAD+D8VpBA3NafvItWyB0VWC/c48ecWevs1VieDSZJHXxFMVI mYO+H0UiNfXKU5MLHQIqIAEOJDYmq9HtxNfVMaBmJ2GvE4hI1E6Ra2cKsONCq7wrKXcN nh1iJwrGsfDnh3wmDCZOAYANwue10RWfpIrlBMIFk6TMJDSfJliokdUy5aCxAdVt2gG3 XZtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=o+K1w93VyF7FbIXH+EpkRNf5NlB6XiME0kYtzLlpwh0=; b=lasLYE/Vr63fkEZqjBrNu/anqr7fEGziruSYHZySNW+pIqXNPOYVf97BveaPIqejfq Q3PsDBYZpGX7mFrEV4vchk+IOnOryp/5OgpuyhRfSB2mVWVCE+qsLNibwQex2oj8XkoF DAjnMzQn4Ggyl0OIyaL0n6bNVAjen17cQ6kTPxUabOGI+IuTgiRUQ03tLeAnQ5F2X8OO 9kiNbTsekTgoHGTQLUkdN+nE+wzN/a2Wz3HIQKEqjO/aE/uARvNP0+BBd4SNzKDq7+Kk S3j6IeiJ88HJ9BKdqcSm44BMkfob300d3Uhp/njNxtf9Ua+DTxr6FQR9rbMtuv1Mb8ib tLbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=ZaSOsVvW; dkim=pass header.i=@codeaurora.org header.s=default header.b=eVMn7S0Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n20-v6si562944plp.561.2018.03.19.19.45.05; Mon, 19 Mar 2018 19:45:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=ZaSOsVvW; dkim=pass header.i=@codeaurora.org header.s=default header.b=eVMn7S0Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752096AbeCTCn3 (ORCPT + 99 others); Mon, 19 Mar 2018 22:43:29 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:43726 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751925AbeCTCnL (ORCPT ); Mon, 19 Mar 2018 22:43:11 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 08BB461112; 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=1521513790; bh=4vO4Hbs1my4wmNuUXQjuAheElAHcZ/h1hB3wV3KjQYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZaSOsVvW3ceIh4W9ijwbQhG9JcPRePlapYgEFAm6h5/j1g3nhS3lu7HmTwxJ3YMKB 9/g4C3gdnUC62SkNUgJqMV5DEUWF1BM3FQatkNolfqph2PvoKNusRdsrD/lQsk8Kzo jVYnt4In3lFG4bi6PIXEXDPp+724N/OwYw4e75Ec= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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 Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , Santosh Raspatur , linux-kernel@vger.kernel.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 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)); } /** -- 2.7.4