From 5a26220873e7246cf08b9d0ce573130719f6fa7c Mon Sep 17 00:00:00 2001 From: Cho KyongHo Date: Wed, 18 Apr 2018 14:52:33 +0900 Subject: [PATCH] android: ion: fix build break with secure DRM on Change-Id: I56841d7748b8ae1d546425b0fcbf70b83d443fda Signed-off-by: Cho KyongHo --- .../staging/android/ion/ion_buffer_protect.c | 33 +++++++++++++++---- drivers/staging/android/ion/ion_exynos.c | 1 - drivers/staging/android/ion/ion_exynos.h | 4 ++- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/drivers/staging/android/ion/ion_buffer_protect.c b/drivers/staging/android/ion/ion_buffer_protect.c index e956ce203faa..bd6dd8432d67 100644 --- a/drivers/staging/android/ion/ion_buffer_protect.c +++ b/drivers/staging/android/ion/ion_buffer_protect.c @@ -15,6 +15,10 @@ */ #include +#include +#include + +#include #include "ion_exynos.h" @@ -26,6 +30,22 @@ 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; diff --git a/drivers/staging/android/ion/ion_exynos.c b/drivers/staging/android/ion/ion_exynos.c index 853202d6271a..21d4b2e74040 100644 --- a/drivers/staging/android/ion/ion_exynos.c +++ b/drivers/staging/android/ion/ion_exynos.c @@ -15,7 +15,6 @@ */ #include -#include #include #include "ion.h" diff --git a/drivers/staging/android/ion/ion_exynos.h b/drivers/staging/android/ion/ion_exynos.h index e36e3d0659db..5a454c1f4761 100644 --- a/drivers/staging/android/ion/ion_exynos.h +++ b/drivers/staging/android/ion/ion_exynos.h @@ -18,6 +18,8 @@ #define _ION_EXYNOS_H_ #include +#include + 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) { -- 2.20.1