linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Will Deacon <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: hpa@zytor.com, mingo@kernel.org, linux-kernel@vger.kernel.org,
	akpm@linux-foundation.org, corbet@lwn.net, arnd@arndb.de,
	okaya@codeaurora.org, benh@kernel.crashing.org,
	peterz@infradead.org, paulmck@linux.vnet.ibm.com,
	torvalds@linux-foundation.org, jgg@ziepe.ca, will.deacon@arm.com,
	tglx@linutronix.de
Subject: [tip:locking/core] locking/memory-barriers.txt: Fix broken DMA vs. MMIO ordering example
Date: Mon, 14 May 2018 23:21:46 -0700	[thread overview]
Message-ID: <tip-5846581e35637771952602eecc1e20ece5ced011@git.kernel.org> (raw)
In-Reply-To: <1526338533-6044-1-git-send-email-paulmck@linux.vnet.ibm.com>

Commit-ID:  5846581e35637771952602eecc1e20ece5ced011
Gitweb:     https://git.kernel.org/tip/5846581e35637771952602eecc1e20ece5ced011
Author:     Will Deacon <will.deacon@arm.com>
AuthorDate: Mon, 14 May 2018 15:55:26 -0700
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 15 May 2018 08:11:13 +0200

locking/memory-barriers.txt: Fix broken DMA vs. MMIO ordering example

The section of memory-barriers.txt that describes the dma_Xmb() barriers
has an incorrect example claiming that a wmb() is required after writing
to coherent memory in order for those writes to be visible to a device
before a subsequent MMIO access using writel() can reach the device.

In fact, this ordering guarantee is provided (at significant cost on some
architectures such as arm and power) by writel, so the wmb() is not
necessary. writel_relaxed exists for cases where this ordering is not
required.

Fix the example and update the text to make this clearer.

Reported-by: Sinan Kaya <okaya@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: akiyks@gmail.com
Cc: boqun.feng@gmail.com
Cc: dhowells@redhat.com
Cc: j.alglave@ucl.ac.uk
Cc: linux-arch@vger.kernel.org
Cc: luc.maranget@inria.fr
Cc: npiggin@gmail.com
Cc: parri.andrea@gmail.com
Cc: stern@rowland.harvard.edu
Link: http://lkml.kernel.org/r/1526338533-6044-1-git-send-email-paulmck@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 Documentation/memory-barriers.txt | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
index 6dafc8085acc..34c1970908a5 100644
--- a/Documentation/memory-barriers.txt
+++ b/Documentation/memory-barriers.txt
@@ -1920,9 +1920,6 @@ There are some more advanced barrier functions:
 		/* assign ownership */
 		desc->status = DEVICE_OWN;
 
-		/* force memory to sync before notifying device via MMIO */
-		wmb();
-
 		/* notify device of new descriptors */
 		writel(DESC_NOTIFY, doorbell);
 	}
@@ -1930,11 +1927,15 @@ There are some more advanced barrier functions:
      The dma_rmb() allows us guarantee the device has released ownership
      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 device
-     can see it now has ownership.  The wmb() is needed to guarantee that the
-     cache coherent memory writes have completed before attempting a write to
-     the cache incoherent MMIO region.
-
-     See Documentation/DMA-API.txt for more information on consistent memory.
+     can see it now has ownership.  Note that, when using writel(), a prior
+     wmb() is not needed to guarantee that the cache coherent memory writes
+     have completed before writing to the MMIO region.  The cheaper
+     writel_relaxed() does not provide this guarantee and must not be used
+     here.
+
+     See the subsection "Kernel I/O barrier effects" for more information on
+     relaxed I/O accessors and the Documentation/DMA-API.txt file for more
+     information on consistent memory.
 
 
 MMIO WRITE BARRIER

  reply	other threads:[~2018-05-15  6:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-14 22:54 [PATCH memory-model 0/8] memory-barriers.txt and atomic_ops.rst updates Paul E. McKenney
2018-05-14 22:55 ` [PATCH memory-model 1/8] docs/memory-barriers.txt: Fix broken DMA vs MMIO ordering example Paul E. McKenney
2018-05-15  6:21   ` tip-bot for Will Deacon [this message]
2018-05-14 22:55 ` [PATCH memory-model 2/8] kokr/doc: READ_ONCE() now implies smp_barrier_depends() Paul E. McKenney
2018-05-15  6:22   ` [tip:locking/core] locking/memory-barriers.txt/kokr: Update Korean translation to indicate that " tip-bot for SeongJae Park
2018-05-14 22:55 ` [PATCH memory-model 3/8] kokr/doc: De-emphasize smp_read_barrier_depends Paul E. McKenney
2018-05-15  6:22   ` [tip:locking/core] locking/memory-barriers.txt/kokr: Update Korean translation to de-emphasize smp_read_barrier_depends() tip-bot for SeongJae Park
2018-05-14 22:55 ` [PATCH memory-model 4/8] kokr/Documentation/memory-barriers.txt: Cross-reference "tools/memory-model/" Paul E. McKenney
2018-05-15  6:23   ` [tip:locking/core] locking/memory-barriers.txt/kokr: Update Korean translation to cross-reference "tools/memory-model/" tip-bot for SeongJae Park
2018-05-14 22:55 ` [PATCH memory-model 5/8] kokr/memory-barriers: Fix description of data dependency barriers Paul E. McKenney
2018-05-15  6:23   ` [tip:locking/core] locking/memory-barriers.txt/kokr: Update Korean translation to fix " tip-bot for SeongJae Park
2018-05-14 22:55 ` [PATCH memory-model 6/8] kokr/locking/memory-barriers: De-emphasize smp_read_barrier_depends() some more Paul E. McKenney
2018-05-15  6:24   ` [tip:locking/core] locking/memory-barriers.txt/kokr: Update Korean translation to de-emphasize " tip-bot for SeongJae Park
2018-05-14 22:55 ` [PATCH memory-model 7/8] atomic_ops.rst: Fix wrong example code Paul E. McKenney
2018-05-15  6:24   ` [tip:locking/core] locking/Documentation: Fix incorrect " tip-bot for SeongJae Park
2018-05-14 22:55 ` [PATCH memory-model 8/8] atomic_ops.rst: Use `warning` rst directive Paul E. McKenney
2018-05-15  6:25   ` [tip:locking/core] locking/Documentation: Use `warning` RST directive tip-bot for SeongJae Park

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=tip-5846581e35637771952602eecc1e20ece5ced011@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=benh@kernel.crashing.org \
    --cc=corbet@lwn.net \
    --cc=hpa@zytor.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=okaya@codeaurora.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=will.deacon@arm.com \
    /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;
as well as URLs for NNTP newsgroup(s).