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

Commit 730fc7cd authored by Govindaraj Rajagopal's avatar Govindaraj Rajagopal
Browse files

msm: vidc: add active session check for clk and bus vote calculation



After couple of buffer transaction, sometimes session will be idle,
So do not consider inactive sessions for clk scaling and bus vote
calculation.

Change-Id: Ib4cc7606da6c828ce1d9108528a2cbbad4e5f6e4
Signed-off-by: default avatarGovindaraj Rajagopal <grajagop@codeaurora.org>
parent 951bb6d9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -391,6 +391,8 @@ int msm_vidc_qbuf(void *instance, struct v4l2_buffer *b)
		return -EINVAL;
	}

	inst->last_qbuf_time_ns = ktime_get_ns();

	for (i = 0; i < b->length; i++) {
		b->m.planes[i].m.fd =
				b->m.planes[i].reserved[MSM_VIDC_BUFFER_FD];
@@ -1483,6 +1485,7 @@ void *msm_vidc_open(int core_id, int session_type)
	inst->max_filled_len = 0;
	inst->entropy_mode = HFI_H264_ENTROPY_CABAC;
	inst->full_range = COLOR_RANGE_UNSPECIFIED;
	inst->active = true;

	for (i = SESSION_MSG_INDEX(SESSION_MSG_START);
		i <= SESSION_MSG_INDEX(SESSION_MSG_END); i++) {
+38 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@
#define MSM_VIDC_MIN_UBWC_COMPRESSION_RATIO (1 << 16)
#define MSM_VIDC_MAX_UBWC_COMPRESSION_RATIO (5 << 16)

#define MSM_VIDC_SESSION_INACTIVE_THRESHOLD_MS 1000

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,
	u32 filled_len);
@@ -172,6 +174,19 @@ int msm_vidc_get_fps(struct msm_vidc_inst *inst)
	return fps;
}

static inline bool is_active_session(u64 prev, u64 curr)
{
	u64 ts_delta;

	if (!prev || !curr)
		return true;

	ts_delta = (prev < curr) ? curr - prev : prev - curr;

	return ((ts_delta / NSEC_PER_MSEC) <=
			MSM_VIDC_SESSION_INACTIVE_THRESHOLD_MS);
}

void update_recon_stats(struct msm_vidc_inst *inst,
	struct recon_stats_type *recon_stats)
{
@@ -265,12 +280,14 @@ int msm_comm_set_buses(struct msm_vidc_core *core, u32 sid)
	struct msm_vidc_inst *inst = NULL;
	struct hfi_device *hdev;
	unsigned long total_bw_ddr = 0, total_bw_llcc = 0;
	u64 curr_time_ns;

	if (!core || !core->device) {
		s_vpr_e(sid, "%s: Invalid args: %pK\n", __func__, core);
		return -EINVAL;
	}
	hdev = core->device;
	curr_time_ns = ktime_get_ns();

	mutex_lock(&core->lock);
	list_for_each_entry(inst, &core->instances, list) {
@@ -295,6 +312,12 @@ int msm_comm_set_buses(struct msm_vidc_core *core, u32 sid)
			continue;
		}

		/* skip inactive session bus bandwidth */
		if (!is_active_session(inst->last_qbuf_time_ns, curr_time_ns)) {
			inst->active = false;
			continue;
		}

		if (inst->bus_data.power_mode == VIDC_POWER_TURBO) {
			total_bw_ddr = total_bw_llcc = INT_MAX;
			break;
@@ -865,8 +888,10 @@ int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid)
	int rc = 0, i = 0;
	struct allowed_clock_rates_table *allowed_clks_tbl = NULL;
	bool increment, decrement;
	u64 curr_time_ns;

	hdev = core->device;
	curr_time_ns = ktime_get_ns();
	allowed_clks_tbl = core->resources.allowed_clks_tbl;
	if (!allowed_clks_tbl) {
		s_vpr_e(sid, "%s: Invalid parameters\n", __func__);
@@ -895,6 +920,12 @@ int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid)
			continue;
		}

		/* skip inactive session clock rate */
		if (!is_active_session(inst->last_qbuf_time_ns, curr_time_ns)) {
			inst->active = false;
			continue;
		}

		if (inst->clk_data.core_id == VIDC_CORE_ID_1)
			freq_core_1 += inst->clk_data.min_freq;
		else if (inst->clk_data.core_id == VIDC_CORE_ID_2)
@@ -1018,6 +1049,12 @@ int msm_comm_scale_clocks_and_bus(struct msm_vidc_inst *inst, bool do_bw_calc)
	core = inst->core;
	hdev = core->device;

	if (!inst->active) {
		/* do not skip bw voting for inactive -> active session */
		do_bw_calc = true;
		inst->active = true;
	}

	if (msm_comm_scale_clocks(inst)) {
		s_vpr_e(inst->sid,
			"Failed to scale clocks. May impact performance\n");
@@ -1029,6 +1066,7 @@ int msm_comm_scale_clocks_and_bus(struct msm_vidc_inst *inst, bool do_bw_calc)
				"Failed to scale DDR bus. May impact perf\n");
		}
	}

	return 0;
}

+2 −0
Original line number Diff line number Diff line
@@ -560,6 +560,8 @@ struct msm_vidc_inst {
	bool is_perf_eligible_session;
	u32 max_filled_len;
	int full_range;
	u64 last_qbuf_time_ns;
	bool active;
};

extern struct msm_vidc_drv *vidc_driver;