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

Commit f9a35e63 authored by Qiwei Liu's avatar Qiwei Liu Committed by Gerrit - the friendly Code Review server
Browse files

msm: vidc: remove redundant freq calculations



Remove freq list, which is unused in current dcvs design.
Remove unused dcvs load, load_low, load_norm, load_high,
as current dcvs design only use min_freq and dcvs_flags.

Change-Id: Ifbf251a9506286f2f34eca6eeb1af79bd07c0f43
Signed-off-by: default avatarQiwei Liu <qiweil@codeaurora.org>
parent 75c4f9c1
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -1567,7 +1567,6 @@ void *msm_vidc_open(int core_id, int session_type)
	mutex_init(&inst->flush_lock);

	INIT_MSM_VIDC_LIST(&inst->scratchbufs);
	INIT_MSM_VIDC_LIST(&inst->freqs);
	INIT_MSM_VIDC_LIST(&inst->input_crs);
	INIT_MSM_VIDC_LIST(&inst->persistbufs);
	INIT_MSM_VIDC_LIST(&inst->pending_getpropq);
@@ -1691,7 +1690,6 @@ void *msm_vidc_open(int core_id, int session_type)
	DEINIT_MSM_VIDC_LIST(&inst->cvpbufs);
	DEINIT_MSM_VIDC_LIST(&inst->registeredbufs);
	DEINIT_MSM_VIDC_LIST(&inst->eosbufs);
	DEINIT_MSM_VIDC_LIST(&inst->freqs);
	DEINIT_MSM_VIDC_LIST(&inst->input_crs);
	DEINIT_MSM_VIDC_LIST(&inst->client_data);
	DEINIT_MSM_VIDC_LIST(&inst->etb_data);
@@ -1748,8 +1746,6 @@ static void msm_vidc_cleanup_instance(struct msm_vidc_inst *inst)

	cancel_batch_work(inst);

	msm_comm_free_freq_table(inst);

	msm_comm_free_input_cr_table(inst);

	if (msm_comm_release_scratch_buffers(inst, false))
@@ -1828,7 +1824,6 @@ int msm_vidc_destroy(struct msm_vidc_inst *inst)
	DEINIT_MSM_VIDC_LIST(&inst->cvpbufs);
	DEINIT_MSM_VIDC_LIST(&inst->registeredbufs);
	DEINIT_MSM_VIDC_LIST(&inst->eosbufs);
	DEINIT_MSM_VIDC_LIST(&inst->freqs);
	DEINIT_MSM_VIDC_LIST(&inst->input_crs);
	DEINIT_MSM_VIDC_LIST(&inst->client_data);
	DEINIT_MSM_VIDC_LIST(&inst->etb_data);
+7 −107
Original line number Diff line number Diff line
@@ -48,15 +48,6 @@ struct msm_vidc_core_ops core_ops_iris2 = {
	.calc_bw = calc_bw_iris2,
};

static inline void msm_dcvs_print_dcvs_stats(struct clock_data *dcvs)
{
	dprintk(VIDC_PERF,
		"DCVS: Loads %lld %lld %lld, Thresholds %d %d %d\n",
		dcvs->load_low, dcvs->load_norm, dcvs->load_high,
		dcvs->min_threshold, dcvs->nom_threshold,
		dcvs->max_threshold);
}

static inline unsigned long get_ubwc_compression_ratio(
	struct ubwc_cr_stats_info_type ubwc_stats_info)
{
@@ -456,7 +447,7 @@ static int msm_dcvs_scale_clocks(struct msm_vidc_inst *inst,
	if (!inst->clk_data.dcvs_mode || inst->batch.enable) {
		dprintk(VIDC_LOW, "Skip DCVS (dcvs %d, batching %d)\n",
			inst->clk_data.dcvs_mode, inst->batch.enable);
		inst->clk_data.load = inst->clk_data.load_norm;
		inst->clk_data.dcvs_flags = 0;
		return 0;
	}

@@ -493,70 +484,22 @@ static int msm_dcvs_scale_clocks(struct msm_vidc_inst *inst,

	if (dcvs->dcvs_window < DCVS_DEC_EXTRA_OUTPUT_BUFFERS ||
		bufs_with_fw == dcvs->nom_threshold) {
		dcvs->load = dcvs->load_norm;
		dcvs->dcvs_flags = 0;
	} else if (bufs_with_fw >= dcvs->max_threshold) {
		dcvs->load = dcvs->load_high;
		dcvs->dcvs_flags |= MSM_VIDC_DCVS_INCR;
	} else if (bufs_with_fw < dcvs->min_threshold) {
		dcvs->load = dcvs->load_low;
		dcvs->dcvs_flags |= MSM_VIDC_DCVS_DECR;
	}

	dprintk(VIDC_PERF,
		"DCVS: %x: bufs_with_fw %d Th[%d %d %d] Flag %#x Load %llu\n",
		"DCVS: %x: bufs_with_fw %d Th[%d %d %d] Flag %#x\n",
		hash32_ptr(inst->session), bufs_with_fw,
		dcvs->min_threshold, dcvs->nom_threshold, dcvs->max_threshold,
		dcvs->dcvs_flags, dcvs->load);
		dcvs->dcvs_flags);

	return rc;
}

static void msm_vidc_update_freq_entry(struct msm_vidc_inst *inst,
	unsigned long freq, u32 device_addr, bool is_turbo)
{
	struct vidc_freq_data *temp, *next;
	bool found = false;

	mutex_lock(&inst->freqs.lock);
	list_for_each_entry_safe(temp, next, &inst->freqs.list, list) {
		if (temp->device_addr == device_addr) {
			temp->freq = freq;
			found = true;
			break;
		}
	}

	if (!found) {
		temp = kzalloc(sizeof(*temp), GFP_KERNEL);
		if (!temp) {
			dprintk(VIDC_ERR, "%s: malloc failure.\n", __func__);
			goto exit;
		}
		temp->freq = freq;
		temp->device_addr = device_addr;
		list_add_tail(&temp->list, &inst->freqs.list);
	}
	temp->turbo = !!is_turbo;
exit:
	mutex_unlock(&inst->freqs.lock);
}

void msm_vidc_clear_freq_entry(struct msm_vidc_inst *inst,
	u32 device_addr)
{
	struct vidc_freq_data *temp, *next;

	mutex_lock(&inst->freqs.lock);
	list_for_each_entry_safe(temp, next, &inst->freqs.list, list) {
		if (temp->device_addr == device_addr)
			temp->freq = 0;
	}
	mutex_unlock(&inst->freqs.lock);

	inst->clk_data.buffer_counter++;
}

static unsigned long msm_vidc_max_freq(struct msm_vidc_core *core)
{
	struct allowed_clock_rates_table *allowed_clks_tbl = NULL;
@@ -568,19 +511,6 @@ static unsigned long msm_vidc_max_freq(struct msm_vidc_core *core)
	return freq;
}

void msm_comm_free_freq_table(struct msm_vidc_inst *inst)
{
	struct vidc_freq_data *temp, *next;

	mutex_lock(&inst->freqs.lock);
	list_for_each_entry_safe(temp, next, &inst->freqs.list, list) {
		list_del(&temp->list);
		kfree(temp);
	}
	INIT_LIST_HEAD(&inst->freqs.list);
	mutex_unlock(&inst->freqs.lock);
}

void msm_comm_free_input_cr_table(struct msm_vidc_inst *inst)
{
	struct vidc_input_cr_data *temp, *next;
@@ -694,14 +624,6 @@ static unsigned long msm_vidc_calc_freq_ar50(struct msm_vidc_inst *inst,
	if (i < 0)
		i = 0;

	dcvs->load_norm = rate;
	dcvs->load_low = i < (int) (core->resources.allowed_clks_tbl_size - 1) ?
		allowed_clks_tbl[i+1].clock_rate : dcvs->load_norm;
	dcvs->load_high = i > 0 ? allowed_clks_tbl[i-1].clock_rate :
		dcvs->load_norm;

	msm_dcvs_print_dcvs_stats(dcvs);

	dprintk(VIDC_PERF, "%s Inst %pK : Filled Len = %d Freq = %llu\n",
		__func__, inst, filled_len, freq);

@@ -790,16 +712,10 @@ static unsigned long msm_vidc_calc_freq_iris1(struct msm_vidc_inst *inst,
	if (i < 0)
		i = 0;

	dcvs->load_norm = rate;
	dcvs->load_low = i < (int) (core->resources.allowed_clks_tbl_size - 1) ?
		allowed_clks_tbl[i+1].clock_rate : dcvs->load_norm;
	dcvs->load_high = i > 0 ? allowed_clks_tbl[i-1].clock_rate :
		dcvs->load_norm;

	dprintk(VIDC_PERF,
		"%s: inst %pK: %x : filled len %d required freq %llu load_norm %llu\n",
		"%s: inst %pK: %x : filled len %d required freq %llu\n",
		__func__, inst, hash32_ptr(inst->session),
		filled_len, freq, dcvs->load_norm);
		filled_len, freq);

	return (unsigned long) freq;
}
@@ -893,16 +809,10 @@ static unsigned long msm_vidc_calc_freq_iris2(struct msm_vidc_inst *inst,
	if (i < 0)
		i = 0;

	dcvs->load_norm = rate;
	dcvs->load_low = i < (int) (core->resources.allowed_clks_tbl_size - 1) ?
		allowed_clks_tbl[i+1].clock_rate : dcvs->load_norm;
	dcvs->load_high = i > 0 ? allowed_clks_tbl[i-1].clock_rate :
		dcvs->load_norm;

	dprintk(VIDC_PERF,
		"%s: inst %pK: %x : filled len %d required freq %llu load_norm %llu\n",
		"%s: inst %pK: %x : filled len %d required freq %llu\n",
		__func__, inst, hash32_ptr(inst->session),
		filled_len, freq, dcvs->load_norm);
		filled_len, freq);

	return (unsigned long) freq;
}
@@ -1059,8 +969,6 @@ int msm_comm_scale_clocks(struct msm_vidc_inst *inst)
		msm_dcvs_scale_clocks(inst, freq);
	}

	msm_vidc_update_freq_entry(inst, freq, device_addr, is_turbo);

	msm_vidc_set_clocks(inst->core);

	return 0;
@@ -1211,16 +1119,8 @@ void msm_clock_data_reset(struct msm_vidc_inst *inst)
	if (i < 0)
		i = 0;

	dcvs->load = dcvs->load_norm = rate;
	dcvs->load_low = i < (core->resources.allowed_clks_tbl_size - 1) ?
		allowed_clks_tbl[i+1].clock_rate : dcvs->load_norm;
	dcvs->load_high = i > 0 ?
		allowed_clks_tbl[i-1].clock_rate : dcvs->load_norm;

	inst->clk_data.buffer_counter = 0;

	msm_dcvs_print_dcvs_stats(dcvs);

	rc = msm_comm_scale_clocks_and_bus(inst, 1);

	if (rc)
+0 −3
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ int msm_vidc_get_mbs_per_frame(struct msm_vidc_inst *inst);
int msm_vidc_get_fps(struct msm_vidc_inst *inst);
int msm_comm_scale_clocks_and_bus(struct msm_vidc_inst *inst, bool do_bw_calc);
int msm_comm_init_clocks_and_bus_data(struct msm_vidc_inst *inst);
void msm_comm_free_freq_table(struct msm_vidc_inst *inst);
int msm_vidc_decide_work_route_iris1(struct msm_vidc_inst *inst);
int msm_vidc_decide_work_mode_iris1(struct msm_vidc_inst *inst);
int msm_vidc_decide_work_route_iris2(struct msm_vidc_inst *inst);
@@ -29,8 +28,6 @@ int msm_vidc_decide_work_mode_iris2(struct msm_vidc_inst *inst);
int msm_vidc_decide_core_and_power_mode_iris1(struct msm_vidc_inst *inst);
int msm_vidc_decide_core_and_power_mode_iris2(struct msm_vidc_inst *inst);
void msm_print_core_status(struct msm_vidc_core *core, u32 core_id);
void msm_vidc_clear_freq_entry(struct msm_vidc_inst *inst,
	u32 device_addr);
void msm_comm_free_input_cr_table(struct msm_vidc_inst *inst);
void msm_comm_update_input_cr(struct msm_vidc_inst *inst, u32 index,
	u32 cr);
+1 −1
Original line number Diff line number Diff line
@@ -2485,7 +2485,7 @@ static void handle_ebd(enum hal_command_response cmd, void *data)
		vb->planes[1].bytesused = vb->planes[1].length;

	update_recon_stats(inst, &empty_buf_done->recon_stats);
	msm_vidc_clear_freq_entry(inst, mbuf->smem[0].device_addr);
	inst->clk_data.buffer_counter++;
	/*
	 * dma cache operations need to be performed before dma_unmap
	 * which is done inside msm_comm_put_vidc_buffer()
+0 −5
Original line number Diff line number Diff line
@@ -393,10 +393,6 @@ enum dcvs_flags {

struct clock_data {
	int buffer_counter;
	u64 load;
	u64 load_low;
	u64 load_norm;
	u64 load_high;
	int min_threshold;
	int nom_threshold;
	int max_threshold;
@@ -518,7 +514,6 @@ struct msm_vidc_inst {
	enum instance_state state;
	struct msm_vidc_format fmts[MAX_PORT_NUM];
	struct buf_queue bufq[MAX_PORT_NUM];
	struct msm_vidc_list freqs;
	struct msm_vidc_list input_crs;
	struct msm_vidc_list scratchbufs;
	struct msm_vidc_list persistbufs;