Lines Matching +full:page +full:- +full:size
1 // SPDX-License-Identifier: GPL-2.0
6 #include <linux/dma-map-ops.h>
8 static struct page *dma_common_vaddr_to_page(void *cpu_addr) in dma_common_vaddr_to_page()
16 * Create scatter-list for the already allocated DMA buffer.
19 void *cpu_addr, dma_addr_t dma_addr, size_t size, in dma_common_get_sgtable() argument
22 struct page *page = dma_common_vaddr_to_page(cpu_addr); in dma_common_get_sgtable() local
27 sg_set_page(sgt->sgl, page, PAGE_ALIGN(size), 0); in dma_common_get_sgtable()
32 * Create userspace mapping for the DMA-coherent memory.
35 void *cpu_addr, dma_addr_t dma_addr, size_t size, in dma_common_mmap() argument
40 unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT; in dma_common_mmap()
41 unsigned long off = vma->vm_pgoff; in dma_common_mmap()
42 struct page *page = dma_common_vaddr_to_page(cpu_addr); in dma_common_mmap() local
43 int ret = -ENXIO; in dma_common_mmap()
45 vma->vm_page_prot = dma_pgprot(dev, vma->vm_page_prot, attrs); in dma_common_mmap()
47 if (dma_mmap_from_dev_coherent(dev, vma, cpu_addr, size, &ret)) in dma_common_mmap()
50 if (off >= count || user_count > count - off) in dma_common_mmap()
51 return -ENXIO; in dma_common_mmap()
53 return remap_pfn_range(vma, vma->vm_start, in dma_common_mmap()
54 page_to_pfn(page) + vma->vm_pgoff, in dma_common_mmap()
55 user_count << PAGE_SHIFT, vma->vm_page_prot); in dma_common_mmap()
57 return -ENXIO; in dma_common_mmap()
61 struct page *dma_common_alloc_pages(struct device *dev, size_t size, in dma_common_alloc_pages() argument
65 struct page *page; in dma_common_alloc_pages() local
67 page = dma_alloc_contiguous(dev, size, gfp); in dma_common_alloc_pages()
68 if (!page) in dma_common_alloc_pages()
69 page = alloc_pages_node(dev_to_node(dev), gfp, get_order(size)); in dma_common_alloc_pages()
70 if (!page) in dma_common_alloc_pages()
73 *dma_handle = ops->map_page(dev, page, 0, size, dir, in dma_common_alloc_pages()
76 dma_free_contiguous(dev, page, size); in dma_common_alloc_pages()
80 memset(page_address(page), 0, size); in dma_common_alloc_pages()
81 return page; in dma_common_alloc_pages()
84 void dma_common_free_pages(struct device *dev, size_t size, struct page *page, in dma_common_free_pages() argument
89 if (ops->unmap_page) in dma_common_free_pages()
90 ops->unmap_page(dev, dma_handle, size, dir, in dma_common_free_pages()
92 dma_free_contiguous(dev, page, size); in dma_common_free_pages()