msm: vidc: port heap mask change to ion for secure session

Changes to pass ION_SECURE in the correct argument field
while calling ion_alloc. Without this change secure session
fails.

Change-Id: Ifa4878b1c312beafc735cb649570913159799d7c
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
This commit is contained in:
Srinu Gorle 2012-11-03 21:08:56 +05:30 committed by Stephen Boyd
parent 8ad7b2c8e6
commit b769cd0cdd
8 changed files with 37 additions and 11 deletions

View file

@ -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,

View file

@ -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");

View file

@ -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__);

View file

@ -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)

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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;