android: ion: fix build break with secure DRM on
authorCho KyongHo <pullip.cho@samsung.com>
Wed, 18 Apr 2018 05:52:33 +0000 (14:52 +0900)
committerSangwook Ju <sw.ju@samsung.com>
Mon, 14 May 2018 10:45:26 +0000 (19:45 +0900)
Change-Id: I56841d7748b8ae1d546425b0fcbf70b83d443fda
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
drivers/staging/android/ion/ion_buffer_protect.c
drivers/staging/android/ion/ion_exynos.c
drivers/staging/android/ion/ion_exynos.h

index e956ce203faacd9a3069c661d7c1548cb1d71503..bd6dd8432d67a884c77bf47ee7262f76c1122fda 100644 (file)
  */
 
 #include <linux/slab.h>
+#include <linux/genalloc.h>
+#include <linux/smc.h>
+
+#include <asm/cacheflush.h>
 
 #include "ion_exynos.h"
 
 static struct gen_pool *secure_iova_pool;
 static DEFINE_SPINLOCK(siova_pool_lock);
 
+#define MAX_IOVA_ALIGNMENT      12
+
+static unsigned long find_first_fit_with_align(unsigned long *map,
+                                              unsigned long size,
+                                              unsigned long start,
+                                              unsigned int nr, void *data,
+                                              struct gen_pool *pool)
+{
+       unsigned long align = ((*(unsigned long *)data) >> PAGE_SHIFT);
+
+       if (align > (1 << MAX_IOVA_ALIGNMENT))
+               align = (1 << MAX_IOVA_ALIGNMENT);
+
+       return bitmap_find_next_zero_area(map, size, start, nr, (align - 1));
+}
+
 static int ion_secure_iova_alloc(unsigned long *addr, unsigned long size,
                                 unsigned int align)
 {
@@ -92,16 +112,17 @@ static int ion_secure_protect(struct ion_buffer_prot_info *protdesc,
 {
        unsigned long size = protdesc->chunk_count * protdesc->chunk_size;
        unsigned long dma_addr = 0;
-       drmdrv_result_t drmret = DRMDRV_OK;
+       enum drmdrv_result_t drmret = DRMDRV_OK;
        int ret;
 
-       ret = ion_secure_iova_alloc(&dma_addr, size, max(protalign, PAGE_SIZE));
+       ret = ion_secure_iova_alloc(&dma_addr, size,
+                                   max_t(u32, protalign, PAGE_SIZE));
        if (ret)
                goto err_iova;
 
-       prot->dma_addr = (unsigned int)dma_addr;
+       protdesc->dma_addr = (unsigned int)dma_addr;
 
-       __flush_dcache_area(prot, sizeof(*protdesc));
+       __flush_dcache_area(protdesc, sizeof(*protdesc));
        if (protdesc->chunk_count > 1)
                __flush_dcache_area(phys_to_virt(protdesc->bus_address),
                                sizeof(unsigned long) * protdesc->chunk_count);
@@ -133,10 +154,10 @@ static int ion_secure_unprotect(struct ion_buffer_prot_info *protdesc)
         */
        ret = exynos_smc(SMC_DRM_PPMP_UNPROT, virt_to_phys(protdesc), 0, 0);
 
-       ion_secure_iova_free(info->prot_desc.dma_addr, size);
+       ion_secure_iova_free(protdesc->dma_addr, size);
 
        if (ret != DRMDRV_OK) {
-               pr_err("%s: UNPROT:%d(err=%d,va=%#lx,len=%#lx,cnt=%u,flg=%u)\n",
+               pr_err("%s: UNPROT:%d(err=%d,va=%#x,len=%#lx,cnt=%u,flg=%u)\n",
                       __func__, SMC_DRM_PPMP_UNPROT, ret, protdesc->dma_addr,
                       size, protdesc->chunk_count, protdesc->flags);
                return -EACCES;
index 853202d6271acc48e3846f2512e4094ab3ead4ca..21d4b2e74040d55ed9bae3e59bf03d4f27fd2518 100644 (file)
@@ -15,7 +15,6 @@
  */
 
 #include <linux/slab.h>
-#include <linux/dma-buf.h>
 #include <linux/exynos_iovmm.h>
 
 #include "ion.h"
index e36e3d0659dbb7fb503ca0dc49de81551976d719..5a454c1f4761aaf6e3ddf09fae2aacfd101524b9 100644 (file)
@@ -18,6 +18,8 @@
 #define _ION_EXYNOS_H_
 
 #include <linux/dma-direction.h>
+#include <linux/dma-buf.h>
+
 struct cma;
 struct dma_buf;
 struct ion_heap;
@@ -75,7 +77,7 @@ extern struct ion_heap *ion_hpa_heap_create(struct ion_platform_heap *pheap);
 #endif
 
 #if defined(CONFIG_EXYNOS_CONTENT_PATH_PROTECTION) && defined(CONFIG_ION_EXYNOS)
-int __init ion_secure_iova_pool_create(void)
+int __init ion_secure_iova_pool_create(void);
 #else
 static inline int ion_secure_iova_pool_create(void)
 {