video: driver: Fix bin buffer allocation in secure usecase
In Secure session, BIN buffer should be allocated from Secure Bitstream region. Allocated buffer must be hypassigned using the DMA buffer Lend call. Change-Id: If5303e78975aab55ac7475ca3ac9f6272585a44b Signed-off-by: Chinmay Sawarkar <chinmays@codeaurora.org>
This commit is contained in:
@@ -881,6 +881,8 @@ u32 msm_vidc_get_buffer_region(struct msm_vidc_inst *inst,
|
||||
region = MSM_VIDC_SECURE_PIXEL;
|
||||
break;
|
||||
case MSM_VIDC_BUF_BIN:
|
||||
region = MSM_VIDC_SECURE_BITSTREAM;
|
||||
break;
|
||||
case MSM_VIDC_BUF_ARP:
|
||||
case MSM_VIDC_BUF_COMV:
|
||||
case MSM_VIDC_BUF_NON_COMV:
|
||||
|
@@ -7,8 +7,8 @@
|
||||
#include <linux/dma-heap.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/qcom-dma-mapping.h>
|
||||
#include <linux/msm_ion.h>
|
||||
#include <linux/ion.h>
|
||||
#include <linux/mem-buf.h>
|
||||
#include <soc/qcom/secure_buffer.h>
|
||||
|
||||
#include "msm_vidc_memory.h"
|
||||
#include "msm_vidc_debug.h"
|
||||
@@ -209,6 +209,9 @@ int msm_vidc_memory_alloc(struct msm_vidc_core *core, struct msm_vidc_alloc *mem
|
||||
int size = 0;
|
||||
struct dma_heap *heap;
|
||||
char *heap_name = NULL;
|
||||
struct mem_buf_lend_kernel_arg lend_arg;
|
||||
int vmids[1];
|
||||
int perms[1];
|
||||
|
||||
if (!mem) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
@@ -226,6 +229,8 @@ int msm_vidc_memory_alloc(struct msm_vidc_core *core, struct msm_vidc_alloc *mem
|
||||
heap_name = "qcom,secure-non-pixel";
|
||||
break;
|
||||
case MSM_VIDC_SECURE_BITSTREAM:
|
||||
heap_name = "qcom,system";
|
||||
break;
|
||||
default:
|
||||
d_vpr_e("invalid secure region : %#x\n", mem->region);
|
||||
return -EINVAL;
|
||||
@@ -243,6 +248,22 @@ int msm_vidc_memory_alloc(struct msm_vidc_core *core, struct msm_vidc_alloc *mem
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (mem->secure && mem->type == MSM_VIDC_BUF_BIN)
|
||||
{
|
||||
vmids[0] = VMID_CP_BITSTREAM;
|
||||
perms[0] = PERM_READ | PERM_WRITE;
|
||||
|
||||
lend_arg.nr_acl_entries = ARRAY_SIZE(vmids);
|
||||
lend_arg.vmids = vmids;
|
||||
lend_arg.perms = perms;
|
||||
|
||||
rc = mem_buf_lend(mem->dmabuf, &lend_arg);
|
||||
if (rc) {
|
||||
d_vpr_e("%s: BIN dmabuf %pK LEND failed, rc %d heap %s\n",
|
||||
__func__, mem->dmabuf, rc, heap_name);
|
||||
}
|
||||
}
|
||||
|
||||
if (mem->map_kernel) {
|
||||
dma_buf_begin_cpu_access(mem->dmabuf, DMA_BIDIRECTIONAL);
|
||||
mem->kvaddr = dma_buf_vmap(mem->dmabuf);
|
||||
|
Reference in New Issue
Block a user