Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>
Cc: "linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"wenst@chromium.org" <wenst@chromium.org>,
	"kernel@collabora.com" <kernel@collabora.com>,
	"Nancy Lin (林欣螢)" <Nancy.Lin@mediatek.com>,
	"daniel@ffwll.ch" <daniel@ffwll.ch>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"Nathan Lu (呂東霖)" <Nathan.Lu@mediatek.com>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>
Subject: Re: [PATCH 2/3] drm/mediatek: Perform iounmap on simple DDP component destruction
Date: Fri, 22 Mar 2024 08:48:53 +0000	[thread overview]
Message-ID: <4b5d172c9b169313aaec777158e2db697fe447fc.camel@mediatek.com> (raw)
In-Reply-To: <20240201125304.218467-3-angelogioacchino.delregno@collabora.com>

Hi, Angelo:

On Thu, 2024-02-01 at 13:53 +0100, AngeloGioacchino Del Regno wrote:
> Add a new mtk_ddp_comp_destroy() function and call it in the teardown
> path of mtk_drm_drv to make sure that we unmap the iospace of the
> simple DDP components.
> 
> While at it, also fix iounmapping on mtk_ddp_comp_init() error path.

Reviewed-by: CK Hu <ck.hu@mediatek.com>

> 
> Fixes: ff1395609e20 ("drm/mediatek: Move mtk_ddp_comp_init() from sub
> driver to DRM driver")
> Signed-off-by: AngeloGioacchino Del Regno <
> angelogioacchino.delregno@collabora.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 38
> ++++++++++++++++++++-
>  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h |  1 +
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c      |  4 ++-
>  3 files changed, 41 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> index c13359eeb3cd..539b526a6b0a 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> @@ -626,8 +626,11 @@ int mtk_ddp_comp_init(struct device_node *node,
> struct mtk_ddp_comp *comp,
>  
>  	priv->regs = of_iomap(node, 0);
>  	priv->clk = of_clk_get(node, 0);
> -	if (IS_ERR(priv->clk))
> +	if (IS_ERR(priv->clk)) {
> +		iounmap(priv->regs);
> +		priv->regs = NULL;
>  		return PTR_ERR(priv->clk);
> +	}
>  
>  #if IS_REACHABLE(CONFIG_MTK_CMDQ)
>  	ret = cmdq_dev_get_client_reg(comp->dev, &priv->cmdq_reg, 0);
> @@ -639,3 +642,36 @@ int mtk_ddp_comp_init(struct device_node *node,
> struct mtk_ddp_comp *comp,
>  
>  	return 0;
>  }
> +
> +void mtk_ddp_comp_destroy(struct mtk_ddp_comp *comp)
> +{
> +	struct mtk_ddp_comp_dev *priv;
> +
> +	if (!comp || !comp->dev)
> +		return;
> +
> +	/* Complex components are destroyed with their own remove
> callback */
> +	if (type == MTK_DISP_AAL ||
> +	    type == MTK_DISP_BLS ||
> +	    type == MTK_DISP_CCORR ||
> +	    type == MTK_DISP_COLOR ||
> +	    type == MTK_DISP_GAMMA ||
> +	    type == MTK_DISP_MERGE ||
> +	    type == MTK_DISP_OVL ||
> +	    type == MTK_DISP_OVL_2L ||
> +	    type == MTK_DISP_PWM ||
> +	    type == MTK_DISP_RDMA ||
> +	    type == MTK_DPI ||
> +	    type == MTK_DP_INTF ||
> +	    type == MTK_DSI)
> +		return;
> +
> +	priv = dev_get_drvdata(comp->dev);
> +	if (!priv)
> +		return;
> +
> +	if (priv->regs) {
> +		iounmap(priv->regs);
> +		priv->regs = NULL;
> +	}
> +}
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
> b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
> index 15b2eafff438..43372b416a3f 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
> @@ -318,6 +318,7 @@ unsigned int
> mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
>  						struct device *dev);
>  int mtk_ddp_comp_init(struct device_node *comp_node, struct
> mtk_ddp_comp *comp,
>  		      unsigned int comp_id);
> +void mtk_ddp_comp_destroy(struct mtk_ddp_comp *comp);
>  enum mtk_ddp_comp_type mtk_ddp_comp_get_type(unsigned int comp_id);
>  void mtk_ddp_write(struct cmdq_pkt *cmdq_pkt, unsigned int value,
>  		   struct cmdq_client_reg *cmdq_reg, void __iomem
> *regs,
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index 14a1e0157cc4..89b6c31a1511 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -944,8 +944,10 @@ static void mtk_drm_remove(struct
> platform_device *pdev)
>  	component_master_del(&pdev->dev, &mtk_drm_ops);
>  	pm_runtime_disable(&pdev->dev);
>  	of_node_put(private->mutex_node);
> -	for (i = 0; i < DDP_COMPONENT_DRM_ID_MAX; i++)
> +	for (i = 0; i < DDP_COMPONENT_DRM_ID_MAX; i++) {
> +		mtk_ddp_comp_destroy(&private->ddp_comp[i]);
>  		of_node_put(private->comp_node[i]);
> +	}
>  }
>  
>  static int mtk_drm_sys_prepare(struct device *dev)
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-03-22  8:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 12:53 [PATCH 0/3] drm/mediatek: Fixes for DDP component search/destroy AngeloGioacchino Del Regno
2024-02-01 12:53 ` [PATCH 1/3] drm/mediatek: drm_ddp_comp: Fix and cleanup DDP component CRTC search AngeloGioacchino Del Regno
2024-03-22  7:30   ` CK Hu (胡俊光)
2024-02-01 12:53 ` [PATCH 2/3] drm/mediatek: Perform iounmap on simple DDP component destruction AngeloGioacchino Del Regno
2024-03-22  8:48   ` CK Hu (胡俊光) [this message]
2024-04-01 14:18     ` Chun-Kuang Hu
2024-02-01 12:53 ` [PATCH 3/3] drm/mediatek: drm_ddp_comp: Add mtk_ddp_is_simple_comp() internal helper AngeloGioacchino Del Regno
2024-03-22  8:57   ` CK Hu (胡俊光)
2024-03-21  9:05 ` [PATCH 0/3] drm/mediatek: Fixes for DDP component search/destroy AngeloGioacchino Del Regno

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=4b5d172c9b169313aaec777158e2db697fe447fc.camel@mediatek.com \
    --to=ck.hu@mediatek.com \
    --cc=Nancy.Lin@mediatek.com \
    --cc=Nathan.Lu@mediatek.com \
    --cc=airlied@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@collabora.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=p.zabel@pengutronix.de \
    --cc=wenst@chromium.org \
    /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