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

Commit 9e7854ec authored by Praneeth Paladugu's avatar Praneeth Paladugu Committed by Shalaj Jain
Browse files

msm: vidc: Limit max supported instances in driver



Currently the limit for max supported instances is in venus.
When we reach this limit, H/W reports session_error for the
new session. This is different than normal session_error
and we need to handle it differently. So, Reject the session if
the new instance exceeds in driver itself to make error handling
easy.

Also add a secure count to restrict the number of secure
instances opened concurrently due to some system wide
limitations on resources.

Change-Id: Icda379d3f3b6a8f6be5e471c378a73920a1c1b58
Signed-off-by: default avatarPraneeth Paladugu <ppaladug@codeaurora.org>
Signed-off-by: default avatarShalaj Jain <shalajj@codeaurora.org>
parent c942d143
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -116,6 +116,9 @@ Optional properties:
           internal cmd queue = 0x800
- qcom,pm-qos-latency-us = The latency used to vote for QOS power manager. This
value is typically max(latencies of every cluster at all power levels) + 1
- qcom,max-secure-instances = An int containing max number of concurrent secure
  instances supported, accounting for venus and system wide limitations like
  memory, performance etc.

[Second level nodes]
Context Banks
+13 −0
Original line number Diff line number Diff line
@@ -546,6 +546,7 @@ static int hfi_fill_codec_info(u8 *data_ptr,
	u32 codecs = 0, codec_count = 0, size = 0;
	struct msm_vidc_capability *capability;
	u32 prop_id = *((u32 *)data_ptr);
	u8 *orig_data_ptr = data_ptr;

	if (prop_id ==  HFI_PROPERTY_PARAM_CODEC_SUPPORTED) {
		struct hfi_codec_supported *prop;
@@ -586,6 +587,18 @@ static int hfi_fill_codec_info(u8 *data_ptr,
		}
	}
	sys_init_done->codec_count = codec_count;

	prop_id = *((u32 *)(orig_data_ptr + size));
	if (prop_id == HFI_PROPERTY_PARAM_MAX_SESSIONS_SUPPORTED) {
		struct hfi_max_sessions_supported *prop =
			(struct hfi_max_sessions_supported *)
			(orig_data_ptr + size + sizeof(u32));

		sys_init_done->max_sessions_supported = prop->max_sessions;
		size += sizeof(struct hfi_max_sessions_supported) + sizeof(u32);
		dprintk(VIDC_DBG, "max_sessions_supported %d\n",
				prop->max_sessions);
	}
	return size;
}

+32 −1
Original line number Diff line number Diff line
@@ -1098,6 +1098,30 @@ int msm_vidc_dqevent(void *inst, struct v4l2_event *event)
}
EXPORT_SYMBOL(msm_vidc_dqevent);

static bool msm_vidc_check_for_inst_overload(struct msm_vidc_core *core)
{
	u32 instance_count = 0;
	u32 secure_instance_count = 0;
	struct msm_vidc_inst *inst = NULL;
	bool overload = false;

	mutex_lock(&core->lock);
	list_for_each_entry(inst, &core->instances, list) {
		instance_count++;
		/* This flag is not updated yet for the current instance */
		if (inst->flags & VIDC_SECURE)
			secure_instance_count++;
	}
	mutex_unlock(&core->lock);

	/* Instance count includes current instance as well. */

	if ((instance_count > core->resources.max_inst_count) ||
		(secure_instance_count > core->resources.max_secure_inst_count))
		overload = true;
	return overload;
}

void *msm_vidc_open(int core_id, int session_type)
{
	struct msm_vidc_inst *inst = NULL;
@@ -1189,12 +1213,19 @@ void *msm_vidc_open(int core_id, int session_type)
	list_add_tail(&inst->list, &core->instances);
	mutex_unlock(&core->lock);

	rc = msm_comm_try_state(inst, MSM_VIDC_CORE_INIT);
	rc = msm_comm_try_state(inst, MSM_VIDC_CORE_INIT_DONE);
	if (rc) {
		dprintk(VIDC_ERR,
			"Failed to move video instance to init state\n");
		goto fail_init;
	}

	if (msm_vidc_check_for_inst_overload(core)) {
		dprintk(VIDC_ERR,
			"Instance count reached Max limit, rejecting session");
		goto fail_init;
	}

	inst->debugfs_root =
		msm_vidc_debugfs_init_inst(inst, core->debugfs_root);

+12 −0
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@
#define V4L2_EVENT_SEQ_BITDEPTH_CHANGED_INSUFFICIENT \
		V4L2_EVENT_MSM_VIDC_PORT_SETTINGS_BITDEPTH_CHANGED_INSUFFICIENT

#define MAX_SUPPORTED_INSTANCES 16

struct getprop_buf {
	struct list_head list;
	void *data;
@@ -628,6 +630,16 @@ static void handle_sys_init_done(enum hal_command_response cmd, void *data)

	core->enc_codec_supported = sys_init_msg->enc_codec_supported;
	core->dec_codec_supported = sys_init_msg->dec_codec_supported;

	/* This should come from sys_init_done */
	core->resources.max_inst_count =
		sys_init_msg->max_sessions_supported ? :
		MAX_SUPPORTED_INSTANCES;

	core->resources.max_secure_inst_count =
		core->resources.max_secure_inst_count ? :
		core->resources.max_inst_count;

	if (core->id == MSM_VIDC_CORE_VENUS &&
		(core->dec_codec_supported & HAL_VIDEO_CODEC_H264))
			core->dec_codec_supported |=
+3 −0
Original line number Diff line number Diff line
@@ -863,6 +863,9 @@ int read_platform_resources_from_dt(
	dprintk(VIDC_DBG, "Slave side cp = %s\n",
				res->slave_side_cp ? "yes" : "no");

	of_property_read_u32(pdev->dev.of_node,
			"qcom,max-secure-instances",
			&res->max_secure_inst_count);
	return rc;

err_setup_legacy_cb:
Loading