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

Commit 305547ed authored by Saurabh Kothawade's avatar Saurabh Kothawade
Browse files

msm: vidc: Update core and stage selection logic



Update logic that decides number of cores, workmode,
and calculates load to consider few more parameters.

CRs-Fixed: 2091112
Change-Id: I0066b58a894733f589ecf9d6ccb99b2d751bc93e
Signed-off-by: default avatarSaurabh Kothawade <skothawa@codeaurora.org>
parent 089d1cb5
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -510,7 +510,7 @@ static unsigned long msm_vidc_calc_freq(struct msm_vidc_inst *inst,
	u32 vpp_cycles_per_mb;
	u32 mbs_per_second;

	mbs_per_second = msm_comm_get_inst_load(inst,
	mbs_per_second = msm_comm_get_inst_load_per_core(inst,
		LOAD_CALC_NO_QUIRKS);

	/*
@@ -524,6 +524,8 @@ static unsigned long msm_vidc_calc_freq(struct msm_vidc_inst *inst,
			inst->clk_data.entry->low_power_cycles :
			inst->clk_data.entry->vpp_cycles;

		vpp_cycles = mbs_per_second * vpp_cycles_per_mb;

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

		/* 10 / 7 is overhead factor */
@@ -533,7 +535,7 @@ static unsigned long msm_vidc_calc_freq(struct msm_vidc_inst *inst,

		vsp_cycles = mbs_per_second * inst->clk_data.entry->vsp_cycles;
		/* 10 / 7 is overhead factor */
		vsp_cycles += ((inst->prop.fps * filled_len * 8) / 7) * 10;
		vsp_cycles += ((inst->prop.fps * filled_len * 8) * 10) / 7;

	} else {
		dprintk(VIDC_ERR, "Unknown session type = %s\n", __func__);
@@ -619,7 +621,7 @@ int msm_vidc_update_operating_rate(struct msm_vidc_inst *inst)
				temp->state >= MSM_VIDC_RELEASE_RESOURCES_DONE)
			continue;

		mbs_per_second = msm_comm_get_inst_load(temp,
		mbs_per_second = msm_comm_get_inst_load_per_core(temp,
		LOAD_CALC_NO_QUIRKS);

		cycles = temp->clk_data.entry->vpp_cycles;
@@ -820,7 +822,7 @@ void msm_clock_data_reset(struct msm_vidc_inst *inst)

	core = inst->core;
	dcvs = &inst->clk_data;
	load = msm_comm_get_inst_load(inst, LOAD_CALC_NO_QUIRKS);
	load = msm_comm_get_inst_load_per_core(inst, LOAD_CALC_NO_QUIRKS);
	cycles = inst->clk_data.entry->vpp_cycles;
	allowed_clks_tbl = core->resources.allowed_clks_tbl;
	if (inst->session_type == MSM_VIDC_ENCODER) {
@@ -1044,10 +1046,7 @@ static u32 get_core_load(struct msm_vidc_core *core,
		} else {
			continue;
		}
		if (inst->clk_data.core_id == 3)
			cycles = cycles / 2;

		current_inst_mbs_per_sec = msm_comm_get_inst_load(inst,
		current_inst_mbs_per_sec = msm_comm_get_inst_load_per_core(inst,
				LOAD_CALC_NO_QUIRKS);
		load += current_inst_mbs_per_sec * cycles;
	}
@@ -1122,22 +1121,26 @@ int msm_vidc_decide_core_and_power_mode(struct msm_vidc_inst *inst)
	if (inst->session_type == MSM_VIDC_ENCODER && hier_mode) {
		if (current_inst_load / 2 + core0_load <= max_freq &&
			current_inst_load / 2 + core1_load <= max_freq) {
			if (inst->clk_data.work_mode == VIDC_WORK_MODE_2) {
				inst->clk_data.core_id = VIDC_CORE_ID_3;
				msm_vidc_power_save_mode_enable(inst, false);
				goto decision_done;
			}
		}
	}

	if (inst->session_type == MSM_VIDC_ENCODER && hier_mode) {
		if (current_inst_lp_load / 2 +
				core0_lp_load <= max_freq &&
			current_inst_lp_load / 2 +
				core1_lp_load <= max_freq) {
			if (inst->clk_data.work_mode == VIDC_WORK_MODE_2) {
				inst->clk_data.core_id = VIDC_CORE_ID_3;
				msm_vidc_power_save_mode_enable(inst, true);
				goto decision_done;
			}
		}
	}

	if (current_inst_load + min_load < max_freq) {
		inst->clk_data.core_id = min_core_id;
+11 −0
Original line number Diff line number Diff line
@@ -737,6 +737,17 @@ int msm_comm_get_inst_load(struct msm_vidc_inst *inst,
	return load;
}

int msm_comm_get_inst_load_per_core(struct msm_vidc_inst *inst,
		enum load_calc_quirks quirks)
{
	int load = msm_comm_get_inst_load(inst, quirks);

	if (inst->clk_data.core_id == VIDC_CORE_ID_3)
		load = load / 2;

	return load;
}

int msm_comm_get_load(struct msm_vidc_core *core,
	enum session_type type, enum load_calc_quirks quirks)
{
+2 −0
Original line number Diff line number Diff line
@@ -85,6 +85,8 @@ enum hal_domain get_hal_domain(int session_type);
int msm_comm_check_core_init(struct msm_vidc_core *core);
int msm_comm_get_inst_load(struct msm_vidc_inst *inst,
			enum load_calc_quirks quirks);
int msm_comm_get_inst_load_per_core(struct msm_vidc_inst *inst,
			enum load_calc_quirks quirks);
int msm_comm_get_load(struct msm_vidc_core *core,
			enum session_type type, enum load_calc_quirks quirks);
int msm_comm_set_color_format(struct msm_vidc_inst *inst,