Received: by 10.213.65.68 with SMTP id h4csp868612imn; Thu, 22 Mar 2018 10:18:20 -0700 (PDT) X-Google-Smtp-Source: AG47ELvpyy5JYesoOKg/qgHSB16Gc35h4fkN4RhHfC7BdHbP56Xmwb4IsPeALFh7M2VjuGwC57hl X-Received: by 10.99.136.194 with SMTP id l185mr18811479pgd.419.1521739100655; Thu, 22 Mar 2018 10:18:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521739100; cv=none; d=google.com; s=arc-20160816; b=kSV0nx6XANTugXLpDP/YsSX6q3wOMU0MMO9uhnGp38duFueoZ0n+IYwi6pe/mLe+Pv UCa0UmkdQ+htHHD678XwUdRBZszCKgmtHQEngK2JTBnCSCyDAj4Mki5VwxyXOuvvdSPw D4q4snkRE178vrC42wwEAGrycoWGzxCV3NF5vgEZbjv8nWKKqGUZVvKLi7nqhbth58lb xmM9jcUDmaa+oNOGBP5kjdKA9xZV10aj3rXLgFIpzSaXozC32NLnDSOKo4R8QTJJXmAc Eprl4Z0XCEu6isFuVONkj4hAHHWUF8mwJ10oVzY+X2iOQPNKaI0my+lzTRDf6g3alE5K lwUg== 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=02EGWMizf/5wFcZ6Eh2aMfyHf54Icwext6FZGelb3Pk=; b=oDC7yL1gjdE/KhTwUnqLKZb0CYffhQlOjnx//mMF1dzflaPaB4+WIt0RN72g7xJrTT shuN3bjQo/9O531lvADx6/muReOoB4Y6m6DBAsDh0FX8ICFHqzVvVT0ZcSa6/GWnEDC9 hvALO5DVm7au2aTjob5Fe5+YpnVmNVEvJ/8tbOpUv5wVMvOnpB5wZ2hVRI43D57hDOon 2+YBu+PMA2AKz0iTqjLxPzap/RpuSZgJeYKwT3pKt5NuQ1MDXmaKDoI8eBVJII5VFtn3 mlQcbgrDD8pAvujEDaN+vZCR4rjNxdrth3tdg8iVJ9kB/8J4frfjUxttYmcAjEVPlUlS /mPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=apF+qCOk; dkim=pass header.i=@codeaurora.org header.s=default header.b=lzNnFpkK; 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 t15si3268640pfa.170.2018.03.22.10.18.04; Thu, 22 Mar 2018 10:18:20 -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=apF+qCOk; dkim=pass header.i=@codeaurora.org header.s=default header.b=lzNnFpkK; 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 S1752209AbeCVRMB (ORCPT + 99 others); Thu, 22 Mar 2018 13:12:01 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:39614 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751902AbeCVRKO (ORCPT ); Thu, 22 Mar 2018 13:10:14 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 042F660C66; Thu, 22 Mar 2018 17:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521738614; bh=LU3yizObs1NOM5YVbLIKElJlwMoZSx8NFIQWPJA7q1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=apF+qCOk05KFs+tTdcGvHbfLldLz172voW83Q/M9r+LbIG/3U43f6qpNyLIWywD8U fiHZ6etjRZi6jdbbDk/J6JtiRpJQgKYuNlGEMTLRbxSV0bik38ttV3WqHt2+FxS3W4 L/Nnv8TBdrAHfa4HjVH4rajbGZV6FnKIAC4wweqY= 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 3CEB360C66; Thu, 22 Mar 2018 17:10:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521738613; bh=LU3yizObs1NOM5YVbLIKElJlwMoZSx8NFIQWPJA7q1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lzNnFpkKXikkAo+hGzgNEFzd2FGDDolrZJFZeRPvoi1eAYoDlN8S8DZrwgt+2gwgw ShICViJBXxeGzdZVdz60TwXLB3qeLC01BBueedCY3pT5zw3ZuqTtJ/QEybl+t9KfIm VZ9wBzsb2SGLRv+fR99fsJksFbpG8fVuaYMqybGk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3CEB360C66 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 v5 3/5] bnx2x: Eliminate duplicate barriers on weakly-ordered archs Date: Thu, 22 Mar 2018 13:10:00 -0400 Message-Id: <1521738603-23596-4-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521738603-23596-1-git-send-email-okaya@codeaurora.org> References: <1521738603-23596-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_sriov.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c | 2 +- 7 files changed, 16 insertions(+), 12 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 d7c98e8..172fd79 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -4155,7 +4155,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) txdata->tx_db.data.prod += nbd; barrier(); - 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 1e33abd..bda5e4f 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -2592,7 +2592,7 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode) txdata->tx_db.data.prod += 2; barrier(); - 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_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c index ffa7959..40e55d8 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c @@ -105,7 +105,7 @@ static void bnx2x_vf_igu_ack_sb(struct bnx2x *bp, struct bnx2x_virtf *vf, DP(NETIF_MSG_HW, "write 0x%08x to IGU(via GRC) addr 0x%x\n", ctl, igu_addr_ctl); - REG_WR(bp, igu_addr_ctl, ctl); + REG_WR_RELAXED(bp, igu_addr_ctl, ctl); mmiowb(); barrier(); } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c index 76a4668..3b2f1bd 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c @@ -170,7 +170,7 @@ 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); /* Wait for PF to complete */ while ((tout >= 0) && (!*done)) { -- 2.7.4