Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3019829rwb; Thu, 29 Sep 2022 19:31:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7c8nkopkdEtoY3/fxzhUiJdlGdbU4OmdoxhdQ+m079Z7Vqwokrb61JXwtn33K//TIL9C58 X-Received: by 2002:a17:90b:4f91:b0:205:edc8:4ae with SMTP id qe17-20020a17090b4f9100b00205edc804aemr13381944pjb.110.1664505106638; Thu, 29 Sep 2022 19:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664505106; cv=none; d=google.com; s=arc-20160816; b=AbYrXUWrJBjRAdJ6jDZzqOrzb39GFDmO5/aPXXaZhPpOJJjUrD/J8Opg0A6eLoS4KU fTDjXB2eGGrT/CtSWdNsguY6/q0Ons4dMHPz+cSw0DtLYf9Q8mGiWIqt+mdK7XlFBKIZ DAKM7OuX+JPdNvgozYRrUXgl+ZftlxKQVla6vFJtCwYgJUyJPckPid9TUKCAX3otgslu uWnYVWrjJiId7vkgLMerYfA7ASdssdlgAnqU7CsIRi5rx9DuMcpS1C3q36FCN30CZNHS 8py66Hruz5eRz/y/1F0tGqALWqgx6X/bMLIhwHENPxxQ2btYNJi+U68kacPqdTTZwss9 EnGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:dkim-signature; bh=xQ1vcv44R7M+xHLcM3UdCcUJ0FmpQ9/QA/hIJR+H2UA=; b=zLmL7LgYL9ajkMatCzOnfYndoaYtytGG1dhO+nOwGqbnQ0YK3oTB63PFT869njJShf 8KiFq8FBHUA8ErkBnYA85QUrB/Omc2GthXUG/pAgAmcbc2jhBwPoKQ916uCS/jaUdux2 S4qv/ey624zHEO5acvYG6kdW8wjk93cRQaSMf1STGErdg49mdT4q1e4+cTDZYIZYp/PI pVrhaF0y8nXHd5qnPa4iLj7TOUXh8YRGafX1ogdtuKv6GWX9zTNUA3umovY5E+bqKMnl L7Pt1Vdb4haFxk1i/V2CuzRs4kE/WcbD7jXyGQlmgDaORrArAQVVEdG+fr9ugS+uiCbF MOww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=tsMpAMYS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f4-20020a170902ce8400b001768876fc87si1934373plg.362.2022.09.29.19.31.29; Thu, 29 Sep 2022 19:31:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=tsMpAMYS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230104AbiI3CKi (ORCPT + 99 others); Thu, 29 Sep 2022 22:10:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbiI3CKf (ORCPT ); Thu, 29 Sep 2022 22:10:35 -0400 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CFF951418 for ; Thu, 29 Sep 2022 19:10:34 -0700 (PDT) Received: by mail-qk1-x72a.google.com with SMTP id k12so2031167qkj.8 for ; Thu, 29 Sep 2022 19:10:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date; bh=xQ1vcv44R7M+xHLcM3UdCcUJ0FmpQ9/QA/hIJR+H2UA=; b=tsMpAMYS9T/aBHCdNULlb4symf7nV2a0qI4uulrb83mI810ItUZOcxgQUmMLsIflWd gIn6QpROC4rtwYoF+fiE7XNB12Uc7sDypXc2V2jPO6+MhbXIoKRCkSZk81T63IiXMF/V nBRElBBq86G8iMEReqfWz+JUsgFXUSwsDpBAg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date; bh=xQ1vcv44R7M+xHLcM3UdCcUJ0FmpQ9/QA/hIJR+H2UA=; b=ydaI06QbaQ3siDgYV4Tt8aTheWE/pWuG0HcVj/4uNALX4x9gCWCRSK4/meow2Kf3dO Hi/AGFy0tVtGlv/7nu81e74faiQ+OeaZ9LKKougV1meC2FEwES6VNZ/MujqI7CgjOQlc byY9ZhmlqOEz7ma5ZUbUQzGWe3fA5k0sb+sqEyxIF0PgOYjmjvr9pt5SIaWkHz60eSav 4Z4ywzqkF+ZxYZ3lquYPag41P6Ss8IlhuFoBNtGi8Ma+/0Xt6vGwCncnI26mEZu8pQ+y T2e0ZfuoNIgoGqti95jC6u7NGRFleTqzwNFPgoKGYlSGsbnmxtBWGvY7OT9zJAFqmU3n 1OxA== X-Gm-Message-State: ACrzQf242YsAUI3pCNUB8QUEz/3lw3JJbHoACC2OzPPdz+lxx56Y0K1L E+RNKgY5EuZ2eM75z3dDfBLp2Q== X-Received: by 2002:a37:686:0:b0:6ce:3883:5ec7 with SMTP id 128-20020a370686000000b006ce38835ec7mr4471547qkg.301.1664503833083; Thu, 29 Sep 2022 19:10:33 -0700 (PDT) Received: from smtpclient.apple (c-73-148-104-166.hsd1.va.comcast.net. [73.148.104.166]) by smtp.gmail.com with ESMTPSA id dt35-20020a05620a47a300b006ce3cffa2c8sm1095285qkb.43.2022.09.29.19.10.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Sep 2022 19:10:32 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Joel Fernandes Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v1] locking/memory-barriers.txt: Improve documentation for writel() usage Date: Thu, 29 Sep 2022 22:10:31 -0400 Message-Id: References: <20220930020355.98534-1-parav@nvidia.com> Cc: bagasdotme@gmail.com, arnd@arndb.de, stern@rowland.harvard.edu, parri.andrea@gmail.com, will@kernel.org, peterz@infradead.org, boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, paulmck@kernel.org, akiyks@gmail.com, dlustig@nvidia.com, corbet@lwn.net, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org In-Reply-To: <20220930020355.98534-1-parav@nvidia.com> To: Parav Pandit X-Mailer: iPhone Mail (19G82) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, > On Sep 29, 2022, at 10:04 PM, Parav Pandit wrote: >=20 > =EF=BB=BFThe cited commit describes that when using writel(), explcit wmb(= ) > is not needed. wmb() is an expensive barrier. writel() uses the needed > I/O barrier instead of expensive wmb(). Because you mentioned it in the commit message, Why not mention in the docum= entation text as well that writel() has the needed I/O barrier in it? >=20 > Hence update the example to be more accurate that matches the current > implementation. That would make it more accurate, since accuracy is your goal. thanks, - Joel >=20 > commit 5846581e3563 ("locking/memory-barriers.txt: Fix broken DMA vs. MMIO= ordering example") > Signed-off-by: Parav Pandit >=20 > --- > changelog: > v0->v1: > - Corrected to mention I/O barrier instead of dma_wmb(). > - removed numbered references in commit log > - corrected typo 'explcit' to 'explicit' in commit log > --- > Documentation/memory-barriers.txt | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) >=20 > diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barr= iers.txt > index 832b5d36e279..2d77a7411e52 100644 > --- a/Documentation/memory-barriers.txt > +++ b/Documentation/memory-barriers.txt > @@ -1927,10 +1927,11 @@ There are some more advanced barrier functions: > before we read the data from the descriptor, and the dma_wmb() allows= > us to guarantee the data is written to the descriptor before the devi= ce > can see it now has ownership. The dma_mb() implies both a dma_rmb() a= nd > - a dma_wmb(). Note that, when using writel(), a prior wmb() is not n= eeded > - to guarantee that the cache coherent memory writes have completed be= fore > - writing to the MMIO region. The cheaper writel_relaxed() does not p= rovide > - this guarantee and must not be used here. > + a dma_wmb(). Note that, when using writel(), a prior I/O barrier is= not > + needed to guarantee that the cache coherent memory writes have compl= eted > + before writing to the MMIO region. The cheaper writel_relaxed() doe= s not > + provide this guarantee and must not be used here. Hence, writeX() is= always > + preferred. >=20 > See the subsection "Kernel I/O barrier effects" for more information o= n > relaxed I/O accessors and the Documentation/core-api/dma-api.rst file= for > --=20 > 2.26.2 >=20