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

Commit 04923698 authored by Akshay Chandrashekhar Kalghatgi's avatar Akshay Chandrashekhar Kalghatgi
Browse files

msm: vidc: Check for max secure instances allowed



Since secure flag is updated later, this change adds an additional check
for max instances allowed during set control call for setting secure flag

Change-Id: Idb48eeba661a5d294e4344aa758dc2ea4097d627
Signed-off-by: default avatarAkshay Chandrashekhar Kalghatgi <akalghat@codeaurora.org>
parent be4e22c9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -866,6 +866,12 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
		inst->flags &= ~VIDC_SECURE;
		if (ctrl->val)
			inst->flags |= VIDC_SECURE;
		if (msm_comm_check_for_inst_overload(inst->core)) {
			dprintk(VIDC_ERR,
				"%s: Instance count reached Max limit, rejecting session",
				__func__);
			return -ENOTSUPP;
		}
		break;
	case V4L2_CID_MPEG_VIDC_VIDEO_FRAME_RATE:
		inst->clk_data.frame_rate = ctrl->val;
+1 −25
Original line number Diff line number Diff line
@@ -1225,30 +1225,6 @@ int msm_vidc_private(void *vidc_inst, unsigned int cmd,
}
EXPORT_SYMBOL(msm_vidc_private);

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;
}

static int msm_vidc_try_set_ctrl(void *instance, struct v4l2_ctrl *ctrl)
{
	struct msm_vidc_inst *inst = instance;
@@ -1470,7 +1446,7 @@ void *msm_vidc_open(int core_id, int session_type)
	}

	msm_dcvs_try_enable(inst);
	if (msm_vidc_check_for_inst_overload(core)) {
	if (msm_comm_check_for_inst_overload(core)) {
		dprintk(VIDC_ERR,
			"Instance count reached Max limit, rejecting session");
		goto fail_init;
+26 −0
Original line number Diff line number Diff line
@@ -6730,3 +6730,29 @@ int msm_comm_set_extradata(struct msm_vidc_inst *inst,
	return rc;
}

bool msm_comm_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++;
		if (inst->flags & VIDC_SECURE)
			secure_instance_count++;
	}
	mutex_unlock(&core->lock);

	if (instance_count > core->resources.max_inst_count ||
		secure_instance_count > core->resources.max_secure_inst_count) {
		overload = true;
		dprintk(VIDC_ERR,
			"%s: inst_count:%u max_inst:%u sec_inst_count:%u max_sec_inst:%u\n",
			__func__, instance_count,
			core->resources.max_inst_count, secure_instance_count,
			core->resources.max_secure_inst_count);
	}
	return overload;
}
+1 −0
Original line number Diff line number Diff line
@@ -280,4 +280,5 @@ int msm_comm_set_index_extradata(struct msm_vidc_inst *inst,
		uint32_t extradata_id, uint32_t value);
int msm_comm_set_extradata(struct msm_vidc_inst *inst, uint32_t extradata_id,
		uint32_t value);
bool msm_comm_check_for_inst_overload(struct msm_vidc_core *core);
#endif
+1 −8
Original line number Diff line number Diff line
@@ -401,14 +401,7 @@ static struct msm_vidc_common_data kona_common_data[] = {
	},
	{
		.key = "qcom,max-secure-instances",
		.value = 2,             /*
					 * As per design driver allows 3rd
					 * instance as well since the secure
					 * flags were updated later for the
					 * current instance. Hence total
					 * secure sessions would be
					 * max-secure-instances + 1.
					 */
		.value = 3,
	},
	{
		.key = "qcom,max-hw-load",