Received: by 10.213.65.68 with SMTP id h4csp751190imn; Fri, 23 Mar 2018 15:25:30 -0700 (PDT) X-Google-Smtp-Source: AG47ELv/AiBkOXW1mGVJRDoRh4CgOYmx0FqWTj4u/0OxbeRNe8q0wD9M1fRSQtROpeVUwCEjZZ7f X-Received: by 10.99.95.84 with SMTP id t81mr21270667pgb.400.1521843930559; Fri, 23 Mar 2018 15:25:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521843930; cv=none; d=google.com; s=arc-20160816; b=DWs3O57z4QebpsDZNybfi81scmCz+ecKlHoLoH4DWx9E75Jmedhe/CnoItSfsQhl5p LWT/hM2MePqn1zuPMENuQqDTBWVVdohbX+RjzZJygvCX1YcN9BO8sl+p1mkGRcalZlFz WFAd2mw3F7pvpS38/n108aulALo9M5sF6NXnbfBAQQWJwyY5Plf4d3N2bvRqo1F8tZcE sG+h/2cIzmkG/TItbFBIhfBJTXFdac1tKGlb1c626kossbZHQs3q6vOhTfPCegfjuVQC 3gBgUwkZ2rCCV+6vYHdxVTVpv5N8dAitdFiNvGxXieU1hQNUSLHblEaWep/nHNMHxjYT bO/g== 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=cofe0ZNg2sGUwqzbGCWW4OMxaTpLjSGegkMwHILxSkE=; b=uWXXH1odq3mvPe/t6vdGf4r92+NTtJovkrC2ttNk2/lwEACdVG5p5ulAlqvAjuDWVE FwCmYDBXQN1Ei0uhBHhTvGh1N2e+Wz6MtWhAc72lR0ScdPatij0s7/OHZ5azY7VRjSxQ Ij5sfhicgqz87bpxUS79tz4sGRMVBZSQYEqMydD7/LeZVfxySWFri64O72ZdCs1EaNCb V5wnj4ShlIijj/T3hwyifyrYVnzzB5RLrAfjUJ6y5CHIt+r8JTjZUY7RKjFg+8cAp5OT 6A23RC50XHAv17KfWtWKRt8YIXkbVCH8jMuVkw1Q6+yfZCOL2vu/ed4pSb19ALYKmhJK Vy0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=HBzFGI6W; dkim=pass header.i=@codeaurora.org header.s=default header.b=HBzFGI6W; 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 z18si7282066pfe.41.2018.03.23.15.25.15; Fri, 23 Mar 2018 15:25:30 -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=HBzFGI6W; dkim=pass header.i=@codeaurora.org header.s=default header.b=HBzFGI6W; 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 S1752459AbeCWWX1 (ORCPT + 99 others); Fri, 23 Mar 2018 18:23:27 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:35818 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752230AbeCWWXX (ORCPT ); Fri, 23 Mar 2018 18:23:23 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B773660F91; Fri, 23 Mar 2018 22:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521843802; bh=bYKl9Xig4chT4Nmq7OjRMBjLLTRW+CUHKZENWAt8XYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HBzFGI6W//cKtmmZ3JnYJZWAdnnctOnIJ1K5lgM3MAq8f9plLC/cHqdIdnvoIlY17 ZwLf1+rDuOKTwpgY6bzCPgqgNaYBmyHXHeKQlB4BBUAaTjWtXogm+7xYY2RxzTWXBx twUJmfl28qxlqZVY1XwxwkHg4vlJbgsewLZzGh0g= 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 3C48460F6D; Fri, 23 Mar 2018 22:23:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521843802; bh=bYKl9Xig4chT4Nmq7OjRMBjLLTRW+CUHKZENWAt8XYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HBzFGI6W//cKtmmZ3JnYJZWAdnnctOnIJ1K5lgM3MAq8f9plLC/cHqdIdnvoIlY17 ZwLf1+rDuOKTwpgY6bzCPgqgNaYBmyHXHeKQlB4BBUAaTjWtXogm+7xYY2RxzTWXBx twUJmfl28qxlqZVY1XwxwkHg4vlJbgsewLZzGh0g= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3C48460F6D 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 , Ariel Elior , everest-linux-l2@cavium.com, linux-kernel@vger.kernel.org Subject: [PATCH v6 4/6] bnx2x: Eliminate duplicate barriers on weakly-ordered archs Date: Fri, 23 Mar 2018 18:23:09 -0400 Message-Id: <1521843791-21201-5-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 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. Since code already has an explicit barrier call, changing writel() to writel_relaxed(). Signed-off-by: Sinan Kaya --- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 12 ++++++++---- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 4 ++-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 4 ++-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c | 4 +++- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index 352beff..d847e1b 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -166,6 +166,12 @@ do { \ #define REG_RD8(bp, offset) readb(REG_ADDR(bp, offset)) #define REG_RD16(bp, offset) readw(REG_ADDR(bp, offset)) +#define REG_WR_RELAXED(bp, offset, val) \ + writel_relaxed((u32)val, REG_ADDR(bp, offset)) + +#define REG_WR16_RELAXED(bp, offset, val) \ + writew_relaxed((u16)val, REG_ADDR(bp, offset)) + #define REG_WR(bp, offset, val) writel((u32)val, REG_ADDR(bp, offset)) #define REG_WR8(bp, offset, val) writeb((u8)val, REG_ADDR(bp, offset)) #define REG_WR16(bp, offset, val) writew((u16)val, REG_ADDR(bp, offset)) @@ -758,10 +764,8 @@ struct bnx2x_fastpath { #if (BNX2X_DB_SHIFT < BNX2X_DB_MIN_SHIFT) #error "Min DB doorbell stride is 8" #endif -#define DOORBELL(bp, cid, val) \ - do { \ - writel((u32)(val), bp->doorbells + (bp->db_size * (cid))); \ - } while (0) +#define DOORBELL_RELAXED(bp, cid, val) \ + writel_relaxed((u32)(val), (bp)->doorbells + ((bp)->db_size * (cid))) /* TX CSUM helpers */ #define SKB_CS_OFF(skb) (offsetof(struct tcphdr, check) - \ diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index b97820f..91d2de6 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -4156,7 +4156,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) /* make sur edescriptor update is observed by HW */ wmb(); - DOORBELL(bp, txdata->cid, txdata->tx_db.raw); + DOORBELL_RELAXED(bp, txdata->cid, txdata->tx_db.raw); mmiowb(); diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index a5265e1..a8ce5c5 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -522,8 +522,8 @@ static inline void bnx2x_update_rx_prod(struct bnx2x *bp, wmb(); for (i = 0; i < sizeof(rx_prods)/4; i++) - REG_WR(bp, fp->ustorm_rx_prods_offset + i*4, - ((u32 *)&rx_prods)[i]); + REG_WR_RELAXED(bp, fp->ustorm_rx_prods_offset + i * 4, + ((u32 *)&rx_prods)[i]); mmiowb(); /* keep prod updates ordered */ diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index 39af4f8..da18aa2 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -2593,7 +2593,7 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode) txdata->tx_db.data.prod += 2; /* make sure descriptor update is observed by the HW */ wmb(); - DOORBELL(bp, txdata->cid, txdata->tx_db.raw); + DOORBELL_RELAXED(bp, txdata->cid, txdata->tx_db.raw); mmiowb(); barrier(); diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 74fc9af..146c40d 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -3817,8 +3817,8 @@ static void bnx2x_sp_prod_update(struct bnx2x *bp) */ mb(); - REG_WR16(bp, BAR_XSTRORM_INTMEM + XSTORM_SPQ_PROD_OFFSET(func), - bp->spq_prod_idx); + REG_WR16_RELAXED(bp, BAR_XSTRORM_INTMEM + XSTORM_SPQ_PROD_OFFSET(func), + bp->spq_prod_idx); mmiowb(); } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c index 76a4668..8e0a317 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c @@ -170,7 +170,9 @@ static int bnx2x_send_msg2pf(struct bnx2x *bp, u8 *done, dma_addr_t msg_mapping) wmb(); /* Trigger the PF FW */ - writeb(1, &zone_data->trigger.vf_pf_channel.addr_valid); + writeb_relaxed(1, &zone_data->trigger.vf_pf_channel.addr_valid); + + mmiowb(); /* Wait for PF to complete */ while ((tout >= 0) && (!*done)) { -- 2.7.4