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: 455768 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3648486jae; Tue, 8 Jun 2021 04:43:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdu2Z0Gkc/RlIAkAABf9iXBJgHhVtKPrAnpo/yaxfqSM/qpvw4zHXv3xKHHwNHyeUeCnpu X-Received: by 2002:a17:906:82c3:: with SMTP id a3mr22164603ejy.230.1623152586197; Tue, 08 Jun 2021 04:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623152586; cv=none; d=google.com; s=arc-20160816; b=YcK1nSnuyMSklgAwKKdAqmQYosiRntq9hpxoChB3tw/l5HwfZXFbn9xYP6rJrIoqTA G16kAJ9g4FezK41vJK9eMoP2V52JShlFMI+GF4KR1Bup+40oAbEfM5/Fj0p2vRKqsCin dLiSr+AnG/O9Z50MYas3pxtncnL9EAnjqCwX+yk2TVJ9icgGYdYrGq71eEGP3m2nc6qU ERURvrRgO2aIHAatU74+LAQFZvwdwhIsvdt3f2NfsiCD4tp1zttzqJmwNm9GL3Ji5/0T RJQ6el41diHb3SoskDZBbJFb38ASh/On64S4WXVXwATV34YjGgC2f7R/9PHq554QM8It PDfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=k2wKJvLK7tR0cSFBus6iUpbSIY6nGRz9/ET7AjDR48U=; b=brWysHb9XVQmyf7Zj0zneSd3NwHlChPc5XfLv95oe+Fgx48uTcGIRqvAc8DrPt0qit oQBKxuSzBTPyKrJBDOIXv9Ux4NJ+dKBah5cKpVRM9q57JYLkpnPMu1Xj4giM8ETQMalf Fkn7RfL0aceW32irozJT58FVpl4n4cUgZRnkgyTcmFpCzNoojF1D6FNplsnXGpYW//pQ hjs2TDwPSNxAE/cfeABBKDQXyIIraAlJgYJNk5GDBhsYV929NlCqEGv6BAoDhypXhI4Q a1h0SNZZ6PsheL6/iJ2pvP5oh08B/OwWUGLqxq8JZ6eTMC2GSopTKpfih6xiqZfJYcef duQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R32UCUXB; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l10si7740928edq.534.2021.06.08.04.43.05; Tue, 08 Jun 2021 04:43:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R32UCUXB; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231919AbhFHLoY (ORCPT + 4 others); 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-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(-) -- 2.25.1 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: 455767 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3648492jae; Tue, 8 Jun 2021 04:43:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl66p2SC0RFXBwCrLT5CadDimasdeFutHTEFseKXXTHcl5iHyOFZS0G4GMqVhmsr0SwtJz X-Received: by 2002:a05:6402:2805:: with SMTP id h5mr8760505ede.379.1623152586662; Tue, 08 Jun 2021 04:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623152586; cv=none; d=google.com; s=arc-20160816; b=ZK0hDpwwSxP+0ZviiW/uAs5BiR8wbtjGvHwtZebd+LXe1dc6P9E6YCoq8Nj35/3GUM /a6YDbd7Suyqs9h8rl/jAsgP7bHU61GdVce4OhFYyK29E6R2HOXSlIfNDVHt/PLOluQf K+R40+hcPEvbn0Rgg1Eh0Kv6ItIsDNXdyfYSAbdrIka8Rfl0rWGJHvATHEQmpKZHxIww WXxbuPLsFN7tgQb4hUsJEenQ2bfXpCUDzOeUxKfO00JUrxesckrENI8rYyjgl+QNN69+ dS/mkZPlDbRA2I0+/sJf2EGCBgBuo+UxuUeujRUM4SuDBdH5YIPFSZNpEvwwG+uuJusx uWKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=f6H94T+uU+WB+eDFyaDEtbp5loDIAeoS21OeowwkFpM=; b=Cha0H4DuZ/VwfRhvaNad9mG2m7A1XqyVEuOmthFbsr2+FfP9SkIzcPwenoMxVVcEuG Pwb5iFHglynp0LpGLrLs71LZbuVAAzZROGdWNch8wnTliwsKsRZJuvxF30eos3vuC97r nwi1Wttz1+0shX/OjER8qtqvRWEDHdtHPyofMDgjjO4Jd/BtTNCw4tw3zguWjkDlppN+ SLJbzjswoLSaUBthZemJ1Jjv5Cz8ggCjGqdGHp8jpv6FnyOQiwEYaj6o212sCq6lZ8F/ Y5jr4+X3YrpwiPGNbsyBKLltfq3A8E3t1xtsCu7GrjnOetzUxG9cowQC6awLoa7kL09s 7gKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="QG/wJKFp"; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l10si7740928edq.534.2021.06.08.04.43.06; Tue, 08 Jun 2021 04:43:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="QG/wJKFp"; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232063AbhFHLoZ (ORCPT + 4 others); 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-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(-) -- 2.25.1 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: 455771 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3649201jae; Tue, 8 Jun 2021 04:44:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuSzQwL9Ym9QfG25ZVQ3DzgWppoEk8J94pvOu5klM+17QPf+QRsOJcHPZWcbhfNFoaGn1r X-Received: by 2002:a17:906:33c8:: with SMTP id w8mr23243752eja.46.1623152651595; Tue, 08 Jun 2021 04:44:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623152651; cv=none; d=google.com; s=arc-20160816; b=d6swe5loUJfpt/oWOkrcf0OWiUn3ffJVHkJoxlkYgRcucKp0AbYoSl75KxpZbB6QQz +PdcWRG6H2K8ks6TWDndyVAooVTziWgFj2DfqPknxvnxazsLaR/QuetB1a4yScUrUhsH y0wTkwlxFX4aPL5y20imRf5PDGF13mgu4X4aVdG9cMKWlaWxeNJHm2Fx42oGlLxz2mWE heax2BARqSbj0TxTtiW6bOsYzvr178z5BrFIz+ND44oIKO3agZnkcUwdU2H1KFzigCPt EE5659MwE/R9ZgkQ7P8ukxk6ztMpbNtIBc11TO6eHuVhXSXq2I6muiArCxHHfqSPUAYd 7mHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Y7K2JbNeUWm87uiKc3ObB7AJ60gqYS/WRSTd2rZZKPQ=; b=FCLPgsXCmkLNvti9XAArnZPo7GZJPkmu1S/cNjXmndR9ei3x6bWcKQpNjevObiF3nT MQxhtkvkPRNeeGQ751tfA1a5OOFY4YsNj6fzvrM8XwywlcXJJ2sJXbiF48GYrBIasNHw Ff855jtn0+zaBJexVjYxl9QK9X5oa6Q33PSOzDp9+1lqucQeRB8uB5xL5FOjFDaE/o1l Jace1qqkxi8A5bHPvsh3srQ3zXUGsEU+Id2fko/EO0bUDxpznDnUYNVDgB4fBYSXgd9b FRInz7Hdu80O3V9NuMLWdAPGMhGn6BwI/u1ADw5QxKUlVj5Yt6tgtoBue2LYs393ScIO p2JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Y9CFdu/A"; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e3si201894edm.242.2021.06.08.04.44.11; Tue, 08 Jun 2021 04:44:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Y9CFdu/A"; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232172AbhFHLpY (ORCPT + 4 others); 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-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(+) -- 2.25.1 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: 455769 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3648500jae; Tue, 8 Jun 2021 04:43:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxu6S1qLaPKQpjJDbDaVxxunLoZOW0qvfzowClBUhNlr4bgH4W3BVWPAETI7DaQHDk6BvE9 X-Received: by 2002:a17:906:82c3:: with SMTP id a3mr22164689ejy.230.1623152587604; Tue, 08 Jun 2021 04:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623152587; cv=none; d=google.com; s=arc-20160816; b=ag24kRSlqEH/76udzLIYtq1gvyfNFtbZOfuRFHMrJef29gGMtNkcPx5q6P1hGkjzhE +B9n5+XdoLXVoWUN4e6ZRyQmGRyoo+E3YmAIIiFFHM3AIBCmz+W8qOH+wx/r6U54BK7B yQjk7VorVAGDZLW32d/B1Rc9YJ66nqwV9izng/VCN2Pdqzzibe+jydJUKYS0IckYIdXp FtMsWKK8spyCtUHMu5MxN/iDM1Rmm/BHu2AFF6sfEPeep28oCFzlofupL5uij5FEGmDL 0+PRo3VfETOjvqUW7RS9eyhMiZPx2Spck6Sr4595BgT39NxFft1e+oPJRSZdEXkB2liD nPlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tFrq06L55Y88t1UsTNBMVBuhf1oW5jJWDm/FwjGxUTg=; b=s3d6bAbhi3MxNJAjb/D5BUgps5e7oLWSk/nKyBybrR4YDMuzHIP39hkYDQwR5jpzxQ OTbneOW4Mchps22zGmhkxi8BxXECXVyVfCrJtG4aEG9I8npWCM+VaAK6rSfYXcc+fmHr aTqWb+ihPVAGi98zJhiXRaHexy45D3xmIRL8i30SXIWORbQ3QylL8tqYeDVja6xKs1zU MVtEWgA6ZxBtBqWL2rqz85XyFTfJQRPr000//DtW/DBesbdMO1XVJVoXNaWPqWcj1WKY V8/AqUZ5O5zJDahk43mIb0d0NVdXqrzRCVqdNnEUlQEQEESPMJS1L20AGRcArYbOGKZ2 wm4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jp3nTomJ; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l10si7740928edq.534.2021.06.08.04.43.07; Tue, 08 Jun 2021 04:43:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jp3nTomJ; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231751AbhFHLo0 (ORCPT + 4 others); 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-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(+) -- 2.25.1 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: 455772 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3649232jae; Tue, 8 Jun 2021 04:44:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrn/hQbEGodIz0K6MO9lB6wWmm95lahd4wPElG8/vpbou6ZT001qMOH5SYe7qQxLdiyqbs X-Received: by 2002:aa7:dd57:: with SMTP id o23mr24556957edw.98.1623152653944; Tue, 08 Jun 2021 04:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623152653; cv=none; d=google.com; s=arc-20160816; b=YnlwN5PM+3jQikQZMHO0+WnlpQL6f9cxMnT1NHgaHBI4PaB6XigTkB2YgeBNjwfBg5 czSJf+8m7NjdW/j4uWIW8yh2shdxDAqOPKsbumKVyJCsQu5iwYUS4U2UiaiNRNIbyAmm D/n98Sztk67wvAjBHvpEEGX522co3OAcV4gbB4Ogrld4cIxJmNrTBYArYvHtdWNtU3LC x/KCZSL77Iys99NGFyIePyFhG+As/RBOQi2wUFIvic7MoYCNrqQldJ/AHHnkMq+iNnwj bJh6O77ViPqAsquay+f2H+JcdtX70ZweaVq7KecKEunGS7NyD8tXcwOvnfdSn3C+YwCf 6sHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=26aHXU1SXvSZ0A6RHa6DT3t7eKawhrtLsouvlIaEHEQ=; b=rxyJeuvXdItWJbAzf+n2D+56hhHu3XyZoarWJtAsMqZ9LGh9Ta1noPnrmm+IFJqAvM TOsza8XC6+6Bp573b3i9kJCbjKz6qVqFwxpfbs4aAOi4IAQ7uDstZhYbvceSSl+MvOuj fss/+iM/LgM0K9ESpnwxei5vB5WPYQjIu7bEcEhhlExN2Uzp1wHHfIm+mTdZjo9gcmJm kvlTz2uA7Ul9t8Jn6ixM3YwXY1oJpjIKOGi6QtoO+iyfVeV1eHqJeP9uRklJNc73J1JH WpAEglpTjNyDCYmqeyr53Pdus671Kuz6qhpCuPvJ1nRdw3Du1ZixE4xqKR81306ziW9f SNrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mtLvh6jY; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e3si201894edm.242.2021.06.08.04.44.13; Tue, 08 Jun 2021 04:44:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mtLvh6jY; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232209AbhFHLpj (ORCPT + 4 others); 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-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(-) -- 2.25.1 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);