msm: vidc: reject sessions based on max mbpf

Driver need not support sessions if cumulative
mbpf (macroblocks per frame) is more than platform
specified value. So reject such sessions.

Change-Id: Id12eedfb97783b746c771066d6a556692be84c9f
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
This commit is contained in:
Maheshwar Ajja 2019-05-09 15:08:51 -07:00
commit 71ce4cbe76
4 changed files with 54 additions and 2 deletions

View file

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

View file

@ -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 */

View file

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

View file

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