dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: <Manikandan.M@microchip.com>
To: <mripard@kernel.org>, <maarten.lankhorst@linux.intel.com>,
	<tzimmermann@suse.de>, <airlied@gmail.com>, <simona@ffwll.ch>
Cc: <dri-devel@lists.freedesktop.org>,
	<alexandre.belloni@bootlin.com>, <claudiu.beznea@tuxon.dev>,
	<Nicolas.Ferre@microchip.com>
Subject: Re: [PATCH 43/60] drm/atmel-hlcdc: Convert to atomic_create_state
Date: Tue, 28 Jul 2026 10:47:44 +0000	[thread overview]
Message-ID: <226ea214-fed8-40b5-b430-ede131e573bb@microchip.com> (raw)
In-Reply-To: <20260709-drm-no-more-plane-reset-v1-43-302d986fe5f0@kernel.org>

Hi Maxime Ripard,

On 7/9/26 17:21, Maxime Ripard wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> The plane reset implementation creates a custom state
> subclass, but only initializes a pristine state without resetting any
> hardware. This is equivalent to what atomic_create_state expects.
> Convert to it.
> 
> The conversion was done using the following Coccinelle semantic patch:
> 
> @@
> identifier funcs;
> symbol drm_atomic_helper_plane_reset;
> symbol drm_atomic_helper_plane_create_state;
> @@
> 
> struct drm_plane_funcs funcs = {
>    ...,
> - .reset = drm_atomic_helper_plane_reset,
> + .atomic_create_state = drm_atomic_helper_plane_create_state,
>    ...,
> };
> 
> @match_struct_reset@
> identifier funcs, reset_func;
> @@
> struct drm_plane_funcs funcs = {
>      ...,
>      .reset = reset_func,
>      ...,
> };
> 
> @reset_uses_helpers depends on match_struct_reset@
> identifier match_struct_reset.reset_func;
> @@
> 
>   void reset_func(...)
>   {
>          <+...
> (
>          __drm_atomic_helper_plane_reset(...);
> |
>          __drm_gem_reset_shadow_plane(...);
> )
>          ...+>
>   }
> 
> @match_struct_destroy@
> identifier funcs, destroy_func;
> @@
> struct drm_plane_funcs funcs = {
>      ...,
>      .atomic_destroy_state = destroy_func,
>      ...,
> };
> 
> @script:python renamed_func@
> old_name << match_struct_reset.reset_func;
> new_name;
> @@
> if old_name.endswith("_reset"):
>      coccinelle.new_name = old_name.replace("_reset", "_create_state")
> else:
>      coccinelle.new_name = old_name
> 
> @update_struct depends on match_struct_reset && reset_uses_helpers@
> identifier match_struct_reset.funcs, match_struct_reset.reset_func;
> identifier renamed_func.new_name;
> @@
> struct drm_plane_funcs funcs = {
>      ...,
> -   .reset = reset_func,
> +   .atomic_create_state = new_name,
>      ...,
> };
> 
> @drop_destroy depends on update_struct && match_struct_destroy@
> identifier match_struct_reset.reset_func;
> identifier match_struct_destroy.destroy_func;
> identifier container_func;
> identifier P;
> symbol drm_atomic_helper_plane_destroy_state;
> symbol __drm_atomic_helper_plane_destroy_state;
> @@
> 
>   void reset_func(struct drm_plane *P)
>   {
>          ...
> (
> -       if (P->state) {
> -               <+...
> (
> -               drm_atomic_helper_plane_destroy_state(P, P->state);
> |
> -               __drm_atomic_helper_plane_destroy_state(P->state);
> |
> -               P->funcs->atomic_destroy_state(P, P->state);
> |
> -               destroy_func(P, P->state);
> )
> -               ...+>
> -       }
> |
> -       drm_WARN_ON_ONCE(P->dev, P->state);
> |
> -       WARN_ON(P->state);
> )
>          ...
> (
> -       kfree(P->state);
> |
> -       kfree(container_func(P->state));
> |
>          // kfree is optional
> )
> (
> -       P->state = NULL;
> |
>          // plane->state clearing is optional
> )
>          ...
>   }
> 
> @drop_destroy_mtk depends on update_struct@
> identifier P;
> symbol __drm_atomic_helper_plane_destroy_state;
> symbol to_mtk_plane_state;
> @@
> 
>   void mtk_plane_reset(struct drm_plane *P)
>   {
>          ...
> -       if (P->state) {
> -               __drm_atomic_helper_plane_destroy_state(P->state);
> -               ...
> -       } else {
>                  ...
> -       }
>          ...
>   }
> 
> @transform_nv50_wndw depends on update_struct@
> identifier S;
> @@
> 
>   void nv50_wndw_reset(...)
>   {
>          ...
> -       if (WARN_ON(!(S = kzalloc_obj(*S))))
> +       S = kzalloc_obj(*S);
> +       if (WARN_ON(!S))
>                  return;
>          ...
>   }
> 
> @transform_kzalloc depends on update_struct@
> identifier match_struct_reset.reset_func;
> identifier P, S;
> statement ST;
> statement list STL;
> @@
> 
>   void reset_func(struct drm_plane *P)
>   {
>          <...
>          S = kzalloc_obj(*S);
> (
> -       if (S)
> -       {
> -               STL
> -       }
> +       if (!S) return;
> +
> +       STL
> |
> -       if (S) ST
> +       if (!S) return;
> +
> +       ST
> )
>          ...>
>   }
> 
> @transform_body depends on update_struct@
> identifier match_struct_reset.reset_func;
> identifier renamed_func.new_name;
> identifier S, P;
> expression PS;
> @@
> - void reset_func(struct drm_plane *P)
> + struct drm_plane_state *new_name(struct drm_plane *P)
> {
>          ...
>          S = kzalloc_obj(*S);
>          ...
> (
>          if (!S) {
>                  ...
> -               return;
> +               return ERR_PTR(-ENOMEM);
>          }
> |
>          if (WARN_ON(!S)) {
>                  ...
> -               return;
> +               return ERR_PTR(-ENOMEM);
>          }
> |
>          if (S == NULL) {
>                  ...
> -               return;
> +               return ERR_PTR(-ENOMEM);
>          }
> )
>          ...
> (
> -       __drm_atomic_helper_plane_reset(P, PS);
> +       __drm_atomic_helper_plane_state_init(PS, P);
> |
> -       __drm_gem_reset_shadow_plane(P, PS);
> +       __drm_gem_shadow_plane_state_init(P, PS);
> )
>          ...
> }
> 
> @update_early_return depends on update_struct@
> identifier match_struct_reset.reset_func;
> identifier renamed_func.new_name;
> identifier P;
> expression PS;
> @@
>   struct drm_plane_state *new_name(struct drm_plane *P)
> {
>          <+...
> -       return;
> +       return ERR_PTR(-EINVAL);
>          ...+>
> }
> 
> @update_return_plane depends on update_struct@
> identifier match_struct_reset.reset_func;
> identifier renamed_func.new_name;
> identifier P;
> expression PS;
> @@
>   struct drm_plane_state *new_name(struct drm_plane *P)
> {
>          ...
>          __drm_atomic_helper_plane_state_init(PS, P);
>          ...
> +
> +       return PS;
> }
> 
> @update_return_shadow depends on update_struct@
> identifier renamed_func.new_name;
> identifier P;
> expression PS;
> @@
>   struct drm_plane_state *new_name(struct drm_plane *P)
> {
>          ...
>          __drm_gem_shadow_plane_state_init(P, PS);
>          ...
> +
> +       return &PS->base;
> }
> 
> Signed-off-by: Maxime Ripard <mripard@kernel.org>
Tested the patch on sama5 platforms

Tested-by: Manikandan Muralidharan <manikandan.m@microchip.com>
> ---
> Cc: alexandre.belloni@bootlin.com
> Cc: claudiu.beznea@tuxon.dev
> Cc: dharma.b@microchip.com
> Cc: manikandan.m@microchip.com
> Cc: nicolas.ferre@microchip.com
> ---
>   drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 27 +++++++++++--------------
>   1 file changed, 12 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> index f17a832351e9..ff35251a0184 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> @@ -1181,40 +1181,37 @@ static void atmel_hlcdc_plane_atomic_destroy_state(struct drm_plane *p,
>          __drm_atomic_helper_plane_destroy_state(s);
> 
>          kfree(state);
>   }
> 
> -static void atmel_hlcdc_plane_reset(struct drm_plane *p)
> +static struct drm_plane_state *atmel_hlcdc_plane_create_state(struct drm_plane *p)
>   {
>          struct atmel_hlcdc_plane_state *state;
>          struct atmel_hlcdc_dc *dc = p->dev->dev_private;
>          struct atmel_hlcdc_plane *plane = drm_plane_to_atmel_hlcdc_plane(p);
> 
> -       if (p->state) {
> -               atmel_hlcdc_plane_atomic_destroy_state(p, p->state);
> -               p->state = NULL;
> -       }
> -
>          state = kzalloc_obj(*state);
> -       if (state) {
> -               if (atmel_hlcdc_plane_alloc_dscrs(p, state)) {
> -                       kfree(state);
> -                       drm_err(p->dev,
> -                               "Failed to allocate initial plane state\n");
> -                       return;
> -               }
> -               __drm_atomic_helper_plane_reset(p, &state->base);
> +       if (!state)
> +               return ERR_PTR(-ENOMEM);
> +
> +       if (atmel_hlcdc_plane_alloc_dscrs(p, state)) {
> +               kfree(state);
> +               drm_err(p->dev, "Failed to allocate initial plane state\n");
> +               return ERR_PTR(-EINVAL);
>          }
> +       __drm_atomic_helper_plane_state_init(&state->base, p);
> 
>          if (plane->layer.desc->layout.csc)
>                  dc->desc->ops->lcdc_csc_init(plane, plane->layer.desc);
> +
> +       return &state->base;
>   }
> 
>   static const struct drm_plane_funcs layer_plane_funcs = {
>          .update_plane = drm_atomic_helper_update_plane,
>          .disable_plane = drm_atomic_helper_disable_plane,
> -       .reset = atmel_hlcdc_plane_reset,
> +       .atomic_create_state = atmel_hlcdc_plane_create_state,
>          .atomic_duplicate_state = atmel_hlcdc_plane_atomic_duplicate_state,
>          .atomic_destroy_state = atmel_hlcdc_plane_atomic_destroy_state,
>   };
> 
>   static int atmel_hlcdc_plane_create(struct drm_device *dev,
> 
> --
> 2.54.0
> 


-- 
Thanks and Regards,
Manikandan M.

  parent reply	other threads:[~2026-07-28 10:47 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 11:50 [PATCH 00/60] drm/plane: Convert all drivers to atomic_create_state and remove reset Maxime Ripard
2026-07-09 11:50 ` [PATCH 01/60] drm/simple-kms: Add create_plane_state hook Maxime Ripard
2026-07-09 12:00   ` sashiko-bot
2026-07-09 13:49   ` Thomas Zimmermann
2026-07-17 13:19     ` Maxime Ripard
2026-07-10  7:50   ` Thomas Zimmermann
2026-07-09 11:50 ` [PATCH 02/60] drm/gem-atomic-helper: Create drm_gem_create_shadow_plane_state() Maxime Ripard
2026-07-10  7:44   ` Thomas Zimmermann
2026-07-10  7:47     ` Thomas Zimmermann
2026-07-10  7:47   ` Thomas Zimmermann
2026-07-09 11:50 ` [PATCH 03/60] drm/gem-atomic-helper: Convert simple-kms shadow helpers to create_plane_state Maxime Ripard
2026-07-09 12:03   ` sashiko-bot
2026-07-10  7:46   ` Thomas Zimmermann
2026-07-09 11:50 ` [PATCH 04/60] drm/gem-atomic-helper: Switch DRM_GEM_SHADOW_PLANE_FUNCS to atomic_create_state Maxime Ripard
2026-07-10  7:51   ` Thomas Zimmermann
2026-07-09 11:50 ` [PATCH 05/60] drm/gem-atomic-helper: Remove drm_gem_reset_shadow_plane() Maxime Ripard
2026-07-10  7:52   ` Thomas Zimmermann
2026-07-09 11:50 ` [PATCH 06/60] drm/sysfb: Convert to atomic_create_state Maxime Ripard
2026-07-10  7:54   ` Thomas Zimmermann
2026-07-09 11:50 ` [PATCH 07/60] drm/simple-kms: Switch " Maxime Ripard
2026-07-10  7:56   ` Thomas Zimmermann
2026-07-09 11:50 ` [PATCH 08/60] drm/ssd130x: Convert " Maxime Ripard
2026-07-16 10:29   ` Javier Martinez Canillas
2026-07-09 11:50 ` [PATCH 09/60] drm/st7920: " Maxime Ripard
2026-07-15 10:09   ` Iker Pedrosa
2026-07-09 11:50 ` [PATCH 10/60] drm/appletbdrm: " Maxime Ripard
2026-07-10 16:39   ` Aditya Garg
2026-07-09 11:50 ` [PATCH 11/60] drm/vkms: " Maxime Ripard
2026-07-09 11:50 ` [PATCH 12/60] drm/gem-atomic-helper: Remove __drm_gem_reset_shadow_plane() Maxime Ripard
2026-07-09 11:50 ` [PATCH 13/60] drm/amdgpu: Convert to atomic_create_state Maxime Ripard
2026-07-09 11:50 ` [PATCH 14/60] drm/hdlcd: " Maxime Ripard
2026-07-31  9:46   ` Liviu Dudau
2026-07-09 11:50 ` [PATCH 15/60] drm/fsl-dcu: " Maxime Ripard
2026-07-09 11:50 ` [PATCH 16/60] drm/hisilicon/kirin: " Maxime Ripard
2026-07-09 11:50 ` [PATCH 17/60] drm/imx/dc: " Maxime Ripard
2026-07-09 11:50 ` [PATCH 18/60] drm/imx/dcss: " Maxime Ripard
2026-07-09 11:50 ` [PATCH 19/60] drm/ingenic: " Maxime Ripard
2026-07-15 22:08   ` Paul Cercueil
2026-07-09 11:50 ` [PATCH 20/60] drm/kmb: " Maxime Ripard
2026-07-09 12:10   ` sashiko-bot
2026-07-09 11:50 ` [PATCH 21/60] drm/logicvc: " Maxime Ripard
2026-07-09 11:50 ` [PATCH 22/60] drm/loongson: " Maxime Ripard
2026-07-09 11:50 ` [PATCH 23/60] drm/meson: " Maxime Ripard
2026-07-10  5:51   ` Martin Blumenstingl
2026-07-09 11:50 ` [PATCH 24/60] drm/msm/mdp4: " Maxime Ripard
2026-07-09 12:31   ` Dmitry Baryshkov
2026-07-09 11:50 ` [PATCH 25/60] drm/lcdif: " Maxime Ripard
2026-07-09 11:50 ` [PATCH 26/60] drm/mxsfb: " Maxime Ripard
2026-07-09 11:50 ` [PATCH 27/60] drm/qxl: " Maxime Ripard
2026-07-09 11:50 ` [PATCH 28/60] drm/rockchip: " Maxime Ripard
2026-07-09 11:50 ` [PATCH 29/60] drm/sprd: " Maxime Ripard
2026-07-09 11:50 ` [PATCH 30/60] drm/sti: " Maxime Ripard
2026-07-09 11:50 ` [PATCH 31/60] drm/stm: " Maxime Ripard
2026-07-09 11:50 ` [PATCH 32/60] drm/sun4i: sun8i: " Maxime Ripard
2026-07-09 12:24   ` sashiko-bot
2026-07-09 11:50 ` [PATCH 33/60] drm/tests: kunit: " Maxime Ripard
2026-07-09 11:51 ` [PATCH 34/60] drm/tilcdc: " Maxime Ripard
2026-07-09 11:51 ` [PATCH 35/60] drm/vboxvideo: " Maxime Ripard
2026-07-09 12:20   ` sashiko-bot
2026-07-09 11:51 ` [PATCH 36/60] drm/virtio: " Maxime Ripard
2026-07-09 11:51 ` [PATCH 37/60] drm/xlnx: " Maxime Ripard
2026-07-09 11:51 ` [PATCH 38/60] drm/atomic-state-helper: Remove drm_atomic_helper_plane_reset() Maxime Ripard
2026-07-09 12:20   ` sashiko-bot
2026-07-09 11:51 ` [PATCH 39/60] drm/amdgpu_dm: Convert to atomic_create_state Maxime Ripard
2026-07-09 12:23   ` sashiko-bot
2026-07-09 11:51 ` [PATCH 40/60] drm/komeda: " Maxime Ripard
2026-07-31  9:48   ` Liviu Dudau
2026-07-09 11:51 ` [PATCH 41/60] drm/malidp: " Maxime Ripard
2026-07-09 12:28   ` sashiko-bot
2026-07-31  9:48   ` Liviu Dudau
2026-07-09 11:51 ` [PATCH 42/60] drm/armada: " Maxime Ripard
2026-07-09 12:23   ` sashiko-bot
2026-07-09 11:51 ` [PATCH 43/60] drm/atmel-hlcdc: " Maxime Ripard
2026-07-09 12:29   ` sashiko-bot
2026-07-28 10:47   ` Manikandan.M [this message]
2026-07-09 11:51 ` [PATCH 44/60] drm/exynos: " Maxime Ripard
2026-07-09 12:25   ` sashiko-bot
2026-07-09 11:51 ` [PATCH 45/60] drm/imx/ipuv3: " Maxime Ripard
2026-07-09 11:51 ` [PATCH 46/60] drm/mediatek: " Maxime Ripard
2026-07-09 12:26   ` sashiko-bot
2026-07-09 11:51 ` [PATCH 47/60] drm/msm/dpu1: " Maxime Ripard
2026-07-09 12:36   ` Dmitry Baryshkov
2026-07-09 11:51 ` [PATCH 48/60] drm/msm/mdp5: " Maxime Ripard
2026-07-09 12:46   ` Dmitry Baryshkov
2026-07-09 11:51 ` [PATCH 49/60] drm/nouveau: " Maxime Ripard
2026-07-09 11:51 ` [PATCH 50/60] drm/omap: " Maxime Ripard
2026-07-09 11:51 ` [PATCH 51/60] drm/rcar-du: " Maxime Ripard
2026-07-09 11:51 ` [PATCH 52/60] drm/rz-du: " Maxime Ripard
2026-07-10 14:31   ` Biju Das
2026-07-09 11:51 ` [PATCH 53/60] drm/shmobile: " Maxime Ripard
2026-07-09 11:51 ` [PATCH 54/60] drm/sun4i: layer: " Maxime Ripard
2026-07-09 12:33   ` sashiko-bot
2026-07-09 11:51 ` [PATCH 55/60] drm/vc4: " Maxime Ripard
2026-07-13 14:47   ` Maíra Canal
2026-07-09 11:51 ` [PATCH 56/60] drm/verisilicon: " Maxime Ripard
2026-07-09 11:51 ` [PATCH 57/60] drm/vmwgfx: " Maxime Ripard
2026-07-09 11:51 ` [PATCH 58/60] drm/atomic-state-helper: Remove __drm_atomic_helper_plane_reset() Maxime Ripard
2026-07-09 11:51 ` [PATCH 59/60] drm/tegra: Convert to atomic_create_state Maxime Ripard
2026-07-15  7:25   ` Mikko Perttunen
2026-07-09 11:51 ` [PATCH 60/60] drm/plane: Remove reset Maxime Ripard
2026-07-09 12:43   ` sashiko-bot

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=226ea214-fed8-40b5-b430-ede131e573bb@microchip.com \
    --to=manikandan.m@microchip.com \
    --cc=Nicolas.Ferre@microchip.com \
    --cc=airlied@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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