Re: [PATCH 59/60] drm/tegra: Convert to atomic_create_state

2026-07-15 Thread Mikko Perttunen
On Thursday, July 9, 2026 8:51 PM 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.
> 
> Signed-off-by: Maxime Ripard 
> ---
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> ---
>  drivers/gpu/drm/tegra/plane.c | 28 
>  1 file changed, 12 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tegra/plane.c b/drivers/gpu/drm/tegra/plane.c
> index 0cb30910773f..2148b0c59815 100644
> --- a/drivers/gpu/drm/tegra/plane.c
> +++ b/drivers/gpu/drm/tegra/plane.c
> @@ -22,32 +22,28 @@ static void tegra_plane_destroy(struct drm_plane *plane)
>  
>   drm_plane_cleanup(plane);
>   kfree(p);
>  }
>  
> -static void tegra_plane_reset(struct drm_plane *plane)
> +static struct drm_plane_state *tegra_plane_atomic_create_state(struct 
> drm_plane *plane)
>  {
>   struct tegra_plane *p = to_tegra_plane(plane);
>   struct tegra_plane_state *state;
>   unsigned int i;
>  
> - if (plane->state)
> - __drm_atomic_helper_plane_destroy_state(plane->state);
> -
> - kfree(plane->state);
> - plane->state = NULL;
> -
>   state = kzalloc_obj(*state);
> - if (state) {
> - plane->state = &state->base;
> - plane->state->plane = plane;
> - plane->state->zpos = p->index;
> - plane->state->normalized_zpos = p->index;
> + if (!state)
> + return ERR_PTR(-ENOMEM);
>  
> - for (i = 0; i < 3; i++)
> - state->iova[i] = DMA_MAPPING_ERROR;
> - }
> + state->base.plane = plane;
> + state->base.zpos = p->index;
> + state->base.normalized_zpos = p->index;
> +
> + for (i = 0; i < 3; i++)
> + state->iova[i] = DMA_MAPPING_ERROR;
> +
> + return &state->base;
>  }
>  
>  static struct drm_plane_state *
>  tegra_plane_atomic_duplicate_state(struct drm_plane *plane)
>  {
> @@ -129,11 +125,11 @@ static bool tegra_plane_format_mod_supported(struct 
> drm_plane *plane,
>  
>  const struct drm_plane_funcs tegra_plane_funcs = {
>   .update_plane = drm_atomic_helper_update_plane,
>   .disable_plane = drm_atomic_helper_disable_plane,
>   .destroy = tegra_plane_destroy,
> - .reset = tegra_plane_reset,
> + .atomic_create_state = tegra_plane_atomic_create_state,
>   .atomic_duplicate_state = tegra_plane_atomic_duplicate_state,
>   .atomic_destroy_state = tegra_plane_atomic_destroy_state,
>   .format_mod_supported = tegra_plane_format_mod_supported,
>  };
>  
> 
> -- 
> 2.54.0
> 
> 

Reviewed-by: Mikko Perttunen 





[PATCH 59/60] drm/tegra: Convert to atomic_create_state

2026-07-09 Thread Maxime Ripard
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.

Signed-off-by: Maxime Ripard 
---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
 drivers/gpu/drm/tegra/plane.c | 28 
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/tegra/plane.c b/drivers/gpu/drm/tegra/plane.c
index 0cb30910773f..2148b0c59815 100644
--- a/drivers/gpu/drm/tegra/plane.c
+++ b/drivers/gpu/drm/tegra/plane.c
@@ -22,32 +22,28 @@ static void tegra_plane_destroy(struct drm_plane *plane)
 
drm_plane_cleanup(plane);
kfree(p);
 }
 
-static void tegra_plane_reset(struct drm_plane *plane)
+static struct drm_plane_state *tegra_plane_atomic_create_state(struct 
drm_plane *plane)
 {
struct tegra_plane *p = to_tegra_plane(plane);
struct tegra_plane_state *state;
unsigned int i;
 
-   if (plane->state)
-   __drm_atomic_helper_plane_destroy_state(plane->state);
-
-   kfree(plane->state);
-   plane->state = NULL;
-
state = kzalloc_obj(*state);
-   if (state) {
-   plane->state = &state->base;
-   plane->state->plane = plane;
-   plane->state->zpos = p->index;
-   plane->state->normalized_zpos = p->index;
+   if (!state)
+   return ERR_PTR(-ENOMEM);
 
-   for (i = 0; i < 3; i++)
-   state->iova[i] = DMA_MAPPING_ERROR;
-   }
+   state->base.plane = plane;
+   state->base.zpos = p->index;
+   state->base.normalized_zpos = p->index;
+
+   for (i = 0; i < 3; i++)
+   state->iova[i] = DMA_MAPPING_ERROR;
+
+   return &state->base;
 }
 
 static struct drm_plane_state *
 tegra_plane_atomic_duplicate_state(struct drm_plane *plane)
 {
@@ -129,11 +125,11 @@ static bool tegra_plane_format_mod_supported(struct 
drm_plane *plane,
 
 const struct drm_plane_funcs tegra_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = tegra_plane_destroy,
-   .reset = tegra_plane_reset,
+   .atomic_create_state = tegra_plane_atomic_create_state,
.atomic_duplicate_state = tegra_plane_atomic_duplicate_state,
.atomic_destroy_state = tegra_plane_atomic_destroy_state,
.format_mod_supported = tegra_plane_format_mod_supported,
 };
 

-- 
2.54.0