Re: [PATCH 45/70] drm/komeda: Convert to atomic_create_state

Liviu Dudau <[email protected]>
Newsgroups org.freedesktop.lists.dri-devel
Message-ID <aowheLXc3XrH9wFX@e142607>
On Fri, Aug 21, 2026 at 04:39:21PM +0200, Maxime Ripard wrote:
> The komeda crtc implementation provides a custom reset hook. However,
> this hook only allocates the state, initializes it with
> __drm_atomic_helper_crtc_reset(), and frees the previous state. It
> does not perform any hardware reset.
> 
> Since this is exactly what the atomic_create_state hook is meant to
> do, minus the old state cleanup which the caller handles, convert the
> implementation to use atomic_create_state with
> __drm_atomic_helper_crtc_state_init() instead.
> 
> Signed-off-by: Maxime Ripard <[email protected]>

Acked-by: Liviu Dudau <[email protected]>

Best regards,
Liviu

> ---
> Cc: Liviu Dudau <[email protected]>
> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_crtc.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> index e8cb782a6f8e..e1165b6d8bfd 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> @@ -491,23 +491,21 @@ static const struct drm_crtc_helper_funcs komeda_crtc_helper_funcs = {
>  	.atomic_disable	= komeda_crtc_atomic_disable,
>  	.mode_valid	= komeda_crtc_mode_valid,
>  	.mode_fixup	= komeda_crtc_mode_fixup,
>  };
>  
> -static void komeda_crtc_reset(struct drm_crtc *crtc)
> +static struct drm_crtc_state *komeda_crtc_create_state(struct drm_crtc *crtc)
>  {
>  	struct komeda_crtc_state *state;
>  
> -	if (crtc->state)
> -		__drm_atomic_helper_crtc_destroy_state(crtc->state);
> -
> -	kfree(to_kcrtc_st(crtc->state));
> -	crtc->state = NULL;
> -
>  	state = kzalloc_obj(*state);
> -	if (state)
> -		__drm_atomic_helper_crtc_reset(crtc, &state->base);
> +	if (!state)
> +		return ERR_PTR(-ENOMEM);
> +
> +	__drm_atomic_helper_crtc_state_init(&state->base, crtc);
> +
> +	return &state->base;
>  }
>  
>  static struct drm_crtc_state *
>  komeda_crtc_atomic_duplicate_state(struct drm_crtc *crtc)
>  {
> @@ -553,11 +551,11 @@ static void komeda_crtc_vblank_disable(struct drm_crtc *crtc)
>  
>  static const struct drm_crtc_funcs komeda_crtc_funcs = {
>  	.destroy		= drm_crtc_cleanup,
>  	.set_config		= drm_atomic_helper_set_config,
>  	.page_flip		= drm_atomic_helper_page_flip,
> -	.reset			= komeda_crtc_reset,
> +	.atomic_create_state = komeda_crtc_create_state,
>  	.atomic_duplicate_state	= komeda_crtc_atomic_duplicate_state,
>  	.atomic_destroy_state	= komeda_crtc_atomic_destroy_state,
>  	.enable_vblank		= komeda_crtc_vblank_enable,
>  	.disable_vblank		= komeda_crtc_vblank_disable,
>  };
> 
> -- 
> 2.55.0
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.