android: ion: free iova at buffer destruction time
authorJanghyuck Kim <janghyuck.kim@samsung.com>
Tue, 27 Feb 2018 09:24:10 +0000 (18:24 +0900)
committerSangwook Ju <sw.ju@samsung.com>
Mon, 14 May 2018 10:45:24 +0000 (19:45 +0900)
In order to optimize the performance of ion_iovmm_unmap(), the actual
unmapping of the device virtual address is deferred. It is expected to
work at buffer destruction time, but this is missing. So unmapping code
is added to work properly.

Change-Id: Ie2dffa58df5125baf4a4e9723db241846e860443
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
drivers/staging/android/ion/ion_exynos.c

index fafb9dae1500c1055dadbcf3e23040e60c6c79ef..efdbe3e9b4be76b21b88ae36cfe455e2a6ea0a16 100644 (file)
@@ -202,10 +202,18 @@ int exynos_ion_alloc_fixup(struct ion_device *idev, struct ion_buffer *buffer)
 void exynos_ion_free_fixup(struct ion_buffer *buffer)
 {
        struct sg_table *table = buffer->sg_table;
+       struct ion_iovm_map *iovm_map, *tmp;
 
        dma_unmap_sg_attrs(buffer->dev->dev.this_device, table->sgl,
                           table->orig_nents, DMA_TO_DEVICE,
                           DMA_ATTR_SKIP_CPU_SYNC);
+
+       list_for_each_entry_safe(iovm_map, tmp, &buffer->iovas, list) {
+               iovmm_unmap(iovm_map->dev, iovm_map->iova);
+               list_del(&iovm_map->list);
+               kfree(iovm_map);
+       }
+
 }
 
 struct sg_table *ion_exynos_map_dma_buf(struct dma_buf_attachment *attachment,