From d98356b914b360fd9dfb04227049d2b4b4cdcfe0 Mon Sep 17 00:00:00 2001 From: Indranil Pradhan Date: Mon, 10 Jul 2023 17:15:17 +0530 Subject: [PATCH] dmabuf: heaps: Support dmabuf alloc from no-map shared-dma-heap Assign right dma_mem info to heap device and avoid dma mapping for no-map memory. Test: Compiled and Qseecom command 7, 17, appttest and apttestcrypto tested successfully. Change-Id: Iaeb6eb26cd5388f005442727bf0cfa7dd541d8bc Signed-off-by: Indranil Pradhan --- drivers/dma-buf/heaps/qcom_cma_heap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/heaps/qcom_cma_heap.c b/drivers/dma-buf/heaps/qcom_cma_heap.c index 218e2d57c84f..118fbb563d1d 100644 --- a/drivers/dma-buf/heaps/qcom_cma_heap.c +++ b/drivers/dma-buf/heaps/qcom_cma_heap.c @@ -166,7 +166,7 @@ struct dma_buf *cma_heap_allocate(struct dma_heap *heap, if (IS_ERR(helper_buffer->vmperm)) goto free_sgtable; - if (helper_buffer->uncached) { + if (helper_buffer->uncached && !cma_heap->is_nomap) { dma_map_sgtable(dma_heap_get_dev(heap), &helper_buffer->sg_table, DMA_BIDIRECTIONAL, 0); dma_unmap_sgtable(dma_heap_get_dev(heap), &helper_buffer->sg_table, @@ -238,7 +238,10 @@ static int __add_cma_heap(struct platform_heap *heap_data, void *data) DMA_BIT_MASK(64)); cma_heap->is_nomap = dmabuf_cma_is_nomap(heap_data->dev); - +#ifdef CONFIG_DMA_DECLARE_COHERENT + if (cma_heap->is_nomap && !dma_heap_get_dev(heap)->dma_mem) + dma_heap_get_dev(heap)->dma_mem = heap_data->dev->dma_mem; +#endif return 0; }