diff --git a/drivers/media/video/msm_wfd/enc-mfc-subdev.c b/drivers/media/video/msm_wfd/enc-mfc-subdev.c index d55391e842bc..112e2f4003f5 100644 --- a/drivers/media/video/msm_wfd/enc-mfc-subdev.c +++ b/drivers/media/video/msm_wfd/enc-mfc-subdev.c @@ -2037,6 +2037,7 @@ static long venc_alloc_recon_buffers(struct v4l2_subdev *sd, void *arg) unsigned long phy_addr; int i = 0; int heap_mask = 0; + u32 ion_flags = 0; u32 len; control.width = inst->width; control.height = inst->height; @@ -2050,7 +2051,8 @@ static long venc_alloc_recon_buffers(struct v4l2_subdev *sd, void *arg) goto err; } heap_mask = ION_HEAP(ION_CP_MM_HEAP_ID); - heap_mask |= inst->secure ? ION_SECURE : ION_HEAP(ION_IOMMU_HEAP_ID); + heap_mask |= inst->secure ? 0 : ION_HEAP(ION_IOMMU_HEAP_ID); + ion_flags |= inst->secure ? ION_SECURE : 0; if (vcd_get_ion_status()) { for (i = 0; i < 4; ++i) { @@ -2061,7 +2063,7 @@ static long venc_alloc_recon_buffers(struct v4l2_subdev *sd, void *arg) ctrl->user_virtual_addr = (void *)i; client_ctx->recon_buffer_ion_handle[i] = ion_alloc(client_ctx->user_ion_client, - control.size, SZ_8K, heap_mask, 0); + control.size, SZ_8K, heap_mask, ion_flags); ctrl->kernel_virtual_addr = ion_map_kernel( client_ctx->user_ion_client, diff --git a/drivers/media/video/msm_wfd/wfd-ioctl.c b/drivers/media/video/msm_wfd/wfd-ioctl.c index e72c2a8218c7..0ba65e7747ac 100644 --- a/drivers/media/video/msm_wfd/wfd-ioctl.c +++ b/drivers/media/video/msm_wfd/wfd-ioctl.c @@ -155,13 +155,15 @@ static int wfd_allocate_ion_buffer(struct ion_client *client, struct ion_handle *handle = NULL; void *kvaddr = NULL; unsigned int alloc_regions = 0; + unsigned int ion_flags = 0; int rc = 0; alloc_regions = ION_HEAP(ION_CP_MM_HEAP_ID); - alloc_regions |= secure ? ION_SECURE : + alloc_regions |= secure ? 0 : ION_HEAP(ION_IOMMU_HEAP_ID); + ion_flags |= secure ? ION_SECURE : 0; handle = ion_alloc(client, - mregion->size, SZ_4K, alloc_regions, 0); + mregion->size, SZ_4K, alloc_regions, ion_flags); if (IS_ERR_OR_NULL(handle)) { WFD_MSG_ERR("Failed to allocate input buffer\n"); diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_utils.c b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_utils.c index 8e5fbaa461b2..73510fd6692e 100644 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_utils.c +++ b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_utils.c @@ -71,7 +71,7 @@ void *ddl_pmem_alloc(struct ddl_buf_addr *addr, size_t sz, u32 alignment) alloc_size = (alloc_size+4095) & ~4095; addr->alloc_handle = ion_alloc( ddl_context->video_ion_client, alloc_size, SZ_4K, - res_trk_get_mem_type(), 0); + res_trk_get_mem_type(), res_trk_get_ion_flags()); if (IS_ERR_OR_NULL(addr->alloc_handle)) { DDL_MSG_ERROR("%s() :DDL ION alloc failed\n", __func__); diff --git a/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker.c b/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker.c index 870ebb59e298..487da28dc974 100644 --- a/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker.c +++ b/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker.c @@ -209,7 +209,8 @@ static int res_trk_pmem_alloc addr->alloc_handle = ion_alloc( ddl_context->video_ion_client, alloc_size, SZ_4K, - res_trk_get_mem_type(), 0); + res_trk_get_mem_type(), + res_trk_get_ion_flags()); if (IS_ERR_OR_NULL(addr->alloc_handle)) { DDL_MSG_ERROR("%s() :DDL ION alloc failed\n", __func__); @@ -843,17 +844,31 @@ int res_trk_get_mem_type(void) if (resource_context.vidc_platform_data->enable_ion) { if (res_trk_check_for_sec_session()) { mem_type = ION_HEAP(mem_type); - if (resource_context.res_mem_type != DDL_FW_MEM) - mem_type |= ION_SECURE; - else if (res_trk_is_cp_enabled()) - mem_type |= ION_SECURE; } else mem_type = (ION_HEAP(mem_type) | ION_HEAP(ION_IOMMU_HEAP_ID)); } + return mem_type; } +unsigned int res_trk_get_ion_flags(void) +{ + unsigned int flags = 0; + if (resource_context.res_mem_type == DDL_FW_MEM) + return flags; + + if (resource_context.vidc_platform_data->enable_ion) { + if (res_trk_check_for_sec_session()) { + if (resource_context.res_mem_type != DDL_FW_MEM) + flags |= ION_SECURE; + else if (res_trk_is_cp_enabled()) + flags |= ION_SECURE; + } + } + return flags; +} + u32 res_trk_is_cp_enabled(void) { if (resource_context.vidc_platform_data->cp_enabled) diff --git a/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker_api.h b/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker_api.h index 2ae2512629cc..ee876f487711 100644 --- a/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker_api.h +++ b/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker_api.h @@ -30,6 +30,7 @@ u32 res_trk_download_firmware(void); u32 res_trk_get_core_type(void); u32 res_trk_get_firmware_addr(struct ddl_buf_addr *firm_addr); int res_trk_get_mem_type(void); +unsigned int res_trk_get_ion_flags(void); u32 res_trk_get_enable_ion(void); u32 res_trk_is_cp_enabled(void); u32 res_trk_get_disable_fullhd(void); diff --git a/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker.c b/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker.c index aee9dfe9e97f..1a7528609f27 100644 --- a/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker.c +++ b/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker.c @@ -760,6 +760,11 @@ u32 res_trk_get_disable_fullhd(void) return 0; } +u32 res_trk_get_ion_flags(void) +{ + return 0; +} + int res_trk_check_for_sec_session() { return 0; diff --git a/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker_api.h b/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker_api.h index 75fdb3e1bf90..a20d9f25b73c 100644 --- a/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker_api.h +++ b/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker_api.h @@ -29,6 +29,7 @@ u32 res_trk_download_firmware(void); u32 res_trk_get_core_type(void); u32 res_trk_get_mem_type(void); u32 res_trk_get_disable_fullhd(void); +u32 res_trk_get_ion_flags(void); u32 res_trk_get_enable_ion(void); u32 res_trk_is_cp_enabled(void); struct ion_client *res_trk_get_ion_client(void); diff --git a/drivers/video/msm/vidc/common/vcd/vcd_sub.c b/drivers/video/msm/vidc/common/vcd/vcd_sub.c index 0d9a0c9358b0..9162b4fce3a2 100644 --- a/drivers/video/msm/vidc/common/vcd/vcd_sub.c +++ b/drivers/video/msm/vidc/common/vcd/vcd_sub.c @@ -92,7 +92,7 @@ static int vcd_pmem_alloc(size_t sz, u8 **kernel_vaddr, u8 **phy_addr, } else { map_buffer->alloc_handle = ion_alloc( cctxt->vcd_ion_client, sz, SZ_4K, - memtype, 0); + memtype, res_trk_get_ion_flags()); if (!map_buffer->alloc_handle) { pr_err("%s() ION alloc failed", __func__); goto bailout;