Skip to contentSkip to conversation

arm: dma-mapping: DMA buf may not have cpu virtual addr

PATCH New Shiraz Hashim 1 participant 1 message Mar 22, 2018 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: dma-mapping: DMA buf may not have cpu virtual addr

DMA buffers may not have cpu virtual addresses when allocated using DMA_ATTR_NO_KERNEL_MAPPING attribute. Page address should therefore be looked up while searching for such dma bufs.

---
 arch/arm/mm/dma-mapping.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mm/dma-mapping.c +3 -2
index ada8eb2..c85fc0a 100644
@@ -883,9 +883,10 @@ static void __arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
 		.page = page,
 		.want_vaddr = ((attrs & DMA_ATTR_NO_KERNEL_MAPPING) == 0),
 	};
+	void *addr = (args.want_vaddr) ? cpu_addr : page;
 
-	buf = arm_dma_buffer_find(cpu_addr);
-	if (WARN(!buf, "Freeing invalid buffer %p\n", cpu_addr))
+	buf = arm_dma_buffer_find(addr);
+	if (WARN(!buf, "Freeing invalid buffer %p\n", addr))
 		return;
 
 	buf->allocator->free(&args);
Signature · 4 lines
Shiraz Hashim

QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation