Lines Matching full:mem

33 					     struct dma_coherent_mem * mem)  in dma_get_device_base()  argument
35 if (mem->use_dev_dma_pfn_offset) in dma_get_device_base()
36 return phys_to_dma(dev, PFN_PHYS(mem->pfn_base)); in dma_get_device_base()
37 return mem->device_base; in dma_get_device_base()
42 struct dma_coherent_mem **mem) in dma_init_coherent_memory() argument
77 *mem = dma_mem; in dma_init_coherent_memory()
87 static void dma_release_coherent_memory(struct dma_coherent_mem *mem) in dma_release_coherent_memory() argument
89 if (!mem) in dma_release_coherent_memory()
92 memunmap(mem->virt_base); in dma_release_coherent_memory()
93 kfree(mem->bitmap); in dma_release_coherent_memory()
94 kfree(mem); in dma_release_coherent_memory()
98 struct dma_coherent_mem *mem) in dma_assign_coherent_memory() argument
106 dev->dma_mem = mem; in dma_assign_coherent_memory()
130 struct dma_coherent_mem *mem; in dma_declare_coherent_memory() local
133 ret = dma_init_coherent_memory(phys_addr, device_addr, size, &mem); in dma_declare_coherent_memory()
137 ret = dma_assign_coherent_memory(dev, mem); in dma_declare_coherent_memory()
139 dma_release_coherent_memory(mem); in dma_declare_coherent_memory()
144 struct dma_coherent_mem *mem, in __dma_alloc_from_coherent() argument
152 spin_lock_irqsave(&mem->spinlock, flags); in __dma_alloc_from_coherent()
154 if (unlikely(size > ((dma_addr_t)mem->size << PAGE_SHIFT))) in __dma_alloc_from_coherent()
157 pageno = bitmap_find_free_region(mem->bitmap, mem->size, order); in __dma_alloc_from_coherent()
164 *dma_handle = dma_get_device_base(dev, mem) + in __dma_alloc_from_coherent()
166 ret = mem->virt_base + ((dma_addr_t)pageno << PAGE_SHIFT); in __dma_alloc_from_coherent()
167 spin_unlock_irqrestore(&mem->spinlock, flags); in __dma_alloc_from_coherent()
171 spin_unlock_irqrestore(&mem->spinlock, flags); in __dma_alloc_from_coherent()
192 struct dma_coherent_mem *mem = dev_get_coherent_memory(dev); in dma_alloc_from_dev_coherent() local
194 if (!mem) in dma_alloc_from_dev_coherent()
197 *ret = __dma_alloc_from_coherent(dev, mem, size, dma_handle); in dma_alloc_from_dev_coherent()
211 static int __dma_release_from_coherent(struct dma_coherent_mem *mem, in __dma_release_from_coherent() argument
214 if (mem && vaddr >= mem->virt_base && vaddr < in __dma_release_from_coherent()
215 (mem->virt_base + ((dma_addr_t)mem->size << PAGE_SHIFT))) { in __dma_release_from_coherent()
216 int page = (vaddr - mem->virt_base) >> PAGE_SHIFT; in __dma_release_from_coherent()
219 spin_lock_irqsave(&mem->spinlock, flags); in __dma_release_from_coherent()
220 bitmap_release_region(mem->bitmap, page, order); in __dma_release_from_coherent()
221 spin_unlock_irqrestore(&mem->spinlock, flags); in __dma_release_from_coherent()
241 struct dma_coherent_mem *mem = dev_get_coherent_memory(dev); in dma_release_from_dev_coherent() local
243 return __dma_release_from_coherent(mem, order, vaddr); in dma_release_from_dev_coherent()
255 static int __dma_mmap_from_coherent(struct dma_coherent_mem *mem, in __dma_mmap_from_coherent() argument
258 if (mem && vaddr >= mem->virt_base && vaddr + size <= in __dma_mmap_from_coherent()
259 (mem->virt_base + ((dma_addr_t)mem->size << PAGE_SHIFT))) { in __dma_mmap_from_coherent()
261 int start = (vaddr - mem->virt_base) >> PAGE_SHIFT; in __dma_mmap_from_coherent()
267 unsigned long pfn = mem->pfn_base + start + off; in __dma_mmap_from_coherent()
295 struct dma_coherent_mem *mem = dev_get_coherent_memory(dev); in dma_mmap_from_dev_coherent() local
297 return __dma_mmap_from_coherent(mem, vma, vaddr, size, ret); in dma_mmap_from_dev_coherent()
322 struct dma_coherent_mem *mem = rmem->priv; in rmem_dma_device_init() local
325 if (!mem) { in rmem_dma_device_init()
327 rmem->size, &mem); in rmem_dma_device_init()
334 mem->use_dev_dma_pfn_offset = true; in rmem_dma_device_init()
335 rmem->priv = mem; in rmem_dma_device_init()
336 dma_assign_coherent_memory(dev, mem); in rmem_dma_device_init()