All of lore.kernel.org
 help / color / mirror / Atom feed
From: lyude@redhat.com
To: Maxime Ripard <mripard@kernel.org>,
	Maarten Lankhorst	 <maarten.lankhorst@linux.intel.com>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	 David Airlie <airlied@gmail.com>,
	Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, dakr@kernel.org,
	nouveau@lists.freedesktop.org
Subject: Re: [PATCH v2 51/61] drm/nouveau: Convert to atomic_create_state
Date: Fri, 14 Aug 2026 15:06:49 -0400	[thread overview]
Message-ID: <fcfc05b3197c0318ecdd8e60597b618f366eb8d3.camel@redhat.com> (raw)
In-Reply-To: <20260814-drm-no-more-plane-reset-v2-51-82d2963dd134@kernel.org>

On Fri, 2026-08-14 at 16:57 +0200, Maxime Ripard wrote:
> 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>
> ---
> Cc: dakr@kernel.org
> Cc: lyude@redhat.com
> Cc: nouveau@lists.freedesktop.org
> ---
>  drivers/gpu/drm/nouveau/dispnv50/wndw.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
> b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
> index 15a322422f4e..378095138d12 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
> @@ -750,22 +750,21 @@ nv50_wndw_zpos_default(struct drm_plane *plane)
>  {
>  	return (plane->type == DRM_PLANE_TYPE_PRIMARY) ? 0 :
>  	       (plane->type == DRM_PLANE_TYPE_OVERLAY) ? 1 : 255;
>  }
>  
> -static void
> -nv50_wndw_reset(struct drm_plane *plane)
> +static struct drm_plane_state *nv50_wndw_create_state(struct
> drm_plane *plane)
>  {
>  	struct nv50_wndw_atom *asyw;
>  
> -	if (WARN_ON(!(asyw = kzalloc_obj(*asyw))))
> -		return;
> +	asyw = kzalloc_obj(*asyw);
> +	if (WARN_ON(!asyw))
> +		return ERR_PTR(-ENOMEM);

Should this be drm_WARN_ON() while we're at it?

Otherwise, this looks good to me:

Reviewed-by: Lyude Paul <lyude@redhat.com>

>  
> -	if (plane->state)
> -		plane->funcs->atomic_destroy_state(plane, plane-
> >state);
> +	__drm_atomic_helper_plane_state_init(&asyw->state, plane);
>  
> -	__drm_atomic_helper_plane_reset(plane, &asyw->state);
> +	return &asyw->state;
>  }
>  
>  static void
>  nv50_wndw_destroy(struct drm_plane *plane)
>  {
> @@ -835,11 +834,11 @@ static bool
> nv50_plane_format_mod_supported(struct drm_plane *plane,
>  const struct drm_plane_funcs
>  nv50_wndw = {
>  	.update_plane = drm_atomic_helper_update_plane,
>  	.disable_plane = drm_atomic_helper_disable_plane,
>  	.destroy = nv50_wndw_destroy,
> -	.reset = nv50_wndw_reset,
> +	.atomic_create_state = nv50_wndw_create_state,
>  	.atomic_duplicate_state = nv50_wndw_atomic_duplicate_state,
>  	.atomic_destroy_state = nv50_wndw_atomic_destroy_state,
>  	.format_mod_supported = nv50_plane_format_mod_supported,
>  };
>  


  reply	other threads:[~2026-08-14 19:07 UTC|newest]

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

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=fcfc05b3197c0318ecdd8e60597b618f366eb8d3.camel@redhat.com \
    --to=lyude@redhat.com \
    --cc=airlied@gmail.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=nouveau@lists.freedesktop.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.