Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1b031f8 authored by Qingqing Zhou's avatar Qingqing Zhou
Browse files

ARM: dma-mapping: Allow highmem pages to not have a mapping



The DMA_ATTR_NO_KERNEL_MAPPING is used to make sure that CMA
pages have no kernel mapping. Add support to make sure that
highmem pages have no mapping.

This got changed as part of Fixes: 459da881 ("iommu: fix
memory related compilation error for 32bit").

Change-Id: Ife76df126ecfedf0dba81a35e0de8a1787355b3d
Signed-off-by: default avatarLaura Abbott <lauraa@codeaurora.org>
Signed-off-by: default avatarRohit Vaswani <rvaswani@codeaurora.org>
Signed-off-by: default avatarVijayanand Jitta <vjitta@codeaurora.org>
Signed-off-by: default avatarCharan Teja Reddy <charante@codeaurora.org>
[qqzhou@codeaurora.org: changed as 459da881 has part of fixes]
Signed-off-by: default avatarQingqing Zhou <qqzhou@codeaurora.org>
parent 6ac75377
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -568,12 +568,13 @@ static void __dma_remap(struct page *page, size_t size, pgprot_t prot,
	flush_tlb_kernel_range(start, end);
}

#define NO_KERNEL_MAPPING_DUMMY		0x2222
static void *__alloc_remap_buffer(struct device *dev, size_t size, gfp_t gfp,
				 pgprot_t prot, struct page **ret_page,
				 const void *caller, bool want_vaddr)
{
	struct page *page;
	void *ptr = NULL;
	void *ptr = (void *)NO_KERNEL_MAPPING_DUMMY;
	/*
	 * __alloc_remap_buffer is only called when the device is
	 * non-coherent
@@ -648,11 +649,21 @@ static void *__alloc_from_contiguous(struct device *dev, size_t size,
	__dma_clear_buffer(page, size, coherent_flag);

	if (PageHighMem(page)) {
		ptr = __dma_alloc_remap(page, size, GFP_KERNEL, prot, caller);
		if (!want_vaddr) {
			/*
			 * Something non-NULL needs to be returned here. Give
			 * back a dummy address that is unmapped to catch
			 * clients trying to use the address incorrectly
			 */
			ptr = (void *)NO_KERNEL_MAPPING_DUMMY;
		} else {
			ptr = __dma_alloc_remap(page, size, GFP_KERNEL,
					prot, caller);
			if (!ptr) {
				dma_release_from_contiguous(dev, page, count);
				return NULL;
			}
		}
	} else {
		__dma_remap(page, size, prot, want_vaddr);
		ptr = page_address(page);
@@ -849,7 +860,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
		kfree(buf);
	}

	return args.want_vaddr ? addr : page;
	return addr;
}

/*