diff options
Diffstat (limited to 'Documentation/DMA-mapping.txt')
-rw-r--r-- | Documentation/DMA-mapping.txt | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/Documentation/DMA-mapping.txt b/Documentation/DMA-mapping.txt index ee4bb73683cd..7c717699032c 100644 --- a/Documentation/DMA-mapping.txt +++ b/Documentation/DMA-mapping.txt | |||
@@ -58,11 +58,15 @@ translating each of those pages back to a kernel address using | |||
58 | something like __va(). [ EDIT: Update this when we integrate | 58 | something like __va(). [ EDIT: Update this when we integrate |
59 | Gerd Knorr's generic code which does this. ] | 59 | Gerd Knorr's generic code which does this. ] |
60 | 60 | ||
61 | This rule also means that you may not use kernel image addresses | 61 | This rule also means that you may use neither kernel image addresses |
62 | (ie. items in the kernel's data/text/bss segment, or your driver's) | 62 | (items in data/text/bss segments), nor module image addresses, nor |
63 | nor may you use kernel stack addresses for DMA. Both of these items | 63 | stack addresses for DMA. These could all be mapped somewhere entirely |
64 | might be mapped somewhere entirely different than the rest of physical | 64 | different than the rest of physical memory. Even if those classes of |
65 | memory. | 65 | memory could physically work with DMA, you'd need to ensure the I/O |
66 | buffers were cacheline-aligned. Without that, you'd see cacheline | ||
67 | sharing problems (data corruption) on CPUs with DMA-incoherent caches. | ||
68 | (The CPU could write to one word, DMA would write to a different one | ||
69 | in the same cache line, and one of them could be overwritten.) | ||
66 | 70 | ||
67 | Also, this means that you cannot take the return of a kmap() | 71 | Also, this means that you cannot take the return of a kmap() |
68 | call and DMA to/from that. This is similar to vmalloc(). | 72 | call and DMA to/from that. This is similar to vmalloc(). |
@@ -194,7 +198,7 @@ document for how to handle this case. | |||
194 | Finally, if your device can only drive the low 24-bits of | 198 | Finally, if your device can only drive the low 24-bits of |
195 | address during PCI bus mastering you might do something like: | 199 | address during PCI bus mastering you might do something like: |
196 | 200 | ||
197 | if (pci_set_dma_mask(pdev, 0x00ffffff)) { | 201 | if (pci_set_dma_mask(pdev, DMA_24BIT_MASK)) { |
198 | printk(KERN_WARNING | 202 | printk(KERN_WARNING |
199 | "mydev: 24-bit DMA addressing not available.\n"); | 203 | "mydev: 24-bit DMA addressing not available.\n"); |
200 | goto ignore_this_device; | 204 | goto ignore_this_device; |
@@ -212,7 +216,7 @@ functions (for example a sound card provides playback and record | |||
212 | functions) and the various different functions have _different_ | 216 | functions) and the various different functions have _different_ |
213 | DMA addressing limitations, you may wish to probe each mask and | 217 | DMA addressing limitations, you may wish to probe each mask and |
214 | only provide the functionality which the machine can handle. It | 218 | only provide the functionality which the machine can handle. It |
215 | is important that the last call to pci_set_dma_mask() be for the | 219 | is important that the last call to pci_set_dma_mask() be for the |
216 | most specific mask. | 220 | most specific mask. |
217 | 221 | ||
218 | Here is pseudo-code showing how this might be done: | 222 | Here is pseudo-code showing how this might be done: |
@@ -284,6 +288,11 @@ There are two types of DMA mappings: | |||
284 | 288 | ||
285 | in order to get correct behavior on all platforms. | 289 | in order to get correct behavior on all platforms. |
286 | 290 | ||
291 | Also, on some platforms your driver may need to flush CPU write | ||
292 | buffers in much the same way as it needs to flush write buffers | ||
293 | found in PCI bridges (such as by reading a register's value | ||
294 | after writing it). | ||
295 | |||
287 | - Streaming DMA mappings which are usually mapped for one DMA transfer, | 296 | - Streaming DMA mappings which are usually mapped for one DMA transfer, |
288 | unmapped right after it (unless you use pci_dma_sync_* below) and for which | 297 | unmapped right after it (unless you use pci_dma_sync_* below) and for which |
289 | hardware can optimize for sequential accesses. | 298 | hardware can optimize for sequential accesses. |
@@ -303,6 +312,9 @@ There are two types of DMA mappings: | |||
303 | 312 | ||
304 | Neither type of DMA mapping has alignment restrictions that come | 313 | Neither type of DMA mapping has alignment restrictions that come |
305 | from PCI, although some devices may have such restrictions. | 314 | from PCI, although some devices may have such restrictions. |
315 | Also, systems with caches that aren't DMA-coherent will work better | ||
316 | when the underlying buffers don't share cache lines with other data. | ||
317 | |||
306 | 318 | ||
307 | Using Consistent DMA mappings. | 319 | Using Consistent DMA mappings. |
308 | 320 | ||