aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/dma-coherent.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-08-14 08:58:01 -0400
committerIngo Molnar <mingo@elte.hu>2008-08-14 08:58:01 -0400
commit51ca3c679194e7435c25b8e77b0a73c597e41ae9 (patch)
treea681dca369607ab0f371d5246b0f75140b860a8a /kernel/dma-coherent.c
parentb55793f7528ce1b73c25b3ac8a86a6cda2a0f9a4 (diff)
parentb635acec48bcaa9183fcbf4e3955616b0d4119b5 (diff)
Merge branch 'linus' into x86/core
Conflicts: arch/x86/kernel/genapic_64.c include/asm-x86/kvm_host.h Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/dma-coherent.c')
-rw-r--r--kernel/dma-coherent.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/kernel/dma-coherent.c b/kernel/dma-coherent.c
index 7517115a8cce..c1d4d5b4c61c 100644
--- a/kernel/dma-coherent.c
+++ b/kernel/dma-coherent.c
@@ -77,15 +77,14 @@ void *dma_mark_declared_memory_occupied(struct device *dev,
77{ 77{
78 struct dma_coherent_mem *mem = dev->dma_mem; 78 struct dma_coherent_mem *mem = dev->dma_mem;
79 int pos, err; 79 int pos, err;
80 int pages = (size + (device_addr & ~PAGE_MASK) + PAGE_SIZE - 1);
81 80
82 pages >>= PAGE_SHIFT; 81 size += device_addr & ~PAGE_MASK;
83 82
84 if (!mem) 83 if (!mem)
85 return ERR_PTR(-EINVAL); 84 return ERR_PTR(-EINVAL);
86 85
87 pos = (device_addr - mem->device_base) >> PAGE_SHIFT; 86 pos = (device_addr - mem->device_base) >> PAGE_SHIFT;
88 err = bitmap_allocate_region(mem->bitmap, pos, get_order(pages)); 87 err = bitmap_allocate_region(mem->bitmap, pos, get_order(size));
89 if (err != 0) 88 if (err != 0)
90 return ERR_PTR(err); 89 return ERR_PTR(err);
91 return mem->virt_base + (pos << PAGE_SHIFT); 90 return mem->virt_base + (pos << PAGE_SHIFT);
@@ -93,7 +92,7 @@ void *dma_mark_declared_memory_occupied(struct device *dev,
93EXPORT_SYMBOL(dma_mark_declared_memory_occupied); 92EXPORT_SYMBOL(dma_mark_declared_memory_occupied);
94 93
95/** 94/**
96 * Try to allocate memory from the per-device coherent area. 95 * dma_alloc_from_coherent() - try to allocate memory from the per-device coherent area
97 * 96 *
98 * @dev: device from which we allocate memory 97 * @dev: device from which we allocate memory
99 * @size: size of requested memory area 98 * @size: size of requested memory area
@@ -101,11 +100,11 @@ EXPORT_SYMBOL(dma_mark_declared_memory_occupied);
101 * @ret: This pointer will be filled with the virtual address 100 * @ret: This pointer will be filled with the virtual address
102 * to allocated area. 101 * to allocated area.
103 * 102 *
104 * This function should be only called from per-arch %dma_alloc_coherent() 103 * This function should be only called from per-arch dma_alloc_coherent()
105 * to support allocation from per-device coherent memory pools. 104 * to support allocation from per-device coherent memory pools.
106 * 105 *
107 * Returns 0 if dma_alloc_coherent should continue with allocating from 106 * Returns 0 if dma_alloc_coherent should continue with allocating from
108 * generic memory areas, or !0 if dma_alloc_coherent should return %ret. 107 * generic memory areas, or !0 if dma_alloc_coherent should return @ret.
109 */ 108 */
110int dma_alloc_from_coherent(struct device *dev, ssize_t size, 109int dma_alloc_from_coherent(struct device *dev, ssize_t size,
111 dma_addr_t *dma_handle, void **ret) 110 dma_addr_t *dma_handle, void **ret)
@@ -127,7 +126,7 @@ int dma_alloc_from_coherent(struct device *dev, ssize_t size,
127} 126}
128 127
129/** 128/**
130 * Try to free the memory allocated from per-device coherent memory pool. 129 * dma_release_from_coherent() - try to free the memory allocated from per-device coherent memory pool
131 * @dev: device from which the memory was allocated 130 * @dev: device from which the memory was allocated
132 * @order: the order of pages allocated 131 * @order: the order of pages allocated
133 * @vaddr: virtual address of allocated pages 132 * @vaddr: virtual address of allocated pages
@@ -136,7 +135,7 @@ int dma_alloc_from_coherent(struct device *dev, ssize_t size,
136 * coherent memory pool and if so, releases that memory. 135 * coherent memory pool and if so, releases that memory.
137 * 136 *
138 * Returns 1 if we correctly released the memory, or 0 if 137 * Returns 1 if we correctly released the memory, or 0 if
139 * %dma_release_coherent() should proceed with releasing memory from 138 * dma_release_coherent() should proceed with releasing memory from
140 * generic pools. 139 * generic pools.
141 */ 140 */
142int dma_release_from_coherent(struct device *dev, int order, void *vaddr) 141int dma_release_from_coherent(struct device *dev, int order, void *vaddr)