Skip to content

Commit 289e1c8

Browse files
paravmellanoxpaulmckrcu
authored andcommitted
locking/memory-barriers.txt: Improve documentation for writel() example
The cited commit describes that when using writel(), explicit wmb() is not needed. wmb() is an expensive barrier. writel() uses the needed platform specific barrier instead of wmb(). writeX() section of "KERNEL I/O BARRIER EFFECTS" already describes ordering of I/O accessors with MMIO writes. Hence add the comment for pseudo code of writel() and remove confusing text around writel() and wmb(). commit 5846581 ("locking/memory-barriers.txt: Fix broken DMA vs. MMIO ordering example") Co-developed-by: Will Deacon <[email protected]> Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Parav Pandit <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 1b929c0 commit 289e1c8

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Documentation/memory-barriers.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,7 +1910,8 @@ There are some more advanced barrier functions:
19101910

19111911
These are for use with consistent memory to guarantee the ordering
19121912
of writes or reads of shared memory accessible to both the CPU and a
1913-
DMA capable device.
1913+
DMA capable device. See Documentation/core-api/dma-api.rst file for more
1914+
information about consistent memory.
19141915

19151916
For example, consider a device driver that shares memory with a device
19161917
and uses a descriptor status value to indicate if the descriptor belongs
@@ -1931,22 +1932,21 @@ There are some more advanced barrier functions:
19311932
/* assign ownership */
19321933
desc->status = DEVICE_OWN;
19331934

1934-
/* notify device of new descriptors */
1935+
/* Make descriptor status visible to the device followed by
1936+
* notify device of new descriptor
1937+
*/
19351938
writel(DESC_NOTIFY, doorbell);
19361939
}
19371940

1938-
The dma_rmb() allows us guarantee the device has released ownership
1941+
The dma_rmb() allows us to guarantee that the device has released ownership
19391942
before we read the data from the descriptor, and the dma_wmb() allows
19401943
us to guarantee the data is written to the descriptor before the device
19411944
can see it now has ownership. The dma_mb() implies both a dma_rmb() and
1942-
a dma_wmb(). Note that, when using writel(), a prior wmb() is not needed
1943-
to guarantee that the cache coherent memory writes have completed before
1944-
writing to the MMIO region. The cheaper writel_relaxed() does not provide
1945-
this guarantee and must not be used here.
1946-
1947-
See the subsection "Kernel I/O barrier effects" for more information on
1948-
relaxed I/O accessors and the Documentation/core-api/dma-api.rst file for
1949-
more information on consistent memory.
1945+
a dma_wmb().
1946+
1947+
Note that the dma_*() barriers do not provide any ordering guarantees for
1948+
accesses to MMIO regions. See the later "KERNEL I/O BARRIER EFFECTS"
1949+
subsection for more information about I/O accessors and MMIO ordering.
19501950

19511951
(*) pmem_wmb();
19521952

0 commit comments

Comments
 (0)