From patchwork Wed Jun 23 07:35:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moudy Ho X-Patchwork-Id: 466025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7B19C4743C for ; Wed, 23 Jun 2021 07:36:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B4204611AC for ; Wed, 23 Jun 2021 07:36:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230053AbhFWHiQ (ORCPT ); Wed, 23 Jun 2021 03:38:16 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:60972 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229978AbhFWHiQ (ORCPT ); Wed, 23 Jun 2021 03:38:16 -0400 X-UUID: 78d6776bd0214c32b4edbaf1791e1ea0-20210623 X-UUID: 78d6776bd0214c32b4edbaf1791e1ea0-20210623 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1932890681; Wed, 23 Jun 2021 15:35:55 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 23 Jun 2021 15:35:53 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 23 Jun 2021 15:35:53 +0800 From: Moudy Ho To: Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Hans Verkuil , Jernej Skrabec CC: Maoguang Meng , Krzysztof Kozlowski , daoyuan huang , Ping-Hsun Wu , Geert Uytterhoeven , Rob Landley , Laurent Pinchart , , , , , , , , , , , , , , , , Subject: [RFC PATCH V0 02/10] media: mtk-mdp3: fix redundant process done caused KE Date: Wed, 23 Jun 2021 15:35:41 +0800 Message-ID: <20210623073549.24170-2-moudy.ho@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210623073549.24170-1-moudy.ho@mediatek.com> References: <20210623073549.24170-1-moudy.ho@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: daoyuan huang In mdp_m2m_worker, there is m2m process done in error handle, so add statement in mdp_cmdq_send for preventing redundant process done in cmdq_pkt_flush return fail case. Signed-off-by: daoyuan huang --- drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c b/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c index ee81a3387cf9..f8bf8fde599c 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c @@ -454,8 +454,10 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) mdp_dump_info(~0, 1); } #endif - if (param->mdp_ctx) - mdp_m2m_job_finish(param->mdp_ctx); + if (!ret) { /* error handle in mdp_m2m_worker */ + if (param->mdp_ctx) + mdp_m2m_job_finish(param->mdp_ctx); + } cmdq_pkt_destroy(cmd.pkt); for (i = 0; i < param->config->num_components; i++) mdp_comp_clock_off(&mdp->pdev->dev, path.comps[i].comp); From patchwork Wed Jun 23 07:35:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moudy Ho X-Patchwork-Id: 466021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E21A0C48BC2 for ; Wed, 23 Jun 2021 07:36:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB9696128C for ; Wed, 23 Jun 2021 07:36:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230339AbhFWHib (ORCPT ); Wed, 23 Jun 2021 03:38:31 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:32792 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230222AbhFWHiW (ORCPT ); Wed, 23 Jun 2021 03:38:22 -0400 X-UUID: 4783db3ba090400eb04bc6ddc0d93cf7-20210623 X-UUID: 4783db3ba090400eb04bc6ddc0d93cf7-20210623 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 314512722; Wed, 23 Jun 2021 15:35:58 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 23 Jun 2021 15:35:56 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 23 Jun 2021 15:35:56 +0800 From: Moudy Ho To: Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Hans Verkuil , Jernej Skrabec CC: Maoguang Meng , Krzysztof Kozlowski , daoyuan huang , Ping-Hsun Wu , Geert Uytterhoeven , Rob Landley , Laurent Pinchart , , , , , , , , , , , , , , , , Subject: [RFC PATCH V0 04/10] media: mtk-mdp3: add error handling in error return Date: Wed, 23 Jun 2021 15:35:43 +0800 Message-ID: <20210623073549.24170-4-moudy.ho@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210623073549.24170-1-moudy.ho@mediatek.com> References: <20210623073549.24170-1-moudy.ho@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: daoyuan huang add error handling in missed places. Signed-off-by: daoyuan huang --- drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c | 14 +++++++++++++- drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c | 16 ++++++++++++++++ drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h | 2 ++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c b/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c index f8bf8fde599c..42a51061677a 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c @@ -398,7 +398,17 @@ static void mdp_handle_cmdq_callback(struct cmdq_cb_data data) cmdq_pkt_destroy(cb_param->pkt); INIT_WORK(&cb_param->auto_release_work, mdp_auto_release_work); - queue_work(mdp->clock_wq, &cb_param->auto_release_work); + if (!queue_work(mdp->clock_wq, &cb_param->auto_release_work)) { + mdp_err("%s:queue_work fail!\n", __func__); + mdp_comp_clocks_off(&mdp->pdev->dev, cb_param->comps, + cb_param->num_comps); + + kfree(cb_param->comps); + kfree(cb_param); + + atomic_dec(&mdp->job_count); + wake_up(&mdp->callback_wq); + } } int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) @@ -495,6 +505,8 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) (void *)cb_param); if (ret) { mdp_err("%s:cmdq_pkt_flush_async fail!\n", __func__); + mdp_comp_clocks_off(&mdp->pdev->dev, cb_param->comps, + cb_param->num_comps); kfree(cb_param); kfree(comps); } diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c b/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c index 23dd413f3423..157ef9408ed3 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c @@ -1072,6 +1072,22 @@ void mdp_comp_clock_off(struct device *dev, struct mdp_comp *comp) pm_runtime_put(comp->comp_dev); } +void mdp_comp_clocks_on(struct device *dev, struct mdp_comp *comps, int num) +{ + int i; + + for (i = 0; i < num; i++) + mdp_comp_clock_on(dev, &comps[i]); +} + +void mdp_comp_clocks_off(struct device *dev, struct mdp_comp *comps, int num) +{ + int i; + + for (i = 0; i < num; i++) + mdp_comp_clock_off(dev, &comps[i]); +} + static int mdp_get_subsys_id(struct device *dev, struct device_node *node, struct mdp_comp *comp) { diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h b/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h index 27d58dc51dce..f201bced3c06 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h @@ -147,6 +147,8 @@ int mdp_component_init(struct mdp_dev *mdp); void mdp_component_deinit(struct mdp_dev *mdp); void mdp_comp_clock_on(struct device *dev, struct mdp_comp *comp); void mdp_comp_clock_off(struct device *dev, struct mdp_comp *comp); +void mdp_comp_clocks_on(struct device *dev, struct mdp_comp *comps, int num); +void mdp_comp_clocks_off(struct device *dev, struct mdp_comp *comps, int num); int mdp_comp_ctx_init(struct mdp_dev *mdp, struct mdp_comp_ctx *ctx, const struct img_compparam *param, const struct img_ipi_frameparam *frame); From patchwork Wed Jun 23 07:35:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moudy Ho X-Patchwork-Id: 466022 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 954D8C49EA6 for ; Wed, 23 Jun 2021 07:36:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 70C266128A for ; Wed, 23 Jun 2021 07:36:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230212AbhFWHiT (ORCPT ); Wed, 23 Jun 2021 03:38:19 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:32792 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230163AbhFWHiT (ORCPT ); Wed, 23 Jun 2021 03:38:19 -0400 X-UUID: 0d48c2887b92484d8d70713bed3920d9-20210623 X-UUID: 0d48c2887b92484d8d70713bed3920d9-20210623 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1373349356; Wed, 23 Jun 2021 15:35:58 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 23 Jun 2021 15:35:56 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 23 Jun 2021 15:35:56 +0800 From: Moudy Ho To: Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Hans Verkuil , Jernej Skrabec CC: Maoguang Meng , Krzysztof Kozlowski , daoyuan huang , Ping-Hsun Wu , Geert Uytterhoeven , Rob Landley , Laurent Pinchart , , , , , , , , , , , , , , , , Subject: [RFC PATCH V0 05/10] media: mtk-mdp3: remove unnecessary Null check Date: Wed, 23 Jun 2021 15:35:44 +0800 Message-ID: <20210623073549.24170-5-moudy.ho@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210623073549.24170-1-moudy.ho@mediatek.com> References: <20210623073549.24170-1-moudy.ho@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: daoyuan huang Remove logically unnecessary NULL check in call back function. Due to no NULL callback param should occur in normal case; and if we use NULL check to jump over this clock off step, the clock ref. count may go asymmetric. Signed-off-by: daoyuan huang --- drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c b/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c index 42a51061677a..df956ca3685c 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c @@ -349,13 +349,8 @@ static void mdp_auto_release_work(struct work_struct *work) auto_release_work); mdp = cb_param->mdp; - if (cb_param->comps && cb_param->num_comps) { - int i; - - for (i = 0; i < cb_param->num_comps; i++) - mdp_comp_clock_off(&mdp->pdev->dev, - &cb_param->comps[i]); - } + mdp_comp_clocks_off(&mdp->pdev->dev, cb_param->comps, + cb_param->num_comps); kfree(cb_param->comps); kfree(cb_param); From patchwork Wed Jun 23 07:35:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moudy Ho X-Patchwork-Id: 466024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5D48C49EA7 for ; Wed, 23 Jun 2021 07:36:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE0786128A for ; Wed, 23 Jun 2021 07:36:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230249AbhFWHiW (ORCPT ); Wed, 23 Jun 2021 03:38:22 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:32810 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230161AbhFWHiU (ORCPT ); Wed, 23 Jun 2021 03:38:20 -0400 X-UUID: 5cbdb2f31c824079b2ddb69ff0dc0608-20210623 X-UUID: 5cbdb2f31c824079b2ddb69ff0dc0608-20210623 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 500013350; Wed, 23 Jun 2021 15:35:58 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 23 Jun 2021 15:35:57 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 23 Jun 2021 15:35:57 +0800 From: Moudy Ho To: Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Hans Verkuil , Jernej Skrabec CC: Maoguang Meng , Krzysztof Kozlowski , daoyuan huang , Ping-Hsun Wu , Geert Uytterhoeven , Rob Landley , Laurent Pinchart , , , , , , , , , , , , , , , , Subject: [RFC PATCH V0 07/10] media: mtk-mdp3: Fix unpaired settings Date: Wed, 23 Jun 2021 15:35:46 +0800 Message-ID: <20210623073549.24170-7-moudy.ho@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210623073549.24170-1-moudy.ho@mediatek.com> References: <20210623073549.24170-1-moudy.ho@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Fix unpaired settings about: 1. clk on/off. 2. CMDQ packet kzalloc/kfree. 3. MDP job_count increase/decrease. Also revise the redundant log. Signed-off-by: Moudy Ho --- .../media/platform/mtk-mdp3/mtk-mdp3-cmdq.c | 97 ++++++++++++------- .../media/platform/mtk-mdp3/mtk-mdp3-core.h | 4 +- .../media/platform/mtk-mdp3/mtk-mdp3-m2m.c | 2 +- 3 files changed, 67 insertions(+), 36 deletions(-) diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c b/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c index a1bdf92d45f7..eac10944283a 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c @@ -5,6 +5,7 @@ */ #include +#include #include "mtk-mdp3-cmdq.h" #include "mtk-mdp3-comp.h" #include "mtk-mdp3-core.h" @@ -230,6 +231,25 @@ static int mdp_path_subfrm_run(const struct mdp_path_subfrm *subfrm, return 0; } +static int mdp_path_ctx_init(struct mdp_dev *mdp, struct mdp_path *path) +{ + const struct img_config *config = path->config; + int index, ret; + + if (config->num_components < 1) + return -EINVAL; + + for (index = 0; index < config->num_components; index++) { + ret = mdp_comp_ctx_init(mdp, &path->comps[index], + &config->components[index], + path->param); + if (ret) + return ret; + } + + return 0; +} + static int mdp_path_config_subfrm(struct mdp_cmd *cmd, struct mdp_path *path, u32 count) { @@ -297,14 +317,6 @@ static int mdp_path_config(struct mdp_dev *mdp, struct mdp_cmd *cmd, struct mdp_comp_ctx *ctx; int index, count, ret; - for (index = 0; index < config->num_components; index++) { - ret = mdp_comp_ctx_init(mdp, &path->comps[index], - &config->components[index], - path->param); - if (ret) - return ret; - } - /* Config path frame */ /* Reset components */ for (index = 0; index < config->num_components; index++) { @@ -410,6 +422,8 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) { struct mdp_cmd cmd; struct mdp_path path; + struct mdp_cmdq_cb_param *cb_param = NULL; + struct mdp_comp *comps = NULL; int i, ret; if (atomic_read(&mdp->suspended)) @@ -438,16 +452,23 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) path.composes[i] = param->composes[i] ? param->composes[i] : &path.bounds[i]; } + + ret = mdp_path_ctx_init(mdp, &path); + if (ret) { + pr_info("%s mdp_path_ctx_init error\n", __func__); + goto err_destory_pkt; + } + + for (i = 0; i < param->config->num_components; i++) + mdp_comp_clock_on(&mdp->pdev->dev, path.comps[i].comp); + ret = mdp_path_config(mdp, &cmd, &path); if (ret) { - atomic_dec(&mdp->job_count); - wake_up(&mdp->callback_wq); - return ret; + pr_info("%s mdp_path_config error\n", __func__); + goto err_destory_pkt; } if (param->wait) { - for (i = 0; i < param->config->num_components; i++) - mdp_comp_clock_on(&mdp->pdev->dev, path.comps[i].comp); ret = cmdq_pkt_flush(cmd.pkt); #ifdef MDP_DEBUG if (ret) { @@ -461,25 +482,20 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) if (param->mdp_ctx) mdp_m2m_job_finish(param->mdp_ctx); } - cmdq_pkt_destroy(cmd.pkt); - for (i = 0; i < param->config->num_components; i++) - mdp_comp_clock_off(&mdp->pdev->dev, path.comps[i].comp); - - atomic_dec(&mdp->job_count); - wake_up(&mdp->callback_wq); + goto err_clock_off; } else { - struct mdp_cmdq_cb_param *cb_param; - struct mdp_comp *comps; - cb_param = kzalloc(sizeof(*cb_param), GFP_KERNEL); - if (!cb_param) - return -ENOMEM; + if (!cb_param) { + ret = -ENOMEM; + goto err_destory_pkt; + } + comps = kcalloc(param->config->num_components, sizeof(*comps), GFP_KERNEL); if (!comps) { - kfree(cb_param); mdp_err("%s:comps alloc fail!\n", __func__); - return -ENOMEM; + ret = -ENOMEM; + goto err_destory_pkt; } for (i = 0; i < param->config->num_components; i++) @@ -493,20 +509,35 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) cb_param->num_comps = param->config->num_components; cb_param->mdp_ctx = param->mdp_ctx; - mdp_comp_clocks_on(&mdp->pdev->dev, cb_param->comps, - cb_param->num_comps); - + cmdq_pkt_finalize(cmd.pkt); ret = cmdq_pkt_flush_async(cmd.pkt, mdp_handle_cmdq_callback, (void *)cb_param); if (ret) { mdp_err("%s:cmdq_pkt_flush_async fail!\n", __func__); - mdp_comp_clocks_off(&mdp->pdev->dev, cb_param->comps, - cb_param->num_comps); - kfree(cb_param); - kfree(comps); + goto err_clock_off; } } + return 0; + +err_clock_off: + if (param->wait) { + for (i = 0; i < param->config->num_components; i++) + mdp_comp_clock_off(&mdp->pdev->dev, path.comps[i].comp); + } else { + mdp_comp_clocks_off(&mdp->pdev->dev, cb_param->comps, + cb_param->num_comps); + } +err_destory_pkt: + cmdq_pkt_destroy(cmd.pkt); + atomic_dec(&mdp->job_count); + if (param->wait) + wake_up(&mdp->callback_wq); + if (comps) + kfree(comps); + if (cb_param) + kfree(cb_param); + return ret; } diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h b/drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h index 98cf54b1d92b..19f46da487aa 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h @@ -64,12 +64,12 @@ extern int mtk_mdp_debug; #define mdp_dbg(level, fmt, ...)\ do {\ if (mtk_mdp_debug >= (level))\ - pr_info("[MTK-MDP3] %d %s:%d: " fmt "\n",\ + pr_info("[MTK-MDP3] %d %s:%d: " fmt,\ level, __func__, __LINE__, ##__VA_ARGS__);\ } while (0) #define mdp_err(fmt, ...)\ - pr_err("[MTK-MDP3][ERR] %s:%d: " fmt "\n", __func__, __LINE__,\ + pr_err("[MTK-MDP3][ERR] %s:%d: " fmt, __func__, __LINE__,\ ##__VA_ARGS__) #else diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.c b/drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.c index 1ae499f6c84b..ff80f01be82f 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.c +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.c @@ -133,7 +133,7 @@ static void mdp_m2m_worker(struct work_struct *work) task.config = ctx->vpu.config; task.param = ¶m; task.composes[0] = &frame->compose; - task.wait = 1; + task.wait = 0; task.cmdq_cb = NULL; task.cb_data = NULL; task.mdp_ctx = ctx; From patchwork Wed Jun 23 07:35:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moudy Ho X-Patchwork-Id: 466023 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94854C49EBC for ; Wed, 23 Jun 2021 07:36:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BCB96128C for ; Wed, 23 Jun 2021 07:36:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230300AbhFWHia (ORCPT ); Wed, 23 Jun 2021 03:38:30 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:47029 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230185AbhFWHiV (ORCPT ); Wed, 23 Jun 2021 03:38:21 -0400 X-UUID: 35c07978e10a4887b812a0db3c03beee-20210623 X-UUID: 35c07978e10a4887b812a0db3c03beee-20210623 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 658592435; Wed, 23 Jun 2021 15:35:59 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 23 Jun 2021 15:35:57 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 23 Jun 2021 15:35:57 +0800 From: Moudy Ho To: Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Hans Verkuil , Jernej Skrabec CC: Maoguang Meng , Krzysztof Kozlowski , daoyuan huang , Ping-Hsun Wu , Geert Uytterhoeven , Rob Landley , Laurent Pinchart , , , , , , , , , , , , , , , , Subject: [RFC PATCH V0 10/10] media: mtk-mdp3: Adjust related settings for 5.13-rc1 Date: Wed, 23 Jun 2021 15:35:49 +0800 Message-ID: <20210623073549.24170-10-moudy.ho@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210623073549.24170-1-moudy.ho@mediatek.com> References: <20210623073549.24170-1-moudy.ho@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: mtk18742 1. remove cmdq_pkt_flush usage. 2. remove VFL_TYPE_GRABBER enum. 3. remove undefined format 4. Adjust CMDQ API param. Signed-off-by: Moudy Ho --- .../media/platform/mtk-mdp3/mmsys_reg_base.h | 2 +- .../media/platform/mtk-mdp3/mtk-mdp3-cmdq.c | 92 +++++++------------ .../media/platform/mtk-mdp3/mtk-mdp3-cmdq.h | 3 +- .../media/platform/mtk-mdp3/mtk-mdp3-core.c | 2 +- .../media/platform/mtk-mdp3/mtk-mdp3-m2m.c | 3 +- .../media/platform/mtk-mdp3/mtk-mdp3-regs.c | 2 +- 6 files changed, 39 insertions(+), 65 deletions(-) diff --git a/drivers/media/platform/mtk-mdp3/mmsys_reg_base.h b/drivers/media/platform/mtk-mdp3/mmsys_reg_base.h index d79b82eea61b..738ecd525474 100644 --- a/drivers/media/platform/mtk-mdp3/mmsys_reg_base.h +++ b/drivers/media/platform/mtk-mdp3/mmsys_reg_base.h @@ -16,7 +16,7 @@ (0xffffffff) : (mask), ##__VA_ARGS__) #define MM_REG_WAIT(cmd, evt) \ - cmdq_pkt_wfe(cmd->pkt, cmd->event[(evt)]) + cmdq_pkt_wfe(cmd->pkt, cmd->event[(evt)], true) #define MM_REG_WAIT_NO_CLEAR(cmd, evt) \ cmdq_pkt_wait_no_clear(cmd->pkt, cmd->event[(evt)]) diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c b/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c index eac10944283a..151485933eae 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c @@ -468,71 +468,48 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) goto err_destory_pkt; } - if (param->wait) { - ret = cmdq_pkt_flush(cmd.pkt); -#ifdef MDP_DEBUG - if (ret) { - struct mdp_func_struct *p_func = mdp_get_func(); - - p_func->mdp_dump_mmsys_config(); - mdp_dump_info(~0, 1); - } -#endif - if (!ret) { /* error handle in mdp_m2m_worker */ - if (param->mdp_ctx) - mdp_m2m_job_finish(param->mdp_ctx); - } - goto err_clock_off; - } else { - cb_param = kzalloc(sizeof(*cb_param), GFP_KERNEL); - if (!cb_param) { - ret = -ENOMEM; - goto err_destory_pkt; - } + cb_param = kzalloc(sizeof(*cb_param), GFP_KERNEL); + if (!cb_param) { + ret = -ENOMEM; + goto err_destory_pkt; + } - comps = kcalloc(param->config->num_components, sizeof(*comps), - GFP_KERNEL); - if (!comps) { - mdp_err("%s:comps alloc fail!\n", __func__); - ret = -ENOMEM; - goto err_destory_pkt; - } + comps = kcalloc(param->config->num_components, sizeof(*comps), + GFP_KERNEL); + if (!comps) { + mdp_err("%s:comps alloc fail!\n", __func__); + ret = -ENOMEM; + goto err_destory_pkt; + } - for (i = 0; i < param->config->num_components; i++) - memcpy(&comps[i], path.comps[i].comp, - sizeof(struct mdp_comp)); - cb_param->mdp = mdp; - cb_param->user_cmdq_cb = param->cmdq_cb; - cb_param->user_cb_data = param->cb_data; - cb_param->pkt = cmd.pkt; - cb_param->comps = comps; - cb_param->num_comps = param->config->num_components; - cb_param->mdp_ctx = param->mdp_ctx; - - cmdq_pkt_finalize(cmd.pkt); - ret = cmdq_pkt_flush_async(cmd.pkt, - mdp_handle_cmdq_callback, - (void *)cb_param); - if (ret) { - mdp_err("%s:cmdq_pkt_flush_async fail!\n", __func__); - goto err_clock_off; - } + for (i = 0; i < param->config->num_components; i++) + memcpy(&comps[i], path.comps[i].comp, + sizeof(struct mdp_comp)); + cb_param->mdp = mdp; + cb_param->user_cmdq_cb = param->cmdq_cb; + cb_param->user_cb_data = param->cb_data; + cb_param->pkt = cmd.pkt; + cb_param->comps = comps; + cb_param->num_comps = param->config->num_components; + cb_param->mdp_ctx = param->mdp_ctx; + + cmdq_pkt_finalize(cmd.pkt); + ret = cmdq_pkt_flush_async(cmd.pkt, + mdp_handle_cmdq_callback, + (void *)cb_param); + if (ret) { + mdp_err("%s:cmdq_pkt_flush_async fail!\n", __func__); + goto err_clock_off; } return 0; err_clock_off: - if (param->wait) { - for (i = 0; i < param->config->num_components; i++) - mdp_comp_clock_off(&mdp->pdev->dev, path.comps[i].comp); - } else { - mdp_comp_clocks_off(&mdp->pdev->dev, cb_param->comps, - cb_param->num_comps); - } + mdp_comp_clocks_off(&mdp->pdev->dev, cb_param->comps, + cb_param->num_comps); err_destory_pkt: cmdq_pkt_destroy(cmd.pkt); atomic_dec(&mdp->job_count); - if (param->wait) - wake_up(&mdp->callback_wq); + wake_up(&mdp->callback_wq); if (comps) kfree(comps); if (cb_param) @@ -543,7 +520,7 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) int mdp_cmdq_sendtask(struct platform_device *pdev, struct img_config *config, struct img_ipi_frameparam *param, - struct v4l2_rect *compose, unsigned int wait, + struct v4l2_rect *compose, void (*cmdq_cb)(struct cmdq_cb_data data), void *cb_data) { struct mdp_dev *mdp = platform_get_drvdata(pdev); @@ -551,7 +528,6 @@ int mdp_cmdq_sendtask(struct platform_device *pdev, struct img_config *config, .config = config, .param = param, .composes[0] = compose, - .wait = wait, .cmdq_cb = cmdq_cb, .cb_data = cb_data, }; diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.h b/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.h index 6b8b0f6b4bb5..f6394d3d0358 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.h +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.h @@ -16,7 +16,7 @@ struct platform_device *mdp_get_plat_device(struct platform_device *pdev); int mdp_cmdq_sendtask(struct platform_device *pdev, struct img_config *config, struct img_ipi_frameparam *param, - struct v4l2_rect *compose, unsigned int wait, + struct v4l2_rect *compose, void (*cmdq_cb)(struct cmdq_cb_data data), void *cb_data); struct mdp_cmd { @@ -28,7 +28,6 @@ struct mdp_cmdq_param { struct img_config *config; struct img_ipi_frameparam *param; const struct v4l2_rect *composes[IMG_MAX_HW_OUTPUTS]; - unsigned int wait; void (*cmdq_cb)(struct cmdq_cb_data data); void *cb_data; diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c b/drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c index 207b55ace97b..a42e436d3a8c 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c @@ -137,7 +137,7 @@ static int mdp_probe(struct platform_device *pdev) mutex_init(&mdp->vpu_lock); mutex_init(&mdp->m2m_lock); - mdp->cmdq_clt = cmdq_mbox_create(dev, 0, 1200); + mdp->cmdq_clt = cmdq_mbox_create(dev, 0); if (IS_ERR(mdp->cmdq_clt)) { ret = PTR_ERR(mdp->cmdq_clt); goto err_put_scp; diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.c b/drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.c index ff80f01be82f..536574f6bc32 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.c +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.c @@ -133,7 +133,6 @@ static void mdp_m2m_worker(struct work_struct *work) task.config = ctx->vpu.config; task.param = ¶m; task.composes[0] = &frame->compose; - task.wait = 0; task.cmdq_cb = NULL; task.cb_data = NULL; task.mdp_ctx = ctx; @@ -769,7 +768,7 @@ int mdp_m2m_device_register(struct mdp_dev *mdp) goto err_m2m_init; } - ret = video_register_device(mdp->m2m_vdev, VFL_TYPE_GRABBER, 2); + ret = video_register_device(mdp->m2m_vdev, VFL_TYPE_VIDEO, 2); if (ret) { dev_err(dev, "Failed to register video device\n"); goto err_video_register; diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.c b/drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.c index 5c48a7e75efd..0c4c942b5f9c 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.c +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.c @@ -168,7 +168,7 @@ static const struct mdp_format mdp_formats[] = { .halign = 5, .flags = MDP_FMT_FLAG_OUTPUT, }, { - .pixelformat = V4L2_PIX_FMT_MM21, + .pixelformat = V4L2_PIX_FMT_NV12MT, .mdp_color = MDP_COLOR_420_BLK, .depth = { 8, 4 }, .row_depth = { 8, 8 },