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

Commit 702e3972 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: vidc: Adjust the load for concurrent sessions"

parents 7ff5d58c 88896322
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -96,6 +96,11 @@ enum session_type {
	MSM_VIDC_MAX_DEVICES = MSM_VIDC_UNKNOWN,
};

enum load_type {
	MSM_VIDC_VIDEO = 0,
	MSM_VIDC_IMAGE,
};

union msm_v4l2_cmd {
	struct v4l2_decoder_cmd dec;
	struct v4l2_encoder_cmd enc;
+62 −22
Original line number Diff line number Diff line
@@ -824,7 +824,8 @@ int msm_comm_get_inst_load_per_core(struct msm_vidc_inst *inst,
}

int msm_comm_get_device_load(struct msm_vidc_core *core,
	enum session_type type, enum load_calc_quirks quirks)
	enum session_type sess_type, enum load_type load_type,
	enum load_calc_quirks quirks)
{
	struct msm_vidc_inst *inst = NULL;
	int num_mbs_per_sec = 0;
@@ -836,7 +837,12 @@ int msm_comm_get_device_load(struct msm_vidc_core *core,

	mutex_lock(&core->lock);
	list_for_each_entry(inst, &core->instances, list) {
		if (inst->session_type != type)
		if (inst->session_type != sess_type)
			continue;

		if (load_type == MSM_VIDC_VIDEO && !is_video_session(inst))
			continue;
		else if (load_type == MSM_VIDC_IMAGE && !is_grid_session(inst))
			continue;

		num_mbs_per_sec += msm_comm_get_inst_load(inst, quirks);
@@ -3448,8 +3454,9 @@ static int msm_vidc_load_resources(int flipped_state,
{
	int rc = 0;
	struct hfi_device *hdev;
	int num_mbs_per_sec = 0, max_load_adj = 0;
	struct msm_vidc_core *core;
	int max_video_load = 0, max_image_load = 0;
	int video_load = 0, image_load = 0;
	enum load_calc_quirks quirks = LOAD_ADMISSION_CONTROL;

	if (!inst || !inst->core || !inst->core->device) {
@@ -3468,18 +3475,33 @@ static int msm_vidc_load_resources(int flipped_state,
	}
	core = inst->core;

	num_mbs_per_sec =
		msm_comm_get_device_load(core, MSM_VIDC_DECODER, quirks) +
		msm_comm_get_device_load(core, MSM_VIDC_ENCODER, quirks);

	max_load_adj = core->resources.max_load +
	image_load = msm_comm_get_device_load(core,
					MSM_VIDC_ENCODER, MSM_VIDC_IMAGE,
					quirks);
	video_load = msm_comm_get_device_load(core,
					MSM_VIDC_DECODER, MSM_VIDC_VIDEO,
					quirks);
	video_load += msm_comm_get_device_load(core,
					MSM_VIDC_ENCODER, MSM_VIDC_VIDEO,
					quirks);

	max_video_load = inst->core->resources.max_load +
				inst->capability.cap[CAP_MBS_PER_FRAME].max;
	max_image_load = inst->core->resources.max_image_load;

	if (num_mbs_per_sec > max_load_adj) {
		s_vpr_e(inst->sid, "HW is overloaded, needed: %d max: %d\n",
			num_mbs_per_sec, max_load_adj);
		msm_vidc_print_running_insts(core);
		msm_comm_kill_session(inst);
	if (video_load > max_video_load) {
		s_vpr_e(inst->sid,
			"H/W is overloaded. needed: %d max: %d\n",
			video_load, max_video_load);
		msm_vidc_print_running_insts(inst->core);
		return -EBUSY;
	}

	if (video_load + image_load > max_video_load + max_image_load) {
		s_vpr_e(inst->sid,
			"H/W is overloaded. needed: [video + image][%d + %d], max: [video + image][%d + %d]\n",
			video_load, image_load, max_video_load, max_image_load);
		msm_vidc_print_running_insts(inst->core);
		return -EBUSY;
	}

@@ -5854,19 +5876,37 @@ int msm_comm_check_memory_supported(struct msm_vidc_inst *vidc_inst)

static int msm_vidc_check_mbps_supported(struct msm_vidc_inst *inst)
{
	int num_mbs_per_sec = 0, max_load_adj = 0;
	int max_video_load = 0, max_image_load = 0;
	int video_load = 0, image_load = 0;
	enum load_calc_quirks quirks = LOAD_ADMISSION_CONTROL;

	if (inst->state == MSM_VIDC_OPEN_DONE) {
		max_load_adj = inst->core->resources.max_load;
		num_mbs_per_sec = msm_comm_get_device_load(inst->core,
					MSM_VIDC_DECODER, quirks);
		num_mbs_per_sec += msm_comm_get_device_load(inst->core,
					MSM_VIDC_ENCODER, quirks);
		if (num_mbs_per_sec > max_load_adj) {
		image_load = msm_comm_get_device_load(inst->core,
					MSM_VIDC_ENCODER, MSM_VIDC_IMAGE,
					quirks);
		video_load = msm_comm_get_device_load(inst->core,
					MSM_VIDC_DECODER, MSM_VIDC_VIDEO,
					quirks);
		video_load += msm_comm_get_device_load(inst->core,
					MSM_VIDC_ENCODER, MSM_VIDC_VIDEO,
					quirks);

		max_video_load = inst->core->resources.max_load;
		max_image_load = inst->core->resources.max_image_load;

		if (video_load > max_video_load) {
			s_vpr_e(inst->sid,
				"H/W is overloaded. needed: %d max: %d\n",
				num_mbs_per_sec, max_load_adj);
				video_load, max_video_load);
			msm_vidc_print_running_insts(inst->core);
			return -EBUSY;
		}

		if (video_load + image_load > max_video_load + max_image_load) {
			s_vpr_e(inst->sid,
				"H/W is overloaded. needed: [video + image][%d + %d], max: [video + image][%d + %d]\n",
				video_load, image_load,
				max_video_load, max_image_load);
			msm_vidc_print_running_insts(inst->core);
			return -EBUSY;
		}
+8 −1
Original line number Diff line number Diff line
@@ -120,6 +120,11 @@ static inline bool is_grid_session(struct msm_vidc_inst *inst)
	}
	return 0;
}

static inline bool is_video_session(struct msm_vidc_inst *inst)
{
	return !is_grid_session(inst);
}
static inline bool is_realtime_session(struct msm_vidc_inst *inst)
{
	struct v4l2_ctrl *ctrl;
@@ -282,7 +287,9 @@ int msm_comm_get_inst_load(struct msm_vidc_inst *inst,
int msm_comm_get_inst_load_per_core(struct msm_vidc_inst *inst,
			enum load_calc_quirks quirks);
int msm_comm_get_device_load(struct msm_vidc_core *core,
			enum session_type type, enum load_calc_quirks quirks);
			enum session_type sess_type,
			enum load_type load_type,
			enum load_calc_quirks quirks);
int msm_comm_set_color_format(struct msm_vidc_inst *inst,
		enum hal_buffer buffer_type, int fourcc);
int msm_comm_g_ctrl(struct msm_vidc_inst *inst, struct v4l2_control *ctrl);
+50 −18
Original line number Diff line number Diff line
@@ -931,12 +931,16 @@ static struct msm_vidc_common_data lito_common_data_v0[] = {
	},
	{
		.key = "qcom,max-hw-load",
		.value = 2220544,
		.value = 1958400,
		/**
		 * ((3840x2176)/256)@60 + ((8192x8192)/256)@1fps
		 * UHD@30 decode + UHD@30 encode + ((8192x8192)/256)@1fps
		 * ((3840x2176)/256)@60
		 * UHD@30 decode + UHD@30 encode
		 */
	},
	{
		.key = "qcom,max-image-load",
		.value = 262144, /* ((8192x8192)/256)@1fps */
	},
	{
		.key = "qcom,max-hq-mbs-per-frame",
		.value = 8160,/* ((1920x1088)/256) */
@@ -1014,10 +1018,14 @@ static struct msm_vidc_common_data lito_common_data_v1[] = {
	},
	{
		.key = "qcom,max-hw-load",
		.value = 1486144,
		.value = 1224000,
		/**
		 * UHD@30 decode + 1080@30 encode + ((8192x8192)/256)@1fps
		 * UHD@30 decode + 1080@30 encode
		 */
	},
		{
		.key = "qcom,max-image-load",
		.value = 262144, /* ((8192x8192)/256)@1fps */
	},
	{
		.key = "qcom,max-hq-mbs-per-frame",
@@ -1096,12 +1104,16 @@ static struct msm_vidc_common_data lagoon_common_data_v0[] = {
	},
	{
		.key = "qcom,max-hw-load",
		.value = 2220544,
		.value = 1958400,
		/**
		 * ((3840x2176)/256)@60fps decode + ((8192x8192)/256)@1fps
		 * UHD@30 decode + 1080@30 encode + ((8192x8192)/256)@1fps
		 * ((3840x2176)/256)@60
		 * UHD@30 decode + UHD@30 encode
		 */
	},
	{
		.key = "qcom,max-image-load",
		.value = 262144,/* ((8192x8192)/256)@1fps */
	},
	{
		.key = "qcom,max-mbpf",
		.value = 130560, /* ((3840x2176)/256) x 4 */
@@ -1179,8 +1191,14 @@ static struct msm_vidc_common_data lagoon_common_data_v1[] = {
	},
	{
		.key = "qcom,max-hw-load",
		.value = 1486144,
		/* UHD@30 decode + 1080@30 encode + ((8192x8192)/256)@1fps */
		.value = 1224000,
		/**
		 * UHD@30 decode + 1080@30 encode
		 */
	},
	{
		.key = "qcom,max-image-load",
		.value = 262144, /* ((8192x8192)/256)@1fps */
	},
	{
		.key = "qcom,max-mbpf",
@@ -1259,14 +1277,18 @@ static struct msm_vidc_common_data kona_common_data[] = {
	},
	{
		.key = "qcom,max-hw-load",
		.value = 8882176,
		.value = 7833600,
		/**
		 * (7680x4320@60fps, 3840x2176@240fps
		 * Greater than 4096x2176@120fps,
		 *  8192x4320@48fps) + ((16384x16384)/256)@1fps
		 *  8192x4320@48fps)
		 */

	},
	{
		.key = "qcom,max-image-load",
		.value = 1048576, /* ((16384x16384)/256)@1fps */
	},
	{
		.key = "qcom,max-mbpf",
		.value = 173056,	/* (8192x4320)/256 + (4096x2176)/256*/
@@ -1407,8 +1429,11 @@ static struct msm_vidc_common_data bengal_common_data_v0[] = {
	},
	{
		.key = "qcom,max-hw-load",
		.value = 751744,
		/* ((1088x1920)/256)@60fps + ((8192x8192)/256)@1fps */
		.value = 489600, /* ((1088x1920)/256)@60fps */
	},
	{
		.key = "qcom,max-image-load",
		.value = 262144, /* ((8192x8192)/256)@1fps */
	},
	{
		.key = "qcom,max-mbpf",
@@ -1463,8 +1488,11 @@ static struct msm_vidc_common_data bengal_common_data_v1[] = {
	},
	{
		.key = "qcom,max-hw-load",
		.value = 506944,
		/* ((1088x1920)/256)@30fps + ((8192x8192)/256)@1fps */
		.value = 244800, /* ((1088x1920)/256)@30fps */
	},
	{
		.key = "qcom,max-image-load",
		.value = 262144, /* ((8192x8192)/256)@1fps */
	},
	{
		.key = "qcom,max-mbpf",
@@ -1519,8 +1547,12 @@ static struct msm_vidc_common_data scuba_common_data[] = {
	},
	{
		.key = "qcom,max-hw-load",
		.value = 506944,
		/* ((1088x1920)/256)@30fps + ((8192x8192)/256)@1fps */
		.value = 352800,
		/* ((1088x1920)/256)@30fps + ((720x1280)/256)@30fps*/
	},
	{
		.key = "qcom,max-image-load",
		.value = 262144, /* ((8192x8192)/256)@1fps */
	},
	{
		.key = "qcom,max-mbpf",
+3 −0
Original line number Diff line number Diff line
@@ -777,6 +777,9 @@ int read_platform_resources_from_drv_data(
	res->max_load = find_key_value(platform_data,
			"qcom,max-hw-load");

	res->max_image_load = find_key_value(platform_data,
			"qcom,max-image-load");

	res->max_mbpf = find_key_value(platform_data,
			"qcom,max-mbpf");

Loading