Contributors: 15
Author |
Tokens |
Token Proportion |
Commits |
Commit Proportion |
Christoph Hellwig |
122 |
43.42% |
5 |
20.83% |
Laura Abbott |
79 |
28.11% |
1 |
4.17% |
Marek Szyprowski |
26 |
9.25% |
3 |
12.50% |
Russell King |
11 |
3.91% |
3 |
12.50% |
Robin Murphy |
9 |
3.20% |
1 |
4.17% |
Hiroshi Doyu |
6 |
2.14% |
1 |
4.17% |
Eric Auger |
6 |
2.14% |
1 |
4.17% |
Greg Kroah-Hartman |
5 |
1.78% |
2 |
8.33% |
Jon Medhurst (Tixy) |
4 |
1.42% |
1 |
4.17% |
Geliang Tang |
3 |
1.07% |
1 |
4.17% |
Andrey Smirnov |
3 |
1.07% |
1 |
4.17% |
Akinobu Mita |
3 |
1.07% |
1 |
4.17% |
gaoxu |
2 |
0.71% |
1 |
4.17% |
David Rientjes |
1 |
0.36% |
1 |
4.17% |
Linus Torvalds |
1 |
0.36% |
1 |
4.17% |
Total |
281 |
|
24 |
|
// 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;
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_array(count, sizeof(struct page *), GFP_KERNEL);
if (!pages)
return NULL;
for (i = 0; i < count; i++)
pages[i] = nth_page(page, i);
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);
}