From patchwork Wed Apr 8 21:33:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11480949 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 876A517D4 for ; Wed, 8 Apr 2020 21:34:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 644B82082F for ; Wed, 8 Apr 2020 21:34:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="eYr8eNy5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730706AbgDHVeC (ORCPT ); Wed, 8 Apr 2020 17:34:02 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:33707 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730702AbgDHVeA (ORCPT ); Wed, 8 Apr 2020 17:34:00 -0400 Received: by mail-lf1-f67.google.com with SMTP id h6so6367066lfc.0 for ; Wed, 08 Apr 2020 14:34:00 -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; bh=dGu6G6U9laSFYPkNmi6ZzG7WVHHi3cCRqEsXprARE/c=; b=eYr8eNy5cDTDVyI+xHQL+AUHFo3gMgU74ThpTvWHIW3Ck+kZLmUFKTThRyC4s2o2WX 4JMNsmiGxwTTeyjmM8J8C8vC2ZLnhtQg9DNUGrHLpfA0WQI3qVmmD9iTB/AUG+7gTsMM ArNLz3rYg/01IMOkcFl+3xLznQCC6EPVlkykqTDhUXcSoQyT/MzNt9z35k4+4xL2t9XW nE7pywacVqNzDuxi5l2V9GUXDmOegHvV3CrKM+6Be9sTOQ1Zo7LjTN+96qKUJ/NPa955 ercDf30Tqxchp0jjbJebHT5t/C5hhX9GoxGBFK5BEoA404g/XwrQTcZOa9HfkMyrRXoa AEtg== 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; bh=dGu6G6U9laSFYPkNmi6ZzG7WVHHi3cCRqEsXprARE/c=; b=YtE0naaFZDe9JheUTUQzvbQ7ISBbnukBtKhC4+lpdMyI8TSd7Kg4uzlFCKY0Q2NjQC Grs1bH9A1Ds84QETKRABgVgOR9hVsgH4NJpk5wcWe/9B13iqOhIovpxSuF0OGGFbsLsN c7bSVUKDo06CXIiKlUhBYey1AqZwBz15bzlXqaBst/SLeIQGKvp05do959Ng76a+YfAc 67nGCWhmthrKHloL3F9GKOtf5elT2DYPYgqZwQRV5q30Um68FRqC2+eWnR7ixo0SYm2W rrl9ukbPpr8U+D9HE9Zs+lwuJyiR9GEbaUYaVC7czeCTe3Q6yKdI/DJoWpjCAW1995v+ 9foQ== X-Gm-Message-State: AGi0PuZZXEomHwyN9rtP6iJ6f5TCHbQZGNNZoZA+BYqJ7Hz4pzZvdd16 Fw89dYYxZxnF2mmtmfwv+FlEHWIaO78= X-Google-Smtp-Source: APiQypJys5JfGvGwfOKAO4N/l/YXrDr/1V9RYF63SNuDS7AhccKshDKvFd9TQV7QnKBo0bgPhrUynQ== X-Received: by 2002:a05:6512:318a:: with SMTP id i10mr5747051lfe.96.1586381639108; Wed, 08 Apr 2020 14:33:59 -0700 (PDT) Received: from localhost.localdomain (212-5-158-138.ip.btc-net.bg. [212.5.158.138]) by smtp.gmail.com with ESMTPSA id t6sm15746688lfb.55.2020.04.08.14.33.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 14:33:58 -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 , Stanimir Varbanov Subject: [PATCH 1/7] venus: core: Add missing mutex destroy Date: Thu, 9 Apr 2020 00:33:24 +0300 Message-Id: <20200408213330.27665-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200408213330.27665-1-stanimir.varbanov@linaro.org> References: <20200408213330.27665-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This adds missing mutex_destroy in remove method of venus core driver. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 4395cb96fb04..f8b9a732bc65 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -335,6 +335,7 @@ static int venus_remove(struct platform_device *pdev) v4l2_device_unregister(&core->v4l2_dev); mutex_destroy(&core->pm_lock); + mutex_destroy(&core->lock); return ret; } From patchwork Wed Apr 8 21:33:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11480951 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDCCA112C for ; Wed, 8 Apr 2020 21:34:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA9F62082D for ; Wed, 8 Apr 2020 21:34:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZVsytK8o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730728AbgDHVeF (ORCPT ); Wed, 8 Apr 2020 17:34:05 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:37229 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729070AbgDHVeE (ORCPT ); Wed, 8 Apr 2020 17:34:04 -0400 Received: by mail-lf1-f68.google.com with SMTP id t11so6327447lfe.4 for ; Wed, 08 Apr 2020 14:34:02 -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; bh=m0H+TjYWwXJL6hiVHCn9qdA94+TCG5AQ9tgfxlqydng=; b=ZVsytK8oepa/xsA0sM8t3gMRagHJuW5Qs0EVWvZ7J1bdzExT/XHV6k5yG+Er1smbpE zP/G7J3t98FuREH7B3bviEHc+AVvKwsnh2sKGF2QbbhNkjsiU7YtGMxQex2bDeQnQ3W1 HJiAywwY/trHlixyjU0xgyyIOyCGkJwsxeBYtx+UCzYuj7V96ZujQd92tms66/dkKvVh DBq+na8TDe4hLVPANGgzqPMHpyJ/l1SLA64P50yo45ya4W9YcAhX6GMbLpXEkhL8Vrla kC5PTPrpHrrwqiu9lrjoov4lp+gBRR7Bf7Za8+dQ19q4eCyFHHQWGIWa2BDEqovsQzlZ 2zcQ== 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; bh=m0H+TjYWwXJL6hiVHCn9qdA94+TCG5AQ9tgfxlqydng=; b=SjLobfDJrCehmDyLsPUDw1DsUHp+mi1LOsDkugJum07/g+sstisbdNu2rr5s0yqWpq 1mabv6qadGNsyl2AYhawoYLWUF7wPgx2MsD77p1N4BSMyvUWn9znpy53yVF4j4E7KKY+ 68KuPFypewkHpPyE5L+GGkh5JrFjYbKWUtka+mz+w6g3KxbFTjGaaN+fPL3fSNIGtVsn PTkeEM1dP/338V5fI0Y2pp5dhQgmb9dnpZJKx4m75quMre1AYkmYW3j56IApqD41y7pU PSZs5Kncb27W7cfo346/gKs+sciYs2I7fBroa95BjEBM8F/WwCseXI66oBirt26sSor2 jb3A== X-Gm-Message-State: AGi0PuZV0QWcAoJs6UtVtnsMZNz72u4rw7M7GUCehHmaY8qfMQkNGGqd AA3nI6lz9ycEeXkEBKDQXUn/oQF/r+k= X-Google-Smtp-Source: APiQypLo2KsnOD3IP8EornlujL2uN5qo/QX3SVWS4aKcbrkUnfD9UjEAD2+xFgq0GNZnpZovYZc74A== X-Received: by 2002:ac2:4116:: with SMTP id b22mr877544lfi.172.1586381641914; Wed, 08 Apr 2020 14:34:01 -0700 (PDT) Received: from localhost.localdomain (212-5-158-138.ip.btc-net.bg. [212.5.158.138]) by smtp.gmail.com with ESMTPSA id t6sm15746688lfb.55.2020.04.08.14.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 14:34:01 -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 , Stanimir Varbanov Subject: [PATCH 2/7] venus: core: Fix mutex destroy in remove Date: Thu, 9 Apr 2020 00:33:25 +0300 Message-Id: <20200408213330.27665-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200408213330.27665-1-stanimir.varbanov@linaro.org> References: <20200408213330.27665-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The hfi_destroy function is called too early in remove method. It destroys a mutex which is used later in the .remove from pmruntime. Solve the issue by moving hfi_destroy after last usage of the mutex. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index f8b9a732bc65..afd76bcd9978 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -318,7 +318,6 @@ static int venus_remove(struct platform_device *pdev) ret = hfi_core_deinit(core, true); WARN_ON(ret); - hfi_destroy(core); venus_shutdown(core); of_platform_depopulate(dev); @@ -330,6 +329,8 @@ static int venus_remove(struct platform_device *pdev) if (pm_ops->core_put) pm_ops->core_put(dev); + hfi_destroy(core); + icc_put(core->video_path); icc_put(core->cpucfg_path); From patchwork Wed Apr 8 21:33:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11480969 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B5C5E112C for ; Wed, 8 Apr 2020 21:34:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 931EE2082F for ; Wed, 8 Apr 2020 21:34:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="n5xzq+jD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730738AbgDHVe2 (ORCPT ); Wed, 8 Apr 2020 17:34:28 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:42143 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730748AbgDHVeG (ORCPT ); Wed, 8 Apr 2020 17:34:06 -0400 Received: by mail-lj1-f196.google.com with SMTP id q19so9251801ljp.9 for ; Wed, 08 Apr 2020 14:34:05 -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; bh=ZmtMLRatZyABHiSvc9LC9XLFnfSECfJ6FOVkP/fee/c=; b=n5xzq+jDqSU/R2czdhnEmBJs1a6WCKd3RUwOfSvFFcJ/OrtE69/SCmXefoP+Z6Dq9q 7ZS3sphirpZb0ZoYJMN0UHaJkzddznQ4DGCfssvT7Cec3VwsYv447cxATz/pPyK4KchP rrPSMTLBqxgDiDOU39ErRVsZ1PAjmDWVgIBude4FjexcFOAQFNp18Mrco8+JLdb6Jyqh +lBbg+OZhTCXbpFdGBcz5gJSuyUiYpsn8Hnhb6dZYfA41PbJWYVd/zUuR5x/3M5CkagY xlIpdkeQGKZkJqHsx6IE3nuRK8gExqcDigP7bTiKCojU+bt1pxVcBwsWX1zufYlNKuEa JxtA== 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; bh=ZmtMLRatZyABHiSvc9LC9XLFnfSECfJ6FOVkP/fee/c=; b=GG/g46aqmnRX3oBhhSdIIJRtdeH5twUdR7ssyeje4zIBhrZQvcG8E7WusOB7cYlZbE GYh6C9IqF4gA9zYpqQNSi50HK45UpEQaM03/FBl5hXhOonLycTYUQilvqckvP4sN2TuS CiNgEn6qV3esbQBFuqT/LQYIsDh7E3CwZ/TQCsASGvmU/23PPjeyHRl3hI3rn4a7VHDY ntXjuXv1wvn07mHgFWgfgdOJU1gV3tS8+9uyzKdtlqQmV3qbBBPwTeEs9RTGHG9F1t3y OwO6L4GRqJEfu3enLCyd3ourz/U+e3wnK1iTgmD2C4TWPtKwwdnDfZLbgj7Kjb45CHSd Ge+g== X-Gm-Message-State: AGi0PuZYYRTLzxzebEAl2Q4GXJ6OJ5aqaZV6OO9SA+Ifgxf025M36V0i TX0ND6Rk69tMjSCE/2FjPlEz5GenTR4= X-Google-Smtp-Source: APiQypKIHx32aNL9j4vusR14vRnUwl6c9YL9LAAD4MO+elshP0otTpQEXAou1ldf8vpiu01UaHqjFA== X-Received: by 2002:a05:651c:2c7:: with SMTP id f7mr6207367ljo.152.1586381644715; Wed, 08 Apr 2020 14:34:04 -0700 (PDT) Received: from localhost.localdomain (212-5-158-138.ip.btc-net.bg. [212.5.158.138]) by smtp.gmail.com with ESMTPSA id t6sm15746688lfb.55.2020.04.08.14.34.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 14:34:04 -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 , Stanimir Varbanov Subject: [PATCH 3/7] venus: core: Constify codec frequency data array Date: Thu, 9 Apr 2020 00:33:26 +0300 Message-Id: <20200408213330.27665-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200408213330.27665-1-stanimir.varbanov@linaro.org> References: <20200408213330.27665-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The array is not changed in the code, so make it const. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index afd76bcd9978..203c6538044f 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -456,7 +456,7 @@ static const struct freq_tbl sdm845_freq_table[] = { { 244800, 100000000 }, /* 1920x1080@30 */ }; -static struct codec_freq_data sdm845_codec_freq_data[] = { +static const struct codec_freq_data sdm845_codec_freq_data[] = { { V4L2_PIX_FMT_H264, VIDC_SESSION_TYPE_ENC, 675, 10 }, { V4L2_PIX_FMT_HEVC, VIDC_SESSION_TYPE_ENC, 675, 10 }, { V4L2_PIX_FMT_VP8, VIDC_SESSION_TYPE_ENC, 675, 10 }, From patchwork Wed Apr 8 21:33:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11480953 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A83C7112C for ; Wed, 8 Apr 2020 21:34:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B2782083E for ; Wed, 8 Apr 2020 21:34:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="t31m+68I" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730739AbgDHVeI (ORCPT ); Wed, 8 Apr 2020 17:34:08 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:38543 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730754AbgDHVeI (ORCPT ); Wed, 8 Apr 2020 17:34:08 -0400 Received: by mail-lj1-f194.google.com with SMTP id v16so9326914ljg.5 for ; Wed, 08 Apr 2020 14:34:07 -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; bh=Mt9OBIj0ykBafNH/9trvGlSeMEJzqQmkZCMhh/GB4oU=; b=t31m+68I3U983sirf6zcS6e9xeVWoUaxTp9krnrbio2KDHZgVrxIe7uqLphilktHFp MDx7Az0j+gxYhyBpKNXOp8Hro+V700/mS+ZDDkuVx63BrbFJvFe/hllVStC81XRcfPxM jNfIu8ewZKQbxq0la02ESkd7HPjGJepHLioqqkhi7ebGAvJhTaOpZJ10dTG/DVKpWVwf 0AqLpPgggy9xqRHuGe8vJSGuAk1AxZJORxF4iKgmytx+oDE2X7ubCnyxKl8Ag5J6hv9a i0Turjc0XfnaDZIepqUsut6p/CwiC9OlZ2UnhUNuPJ4BcSqD61k2Ile6WKCnaX3SeZij upWQ== 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; bh=Mt9OBIj0ykBafNH/9trvGlSeMEJzqQmkZCMhh/GB4oU=; b=lLMexqsmD8oPndjNsPG//MHKxLHVgH6wdA84pecJ9hFu2t7wNE1L/oN0K3r+RUKg7G 34mh3rS94OysbguNbn5DX4wwkP17m9hORRGqYEKlloN8VET/jnG84jXvwbsnjM83RF9f Wwi+k3bNM3JT3jEFiLPFF/vABPrc9FoHKQbCD4zGSMathZS/huiZDQDIryyNvFCg5p+v wUyEzzHjqn706Hf6Hns9m4an4mU9cCXUFslO7RZeqfG8j/hX5IQowTf5JLuLLxOjga3l q5aFRdiU4IbsULFzXTMgMrsGVW7LIjL98XiYfOMvz2+ZK6VXuc4OoJUUwYYrVP7S6kBq 5spA== X-Gm-Message-State: AGi0PubjA9Xk8+a4KovzNnLZxK2gI+pm0cYhJV91ZAEf87TXyuyjDy64 b9mTlB8G42Y3x3uqb4l0vjaiLP2wqAk= X-Google-Smtp-Source: APiQypLFbtG20kBPRjrMvbSnxkPIJuRxVgxuATQnnRzzI6NprTKvBrrkBcaA+fi4G4LdQEEFQ/QWSg== X-Received: by 2002:a2e:8e3a:: with SMTP id r26mr6347426ljk.233.1586381645983; Wed, 08 Apr 2020 14:34:05 -0700 (PDT) Received: from localhost.localdomain (212-5-158-138.ip.btc-net.bg. [212.5.158.138]) by smtp.gmail.com with ESMTPSA id t6sm15746688lfb.55.2020.04.08.14.34.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 14:34:05 -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 , Stanimir Varbanov Subject: [PATCH 4/7] venus: helpers: Done buffers per queue type Date: Thu, 9 Apr 2020 00:33:27 +0300 Message-Id: <20200408213330.27665-5-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200408213330.27665-1-stanimir.varbanov@linaro.org> References: <20200408213330.27665-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Currently calling venus_helper_buffers_done() will return buffers to user for both capture and output queues in the same call. This is wrong because both queues are really separate and calling stop_streaming on one queue shouldn't return buffers for the other. Solve this by add a new queue type argument and fix the clients of the helper function. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/helpers.c | 18 ++++++++++++------ drivers/media/platform/qcom/venus/helpers.h | 2 +- drivers/media/platform/qcom/venus/vdec.c | 5 ++--- drivers/media/platform/qcom/venus/venc.c | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index bcc603804041..0143af7822b2 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -1129,15 +1129,18 @@ void venus_helper_vb2_buf_queue(struct vb2_buffer *vb) } EXPORT_SYMBOL_GPL(venus_helper_vb2_buf_queue); -void venus_helper_buffers_done(struct venus_inst *inst, +void venus_helper_buffers_done(struct venus_inst *inst, unsigned int type, enum vb2_buffer_state state) { struct vb2_v4l2_buffer *buf; - while ((buf = v4l2_m2m_src_buf_remove(inst->m2m_ctx))) - v4l2_m2m_buf_done(buf, state); - while ((buf = v4l2_m2m_dst_buf_remove(inst->m2m_ctx))) - v4l2_m2m_buf_done(buf, state); + if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { + while ((buf = v4l2_m2m_src_buf_remove(inst->m2m_ctx))) + v4l2_m2m_buf_done(buf, state); + } else if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { + while ((buf = v4l2_m2m_dst_buf_remove(inst->m2m_ctx))) + v4l2_m2m_buf_done(buf, state); + } } EXPORT_SYMBOL_GPL(venus_helper_buffers_done); @@ -1168,7 +1171,10 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q) INIT_LIST_HEAD(&inst->registeredbufs); } - venus_helper_buffers_done(inst, VB2_BUF_STATE_ERROR); + venus_helper_buffers_done(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + VB2_BUF_STATE_ERROR); + venus_helper_buffers_done(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + VB2_BUF_STATE_ERROR); if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) inst->streamon_out = 0; diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index b64875564064..8fbbda12a4fe 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -14,7 +14,7 @@ struct venus_core; bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt); struct vb2_v4l2_buffer *venus_helper_find_buf(struct venus_inst *inst, unsigned int type, u32 idx); -void venus_helper_buffers_done(struct venus_inst *inst, +void venus_helper_buffers_done(struct venus_inst *inst, unsigned int type, enum vb2_buffer_state state); int venus_helper_vb2_buf_init(struct vb2_buffer *vb); int venus_helper_vb2_buf_prepare(struct vb2_buffer *vb); diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index e8e1ecf7cf4a..7d093accbd59 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1044,7 +1044,7 @@ static int vdec_start_streaming(struct vb2_queue *q, unsigned int count) put_power: vdec_pm_put(inst, false); error: - venus_helper_buffers_done(inst, VB2_BUF_STATE_QUEUED); + venus_helper_buffers_done(inst, q->type, VB2_BUF_STATE_QUEUED); mutex_unlock(&inst->lock); return ret; } @@ -1071,7 +1071,6 @@ static int vdec_stop_capture(struct venus_inst *inst) break; case VENUS_DEC_STATE_DRC: ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT); - vdec_cancel_dst_buffers(inst); inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP; INIT_LIST_HEAD(&inst->registeredbufs); venus_helper_free_dpb_bufs(inst); @@ -1117,7 +1116,7 @@ static void vdec_stop_streaming(struct vb2_queue *q) else ret = vdec_stop_output(inst); - venus_helper_buffers_done(inst, VB2_BUF_STATE_ERROR); + venus_helper_buffers_done(inst, q->type, VB2_BUF_STATE_ERROR); if (ret) goto unlock; diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 9981a2a27c90..3d8431dc14c4 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -1018,7 +1018,7 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count) deinit_sess: hfi_session_deinit(inst); bufs_done: - venus_helper_buffers_done(inst, VB2_BUF_STATE_QUEUED); + venus_helper_buffers_done(inst, q->type, VB2_BUF_STATE_QUEUED); if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) inst->streamon_out = 0; else From patchwork Wed Apr 8 21:33:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11480967 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CC8E14B4 for ; Wed, 8 Apr 2020 21:34:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 798C32082F for ; Wed, 8 Apr 2020 21:34:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Rs+1EAWz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730590AbgDHVeZ (ORCPT ); Wed, 8 Apr 2020 17:34:25 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:38548 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730770AbgDHVeK (ORCPT ); Wed, 8 Apr 2020 17:34:10 -0400 Received: by mail-lj1-f196.google.com with SMTP id v16so9327006ljg.5 for ; Wed, 08 Apr 2020 14:34:08 -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; bh=KqwTl0YCgxCFoD6QzWeacolgi5eHFyPVK66/B9eGEJU=; b=Rs+1EAWzy1VV58B8ic72umCM2g0DVr+FxSWDqFmuwQmbfcsQpCSPb7ozP5rsx/AY+v WRNLg7tvETXoGITLQpT/VnxMGFH2obCaWmepQI3a9qkWRDDXkdyEQIJCH/3Sj4/nTST0 T26x+BW6P1xRvZ0cSj/M70vkWbWi5s+NJMYTnYH/DbwSaaSfOTaD0im2zjRHktmqAotY eTtHSQcVx3L32UzappU/dibiG6+F0TR+g7dexzBVWP8PzFLig3R/qXtGrOiOd9MlGYES aJvKlWhE3FdV0pJwG+LKBZRLJeBP0lQhpN5F530MQF5kQY1xQj/NaWdktwvQT35PKwoy WzIg== 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; bh=KqwTl0YCgxCFoD6QzWeacolgi5eHFyPVK66/B9eGEJU=; b=cOBSZsxJ4ZtzxjEz3c2zD1KZ85W+O0I2pWHJ/6CenjcR/X42B3Aij49ysvMGuLaZ7m d1McuHZWjukNtrWcy4XghW4/Zqp3Mc6rNbx431ncc2EgZc3AzPiRR+SqsbNFcfLCJGGt IJTzkAMbhMUXf0Stmj4dTnUtfm1/htfKTrFSR3HkJ9TVczObf+Mh55J/cFmbAS3ajYMG qm+wreukf2S9VVAgAAlp8A5udTnIvNPgPRKQ9UY8WjxZ38G9lXshv+fj3ynWfvDfTiLy xLUz4jyEzVbx7QF5dk+E6OLtMGsT52dHatLD+IWmTRJ0Mq+y+q79GK8DcCGFQ7FhnaAz SjrQ== X-Gm-Message-State: AGi0PuZyZfWRTOe72W28qJJf75rWhC5WyTMPCnfFD1SAsVkSlOpeOSdF DOOTkJJ6BULqA+PSW4XhRH6B+tgP+AI= X-Google-Smtp-Source: APiQypLMz6OhjtqiITix26SHaGKIE/PNn8sq0YjVxchoC3Vnmc57okLBEnC2m/RXu2OROr26JHycvw== X-Received: by 2002:a2e:9ccd:: with SMTP id g13mr6174687ljj.147.1586381648068; Wed, 08 Apr 2020 14:34:08 -0700 (PDT) Received: from localhost.localdomain (212-5-158-138.ip.btc-net.bg. [212.5.158.138]) by smtp.gmail.com with ESMTPSA id t6sm15746688lfb.55.2020.04.08.14.34.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 14:34:07 -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 , Stanimir Varbanov Subject: [PATCH 5/7] venus: vdec: Mark flushed buffers with error state Date: Thu, 9 Apr 2020 00:33:28 +0300 Message-Id: <20200408213330.27665-6-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200408213330.27665-1-stanimir.varbanov@linaro.org> References: <20200408213330.27665-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Once the hfi_session_flush is issued by the vdec all queued buffers to firmware should be returned to the v4l driver. Some of those buffers are not processed at the time of flush command, those buffers has filled len zero (no data). Catch that in buffer_done callback and mark not filled capture buffers with error state so that client can discard them. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/vdec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 7d093accbd59..5823537b3131 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1241,6 +1241,9 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type, if (inst->codec_state == VENUS_DEC_STATE_DRAIN) inst->codec_state = VENUS_DEC_STATE_STOPPED; } + + if (!bytesused) + state = VB2_BUF_STATE_ERROR; } else { vbuf->sequence = inst->sequence_out++; } From patchwork Wed Apr 8 21:33:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11480961 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 199F5112C for ; Wed, 8 Apr 2020 21:34:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EC6A42083E for ; Wed, 8 Apr 2020 21:34:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LnInvZrd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730807AbgDHVeR (ORCPT ); Wed, 8 Apr 2020 17:34:17 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:37238 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730784AbgDHVeN (ORCPT ); Wed, 8 Apr 2020 17:34:13 -0400 Received: by mail-lf1-f68.google.com with SMTP id t11so6327691lfe.4 for ; Wed, 08 Apr 2020 14:34:12 -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; bh=i8clFFvhHtURStOSkT8VPHksSoNdpLFd6h/Iv5cyGI4=; b=LnInvZrdIwupNbyGWWNiLyou/EL25bZac5eBr3jTVOIfPEW+fE4DypVYwGBMQR/ohi fz3GmUoCkoIQWq86bcc0NR4/uLND/ulWi1n90PaOt1C4xNZ0rydmjkToAOnIl6dyh2Qz ORP6KVN7HP9MipYbv15xeQf0Khg3Ts99bfLeksOG7tT4GRHGSgpVVlgZnS0zq68BPcJF 8GECRu1EQDr7ptBiqZBFqJ0J1LgAyLNLoUaiKTExZB6I4iaOzUQCHMKtWKntxWKWxEdn ga0+B9sf+h5bikFzqacmy/T/YhwbvTU7Z1FEup/UHx2sqyVAAR1NnkFA7lliMFZ8GnPf bp+w== 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; bh=i8clFFvhHtURStOSkT8VPHksSoNdpLFd6h/Iv5cyGI4=; b=DhaBJNy8GjFhgDE5BHFqNkU96DjwBRMb79/o2eweYB9Kp3NkZQfeBj5XCX1AKLAug8 bwELxgOhKnUHBY5tNY5D4MKJ4qdxyc/rcYDEmIZJkq7uB8Mr/gIQKL9NOYeeRT5QekA3 /exS0RC4PE8osmImGCVlX55SND6CWZ2TCsLwUMnt5RinIJVHAbyMI5o7LLRcDlW9VAHn V6bcGwCnmjAnIuNUmLysxIsYHfCkTtEE/Q75duYQZyZZBcHfc2CCr989T6JD/+Dm+DwZ Ccj+QnvwYRrxmt6M3XwFWfKs6frqp6CwlBc0qBVLhjsuvJUamoP+ZXd2ds4Jt6sV6lmX iuHw== X-Gm-Message-State: AGi0PuY+371l+EYOeIHtkiYMQfTh+J8De2NwXJmJESBxXdTk9uJeZ5Dn LNysYR4pVhLCcNipSP6RYUkRdoKO6mI= X-Google-Smtp-Source: APiQypIafYSBQ7sBXl2z33XJ4IVDpuvO6hb/lUDU0fCXq73HvkPJCCXY3/XQQspt3/SUnsH3GZurEQ== X-Received: by 2002:ac2:4da7:: with SMTP id h7mr5216375lfe.95.1586381651346; Wed, 08 Apr 2020 14:34:11 -0700 (PDT) Received: from localhost.localdomain (212-5-158-138.ip.btc-net.bg. [212.5.158.138]) by smtp.gmail.com with ESMTPSA id t6sm15746688lfb.55.2020.04.08.14.34.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 14:34:10 -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 , Stanimir Varbanov Subject: [PATCH 6/7] venus: vdec: Init registered list unconditionally Date: Thu, 9 Apr 2020 00:33:29 +0300 Message-Id: <20200408213330.27665-7-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200408213330.27665-1-stanimir.varbanov@linaro.org> References: <20200408213330.27665-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Presently the list initialization is done only in dynamic-resolution-change state, which leads to list corruptions and use-after-free. Init list_head unconditionally in vdec_stop_capture called by vb2 stop_streaming without takeing into account current codec state. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/vdec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 5823537b3131..f23cbd812ef4 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1072,13 +1072,14 @@ static int vdec_stop_capture(struct venus_inst *inst) case VENUS_DEC_STATE_DRC: ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT); inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP; - INIT_LIST_HEAD(&inst->registeredbufs); venus_helper_free_dpb_bufs(inst); break; default: - return 0; + break; } + INIT_LIST_HEAD(&inst->registeredbufs); + return ret; } From patchwork Wed Apr 8 21:33:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11480965 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9012414B4 for ; Wed, 8 Apr 2020 21:34:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 642532083E for ; Wed, 8 Apr 2020 21:34:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jPAP4ppt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730553AbgDHVeY (ORCPT ); Wed, 8 Apr 2020 17:34:24 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:44832 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730798AbgDHVeR (ORCPT ); Wed, 8 Apr 2020 17:34:17 -0400 Received: by mail-lf1-f66.google.com with SMTP id 131so6282877lfh.11 for ; Wed, 08 Apr 2020 14:34:15 -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; bh=AXEwq2LfKZq9jZegx8V3cfaW46VWP+fA7RcQ4zX+6AI=; b=jPAP4pptlrc6Q8aApSXno0wjC5irSo2RhU/NlN8d93U02X4zOIZYKkmlqTIvOS1QS3 1bzshkxkMLXILtyf5A4SpmirLLL/IAYw50MT8vo88yVZVP8s3wMOdRqR6Cq85I/MRgPO ZiOX9GjI2c3WP25YxIgl5Z5xPJKjICKijoiO85WKO8mxv59Fe47KtWMww8OwfUXy5vD8 yCw7Oa5pz3yMprnXQr2B4U++0wGYM06NFK5uRdLavEgdOLL5+ufiMbtv8/U5T0KpgMLv eYpdT7Pi+n8538PeSs2WAPcBXVpAiYKvp14CRJYbn7QxD7g0Iy45ZsHGDuq5pOKNE4cQ Vb6w== 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; bh=AXEwq2LfKZq9jZegx8V3cfaW46VWP+fA7RcQ4zX+6AI=; b=boSaeboWQFXhwSMlmPNgZUEJIGxjD/mYKvIN6hBlcrsPSbq7DvVuV1f9ucXRZCaLAh bGr73KkJms9Twf1U3YdsV+aUghMrSwkRW/l96QNjeBgy1BWhMSOZFFyQe+gI/t4sTK20 9IuaM91n/7jMRuAMEAb1e8PUDPytY6UrpLafNh3MJX7jCACbYs+pLx1o6F/tuDzSSCGq u6Io2voSu1WlWhdxurrzywhbFp/X3q3Utx8X2seE+sEBnJ7PCsPcGDDaF6I+qw+Fwt3t HmWB1a8nZSEAizKNMAtPDObZ/nyaMpyoOY22wxopTq2tprd6nwMaElkK6UirIUfA2ReB uDCQ== X-Gm-Message-State: AGi0PubItjSZlnzaNgQLiXWLG6FygZEati3MnULoxi/zn0qK/UfCzF5R Z1gnZ4oOA+06JpbYracaYz4yRoP2uAQ= X-Google-Smtp-Source: APiQypLFJs1t1iNw8j6sA8tRaEtZ7232JHvqALlP5aaWya5C1Se9P8Y3p+5jI4WkgT3K8YXTUzruAw== X-Received: by 2002:a19:7615:: with SMTP id c21mr5612680lff.24.1586381654421; Wed, 08 Apr 2020 14:34:14 -0700 (PDT) Received: from localhost.localdomain (212-5-158-138.ip.btc-net.bg. [212.5.158.138]) by smtp.gmail.com with ESMTPSA id t6sm15746688lfb.55.2020.04.08.14.34.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 14:34:13 -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 , Stanimir Varbanov Subject: [PATCH 7/7] venus: Mark last capture buffer Date: Thu, 9 Apr 2020 00:33:30 +0300 Message-Id: <20200408213330.27665-8-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200408213330.27665-1-stanimir.varbanov@linaro.org> References: <20200408213330.27665-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org According to stateful Codec API the decoder will process all remaining buffers from before the source change event in dynamic-resolution-change state and mark the last buffer with V4L2_BUF_FLAG_LAST. In Venus case the firmware doesn't mark that last buffer and some mechanism have to be created in v4l decoder driver. Fortunately the firmware interface (HFI) claims that the decoder output buffers will be returned to v4l decoder driver before it send the insufficient event. In order to do that we save last queued in the driver capture buffer in the event_notify and issue flush on output firmware buffers queue. Once the saved buffer is returned (as a result of flush command) we mark it as LAST. For all that possible we extend HFI flush command with one more argument and one more flush_done HFI driver callback. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 5 ++- drivers/media/platform/qcom/venus/hfi.c | 10 +++-- drivers/media/platform/qcom/venus/hfi.h | 3 +- drivers/media/platform/qcom/venus/hfi_msgs.c | 2 + drivers/media/platform/qcom/venus/vdec.c | 45 +++++++++++++++++--- 5 files changed, 54 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 3ab644a39786..7118612673c9 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -261,7 +261,8 @@ enum venus_dec_state { VENUS_DEC_STATE_SEEK = 4, VENUS_DEC_STATE_DRAIN = 5, VENUS_DEC_STATE_DECODING = 6, - VENUS_DEC_STATE_DRC = 7 + VENUS_DEC_STATE_DRC = 7, + VENUS_DEC_STATE_DRC_FLUSH_DONE = 8, }; struct venus_ts_metadata { @@ -326,6 +327,7 @@ struct venus_ts_metadata { * @priv: a private for HFI operations callbacks * @session_type: the type of the session (decoder or encoder) * @hprop: a union used as a holder by get property + * @last_buf: last capture buffer for dynamic-resoluton-change */ struct venus_inst { struct list_head list; @@ -387,6 +389,7 @@ struct venus_inst { union hfi_get_property hprop; unsigned int core_acquired: 1; unsigned int bit_depth; + struct vb2_buffer *last_buf; }; #define IS_V1(core) ((core)->res->hfi_version == HFI_VERSION_1XX) diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index 3d8b1284d1f3..a211eb93e0f9 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -382,7 +382,7 @@ int hfi_session_unload_res(struct venus_inst *inst) } EXPORT_SYMBOL_GPL(hfi_session_unload_res); -int hfi_session_flush(struct venus_inst *inst, u32 type) +int hfi_session_flush(struct venus_inst *inst, u32 type, bool block) { const struct hfi_ops *ops = inst->core->ops; int ret; @@ -393,9 +393,11 @@ int hfi_session_flush(struct venus_inst *inst, u32 type) if (ret) return ret; - ret = wait_session_msg(inst); - if (ret) - return ret; + if (block) { + ret = wait_session_msg(inst); + if (ret) + return ret; + } return 0; } diff --git a/drivers/media/platform/qcom/venus/hfi.h b/drivers/media/platform/qcom/venus/hfi.h index 855822c9f39b..62c315291484 100644 --- a/drivers/media/platform/qcom/venus/hfi.h +++ b/drivers/media/platform/qcom/venus/hfi.h @@ -102,6 +102,7 @@ struct hfi_inst_ops { u32 hfi_flags, u64 timestamp_us); void (*event_notify)(struct venus_inst *inst, u32 event, struct hfi_event_data *data); + void (*flush_done)(struct venus_inst *inst); }; struct hfi_ops { @@ -161,7 +162,7 @@ int hfi_session_continue(struct venus_inst *inst); int hfi_session_abort(struct venus_inst *inst); int hfi_session_load_res(struct venus_inst *inst); int hfi_session_unload_res(struct venus_inst *inst); -int hfi_session_flush(struct venus_inst *inst, u32 type); +int hfi_session_flush(struct venus_inst *inst, u32 type, bool block); int hfi_session_set_buffers(struct venus_inst *inst, struct hfi_buffer_desc *bd); int hfi_session_unset_buffers(struct venus_inst *inst, diff --git a/drivers/media/platform/qcom/venus/hfi_msgs.c b/drivers/media/platform/qcom/venus/hfi_msgs.c index 04ef2286efc6..279a9d6fe737 100644 --- a/drivers/media/platform/qcom/venus/hfi_msgs.c +++ b/drivers/media/platform/qcom/venus/hfi_msgs.c @@ -439,6 +439,8 @@ static void hfi_session_flush_done(struct venus_core *core, inst->error = pkt->error_type; complete(&inst->done); + if (inst->ops->flush_done) + inst->ops->flush_done(inst); } static void hfi_session_etb_done(struct venus_core *core, diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index f23cbd812ef4..527944c822b5 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -906,7 +906,7 @@ static int vdec_start_capture(struct venus_inst *inst) return 0; reconfigure: - ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT); + ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT, true); if (ret) return ret; @@ -1063,14 +1063,16 @@ static int vdec_stop_capture(struct venus_inst *inst) switch (inst->codec_state) { case VENUS_DEC_STATE_DECODING: - ret = hfi_session_flush(inst, HFI_FLUSH_ALL); + ret = hfi_session_flush(inst, HFI_FLUSH_ALL, true); /* fallthrough */ case VENUS_DEC_STATE_DRAIN: vdec_cancel_dst_buffers(inst); inst->codec_state = VENUS_DEC_STATE_STOPPED; break; case VENUS_DEC_STATE_DRC: - ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT); + WARN_ON(1); + fallthrough; + case VENUS_DEC_STATE_DRC_FLUSH_DONE: inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP; venus_helper_free_dpb_bufs(inst); break; @@ -1091,12 +1093,12 @@ static int vdec_stop_output(struct venus_inst *inst) case VENUS_DEC_STATE_DECODING: case VENUS_DEC_STATE_DRAIN: case VENUS_DEC_STATE_STOPPED: - ret = hfi_session_flush(inst, HFI_FLUSH_ALL); + ret = hfi_session_flush(inst, HFI_FLUSH_ALL, true); inst->codec_state = VENUS_DEC_STATE_SEEK; break; case VENUS_DEC_STATE_INIT: case VENUS_DEC_STATE_CAPTURE_SETUP: - ret = hfi_session_flush(inst, HFI_FLUSH_INPUT); + ret = hfi_session_flush(inst, HFI_FLUSH_INPUT, true); break; default: break; @@ -1234,6 +1236,13 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type, vb->timestamp = timestamp_us * NSEC_PER_USEC; vbuf->sequence = inst->sequence_cap++; + if (inst->last_buf == vb) { + inst->last_buf = NULL; + vbuf->flags |= V4L2_BUF_FLAG_LAST; + vb2_set_plane_payload(vb, 0, 0); + vb->timestamp = 0; + } + if (vbuf->flags & V4L2_BUF_FLAG_LAST) { const struct v4l2_event ev = { .type = V4L2_EVENT_EOS }; @@ -1311,6 +1320,25 @@ static void vdec_event_change(struct venus_inst *inst, } } + /* + * The assumption is that the firmware have to return the last buffer + * before this event is received in the v4l2 driver. Also the firmware + * itself doesn't mark the last decoder output buffer with HFI EOS flag. + */ + + if (!sufficient && inst->codec_state == VENUS_DEC_STATE_DRC) { + struct vb2_v4l2_buffer *last; + int ret; + + last = v4l2_m2m_last_dst_buf(inst->m2m_ctx); + if (last) + inst->last_buf = &last->vb2_buf; + + ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT, false); + if (ret) + dev_dbg(dev, "flush output error %d\n", ret); + } + inst->reconfig = true; v4l2_event_queue_fh(&inst->fh, &ev); wake_up(&inst->reconf_wait); @@ -1351,9 +1379,16 @@ static void vdec_event_notify(struct venus_inst *inst, u32 event, } } +static void vdec_flush_done(struct venus_inst *inst) +{ + if (inst->codec_state == VENUS_DEC_STATE_DRC) + inst->codec_state = VENUS_DEC_STATE_DRC_FLUSH_DONE; +} + static const struct hfi_inst_ops vdec_hfi_ops = { .buf_done = vdec_buf_done, .event_notify = vdec_event_notify, + .flush_done = vdec_flush_done, }; static void vdec_inst_init(struct venus_inst *inst)