Lines Matching refs:DMA
1 Dynamic DMA mapping Guide
8 This is a guide to device driver writers on how to use the DMA API
10 DMA-API.txt.
12 CPU and DMA addresses
14 There are several kinds of addresses involved in the DMA API, and it's
29 registers at an MMIO address, or if it performs DMA to read or write system
35 From a device's point of view, DMA uses the bus address space, but it may
38 so devices only need to use 32-bit DMA addresses.
73 If the device supports DMA, the driver sets up a buffer using kmalloc() or
77 cannot because DMA doesn't go through the CPU virtual memory system.
79 In some simple systems, the device can do DMA directly to physical address
80 Y. But in many others, there is IOMMU hardware that translates DMA
82 of the reason for the DMA API: the driver can give a virtual address X to
84 mapping and returns the DMA address Z. The driver then tells the device to
85 do DMA to Z, and the IOMMU maps it to the buffer at address Y in system
88 So that Linux can use the dynamic DMA mapping, it needs some help from the
89 drivers, namely it has to take into account that DMA addresses should be
90 mapped only for the time they are actually used and unmapped after the DMA
96 Note that the DMA API works with any bus independent of the underlying
97 microprocessor architecture. You should use the DMA API rather than the
98 bus-specific DMA API, i.e., use the dma_map_*() interfaces rather than the
106 can hold any valid DMA address for the platform and should be used
107 everywhere you hold a DMA address returned from the DMA mapping functions.
109 What memory is DMA'able?
112 be used with the DMA mapping facilities. There has been an unwritten
118 (i.e. kmalloc() or kmem_cache_alloc()) then you may DMA to/from
122 returned from vmalloc() for DMA. It is possible to DMA to the
131 stack addresses for DMA. These could all be mapped somewhere entirely
133 memory could physically work with DMA, you'd need to ensure the I/O
135 sharing problems (data corruption) on CPUs with DMA-incoherent caches.
136 (The CPU could write to one word, DMA would write to a different one
140 call and DMA to/from that. This is similar to vmalloc().
144 for you to DMA from/to.
146 DMA addressing limitations
148 Does your device have any DMA addressing limitations? For example, is
163 probe routine to see if the DMA controller on the machine can properly
164 support the DMA addressing limitation your device has. It is good
189 supports. It returns zero if your card can perform DMA properly on
196 If it returns non-zero, your device cannot perform DMA properly on
198 behavior. You must either use a different mask, or not use DMA.
202 1) Use another DMA mask, if possible (see below).
203 2) Use some non-DMA mode for data transfer, if possible.
215 dev_warn(dev, "mydev: No suitable DMA available\n");
228 all 64-bits when accessing streaming DMA:
237 dev_warn(dev, "mydev: No suitable DMA available\n");
253 dev_warn(dev, "mydev: No suitable DMA available\n");
266 dev_warn(dev, "mydev: 24-bit DMA addressing not available\n");
272 kernel will use this information later when you make DMA mappings.
278 DMA addressing limitations, you may wish to probe each mask and
296 dev_warn(dev, "%s: Playback disabled due to DMA limitations\n",
303 dev_warn(dev, "%s: Record disabled due to DMA limitations\n",
309 and thus retaining the 16MB DMA addressing limitations of ISA.
311 Types of DMA mappings
313 There are two types of DMA mappings:
315 - Consistent DMA mappings which are usually mapped at driver
324 bits of the DMA space. However, for future compatibility you should
330 - Network card DMA ring descriptors.
339 IMPORTANT: Consistent DMA memory does not preclude the usage of
357 - Streaming DMA mappings which are usually mapped for one DMA
374 Neither type of DMA mapping has alignment restrictions that come from
376 Also, systems with caches that aren't DMA-coherent will work better
380 Using Consistent DMA mappings.
382 To allocate and map large (PAGE_SIZE or so) consistent DMA regions,
399 The consistent DMA mapping interfaces, for non-NULL dev, will by
400 default return a DMA address which is 32-bit addressable. Even if the
401 device indicates (via DMA mask) that it may address the upper 32-bits,
402 consistent allocation will only return > 32-bit addresses for DMA if
403 the consistent DMA mask has been explicitly changed via
411 The CPU virtual address and the DMA address are both
418 To unmap and free such a DMA region, you call:
447 Allocate memory from a DMA pool like this:
471 DMA Direction
474 take a DMA direction argument, which is an integer and takes on
482 You should provide the exact DMA direction if you know it.
486 It is the direction in which the data moves during the DMA
492 If you absolutely cannot know the direction of the DMA transfer,
493 specify DMA_BIDIRECTIONAL. It means that the DMA can go in
505 Some platforms actually have a write permission boolean which DMA
508 kernel logs when the DMA controller hardware detects violation of the
524 Using Streaming DMA mappings
526 The streaming DMA mapping routines can be called from interrupt
541 * reduce current DMA mapping usage,
553 error. Not all DMA implementations support the dma_mapping_error() interface.
556 that the mapping code will work correctly on all DMA implementations without
560 to check for errors that make assumptions about the underlying DMA
580 You should call dma_unmap_single() when the DMA activity is finished, e.g.,
581 from the interrupt which told you that the DMA transfer is done.
598 * reduce current DMA mapping usage,
614 You should call dma_unmap_page() when the DMA activity is finished, e.g.,
615 from the interrupt which told you that the DMA transfer is done.
630 into one (e.g. if DMA mapping is done with PAGE_SIZE granularity, any
645 Again, make sure DMA activity has already finished.
653 counterpart, because the DMA address space is a shared resource and
654 you could render the machine unusable by consuming all DMA addresses.
656 If you need to use the same streaming DMA region multiple times and touch
657 the data in between the DMA transfers, the buffer needs to be synced
659 correct copy of the DMA buffer.
661 So, firstly, just map it with dma_map_{single,sg}(), and after each DMA
672 Then, if you wish to let the device get at the DMA area again,
684 After the last DMA transfer call one of the DMA unmap routines
699 * reduce current DMA mapping usage,
725 * the DMA transfer with the CPU first
755 dynamic DMA mapping scheme - you have to always store the DMA addresses
758 supports dynamic DMA mapping in hardware) in your driver structures and/or
768 DMA address space is limited on some architectures and an allocation
781 * reduce current DMA mapping usage,
799 * reduce current DMA mapping usage,
808 * reduce current DMA mapping usage,
835 * reduce current DMA mapping usage,
857 and return NETDEV_TX_OK if the DMA mapping fails on the transmit hook
861 SCSI drivers must return SCSI_MLQUEUE_HOST_BUSY if the DMA mapping
937 DMA-safe. Drivers and subsystems depend on it. If an architecture
938 isn't fully DMA-coherent (i.e. hardware doesn't ensure that data in
944 Note that ARCH_DMA_MINALIGN is about DMA memory alignment
953 library to support the DMA API with multiple types of IOMMUs. Lots