ixgbevf: Kconfig, Makefile and Documentation
[safe/jmp/linux-2.6] / Documentation / DMA-mapping.txt
index 6883921..ecad88d 100644 (file)
@@ -26,7 +26,7 @@ mapped only for the time they are actually used and unmapped after the DMA
 transfer.
 
 The following API will work of course even on platforms where no such
-hardware exists, see e.g. include/asm-i386/pci.h for how it is implemented on
+hardware exists, see e.g. arch/x86/include/asm/pci.h for how it is implemented on
 top of the virt_to_bus interface.
 
 First of all, you should make sure
@@ -136,7 +136,7 @@ exactly why.
 The standard 32-bit addressing PCI device would do something like
 this:
 
-       if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
+       if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
                printk(KERN_WARNING
                       "mydev: No suitable DMA available.\n");
                goto ignore_this_device;
@@ -155,9 +155,9 @@ all 64-bits when accessing streaming DMA:
 
        int using_dac;
 
-       if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
+       if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
                using_dac = 1;
-       } else if (!pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
+       } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
                using_dac = 0;
        } else {
                printk(KERN_WARNING
@@ -170,14 +170,14 @@ the case would look like this:
 
        int using_dac, consistent_using_dac;
 
-       if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
+       if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
                using_dac = 1;
                consistent_using_dac = 1;
-               pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
-       } else if (!pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
+               pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
+       } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
                using_dac = 0;
                consistent_using_dac = 0;
-               pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
+               pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
        } else {
                printk(KERN_WARNING
                       "mydev: No suitable DMA available.\n");
@@ -189,22 +189,14 @@ smaller mask as pci_set_dma_mask(). However for the rare case that a
 device driver only uses consistent allocations, one would have to
 check the return value from pci_set_consistent_dma_mask().
 
-If your 64-bit device is going to be an enormous consumer of DMA
-mappings, this can be problematic since the DMA mappings are a
-finite resource on many platforms.  Please see the "DAC Addressing
-for Address Space Hungry Devices" section near the end of this
-document for how to handle this case.
-
 Finally, if your device can only drive the low 24-bits of
 address during PCI bus mastering you might do something like:
 
-       if (pci_set_dma_mask(pdev, DMA_24BIT_MASK)) {
+       if (pci_set_dma_mask(pdev, DMA_BIT_MASK(24))) {
                printk(KERN_WARNING
                       "mydev: 24-bit DMA addressing not available.\n");
                goto ignore_this_device;
        }
-[Better use DMA_24BIT_MASK instead of 0x00ffffff.
-See linux/include/dma-mapping.h for reference.]
 
 When pci_set_dma_mask() is successful, and returns zero, the PCI layer
 saves away this mask you have provided.  The PCI layer will use this
@@ -221,8 +213,8 @@ most specific mask.
 
 Here is pseudo-code showing how this might be done:
 
-       #define PLAYBACK_ADDRESS_BITS   DMA_32BIT_MASK
-       #define RECORD_ADDRESS_BITS     0x00ffffff
+       #define PLAYBACK_ADDRESS_BITS   DMA_BIT_MASK(32)
+       #define RECORD_ADDRESS_BITS     DMA_BIT_MASK(24)
 
        struct my_sound_card *card;
        struct pci_dev *pdev;
@@ -232,14 +224,14 @@ Here is pseudo-code showing how this might be done:
                card->playback_enabled = 1;
        } else {
                card->playback_enabled = 0;
-               printk(KERN_WARN "%s: Playback disabled due to DMA limitations.\n",
+               printk(KERN_WARNING "%s: Playback disabled due to DMA limitations.\n",
                       card->name);
        }
        if (!pci_set_dma_mask(pdev, RECORD_ADDRESS_BITS)) {
                card->record_enabled = 1;
        } else {
                card->record_enabled = 0;
-               printk(KERN_WARN "%s: Record disabled due to DMA limitations.\n",
+               printk(KERN_WARNING "%s: Record disabled due to DMA limitations.\n",
                       card->name);
        }
 
@@ -323,11 +315,11 @@ you should do:
 
        dma_addr_t dma_handle;
 
-       cpu_addr = pci_alloc_consistent(dev, size, &dma_handle);
+       cpu_addr = pci_alloc_consistent(pdev, size, &dma_handle);
 
-where dev is a struct pci_dev *. You should pass NULL for PCI like buses
-where devices don't have struct pci_dev (like ISA, EISA).  This may be
-called in interrupt context. 
+where pdev is a struct pci_dev *. This may be called in interrupt context.
+You should use dma_alloc_coherent (see DMA-API.txt) for buses
+where devices don't have struct pci_dev (like ISA, EISA).
 
 This argument is needed because the DMA translations may be bus
 specific (and often is private to the bus which the device is attached
@@ -340,7 +332,7 @@ __get_free_pages (but takes size instead of a page order).  If your
 driver needs regions sized smaller than a page, you may prefer using
 the pci_pool interface, described below.
 
-The consistent DMA mapping interfaces, for non-NULL dev, will by
+The consistent DMA mapping interfaces, for non-NULL pdev, will by
 default return a DMA address which is SAC (Single Address Cycle)
 addressable.  Even if the device indicates (via PCI dma mask) that it
 may address the upper 32-bits and thus perform DAC cycles, consistent
@@ -362,9 +354,9 @@ buffer you receive will not cross a 64K boundary.
 
 To unmap and free such a DMA region, you call:
 
-       pci_free_consistent(dev, size, cpu_addr, dma_handle);
+       pci_free_consistent(pdev, size, cpu_addr, dma_handle);
 
-where dev, size are the same as in the above call and cpu_addr and
+where pdev, size are the same as in the above call and cpu_addr and
 dma_handle are the values pci_alloc_consistent returned to you.
 This function may not be called in interrupt context.
 
@@ -379,9 +371,9 @@ Create a pci_pool like this:
 
        struct pci_pool *pool;
 
-       pool = pci_pool_create(name, dev, size, align, alloc);
+       pool = pci_pool_create(name, pdev, size, align, alloc);
 
-The "name" is for diagnostics (like a kmem_cache name); dev and size
+The "name" is for diagnostics (like a kmem_cache name); pdev and size
 are as above.  The device's hardware alignment requirement for this
 type of data is "align" (which is expressed in bytes, and must be a
 power of two).  If your device has no boundary crossing restrictions,
@@ -480,11 +472,11 @@ To map a single region, you do:
        void *addr = buffer->ptr;
        size_t size = buffer->len;
 
-       dma_handle = pci_map_single(dev, addr, size, direction);
+       dma_handle = pci_map_single(pdev, addr, size, direction);
 
 and to unmap it:
 
-       pci_unmap_single(dev, dma_handle, size, direction);
+       pci_unmap_single(pdev, dma_handle, size, direction);
 
 You should call pci_unmap_single when the DMA activity is finished, e.g.
 from the interrupt which told you that the DMA transfer is done.
@@ -501,17 +493,17 @@ Specifically:
        unsigned long offset = buffer->offset;
        size_t size = buffer->len;
 
-       dma_handle = pci_map_page(dev, page, offset, size, direction);
+       dma_handle = pci_map_page(pdev, page, offset, size, direction);
 
        ...
 
-       pci_unmap_page(dev, dma_handle, size, direction);
+       pci_unmap_page(pdev, dma_handle, size, direction);
 
 Here, "offset" means byte offset within the given page.
 
 With scatterlists, you map a region gathered from several regions by:
 
-       int i, count = pci_map_sg(dev, sglist, nents, direction);
+       int i, count = pci_map_sg(pdev, sglist, nents, direction);
        struct scatterlist *sg;
 
        for_each_sg(sglist, sg, count, i) {
@@ -535,7 +527,7 @@ accessed sg->address and sg->length as shown above.
 
 To unmap a scatterlist, just call:
 
-       pci_unmap_sg(dev, sglist, nents, direction);
+       pci_unmap_sg(pdev, sglist, nents, direction);
 
 Again, make sure DMA activity has already finished.
 
@@ -558,11 +550,11 @@ correct copy of the DMA buffer.
 So, firstly, just map it with pci_map_{single,sg}, and after each DMA
 transfer call either:
 
-       pci_dma_sync_single_for_cpu(dev, dma_handle, size, direction);
+       pci_dma_sync_single_for_cpu(pdev, dma_handle, size, direction);
 
 or:
 
-       pci_dma_sync_sg_for_cpu(dev, sglist, nents, direction);
+       pci_dma_sync_sg_for_cpu(pdev, sglist, nents, direction);
 
 as appropriate.
 
@@ -570,7 +562,7 @@ Then, if you wish to let the device get at the DMA area again,
 finish accessing the data with the cpu, and then before actually
 giving the buffer to the hardware call either:
 
-       pci_dma_sync_single_for_device(dev, dma_handle, size, direction);
+       pci_dma_sync_single_for_device(pdev, dma_handle, size, direction);
 
 or:
 
@@ -652,18 +644,6 @@ It is planned to completely remove virt_to_bus() and bus_to_virt() as
 they are entirely deprecated.  Some ports already do not provide these
 as it is impossible to correctly support them.
 
-               64-bit DMA and DAC cycle support
-
-Do you understand all of the text above?  Great, then you already
-know how to use 64-bit DMA addressing under Linux.  Simply make
-the appropriate pci_set_dma_mask() calls based upon your cards
-capabilities, then use the mapping APIs above.
-
-It is that simple.
-
-Well, not for some odd devices.  See the next section for information
-about that.
-
                Optimizing Unmap State Space Consumption
 
 On many platforms, pci_unmap_{single,page}() is simply a nop.
@@ -759,8 +739,8 @@ failure can be determined by:
 
        dma_addr_t dma_handle;
 
-       dma_handle = pci_map_single(dev, addr, size, direction);
-       if (pci_dma_mapping_error(dma_handle)) {
+       dma_handle = pci_map_single(pdev, addr, size, direction);
+       if (pci_dma_mapping_error(pdev, dma_handle)) {
                /*
                 * reduce current DMA mapping usage,
                 * delay and try again later or
@@ -782,5 +762,5 @@ following people:
        Jay Estabrook <Jay.Estabrook@compaq.com>
        Thomas Sailer <sailer@ife.ee.ethz.ch>
        Andrea Arcangeli <andrea@suse.de>
-       Jens Axboe <axboe@suse.de>
+       Jens Axboe <jens.axboe@oracle.com>
        David Mosberger-Tang <davidm@hpl.hp.com>