Re: [PATCH v2 56/61] drm/sun4i: layer: Convert to atomic_create_state

[email protected]
Newsgroups dev.linux.lists.linux-sunxi,org.freedesktop.lists.dri-devel
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The `.atomic_create_state` hook (`sun4i_backend_layer_create_state`) illegally retains state destruction logic, violating the factory function API contract.
--

--- Patch [56]: [PATCH v2 56/61] drm/sun4i: layer: Convert to atomic_create_state ---
commit ff1555af002cdd0794b6aa7ae72c66565fbe6fdd
Author: Maxime Ripard <[email protected]>

drm/sun4i: layer: Convert to atomic_create_state

This commit converts the plane reset implementation to use
atomic_create_state. The existing implementation creates a custom state
subclass but only initializes a pristine state without resetting any
hardware, which matches the expected behavior of atomic_create_state.

> diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c
> index d65587d96d9ee..b165960ca8e5d 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_layer.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_layer.c
> @@ -16,7 +16,7 @@
>  #include "sun4i_layer.h"
>  #include "sunxi_engine.h"
>  
> -static void sun4i_backend_layer_reset(struct drm_plane *plane)
> +static struct drm_plane_state *sun4i_backend_layer_create_state(struct drm_plane *plane)
>  {
>  	struct sun4i_layer_state *state;
>  
>  	if (plane->state) {
>  		state = state_to_sun4i_layer_state(plane->state);
>  
>  		__drm_atomic_helper_plane_destroy_state(&state->state);
>  
>  		kfree(state);
>  		plane->state = NULL;
>  	}

[Severity: Medium]
Should this state destruction logic be removed since this function is now
an atomic_create_state hook?

The atomic_create_state factory function API contract expects only
allocation and initialization of a new state object. Although the DRM core
guarantees plane->state is NULL before invoking this hook (making this
block functionally dead code), it appears the Coccinelle semantic patch
may have missed removing this destruction block during the conversion.

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=56
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.