Skip to content

Commit

Permalink
Merge tag 'standardize-docs' of git://git.lwn.net/linux
Browse files Browse the repository at this point in the history
Pull documentation format standardization from Jonathan Corbet:
 "This series converts a number of top-level documents to the RST format
  without incorporating them into the Sphinx tree. The hope is to bring
  some uniformity to kernel documentation and, perhaps more importantly,
  have our existing docs serve as an example of the desired formatting
  for those that will be added later.

  Mauro has gone through and fixed up a lot of top-level documentation
  files to make them conform to the RST format, but without moving or
  renaming them in any way. This will help when we incorporate the ones
  we want to keep into the Sphinx doctree, but the real purpose is to
  bring a bit of uniformity to our documentation and let the top-level
  docs serve as examples for those writing new ones"

* tag 'standardize-docs' of git://git.lwn.net/linux: (84 commits)
  docs: kprobes.txt: Fix whitespacing
  tee.txt: standardize document format
  cgroup-v2.txt: standardize document format
  dell_rbu.txt: standardize document format
  zorro.txt: standardize document format
  xz.txt: standardize document format
  xillybus.txt: standardize document format
  vfio.txt: standardize document format
  vfio-mediated-device.txt: standardize document format
  unaligned-memory-access.txt: standardize document format
  this_cpu_ops.txt: standardize document format
  svga.txt: standardize document format
  static-keys.txt: standardize document format
  smsc_ece1099.txt: standardize document format
  SM501.txt: standardize document format
  siphash.txt: standardize document format
  sgi-ioc4.txt: standardize document format
  SAK.txt: standardize document format
  rpmsg.txt: standardize document format
  robust-futexes.txt: standardize document format
  ...
  • Loading branch information
torvalds committed Jul 15, 2017
2 parents 52f6c58 + 43e5f7e commit 486088b
Show file tree
Hide file tree
Showing 81 changed files with 6,263 additions and 4,731 deletions.
153 changes: 88 additions & 65 deletions Documentation/DMA-API-HOWTO.txt

Large diffs are not rendered by default.

580 changes: 329 additions & 251 deletions Documentation/DMA-API.txt

Large diffs are not rendered by default.

71 changes: 36 additions & 35 deletions Documentation/DMA-ISA-LPC.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
DMA with ISA and LPC devices
============================
============================
DMA with ISA and LPC devices
============================

Pierre Ossman <[email protected]>
:Author: Pierre Ossman <[email protected]>

This document describes how to do DMA transfers using the old ISA DMA
controller. Even though ISA is more or less dead today the LPC bus
uses the same DMA system so it will be around for quite some time.

Part I - Headers and dependencies
---------------------------------
Headers and dependencies
------------------------

To do ISA style DMA you need to include two headers:
To do ISA style DMA you need to include two headers::

#include <linux/dma-mapping.h>
#include <asm/dma.h>
#include <linux/dma-mapping.h>
#include <asm/dma.h>

The first is the generic DMA API used to convert virtual addresses to
bus addresses (see Documentation/DMA-API.txt for details).
Expand All @@ -23,8 +24,8 @@ this is not present on all platforms make sure you construct your
Kconfig to be dependent on ISA_DMA_API (not ISA) so that nobody tries
to build your driver on unsupported platforms.

Part II - Buffer allocation
---------------------------
Buffer allocation
-----------------

The ISA DMA controller has some very strict requirements on which
memory it can access so extra care must be taken when allocating
Expand All @@ -47,8 +48,8 @@ __GFP_RETRY_MAYFAIL and __GFP_NOWARN to make the allocator try a bit harder.
(This scarcity also means that you should allocate the buffer as
early as possible and not release it until the driver is unloaded.)

Part III - Address translation
------------------------------
Address translation
-------------------

To translate the virtual address to a bus address, use the normal DMA
API. Do _not_ use isa_virt_to_phys() even though it does the same
Expand All @@ -61,8 +62,8 @@ Note: x86_64 had a broken DMA API when it came to ISA but has since
been fixed. If your arch has problems then fix the DMA API instead of
reverting to the ISA functions.

Part IV - Channels
------------------
Channels
--------

A normal ISA DMA controller has 8 channels. The lower four are for
8-bit transfers and the upper four are for 16-bit transfers.
Expand All @@ -80,8 +81,8 @@ The ability to use 16-bit or 8-bit transfers is _not_ up to you as a
driver author but depends on what the hardware supports. Check your
specs or test different channels.

Part V - Transfer data
----------------------
Transfer data
-------------

Now for the good stuff, the actual DMA transfer. :)

Expand Down Expand Up @@ -112,37 +113,37 @@ Once the DMA transfer is finished (or timed out) you should disable
the channel again. You should also check get_dma_residue() to make
sure that all data has been transferred.

Example:
Example::

int flags, residue;
int flags, residue;

flags = claim_dma_lock();
flags = claim_dma_lock();

clear_dma_ff();
clear_dma_ff();

set_dma_mode(channel, DMA_MODE_WRITE);
set_dma_addr(channel, phys_addr);
set_dma_count(channel, num_bytes);
set_dma_mode(channel, DMA_MODE_WRITE);
set_dma_addr(channel, phys_addr);
set_dma_count(channel, num_bytes);

dma_enable(channel);
dma_enable(channel);

release_dma_lock(flags);
release_dma_lock(flags);

while (!device_done());
while (!device_done());

flags = claim_dma_lock();
flags = claim_dma_lock();

dma_disable(channel);
dma_disable(channel);

residue = dma_get_residue(channel);
if (residue != 0)
printk(KERN_ERR "driver: Incomplete DMA transfer!"
" %d bytes left!\n", residue);
residue = dma_get_residue(channel);
if (residue != 0)
printk(KERN_ERR "driver: Incomplete DMA transfer!"
" %d bytes left!\n", residue);

release_dma_lock(flags);
release_dma_lock(flags);

Part VI - Suspend/resume
------------------------
Suspend/resume
--------------

It is the driver's responsibility to make sure that the machine isn't
suspended while a DMA transfer is in progress. Also, all DMA settings
Expand Down
15 changes: 9 additions & 6 deletions Documentation/DMA-attributes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
DMA attributes
==============
==============
DMA attributes
==============

This document describes the semantics of the DMA attributes that are
defined in linux/dma-mapping.h.
Expand Down Expand Up @@ -108,6 +109,7 @@ This is a hint to the DMA-mapping subsystem that it's probably not worth
the time to try to allocate memory to in a way that gives better TLB
efficiency (AKA it's not worth trying to build the mapping out of larger
pages). You might want to specify this if:

- You know that the accesses to this memory won't thrash the TLB.
You might know that the accesses are likely to be sequential or
that they aren't sequential but it's unlikely you'll ping-pong
Expand All @@ -121,11 +123,12 @@ pages). You might want to specify this if:
the mapping to have a short lifetime then it may be worth it to
optimize allocation (avoid coming up with large pages) instead of
getting the slight performance win of larger pages.

Setting this hint doesn't guarantee that you won't get huge pages, but it
means that we won't try quite as hard to get them.

NOTE: At the moment DMA_ATTR_ALLOC_SINGLE_PAGES is only implemented on ARM,
though ARM64 patches will likely be posted soon.
.. note:: At the moment DMA_ATTR_ALLOC_SINGLE_PAGES is only implemented on ARM,
though ARM64 patches will likely be posted soon.

DMA_ATTR_NO_WARN
----------------
Expand All @@ -142,10 +145,10 @@ problem at all, depending on the implementation of the retry mechanism.
So, this provides a way for drivers to avoid those error messages on calls
where allocation failures are not a problem, and shouldn't bother the logs.

NOTE: At the moment DMA_ATTR_NO_WARN is only implemented on PowerPC.
.. note:: At the moment DMA_ATTR_NO_WARN is only implemented on PowerPC.

DMA_ATTR_PRIVILEGED
------------------------------
-------------------

Some advanced peripherals such as remote processors and GPUs perform
accesses to DMA buffers in both privileged "supervisor" and unprivileged
Expand Down
Loading

0 comments on commit 486088b

Please sign in to comment.