From 7e866a6a3c62c37ab4cff0447b0d3bf6596f859c Mon Sep 17 00:00:00 2001 From: Chinmay Sawarkar Date: Tue, 11 Jun 2019 10:46:04 -0700 Subject: [PATCH 1/3] msm: vidc: Initialize max cf and max cr values CF and CR cannot be zero. Initialization of Min/Max values keeps the values within limits, when FW does not provide them. Also, do not modify CF, CR value based on DCVS. Always use worst case values. CRs-Fixed: 2467542 Change-Id: I91ed83cb5c9e1a8cda5775c491d99b97c4043a12 Signed-off-by: Chinmay Sawarkar --- msm/vidc/msm_vidc_bus.h | 1 - msm/vidc/msm_vidc_clocks.c | 22 ++++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/msm/vidc/msm_vidc_bus.h b/msm/vidc/msm_vidc_bus.h index 66d65d4b5ebd..919ee1cd3587 100644 --- a/msm/vidc/msm_vidc_bus.h +++ b/msm/vidc/msm_vidc_bus.h @@ -226,7 +226,6 @@ struct vidc_bus_vote_data { int input_cr; u32 ddr_bw; u32 sys_cache_bw; - bool use_dpb_read; unsigned int lcu_size; unsigned int fps; enum msm_vidc_power_mode power_mode; diff --git a/msm/vidc/msm_vidc_clocks.c b/msm/vidc/msm_vidc_clocks.c index cfbaddff1f62..1151b0be8a89 100755 --- a/msm/vidc/msm_vidc_clocks.c +++ b/msm/vidc/msm_vidc_clocks.c @@ -14,7 +14,7 @@ #define MSM_VIDC_MAX_UBWC_COMPLEXITY_FACTOR (4 << 16) #define MSM_VIDC_MIN_UBWC_COMPRESSION_RATIO (1 << 16) -#define MSM_VIDC_MAX_UBWC_COMPRESSION_RATIO (5 << 16) +#define MSM_VIDC_MAX_UBWC_COMPRESSION_RATIO (3 << 16) static int msm_vidc_decide_work_mode_ar50(struct msm_vidc_inst *inst); static unsigned long msm_vidc_calc_freq_ar50(struct msm_vidc_inst *inst, @@ -167,6 +167,7 @@ void update_recon_stats(struct msm_vidc_inst *inst, recon_stats->buffer_index) { binfo->CR = CR; binfo->CF = CF; + break; } } mutex_unlock(&inst->reconbufs.lock); @@ -177,10 +178,12 @@ static int fill_dynamic_stats(struct msm_vidc_inst *inst, { struct recon_buf *binfo, *nextb; struct vidc_input_cr_data *temp, *next; - u32 min_cf = MSM_VIDC_MAX_UBWC_COMPLEXITY_FACTOR, max_cf = 0; - u32 min_input_cr = MSM_VIDC_MAX_UBWC_COMPRESSION_RATIO, - max_input_cr = 0; - u32 min_cr = MSM_VIDC_MAX_UBWC_COMPRESSION_RATIO, max_cr = 0; + u32 max_cr = MSM_VIDC_MIN_UBWC_COMPRESSION_RATIO; + u32 max_cf = MSM_VIDC_MIN_UBWC_COMPLEXITY_FACTOR; + u32 max_input_cr = MSM_VIDC_MIN_UBWC_COMPRESSION_RATIO; + u32 min_cf = MSM_VIDC_MAX_UBWC_COMPLEXITY_FACTOR; + u32 min_input_cr = MSM_VIDC_MAX_UBWC_COMPRESSION_RATIO; + u32 min_cr = MSM_VIDC_MAX_UBWC_COMPRESSION_RATIO; mutex_lock(&inst->reconbufs.lock); list_for_each_entry_safe(binfo, nextb, &inst->reconbufs.list, list) { @@ -215,15 +218,6 @@ static int fill_dynamic_stats(struct msm_vidc_inst *inst, vote_data->compression_ratio = min_cr; vote_data->complexity_factor = max_cf; vote_data->input_cr = min_input_cr; - vote_data->use_dpb_read = false; - - /* Check if driver can vote for lower bus BW */ - if (inst->clk_data.load < inst->clk_data.load_norm) { - vote_data->compression_ratio = max_cr; - vote_data->complexity_factor = min_cf; - vote_data->input_cr = max_input_cr; - vote_data->use_dpb_read = true; - } dprintk(VIDC_PERF, "Input CR = %d Recon CR = %d Complexity Factor = %d\n", From d6ab63aafe6e3d5f44723b23ea9c7c20c7bf7131 Mon Sep 17 00:00:00 2001 From: Chinmay Sawarkar Date: Tue, 11 Jun 2019 12:22:09 -0700 Subject: [PATCH 2/3] msm: vidc: Use frame statistics for decode bw calculations FW provides UBWC_CR_STATS_INFO with every EBD which can be used to accurately calculate BW requirements. Also renamed reconbufs to refbufs, which is common to encode and decode. CRs-Fixed: 2467542 Change-Id: I29afdcd466bd61f455507d30ab7ca951d0e9911c Signed-off-by: Chinmay Sawarkar --- msm/vidc/msm_vidc.c | 2 +- msm/vidc/msm_vidc_clocks.c | 13 ++++++------- msm/vidc/msm_vidc_common.c | 28 +++++++++++----------------- msm/vidc/msm_vidc_internal.h | 2 +- 4 files changed, 19 insertions(+), 26 deletions(-) mode change 100755 => 100644 msm/vidc/msm_vidc.c mode change 100755 => 100644 msm/vidc/msm_vidc_clocks.c diff --git a/msm/vidc/msm_vidc.c b/msm/vidc/msm_vidc.c old mode 100755 new mode 100644 index 9264190be82e..079b73d54f71 --- a/msm/vidc/msm_vidc.c +++ b/msm/vidc/msm_vidc.c @@ -1525,7 +1525,7 @@ void *msm_vidc_open(int core_id, int session_type) INIT_MSM_VIDC_LIST(&inst->outputbufs); INIT_MSM_VIDC_LIST(&inst->registeredbufs); INIT_MSM_VIDC_LIST(&inst->cvpbufs); - INIT_MSM_VIDC_LIST(&inst->reconbufs); + INIT_MSM_VIDC_LIST(&inst->refbufs); INIT_MSM_VIDC_LIST(&inst->eosbufs); INIT_MSM_VIDC_LIST(&inst->etb_data); INIT_MSM_VIDC_LIST(&inst->fbd_data); diff --git a/msm/vidc/msm_vidc_clocks.c b/msm/vidc/msm_vidc_clocks.c old mode 100755 new mode 100644 index 1151b0be8a89..08328f16ff87 --- a/msm/vidc/msm_vidc_clocks.c +++ b/msm/vidc/msm_vidc_clocks.c @@ -160,9 +160,8 @@ void update_recon_stats(struct msm_vidc_inst *inst, CF = recon_stats->complexity_number / frame_size; else CF = MSM_VIDC_MAX_UBWC_COMPLEXITY_FACTOR; - - mutex_lock(&inst->reconbufs.lock); - list_for_each_entry(binfo, &inst->reconbufs.list, list) { + mutex_lock(&inst->refbufs.lock); + list_for_each_entry(binfo, &inst->refbufs.list, list) { if (binfo->buffer_index == recon_stats->buffer_index) { binfo->CR = CR; @@ -170,7 +169,7 @@ void update_recon_stats(struct msm_vidc_inst *inst, break; } } - mutex_unlock(&inst->reconbufs.lock); + mutex_unlock(&inst->refbufs.lock); } static int fill_dynamic_stats(struct msm_vidc_inst *inst, @@ -185,8 +184,8 @@ static int fill_dynamic_stats(struct msm_vidc_inst *inst, u32 min_input_cr = MSM_VIDC_MAX_UBWC_COMPRESSION_RATIO; u32 min_cr = MSM_VIDC_MAX_UBWC_COMPRESSION_RATIO; - mutex_lock(&inst->reconbufs.lock); - list_for_each_entry_safe(binfo, nextb, &inst->reconbufs.list, list) { + mutex_lock(&inst->refbufs.lock); + list_for_each_entry_safe(binfo, nextb, &inst->refbufs.list, list) { if (binfo->CR) { min_cr = min(min_cr, binfo->CR); max_cr = max(max_cr, binfo->CR); @@ -196,7 +195,7 @@ static int fill_dynamic_stats(struct msm_vidc_inst *inst, max_cf = max(max_cf, binfo->CF); } } - mutex_unlock(&inst->reconbufs.lock); + mutex_unlock(&inst->refbufs.lock); mutex_lock(&inst->input_crs.lock); list_for_each_entry_safe(temp, next, &inst->input_crs.list, list) { diff --git a/msm/vidc/msm_vidc_common.c b/msm/vidc/msm_vidc_common.c index 6cb6736dee66..d285cd713f7c 100644 --- a/msm/vidc/msm_vidc_common.c +++ b/msm/vidc/msm_vidc_common.c @@ -4891,13 +4891,13 @@ int msm_comm_release_recon_buffers(struct msm_vidc_inst *inst) return -EINVAL; } - mutex_lock(&inst->reconbufs.lock); - list_for_each_entry_safe(buf, next, &inst->reconbufs.list, list) { + mutex_lock(&inst->refbufs.lock); + list_for_each_entry_safe(buf, next, &inst->refbufs.list, list) { list_del(&buf->list); kfree(buf); } - INIT_LIST_HEAD(&inst->reconbufs.list); - mutex_unlock(&inst->reconbufs.lock); + INIT_LIST_HEAD(&inst->refbufs.list); + mutex_unlock(&inst->refbufs.lock); return 0; } @@ -5049,32 +5049,26 @@ error: int msm_comm_set_recon_buffers(struct msm_vidc_inst *inst) { int rc = 0; - unsigned int i = 0; - struct hal_buffer_requirements *internal_buf; + unsigned int i = 0, bufcount = 0; struct recon_buf *binfo; - struct msm_vidc_list *buf_list = &inst->reconbufs; + struct msm_vidc_list *buf_list = &inst->refbufs; if (!inst) { dprintk(VIDC_ERR, "%s invalid parameters\n", __func__); return -EINVAL; } - if (inst->session_type != MSM_VIDC_ENCODER) { - dprintk(VIDC_HIGH, "Recon buffs not req for decoder/cvp\n"); + if (inst->session_type != MSM_VIDC_ENCODER && + inst->session_type != MSM_VIDC_DECODER) { + dprintk(VIDC_HIGH, "Recon buffs not req for cvp\n"); return 0; } - internal_buf = get_buff_req_buffer(inst, - HAL_BUFFER_INTERNAL_RECON); - if (!internal_buf || !internal_buf->buffer_count_actual) { - dprintk(VIDC_HIGH, "Inst : %pK Recon buffers not required\n", - inst); - return 0; - } + bufcount = inst->fmts[OUTPUT_PORT].count_actual; msm_comm_release_recon_buffers(inst); - for (i = 0; i < internal_buf->buffer_count_actual; i++) { + for (i = 0; i < bufcount; i++) { binfo = kzalloc(sizeof(*binfo), GFP_KERNEL); if (!binfo) { dprintk(VIDC_ERR, "Out of memory\n"); diff --git a/msm/vidc/msm_vidc_internal.h b/msm/vidc/msm_vidc_internal.h index 453451851a55..6565760a4c12 100644 --- a/msm/vidc/msm_vidc_internal.h +++ b/msm/vidc/msm_vidc_internal.h @@ -470,7 +470,7 @@ struct msm_vidc_inst { struct msm_vidc_list persistbufs; struct msm_vidc_list pending_getpropq; struct msm_vidc_list outputbufs; - struct msm_vidc_list reconbufs; + struct msm_vidc_list refbufs; struct msm_vidc_list eosbufs; struct msm_vidc_list registeredbufs; struct msm_vidc_list cvpbufs; From fb9ec98d7081c6f57caa6ec41c1a69791d9d7ce4 Mon Sep 17 00:00:00 2001 From: Chinmay Sawarkar Date: Tue, 11 Jun 2019 10:49:27 -0700 Subject: [PATCH 3/3] msm: vidc: Add bw for cbcr dbp read and write As per system requirements this additional bw is needed for decode session. Change-Id: Ia435aadcf78e4e2fd7b01ed00633fa2f38729bc6 Signed-off-by: Chinmay Sawarkar --- msm/vidc/msm_vidc_bus_iris2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/msm/vidc/msm_vidc_bus_iris2.c b/msm/vidc/msm_vidc_bus_iris2.c index bbb640fc46b9..1a9f92529438 100644 --- a/msm/vidc/msm_vidc_bus_iris2.c +++ b/msm/vidc/msm_vidc_bus_iris2.c @@ -171,11 +171,13 @@ static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d, ddr.dpb_read = fp_div(fp_mult(ddr.dpb_read, fp_mult(dpb_factor, motion_vector_complexity)), dpb_read_compression_factor); + ddr.dpb_read += fp_div(ddr.dpb_read, FP_INT(2)); ddr.dpb_write = dpb_bpp == 8 ? y_bw_no_ubwc_8bpp : y_bw_no_ubwc_10bpp; ddr.dpb_write = fp_div(fp_mult(ddr.dpb_write, fp_mult(dpb_factor, dpb_write_factor)), dpb_write_compression_factor); + ddr.dpb_write += fp_div(ddr.dpb_write, FP_INT(2)); dpb_total = ddr.dpb_read + ddr.dpb_write;