Skip to content

Commit 3efc520

Browse files
Stanimir Varbanovmchehab
authored andcommitted
media: venus: hfi: Check for sys error on session hfi functions
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]>
1 parent b46ff4e commit 3efc520

File tree

1 file changed

+46
-0
lines changed
  • drivers/media/platform/qcom/venus

1 file changed

+46
-0
lines changed

drivers/media/platform/qcom/venus/hfi.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ int hfi_session_create(struct venus_inst *inst, const struct hfi_inst_ops *ops)
187187

188188
mutex_lock(&core->lock);
189189

190+
if (test_bit(0, &inst->core->sys_error)) {
191+
ret = -EIO;
192+
goto unlock;
193+
}
194+
190195
max = atomic_add_unless(&core->insts_count, 1,
191196
core->max_sessions_supported);
192197
if (!max) {
@@ -196,6 +201,7 @@ int hfi_session_create(struct venus_inst *inst, const struct hfi_inst_ops *ops)
196201
ret = 0;
197202
}
198203

204+
unlock:
199205
mutex_unlock(&core->lock);
200206

201207
return ret;
@@ -263,6 +269,9 @@ int hfi_session_deinit(struct venus_inst *inst)
263269
if (inst->state < INST_INIT)
264270
return -EINVAL;
265271

272+
if (test_bit(0, &inst->core->sys_error))
273+
goto done;
274+
266275
reinit_completion(&inst->done);
267276

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

285+
done:
276286
inst->state = INST_UNINIT;
277287

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

297+
if (test_bit(0, &inst->core->sys_error))
298+
return -EIO;
299+
287300
if (inst->state != INST_LOAD_RESOURCES)
288301
return -EINVAL;
289302

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

324+
if (test_bit(0, &inst->core->sys_error))
325+
return -EIO;
326+
311327
if (inst->state != INST_START)
312328
return -EINVAL;
313329

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

350+
if (test_bit(0, &inst->core->sys_error))
351+
return -EIO;
352+
334353
if (core->res->hfi_version == HFI_VERSION_1XX)
335354
return 0;
336355

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

365+
if (test_bit(0, &inst->core->sys_error))
366+
return -EIO;
367+
346368
reinit_completion(&inst->done);
347369

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

387+
if (test_bit(0, &inst->core->sys_error))
388+
return -EIO;
389+
365390
if (inst->state != INST_INIT)
366391
return -EINVAL;
367392

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

413+
if (test_bit(0, &inst->core->sys_error))
414+
return -EIO;
415+
388416
if (inst->state != INST_STOP)
389417
return -EINVAL;
390418

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

440+
if (test_bit(0, &inst->core->sys_error))
441+
return -EIO;
442+
412443
reinit_completion(&inst->done);
413444

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

463+
if (test_bit(0, &inst->core->sys_error))
464+
return -EIO;
465+
432466
return ops->session_set_buffers(inst, bd);
433467
}
434468

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

475+
if (test_bit(0, &inst->core->sys_error))
476+
return -EIO;
477+
441478
reinit_completion(&inst->done);
442479

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

500+
if (test_bit(0, &inst->core->sys_error))
501+
return -EIO;
502+
463503
if (inst->state < INST_INIT || inst->state >= INST_STOP)
464504
return -EINVAL;
465505

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

526+
if (test_bit(0, &inst->core->sys_error))
527+
return -EIO;
528+
486529
if (inst->state < INST_INIT || inst->state >= INST_STOP)
487530
return -EINVAL;
488531

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

540+
if (test_bit(0, &inst->core->sys_error))
541+
return -EIO;
542+
497543
if (fd->buffer_type == HFI_BUFFER_INPUT)
498544
return ops->session_etb(inst, fd);
499545
else if (fd->buffer_type == HFI_BUFFER_OUTPUT ||

0 commit comments

Comments
 (0)