]> err.no Git - linux-2.6/blobdiff - kernel/dma-coherent.c
lockdep: annotate mm_take_all_locks()
[linux-2.6] / kernel / dma-coherent.c
index 89a554cfd936b57573eb3c240ceb78b764ef1824..7517115a8cce604cd9535d327d1ab7e12dce2f7a 100644 (file)
@@ -92,6 +92,21 @@ void *dma_mark_declared_memory_occupied(struct device *dev,
 }
 EXPORT_SYMBOL(dma_mark_declared_memory_occupied);
 
+/**
+ * Try to allocate memory from the per-device coherent area.
+ *
+ * @dev:       device from which we allocate memory
+ * @size:      size of requested memory area
+ * @dma_handle:        This will be filled with the correct dma handle
+ * @ret:       This pointer will be filled with the virtual address
+ *             to allocated area.
+ *
+ * This function should be only called from per-arch %dma_alloc_coherent()
+ * to support allocation from per-device coherent memory pools.
+ *
+ * Returns 0 if dma_alloc_coherent should continue with allocating from
+ * generic memory areas, or !0 if dma_alloc_coherent should return %ret.
+ */
 int dma_alloc_from_coherent(struct device *dev, ssize_t size,
                                       dma_addr_t *dma_handle, void **ret)
 {
@@ -105,13 +120,25 @@ int dma_alloc_from_coherent(struct device *dev, ssize_t size,
                        *dma_handle = mem->device_base + (page << PAGE_SHIFT);
                        *ret = mem->virt_base + (page << PAGE_SHIFT);
                        memset(*ret, 0, size);
-               }
-               if (mem->flags & DMA_MEMORY_EXCLUSIVE)
+               } else if (mem->flags & DMA_MEMORY_EXCLUSIVE)
                        *ret = NULL;
        }
        return (mem != NULL);
 }
 
+/**
+ * Try to free the memory allocated from per-device coherent memory pool.
+ * @dev:       device from which the memory was allocated
+ * @order:     the order of pages allocated
+ * @vaddr:     virtual address of allocated pages
+ *
+ * This checks whether the memory was allocated from the per-device
+ * coherent memory pool and if so, releases that memory.
+ *
+ * Returns 1 if we correctly released the memory, or 0 if
+ * %dma_release_coherent() should proceed with releasing memory from
+ * generic pools.
+ */
 int dma_release_from_coherent(struct device *dev, int order, void *vaddr)
 {
        struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;