From: "Arnd Bergmann" <arnd@arndb.de>
To: "Parav Pandit" <parav@nvidia.com>,
"stern@rowland.harvard.edu" <stern@rowland.harvard.edu>,
"parri.andrea@gmail.com" <parri.andrea@gmail.com>,
"Will Deacon" <will@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"boqun.feng@gmail.com" <boqun.feng@gmail.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
"dhowells@redhat.com" <dhowells@redhat.com>,
"j.alglave@ucl.ac.uk" <j.alglave@ucl.ac.uk>,
"luc.maranget@inria.fr" <luc.maranget@inria.fr>,
"Paul E. McKenney" <paulmck@kernel.org>,
"akiyks@gmail.com" <akiyks@gmail.com>,
"Dan Lustig" <dlustig@nvidia.com>,
"joel@joelfernandes.org" <joel@joelfernandes.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Linux-Arch <linux-arch@vger.kernel.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>
Subject: Re: [PATCH] locking/memory-barriers.txt: Improve documentation for writel() usage
Date: Thu, 15 Sep 2022 17:16:24 +0200 [thread overview]
Message-ID: <a8ee97f5-b92f-47a6-9b50-197974738ff7@www.fastmail.com> (raw)
In-Reply-To: <PH0PR12MB5481192DB7B5C6E19683D514DC499@PH0PR12MB5481.namprd12.prod.outlook.com>
On Thu, Sep 15, 2022, at 4:18 PM, Parav Pandit wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>> Sent: Thursday, September 15, 2022 8:38 AM
>>
>> On Thu, Sep 15, 2022, at 7:01 AM, Parav Pandit wrote:
>> > The cited commit [1] describes that when using writel(), explcit wmb()
>> > is not needed. However, it should have said that dma_wmb() is not
>> > needed.
>>
>> Are you sure? As I understand it, the dma_wmb() only serializes a set of
>> memory accesses, but does not serialized against an MMIO access, which
>> depending on the CPU architecture may require a different type of barrier.
>>
>> E.g. on arm, writel() uses __iowmb(), which like wmb() is defined as "dsb(x);
>> arm_heavy_mb();", while dma_wmb() is a "dmb(oshst)".
>
> You are right, on arm heavy barrier dsb() is needed, while on arm64,
> dmb(oshst) is sufficient.
>
> So more accurate documentation is to say that
> 'when using writel() a prior IO barrier is not needed ...'
>
> How about that?
That's probably fine, not sure if it's worth changing.
> It started with my cleanup efforts to two drivers [1] and [2] that had
> difficulty in using writel() on 32-bit system, and it ended up open
> coding writel() as wmb() + mlx5_write64().
>
> I am cleaning up the repetitive pattern of,
> wmb();
> mlx5_write64()
>
> Before I fix drivers, I thought to improve the documentation that I can
> follow. :)
Right, that is definitely a good idea.
I see that there is more going on with that function, at least
the loop in post_send_nop() probably just wants to use
__iowrite64_copy(), but that also has no barrier in it, while
changing mlx5_write64() to use iowrite64be() or similar would
of course add excessive barriers inside of the loop.
Arnd
next prev parent reply other threads:[~2022-09-15 15:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-15 5:01 Parav Pandit
2022-09-15 12:16 ` Bagas Sanjaya
2022-09-15 12:35 ` Parav Pandit
2022-09-15 12:37 ` Arnd Bergmann
2022-09-15 14:18 ` Parav Pandit
2022-09-15 15:16 ` Arnd Bergmann [this message]
2022-09-15 16:35 ` Parav Pandit
2022-09-15 18:38 ` Arnd Bergmann
2022-09-23 15:55 ` Parav Pandit
2022-09-23 18:40 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a8ee97f5-b92f-47a6-9b50-197974738ff7@www.fastmail.com \
--to=arnd@arndb.de \
--cc=akiyks@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=corbet@lwn.net \
--cc=dhowells@redhat.com \
--cc=dlustig@nvidia.com \
--cc=j.alglave@ucl.ac.uk \
--cc=joel@joelfernandes.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luc.maranget@inria.fr \
--cc=npiggin@gmail.com \
--cc=parav@nvidia.com \
--cc=parri.andrea@gmail.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=stern@rowland.harvard.edu \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®