From patchwork Fri Mar 16 16:16:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10290457 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 A5295602BD for ; Fri, 16 Mar 2018 23:00:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 992F6290EB for ; Fri, 16 Mar 2018 23:00:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DB32290EE; Fri, 16 Mar 2018 23:00:11 +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 E1C97290EC for ; Fri, 16 Mar 2018 23:00:10 +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=/vJmWq5CJFAWDgV2SgQW+kzRRM1s15ZIEQRSMxANN44=; b=pZOaucLJ3aDcjX Cc8XZIGvrEtPTukjKzhWJ5dnYoMELk2RsEM7TqNy4fpr1hwYp5Ake+Z3KADqApOGhA1crrKgtLnZe vVJdy5uic9/CmmlXFj3HdnfFykjHUri0l42JRVW6HBvJiX2696LviNch7DjI7gejtg5aNHeWXofnc It6ptSPG2hHgE8l9NnAbFpdk7HQ3oyccw0tKLjU+AXfAwnwoROE50/JxaWeQ3W0GFiB0m3F5lNyIa dM7N3YWv5dlHnnd3CXnmn/5ZVSCWnwHWx+ThJn97p5sYXN8TNXM7EgXou99Z2WbG2mCy+BepXjcsE DSqT3z1iUWE/ZgbkhaGw==; 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 1ewyKS-0002vu-BD; Fri, 16 Mar 2018 23:00:04 +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-0006F1-NS 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=18iKXH0MZ2pr27WVSxC4NEaNci6VgDdcPyMVhTFwKrc=; b=mGxB+F5cFpEoSnUqyVq7mQTlHB z4DUmSLYFLpkEjxbRuI7mfn0SJUI8zTZ1zxw4sPdBt+MkHQjcLv9FVoQi2gcIXosFEtKnIdU7R+Dl V2PqBjFbYHhNr/SI4rMazzA1CUWyx0zrN+3BYO4Vj1qfre6PeX3+FToV7knNurrOzTRmZ6P6iWIQo 4zj8irukgpH/pd2VTNR+8wy3xzVQqXfAl6HMkzPTtxMuZfgdlFHA0STDlOWGkIDpg4lwxAzcJGBIB o+M5Ff2m8uZsW+v+fjfEKoP2I1yr1EdWLyVDR7AJSNXRe/kOXJS1iT2GiPzO/jEMjowe4kPGTnT74 S+IPTMHg==; 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-0005RA-Ab 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 CBC63603AF; 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=1521217029; bh=LLy2i4h5QqHwEiq4ILZt3gzgEOKTVKUaRMd6LrJAlBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Al8e7zD5kGVil3umUcFn0IOZizJ4WUN33eiE7Fsf9OvukVimiyOSsD2n+OKVkZi/w gg3m4DPqxG0fZjX4HN9+ayKfZx39gio3BfXHXGbAP6iLBD4yt+GkhrmhgEux5XmTxU 9Y4lQBbwKGC5Q9ZFEkC4IpyzcWOprRYmE7ZmkUXY= 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 C3E3260F5C; Fri, 16 Mar 2018 16:17:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521217028; bh=LLy2i4h5QqHwEiq4ILZt3gzgEOKTVKUaRMd6LrJAlBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GP/gg3XZz63XLKgpkhqvK1hUZ+A82OinCcZxZbkj981hBx0pWKsI0bIeWKgZX7CBA Eo9xvSVpKBcJSEgzWS8YZwsD2a/VxxevHhqFJbfBH+08U7T7lJ2OU41VcZ/Ae0EdMR CXtuq5zoe3NobayvYY1jC3FIXOCEvm3qyGb8j80M= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C3E3260F5C 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 13/18] net: cxgb4/cxgb4vf: Eliminate duplicate barriers on weakly-ordered archs Date: Fri, 16 Mar 2018 12:16:26 -0400 Message-Id: <1521216991-28706-14-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_698864_4CE5A29B X-CRM114-Status: GOOD ( 15.73 ) 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: Casey Leedom , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Sinan Kaya , Ganesh Goudar , 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/cxgb4/cxgb4.h | 6 ++++++ drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 13 +++++++------ drivers/net/ethernet/chelsio/cxgb4/sge.c | 8 ++++---- drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 2 +- drivers/net/ethernet/chelsio/cxgb4vf/adapter.h | 14 ++++++++++++++ drivers/net/ethernet/chelsio/cxgb4vf/sge.c | 16 +++++++++------- 6 files changed, 41 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h index 9040e13..6bde0b9 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h @@ -1202,6 +1202,12 @@ static inline void t4_write_reg(struct adapter *adap, u32 reg_addr, u32 val) writel(val, adap->regs + reg_addr); } +static inline void t4_write_reg_relaxed(struct adapter *adap, u32 reg_addr, + u32 val) +{ + writel_relaxed(val, adap->regs + reg_addr); +} + #ifndef readq static inline u64 readq(const volatile void __iomem *addr) { diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index 7b452e8..276472d 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c @@ -1723,8 +1723,8 @@ int cxgb4_sync_txq_pidx(struct net_device *dev, u16 qid, u16 pidx, else val = PIDX_T5_V(delta); wmb(); - t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL_A), - QID_V(qid) | val); + t4_write_reg_relaxed(adap, MYPF_REG(SGE_PF_KDOORBELL_A), + QID_V(qid) | val); } out: return ret; @@ -1902,8 +1902,9 @@ static void enable_txq_db(struct adapter *adap, struct sge_txq *q) * are committed before we tell HW about them. */ wmb(); - t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL_A), - QID_V(q->cntxt_id) | PIDX_V(q->db_pidx_inc)); + t4_write_reg_relaxed(adap, MYPF_REG(SGE_PF_KDOORBELL_A), + QID_V(q->cntxt_id) | + PIDX_V(q->db_pidx_inc)); q->db_pidx_inc = 0; } q->db_disabled = 0; @@ -2003,8 +2004,8 @@ static void sync_txq_pidx(struct adapter *adap, struct sge_txq *q) else val = PIDX_T5_V(delta); wmb(); - t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL_A), - QID_V(q->cntxt_id) | val); + t4_write_reg_relaxed(adap, MYPF_REG(SGE_PF_KDOORBELL_A), + QID_V(q->cntxt_id) | val); } out: q->db_disabled = 0; diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index 6e310a0..1a1738a 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c @@ -530,11 +530,11 @@ static inline void ring_fl_db(struct adapter *adap, struct sge_fl *q) * mechanism. */ if (unlikely(q->bar2_addr == NULL)) { - t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL_A), - val | QID_V(q->cntxt_id)); + t4_write_reg_relaxed(adap, MYPF_REG(SGE_PF_KDOORBELL_A), + val | QID_V(q->cntxt_id)); } else { - writel(val | QID_V(q->bar2_qid), - q->bar2_addr + SGE_UDB_KDOORBELL); + writel_relaxed(val | QID_V(q->bar2_qid), + q->bar2_addr + SGE_UDB_KDOORBELL); /* This Write memory Barrier will force the write to * the User Doorbell area to be flushed. diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c index 920bccd..8b723a0 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c @@ -139,7 +139,7 @@ void t4_write_indirect(struct adapter *adap, unsigned int addr_reg, { while (nregs--) { t4_write_reg(adap, addr_reg, start_idx++); - t4_write_reg(adap, data_reg, *vals++); + t4_write_reg_relaxed(adap, data_reg, *vals++); } } diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h b/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h index 5883f09..00247be4 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h +++ b/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h @@ -442,6 +442,20 @@ static inline void t4_write_reg(struct adapter *adapter, u32 reg_addr, u32 val) writel(val, adapter->regs + reg_addr); } +/** + * t4_write_reg_relaxed - write a HW register without ordering guarantees + * @adapter: the adapter + * @reg_addr: the register address + * @val: the value to write + * + * Write a 32-bit value into the given HW register. + */ +static inline void t4_write_reg_relaxed(struct adapter *adapter, u32 reg_addr, + u32 val) +{ + writel_relaxed(val, adapter->regs + reg_addr); +} + #ifndef readq static inline u64 readq(const volatile void __iomem *addr) { diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c index dfce5df..1d98387 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c @@ -546,12 +546,13 @@ static inline void ring_fl_db(struct adapter *adapter, struct sge_fl *fl) * mechanism. */ if (unlikely(fl->bar2_addr == NULL)) { - t4_write_reg(adapter, - T4VF_SGE_BASE_ADDR + SGE_VF_KDOORBELL, - QID_V(fl->cntxt_id) | val); + t4_write_reg_relaxed(adapter, + T4VF_SGE_BASE_ADDR + + SGE_VF_KDOORBELL, + QID_V(fl->cntxt_id) | val); } else { - writel(val | QID_V(fl->bar2_qid), - fl->bar2_addr + SGE_UDB_KDOORBELL); + writel_relaxed(val | QID_V(fl->bar2_qid), + fl->bar2_addr + SGE_UDB_KDOORBELL); /* This Write memory Barrier will force the write to * the User Doorbell area to be flushed. @@ -980,8 +981,9 @@ static inline void ring_tx_db(struct adapter *adapter, struct sge_txq *tq, if (unlikely(tq->bar2_addr == NULL)) { u32 val = PIDX_V(n); - t4_write_reg(adapter, T4VF_SGE_BASE_ADDR + SGE_VF_KDOORBELL, - QID_V(tq->cntxt_id) | val); + t4_write_reg_relaxed(adapter, + T4VF_SGE_BASE_ADDR + SGE_VF_KDOORBELL, + QID_V(tq->cntxt_id) | val); } else { u32 val = PIDX_T5_V(n);