Received: by 10.213.65.68 with SMTP id h4csp535610imn; Tue, 20 Mar 2018 09:03:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELvNmOkpTQ0gZZ8CsegQQDqYemJMXJHgLRBAPYa3tpwyJjVuyUr1TnwR0q6/YvYWmkVuCrmy X-Received: by 10.98.227.16 with SMTP id g16mr5909563pfh.171.1521561836954; Tue, 20 Mar 2018 09:03:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521561836; cv=none; d=google.com; s=arc-20160816; b=oF4VWBd7Z8Nc5cYtJJMc0K+CqoqJCqcSYiwWtMCb/6gbbeH1yGTwGw5Ex1mHpPL3kE 1iztDIeIv3XsFUp8dCXg2I932ehrS9o6qJQh5uivrsLj5wxXEZm0MeBnJ1eqsYX5ij5U rHgNY2WzkAaBFe2q2D72BrwBUDrNRAllAGuVXj+2+Y7OQX7PpecWctN9Kp/8KV4KQ5PC 4Mpid8Y1xzzyqb/4xW8MMThW42zL0ZzSy5gRpLWL1ZSIfvRkmKnrEWMc9bKFCNMbcelu pP/rNZYQ2CsedyRhiv/Fypv86KCdW/GDJLsHmHFv23FweMLC8Ck9ME1JHMHNsZ/WAEOa izvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=AXplICBBx0+zQHcC4elJ69291UeBU/xPRZiOPrrTjtc=; b=qoys2EgMS1lZmW8BhPvj49IxYbh4xcq4MtftWiVsuYeKbRdyLW5PwJv2Akd2bxfmtB LHYVliR1zIs6gMB1ccG6yilq9bO0zGj2W5o5Zh2hQXKc0K6BXveBa+aOHjH5/VWoyXhT XYMDs1JNDrB/V9SEjHwQwfDIwcAf8KyQckIjxBx7C8RIaxFjrDywDx6pnGIWtrCignsW 3fbr8Ol+Vvai8i5kvgazxZGUDxocNGndvKi/a/nx/Kxy7LPOK57NCPA6hscTUQOGeGG2 HqdsImAhRdmQeqsTM681Qo8Ci/e35wh207Ir448HKouFeaBzTNKdwVdpkQ6zgpsgUBZR /o3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=iDBMRmuD; 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 t13si1479321pfa.294.2018.03.20.09.03.31; Tue, 20 Mar 2018 09:03:56 -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=@ziepe.ca header.s=google header.b=iDBMRmuD; 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 S1751701AbeCTQCB (ORCPT + 99 others); Tue, 20 Mar 2018 12:02:01 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:52290 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751320AbeCTQB6 (ORCPT ); Tue, 20 Mar 2018 12:01:58 -0400 Received: by mail-wm0-f66.google.com with SMTP id l9so4491595wmh.2 for ; Tue, 20 Mar 2018 09:01:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=AXplICBBx0+zQHcC4elJ69291UeBU/xPRZiOPrrTjtc=; b=iDBMRmuDcgsXUrK4XTE0t8HgeWE7Hv2xRwnayaSp5X/FkgoqXwfWeZqLgenUGNvvYL G4w5Hxazfl5HRSKWESrLQD3/F1EI2QAINr1bfvmCShjYQC6OdUtss1caVmWlAcak42B5 t9gaAr8ecxTxkgB0enR7ng97SklUJyT2yYbJw7F91sZ+P73jjZ1Esd2+oWCXVGDMzPwI XkI7JjzqCiKY+drcP1QeYNmwoz3Br1vWyX3v9qHM4oinxpgxBTXR4Y4gWR94gdlsc4Xj hsQwGUe8F4ffezxVPSTho7lpnVs+o4TDFBPubm2VWM91apyjU+4JVl/pY5//oTAx67mC vVTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=AXplICBBx0+zQHcC4elJ69291UeBU/xPRZiOPrrTjtc=; b=t0xP3NZU/olaRDmbCQwVnyWCTDWQxrI8CCKUCUJTYKqMmMpQ3fAyDFMSyp5wFd8b21 JYH5JK4jio4pJwCtMomQP1mbWDSUKr91S0Dvd3Sad210wtokcYFw8aT7bQ3tXOm9v2lU mydIJ7Uvp4FxwLqhsyHKPoRycpdtmZZKYqUt89DGvBVx4LLXB3/HiiCuHFrsXWmbxtK4 37BttVznQpq3twNUhh5F1DUazWesxdmefFI8+A1T/pjonLTuRV1p0dTiGJi9pXsscQBz WWI8cSdlm5oUczQNwdyH1xxenMetSroswsoMK8x91V0rrdpSTuqP9MFqf/t6GjpCyOC9 u3MQ== X-Gm-Message-State: AElRT7GaGgNBHB1ryQabYoPA3DO2aNtNEXcbTK3D17752wtFcWfH3ipb Mz71lnrf5G29wYMEVAs869nHP0VkCHM= X-Received: by 10.28.71.67 with SMTP id u64mr156025wma.76.1521561717536; Tue, 20 Mar 2018 09:01:57 -0700 (PDT) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id i44sm1755463wri.23.2018.03.20.09.01.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Mar 2018 09:01:55 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1eyJhv-0006uN-MP; Tue, 20 Mar 2018 10:01:51 -0600 Date: Tue, 20 Mar 2018 10:01:51 -0600 From: Jason Gunthorpe To: Sinan Kaya Cc: linux-rdma@vger.kernel.org, timur@codeaurora.org, sulrich@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Faisal Latif , Doug Ledford , linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 5/6] IB/nes: Eliminate duplicate barriers on weakly-ordered archs Message-ID: <20180320160151.GM19744@ziepe.ca> References: <1521514068-8856-1-git-send-email-okaya@codeaurora.org> <1521514068-8856-6-git-send-email-okaya@codeaurora.org> <20180320145413.GH19744@ziepe.ca> <3b96019a-2b3b-374a-453e-0553fb04c0a7@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3b96019a-2b3b-374a-453e-0553fb04c0a7@codeaurora.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 20, 2018 at 10:23:16AM -0500, Sinan Kaya wrote: > On 3/20/2018 9:54 AM, Jason Gunthorpe wrote: > > On Mon, Mar 19, 2018 at 10:47:47PM -0400, Sinan Kaya wrote: > >> 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(). > >> > >> Signed-off-by: Sinan Kaya > >> drivers/infiniband/hw/nes/nes.h | 5 +++++ > >> drivers/infiniband/hw/nes/nes_hw.c | 21 ++++++++++++++------- > >> drivers/infiniband/hw/nes/nes_mgt.c | 15 ++++++++++----- > >> drivers/infiniband/hw/nes/nes_nic.c | 2 +- > >> drivers/infiniband/hw/nes/nes_utils.c | 3 ++- > >> drivers/infiniband/hw/nes/nes_verbs.c | 5 +++-- > >> 6 files changed, 35 insertions(+), 16 deletions(-) > >> > >> diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h > >> index 00c27291..85e007d 100644 > >> +++ b/drivers/infiniband/hw/nes/nes.h > >> @@ -387,6 +387,11 @@ static inline void nes_write_indexed(struct nes_device *nesdev, u32 reg_index, u > >> spin_unlock_irqrestore(&nesdev->indexed_regs_lock, flags); > >> } > >> > >> +static inline void nes_write32_relaxed(void __iomem *addr, u32 val) > >> +{ > >> + writel_relaxed(val, addr); > >> +} > > > > This wrapper is pointless, let us not add more.. > > > >> static inline void nes_write32(void __iomem *addr, u32 val) > >> { > >> writel(val, addr); > >> diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c > >> index 18a7de1..568e17d 100644 > >> +++ b/drivers/infiniband/hw/nes/nes_hw.c > >> @@ -1257,7 +1257,8 @@ int nes_destroy_cqp(struct nes_device *nesdev) > >> > >> barrier(); > >> /* Ring doorbell (5 WQEs) */ > >> - nes_write32(nesdev->regs+NES_WQE_ALLOC, 0x05800000 | nesdev->cqp.qp_id); > >> + nes_write32_relaxed(nesdev->regs+NES_WQE_ALLOC, > >> + 0x05800000 | nesdev->cqp.qp_id); > > > > barrier() is not strong enough to order writel, so this doesn't seem > > right? > > > > It is probably noteven strong enough for what this driver thinks it is > > doing.. This driver is essentially dead and broken, probably just > > don't change it. > > Just for the sake of other changes in netdev directory and my education... > > barrier() on ARM is a wmb(). It should be a compiler barrier on intel. > > You are saying barrier() should have been a wmb(), right? Yes, that is my understanding.. barrier() is supposed to be a very weak barrier that just ensures the CPU is locally consistent with itself. It doesn't say anything about DMA access, or SMP cases. I don't think it is supposed to order anything related to writel_relaxed() > I have gone through similar exercise on netdev directory and changed > > barrier() > writel() > > to > > barrier() > writel_relaxed() > > Do you see any problem with this? Seems dangerous as a mechanical change to me, it really depends on why the driver author put barrier() there. In this case, I strongly suspect nes really intended to say wmb() Jason