[16/17] drm/vkms: Convert to using __drm_atomic_helper_crtc_reset() for reset.
diff mbox series

Message ID 20190301125627.7285-17-maarten.lankhorst@linux.intel.com
State New
Headers show
Series
  • drm: Start subclassing crtc_state.
Related show

Commit Message

Maarten Lankhorst March 1, 2019, 12:56 p.m. UTC
Convert vkms to using __drm_atomic_helper_crtc_reset(), instead of
writing its own version. Instead of open coding destroy_state(),
call it directly for freeing the old state.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
---
 drivers/gpu/drm/vkms/vkms_crtc.c | 33 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 20 deletions(-)

Comments

Rodrigo Siqueira March 6, 2019, 10:43 p.m. UTC | #1
On 03/01, Maarten Lankhorst wrote:
> Convert vkms to using __drm_atomic_helper_crtc_reset(), instead of
> writing its own version. Instead of open coding destroy_state(),
> call it directly for freeing the old state.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
> Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> ---
>  drivers/gpu/drm/vkms/vkms_crtc.c | 33 +++++++++++++-------------------
>  1 file changed, 13 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
> index 8a9aeb0a9ea8..550888e72c96 100644
> --- a/drivers/gpu/drm/vkms/vkms_crtc.c
> +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
> @@ -83,26 +83,6 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
>  	return true;
>  }
>  
> -static void vkms_atomic_crtc_reset(struct drm_crtc *crtc)
> -{
> -	struct vkms_crtc_state *vkms_state = NULL;
> -
> -	if (crtc->state) {
> -		vkms_state = to_vkms_crtc_state(crtc->state);
> -		__drm_atomic_helper_crtc_destroy_state(crtc->state);
> -		kfree(vkms_state);
> -		crtc->state = NULL;
> -	}
> -
> -	vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL);
> -	if (!vkms_state)
> -		return;
> -	INIT_WORK(&vkms_state->crc_work, vkms_crc_work_handle);
> -
> -	crtc->state = &vkms_state->base;
> -	crtc->state->crtc = crtc;
> -}
> -
>  static struct drm_crtc_state *
>  vkms_atomic_crtc_duplicate_state(struct drm_crtc *crtc)
>  {
> @@ -135,6 +115,19 @@ static void vkms_atomic_crtc_destroy_state(struct drm_crtc *crtc,
>  	}
>  }
>  
> +static void vkms_atomic_crtc_reset(struct drm_crtc *crtc)
> +{
> +	struct vkms_crtc_state *vkms_state =
> +		kzalloc(sizeof(*vkms_state), GFP_KERNEL);
> +
> +	if (crtc->state)
> +		vkms_atomic_crtc_destroy_state(crtc, crtc->state);
> +
> +	__drm_atomic_helper_crtc_reset(crtc, &vkms_state->base);
> +	if (vkms_state)
> +		INIT_WORK(&vkms_state->crc_work, vkms_crc_work_handle);
> +}
> +
>  static const struct drm_crtc_funcs vkms_crtc_funcs = {
>  	.set_config             = drm_atomic_helper_set_config,
>  	.destroy                = drm_crtc_cleanup,
> -- 
> 2.20.1
> 

Hi Maarten,

First of all, thanks for the patch :)

I tested it on my VM with the IGT test, and everything looks fine.

Reviewed-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Maarten Lankhorst April 25, 2019, 9:41 a.m. UTC | #2
Op 06-03-2019 om 23:43 schreef Rodrigo Siqueira:
> On 03/01, Maarten Lankhorst wrote:
>> Convert vkms to using __drm_atomic_helper_crtc_reset(), instead of
>> writing its own version. Instead of open coding destroy_state(),
>> call it directly for freeing the old state.
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
>> Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
>> Cc: Daniel Vetter <daniel@ffwll.ch>
>> ---
>>  drivers/gpu/drm/vkms/vkms_crtc.c | 33 +++++++++++++-------------------
>>  1 file changed, 13 insertions(+), 20 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
>> index 8a9aeb0a9ea8..550888e72c96 100644
>> --- a/drivers/gpu/drm/vkms/vkms_crtc.c
>> +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
>> @@ -83,26 +83,6 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
>>  	return true;
>>  }
>>  
>> -static void vkms_atomic_crtc_reset(struct drm_crtc *crtc)
>> -{
>> -	struct vkms_crtc_state *vkms_state = NULL;
>> -
>> -	if (crtc->state) {
>> -		vkms_state = to_vkms_crtc_state(crtc->state);
>> -		__drm_atomic_helper_crtc_destroy_state(crtc->state);
>> -		kfree(vkms_state);
>> -		crtc->state = NULL;
>> -	}
>> -
>> -	vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL);
>> -	if (!vkms_state)
>> -		return;
>> -	INIT_WORK(&vkms_state->crc_work, vkms_crc_work_handle);
>> -
>> -	crtc->state = &vkms_state->base;
>> -	crtc->state->crtc = crtc;
>> -}
>> -
>>  static struct drm_crtc_state *
>>  vkms_atomic_crtc_duplicate_state(struct drm_crtc *crtc)
>>  {
>> @@ -135,6 +115,19 @@ static void vkms_atomic_crtc_destroy_state(struct drm_crtc *crtc,
>>  	}
>>  }
>>  
>> +static void vkms_atomic_crtc_reset(struct drm_crtc *crtc)
>> +{
>> +	struct vkms_crtc_state *vkms_state =
>> +		kzalloc(sizeof(*vkms_state), GFP_KERNEL);
>> +
>> +	if (crtc->state)
>> +		vkms_atomic_crtc_destroy_state(crtc, crtc->state);
>> +
>> +	__drm_atomic_helper_crtc_reset(crtc, &vkms_state->base);
>> +	if (vkms_state)
>> +		INIT_WORK(&vkms_state->crc_work, vkms_crc_work_handle);
>> +}
>> +
>>  static const struct drm_crtc_funcs vkms_crtc_funcs = {
>>  	.set_config             = drm_atomic_helper_set_config,
>>  	.destroy                = drm_crtc_cleanup,
>> -- 
>> 2.20.1
>>
> Hi Maarten,
>
> First of all, thanks for the patch :)
>
> I tested it on my VM with the IGT test, and everything looks fine.
>
> Reviewed-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
>
Thanks, pushed patches 1-3, and rockchip, tegra, msm, vkms, mali and i915 patches with reviews. :)

Will resend the rest of the series and address the feedback.

Patch
diff mbox series

diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
index 8a9aeb0a9ea8..550888e72c96 100644
--- a/drivers/gpu/drm/vkms/vkms_crtc.c
+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
@@ -83,26 +83,6 @@  bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 	return true;
 }
 
-static void vkms_atomic_crtc_reset(struct drm_crtc *crtc)
-{
-	struct vkms_crtc_state *vkms_state = NULL;
-
-	if (crtc->state) {
-		vkms_state = to_vkms_crtc_state(crtc->state);
-		__drm_atomic_helper_crtc_destroy_state(crtc->state);
-		kfree(vkms_state);
-		crtc->state = NULL;
-	}
-
-	vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL);
-	if (!vkms_state)
-		return;
-	INIT_WORK(&vkms_state->crc_work, vkms_crc_work_handle);
-
-	crtc->state = &vkms_state->base;
-	crtc->state->crtc = crtc;
-}
-
 static struct drm_crtc_state *
 vkms_atomic_crtc_duplicate_state(struct drm_crtc *crtc)
 {
@@ -135,6 +115,19 @@  static void vkms_atomic_crtc_destroy_state(struct drm_crtc *crtc,
 	}
 }
 
+static void vkms_atomic_crtc_reset(struct drm_crtc *crtc)
+{
+	struct vkms_crtc_state *vkms_state =
+		kzalloc(sizeof(*vkms_state), GFP_KERNEL);
+
+	if (crtc->state)
+		vkms_atomic_crtc_destroy_state(crtc, crtc->state);
+
+	__drm_atomic_helper_crtc_reset(crtc, &vkms_state->base);
+	if (vkms_state)
+		INIT_WORK(&vkms_state->crc_work, vkms_crc_work_handle);
+}
+
 static const struct drm_crtc_funcs vkms_crtc_funcs = {
 	.set_config             = drm_atomic_helper_set_config,
 	.destroy                = drm_crtc_cleanup,