diff --git a/msm/vidc/msm_vidc_common.c b/msm/vidc/msm_vidc_common.c index 24f04f5d0fb4..0b161029896c 100644 --- a/msm/vidc/msm_vidc_common.c +++ b/msm/vidc/msm_vidc_common.c @@ -5261,7 +5261,47 @@ void msm_vidc_ssr_handler(struct work_struct *work) mutex_unlock(&core->lock); } -static int msm_vidc_load_supported(struct msm_vidc_inst *inst) +static int msm_vidc_check_mbpf_supported(struct msm_vidc_inst *inst) +{ + u32 mbpf = 0; + struct msm_vidc_core *core; + struct msm_vidc_inst *temp; + + if (!inst || !inst->core) { + dprintk(VIDC_ERR, "%s: invalid params\n", __func__); + return -EINVAL; + } + core = inst->core; + + if (!core->resources.max_mbpf) { + dprintk(VIDC_DBG, "%s: max mbpf not available\n", + __func__); + return 0; + } + + mutex_lock(&core->lock); + list_for_each_entry(temp, &core->instances, list) { + /* ignore invalid session */ + if (temp->state == MSM_VIDC_CORE_INVALID) + continue; + /* ignore thumbnail session */ + if (is_thumbnail_session(temp)) + continue; + mbpf += NUM_MBS_PER_FRAME( + temp->fmts[INPUT_PORT].v4l2_fmt.fmt.pix_mp.height, + temp->fmts[INPUT_PORT].v4l2_fmt.fmt.pix_mp.width); + } + mutex_unlock(&core->lock); + + if (mbpf > core->resources.max_mbpf) { + msm_vidc_print_running_insts(inst->core); + return -EBUSY; + } + + return 0; +} + +static int msm_vidc_check_mbps_supported(struct msm_vidc_inst *inst) { int num_mbs_per_sec = 0, max_load_adj = 0; enum load_calc_quirks quirks = LOAD_CALC_IGNORE_TURBO_LOAD | @@ -5389,13 +5429,17 @@ int msm_vidc_check_session_supported(struct msm_vidc_inst *inst) capability = &inst->capability; hdev = inst->core->device; core = inst->core; - rc = msm_vidc_load_supported(inst); + rc = msm_vidc_check_mbps_supported(inst); if (rc) { dprintk(VIDC_WARN, "%s: Hardware is overloaded\n", __func__); return rc; } + rc = msm_vidc_check_mbpf_supported(inst); + if (rc) + return rc; + if (!is_thermal_permissible(core)) { dprintk(VIDC_WARN, "Thermal level critical, stop all active sessions!\n"); diff --git a/msm/vidc/msm_vidc_platform.c b/msm/vidc/msm_vidc_platform.c index ca454c39bc88..97a734ad5391 100644 --- a/msm/vidc/msm_vidc_platform.c +++ b/msm/vidc/msm_vidc_platform.c @@ -532,6 +532,10 @@ static struct msm_vidc_common_data kona_common_data[] = { * 8192x4320@48fps */ }, + { + .key = "qcom,max-mbpf", + .value = 138240, /* (8192x4320)/256 */ + }, { .key = "qcom,max-hq-mbs-per-frame", .value = 34560, /* 4096x2160 */ diff --git a/msm/vidc/msm_vidc_res_parse.c b/msm/vidc/msm_vidc_res_parse.c index b1e46a5db018..816a8a4eac14 100644 --- a/msm/vidc/msm_vidc_res_parse.c +++ b/msm/vidc/msm_vidc_res_parse.c @@ -777,6 +777,9 @@ int read_platform_resources_from_drv_data( res->max_load = find_key_value(platform_data, "qcom,max-hw-load"); + res->max_mbpf = find_key_value(platform_data, + "qcom,max-mbpf"); + res->max_hq_mbs_per_frame = find_key_value(platform_data, "qcom,max-hq-mbs-per-frame"); diff --git a/msm/vidc/msm_vidc_resources.h b/msm/vidc/msm_vidc_resources.h index 59847ea39a6b..90d4d03d7df2 100644 --- a/msm/vidc/msm_vidc_resources.h +++ b/msm/vidc/msm_vidc_resources.h @@ -166,6 +166,7 @@ struct msm_vidc_platform_resources { struct addr_set qdss_addr_set; struct buffer_usage_set buffer_usage_set; uint32_t max_load; + uint32_t max_mbpf; uint32_t max_hq_mbs_per_frame; uint32_t max_hq_mbs_per_sec; uint32_t max_bframe_mbs_per_frame;