mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/mediatek: simplify mtk_crtc allocation
@ 2026-03-31  0:23 Rosen Penev
  2026-05-08  6:43 ` CK Hu (胡俊光)
  2026-05-13 14:53 ` Chun-Kuang Hu
  0 siblings, 2 replies; 3+ messages in thread
From: Rosen Penev @ 2026-03-31  0:23 UTC (permalink / raw)
  To: dri-devel
  Cc: Chun-Kuang Hu, Philipp Zabel, David Airlie, Simona Vetter,
	Matthias Brugger, AngeloGioacchino Del Regno,
	moderated list:DRM DRIVERS FOR MEDIATEK,
	open list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support

Use a flexible array member to combine allocations.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/gpu/drm/mediatek/mtk_crtc.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_crtc.c b/drivers/gpu/drm/mediatek/mtk_crtc.c
index fcb16f3f7b23..914841d2396e 100644
--- a/drivers/gpu/drm/mediatek/mtk_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_crtc.c
@@ -62,7 +62,6 @@ struct mtk_crtc {
 	struct device			*dma_dev;
 	struct mtk_mutex		*mutex;
 	unsigned int			ddp_comp_nr;
-	struct mtk_ddp_comp		**ddp_comp;
 	unsigned int			num_conn_routes;
 	const struct mtk_drm_route	*conn_routes;
 
@@ -71,6 +70,8 @@ struct mtk_crtc {
 	bool				config_updating;
 	/* lock for config_updating to cmd buffer */
 	spinlock_t			config_lock;
+
+	struct mtk_ddp_comp		*ddp_comp[];
 };
 
 struct mtk_crtc_state {
@@ -1048,18 +1049,12 @@ int mtk_crtc_create(struct drm_device *drm_dev, const unsigned int *path,
 		}
 	}
 
-	mtk_crtc = devm_kzalloc(dev, sizeof(*mtk_crtc), GFP_KERNEL);
+	mtk_crtc = devm_kzalloc(dev, struct_size(mtk_crtc, ddp_comp, path_len + (conn_routes ? 1 : 0)), GFP_KERNEL);
 	if (!mtk_crtc)
 		return -ENOMEM;
 
-	mtk_crtc->mmsys_dev = priv->mmsys_dev;
 	mtk_crtc->ddp_comp_nr = path_len;
-	mtk_crtc->ddp_comp = devm_kcalloc(dev,
-					  mtk_crtc->ddp_comp_nr + (conn_routes ? 1 : 0),
-					  sizeof(*mtk_crtc->ddp_comp),
-					  GFP_KERNEL);
-	if (!mtk_crtc->ddp_comp)
-		return -ENOMEM;
+	mtk_crtc->mmsys_dev = priv->mmsys_dev;
 
 	mtk_crtc->mutex = mtk_mutex_get(priv->mutex_dev);
 	if (IS_ERR(mtk_crtc->mutex)) {
-- 
2.53.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/mediatek: simplify mtk_crtc allocation
  2026-03-31  0:23 [PATCH] drm/mediatek: simplify mtk_crtc allocation Rosen Penev
@ 2026-05-08  6:43 ` CK Hu (胡俊光)
  2026-05-13 14:53 ` Chun-Kuang Hu
  1 sibling, 0 replies; 3+ messages in thread
From: CK Hu (胡俊光) @ 2026-05-08  6:43 UTC (permalink / raw)
  To: dri-devel, rosenp
  Cc: chunkuang.hu, simona, AngeloGioacchino Del Regno, airlied,
	linux-kernel, linux-arm-kernel, p.zabel, linux-mediatek,
	matthias.bgg

On Mon, 2026-03-30 at 17:23 -0700, Rosen Penev wrote:
> External email : Please do not click links or open attachments until you have verified the sender or the content.
> 
> 
> Use a flexible array member to combine allocations.

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

> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_crtc.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_crtc.c b/drivers/gpu/drm/mediatek/mtk_crtc.c
> index fcb16f3f7b23..914841d2396e 100644
> --- a/drivers/gpu/drm/mediatek/mtk_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_crtc.c
> @@ -62,7 +62,6 @@ struct mtk_crtc {
>         struct device                   *dma_dev;
>         struct mtk_mutex                *mutex;
>         unsigned int                    ddp_comp_nr;
> -       struct mtk_ddp_comp             **ddp_comp;
>         unsigned int                    num_conn_routes;
>         const struct mtk_drm_route      *conn_routes;
> 
> @@ -71,6 +70,8 @@ struct mtk_crtc {
>         bool                            config_updating;
>         /* lock for config_updating to cmd buffer */
>         spinlock_t                      config_lock;
> +
> +       struct mtk_ddp_comp             *ddp_comp[];
>  };
> 
>  struct mtk_crtc_state {
> @@ -1048,18 +1049,12 @@ int mtk_crtc_create(struct drm_device *drm_dev, const unsigned int *path,
>                 }
>         }
> 
> -       mtk_crtc = devm_kzalloc(dev, sizeof(*mtk_crtc), GFP_KERNEL);
> +       mtk_crtc = devm_kzalloc(dev, struct_size(mtk_crtc, ddp_comp, path_len + (conn_routes ? 1 : 0)), GFP_KERNEL);
>         if (!mtk_crtc)
>                 return -ENOMEM;
> 
> -       mtk_crtc->mmsys_dev = priv->mmsys_dev;
>         mtk_crtc->ddp_comp_nr = path_len;
> -       mtk_crtc->ddp_comp = devm_kcalloc(dev,
> -                                         mtk_crtc->ddp_comp_nr + (conn_routes ? 1 : 0),
> -                                         sizeof(*mtk_crtc->ddp_comp),
> -                                         GFP_KERNEL);
> -       if (!mtk_crtc->ddp_comp)
> -               return -ENOMEM;
> +       mtk_crtc->mmsys_dev = priv->mmsys_dev;
> 
>         mtk_crtc->mutex = mtk_mutex_get(priv->mutex_dev);
>         if (IS_ERR(mtk_crtc->mutex)) {
> --
> 2.53.0
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/mediatek: simplify mtk_crtc allocation
  2026-03-31  0:23 [PATCH] drm/mediatek: simplify mtk_crtc allocation Rosen Penev
  2026-05-08  6:43 ` CK Hu (胡俊光)
@ 2026-05-13 14:53 ` Chun-Kuang Hu
  1 sibling, 0 replies; 3+ messages in thread
From: Chun-Kuang Hu @ 2026-05-13 14:53 UTC (permalink / raw)
  To: Rosen Penev
  Cc: dri-devel, Chun-Kuang Hu, Philipp Zabel, David Airlie,
	Simona Vetter, Matthias Brugger, AngeloGioacchino Del Regno,
	moderated list:DRM DRIVERS FOR MEDIATEK,
	open list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support

Hi, Rosen:

Rosen Penev <rosenp@gmail.com> 於 2026年3月31日週二 上午12:24寫道:
>
> Use a flexible array member to combine allocations.

Applied to mediatek-drm-next [1], thanks.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_crtc.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_crtc.c b/drivers/gpu/drm/mediatek/mtk_crtc.c
> index fcb16f3f7b23..914841d2396e 100644
> --- a/drivers/gpu/drm/mediatek/mtk_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_crtc.c
> @@ -62,7 +62,6 @@ struct mtk_crtc {
>         struct device                   *dma_dev;
>         struct mtk_mutex                *mutex;
>         unsigned int                    ddp_comp_nr;
> -       struct mtk_ddp_comp             **ddp_comp;
>         unsigned int                    num_conn_routes;
>         const struct mtk_drm_route      *conn_routes;
>
> @@ -71,6 +70,8 @@ struct mtk_crtc {
>         bool                            config_updating;
>         /* lock for config_updating to cmd buffer */
>         spinlock_t                      config_lock;
> +
> +       struct mtk_ddp_comp             *ddp_comp[];
>  };
>
>  struct mtk_crtc_state {
> @@ -1048,18 +1049,12 @@ int mtk_crtc_create(struct drm_device *drm_dev, const unsigned int *path,
>                 }
>         }
>
> -       mtk_crtc = devm_kzalloc(dev, sizeof(*mtk_crtc), GFP_KERNEL);
> +       mtk_crtc = devm_kzalloc(dev, struct_size(mtk_crtc, ddp_comp, path_len + (conn_routes ? 1 : 0)), GFP_KERNEL);
>         if (!mtk_crtc)
>                 return -ENOMEM;
>
> -       mtk_crtc->mmsys_dev = priv->mmsys_dev;
>         mtk_crtc->ddp_comp_nr = path_len;
> -       mtk_crtc->ddp_comp = devm_kcalloc(dev,
> -                                         mtk_crtc->ddp_comp_nr + (conn_routes ? 1 : 0),
> -                                         sizeof(*mtk_crtc->ddp_comp),
> -                                         GFP_KERNEL);
> -       if (!mtk_crtc->ddp_comp)
> -               return -ENOMEM;
> +       mtk_crtc->mmsys_dev = priv->mmsys_dev;
>
>         mtk_crtc->mutex = mtk_mutex_get(priv->mutex_dev);
>         if (IS_ERR(mtk_crtc->mutex)) {
> --
> 2.53.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-13 14:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-31  0:23 [PATCH] drm/mediatek: simplify mtk_crtc allocation Rosen Penev
2026-05-08  6:43 ` CK Hu (胡俊光)
2026-05-13 14:53 ` Chun-Kuang Hu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®