[PATCH 21/29] drm/tidss: crtc: Implement destroy_state

Maxime Ripard posted 29 patches 1 month ago
[PATCH 21/29] drm/tidss: crtc: Implement destroy_state
Posted by Maxime Ripard 1 month ago
The tidss crtc driver implements its own state, with its own
implementation of reset and duplicate_state, but uses the default
destroy_state helper.

This somewhat works for now because the drm_crtc_state field in
tidss_crtc_state is the first field so the offset is 0, but it's pretty
fragile and it should really have its own destroy_state implementation.

Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
 drivers/gpu/drm/tidss/tidss_crtc.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tidss/tidss_crtc.c b/drivers/gpu/drm/tidss/tidss_crtc.c
index db7c5e4225e6247047087a35a2e6422950fc0111..eb431a238b11d22349d61f0e17f05994f50d5f2f 100644
--- a/drivers/gpu/drm/tidss/tidss_crtc.c
+++ b/drivers/gpu/drm/tidss/tidss_crtc.c
@@ -341,10 +341,19 @@ static void tidss_crtc_disable_vblank(struct drm_crtc *crtc)
 	tidss_irq_disable_vblank(crtc);
 
 	tidss_runtime_put(tidss);
 }
 
+static void tidss_crtc_destroy_state(struct drm_crtc *crtc,
+				     struct drm_crtc_state *state)
+{
+	struct tidss_crtc_state *tstate = to_tidss_crtc_state(state);
+
+	__drm_atomic_helper_crtc_destroy_state(&tstate->base);
+	kfree(tstate);
+}
+
 static void tidss_crtc_reset(struct drm_crtc *crtc)
 {
 	struct tidss_crtc_state *tstate;
 
 	if (crtc->state)
@@ -396,11 +405,11 @@ static const struct drm_crtc_funcs tidss_crtc_funcs = {
 	.reset = tidss_crtc_reset,
 	.destroy = tidss_crtc_destroy,
 	.set_config = drm_atomic_helper_set_config,
 	.page_flip = drm_atomic_helper_page_flip,
 	.atomic_duplicate_state = tidss_crtc_duplicate_state,
-	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+	.atomic_destroy_state = tidss_crtc_destroy_state,
 	.enable_vblank = tidss_crtc_enable_vblank,
 	.disable_vblank = tidss_crtc_disable_vblank,
 };
 
 struct tidss_crtc *tidss_crtc_create(struct tidss_device *tidss,

-- 
2.50.1
Re: [PATCH 21/29] drm/tidss: crtc: Implement destroy_state
Posted by Thomas Zimmermann 1 month ago

Am 02.09.25 um 10:32 schrieb Maxime Ripard:
> The tidss crtc driver implements its own state, with its own
> implementation of reset and duplicate_state, but uses the default
> destroy_state helper.
>
> This somewhat works for now because the drm_crtc_state field in
> tidss_crtc_state is the first field so the offset is 0, but it's pretty
> fragile and it should really have its own destroy_state implementation.
>
> Signed-off-by: Maxime Ripard <mripard@kernel.org>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>   drivers/gpu/drm/tidss/tidss_crtc.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/tidss/tidss_crtc.c b/drivers/gpu/drm/tidss/tidss_crtc.c
> index db7c5e4225e6247047087a35a2e6422950fc0111..eb431a238b11d22349d61f0e17f05994f50d5f2f 100644
> --- a/drivers/gpu/drm/tidss/tidss_crtc.c
> +++ b/drivers/gpu/drm/tidss/tidss_crtc.c
> @@ -341,10 +341,19 @@ static void tidss_crtc_disable_vblank(struct drm_crtc *crtc)
>   	tidss_irq_disable_vblank(crtc);
>   
>   	tidss_runtime_put(tidss);
>   }
>   
> +static void tidss_crtc_destroy_state(struct drm_crtc *crtc,
> +				     struct drm_crtc_state *state)
> +{
> +	struct tidss_crtc_state *tstate = to_tidss_crtc_state(state);
> +
> +	__drm_atomic_helper_crtc_destroy_state(&tstate->base);
> +	kfree(tstate);
> +}
> +
>   static void tidss_crtc_reset(struct drm_crtc *crtc)
>   {
>   	struct tidss_crtc_state *tstate;
>   
>   	if (crtc->state)
> @@ -396,11 +405,11 @@ static const struct drm_crtc_funcs tidss_crtc_funcs = {
>   	.reset = tidss_crtc_reset,
>   	.destroy = tidss_crtc_destroy,
>   	.set_config = drm_atomic_helper_set_config,
>   	.page_flip = drm_atomic_helper_page_flip,
>   	.atomic_duplicate_state = tidss_crtc_duplicate_state,
> -	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
> +	.atomic_destroy_state = tidss_crtc_destroy_state,
>   	.enable_vblank = tidss_crtc_enable_vblank,
>   	.disable_vblank = tidss_crtc_disable_vblank,
>   };
>   
>   struct tidss_crtc *tidss_crtc_create(struct tidss_device *tidss,
>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
Re: (subset) [PATCH 21/29] drm/tidss: crtc: Implement destroy_state
Posted by Maxime Ripard 3 days, 1 hour ago
On Tue, 02 Sep 2025 10:32:49 +0200, Maxime Ripard wrote:
> The tidss crtc driver implements its own state, with its own
> implementation of reset and duplicate_state, but uses the default
> destroy_state helper.
> 
> This somewhat works for now because the drm_crtc_state field in
> tidss_crtc_state is the first field so the offset is 0, but it's pretty
> fragile and it should really have its own destroy_state implementation.
> 
> [...]

Applied to misc/kernel.git (drm-misc-next).

Thanks!
Maxime