Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fdb2864a authored by Qiwei Liu's avatar Qiwei Liu
Browse files

msm: vidc: refine firmware cycle calculation



- Dynamically calculate firmware cycle overhead for
  vpp_cycles, instead of using fixed 1.05.
- Consider firmware cycle for ar50 also.
- Refine vsp bw voting for 1-stage mode.

Change-Id: I7dd4b1bd7877ae1a9e470bc4a1604cb16dff84c8
Signed-off-by: default avatarQiwei Liu <qiweil@codeaurora.org>
parent 51683be8
Loading
Loading
Loading
Loading
+2 −4
Original line number Original line Diff line number Diff line
@@ -446,8 +446,7 @@ static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d,


	bitrate = (d->bitrate + 1000000 - 1) / 1000000;
	bitrate = (d->bitrate + 1000000 - 1) / 1000000;


	bins_to_bit_factor = d->work_mode == VIDC_WORK_MODE_1 ?
	bins_to_bit_factor = FP_INT(4);
		FP_INT(0) : FP_INT(4);
	vsp_write_factor = bins_to_bit_factor;
	vsp_write_factor = bins_to_bit_factor;
	vsp_read_factor = bins_to_bit_factor + FP_INT(2);
	vsp_read_factor = bins_to_bit_factor + FP_INT(2);


@@ -684,8 +683,7 @@ static unsigned long __calculate_encoder(struct vidc_bus_vote_data *d,


	work_mode_1 = d->work_mode == VIDC_WORK_MODE_1;
	work_mode_1 = d->work_mode == VIDC_WORK_MODE_1;
	low_power = d->power_mode == VIDC_POWER_LOW;
	low_power = d->power_mode == VIDC_POWER_LOW;
	bins_to_bit_factor = work_mode_1 ?
	bins_to_bit_factor = FP_INT(4);
		FP_INT(0) : FP_INT(4);


	if (d->use_sys_cache) {
	if (d->use_sys_cache) {
		llc_ref_chroma_cache_enabled = true;
		llc_ref_chroma_cache_enabled = true;
+22 −13
Original line number Original line Diff line number Diff line
@@ -551,6 +551,7 @@ static unsigned long msm_vidc_calc_freq_ar50(struct msm_vidc_inst *inst,
{
{
	unsigned long freq = 0;
	unsigned long freq = 0;
	unsigned long vpp_cycles = 0, vsp_cycles = 0;
	unsigned long vpp_cycles = 0, vsp_cycles = 0;
	unsigned long fw_cycles = 0, fw_vpp_cycles = 0;
	u32 vpp_cycles_per_mb;
	u32 vpp_cycles_per_mb;
	u32 mbs_per_second;
	u32 mbs_per_second;
	struct msm_vidc_core *core = NULL;
	struct msm_vidc_core *core = NULL;
@@ -573,12 +574,17 @@ static unsigned long msm_vidc_calc_freq_ar50(struct msm_vidc_inst *inst,
	 * between them.
	 * between them.
	 */
	 */


	fw_cycles = fps * inst->core->resources.fw_cycles;
	fw_vpp_cycles = fps * inst->core->resources.fw_vpp_cycles;

	if (inst->session_type == MSM_VIDC_ENCODER) {
	if (inst->session_type == MSM_VIDC_ENCODER) {
		vpp_cycles_per_mb = inst->flags & VIDC_LOW_POWER ?
		vpp_cycles_per_mb = inst->flags & VIDC_LOW_POWER ?
			inst->clk_data.entry->low_power_cycles :
			inst->clk_data.entry->low_power_cycles :
			inst->clk_data.entry->vpp_cycles;
			inst->clk_data.entry->vpp_cycles;


		vpp_cycles = mbs_per_second * vpp_cycles_per_mb;
		vpp_cycles = mbs_per_second * vpp_cycles_per_mb;
		/* 21 / 20 is minimum overhead factor */
		vpp_cycles += max(vpp_cycles / 20, fw_vpp_cycles);


		vsp_cycles = mbs_per_second * inst->clk_data.entry->vsp_cycles;
		vsp_cycles = mbs_per_second * inst->clk_data.entry->vsp_cycles;


@@ -586,6 +592,8 @@ static unsigned long msm_vidc_calc_freq_ar50(struct msm_vidc_inst *inst,
		vsp_cycles += (inst->clk_data.bitrate * 10) / 7;
		vsp_cycles += (inst->clk_data.bitrate * 10) / 7;
	} else if (inst->session_type == MSM_VIDC_DECODER) {
	} else if (inst->session_type == MSM_VIDC_DECODER) {
		vpp_cycles = mbs_per_second * inst->clk_data.entry->vpp_cycles;
		vpp_cycles = mbs_per_second * inst->clk_data.entry->vpp_cycles;
		/* 21 / 20 is minimum overhead factor */
		vpp_cycles += max(vpp_cycles / 20, fw_vpp_cycles);


		vsp_cycles = mbs_per_second * inst->clk_data.entry->vsp_cycles;
		vsp_cycles = mbs_per_second * inst->clk_data.entry->vsp_cycles;
		/* 10 / 7 is overhead factor */
		/* 10 / 7 is overhead factor */
@@ -597,6 +605,7 @@ static unsigned long msm_vidc_calc_freq_ar50(struct msm_vidc_inst *inst,
	}
	}


	freq = max(vpp_cycles, vsp_cycles);
	freq = max(vpp_cycles, vsp_cycles);
	freq = max(freq, fw_cycles);


	dprintk(VIDC_DBG, "Update DCVS Load\n");
	dprintk(VIDC_DBG, "Update DCVS Load\n");
	allowed_clks_tbl = core->resources.allowed_clks_tbl;
	allowed_clks_tbl = core->resources.allowed_clks_tbl;
@@ -624,7 +633,8 @@ static unsigned long msm_vidc_calc_freq(struct msm_vidc_inst *inst,
	u32 filled_len)
	u32 filled_len)
{
{
	unsigned long freq = 0;
	unsigned long freq = 0;
	unsigned long vpp_cycles = 0, vsp_cycles = 0, fw_cycles = 0;
	unsigned long vpp_cycles = 0, vsp_cycles = 0;
	unsigned long fw_cycles = 0, fw_vpp_cycles = 0;
	u32 vpp_cycles_per_mb;
	u32 vpp_cycles_per_mb;
	u32 mbs_per_second;
	u32 mbs_per_second;
	struct msm_vidc_core *core = NULL;
	struct msm_vidc_core *core = NULL;
@@ -648,15 +658,18 @@ static unsigned long msm_vidc_calc_freq(struct msm_vidc_inst *inst,
	 * between them.
	 * between them.
	 */
	 */


	fw_cycles = fps * inst->core->resources.fw_cycles;
	fw_vpp_cycles = fps * inst->core->resources.fw_vpp_cycles;

	if (inst->session_type == MSM_VIDC_ENCODER) {
	if (inst->session_type == MSM_VIDC_ENCODER) {
		vpp_cycles_per_mb = inst->flags & VIDC_LOW_POWER ?
		vpp_cycles_per_mb = inst->flags & VIDC_LOW_POWER ?
			inst->clk_data.entry->low_power_cycles :
			inst->clk_data.entry->low_power_cycles :
			inst->clk_data.entry->vpp_cycles;
			inst->clk_data.entry->vpp_cycles;


		vpp_cycles = mbs_per_second * vpp_cycles_per_mb;
		vpp_cycles = mbs_per_second * vpp_cycles_per_mb /
		/* 21 / 20 is overhead factor */
				inst->clk_data.work_route;
		vpp_cycles = (vpp_cycles * 21)/
		/* 21 / 20 is minimum overhead factor */
				(inst->clk_data.work_route * 20);
		vpp_cycles += max(vpp_cycles / 20, fw_vpp_cycles);


		vsp_cycles = mbs_per_second * inst->clk_data.entry->vsp_cycles;
		vsp_cycles = mbs_per_second * inst->clk_data.entry->vsp_cycles;


@@ -669,21 +682,17 @@ static unsigned long msm_vidc_calc_freq(struct msm_vidc_inst *inst,
		vsp_cycles += ((u64)inst->clk_data.bitrate * vsp_factor_num) /
		vsp_cycles += ((u64)inst->clk_data.bitrate * vsp_factor_num) /
				vsp_factor_den;
				vsp_factor_den;


		fw_cycles = fps * inst->core->resources.fw_cycles;

	} else if (inst->session_type == MSM_VIDC_DECODER) {
	} else if (inst->session_type == MSM_VIDC_DECODER) {
		vpp_cycles = mbs_per_second * inst->clk_data.entry->vpp_cycles;
		vpp_cycles = mbs_per_second * inst->clk_data.entry->vpp_cycles /
		/* 21 / 20 is overhead factor */
				inst->clk_data.work_route;
		vpp_cycles = (vpp_cycles * 21)/
		/* 21 / 20 is minimum overhead factor */
				(inst->clk_data.work_route * 20);
		vpp_cycles += max(vpp_cycles / 20, fw_vpp_cycles);


		vsp_cycles = mbs_per_second * inst->clk_data.entry->vsp_cycles;
		vsp_cycles = mbs_per_second * inst->clk_data.entry->vsp_cycles;


		/* vsp perf is about 0.5 bits/cycle */
		/* vsp perf is about 0.5 bits/cycle */
		vsp_cycles += ((fps * filled_len * 8) * 10) / 5;
		vsp_cycles += ((fps * filled_len * 8) * 10) / 5;


		fw_cycles = fps * inst->core->resources.fw_cycles;

	} else {
	} else {
		dprintk(VIDC_ERR, "Unknown session type = %s\n", __func__);
		dprintk(VIDC_ERR, "Unknown session type = %s\n", __func__);
		return msm_vidc_max_freq(inst->core);
		return msm_vidc_max_freq(inst->core);
+18 −2
Original line number Original line Diff line number Diff line
@@ -195,6 +195,10 @@ static struct msm_vidc_common_data sm6150_common_data[] = {
		.key = "qcom,fw-cycles",
		.key = "qcom,fw-cycles",
		.value = 733003,
		.value = 733003,
	},
	},
	{
		.key = "qcom,fw-vpp-cycles",
		.value = 225975,
	},
};
};


static struct msm_vidc_common_data sm8150_common_data[] = {
static struct msm_vidc_common_data sm8150_common_data[] = {
@@ -274,6 +278,10 @@ static struct msm_vidc_common_data sm8150_common_data[] = {
		.key = "qcom,fw-cycles",
		.key = "qcom,fw-cycles",
		.value = 760000,
		.value = 760000,
	},
	},
	{
		.key = "qcom,fw-vpp-cycles",
		.value = 166667,
	},
};
};


static struct msm_vidc_common_data sdmmagpie_common_data_v0[] = {
static struct msm_vidc_common_data sdmmagpie_common_data_v0[] = {
@@ -346,7 +354,11 @@ static struct msm_vidc_common_data sdmmagpie_common_data_v0[] = {
	},
	},
	{
	{
		.key = "qcom,fw-cycles",
		.key = "qcom,fw-cycles",
		.value = 733003,
		.value = 760000,
	},
	{
		.key = "qcom,fw-vpp-cycles",
		.value = 166667,
	},
	},
};
};


@@ -420,7 +432,11 @@ static struct msm_vidc_common_data sdmmagpie_common_data_v1[] = {
	},
	},
	{
	{
		.key = "qcom,fw-cycles",
		.key = "qcom,fw-cycles",
		.value = 733003,
		.value = 760000,
	},
	{
		.key = "qcom,fw-vpp-cycles",
		.value = 166667,
	},
	},
};
};


+2 −0
Original line number Original line Diff line number Diff line
@@ -801,6 +801,8 @@ int read_platform_resources_from_drv_data(
			"qcom,dcvs");
			"qcom,dcvs");
	res->fw_cycles = find_key_value(platform_data,
	res->fw_cycles = find_key_value(platform_data,
			"qcom,fw-cycles");
			"qcom,fw-cycles");
	res->fw_vpp_cycles = find_key_value(platform_data,
			"qcom,fw-vpp-cycles");


	res->csc_coeff_data = &platform_data->csc_data;
	res->csc_coeff_data = &platform_data->csc_data;


+1 −0
Original line number Original line Diff line number Diff line
@@ -201,6 +201,7 @@ struct msm_vidc_platform_resources {
	struct msm_vidc_mem_cdsp mem_cdsp;
	struct msm_vidc_mem_cdsp mem_cdsp;
	uint32_t vpu_ver;
	uint32_t vpu_ver;
	uint32_t fw_cycles;
	uint32_t fw_cycles;
	uint32_t fw_vpp_cycles;
	uint32_t clk_freq_threshold;
	uint32_t clk_freq_threshold;
	struct cx_ipeak_client *cx_ipeak_context;
	struct cx_ipeak_client *cx_ipeak_context;
};
};