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

Commit c9f4afce authored by Linux Build Service Account's avatar Linux Build Service Account
Browse files

Merge 93838784 on remote branch

Change-Id: Id8eaae2e11786c3052dadb9d131b45b3006fad5e
parents bfbb4c1a 93838784
Loading
Loading
Loading
Loading
+27 −22
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
 */

#include <asm/dma-iommu.h>
@@ -990,20 +990,22 @@ static void __set_registers(struct venus_hfi_device *device, u32 sid)
	}
}

static int __vote_bandwidth(struct bus_info *bus,
	unsigned long bw_kbps, u32 sid)
static int __vote_bandwidth(struct bus_info *bus, unsigned long ab_kbps,
			    unsigned long ib_kbps, u32 sid)
{
	int rc = 0;
	uint64_t ab = 0;
	uint64_t ab = 0, ib = 0;

	/* Bus Driver expects values in Bps */
	ab = bw_kbps * 1000;
	s_vpr_p(sid, "Voting bus %s to ab %llu bps\n", bus->name, ab);
	rc = msm_bus_scale_update_bw(bus->client, ab, 0);
	ab = ab_kbps * 1000;
	ib = ib_kbps * 1000;
	s_vpr_p(sid, "Voting bus %s to ab %llu ib %llu bps\n",
						bus->name, ab, ib);
	rc = msm_bus_scale_update_bw(bus->client, ab, ib);
	if (rc)
		s_vpr_e(sid, "Failed voting bus %s to ab %llu, rc=%d\n",
				bus->name, ab, rc);

		s_vpr_e(sid,
			"Failed voting bus %s to ab %llu ib %llu bps rc=%d\n",
			bus->name, ab, ib, rc);
	return rc;
}

@@ -1015,7 +1017,7 @@ int __unvote_buses(struct venus_hfi_device *device, u32 sid)
	device->bus_vote = DEFAULT_BUS_VOTE;

	venus_hfi_for_each_bus(device, bus) {
		rc = __vote_bandwidth(bus, 0, sid);
		rc = __vote_bandwidth(bus, 0, 0, sid);
		if (rc)
			goto err_unknown_device;
	}
@@ -1029,7 +1031,7 @@ static int __vote_buses(struct venus_hfi_device *device,
{
	int rc = 0;
	struct bus_info *bus = NULL;
	unsigned long bw_kbps = 0, bw_prev = 0;
	unsigned long ab_kbps = 0, ib_kbps = 0, bw_prev = 0;
	enum vidc_bus_type type;

	venus_hfi_for_each_bus(device, bus) {
@@ -1037,33 +1039,36 @@ static int __vote_buses(struct venus_hfi_device *device,
			type = get_type_frm_name(bus->name);

			if (type == DDR) {
				bw_kbps = bw_ddr;
				ab_kbps = bw_ddr;
				bw_prev = device->bus_vote.total_bw_ddr;
			} else if (type == LLCC) {
				bw_kbps = bw_llcc;
				ab_kbps = bw_llcc;
				bw_prev = device->bus_vote.total_bw_llcc;
			} else {
				bw_kbps = bus->range[1];
				ab_kbps = bus->range[1];
				bw_prev = device->bus_vote.total_bw_ddr ?
						bw_kbps : 0;
						ab_kbps : 0;
			}

			/* ensure freq is within limits */
			bw_kbps = clamp_t(typeof(bw_kbps), bw_kbps,
			ab_kbps = clamp_t(typeof(ab_kbps), ab_kbps,
				bus->range[0], bus->range[1]);

			if (TRIVIAL_BW_CHANGE(bw_kbps, bw_prev) && bw_prev) {
			if (TRIVIAL_BW_CHANGE(ab_kbps, bw_prev) && bw_prev) {
				s_vpr_l(sid, "Skip voting bus %s to %llu bps",
					bus->name, bw_kbps * 1000);
					bus->name, ab_kbps * 1000);
				continue;
			}

			rc = __vote_bandwidth(bus, bw_kbps, sid);
			if (device->res->vpu_ver == VPU_VERSION_AR50_LITE)
				ib_kbps = 2 * ab_kbps;

			rc = __vote_bandwidth(bus, ab_kbps, ib_kbps, sid);

			if (type == DDR)
				device->bus_vote.total_bw_ddr = bw_kbps;
				device->bus_vote.total_bw_ddr = ab_kbps;
			else if (type == LLCC)
				device->bus_vote.total_bw_llcc = bw_kbps;
				device->bus_vote.total_bw_llcc = ab_kbps;
		} else {
			s_vpr_e(sid, "No BUS to Vote\n");
		}
+3 −3
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
 */

#include "msm_cvp_internal.h"
@@ -233,14 +233,14 @@ static int msm_cvp_scale_clocks_and_bus(struct msm_vidc_inst *inst)
		return -EINVAL;
	}

	rc = msm_vidc_set_clocks(inst->core, inst->sid);
	rc = msm_vidc_set_clocks(inst->core, inst->sid, false);
	if (rc) {
		s_vpr_e(inst->sid, "%s: failed set_clocks for inst %pK\n",
			__func__, inst);
		goto exit;
	}

	rc = msm_comm_vote_bus(inst);
	rc = msm_comm_vote_bus(inst, false);
	if (rc) {
		s_vpr_e(inst->sid,
			"%s: failed vote_bus for inst %pK\n", __func__, inst);
+10 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
 */

#include <linux/slab.h>
@@ -927,6 +927,15 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
	case V4L2_CID_MPEG_VIDC_VIDEO_OPERATING_RATE:
		if (!is_valid_operating_rate(inst, ctrl->val))
			break;
		/*
		 * reset the resources like clock and bus as per the updated
		 * flag. When switch from TURBO to normal, need not wait for
		 * next qbuf to scale down the resources.
		 */
		if ((inst->flags & VIDC_TURBO) && (ctrl->val != INT_MAX)) {
			inst->flags &= ~VIDC_TURBO;
			msm_comm_reset_clocks_and_bus(inst);
		}
		inst->flags &= ~VIDC_TURBO;
		if (ctrl->val == INT_MAX)
			inst->flags |= VIDC_TURBO;
+38 −15
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
 */

#include "msm_vidc_common.h"
@@ -274,7 +274,7 @@ static int fill_dynamic_stats(struct msm_vidc_inst *inst,
	return 0;
}

int msm_comm_set_buses(struct msm_vidc_core *core, u32 sid)
int msm_comm_set_buses(struct msm_vidc_core *core, u32 sid, bool force_reset)
{
	int rc = 0;
	struct msm_vidc_inst *inst = NULL;
@@ -306,7 +306,7 @@ int msm_comm_set_buses(struct msm_vidc_core *core, u32 sid)
		}
		mutex_unlock(&inst->registeredbufs.lock);

		if ((!filled_len || !device_addr) &&
		if ((!filled_len || !device_addr) && !force_reset &&
			(inst->session_type != MSM_VIDC_CVP)) {
			s_vpr_l(sid, "%s: no input\n", __func__);
			continue;
@@ -333,7 +333,7 @@ int msm_comm_set_buses(struct msm_vidc_core *core, u32 sid)
	return rc;
}

int msm_comm_vote_bus(struct msm_vidc_inst *inst)
int msm_comm_vote_bus(struct msm_vidc_inst *inst, bool force_reset)
{
	int rc = 0;
	struct msm_vidc_core *core;
@@ -368,7 +368,7 @@ int msm_comm_vote_bus(struct msm_vidc_inst *inst)
	}
	mutex_unlock(&inst->registeredbufs.lock);

	if ((!filled_len || !device_addr) &&
	if ((!filled_len || !device_addr) && !force_reset &&
		(inst->session_type != MSM_VIDC_CVP)) {
		s_vpr_l(inst->sid, "%s: no input\n", __func__);
		return 0;
@@ -457,7 +457,7 @@ int msm_comm_vote_bus(struct msm_vidc_inst *inst)
		call_core_op(core, calc_bw, vote_data);
	}

	rc = msm_comm_set_buses(core, inst->sid);
	rc = msm_comm_set_buses(core, inst->sid, force_reset);

	return rc;
}
@@ -877,7 +877,7 @@ static unsigned long msm_vidc_calc_freq_iris2(struct msm_vidc_inst *inst,
	return (unsigned long) freq;
}

int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid)
int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid, bool force_reset)
{
	struct hfi_device *hdev;
	unsigned long freq_core_1 = 0, freq_core_2 = 0, rate = 0;
@@ -915,7 +915,7 @@ int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid)
		}
		mutex_unlock(&inst->registeredbufs.lock);

		if (!filled_len || !device_addr) {
		if ((!filled_len || !device_addr) && !force_reset) {
			s_vpr_l(sid, "%s: no input\n", __func__);
			continue;
		}
@@ -988,7 +988,7 @@ int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid)
	return rc;
}

int msm_comm_scale_clocks(struct msm_vidc_inst *inst)
int msm_comm_scale_clocks(struct msm_vidc_inst *inst, bool force_reset)
{
	struct msm_vidc_buffer *temp, *next;
	unsigned long freq = 0;
@@ -1013,7 +1013,7 @@ int msm_comm_scale_clocks(struct msm_vidc_inst *inst)
	}
	mutex_unlock(&inst->registeredbufs.lock);

	if (!filled_len || !device_addr) {
	if ((!filled_len || !device_addr) && !force_reset) {
		s_vpr_l(inst->sid, "%s: no input\n", __func__);
		return 0;
	}
@@ -1032,7 +1032,7 @@ int msm_comm_scale_clocks(struct msm_vidc_inst *inst)
		msm_dcvs_scale_clocks(inst, freq);
	}

	msm_vidc_set_clocks(inst->core, inst->sid);
	msm_vidc_set_clocks(inst->core, inst->sid, force_reset);

	return 0;
}
@@ -1055,13 +1055,13 @@ int msm_comm_scale_clocks_and_bus(struct msm_vidc_inst *inst, bool do_bw_calc)
		inst->active = true;
	}

	if (msm_comm_scale_clocks(inst)) {
	if (msm_comm_scale_clocks(inst, false)) {
		s_vpr_e(inst->sid,
			"Failed to scale clocks. May impact performance\n");
	}

	if (do_bw_calc) {
		if (msm_comm_vote_bus(inst)) {
		if (msm_comm_vote_bus(inst, false)) {
			s_vpr_e(inst->sid,
				"Failed to scale DDR bus. May impact perf\n");
		}
@@ -1070,6 +1070,25 @@ int msm_comm_scale_clocks_and_bus(struct msm_vidc_inst *inst, bool do_bw_calc)
	return 0;
}

int msm_comm_reset_clocks_and_bus(struct msm_vidc_inst *inst)
{
	if (!inst) {
		d_vpr_e("%s: invalid params %pK\n", __func__, inst);
		return -EINVAL;
	}

	if (msm_comm_scale_clocks(inst, true)) {
		s_vpr_e(inst->sid,
			"Failed to reset clocks. May impact performance\n");
	}

	if (msm_comm_vote_bus(inst, true)) {
		s_vpr_e(inst->sid,
			"Failed to reset DDR bus. May impact perf\n");
	}
	return 0;
}

int msm_dcvs_try_enable(struct msm_vidc_inst *inst)
{
	bool disable_hfr_dcvs = false;
@@ -1750,10 +1769,14 @@ int msm_vidc_decide_core_and_power_mode_iris1(struct msm_vidc_inst *inst)
		s_vpr_h(inst->sid, "Moved all inst's to LP");
		msm_vidc_move_core_to_power_save_mode(core,
			VIDC_CORE_ID_1, inst->sid);
	} else {
		if (!is_realtime_session(inst)) {
			s_vpr_h(inst->sid, "Supporting NRT session");
		} else {
			s_vpr_e(inst->sid, "Core cannot support this load\n");
			return -EINVAL;
		}
	}

	inst->clk_data.core_id = VIDC_CORE_ID_1;
	rc = msm_comm_scale_clocks_and_bus(inst, 1);
+4 −3
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
 */

#ifndef _MSM_VIDC_CLOCKS_H_
@@ -9,8 +9,8 @@

void msm_clock_data_reset(struct msm_vidc_inst *inst);
void msm_dcvs_reset(struct msm_vidc_inst *inst);
int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid);
int msm_comm_vote_bus(struct msm_vidc_inst *inst);
int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid, bool force_reset);
int msm_comm_vote_bus(struct msm_vidc_inst *inst, bool force_reset);
int msm_dcvs_try_enable(struct msm_vidc_inst *inst);
bool res_is_less_than(u32 width, u32 height, u32 ref_width, u32 ref_height);
bool res_is_greater_than(u32 width, u32 height, u32 ref_width, u32 ref_height);
@@ -21,6 +21,7 @@ bool res_is_greater_than_or_equal_to(u32 width, u32 height,
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_reset_clocks_and_bus(struct msm_vidc_inst *inst);
int msm_comm_init_clocks_and_bus_data(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);
Loading