Received: by 10.213.65.68 with SMTP id h4csp64497imn; Mon, 19 Mar 2018 19:46:52 -0700 (PDT) X-Google-Smtp-Source: AG47ELtP10oYBgKxgAOlU3H2QhToGioNBcoxOOP/SHZSSjqyUIi24uar8qAcEivPFMRMb4Cm4wL5 X-Received: by 2002:a17:902:b691:: with SMTP id c17-v6mr14837869pls.308.1521514012044; Mon, 19 Mar 2018 19:46:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521514012; cv=none; d=google.com; s=arc-20160816; b=rXYFZuVbtUWEBbGIJQTEal02yZJAl+VKfg27FcEY5uN9mZbk7GjyegeOBwlzEAzJn6 /k6i2ulHqGuZZpvONpmq6ggf+nCxOYa45OiUe+gWzUlWzYFhzN8GyiDZqUyj+S0uHDSo nRGm0pmSf9+O5IuqVa1m17QQSUiXdB90gFv+NA0rC9fLDlh21hPAHs61r2G2b5kuFUfE /6/o9GntSRe87qbs5auyIySeNZqtlZmm3S3yZ/jSG70BXjnoq0xVJSwjLZ66ZQaeH8zn G9NgQRMsZ7eQMSxGtlSUJ6UzOd7fSHYDMeZSyPr7h429xI35LcBfF4tRU49dl7laEDIp qQ6A== 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=M4K6kta6d77Jvh6pwXJSzEby0fVbalfK2853QY3rjow=; b=qSKOiXrnnnqnVLpqS7mhajiI5+KZ8415CFGIr6jRpPG4D/TwU1VvcdlavKxMg2DNgh IMO+o7LGt4l3WHGFSZ0fnlhw/1E4Z8TtiikaKB/jjgo1A8P5oXr/rkLpO5kbxR0pBqp2 qOk1LoQNw1DrsH0gWNiHsWTiHwEjy3F7qxCf6Do4knJ9VcHZs7bvy/xj7w850xBX7GLB UwJuwWWBWUnPxskf7VqzdmsT4y77H6wmp11vIZ/8lYDQGY9TjPr2RRnYa5j3Y+DAcQGJ ATgY7mSvFE8BDIM2mBh0buTB852ujLUUWLL5owSdYqNt03n3m8YR8swO6gZ8HhKDPCsy 7aTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=mtrIsire; dkim=pass header.i=@codeaurora.org header.s=default header.b=nGXC5lO6; 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 f91-v6si647942plf.203.2018.03.19.19.46.38; Mon, 19 Mar 2018 19:46:52 -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=mtrIsire; dkim=pass header.i=@codeaurora.org header.s=default header.b=nGXC5lO6; 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 S1752278AbeCTCpa (ORCPT + 99 others); Mon, 19 Mar 2018 22:45:30 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:43522 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751897AbeCTCnH (ORCPT ); Mon, 19 Mar 2018 22:43:07 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1376F60C66; Tue, 20 Mar 2018 02:42:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521513786; bh=RHuipZccrJVinGZddlA+J2BqOYeiKTjqWwjm7aoU4nQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mtrIsireMR0XMWp/WSIgLuzqoY5t4cU3W1x9scO6kAG7QJ+eStH1/XpYJh8oGs8A+ YZBsGi0QsBnVbKbbvBg0kxxYAy7OSrHhZhmLxqr/jX3tqtSCVSgKfcVypVTNdJJXbh zNzLsd2ZpcieYkEane4cvSvCqEPWycw8AOFU2j1Y= 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 8AA3360FAA; Tue, 20 Mar 2018 02:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521513777; bh=RHuipZccrJVinGZddlA+J2BqOYeiKTjqWwjm7aoU4nQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nGXC5lO6TtU2N/EP30M3f7ssE1xHY6a2R09svVG8TWfLch4vzxXJiRt0OJiZfuSQD Y482ZqQmkMpYMN6lvbG70C+0XHzmFppvAgtholXgDDXbbwON5jFf9YWrfjEVRlo7tT mZTINKzIp0nHsEp4RIQUPgqraNwmgMjrjGlkE2jg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8AA3360FAA 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 v4 11/17] bnx2x: Eliminate duplicate barriers on weakly-ordered archs Date: Mon, 19 Mar 2018 22:42:26 -0400 Message-Id: <1521513753-7325-12-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. 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 | 9 ++++++++- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 4 ++-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 21 +++++++++++---------- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c | 2 +- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index 352beff..ac38db9 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)) @@ -760,7 +766,8 @@ struct bnx2x_fastpath { #endif #define DOORBELL(bp, cid, val) \ do { \ - writel((u32)(val), bp->doorbells + (bp->db_size * (cid))); \ + writel_relaxed((u32)(val),\ + bp->doorbells + (bp->db_size * (cid))); \ } while (0) /* TX CSUM helpers */ 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_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 74fc9af..2dea1b6 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -1608,8 +1608,8 @@ static void bnx2x_hc_int_enable(struct bnx2x *bp) } else val = 0xffff; - REG_WR(bp, HC_REG_TRAILING_EDGE_0 + port*8, val); - REG_WR(bp, HC_REG_LEADING_EDGE_0 + port*8, val); + REG_WR_RELAXED(bp, HC_REG_TRAILING_EDGE_0 + port * 8, val); + REG_WR_RELAXED(bp, HC_REG_LEADING_EDGE_0 + port * 8, val); } /* Make sure that interrupts are indeed enabled from here on */ @@ -1672,8 +1672,8 @@ static void bnx2x_igu_int_enable(struct bnx2x *bp) } else val = 0xffff; - REG_WR(bp, IGU_REG_TRAILING_EDGE_LATCH, val); - REG_WR(bp, IGU_REG_LEADING_EDGE_LATCH, val); + REG_WR_RELAXED(bp, IGU_REG_TRAILING_EDGE_LATCH, val); + REG_WR_RELAXED(bp, IGU_REG_LEADING_EDGE_LATCH, val); /* Make sure that interrupts are indeed enabled from here on */ mmiowb(); @@ -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(); } @@ -7761,7 +7761,7 @@ void bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, u8 idu_sb_id, bool is_pf) barrier(); 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(); @@ -9720,13 +9720,14 @@ static void bnx2x_process_kill_chip_reset(struct bnx2x *bp, bool global) barrier(); mmiowb(); - REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, - reset_mask2 & (~stay_reset2)); + REG_WR_RELAXED(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, + reset_mask2 & (~stay_reset2)); barrier(); mmiowb(); - REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, reset_mask1); + REG_WR_RELAXED(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, + reset_mask1); 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