Loading msm/vidc/hfi_common.c +2 −0 Original line number Diff line number Diff line Loading @@ -3956,6 +3956,7 @@ static int __protect_cp_mem(struct venus_hfi_device *device) memprot.cp_nonpixel_start = 0x0; memprot.cp_nonpixel_size = 0x0; mutex_lock(&device->res->cb_lock); list_for_each_entry(cb, &device->res->context_banks, list) { if (!strcmp(cb->name, "venus_ns")) { desc.args[1] = memprot.cp_size = Loading @@ -3974,6 +3975,7 @@ static int __protect_cp_mem(struct venus_hfi_device *device) memprot.cp_nonpixel_size); } } mutex_unlock(&device->res->cb_lock); desc.arginfo = SCM_ARGS(4); rc = scm_call2(SCM_SIP_FNID(SCM_SVC_MP, Loading msm/vidc/msm_smem.c +2 −0 Original line number Diff line number Diff line Loading @@ -591,6 +591,7 @@ struct context_bank_info *msm_smem_get_context_bank(u32 session_type, buffer_type = HAL_BUFFER_INTERNAL_PERSIST_1; } mutex_lock(&res->cb_lock); list_for_each_entry(cb, &res->context_banks, list) { if (cb->is_secure == is_secure && cb->buffer_type & buffer_type) { Loading @@ -598,6 +599,7 @@ struct context_bank_info *msm_smem_get_context_bank(u32 session_type, break; } } mutex_unlock(&res->cb_lock); if (!match) s_vpr_e(sid, "%s: cb not found for buffer_type %x, is_secure %d\n", Loading msm/vidc/msm_v4l2_vidc.c +2 −0 Original line number Diff line number Diff line Loading @@ -313,6 +313,7 @@ static int msm_vidc_initialize_core(struct platform_device *pdev, INIT_LIST_HEAD(&core->instances); mutex_init(&core->lock); mutex_init(&core->resources.cb_lock); core->state = VIDC_CORE_UNINIT; for (i = SYS_MSG_INDEX(SYS_MSG_START); Loading Loading @@ -697,6 +698,7 @@ static int msm_vidc_remove(struct platform_device *pdev) msm_vidc_free_platform_resources(&core->resources); sysfs_remove_group(&pdev->dev.kobj, &msm_vidc_core_attr_group); dev_set_drvdata(&pdev->dev, NULL); mutex_destroy(&core->resources.cb_lock); mutex_destroy(&core->lock); kfree(core); return rc; Loading msm/vidc/msm_vidc_common.c +48 −8 Original line number Diff line number Diff line Loading @@ -5766,26 +5766,29 @@ int msm_comm_check_memory_supported(struct msm_vidc_inst *vidc_inst) struct msm_vidc_format *fmt; struct v4l2_format *f; struct hal_buffer_requirements *req; struct context_bank_info *cb = NULL; u32 i, dpb_cnt = 0, dpb_size = 0, rc = 0; u64 mem_size = 0; u32 inst_mem_size, non_sec_cb_size = 0; u64 total_mem_size = 0, non_sec_mem_size = 0; u32 memory_limit_mbytes; core = vidc_inst->core; mutex_lock(&core->lock); list_for_each_entry(inst, &core->instances, list) { inst_mem_size = 0; /* input port buffers memory size */ fmt = &inst->fmts[INPUT_PORT]; f = &fmt->v4l2_fmt; for (i = 0; i < f->fmt.pix_mp.num_planes; i++) mem_size += f->fmt.pix_mp.plane_fmt[i].sizeimage * inst_mem_size += f->fmt.pix_mp.plane_fmt[i].sizeimage * fmt->count_actual; /* output port buffers memory size */ fmt = &inst->fmts[OUTPUT_PORT]; f = &fmt->v4l2_fmt; for (i = 0; i < f->fmt.pix_mp.num_planes; i++) mem_size += f->fmt.pix_mp.plane_fmt[i].sizeimage * inst_mem_size += f->fmt.pix_mp.plane_fmt[i].sizeimage * fmt->count_actual; /* dpb buffers memory size */ Loading @@ -5802,29 +5805,49 @@ int msm_comm_check_memory_supported(struct msm_vidc_inst *vidc_inst) } dpb_cnt = dpb.buffer_count_actual; dpb_size = dpb.buffer_size; mem_size += dpb_cnt * dpb_size; inst_mem_size += dpb_cnt * dpb_size; } /* internal buffers memory size */ for (i = 0; i < HAL_BUFFER_MAX; i++) { req = &inst->buff_req.buffer[i]; if (is_internal_buffer(req->buffer_type)) mem_size += req->buffer_size * inst_mem_size += req->buffer_size * req->buffer_count_actual; } if (!is_secure_session(inst)) non_sec_mem_size += inst_mem_size; total_mem_size += inst_mem_size; } mutex_unlock(&core->lock); memory_limit_mbytes = msm_comm_get_memory_limit(core); if ((mem_size >> 20) > memory_limit_mbytes) { if ((total_mem_size >> 20) > memory_limit_mbytes) { s_vpr_e(vidc_inst->sid, "%s: video mem overshoot - reached %llu MB, max_limit %llu MB\n", __func__, mem_size >> 20, memory_limit_mbytes); msm_comm_print_mem_usage(core); __func__, total_mem_size >> 20, memory_limit_mbytes); msm_comm_print_insts_info(core); return -EBUSY; } if (!is_secure_session(vidc_inst)) { mutex_lock(&core->resources.cb_lock); list_for_each_entry(cb, &core->resources.context_banks, list) if (!cb->is_secure) non_sec_cb_size = cb->addr_range.size; mutex_unlock(&core->resources.cb_lock); if (non_sec_mem_size > non_sec_cb_size) { s_vpr_e(vidc_inst->sid, "%s: insufficient device addr space, required %llu, available %llu\n", __func__, non_sec_mem_size, non_sec_cb_size); msm_comm_print_insts_info(core); return -EINVAL; } } return 0; } Loading Loading @@ -6343,6 +6366,23 @@ void msm_comm_print_inst_info(struct msm_vidc_inst *inst) mutex_unlock(&inst->cvpbufs.lock); } void msm_comm_print_insts_info(struct msm_vidc_core *core) { struct msm_vidc_inst *inst = NULL; if (!core) { d_vpr_e("%s: invalid params\n", __func__); return; } msm_comm_print_mem_usage(core); mutex_lock(&core->lock); list_for_each_entry(inst, &core->instances, list) msm_comm_print_inst_info(inst); mutex_unlock(&core->lock); } int msm_comm_session_continue(void *instance) { struct msm_vidc_inst *inst = instance; Loading msm/vidc/msm_vidc_common.h +1 −0 Original line number Diff line number Diff line Loading @@ -295,6 +295,7 @@ int msm_comm_ctrl_deinit(struct msm_vidc_inst *inst); void msm_comm_cleanup_internal_buffers(struct msm_vidc_inst *inst); bool msm_comm_turbo_session(struct msm_vidc_inst *inst); void msm_comm_print_inst_info(struct msm_vidc_inst *inst); void msm_comm_print_insts_info(struct msm_vidc_core *core); int msm_comm_v4l2_to_hfi(int id, int value, u32 sid); int msm_comm_hfi_to_v4l2(int id, int value, u32 sid); int msm_comm_get_v4l2_profile(int fourcc, int profile, u32 sid); Loading Loading
msm/vidc/hfi_common.c +2 −0 Original line number Diff line number Diff line Loading @@ -3956,6 +3956,7 @@ static int __protect_cp_mem(struct venus_hfi_device *device) memprot.cp_nonpixel_start = 0x0; memprot.cp_nonpixel_size = 0x0; mutex_lock(&device->res->cb_lock); list_for_each_entry(cb, &device->res->context_banks, list) { if (!strcmp(cb->name, "venus_ns")) { desc.args[1] = memprot.cp_size = Loading @@ -3974,6 +3975,7 @@ static int __protect_cp_mem(struct venus_hfi_device *device) memprot.cp_nonpixel_size); } } mutex_unlock(&device->res->cb_lock); desc.arginfo = SCM_ARGS(4); rc = scm_call2(SCM_SIP_FNID(SCM_SVC_MP, Loading
msm/vidc/msm_smem.c +2 −0 Original line number Diff line number Diff line Loading @@ -591,6 +591,7 @@ struct context_bank_info *msm_smem_get_context_bank(u32 session_type, buffer_type = HAL_BUFFER_INTERNAL_PERSIST_1; } mutex_lock(&res->cb_lock); list_for_each_entry(cb, &res->context_banks, list) { if (cb->is_secure == is_secure && cb->buffer_type & buffer_type) { Loading @@ -598,6 +599,7 @@ struct context_bank_info *msm_smem_get_context_bank(u32 session_type, break; } } mutex_unlock(&res->cb_lock); if (!match) s_vpr_e(sid, "%s: cb not found for buffer_type %x, is_secure %d\n", Loading
msm/vidc/msm_v4l2_vidc.c +2 −0 Original line number Diff line number Diff line Loading @@ -313,6 +313,7 @@ static int msm_vidc_initialize_core(struct platform_device *pdev, INIT_LIST_HEAD(&core->instances); mutex_init(&core->lock); mutex_init(&core->resources.cb_lock); core->state = VIDC_CORE_UNINIT; for (i = SYS_MSG_INDEX(SYS_MSG_START); Loading Loading @@ -697,6 +698,7 @@ static int msm_vidc_remove(struct platform_device *pdev) msm_vidc_free_platform_resources(&core->resources); sysfs_remove_group(&pdev->dev.kobj, &msm_vidc_core_attr_group); dev_set_drvdata(&pdev->dev, NULL); mutex_destroy(&core->resources.cb_lock); mutex_destroy(&core->lock); kfree(core); return rc; Loading
msm/vidc/msm_vidc_common.c +48 −8 Original line number Diff line number Diff line Loading @@ -5766,26 +5766,29 @@ int msm_comm_check_memory_supported(struct msm_vidc_inst *vidc_inst) struct msm_vidc_format *fmt; struct v4l2_format *f; struct hal_buffer_requirements *req; struct context_bank_info *cb = NULL; u32 i, dpb_cnt = 0, dpb_size = 0, rc = 0; u64 mem_size = 0; u32 inst_mem_size, non_sec_cb_size = 0; u64 total_mem_size = 0, non_sec_mem_size = 0; u32 memory_limit_mbytes; core = vidc_inst->core; mutex_lock(&core->lock); list_for_each_entry(inst, &core->instances, list) { inst_mem_size = 0; /* input port buffers memory size */ fmt = &inst->fmts[INPUT_PORT]; f = &fmt->v4l2_fmt; for (i = 0; i < f->fmt.pix_mp.num_planes; i++) mem_size += f->fmt.pix_mp.plane_fmt[i].sizeimage * inst_mem_size += f->fmt.pix_mp.plane_fmt[i].sizeimage * fmt->count_actual; /* output port buffers memory size */ fmt = &inst->fmts[OUTPUT_PORT]; f = &fmt->v4l2_fmt; for (i = 0; i < f->fmt.pix_mp.num_planes; i++) mem_size += f->fmt.pix_mp.plane_fmt[i].sizeimage * inst_mem_size += f->fmt.pix_mp.plane_fmt[i].sizeimage * fmt->count_actual; /* dpb buffers memory size */ Loading @@ -5802,29 +5805,49 @@ int msm_comm_check_memory_supported(struct msm_vidc_inst *vidc_inst) } dpb_cnt = dpb.buffer_count_actual; dpb_size = dpb.buffer_size; mem_size += dpb_cnt * dpb_size; inst_mem_size += dpb_cnt * dpb_size; } /* internal buffers memory size */ for (i = 0; i < HAL_BUFFER_MAX; i++) { req = &inst->buff_req.buffer[i]; if (is_internal_buffer(req->buffer_type)) mem_size += req->buffer_size * inst_mem_size += req->buffer_size * req->buffer_count_actual; } if (!is_secure_session(inst)) non_sec_mem_size += inst_mem_size; total_mem_size += inst_mem_size; } mutex_unlock(&core->lock); memory_limit_mbytes = msm_comm_get_memory_limit(core); if ((mem_size >> 20) > memory_limit_mbytes) { if ((total_mem_size >> 20) > memory_limit_mbytes) { s_vpr_e(vidc_inst->sid, "%s: video mem overshoot - reached %llu MB, max_limit %llu MB\n", __func__, mem_size >> 20, memory_limit_mbytes); msm_comm_print_mem_usage(core); __func__, total_mem_size >> 20, memory_limit_mbytes); msm_comm_print_insts_info(core); return -EBUSY; } if (!is_secure_session(vidc_inst)) { mutex_lock(&core->resources.cb_lock); list_for_each_entry(cb, &core->resources.context_banks, list) if (!cb->is_secure) non_sec_cb_size = cb->addr_range.size; mutex_unlock(&core->resources.cb_lock); if (non_sec_mem_size > non_sec_cb_size) { s_vpr_e(vidc_inst->sid, "%s: insufficient device addr space, required %llu, available %llu\n", __func__, non_sec_mem_size, non_sec_cb_size); msm_comm_print_insts_info(core); return -EINVAL; } } return 0; } Loading Loading @@ -6343,6 +6366,23 @@ void msm_comm_print_inst_info(struct msm_vidc_inst *inst) mutex_unlock(&inst->cvpbufs.lock); } void msm_comm_print_insts_info(struct msm_vidc_core *core) { struct msm_vidc_inst *inst = NULL; if (!core) { d_vpr_e("%s: invalid params\n", __func__); return; } msm_comm_print_mem_usage(core); mutex_lock(&core->lock); list_for_each_entry(inst, &core->instances, list) msm_comm_print_inst_info(inst); mutex_unlock(&core->lock); } int msm_comm_session_continue(void *instance) { struct msm_vidc_inst *inst = instance; Loading
msm/vidc/msm_vidc_common.h +1 −0 Original line number Diff line number Diff line Loading @@ -295,6 +295,7 @@ int msm_comm_ctrl_deinit(struct msm_vidc_inst *inst); void msm_comm_cleanup_internal_buffers(struct msm_vidc_inst *inst); bool msm_comm_turbo_session(struct msm_vidc_inst *inst); void msm_comm_print_inst_info(struct msm_vidc_inst *inst); void msm_comm_print_insts_info(struct msm_vidc_core *core); int msm_comm_v4l2_to_hfi(int id, int value, u32 sid); int msm_comm_hfi_to_v4l2(int id, int value, u32 sid); int msm_comm_get_v4l2_profile(int fourcc, int profile, u32 sid); Loading