[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8afa9c8e-079e-6e50-a8d7-21e0b1698f76@collabora.com>
Date: Fri, 30 Sep 2022 14:12:51 +0200
From: AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>
To: Moudy Ho <moudy.ho@...iatek.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Matthias Brugger <matthias.bgg@...il.com>,
Hans Verkuil <hverkuil-cisco@...all.nl>
Cc: linux-media@...r.kernel.org, linux-mediatek@...ts.infradead.org,
linux-kernel@...r.kernel.org,
Project_Global_Chrome_Upstream_Group@...iatek.com
Subject: Re: [PATCH v1 2/2] media: platform: mtk-mdp3: fix error handling
about components clock_on
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@...iatek.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;
> }
>
Powered by blists - more mailing lists