From patchwork Fri Mar 16 16:16:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10289455 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 3C731601BE for ; Fri, 16 Mar 2018 17:03:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C89628E81 for ; Fri, 16 Mar 2018 17:03:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 217B028E99; Fri, 16 Mar 2018 17:03:58 +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 7D76C28E81 for ; Fri, 16 Mar 2018 17:03:57 +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=NtRzPYPAZfvTZC xULKHbBLcVBjfft13yd3Qme1NHQMavd/BF9Q3m3nze0uv1w45zfZWJ2AO8pER1QzH4L/OuuyVxUn3 yBIVvSnwdZDTgqA+enQe73GKTJh8dys47686ML1Xl81q4aicW4eEjOiQPupn/+ZK5HayXpnPE+gb+ jITQXjRmLBssDmKNtHYC+vlZy3UxwNF6wR/6KIedg0zTDMAOE4QJedjRyCEYUWtG/1f6oxGOYiax8 zoZ01R/ZxfQQlOSpj9phHJjN2EC5L9wMx69GYwDW+zxMVAoXunN24xOa4A8ZdMR5CWy8PcbVnByLp VqO1DnDObwRBdyZ0npSg==; 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 1ewslf-0004xn-Hv; Fri, 16 Mar 2018 17:03:47 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ews2i-0006JL-QW for linux-arm-kernel@bombadil.infradead.org; Fri, 16 Mar 2018 16:17:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=o+K1w93VyF7FbIXH+EpkRNf5NlB6XiME0kYtzLlpwh0=; b=DbTgmkAyThqfrPd1fg0GZPsdpJ xpUBbCSYe6en9xoSZVA/1L/aNThn2nH9QxyRzugADjYjUOo41dlguJVd8h1ZdA2Q/JE7iRcpCW31+ qtMuaQdQCTUEfjGnxRI0/ix6cKtVwa4N0QvLVYvjMmuxe6ztSqBk/yThf+AWy45IooglpCespoGxA 8CR6ZqiHK3jy6PbTA2syxdajGCvOOCKlF9EwMvYnAup2FQy9lXCOCtE60Ncjuon2OCkj9wkG5KlgT a7JKavhauLDuMs1UIEc5EUTMRzI8LfeIPLJFkNd41WWCQYNAVXbw58ELlkjNM89r6l0ixV60xM1UZ E0QH9bEQ==; Received: from smtp.codeaurora.org ([198.145.29.96]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ews2d-0005RC-AZ for linux-arm-kernel@lists.infradead.org; Fri, 16 Mar 2018 16:17:18 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8013960390; Fri, 16 Mar 2018 16:17:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521217030; bh=4vO4Hbs1my4wmNuUXQjuAheElAHcZ/h1hB3wV3KjQYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dm/lltjRYfVASwMER9+CjbP2hfsXR1fJirZaT1beTyd+FYTcimbQMk28LrLgw8qTL Y9vx0nsylMuUvEK9vB/gOTQenjb0T0/+VwLMo4jRBJorM3fTI/qf3XoMDpm1o3HMSG s0ab6yesXQfuXLX9ZpE9g/FEy7z8MNeLfO1hv6aU= 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 412D660F6E; Fri, 16 Mar 2018 16:17:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521217030; bh=4vO4Hbs1my4wmNuUXQjuAheElAHcZ/h1hB3wV3KjQYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dm/lltjRYfVASwMER9+CjbP2hfsXR1fJirZaT1beTyd+FYTcimbQMk28LrLgw8qTL Y9vx0nsylMuUvEK9vB/gOTQenjb0T0/+VwLMo4jRBJorM3fTI/qf3XoMDpm1o3HMSG s0ab6yesXQfuXLX9ZpE9g/FEy7z8MNeLfO1hv6aU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 412D660F6E 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 v3 14/18] net: cxgb3: Eliminate duplicate barriers on weakly-ordered archs Date: Fri, 16 Mar 2018 12:16:27 -0400 Message-Id: <1521216991-28706-15-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521216991-28706-1-git-send-email-okaya@codeaurora.org> References: <1521216991-28706-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-20180316_161715_681418_5E3E8235 X-CRM114-Status: GOOD ( 12.36 ) 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)); } /**