From patchwork Tue May 18 15:45:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 441217 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp352094jac; Tue, 18 May 2021 08:46:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwO7Gcqsg8/hYgYFwhBYEc67uBEm9cYhV6jqEVUFjEoaPN5Qdvn1rC6KMeFM/ilk/yvVTtU X-Received: by 2002:a5e:a806:: with SMTP id c6mr4565219ioa.180.1621352784425; Tue, 18 May 2021 08:46:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621352784; cv=none; d=google.com; s=arc-20160816; b=otqAVbNbhq04zh822hrxptaubAyFBQQ9p9XQocrceeIR7aMpc/DiB+qDxdlqqnV228 mPjeViB0zqyvB3EO/Kq13L/3AyuGjEZDUlKBe6UjsorXaQ6dhwpy4p5fL07hsl0eCmIM X+QFHZKX+Ac+gMpFIwdASzvyaH8m8OoItY+qQMqRKe4iFDBwfQw8kWHCjHkDzG6Dkb02 gqFesmVY6HJsZoGaCUfOE6JSe75PBKEeK3qGVCh6zQI3gSDDI1ZaFR0tDE39ZDdrqIrq hAWqEaqVNCDAcdv4LY6CPdLMvQJcmWlV8GI1fnQZI4hQINEmtVQTzPnTannH+I9aRelf pqnQ== 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=1/H81rU02gspRWJgBsv9W0dFt8/8Hr7Pms8U3EgDA+w=; b=hykaLoxaAsEi/vBqsJezqYe3ZEGfeS8VqNrXpS67F1WF/R944d/JGlJGBHZPmrUjmM KHRErathpIcLSuTZzdlZjns7jEG5WRY9/xrHQIQGnHYmVS7RHw2SDTUZ4A8F5423Z/Np zoA/v0xKFDKKaYxWH55FRd1FzvWzSWLokHk0J9h5xLoHKh+J7ndpf4TBRUeB484vesQG 61QCDuNiv9Y2S66qYTXgSRnjWv3XtzBbDo6YP8yTyIes+jFRoVS66StF+R3vpULnRPqw r//WtBHTE2jse0lj0tVY8jUlgWXOzaRscAnj18RJMpODbS31vhIH2VhH44JiV6a+39+w VHrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="h4OWn/Ns"; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 m1si24689393ilu.13.2021.05.18.08.46.23; Tue, 18 May 2021 08:46:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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="h4OWn/Ns"; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1350343AbhERPr3 (ORCPT + 17 others); Tue, 18 May 2021 11:47:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350312AbhERPqr (ORCPT ); Tue, 18 May 2021 11:46:47 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 128E1C061763 for ; Tue, 18 May 2021 08:45:26 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id n2so15309618ejy.7 for ; Tue, 18 May 2021 08:45:25 -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=1/H81rU02gspRWJgBsv9W0dFt8/8Hr7Pms8U3EgDA+w=; b=h4OWn/Ns0ZlE7bfHiYjnBQ/qhCvVVo1H5J/FwA+uo2OgCZFV/gsV5Qbct+RI3pnmWT pxXLhFqMd3XnDevqVqwCriVafixt6W/5xVtnxghUorX7c4uxboXhRl37TyT5qESEmoEu z5y1XeltxPk1LAQs6v/lmi0kB5ixuSLdEG9xKswYxvzxgJBxcnv68r/vLSIhX7ssWFJR xrLVNeHvJd0JoFq+MM1yYtx6gcceAhueq2oSVTtupgXL4CvHoSmgLg3FJRu3CTeoK9Iv C2Bxjm6sK6LB//nXIEApzHsVr0QWqW1oysk3gYdzEPenfpmse5oEqrcv1cuNmd3KDwTX zkIQ== 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=1/H81rU02gspRWJgBsv9W0dFt8/8Hr7Pms8U3EgDA+w=; b=A23pTzGRvwkEu7dYgavitTr/ql/CWC4C15BZ+yPwd6EYYOlMKPGIa36Hnsy5homGhM V688QgvwsuXIqMwIKrbaO+Winqis0NYGfTO4raH9Hi5YCvtrNuKs45Z7XChkYZU6fGrI zM9NRtLdvb6p/tgYsHGuvIrXJrBT/5S/qotLY98Qrzb+vxwPiDKVxWyqA6rnc6Y3tcno 1HTx0Ouh1O/FwDMpRFv2ZevtDnBUe16/ARB/ddGu4ZNuXuqCBrCxberhsrWlTE2UodvM 4mnrHVfcRgg+kSVJIc0lUhjJdHy+TMIw81GGc/XVO3eADevaB5EcEhT5aJBPlXZ0An5a 9XsA== X-Gm-Message-State: AOAM532WyLXprXWpZVytqPE6ImxC3NWTq/GSrjWbgfMo84CGzhQ8jix8 FN1O9RzsKiv++cUc+yaIlhG+eA== X-Received: by 2002:a17:906:c448:: with SMTP id ck8mr6697836ejb.497.1621352724422; Tue, 18 May 2021 08:45:24 -0700 (PDT) Received: from localhost.localdomain ([195.24.90.54]) by smtp.gmail.com with ESMTPSA id n17sm13016434eds.72.2021.05.18.08.45.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 08:45:24 -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 1/5] venus: venc: Use pmruntime autosuspend Date: Tue, 18 May 2021 18:45:05 +0300 Message-Id: <20210518154509.602137-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518154509.602137-1-stanimir.varbanov@linaro.org> References: <20210518154509.602137-1-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Migrate encoder to use pm-runtime autosuspend APIs. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/venc.c | 104 +++++++++++++++++++++-- 1 file changed, 96 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 4a7291f934b6..a7a858f03ba3 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_get_sync(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_get_sync(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_get_sync(core->dev_enc); - if (ret < 0) - goto err_put_sync; - 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,7 @@ 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; } @@ -1260,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); @@ -1268,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; @@ -1325,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 May 18 15:45:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 441218 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp352156jac; Tue, 18 May 2021 08:46:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywpi1r1v25LS4cl9LG7TwO0oBIsPdaM3dlJUaoGhU3LHMPFU9U02QxSP6GnDAVU9/MKvbk X-Received: by 2002:a05:6602:1222:: with SMTP id z2mr4550445iot.120.1621352788898; Tue, 18 May 2021 08:46:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621352788; cv=none; d=google.com; s=arc-20160816; b=ip8agUErK4Vv86DTHT7YvZNeEyaIxi8+Ste0PHVvUjNqy8Z1Nb4VdkfgI7OtZ1NMg7 BrPdgdSt35t54bPD2m1L7u7aWmJ9jgaBAsn7EPWodO7BY5vq0cACn7lmRhvSPBHfafjB zPY9uZaNjcAQTOn/upWhgodmiadBd/FjsKd0rzLoonR3RKYXvLWnIIK+O61j447+mfBC i2XA4GCdHfCbL+e2rjyu2MaBkQePYAVZuaN3ypQBupikmjkodvDaClkHPYhb49MgItFe 3+gqQ2nRF75d4MROzl/netP8dDruaYzTM3l1JNe0azvEQzklHZBbgQFfxH+faHDaRTZD qACA== 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=3eQT5w75rkSKr8V4Rzzvpp/1P0SvKsxN/0nHM1tgGJI=; b=BD1LtDmBJfgLd95pRBLbUDH0P/7WLDhvnunGY3Ru1cwNB836QAHTJVJUKPhykeehPT ZsphFY502Z060IYRNqXS2GEqz34PG0uG+nPw0p0UBlgKafTpu9EfICQMXtre0aJ/sxIf T0kbQJnnLwrVXZZfzBVhXSXcAZSgQ4BoPnYBPmQjjf6SGOJlNsfK/ahtrSd1mnOaQ972 xBGNTV8056DdzZEvlT+SAXZhSvjE2NhXYgbE5ICAqR3DySINxs6XnE1OCVjAgTKNINom cJS+sK/IZ5FJ1/Hn+rafF9x2tQ6dh13fOd8Nd2Nhzg/KlvBfgjRJrvbKI8+JpoQrkFer 1GZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rRhgP9UZ; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 v3si21970616ilq.36.2021.05.18.08.46.28; Tue, 18 May 2021 08:46:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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=rRhgP9UZ; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1350312AbhERPri (ORCPT + 17 others); Tue, 18 May 2021 11:47:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350315AbhERPqs (ORCPT ); Tue, 18 May 2021 11:46:48 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BCB3C06138A for ; Tue, 18 May 2021 08:45:27 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id k10so15310477ejj.8 for ; Tue, 18 May 2021 08:45:26 -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=3eQT5w75rkSKr8V4Rzzvpp/1P0SvKsxN/0nHM1tgGJI=; b=rRhgP9UZQiEtb6v8BAdYyzo30YdvcIFku8IRRd3mkNvNFcE+EWF6QZTLqsz9OdbMU7 GVvvDahRMVIt3nHGMgTIfO85NVc+TZIwj2mEvs4hJxiAv1cswxOu/w0dil0C5nAcDmJm 4QS3Jzp4KbQ/P2eQPLlwfADa15l/P9Sw4WZBfHhCd4fy1CoIkuAT/B+UlloP5rTVaGSR WRv2YMGSOIQ20WwAiQ6yO2JKzb8ZCnBrjXq9XQ+f5yzKqZyaXadWauEQAL4FvBIzGUnL YGjcdJZ4d28Pt+weEaWL2rLlQsjDUNPUycz3ThX+wPIud59ceeZ5wS6mQAR81WMakib/ E0GA== 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=3eQT5w75rkSKr8V4Rzzvpp/1P0SvKsxN/0nHM1tgGJI=; b=Z7f0UI7FMGIab9gPzCSw/HpGmUVXh1ahM8d9YkpTFePm35MRA57q6nl5m4OPqKFLPq mDHbedTbKrfom+8U30/kYSFK8fJUkyK+YJBNHDyQCYtU9drtMijppRQmXivievtXLjv6 o2LDrWCWmXMExEdhdPNg8MzD40AtQIh4BBJcE6nWFQOSHRMRdZiejbUQ72eGTKDOy8i3 bjkzNQEs0w6L6XDK1XWsCsng/Ya9mPCAkRqxATpm0Qjrkyl0u5hddiPs0V7kQ1GSFzi6 wUHtTtMHlnytzRWRU4PGDAIX3ALQFtA7unEeY3WbVVVBoiTpHSL6iRi+qZ3KEQrG0LQ0 u0uw== X-Gm-Message-State: AOAM530pdcdvxiZcshildf+2IF2wnaBWdUDkNkcbTBcaUk2IWsug9pfO BWmGAA2g/fBlkXLsD0090YFpPw== X-Received: by 2002:a17:906:7c82:: with SMTP id w2mr6796433ejo.448.1621352725704; Tue, 18 May 2021 08:45:25 -0700 (PDT) Received: from localhost.localdomain ([195.24.90.54]) by smtp.gmail.com with ESMTPSA id n17sm13016434eds.72.2021.05.18.08.45.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 08:45:25 -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 2/5] venus: Make sys_error flag an atomic bitops Date: Tue, 18 May 2021 18:45:06 +0300 Message-Id: <20210518154509.602137-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518154509.602137-1-stanimir.varbanov@linaro.org> References: <20210518154509.602137-1-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 745f226a523f..15713209cc48 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 @@ -182,7 +183,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 b813d6dba481..de87f4c81a1c 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -1478,7 +1478,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 ddb7cd39424e..132a2921902a 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 May 18 15:45:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 441219 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp352405jac; Tue, 18 May 2021 08:46:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+O/5/dWRIaAgR3XRAPyFor/BSHy7xRg9sNrBc1lGgm/iC5Ad82WCxJXVOi4Ht4chvCjac X-Received: by 2002:a05:6638:597:: with SMTP id a23mr6107924jar.27.1621352804254; Tue, 18 May 2021 08:46:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621352804; cv=none; d=google.com; s=arc-20160816; b=nwq3t2zwJGiST9GmvaFcfzq3quq8Y+6Jj/dv4falmgvKptJ/e/9ItQZ1eOMVQC8nGj ulFr+M/zJ4fDgI1oGLoJhb5bQTSarl+tQ81r7ulGbs7jOHQ5Z73hzj1UG2CoyTSP2D4C Mp7roDXt+pEbhwHIKVbjj/SjM9NpRlCKmuzBj2UkKaWSeQ4tn9tUy290yBoCUS4ppVIN MgoYxhQu3kUU4+7nrdHQvWpw20F2jrXhLwLTwlhikmRWipjOA961f1yab1+iibOcKBd6 RRWf/WI0UxBnsaoJMqnRvBrgAwtN8ZW/kYNXyiVi7nEeAcYgO0hh/GInrRl3d8scSj6K pSLg== 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=I+uokykHZeMy2+feXn3LjsoQgLFsXUEkSOMV0oTIkUR9xFwsgPsg9/hEJtKPN+Kj/X xr9VY1IcTFn915gEJi0Qoo743xvLCCMlRzwBEDJgNKJx2DfXFhH4VqxVXIAMWH9ftNqJ gKbF1YvWcNQ821VIdELUZB5eHgGUaZeAo8aXy3PIhsqm79OdNWaE6kSbFdLdZJho728p r/ptKtkUJ5bVG+bPvI8uLY28uAtPTezZqpKMizDpZ8Okf3VD3V7iRTW8pMJvDKpe0GyR 94gZgKsAidiIBpuLzkYvW9hSdCqH4FFnnGOyyi07DTgvk3bfqwLpxylgkNfMDa0fcrCq oujQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NPEiXHCh; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 v3si21970616ilq.36.2021.05.18.08.46.44; Tue, 18 May 2021 08:46:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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=NPEiXHCh; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1350376AbhERPr4 (ORCPT + 17 others); Tue, 18 May 2021 11:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350307AbhERPrR (ORCPT ); Tue, 18 May 2021 11:47:17 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C2FFC06138E for ; Tue, 18 May 2021 08:45:28 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id z12so13873500ejw.0 for ; Tue, 18 May 2021 08:45:28 -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=NPEiXHChn3WwgCCrlRDA2Pr9U8tOuNH538BPSpd6Al/XC/DBBtreV9h6ky5XUB8nar SKRS88Uz4OxHyDtGhi70CfQQw84mcg5CgFOXbRZ/3nhOfur2gOfyzHfItD/+3yEo5ksT 8FOHplGBOw1A/PSedhwiGZ5jhd+n9SV2IBCck01s8RYdVtV0VHZjFxKePBkBFZYGZBMv GoBZ6fyl11KKhuBmYnfURitHCDEGRjlfhze8TajoPf0I2M8mbXF6M/jQ9MjAPXC0wRXk u1mWPItXfjpfcEYModQmL9mWx1lfajVZ2ErNwFVeM5zjU4gS10tsFFyZJl+EOHJW2XHx Qgfg== 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=mcui7oF+U3DDl4J8i2liLBn5lzMmbIPZLPs0jchPwBeWYKpmO/dw+9f5Dfp9y+I7mK BqM2apXdJAvd6VtCBKfxYdg7cQKpIz6Mp8FhsVwC6N+1YIdov2I4K55kJnbXN2/Swds1 3Uo16CEXjEnMcMZdPa7ByFDoC8zkzruMbIwzGrKbvb3QPEmVCSvFZZn1XzhpUvJa2MIw LBzG2NV11sJVN28lRbVby7+DW/gu4gr1lgdA0EqYLW1PiUbjhUVUKDV/DM6UqXMI+f5K FVX+wXDA6QiJTx4kf/0O4LMt7ozmi0/slBTp5U7dYT65nD3sONH/PFkLRcDaaQTROYvo EDuA== X-Gm-Message-State: AOAM533wz+VX1Vt9fM6y/csIiX4wMITjf/mG6rvPn2zap81Qnz6yVPkc ecaNOe5/ad/tu4RuzzXPJPAoTA== X-Received: by 2002:a17:906:2b57:: with SMTP id b23mr6625927ejg.294.1621352726608; Tue, 18 May 2021 08:45:26 -0700 (PDT) Received: from localhost.localdomain ([195.24.90.54]) by smtp.gmail.com with ESMTPSA id n17sm13016434eds.72.2021.05.18.08.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 08:45:26 -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 3/5] venus: hfi: Check for sys error on session hfi functions Date: Tue, 18 May 2021 18:45:07 +0300 Message-Id: <20210518154509.602137-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518154509.602137-1-stanimir.varbanov@linaro.org> References: <20210518154509.602137-1-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 May 18 15:45:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 441220 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp352449jac; Tue, 18 May 2021 08:46:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHQjFffiw343t+9nrqldPkM+IfWm5QLEU7qGy6GbvuwUV40C33NBXArgxA5WOmNYSFcP/K X-Received: by 2002:a05:6e02:168e:: with SMTP id f14mr4983827ila.292.1621352806787; Tue, 18 May 2021 08:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621352806; cv=none; d=google.com; s=arc-20160816; b=en0CSFxcRWSooxzPArcMXUBOHrRueIrRZJlZlx+CK11I8OD2BNAznsfUtDVG+sMlmT uJIif4+GF+7EaKw3UFaVttR8B7gejKhAbfO3rHhRyd1tGoDfQaKHyqQmpiUwKtTaK7Ls 6dnaOHs77Lmw3wnkaLkskCzutN098X/NKXMn5mHiiDF8NRgHEfR5sJK8Rk5kIaeru1n2 BYeHrp+IMUalEmO938eqOlNETr0wevgV9hICAgpqLdhjINyqdKdZKYu+93y3t87Bj3wJ lxCVnEdL+EimuIUpB+EjVIoHrnXgNQmi31ZUMrNov2egh7qR9SKCXuSCUlBem7/9Pix/ uS0w== 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=pBC9lAWMmdU2wypGRaqpn1YM7C+m/9LQ4eZFQOQwGaM=; b=hV/eOubDrAkfDLW4fQQuEZ42QBuF9QZF5B/3gUekeyoGkqyLUYEi3XoOC8G1VsNaFB N+rqk1wo3/oEes/TlcdzlxUxIYZSA5qj2h1YLo26bgSNK/nM5CQmJJCGEgHZAiqsqpyZ xYT7lIgKv69uh46SRC4I8EqkcLabtr7PPc0IzPQE6vrGE0MrpUQOvd9GrrpcEHDU56SC V30efp49S+hVo6yO04mhAXKt7JtJ/yyEc0HO/UJBLmoh3UwgXQGf4OfHEmhwuDJDjtUm pt8RPHONvP05r6mayNhsYAWEGpcWFZLxfbtQ3FIL8h79opt4mF17GTx3mfUPCEwi73m/ 7ROw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V5vmq52b; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 v3si21970616ilq.36.2021.05.18.08.46.46; Tue, 18 May 2021 08:46:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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=V5vmq52b; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1345261AbhERPsB (ORCPT + 17 others); Tue, 18 May 2021 11:48:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350330AbhERPrW (ORCPT ); Tue, 18 May 2021 11:47:22 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DB97C061343 for ; Tue, 18 May 2021 08:45:28 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id k10so15310620ejj.8 for ; Tue, 18 May 2021 08:45:28 -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=pBC9lAWMmdU2wypGRaqpn1YM7C+m/9LQ4eZFQOQwGaM=; b=V5vmq52b+rKzRQya3bt/2XugBvt5zZTXazpcMM91mDBR6xlKrEcXJUHCfPgP4cRTwu dJm+7hKTEeJAqdIPG7dlP8Ohpx+85+GSztuxIpRyh7kszcfUOUoVuwnz2oNuf5IUVP6R UNSf+CCPA5ZKrQRjobHJ+BFsCoKwKQxR2oh7r9rHoVlG3445qQRS1UPOqQbVdAVhGIty 7YV+WONKc14E1ZT2UVM61zdboD8cGF+icAVxTuHyc9HAUrVFG8gsTZXDfF0VeuuPUZds hXKYP5/g+Qw7N67g2uZTfRMfdS9CIMCnuXe2LrKEXbMY8yScGXsqHCUA5Botle9q/SkN lVbg== 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=pBC9lAWMmdU2wypGRaqpn1YM7C+m/9LQ4eZFQOQwGaM=; b=mfEaEA8wp+WsNBsmYPhFByoR378X6vyfrEpm/lWnMP64mo3f1bjhzR+yEe1wIw/Q5S bEiBoiC8IAtCJiDxo+TKqr33zDMb0T6keP+XE3Nt/rWbtZcCYYh/S/wTlZ+KR6Aa0cSJ OkqRRs7y8dYT0IbpKfdetZNE6W170zHyRnZKvm2V4u1tF20KabF0TWpPCHu0PwS2J9T8 zp/tEgJ5BxOeahZmDE/w43cezppDFMFsOqfP8uEbxgnIOvCgspHY0qEg1LW3gFDi6IOE q9qDPizG80P24yDZ7lEJxtZMS1l71IOfJq+MjURQv2sWKMWP7KRaApp3F1ss6t6+Weev SkdA== X-Gm-Message-State: AOAM532x/zBEHHJlUZoE1vOyLbbN7JgBA57ZtK9BoxA8M87BVRa2wvG4 adJJK3xeLb/zn8EdSahd+O84VuLJnNWjjWMx X-Received: by 2002:a17:906:3ed0:: with SMTP id d16mr6671002ejj.16.1621352727606; Tue, 18 May 2021 08:45:27 -0700 (PDT) Received: from localhost.localdomain ([195.24.90.54]) by smtp.gmail.com with ESMTPSA id n17sm13016434eds.72.2021.05.18.08.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 08:45:27 -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 4/5] venus: helpers: Add helper to mark fatal vb2 error Date: Tue, 18 May 2021 18:45:08 +0300 Message-Id: <20210518154509.602137-5-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518154509.602137-1-stanimir.varbanov@linaro.org> References: <20210518154509.602137-1-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 de87f4c81a1c..6c4b64e995a1 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -1506,6 +1506,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 May 18 15:45:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 441221 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp352473jac; Tue, 18 May 2021 08:46:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznw4f8eHDB32B5cwcD3lnXm7a8oHt/VHxfRWyhp7cXkWH7A/ge0FnGbCVcOPQiqMkTGBZF X-Received: by 2002:a05:6602:1222:: with SMTP id z2mr4551941iot.120.1621352807995; Tue, 18 May 2021 08:46:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621352807; cv=none; d=google.com; s=arc-20160816; b=ksn27r/yvZEPQDoWKqWgdX40Mz0OqFCMXTypQaotmuI9GyJ3PPcI231St4Isk3gec4 QSfuTy4KhOTEPI9LwPGp9KVOzOU3nAFIUTyc77E05Jr9cV77HD6RMi26oSmUFoEaRFbd 47QESnUjv5v/8bsagcyS1FpgrkdnTI4LCneoXOnnGDNfSHpidUYkRDP7b+VqUXSazkpD WCVEMSYpD+40scFX58SHqXbgEJwhQheC/TZUXyQ8j8EKc8fsZsTmqdU72Tsgfzb/Gmy3 SNAjfFwqP6VYRsbLLqq3Zbkpsl/6tXNmlJiKrQLLbzOmSxmMQzbM3gtaQ9vqENwGhPfG rpXA== 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=8C/6l4d+SEnoWZvzZbTyveJhPhCLYFpI4fdt3SHOYbs=; b=oG5wnaYlhQm8t7G5hP2bflJ245EkqSxCpisIvV7P/cIbLTXa5U3BLEUh8N5Y0JWrGc vsiM/LeUIt9UVBboIkg4wSkkLLDuU1e7v5eNlrHwRb6Lr2sMzjy06xnfXkxYPKcZIPtG Farbf2CW72zbVuJ4r0L6qvoMQTN4NlqJPS5j2czjRm2+4GDE8kU8m5Z9Vh48ei7JmatF MAF3nt0QqtRW7QXiiwRv2VCMUA4DsMGeQ8eMmKoa8BygqG8/qPLDn+a22Ftud+RFdji2 Mu9EMdt656zMO7RRQVmHLQEl/oSsJ39SOUUSRQvLtQVcszIXgY+oK9lgYgwOsNeykN10 a3/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="DTe/CuZh"; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 v3si21970616ilq.36.2021.05.18.08.46.47; Tue, 18 May 2021 08:46:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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="DTe/CuZh"; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1350331AbhERPsE (ORCPT + 17 others); Tue, 18 May 2021 11:48:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350333AbhERPrW (ORCPT ); Tue, 18 May 2021 11:47:22 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0914C061346 for ; Tue, 18 May 2021 08:45:30 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id n2so15309932ejy.7 for ; Tue, 18 May 2021 08:45:29 -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=8C/6l4d+SEnoWZvzZbTyveJhPhCLYFpI4fdt3SHOYbs=; b=DTe/CuZhZG56+uLl6KKrzDwoQgCY26/IKFMDzbQWGQvD5Y952bG/Y+FBSmWAuCKxt4 GNIYofirAaXsY2UZHs4OXy3Jnwjl290IqHFRA6j3evnX5Zf2PeCaY+gd1a7eiU8jBfDl pNI11i8aEq4CgEAwNm7vIPNPSTZsZfIoTBFnu+NEQ0JPKIy7NMnU3UxgrjWWzOSWwnfp bCwZOIypTvyB6QWjQPOXaPQchjkpW/EJCvrRHJXkMNa4dPZEMycTYQd5qAwymx80/ZJp ct1iAj7uKCFEZn/WM4TFza6KD2pkWG9110K/VXUBU0WVGV2ew3si0PbychMC7sXts1Oc YErA== 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=8C/6l4d+SEnoWZvzZbTyveJhPhCLYFpI4fdt3SHOYbs=; b=nsm6STTY34tFIQ3wfVEpQ7ZC6AaQA4LHp4euTESRfRenBSqB5dvB0vzXs/2g5IPCzx zrOHLulS2KZTEghbA5HFdyBZHfmbSosZVfYiw6imME9JXKYl3AbNT4PiVrmd7LyJNB4Z e5sv3o4Cuea6CRiXdIvaZiJC166G2MGw9f0imHFrZK6u+Gsu0niPldvqrwuyyiCcJuBS BIJ+HLCi4xTmk0nDdtx117zVS6++b1H7s8lsf5U/xUv56qxkV+HlVlF3OXcaXJLC+Fw8 dSVABqiDUZTEkb6b9ZfgeZj9yajVFs/m93tK3KYqBGGJmpirYpDX16WB04h+QlyLFXcr H2bA== X-Gm-Message-State: AOAM532OLRFrEDCdZf8gofCey3SUlFp3hrsL9N389kdrHV31AdDKaXQ4 iyC+GeCH51NVxRXwiuliHa9o4w== X-Received: by 2002:a17:906:3ce9:: with SMTP id d9mr6727934ejh.172.1621352728692; Tue, 18 May 2021 08:45:28 -0700 (PDT) Received: from localhost.localdomain ([195.24.90.54]) by smtp.gmail.com with ESMTPSA id n17sm13016434eds.72.2021.05.18.08.45.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 08:45: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 5/5] venus: Handle fatal errors during encoding and decoding Date: Tue, 18 May 2021 18:45:09 +0300 Message-Id: <20210518154509.602137-6-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518154509.602137-1-stanimir.varbanov@linaro.org> References: <20210518154509.602137-1-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 15713209cc48..8e2b4635a396 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -184,6 +184,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; @@ -329,6 +330,7 @@ struct venus_ts_metadata { * @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 @@ -392,6 +394,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 6c4b64e995a1..9b8ff76e3c43 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -1502,6 +1502,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 132a2921902a..5e5584fc21e9 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 a7a858f03ba3..001b9bba3909 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);