video: driver: check for session_error at ioctl entry point
Currently session_error check is scattered at multiple places, So check for session error at ioctl entry point itself(for set type controls only). Cleanup &inst->response_works.list as part of session close to avoid leaks and remove unused variables from inst struct. Change-Id: I349ec845cc71814b33a94ac07c7628304ddae564 Signed-off-by: Govindaraj Rajagopal <grajagop@codeaurora.org>
Dieser Commit ist enthalten in:
@@ -136,9 +136,7 @@ struct msm_vidc_inst {
|
||||
struct delayed_work response_work;
|
||||
struct workqueue_struct *response_workq;
|
||||
struct list_head response_works; /* list of struct response_work */
|
||||
struct list_head input_ts;
|
||||
struct list_head enc_input_crs;
|
||||
struct list_head decode_bitrate_data;
|
||||
bool once_per_session_set;
|
||||
bool ipsc_properties_set;
|
||||
bool opsc_properties_set;
|
||||
|
@@ -71,7 +71,7 @@ int msm_vidc_poll(void *instance, struct file *filp,
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return POLLERR;
|
||||
}
|
||||
if (inst->state == MSM_VIDC_ERROR) {
|
||||
if (is_session_error(inst)) {
|
||||
i_vpr_e(inst, "%s: inst in error state\n", __func__);
|
||||
return POLLERR;
|
||||
}
|
||||
@@ -437,11 +437,6 @@ int msm_vidc_qbuf(void *instance, struct media_device *mdev,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (is_session_error(inst)) {
|
||||
rc = -EBUSY;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
q = msm_vidc_get_vb2q(inst, b->type, __func__);
|
||||
if (!q) {
|
||||
rc = -EINVAL;
|
||||
|
@@ -703,12 +703,6 @@ int msm_v4l2_op_s_ctrl(struct v4l2_ctrl *ctrl)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (inst->state == MSM_VIDC_ERROR) {
|
||||
i_vpr_e(inst, "%s: set ctrl not allowed in error state\n");
|
||||
/* (error name TBD); */
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
capability = inst->capabilities;
|
||||
|
||||
i_vpr_h(inst, "%s: state %d, name %s, id 0x%x value %d\n",
|
||||
|
@@ -1082,7 +1082,7 @@ int msm_vidc_change_inst_state(struct msm_vidc_inst *inst,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (inst->state == MSM_VIDC_ERROR) {
|
||||
if (is_session_error(inst)) {
|
||||
i_vpr_h(inst,
|
||||
"%s: inst is in bad state, can not change state to %s\n",
|
||||
func, state_name(request_state));
|
||||
@@ -1429,10 +1429,6 @@ enum msm_vidc_allow msm_vidc_allow_qbuf(struct msm_vidc_inst *inst, u32 type)
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return MSM_VIDC_DISALLOW;
|
||||
}
|
||||
if (inst->state == MSM_VIDC_ERROR) {
|
||||
i_vpr_e(inst, "%s: inst in error state\n", __func__);
|
||||
return MSM_VIDC_DISALLOW;
|
||||
}
|
||||
|
||||
port = v4l2_type_to_driver_port(inst, type, __func__);
|
||||
if (port < 0)
|
||||
@@ -4619,6 +4615,7 @@ void msm_vidc_destroy_buffers(struct msm_vidc_inst *inst)
|
||||
struct msm_vidc_buffers *buffers;
|
||||
struct msm_vidc_buffer *buf, *dummy;
|
||||
struct msm_vidc_timestamp *ts, *dummy_ts;
|
||||
struct response_work *work, *dummy_work = NULL;
|
||||
static const enum msm_vidc_buffer_type ext_buf_types[] = {
|
||||
MSM_VIDC_BUF_INPUT,
|
||||
MSM_VIDC_BUF_OUTPUT,
|
||||
@@ -4687,6 +4684,12 @@ void msm_vidc_destroy_buffers(struct msm_vidc_inst *inst)
|
||||
msm_vidc_put_ts(inst, ts);
|
||||
}
|
||||
|
||||
list_for_each_entry_safe(work, dummy_work, &inst->response_works, list) {
|
||||
list_del(&work->list);
|
||||
kfree(work->data);
|
||||
kfree(work);
|
||||
}
|
||||
|
||||
/* destroy buffers from pool */
|
||||
msm_vidc_destroy_vidc_buffer(inst);
|
||||
msm_vidc_destroy_alloc_buffer(inst);
|
||||
@@ -5068,7 +5071,7 @@ int msm_vidc_check_core_mbps(struct msm_vidc_inst *inst)
|
||||
core_lock(core, __func__);
|
||||
list_for_each_entry(instance, &core->instances, list) {
|
||||
/* ignore invalid/error session */
|
||||
if (instance->state == MSM_VIDC_ERROR)
|
||||
if (is_session_error(instance))
|
||||
continue;
|
||||
|
||||
/* ignore thumbnail, image, and non realtime sessions */
|
||||
@@ -5105,7 +5108,7 @@ static int msm_vidc_check_core_mbpf(struct msm_vidc_inst *inst)
|
||||
core_lock(core, __func__);
|
||||
list_for_each_entry(instance, &core->instances, list) {
|
||||
/* ignore invalid/error session */
|
||||
if (instance->state == MSM_VIDC_ERROR)
|
||||
if (is_session_error(instance))
|
||||
continue;
|
||||
|
||||
/* ignore thumbnail session */
|
||||
|
@@ -64,9 +64,6 @@ int msm_vidc_get_inst_load(struct msm_vidc_inst *inst)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (inst->state == MSM_VIDC_ERROR)
|
||||
goto exit;
|
||||
|
||||
/*
|
||||
* NRT sessions - clock scaling is based on OPP table.
|
||||
* - No load based rejection.
|
||||
@@ -77,7 +74,6 @@ int msm_vidc_get_inst_load(struct msm_vidc_inst *inst)
|
||||
else
|
||||
load = msm_vidc_get_mbps(inst);
|
||||
|
||||
exit:
|
||||
return load;
|
||||
}
|
||||
|
||||
|
@@ -118,11 +118,17 @@ int msm_v4l2_s_fmt(struct file *filp, void *fh,
|
||||
}
|
||||
|
||||
inst_lock(inst, __func__);
|
||||
if (is_session_error(inst)) {
|
||||
i_vpr_e(inst, "%s: inst in error state\n", __func__);
|
||||
rc = -EBUSY;
|
||||
goto unlock;
|
||||
}
|
||||
rc = msm_vidc_s_fmt((void *)inst, f);
|
||||
if (rc)
|
||||
i_vpr_e(inst, "%s: failed with %d\n", __func__, rc);
|
||||
inst_unlock(inst, __func__);
|
||||
|
||||
unlock:
|
||||
inst_unlock(inst, __func__);
|
||||
put_inst(inst);
|
||||
|
||||
return rc;
|
||||
@@ -164,11 +170,17 @@ int msm_v4l2_s_selection(struct file *filp, void *fh,
|
||||
}
|
||||
|
||||
inst_lock(inst, __func__);
|
||||
if (is_session_error(inst)) {
|
||||
i_vpr_e(inst, "%s: inst in error state\n", __func__);
|
||||
rc = -EBUSY;
|
||||
goto unlock;
|
||||
}
|
||||
rc = msm_vidc_s_selection((void *)inst, s);
|
||||
if (rc)
|
||||
i_vpr_e(inst, "%s: failed with %d\n", __func__, rc);
|
||||
inst_unlock(inst, __func__);
|
||||
|
||||
unlock:
|
||||
inst_unlock(inst, __func__);
|
||||
put_inst(inst);
|
||||
|
||||
return rc;
|
||||
@@ -210,11 +222,17 @@ int msm_v4l2_s_parm(struct file *filp, void *fh,
|
||||
}
|
||||
|
||||
inst_lock(inst, __func__);
|
||||
if (is_session_error(inst)) {
|
||||
i_vpr_e(inst, "%s: inst in error state\n", __func__);
|
||||
rc = -EBUSY;
|
||||
goto unlock;
|
||||
}
|
||||
rc = msm_vidc_s_param((void *)inst, a);
|
||||
if (rc)
|
||||
i_vpr_e(inst, "%s: failed with %d\n", __func__, rc);
|
||||
inst_unlock(inst, __func__);
|
||||
|
||||
unlock:
|
||||
inst_unlock(inst, __func__);
|
||||
put_inst(inst);
|
||||
|
||||
return rc;
|
||||
@@ -256,11 +274,17 @@ int msm_v4l2_s_ctrl(struct file *filp, void *fh,
|
||||
}
|
||||
|
||||
inst_lock(inst, __func__);
|
||||
if (is_session_error(inst)) {
|
||||
i_vpr_e(inst, "%s: inst in error state\n", __func__);
|
||||
rc = -EBUSY;
|
||||
goto unlock;
|
||||
}
|
||||
rc = msm_vidc_s_ctrl((void *)inst, a);
|
||||
if (rc)
|
||||
i_vpr_e(inst, "%s: failed with %d\n", __func__, rc);
|
||||
inst_unlock(inst, __func__);
|
||||
|
||||
unlock:
|
||||
inst_unlock(inst, __func__);
|
||||
put_inst(inst);
|
||||
|
||||
return rc;
|
||||
@@ -326,11 +350,17 @@ int msm_v4l2_qbuf(struct file *filp, void *fh,
|
||||
}
|
||||
|
||||
inst_lock(inst, __func__);
|
||||
if (is_session_error(inst)) {
|
||||
i_vpr_e(inst, "%s: inst in error state\n", __func__);
|
||||
rc = -EBUSY;
|
||||
goto unlock;
|
||||
}
|
||||
rc = msm_vidc_qbuf(inst, vdev->v4l2_dev->mdev, b);
|
||||
if (rc)
|
||||
i_vpr_e(inst, "%s: failed with %d\n", __func__, rc);
|
||||
inst_unlock(inst, __func__);
|
||||
|
||||
unlock:
|
||||
inst_unlock(inst, __func__);
|
||||
put_inst(inst);
|
||||
|
||||
return rc;
|
||||
@@ -370,11 +400,17 @@ int msm_v4l2_streamon(struct file *filp, void *fh,
|
||||
}
|
||||
|
||||
inst_lock(inst, __func__);
|
||||
if (is_session_error(inst)) {
|
||||
i_vpr_e(inst, "%s: inst in error state\n", __func__);
|
||||
rc = -EBUSY;
|
||||
goto unlock;
|
||||
}
|
||||
rc = msm_vidc_streamon((void *)inst, i);
|
||||
if (rc)
|
||||
i_vpr_e(inst, "%s: failed with %d\n", __func__, rc);
|
||||
inst_unlock(inst, __func__);
|
||||
|
||||
unlock:
|
||||
inst_unlock(inst, __func__);
|
||||
put_inst(inst);
|
||||
|
||||
return rc;
|
||||
@@ -417,11 +453,17 @@ int msm_v4l2_subscribe_event(struct v4l2_fh *fh,
|
||||
}
|
||||
|
||||
inst_lock(inst, __func__);
|
||||
if (is_session_error(inst)) {
|
||||
i_vpr_e(inst, "%s: inst in error state\n", __func__);
|
||||
rc = -EBUSY;
|
||||
goto unlock;
|
||||
}
|
||||
rc = msm_vidc_subscribe_event((void *)inst, sub);
|
||||
if (rc)
|
||||
i_vpr_e(inst, "%s: failed with %d\n", __func__, rc);
|
||||
inst_unlock(inst, __func__);
|
||||
|
||||
unlock:
|
||||
inst_unlock(inst, __func__);
|
||||
put_inst(inst);
|
||||
|
||||
return rc;
|
||||
@@ -464,11 +506,17 @@ int msm_v4l2_decoder_cmd(struct file *filp, void *fh,
|
||||
}
|
||||
|
||||
inst_lock(inst, __func__);
|
||||
if (is_session_error(inst)) {
|
||||
i_vpr_e(inst, "%s: inst in error state\n", __func__);
|
||||
rc = -EBUSY;
|
||||
goto unlock;
|
||||
}
|
||||
rc = msm_vidc_cmd((void *)inst, (union msm_v4l2_cmd *)dec);
|
||||
if (rc)
|
||||
i_vpr_e(inst, "%s: failed with %d\n", __func__, rc);
|
||||
inst_unlock(inst, __func__);
|
||||
|
||||
unlock:
|
||||
inst_unlock(inst, __func__);
|
||||
put_inst(inst);
|
||||
|
||||
return rc;
|
||||
@@ -487,11 +535,17 @@ int msm_v4l2_encoder_cmd(struct file *filp, void *fh,
|
||||
}
|
||||
|
||||
inst_lock(inst, __func__);
|
||||
if (is_session_error(inst)) {
|
||||
i_vpr_e(inst, "%s: inst in error state\n", __func__);
|
||||
rc = -EBUSY;
|
||||
goto unlock;
|
||||
}
|
||||
rc = msm_vidc_cmd((void *)inst, (union msm_v4l2_cmd *)enc);
|
||||
if (rc)
|
||||
i_vpr_e(inst, "%s: failed with %d\n", __func__, rc);
|
||||
inst_unlock(inst, __func__);
|
||||
|
||||
unlock:
|
||||
inst_unlock(inst, __func__);
|
||||
put_inst(inst);
|
||||
|
||||
return rc;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren