Skip to content

Commit

Permalink
media: venus: hfi: Check for sys error on session hfi functions
Browse files Browse the repository at this point in the history
Check sys error flag for all hfi_session_xxx functions and
exit with EIO in case of an error.

Signed-off-by: Stanimir Varbanov <[email protected]>
Tested-by: Vikash Garodia <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
Stanimir Varbanov authored and mchehab committed Oct 21, 2021
1 parent b46ff4e commit 3efc520
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions drivers/media/platform/qcom/venus/hfi.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ int hfi_session_create(struct venus_inst *inst, const struct hfi_inst_ops *ops)

mutex_lock(&core->lock);

if (test_bit(0, &inst->core->sys_error)) {
ret = -EIO;
goto unlock;
}

max = atomic_add_unless(&core->insts_count, 1,
core->max_sessions_supported);
if (!max) {
Expand All @@ -196,6 +201,7 @@ int hfi_session_create(struct venus_inst *inst, const struct hfi_inst_ops *ops)
ret = 0;
}

unlock:
mutex_unlock(&core->lock);

return ret;
Expand Down Expand Up @@ -263,6 +269,9 @@ int hfi_session_deinit(struct venus_inst *inst)
if (inst->state < INST_INIT)
return -EINVAL;

if (test_bit(0, &inst->core->sys_error))
goto done;

reinit_completion(&inst->done);

ret = ops->session_end(inst);
Expand All @@ -273,6 +282,7 @@ int hfi_session_deinit(struct venus_inst *inst)
if (ret)
return ret;

done:
inst->state = INST_UNINIT;

return 0;
Expand All @@ -284,6 +294,9 @@ int hfi_session_start(struct venus_inst *inst)
const struct hfi_ops *ops = inst->core->ops;
int ret;

if (test_bit(0, &inst->core->sys_error))
return -EIO;

if (inst->state != INST_LOAD_RESOURCES)
return -EINVAL;

Expand All @@ -308,6 +321,9 @@ int hfi_session_stop(struct venus_inst *inst)
const struct hfi_ops *ops = inst->core->ops;
int ret;

if (test_bit(0, &inst->core->sys_error))
return -EIO;

if (inst->state != INST_START)
return -EINVAL;

Expand All @@ -331,6 +347,9 @@ int hfi_session_continue(struct venus_inst *inst)
{
struct venus_core *core = inst->core;

if (test_bit(0, &inst->core->sys_error))
return -EIO;

if (core->res->hfi_version == HFI_VERSION_1XX)
return 0;

Expand All @@ -343,6 +362,9 @@ int hfi_session_abort(struct venus_inst *inst)
const struct hfi_ops *ops = inst->core->ops;
int ret;

if (test_bit(0, &inst->core->sys_error))
return -EIO;

reinit_completion(&inst->done);

ret = ops->session_abort(inst);
Expand All @@ -362,6 +384,9 @@ int hfi_session_load_res(struct venus_inst *inst)
const struct hfi_ops *ops = inst->core->ops;
int ret;

if (test_bit(0, &inst->core->sys_error))
return -EIO;

if (inst->state != INST_INIT)
return -EINVAL;

Expand All @@ -385,6 +410,9 @@ int hfi_session_unload_res(struct venus_inst *inst)
const struct hfi_ops *ops = inst->core->ops;
int ret;

if (test_bit(0, &inst->core->sys_error))
return -EIO;

if (inst->state != INST_STOP)
return -EINVAL;

Expand All @@ -409,6 +437,9 @@ int hfi_session_flush(struct venus_inst *inst, u32 type, bool block)
const struct hfi_ops *ops = inst->core->ops;
int ret;

if (test_bit(0, &inst->core->sys_error))
return -EIO;

reinit_completion(&inst->done);

ret = ops->session_flush(inst, type);
Expand All @@ -429,6 +460,9 @@ int hfi_session_set_buffers(struct venus_inst *inst, struct hfi_buffer_desc *bd)
{
const struct hfi_ops *ops = inst->core->ops;

if (test_bit(0, &inst->core->sys_error))
return -EIO;

return ops->session_set_buffers(inst, bd);
}

Expand All @@ -438,6 +472,9 @@ int hfi_session_unset_buffers(struct venus_inst *inst,
const struct hfi_ops *ops = inst->core->ops;
int ret;

if (test_bit(0, &inst->core->sys_error))
return -EIO;

reinit_completion(&inst->done);

ret = ops->session_unset_buffers(inst, bd);
Expand All @@ -460,6 +497,9 @@ int hfi_session_get_property(struct venus_inst *inst, u32 ptype,
const struct hfi_ops *ops = inst->core->ops;
int ret;

if (test_bit(0, &inst->core->sys_error))
return -EIO;

if (inst->state < INST_INIT || inst->state >= INST_STOP)
return -EINVAL;

Expand All @@ -483,6 +523,9 @@ int hfi_session_set_property(struct venus_inst *inst, u32 ptype, void *pdata)
{
const struct hfi_ops *ops = inst->core->ops;

if (test_bit(0, &inst->core->sys_error))
return -EIO;

if (inst->state < INST_INIT || inst->state >= INST_STOP)
return -EINVAL;

Expand All @@ -494,6 +537,9 @@ int hfi_session_process_buf(struct venus_inst *inst, struct hfi_frame_data *fd)
{
const struct hfi_ops *ops = inst->core->ops;

if (test_bit(0, &inst->core->sys_error))
return -EIO;

if (fd->buffer_type == HFI_BUFFER_INPUT)
return ops->session_etb(inst, fd);
else if (fd->buffer_type == HFI_BUFFER_OUTPUT ||
Expand Down

0 comments on commit 3efc520

Please sign in to comment.