Contributors: 15
| Author |
Tokens |
Token Proportion |
Commits |
Commit Proportion |
| Christoph Hellwig |
125 |
42.96% |
5 |
21.74% |
| Laura Abbott |
80 |
27.49% |
1 |
4.35% |
| Marek Szyprowski |
26 |
8.93% |
3 |
13.04% |
| Yosry Ahmed |
16 |
5.50% |
1 |
4.35% |
| Russell King |
11 |
3.78% |
3 |
13.04% |
| Andrey Smirnov |
9 |
3.09% |
1 |
4.35% |
| Eric Auger |
6 |
2.06% |
1 |
4.35% |
| Robin Murphy |
6 |
2.06% |
1 |
4.35% |
| Jon Medhurst (Tixy) |
4 |
1.37% |
1 |
4.35% |
| Kees Cook |
3 |
1.03% |
1 |
4.35% |
| Greg Kroah-Hartman |
1 |
0.34% |
1 |
4.35% |
| David Hildenbrand |
1 |
0.34% |
1 |
4.35% |
| Linus Torvalds |
1 |
0.34% |
1 |
4.35% |
| gaoxu |
1 |
0.34% |
1 |
4.35% |
| David Rientjes |
1 |
0.34% |
1 |
4.35% |
| Total |
291 |
|
23 |
|
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2014 The Linux Foundation
*/
#include <linux/dma-map-ops.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
struct page **dma_common_find_pages(void *cpu_addr)
{
struct vm_struct *area = find_vm_area(cpu_addr);
if (!area || !(area->flags & VM_DMA_COHERENT))
return NULL;
WARN(area->flags != VM_DMA_COHERENT,
"unexpected flags in area: %p\n", cpu_addr);
return area->pages;
}
/*
* Remaps an array of PAGE_SIZE pages into another vm_area.
* Cannot be used in non-sleeping contexts
*/
void *dma_common_pages_remap(struct page **pages, size_t size,
pgprot_t prot, const void *caller)
{
void *vaddr;
vaddr = vmap(pages, PAGE_ALIGN(size) >> PAGE_SHIFT,
VM_DMA_COHERENT, prot);
if (vaddr)
find_vm_area(vaddr)->pages = pages;
return vaddr;
}
/*
* Remaps an allocated contiguous region into another vm_area.
* Cannot be used in non-sleeping contexts
*/
void *dma_common_contiguous_remap(struct page *page, size_t size,
pgprot_t prot, const void *caller)
{
int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
struct page **pages;
void *vaddr;
int i;
pages = kvmalloc_objs(struct page *, count);
if (!pages)
return NULL;
for (i = 0; i < count; i++)
pages[i] = page++;
vaddr = vmap(pages, count, VM_DMA_COHERENT, prot);
kvfree(pages);
return vaddr;
}
/*
* Unmaps a range previously mapped by dma_common_*_remap
*/
void dma_common_free_remap(void *cpu_addr, size_t size)
{
struct vm_struct *area = find_vm_area(cpu_addr);
if (!area || !(area->flags & VM_DMA_COHERENT)) {
WARN(1, "trying to free invalid coherent area: %p\n", cpu_addr);
return;
}
vunmap(cpu_addr);
}