From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Moudy Ho <moudy.ho@mediatek.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org,
linux-kernel@vger.kernel.org,
Project_Global_Chrome_Upstream_Group@mediatek.com
Subject: Re: [PATCH v1 2/2] media: platform: mtk-mdp3: fix error handling about components clock_on
Date: Fri, 30 Sep 2022 14:12:51 +0200 [thread overview]
Message-ID: <8afa9c8e-079e-6e50-a8d7-21e0b1698f76@collabora.com> (raw)
In-Reply-To: <20220930102306.13201-3-moudy.ho@mediatek.com>
Il 30/09/22 12:23, Moudy Ho ha scritto:
> Add goto statement in mdp_comp_clock_on() to avoid error code not being
> propagated or returning positive values.
> This change also performs a well-timed clock_off when an error occurs, and
> reduces unnecessary error logging in mdp_cmdq_send().
>
> Fixes: 61890ccaefaf ("media: platform: mtk-mdp3: add MediaTek MDP3 driver")
> Signed-off-by: Moudy Ho <moudy.ho@mediatek.com>
> ---
> .../platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 4 +---
> .../platform/mediatek/mdp3/mtk-mdp3-comp.c | 24 ++++++++++++++-----
> 2 files changed, 19 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
> index e194dec8050a..124c1b96e96b 100644
> --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
> +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
> @@ -433,10 +433,8 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param)
> cmd->mdp_ctx = param->mdp_ctx;
>
> ret = mdp_comp_clocks_on(&mdp->pdev->dev, cmd->comps, cmd->num_comps);
> - if (ret) {
> - dev_err(dev, "comp %d failed to enable clock!\n", ret);
> + if (ret)
> goto err_free_path;
> - }
>
> dma_sync_single_for_device(mdp->cmdq_clt->chan->mbox->dev,
> cmd->pkt.pa_base, cmd->pkt.cmd_buf_size,
> diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
> index d3eaf8884412..fe6a39315e88 100644
> --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
> +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
> @@ -699,12 +699,22 @@ int mdp_comp_clock_on(struct device *dev, struct mdp_comp *comp)
> dev_err(dev,
> "Failed to enable clk %d. type:%d id:%d\n",
> i, comp->type, comp->id);
> - pm_runtime_put(comp->comp_dev);
> - return ret;
> + goto err_unwind;
> }
> }
>
> return 0;
> +
> +err_unwind:
For this label to be clearer, I would rename it as `err_revert`, or
`clocks_off`, or even simply `err`, as the `unwind` word may create
some confusion here.
> + while (--i >= 0) {
> + if (IS_ERR_OR_NULL(comp->clks[i]))
> + continue;
> + clk_disable_unprepare(comp->clks[i]);
> + }
> + if (comp->comp_dev)
> + pm_runtime_put_sync(comp->comp_dev);
> +
> + return ret;
> }
>
> void mdp_comp_clock_off(struct device *dev, struct mdp_comp *comp)
> @@ -723,11 +733,13 @@ void mdp_comp_clock_off(struct device *dev, struct mdp_comp *comp)
>
> int mdp_comp_clocks_on(struct device *dev, struct mdp_comp *comps, int num)
> {
> - int i;
> + int i, ret;
>
> - for (i = 0; i < num; i++)
> - if (mdp_comp_clock_on(dev, &comps[i]) != 0)
> - return ++i;
> + for (i = 0; i < num; i++) {
> + ret = mdp_comp_clock_on(dev, &comps[i]);
> + if (ret)
> + return ret;
> + }
>
> return 0;
> }
>
next prev parent reply other threads:[~2022-09-30 12:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-30 10:23 [PATCH v1 0/2] Fix error handling for MDP3 Moudy Ho
2022-09-30 10:23 ` [PATCH v1 1/2] media: platform: mtk-mdp3: fix error handling in mdp_cmdq_send() Moudy Ho
2022-09-30 12:14 ` AngeloGioacchino Del Regno
2022-09-30 10:23 ` [PATCH v1 2/2] media: platform: mtk-mdp3: fix error handling about components clock_on Moudy Ho
2022-09-30 12:12 ` AngeloGioacchino Del Regno [this message]
2022-10-03 2:48 ` moudy ho
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8afa9c8e-079e-6e50-a8d7-21e0b1698f76@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=moudy.ho@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox