From 0e47811b36fd7d0a045a7f188dc94194758992e8 Mon Sep 17 00:00:00 2001 From: Sharat Masetty Date: Wed, 27 Mar 2019 15:15:44 +0530 Subject: [PATCH] msm: kgsl: Call dma_buf_unmap_attachment() early When we import an ION buffer, we call the dma_buf_map_attachment(). The intent is to not map it to the dma device(which in this case is the KGSl device), but to only get the sg_table. Once we have the sg_table we later map the physical pages to the GPU SMMU manually and not by using the dma device ops. The ION driver as part of the partial cache maintenance requires that all the sg_tables of the attached devices to the buffer have a single segment. This creates a problem for KGSL since in this case the kgsl is a dummy device, so the buffer for KGSL always has multiple segments. This patch calls the dma_buf_unmap_attachment() as soon we get a hold of the sg_table as doing so a) we don't need the buffer to be mapped to a dummy device, b) removes the buffer from the cache maintenance constraints of the ION driver. Change-Id: I0675e62c4a27b4e368d53ea6310c9244b687baa6 Signed-off-by: Sharat Masetty Signed-off-by: Puranam V G Tejaswi --- drivers/gpu/msm/kgsl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c index 3a466a20d8a6..5cd76eabc6f7 100644 --- a/drivers/gpu/msm/kgsl.c +++ b/drivers/gpu/msm/kgsl.c @@ -315,8 +315,6 @@ static void kgsl_destroy_ion(struct kgsl_dma_buf_meta *meta) { if (meta != NULL) { remove_dmabuf_list(meta); - dma_buf_unmap_attachment(meta->attach, meta->table, - DMA_BIDIRECTIONAL); dma_buf_detach(meta->dmabuf, meta->attach); dma_buf_put(meta->dmabuf); kfree(meta); @@ -2859,6 +2857,8 @@ static int kgsl_setup_dma_buf(struct kgsl_device *device, goto out; } + dma_buf_unmap_attachment(attach, sg_table, DMA_BIDIRECTIONAL); + meta->table = sg_table; entry->priv_data = meta; entry->memdesc.sgt = sg_table;