kernel: dma: disallow altering logical map for non-CMA allocs

DMA_ATTR_STRONGLY_ORDERED and DMA_ATTR_NO_KERNEL_MAPPING alters
the logical mapping of allocated memory. This works only for CMA
allocations where the pages are PAGE_SIZE mapped.
Disallow fallback to buddy alloc if above attrs are set.

Change-Id: I25c632d3c9179e22bc5061fd5f7e9ab6e7847322
Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
This commit is contained in:
Vinayak Menon committed 2020-09-03 13:56:56 +05:30
1 parent bdf17c96e2
commit 765e7b83f6
2 files changed
+4 -2

No files matched your search

+2 -1
View File
@@ -85,7 +85,8 @@ again:
page = NULL;
}
}
if (!page)
if (!page && !(attrs & (DMA_ATTR_STRONGLY_ORDERED |
DMA_ATTR_NO_KERNEL_MAPPING)))
page = alloc_pages_node(dev_to_node(dev), gfp, page_order);
if (page && !dma_coherent_ok(dev, page_to_phys(page), size)) {
+2 -1
View File
@@ -1026,7 +1026,8 @@ void *swiotlb_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
gfp |= __GFP_NOWARN;
vaddr = dma_direct_alloc(dev, size, dma_handle, gfp, attrs);
if (!vaddr)
if (!vaddr && !(attrs & (DMA_ATTR_STRONGLY_ORDERED |
DMA_ATTR_NO_KERNEL_MAPPING)))
vaddr = swiotlb_alloc_buffer(dev, size, dma_handle, attrs);
return vaddr;
}