From patchwork Tue Jun 8 11:41:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 12306541 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79BBDC47082 for ; Tue, 8 Jun 2021 11:42:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5ADEE61358 for ; Tue, 8 Jun 2021 11:42:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231919AbhFHLoY (ORCPT ); Tue, 8 Jun 2021 07:44:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231560AbhFHLoX (ORCPT ); Tue, 8 Jun 2021 07:44:23 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE934C061574 for ; Tue, 8 Jun 2021 04:42:30 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id dj8so24139909edb.6 for ; Tue, 08 Jun 2021 04:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k2wKJvLK7tR0cSFBus6iUpbSIY6nGRz9/ET7AjDR48U=; b=R32UCUXBtI7/c9g37x4Z3cV6QgcGQQxUuH1H/ZQQUISK7W6Q8cGXc+uLp3VFs0tBfL rJAf8FWLzhIZ5Q+QEOaUioIp/t+XZcW4dKmhL7+H9F3NajRLv3Bwp9SekN02StkgoLxL DCftmQZIf20Ui9052JnyCJFn7czcTyaFUSB/5Qd6fPAXm8diHwSJOadB6VRonUKIjrp9 z4i5x3hx6YdaXVlA8QZKwr8r/0UAGg48qP42uKB/rbNvZgLZHZ5unJa9GqSk31+jeeoH KRn5Llm9DNq5n3kBVu9Xx7Qa0ZEfkwPt81SP9is139aQnZKXNIkMs0guB/jS7AKgoTjE ERiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k2wKJvLK7tR0cSFBus6iUpbSIY6nGRz9/ET7AjDR48U=; b=Wk+uLejd8vmIz7Qm1yC9YjD2n/Diyk2tSmMgGaOq9pJle1yRuUmbzxkJt9vgSQLzOu 6eVdJEGdliU2eeT811YmgA3tJF5/CR3nkgHW0JGssprs4zpCwom0L1wYdQNcXNqKh9HW 8BJznKBGugEwWrFUgQaXYncfvrMrSjmOENSMHNcEtaNiaJCruFuu9wlYW7jb96AuLEvV b0XEBttUgQPnaKXqfWowuujPsz9AvYqNLmatOFaLsjYTlGDCwzdj8jmZAIPt+wFprXAs OmIrL9K+0MQqgc3AqpVI0GZeZdpKfqu4K6seVIBUOMsSPMdbAeHjczFQOsCGk0t56teJ u/Uw== X-Gm-Message-State: AOAM530oyNkdRWLNIDi5S7hW4r25mXHeYGDcZAOMQbT6wZTecwPi2Q7b 3S4VFdXYRMd5bxsUgDuWUSZhf6KOOFaqvSYu X-Google-Smtp-Source: ABdhPJx1fY3mD3MXSBOSPBkM412FkGkhPQHglrkVDdMI2xU70RD2T3wXp8TW0mwyMrPbOrUrGGbZrA== X-Received: by 2002:aa7:d798:: with SMTP id s24mr20722933edq.243.1623152548946; Tue, 08 Jun 2021 04:42:28 -0700 (PDT) Received: from localhost.localdomain (hst-221-104.medicom.bg. [84.238.221.104]) by smtp.gmail.com with ESMTPSA id x4sm8754740edq.23.2021.06.08.04.42.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 04:42:28 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Mansur Alisha Shaik , Stanimir Varbanov Subject: [PATCH v2 1/5] venus: venc: Use pmruntime autosuspend Date: Tue, 8 Jun 2021 14:41:52 +0300 Message-Id: <20210608114156.87018-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210608114156.87018-1-stanimir.varbanov@linaro.org> References: <20210608114156.87018-1-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Migrate encoder to pm-runtime autosuspend. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/venc.c | 103 +++++++++++++++++++++-- 1 file changed, 95 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 8dd49d4f124c..47badd43145d 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -536,6 +536,64 @@ static const struct v4l2_ioctl_ops venc_ioctl_ops = { .vidioc_unsubscribe_event = v4l2_event_unsubscribe, }; +static int venc_pm_get(struct venus_inst *inst) +{ + struct venus_core *core = inst->core; + struct device *dev = core->dev_enc; + int ret; + + mutex_lock(&core->pm_lock); + ret = pm_runtime_resume_and_get(dev); + mutex_unlock(&core->pm_lock); + + return ret < 0 ? ret : 0; +} + +static int venc_pm_put(struct venus_inst *inst, bool autosuspend) +{ + struct venus_core *core = inst->core; + struct device *dev = core->dev_enc; + int ret; + + mutex_lock(&core->pm_lock); + + if (autosuspend) + ret = pm_runtime_put_autosuspend(dev); + else + ret = pm_runtime_put_sync(dev); + + mutex_unlock(&core->pm_lock); + + return ret < 0 ? ret : 0; +} + +static int venc_pm_get_put(struct venus_inst *inst) +{ + struct venus_core *core = inst->core; + struct device *dev = core->dev_enc; + int ret = 0; + + mutex_lock(&core->pm_lock); + + if (pm_runtime_suspended(dev)) { + ret = pm_runtime_resume_and_get(dev); + if (ret < 0) + goto error; + + ret = pm_runtime_put_autosuspend(dev); + } + +error: + mutex_unlock(&core->pm_lock); + + return ret < 0 ? ret : 0; +} + +static void venc_pm_touch(struct venus_inst *inst) +{ + pm_runtime_mark_last_busy(inst->core->dev_enc); +} + static int venc_set_properties(struct venus_inst *inst) { struct venc_controls *ctr = &inst->controls.enc; @@ -891,10 +949,18 @@ static int venc_queue_setup(struct vb2_queue *q, return 0; } + ret = venc_pm_get(inst); + if (ret) + return ret; + mutex_lock(&inst->lock); ret = venc_init_session(inst); mutex_unlock(&inst->lock); + if (ret) + goto put_power; + + ret = venc_pm_put(inst, false); if (ret) return ret; @@ -930,6 +996,9 @@ static int venc_queue_setup(struct vb2_queue *q, break; } + return ret; +put_power: + venc_pm_put(inst, false); return ret; } @@ -946,6 +1015,8 @@ static void venc_release_session(struct venus_inst *inst) { int ret; + venc_pm_get(inst); + mutex_lock(&inst->lock); ret = hfi_session_deinit(inst); @@ -957,6 +1028,8 @@ static void venc_release_session(struct venus_inst *inst) venus_pm_load_scale(inst); INIT_LIST_HEAD(&inst->registeredbufs); venus_pm_release_core(inst); + + venc_pm_put(inst, false); } static void venc_buf_cleanup(struct vb2_buffer *vb) @@ -1026,7 +1099,15 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count) inst->sequence_cap = 0; inst->sequence_out = 0; + ret = venc_pm_get(inst); + if (ret) + goto error; + ret = venus_pm_acquire_core(inst); + if (ret) + goto put_power; + + ret = venc_pm_put(inst, true); if (ret) goto error; @@ -1051,6 +1132,8 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count) return 0; +put_power: + venc_pm_put(inst, false); error: venus_helper_buffers_done(inst, q->type, VB2_BUF_STATE_QUEUED); if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) @@ -1065,6 +1148,8 @@ static void venc_vb2_buf_queue(struct vb2_buffer *vb) { struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); + venc_pm_get_put(inst); + mutex_lock(&inst->lock); venus_helper_vb2_buf_queue(vb); mutex_unlock(&inst->lock); @@ -1088,6 +1173,8 @@ static void venc_buf_done(struct venus_inst *inst, unsigned int buf_type, struct vb2_buffer *vb; unsigned int type; + venc_pm_touch(inst); + if (buf_type == HFI_BUFFER_INPUT) type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; else @@ -1117,6 +1204,8 @@ static void venc_event_notify(struct venus_inst *inst, u32 event, { struct device *dev = inst->core->dev_enc; + venc_pm_touch(inst); + if (event == EVT_SESSION_ERROR) { inst->session_error = true; dev_err(dev, "enc: event session error %x\n", inst->error); @@ -1205,13 +1294,9 @@ static int venc_open(struct file *file) venus_helper_init_instance(inst); - ret = pm_runtime_resume_and_get(core->dev_enc); - if (ret < 0) - goto err_free; - ret = venc_ctrl_init(inst); if (ret) - goto err_put_sync; + goto err_free; ret = hfi_session_create(inst, &venc_hfi_ops); if (ret) @@ -1250,8 +1335,6 @@ static int venc_open(struct file *file) hfi_session_destroy(inst); err_ctrl_deinit: venc_ctrl_deinit(inst); -err_put_sync: - pm_runtime_put_sync(core->dev_enc); err_free: kfree(inst); return ret; @@ -1261,6 +1344,8 @@ static int venc_close(struct file *file) { struct venus_inst *inst = to_inst(file); + venc_pm_get(inst); + v4l2_m2m_ctx_release(inst->m2m_ctx); v4l2_m2m_release(inst->m2m_dev); venc_ctrl_deinit(inst); @@ -1269,7 +1354,7 @@ static int venc_close(struct file *file) v4l2_fh_del(&inst->fh); v4l2_fh_exit(&inst->fh); - pm_runtime_put_sync(inst->core->dev_enc); + venc_pm_put(inst, false); kfree(inst); return 0; @@ -1326,6 +1411,8 @@ static int venc_probe(struct platform_device *pdev) core->dev_enc = dev; video_set_drvdata(vdev, core); + pm_runtime_set_autosuspend_delay(dev, 2000); + pm_runtime_use_autosuspend(dev); pm_runtime_enable(dev); return 0; From patchwork Tue Jun 8 11:41:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 12306543 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFB7AC4743E for ; Tue, 8 Jun 2021 11:42:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C881A61358 for ; Tue, 8 Jun 2021 11:42:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232063AbhFHLoZ (ORCPT ); Tue, 8 Jun 2021 07:44:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231952AbhFHLoY (ORCPT ); Tue, 8 Jun 2021 07:44:24 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6433EC06178B for ; Tue, 8 Jun 2021 04:42:31 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id u24so24115084edy.11 for ; Tue, 08 Jun 2021 04:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f6H94T+uU+WB+eDFyaDEtbp5loDIAeoS21OeowwkFpM=; b=QG/wJKFpRPzOEUjVnHHgCiipF5S/uZflN9CSbI/EZ499HxfDH2LyWhCQGMaRwX63GR cyZVrASsK+yDEOcb6wp3S/B9P0iGLsUrZoky7sjPviqNrBYbgozMFxG5Ygc9XRPKtKkB Blic0n4W89QaSKySvQcZr8ua9PBBk958JeicyM7MlddGuX7L0WtVpjvz09jsgPwQuQi+ gU4u67SEkn01kb8FIRu4dDxlZiETFxTZ888peJK7suaY5tBf0nNkbgRDEBQA3aPD7cAZ EsWatH9P508SnFZpDc3aLzbNlJ7sObezxGWFlhf6kNrgiGo54VGYqZDmYUMHGncIdht/ dHgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f6H94T+uU+WB+eDFyaDEtbp5loDIAeoS21OeowwkFpM=; b=Tqt709p/eLuH9MV78vZotNIGmXYJNV2zwRdH8hQ+We0kyAhrcG+7TaH/l3J2fN4TqA ct8bq1TjqNI2g15D74QQ62YjFi4nBgCfiO18rv1RVGXMuBQLM+4SnM1rznIb/vmMeGiY n+BaLiEo3EWQuYHkVYLauM+xjFhpy7rDIf8xMY3oxWPm9Uo4CHLmoE6lt1GbI4iSJEut gGpRif8LqcWqMb2fPNfKyZbumkH2aNQymxEvApy6dOt8vBrF1gF5zUfdYskPBaWtj4pF XKqxswwE8RFiTPBhYiEb3ayIg4COVu/JEcqOuGRTQdlGselwCGPElFNgB393UrjeSyCA c3Ow== X-Gm-Message-State: AOAM5330KpvM36yErbmUI5vVPgJRjZXILS3G/7NOvjco0lKyKBIhof9J z6whyHXph5OPyomL8+Jd6pxQkukTrZ76xin6 X-Google-Smtp-Source: ABdhPJyBfpIAhDrVqkuaOoJw+3WTk/udkxbSUmXfFxjapUZPAs45fsuajL7tw1HOAqRsnQO62kq3UA== X-Received: by 2002:a05:6402:520b:: with SMTP id s11mr24744852edd.111.1623152549669; Tue, 08 Jun 2021 04:42:29 -0700 (PDT) Received: from localhost.localdomain (hst-221-104.medicom.bg. [84.238.221.104]) by smtp.gmail.com with ESMTPSA id x4sm8754740edq.23.2021.06.08.04.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 04:42:29 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Mansur Alisha Shaik , Stanimir Varbanov Subject: [PATCH v2 2/5] venus: Make sys_error flag an atomic bitops Date: Tue, 8 Jun 2021 14:41:53 +0300 Message-Id: <20210608114156.87018-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210608114156.87018-1-stanimir.varbanov@linaro.org> References: <20210608114156.87018-1-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Make the sys_error flag an atomic bitops in order to avoid locking in sys_error readers. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.c | 4 ++-- drivers/media/platform/qcom/venus/core.h | 3 ++- drivers/media/platform/qcom/venus/helpers.c | 2 +- drivers/media/platform/qcom/venus/hfi.c | 2 +- drivers/media/platform/qcom/venus/vdec.c | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 91b15842c555..cc6195f2409c 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -65,7 +65,7 @@ static void venus_event_notify(struct venus_core *core, u32 event) } mutex_lock(&core->lock); - core->sys_error = true; + set_bit(0, &core->sys_error); list_for_each_entry(inst, &core->instances, list) inst->ops->event_notify(inst, EVT_SESSION_ERROR, NULL); mutex_unlock(&core->lock); @@ -161,7 +161,7 @@ static void venus_sys_error_handler(struct work_struct *work) dev_warn(core->dev, "system error has occurred (recovered)\n"); mutex_lock(&core->lock); - core->sys_error = false; + clear_bit(0, &core->sys_error); mutex_unlock(&core->lock); } diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 8df2d497d706..a625a8477f75 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -7,6 +7,7 @@ #ifndef __VENUS_CORE_H_ #define __VENUS_CORE_H_ +#include #include #include #include @@ -181,7 +182,7 @@ struct venus_core { unsigned int state; struct completion done; unsigned int error; - bool sys_error; + unsigned long sys_error; const struct hfi_core_ops *core_ops; const struct venus_pm_ops *pm_ops; struct mutex pm_lock; diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 1fe6d463dc99..210c628ac8f4 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -1477,7 +1477,7 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q) ret |= venus_helper_intbufs_free(inst); ret |= hfi_session_deinit(inst); - if (inst->session_error || core->sys_error) + if (inst->session_error || test_bit(0, &core->sys_error)) ret = -EIO; if (ret) diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index 0f2482367e06..179b1f8b2650 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -214,7 +214,7 @@ int hfi_session_init(struct venus_inst *inst, u32 pixfmt) * session_init() can't pass successfully */ mutex_lock(&core->lock); - if (!core->ops || core->sys_error) { + if (!core->ops || test_bit(0, &inst->core->sys_error)) { mutex_unlock(&core->lock); return -EIO; } diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 198e47eb63f4..68736359fc2c 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1211,7 +1211,7 @@ static void vdec_session_release(struct venus_inst *inst) ret = hfi_session_deinit(inst); abort = (ret && ret != -EINVAL) ? 1 : 0; - if (inst->session_error || core->sys_error) + if (inst->session_error || test_bit(0, &core->sys_error)) abort = 1; if (abort) From patchwork Tue Jun 8 11:41:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 12306547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89A17C47082 for ; Tue, 8 Jun 2021 11:43:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7970F6135A for ; Tue, 8 Jun 2021 11:43:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232172AbhFHLpY (ORCPT ); Tue, 8 Jun 2021 07:45:24 -0400 Received: from mail-ed1-f45.google.com ([209.85.208.45]:46810 "EHLO mail-ed1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232191AbhFHLpY (ORCPT ); Tue, 8 Jun 2021 07:45:24 -0400 Received: by mail-ed1-f45.google.com with SMTP id r11so24080073edt.13 for ; Tue, 08 Jun 2021 04:43:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y7K2JbNeUWm87uiKc3ObB7AJ60gqYS/WRSTd2rZZKPQ=; b=Y9CFdu/A3lYi+m+ZOqPqTrRzlO0TanrAkOSXVsz9kDK1wqQDq1wyCIM+oE6HiyxgUu 8WftKNaykN4h557cUIqTLx6ycrbtZJsthwiw1qHZV1i6lXTnzaH4zcIh/e7oeS/aeLgZ 6JOM53/sZv9THkqUoBqIkf2qsW4XdpjlyoWdHTonFG9ewcJNAyImh9AWfjn8uv+l6QRV u/+zLsX8WyYF4SJoKKNfyrZNs9pMRSVqbBxxxBiFhxUcbiqGdAaSYnFy4p24A8eCc229 Qos5NTUnKuhGPD1XRjlVT6AL4l0PNzImHTgMGr12+OIaJTLm0tpAt/0qdtwk80rwFjmN BjBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y7K2JbNeUWm87uiKc3ObB7AJ60gqYS/WRSTd2rZZKPQ=; b=rxJ3UxO7rNKu78/AKRVanxePEZjSeEqiVThD999ULtcTsEZUdGBbdSB9EbIHarmeYy K+rNjJcWj7qWXc7N7w79y4jxK/t7x0f17gHEqqbZa7L5Atle8OaIDGdNuGAsCdEoGcpi xJiY12KG4m0oqG/+0jhIEpaLoN4J8hzESMSQrnt0gquhcMOpT5zAZ/GxDU00M6/dQ7eA QehXy+W7DnSPSjqoRaFaCGJf6xY/UJzR7FYoFYe8sDY6bjE//XzyXdB1flarqJmKtAmF m/TYc08862eA+GDMHNCp7zy1FPDFY/Wj9/AxeuA5I5k7yLBYQFg5rY3HhepJYMnWqFd/ uCDg== X-Gm-Message-State: AOAM530IoaYLFcA1hYiVELXHAgNwwlTjmYK+Ioffc4t9D4GFHflhly1/ cvUYIKaHZyc/V35XxjUTDksWNZdl0bt43Z/L X-Google-Smtp-Source: ABdhPJzd7ct8ZuBfa7wEsDhzlXv/2Ul3Ym9yy/mPqr+Dfb+/AUPktRs/sm34XVtMMdUNfxj8fz/Xzw== X-Received: by 2002:aa7:d84e:: with SMTP id f14mr25055452eds.12.1623152550438; Tue, 08 Jun 2021 04:42:30 -0700 (PDT) Received: from localhost.localdomain (hst-221-104.medicom.bg. [84.238.221.104]) by smtp.gmail.com with ESMTPSA id x4sm8754740edq.23.2021.06.08.04.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 04:42:30 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Mansur Alisha Shaik , Stanimir Varbanov Subject: [PATCH v2 3/5] venus: hfi: Check for sys error on session hfi functions Date: Tue, 8 Jun 2021 14:41:54 +0300 Message-Id: <20210608114156.87018-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210608114156.87018-1-stanimir.varbanov@linaro.org> References: <20210608114156.87018-1-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Check sys error flag for all hfi_session_xxx functions and exit with EIO in case of an error. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/hfi.c | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index 179b1f8b2650..4e2151fb47f0 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -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) { @@ -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; @@ -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); @@ -273,6 +282,7 @@ int hfi_session_deinit(struct venus_inst *inst) if (ret) return ret; +done: inst->state = INST_UNINIT; return 0; @@ -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; @@ -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; @@ -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; @@ -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); @@ -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; @@ -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; @@ -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); @@ -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); } @@ -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); @@ -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; @@ -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; @@ -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 || From patchwork Tue Jun 8 11:41:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 12306545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AA06C4743F for ; Tue, 8 Jun 2021 11:42:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA95661351 for ; Tue, 8 Jun 2021 11:42:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231751AbhFHLo0 (ORCPT ); Tue, 8 Jun 2021 07:44:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232069AbhFHLoZ (ORCPT ); Tue, 8 Jun 2021 07:44:25 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4DDEC06178B for ; Tue, 8 Jun 2021 04:42:32 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id f5so19128421eds.0 for ; Tue, 08 Jun 2021 04:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tFrq06L55Y88t1UsTNBMVBuhf1oW5jJWDm/FwjGxUTg=; b=Jp3nTomJgkEhgEeyNwnrzndFq1i5o2nkzUWx/TjttTeXoFc+xDqbl/RePlnQ34/o83 aqETP9FV1A5nviFpqiUOhI2WiaWjQQCMqjUKjA7UUHB8kzTqJIA/gnWnur/Sb5Ayux/Y +VNdJOZdweRnciUJCKJxa76D1XseXobydCW9A/ZXTNUK2RLxcJFjkV06DEyndn1U3aNN bEzQOZ1jG2C2ZqEw57GLBKOoRD5TIqcNe9HTaMWLorKiUiyHw3qxr/pvZRh3itKpaMXp UKXp2+v37eTFZ8u41Xlq1T7meq98CeBY5+/mBUbNCkhsPrEticL4nsfddP52mycsznqM GmTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tFrq06L55Y88t1UsTNBMVBuhf1oW5jJWDm/FwjGxUTg=; b=DExV+wVSuKJ/v4PcmP3E08RPMsTDG1PSg29pQ6OvSIVe2NIGehhaS6/ApToYoCb2/l lAqa2wxiuycp/Y19ln00Dx1TFf1kinVUqlHAV01UMuIozyDkEeVEbHK2s4RGG3p3CCxS lTShynEf8Psp+t05wyq6mgkiP6vcwpvsbk8EKKUO87IKWr48RR8CCik0M9fCgJbH4Tj4 kQxTAgzmyHGHZKayyd3RXoRrFhVUQ5eajAv2LR1Za/S2loQMh3hsEKVnSlg3oIiQKTTu 4TzouehLqJw6wVWIIWsleNEN6ej/Nf0QvPeXImPIc3YgUIxGdNEBfvQAhAVrdPd20XDR YKBA== X-Gm-Message-State: AOAM531yG7l8+SKX4lpGkDoT5nZMFQPQKm7/hGoBrOo++mytTFUHNyPp 4JVjXPZewnHh6TSvLNCBKBus03MjecckqA2P X-Google-Smtp-Source: ABdhPJw+uZQIHhLXGaXT3Ui6sOHP3nHG5aE5HnbKkLgQyrNANYbcdjG1Cf5aIH/wLOQ8wn/6cXokpg== X-Received: by 2002:aa7:c68f:: with SMTP id n15mr9554873edq.145.1623152551207; Tue, 08 Jun 2021 04:42:31 -0700 (PDT) Received: from localhost.localdomain (hst-221-104.medicom.bg. [84.238.221.104]) by smtp.gmail.com with ESMTPSA id x4sm8754740edq.23.2021.06.08.04.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 04:42:30 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Mansur Alisha Shaik , Stanimir Varbanov Subject: [PATCH v2 4/5] venus: helpers: Add helper to mark fatal vb2 error Date: Tue, 8 Jun 2021 14:41:55 +0300 Message-Id: <20210608114156.87018-5-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210608114156.87018-1-stanimir.varbanov@linaro.org> References: <20210608114156.87018-1-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add a helper to mark source and destination vb2 queues fatal unrecoverable error. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/helpers.c | 12 ++++++++++++ drivers/media/platform/qcom/venus/helpers.h | 1 + 2 files changed, 13 insertions(+) diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 210c628ac8f4..abd41ebf3c1b 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -1505,6 +1505,18 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q) } EXPORT_SYMBOL_GPL(venus_helper_vb2_stop_streaming); +void venus_helper_vb2_queue_error(struct venus_inst *inst) +{ + struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx; + struct vb2_queue *q; + + q = v4l2_m2m_get_src_vq(m2m_ctx); + vb2_queue_error(q); + q = v4l2_m2m_get_dst_vq(m2m_ctx); + vb2_queue_error(q); +} +EXPORT_SYMBOL_GPL(venus_helper_vb2_queue_error); + int venus_helper_process_initial_cap_bufs(struct venus_inst *inst) { struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx; diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index e6269b4be3af..6a250c3d3cfe 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -21,6 +21,7 @@ int venus_helper_vb2_buf_prepare(struct vb2_buffer *vb); void venus_helper_vb2_buf_queue(struct vb2_buffer *vb); void venus_helper_vb2_stop_streaming(struct vb2_queue *q); int venus_helper_vb2_start_streaming(struct venus_inst *inst); +void venus_helper_vb2_queue_error(struct venus_inst *inst); void venus_helper_m2m_device_run(void *priv); void venus_helper_m2m_job_abort(void *priv); int venus_helper_get_bufreq(struct venus_inst *inst, u32 type, From patchwork Tue Jun 8 11:41:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 12306551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1560BC47082 for ; Tue, 8 Jun 2021 11:43:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB04161359 for ; Tue, 8 Jun 2021 11:43:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232209AbhFHLpj (ORCPT ); Tue, 8 Jun 2021 07:45:39 -0400 Received: from mail-ed1-f49.google.com ([209.85.208.49]:41761 "EHLO mail-ed1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232208AbhFHLpj (ORCPT ); Tue, 8 Jun 2021 07:45:39 -0400 Received: by mail-ed1-f49.google.com with SMTP id g18so22130016edq.8 for ; Tue, 08 Jun 2021 04:43:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=26aHXU1SXvSZ0A6RHa6DT3t7eKawhrtLsouvlIaEHEQ=; b=mtLvh6jYIsKx7MN3I7KBDJBag2UsHkcXvWAKZEtmSkTqP8Y9wdlB/gG80/5K/trLuW GX/S00MpVl4VCv+h6NOkLppIHqigFzAS0hyYNk/IdLiFg+Yh9fQmehiPah8t2cUfGjsR gCiviMeiB26bXFUXkPBfURcYC+Rm4dO7P1769S3DNKAiWyhXNlZdYSK6l1eaJ/uxE88R NU8EcLiATM5c1gFBZNUOAOuxbEdzD+g2TacKexrd17UFWrsOf35Pl0P/gZ9vbo6WD5Rp jvOzuDwkXgLEFZSiHIKpmDzK+MiYm9Y2xdI6zXfodGm3LkHdSayNmrIvCYjOKYQ9y7fv OWNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=26aHXU1SXvSZ0A6RHa6DT3t7eKawhrtLsouvlIaEHEQ=; b=qbXwq0lRDT5AmUcs0UDayA1DXDWchYGcaa7vNUgTxjFmXZiHQGIqG/ZMMX12gsk4mY vTqFBq1yLoDWgnOnJ54AARxs6kg15HMRziPXBsbrrlSQGEj4d5r1LdfeSyMJ7TA4l+4C XNJRmwo7t7OEyn0hhXM9xF2/OQkYiY9xlF/Ogd9DqM87g/5fDlfLmONGmXrFFhNa3AE1 Kr4bGps4jzNqStO9bU79yXhhLYGJdcGwicFBEr8J9Bo//vjHuY+uSHiujxS5wt9eysPq MgQgxDlo+2JVk4KKwGMThXvGimtBFFC4My454o6GyLW77j6j8YR7yj21WOiWyLJifmBT hNPg== X-Gm-Message-State: AOAM531QngwQT8H17Uz/8UfB8o9PZbcdEmmYRBKJ+PRAyaHuXSar/mRc KO2kqs7Af7+KFTZS5yxUPOXN+dL+3BrMzHCe X-Google-Smtp-Source: ABdhPJyqD94ChqseTxPk/jjLnW5VWOvfKFqeClavDa5+Inp/+Zu2pxdo/bBUECF/ez5e5WDNv610Vg== X-Received: by 2002:a05:6402:170e:: with SMTP id y14mr25601743edu.367.1623152551937; Tue, 08 Jun 2021 04:42:31 -0700 (PDT) Received: from localhost.localdomain (hst-221-104.medicom.bg. [84.238.221.104]) by smtp.gmail.com with ESMTPSA id x4sm8754740edq.23.2021.06.08.04.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 04:42:31 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Mansur Alisha Shaik , Stanimir Varbanov Subject: [PATCH v2 5/5] venus: Handle fatal errors during encoding and decoding Date: Tue, 8 Jun 2021 14:41:56 +0300 Message-Id: <20210608114156.87018-6-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210608114156.87018-1-stanimir.varbanov@linaro.org> References: <20210608114156.87018-1-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org According to stateful decoder docs a fatal failure of decoding (and encoding) could be recover it by closing the corresponding file handle and open new one or reinitialize decoding (and encoding) by stop streaming on both queues. In order to satisfy this requirement we add a mechanism ins sys_error_handler and corresponding decoder and encoder drivers to wait for sys_error_done waitqueue in reqbuf. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.c | 9 ++++++--- drivers/media/platform/qcom/venus/core.h | 3 +++ drivers/media/platform/qcom/venus/helpers.c | 2 ++ drivers/media/platform/qcom/venus/vdec.c | 16 ++++++++++++++++ drivers/media/platform/qcom/venus/venc.c | 13 +++++++++++++ 5 files changed, 40 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index cc6195f2409c..b1fa9b349efb 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -95,9 +95,8 @@ static void venus_sys_error_handler(struct work_struct *work) failed = true; } - hfi_core_deinit(core, true); - - mutex_lock(&core->lock); + core->ops->core_deinit(core); + core->state = CORE_UNINIT; for (i = 0; i < max_attempts; i++) { if (!pm_runtime_active(core->dev_dec) && !pm_runtime_active(core->dev_enc)) @@ -105,6 +104,8 @@ static void venus_sys_error_handler(struct work_struct *work) msleep(10); } + mutex_lock(&core->lock); + venus_shutdown(core); venus_coredump(core); @@ -162,6 +163,7 @@ static void venus_sys_error_handler(struct work_struct *work) mutex_lock(&core->lock); clear_bit(0, &core->sys_error); + wake_up_all(&core->sys_err_done); mutex_unlock(&core->lock); } @@ -318,6 +320,7 @@ static int venus_probe(struct platform_device *pdev) INIT_LIST_HEAD(&core->instances); mutex_init(&core->lock); INIT_DELAYED_WORK(&core->work, venus_sys_error_handler); + init_waitqueue_head(&core->sys_err_done); ret = devm_request_threaded_irq(dev, core->irq, hfi_isr, hfi_isr_thread, IRQF_TRIGGER_HIGH | IRQF_ONESHOT, diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index a625a8477f75..0f65a3beecbb 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -183,6 +183,7 @@ struct venus_core { struct completion done; unsigned int error; unsigned long sys_error; + wait_queue_head_t sys_err_done; const struct hfi_core_ops *core_ops; const struct venus_pm_ops *pm_ops; struct mutex pm_lock; @@ -333,6 +334,7 @@ enum venus_inst_modes { * @registeredbufs: a list of registered capture bufferes * @delayed_process: a list of delayed buffers * @delayed_process_work: a work_struct for process delayed buffers + * @nonblock: nonblocking flag * @ctrl_handler: v4l control handler * @controls: a union of decoder and encoder control parameters * @fh: a holder of v4l file handle structure @@ -396,6 +398,7 @@ struct venus_inst { struct list_head registeredbufs; struct list_head delayed_process; struct work_struct delayed_process_work; + bool nonblock; struct v4l2_ctrl_handler ctrl_handler; union { diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index abd41ebf3c1b..46aaa25efe9e 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -1501,6 +1501,8 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q) venus_pm_release_core(inst); + inst->session_error = 0; + mutex_unlock(&inst->lock); } EXPORT_SYMBOL_GPL(venus_helper_vb2_stop_streaming); diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 68736359fc2c..5c416c8b9365 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -830,6 +830,7 @@ static int vdec_queue_setup(struct vb2_queue *q, unsigned int sizes[], struct device *alloc_devs[]) { struct venus_inst *inst = vb2_get_drv_priv(q); + struct venus_core *core = inst->core; unsigned int in_num, out_num; int ret = 0; @@ -855,6 +856,16 @@ static int vdec_queue_setup(struct vb2_queue *q, return 0; } + if (test_bit(0, &core->sys_error)) { + if (inst->nonblock) + return -EAGAIN; + + ret = wait_event_interruptible(core->sys_err_done, + !test_bit(0, &core->sys_error)); + if (ret) + return ret; + } + ret = vdec_pm_get(inst); if (ret) return ret; @@ -1178,6 +1189,8 @@ static void vdec_stop_streaming(struct vb2_queue *q) venus_helper_buffers_done(inst, q->type, VB2_BUF_STATE_ERROR); + inst->session_error = 0; + if (ret) goto unlock; @@ -1448,6 +1461,7 @@ static void vdec_event_notify(struct venus_inst *inst, u32 event, switch (event) { case EVT_SESSION_ERROR: inst->session_error = true; + venus_helper_vb2_queue_error(inst); dev_err(dev, "dec: event session error %x\n", inst->error); break; case EVT_SYS_EVENT_CHANGE: @@ -1568,6 +1582,8 @@ static int vdec_open(struct file *file) inst->bit_depth = VIDC_BITDEPTH_8; inst->pic_struct = HFI_INTERLACE_FRAME_PROGRESSIVE; init_waitqueue_head(&inst->reconf_wait); + inst->nonblock = file->f_flags & O_NONBLOCK; + venus_helper_init_instance(inst); ret = vdec_ctrl_init(inst); diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 47badd43145d..33a5b4a94cb4 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -926,6 +926,7 @@ static int venc_queue_setup(struct vb2_queue *q, unsigned int sizes[], struct device *alloc_devs[]) { struct venus_inst *inst = vb2_get_drv_priv(q); + struct venus_core *core = inst->core; unsigned int num, min = 4; int ret; @@ -949,6 +950,16 @@ static int venc_queue_setup(struct vb2_queue *q, return 0; } + if (test_bit(0, &core->sys_error)) { + if (inst->nonblock) + return -EAGAIN; + + ret = wait_event_interruptible(core->sys_err_done, + !test_bit(0, &core->sys_error)); + if (ret) + return ret; + } + ret = venc_pm_get(inst); if (ret) return ret; @@ -1208,6 +1219,7 @@ static void venc_event_notify(struct venus_inst *inst, u32 event, if (event == EVT_SESSION_ERROR) { inst->session_error = true; + venus_helper_vb2_queue_error(inst); dev_err(dev, "enc: event session error %x\n", inst->error); } } @@ -1291,6 +1303,7 @@ static int venc_open(struct file *file) inst->session_type = VIDC_SESSION_TYPE_ENC; inst->clk_data.core_id = VIDC_CORE_ID_DEFAULT; inst->core_acquired = false; + inst->nonblock = file->f_flags & O_NONBLOCK; venus_helper_init_instance(inst);