Skip to content

Commit

Permalink
xtensa: support DMA_ATTR_NO_KERNEL_MAPPING attribute
Browse files Browse the repository at this point in the history
An application that doesn't need kernel mapping of the DMA memory it
allocates may specify DMA_ATTR_NO_KERNEL_MAPPING attribute to allocation
function. Support this attribute and return address of the first struct
page that covers the allocation.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
  • Loading branch information
Max Filippov committed Jul 11, 2018
1 parent 3f2bbf4 commit adbfa4e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions arch/xtensa/kernel/pci-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,

*handle = phys_to_dma(dev, page_to_phys(page));

if (attrs & DMA_ATTR_NO_KERNEL_MAPPING) {
return page;
}

#ifdef CONFIG_MMU
if (PageHighMem(page)) {
void *p;
Expand Down Expand Up @@ -147,8 +151,10 @@ void arch_dma_free(struct device *dev, size_t size, void *vaddr,
unsigned long addr = (unsigned long)vaddr;
struct page *page;

if (addr >= XCHAL_KSEG_BYPASS_VADDR &&
addr - XCHAL_KSEG_BYPASS_VADDR < XCHAL_KSEG_SIZE) {
if (attrs & DMA_ATTR_NO_KERNEL_MAPPING) {
page = vaddr;
} else if (addr >= XCHAL_KSEG_BYPASS_VADDR &&
addr - XCHAL_KSEG_BYPASS_VADDR < XCHAL_KSEG_SIZE) {
addr += XCHAL_KSEG_CACHED_VADDR - XCHAL_KSEG_BYPASS_VADDR;
page = virt_to_page(addr);
} else {
Expand Down

0 comments on commit adbfa4e

Please sign in to comment.