Received: by 10.213.65.68 with SMTP id h4csp63864imn; Mon, 19 Mar 2018 19:45:16 -0700 (PDT) X-Google-Smtp-Source: AG47ELsaRJWBSWhXIpGfweBxAqGnILcLgM5hA2ih9HloiE2YvuUzl3mCEISuO/cPfnYbzuU0DcEM X-Received: by 10.99.163.67 with SMTP id v3mr10540062pgn.298.1521513915984; Mon, 19 Mar 2018 19:45:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521513915; cv=none; d=google.com; s=arc-20160816; b=PsBBqa9B4EFtroajAlZFcdK4adBY6/yiBdYaYx6hU7FvjivX4YQtBtLBi/QBhQwGaS R1U7UHRvBwzzw/JL89xEGWFNJRKl8SKYRi0LdMLvB03MW8zXUsG4E3o8CS/fjOJJ9AVo 3xB7QvzKqbRkzNXnF75VwhZNxjfjHQYVDUAaFoLPDVGA07X5OCF3wkm6G/fntNijFExA +0df9qrbvOCZzc/Gq34CsXKmonasc43TlFuV2oa2ceBaUFIY3L1WdqPiwqWbLFZv4KOh 92Z0nnA6/Dk/gVRy23qfynkJ75UKTqjFRWW54oqKoByLrKs8s0lSnTPsXQu851wVXc3L Pv0g== 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=BI6lTNwKMK8EcsDq0cYElDjpSm3qYaLSRhk3p+JI8SI=; b=ll/Fc3SgtXeXV1o5yRdxLTPNayt4tx46MfK2RbHKEiGgaS1O9Y6VF2uj+ab/HCWHDz 1JCtZ1A6vo4B/ns2OhkRvJyV8N/GdoFi59mtisiSpAr5bss/W97arlcF8vb/JQDfTVib OFybCsblM7f7QQZDbHyf8OXs+H/tvdtXUosT0mjyPJ94EEZmSEswxgMd1CPGc4rBHO7Q z8GP0Dfed4NygMSa34cECJ2c328jei66Yc/Hkgdqzlet6RQv6RDPNLOUOUVKPFZijU4c FTOe62QqsTzvB6yTYQ+dFMevHfqvUXwAc3Nos4+58Godnf94Y4g9klUYnrt9KtcQiFv1 tHJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=eDzPybKr; dkim=pass header.i=@codeaurora.org header.s=default header.b=bXnWfI4w; 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 f3-v6si627071plr.192.2018.03.19.19.45.01; Mon, 19 Mar 2018 19:45:15 -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=eDzPybKr; dkim=pass header.i=@codeaurora.org header.s=default header.b=bXnWfI4w; 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 S1752163AbeCTCnu (ORCPT + 99 others); Mon, 19 Mar 2018 22:43:50 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44562 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752078AbeCTCn2 (ORCPT ); Mon, 19 Mar 2018 22:43:28 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7E22E60C66; Tue, 20 Mar 2018 02:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521513806; bh=zp2AaxIN6WDbm/SHpi7OTLVud+5zxaF6GvQVEs2949Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eDzPybKrP8TXwHXuL55vB/pc4Mj5IBNAtB77hweSxSdO8tt14XV+SUw/T/OjXc1A/ HLIrWQZr/Eraqwn74sfU/vEQQWR6RI+kus7nYuhYiX5isVLY5JNGQD+b5QTaSNON+1 Y9Q2x/kNwubfWlSdkJGnC9B/ItOyFGYQxIQr65IQ= 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 5E76E60F6D; Tue, 20 Mar 2018 02:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521513794; bh=zp2AaxIN6WDbm/SHpi7OTLVud+5zxaF6GvQVEs2949Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bXnWfI4wWqw7zHEYdlW6pYJEIwmNrIhA7cQlXNip+9nGYgdH1ufQ6RE0uExviDpBy YFDtqLAPCtJKB3GC13Lspsd+8AFRqqQopVLxQlPcZFqXfgS/ayliui22945jCRwuq4 FTnrps7GuDGefQ6GsYdPEtCE3pPTWWcI7iYSTEE4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5E76E60F6D 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 , Netanel Belgazal , Saeed Bishara , Zorik Machulsky , "David S. Miller" , Tobias Klauser , linux-kernel@vger.kernel.org Subject: [PATCH v4 17/17] net: ena: Eliminate duplicate barriers on weakly-ordered archs Date: Mon, 19 Mar 2018 22:42:32 -0400 Message-Id: <1521513753-7325-18-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 barrier() 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 barrier(). Since code already has an explicit barrier call, changing writel() to writel_relaxed(). Signed-off-by: Sinan Kaya --- drivers/net/ethernet/amazon/ena/ena_com.c | 6 ++++-- drivers/net/ethernet/amazon/ena/ena_eth_com.h | 22 ++++++++++++++++++++-- drivers/net/ethernet/amazon/ena/ena_netdev.c | 4 ++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c index bf2de52..b6e628f 100644 --- a/drivers/net/ethernet/amazon/ena/ena_com.c +++ b/drivers/net/ethernet/amazon/ena/ena_com.c @@ -631,7 +631,8 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev *ena_dev, u16 offset) */ wmb(); - writel(mmio_read_reg, ena_dev->reg_bar + ENA_REGS_MMIO_REG_READ_OFF); + writel_relaxed(mmio_read_reg, + ena_dev->reg_bar + ENA_REGS_MMIO_REG_READ_OFF); for (i = 0; i < timeout; i++) { if (read_resp->req_id == mmio_read->seq_num) @@ -1826,7 +1827,8 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data) /* write the aenq doorbell after all AENQ descriptors were read */ mb(); - writel((u32)aenq->head, dev->reg_bar + ENA_REGS_AENQ_HEAD_DB_OFF); + writel_relaxed((u32)aenq->head, + dev->reg_bar + ENA_REGS_AENQ_HEAD_DB_OFF); } int ena_com_dev_reset(struct ena_com_dev *ena_dev, diff --git a/drivers/net/ethernet/amazon/ena/ena_eth_com.h b/drivers/net/ethernet/amazon/ena/ena_eth_com.h index 2f76572..09ef7cd 100644 --- a/drivers/net/ethernet/amazon/ena/ena_eth_com.h +++ b/drivers/net/ethernet/amazon/ena/ena_eth_com.h @@ -107,7 +107,8 @@ static inline int ena_com_sq_empty_space(struct ena_com_io_sq *io_sq) return io_sq->q_depth - 1 - cnt; } -static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq) +static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq, + bool relaxed) { u16 tail; @@ -116,7 +117,24 @@ static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq) pr_debug("write submission queue doorbell for queue: %d tail: %d\n", io_sq->qid, tail); - writel(tail, io_sq->db_addr); + if (relaxed) + writel_relaxed(tail, io_sq->db_addr); + else + writel(tail, io_sq->db_addr); + + return 0; +} + +static inline int ena_com_write_sq_doorbell_rel(struct ena_com_io_sq *io_sq) +{ + u16 tail; + + tail = io_sq->tail; + + pr_debug("write submission queue doorbell for queue: %d tail: %d\n", + io_sq->qid, tail); + + writel_relaxed(tail, io_sq->db_addr); return 0; } diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index 6975150..0530201 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -556,7 +556,7 @@ static int ena_refill_rx_bufs(struct ena_ring *rx_ring, u32 num) * issue a doorbell */ wmb(); - ena_com_write_sq_doorbell(rx_ring->ena_com_io_sq); + ena_com_write_sq_doorbell(rx_ring->ena_com_io_sq, true); } rx_ring->next_to_use = next_to_use; @@ -2151,7 +2151,7 @@ static netdev_tx_t ena_start_xmit(struct sk_buff *skb, struct net_device *dev) if (netif_xmit_stopped(txq) || !skb->xmit_more) { /* trigger the dma engine */ - ena_com_write_sq_doorbell(tx_ring->ena_com_io_sq); + ena_com_write_sq_doorbell(tx_ring->ena_com_io_sq, false); u64_stats_update_begin(&tx_ring->syncp); tx_ring->tx_stats.doorbells++; u64_stats_update_end(&tx_ring->syncp); -- 2.7.4