diff options
author | Stanimir Varbanov <stanimir.varbanov@linaro.org> | 2020-12-04 11:01:37 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2021-01-13 09:06:17 +0100 |
commit | 20891170f339a8754312a877f3d17f0e5dadd599 (patch) | |
tree | 087fa77a444163b2d9288702231a1c958dc245af /drivers/media/platform/qcom/venus/hfi.c | |
parent | 5f2ca73dcca96c3de96a0e4d9ea24ebb46c55d2e (diff) | |
download | linux-stable-20891170f339a8754312a877f3d17f0e5dadd599.tar.gz linux-stable-20891170f339a8754312a877f3d17f0e5dadd599.tar.bz2 linux-stable-20891170f339a8754312a877f3d17f0e5dadd599.zip |
media: venus: Limit HFI sessions to the maximum supported
Currently we rely on firmware to return error when we reach the maximum
supported number of sessions. But this errors are happened at reqbuf
time which is a bit later. The more reasonable way looks like is to
return the error on driver open.
To achieve that modify hfi_session_create to return error when we reach
maximum count of sessions and thus refuse open.
Tested-by: Fritz Koenig <frkoenig@chromium.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/platform/qcom/venus/hfi.c')
-rw-r--r-- | drivers/media/platform/qcom/venus/hfi.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index 638ed5cfe05e..8786609d269e 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -175,6 +175,8 @@ static int wait_session_msg(struct venus_inst *inst) int hfi_session_create(struct venus_inst *inst, const struct hfi_inst_ops *ops) { struct venus_core *core = inst->core; + bool max; + int ret; if (!ops) return -EINVAL; @@ -184,11 +186,19 @@ int hfi_session_create(struct venus_inst *inst, const struct hfi_inst_ops *ops) inst->ops = ops; mutex_lock(&core->lock); - list_add_tail(&inst->list, &core->instances); - atomic_inc(&core->insts_count); + + max = atomic_add_unless(&core->insts_count, 1, + core->max_sessions_supported); + if (!max) { + ret = -EAGAIN; + } else { + list_add_tail(&inst->list, &core->instances); + ret = 0; + } + mutex_unlock(&core->lock); - return 0; + return ret; } EXPORT_SYMBOL_GPL(hfi_session_create); |