dma-mapping: introduce a dma_common_find_pages helper
A helper to find the backing page array based on a virtual address. This also ensures we do the same vm_flags check everywhere instead of slightly different or missing ones in a few places. Signed-off-by: Christoph Hellwig <hch@lst.de>
这个提交包含在:
@@ -11,6 +11,15 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
static struct vm_struct *__dma_common_pages_remap(struct page **pages,
|
||||
size_t size, pgprot_t prot, const void *caller)
|
||||
{
|
||||
@@ -78,9 +87,9 @@ void *dma_common_contiguous_remap(struct page *page, size_t size,
|
||||
*/
|
||||
void dma_common_free_remap(void *cpu_addr, size_t size)
|
||||
{
|
||||
struct vm_struct *area = find_vm_area(cpu_addr);
|
||||
struct page **pages = dma_common_find_pages(cpu_addr);
|
||||
|
||||
if (!area || area->flags != VM_DMA_COHERENT) {
|
||||
if (!pages) {
|
||||
WARN(1, "trying to free invalid coherent area: %p\n", cpu_addr);
|
||||
return;
|
||||
}
|
||||
|
在新工单中引用
屏蔽一个用户