drm: reset empty state in transitional helpers
diff mbox

Message ID 1435847633-22725-1-git-send-email-daniel.vetter@ffwll.ch
State New
Headers show

Commit Message

Daniel Vetter July 2, 2015, 2:33 p.m. UTC
Transitional drivers might not have all the state frobbing lined up
yet. But since the initial code has been merged a lot more state was
added, so we really need this.

Cc: Daniel Stone <daniels@collabora.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_crtc_helper.c  |  8 +++++---
 drivers/gpu/drm/drm_plane_helper.c | 16 ++++++++++------
 2 files changed, 15 insertions(+), 9 deletions(-)

Comments

John Hunter July 2, 2015, 2:39 p.m. UTC | #1
On Thu, Jul 2, 2015 at 10:33 PM, Daniel Vetter <daniel.vetter@ffwll.ch>
wrote:

> Transitional drivers might not have all the state frobbing lined up
> yet. But since the initial code has been merged a lot more state was
> added, so we really need this.
>
> Cc: Daniel Stone <daniels@collabora.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>
Tested-by: Zhao Junwang <zhjwpku@gmail.com>

> ---
>  drivers/gpu/drm/drm_crtc_helper.c  |  8 +++++---
>  drivers/gpu/drm/drm_plane_helper.c | 16 ++++++++++------
>  2 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_crtc_helper.c
> b/drivers/gpu/drm/drm_crtc_helper.c
> index 93104f3555f5..d3dfb0ebbeb2 100644
> --- a/drivers/gpu/drm/drm_crtc_helper.c
> +++ b/drivers/gpu/drm/drm_crtc_helper.c
> @@ -927,10 +927,12 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc,
> struct drm_display_mode *mod
>
>         if (crtc->funcs->atomic_duplicate_state)
>                 crtc_state = crtc->funcs->atomic_duplicate_state(crtc);
> -       else if (crtc->state)
> +       else {
> +               if (!crtc->state)
> +                       drm_atomic_helper_crtc_reset(crtc);
> +
>                 crtc_state = drm_atomic_helper_crtc_duplicate_state(crtc);
> -       else
> -               crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL);
> +       }
>
>         if (!crtc_state)
>                 return -ENOMEM;
> diff --git a/drivers/gpu/drm/drm_plane_helper.c
> b/drivers/gpu/drm/drm_plane_helper.c
> index 2f0ed11024eb..b07a213f5655 100644
> --- a/drivers/gpu/drm/drm_plane_helper.c
> +++ b/drivers/gpu/drm/drm_plane_helper.c
> @@ -525,10 +525,12 @@ int drm_plane_helper_update(struct drm_plane *plane,
> struct drm_crtc *crtc,
>
>         if (plane->funcs->atomic_duplicate_state)
>                 plane_state = plane->funcs->atomic_duplicate_state(plane);
> -       else if (plane->state)
> +       else {
> +               if (!plane->state)
> +                       drm_atomic_helper_plane_reset(plane);
> +
>                 plane_state =
> drm_atomic_helper_plane_duplicate_state(plane);
> -       else
> -               plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
> +       }
>         if (!plane_state)
>                 return -ENOMEM;
>         plane_state->plane = plane;
> @@ -572,10 +574,12 @@ int drm_plane_helper_disable(struct drm_plane *plane)
>
>         if (plane->funcs->atomic_duplicate_state)
>                 plane_state = plane->funcs->atomic_duplicate_state(plane);
> -       else if (plane->state)
> +       else {
> +               if (!plane->state)
> +                       drm_atomic_helper_plane_reset(plane);
> +
>                 plane_state =
> drm_atomic_helper_plane_duplicate_state(plane);
> -       else
> -               plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
> +       }
>         if (!plane_state)
>                 return -ENOMEM;
>         plane_state->plane = plane;
> --
> 2.1.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
Daniel Stone July 3, 2015, 7:10 a.m. UTC | #2
On Thursday, July 2, 2015, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:

> Transitional drivers might not have all the state frobbing lined up
> yet. But since the initial code has been merged a lot more state was
> added, so we really need this.
>
> Cc: Daniel Stone <daniels@collabora.com <javascript:;>>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com <javascript:;>>
>

Reviewed-by: Daniel Stone <daniels@collabora.com>

Patch
diff mbox

diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 93104f3555f5..d3dfb0ebbeb2 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -927,10 +927,12 @@  int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod
 
 	if (crtc->funcs->atomic_duplicate_state)
 		crtc_state = crtc->funcs->atomic_duplicate_state(crtc);
-	else if (crtc->state)
+	else {
+		if (!crtc->state)
+			drm_atomic_helper_crtc_reset(crtc);
+
 		crtc_state = drm_atomic_helper_crtc_duplicate_state(crtc);
-	else
-		crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL);
+	}
 
 	if (!crtc_state)
 		return -ENOMEM;
diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c
index 2f0ed11024eb..b07a213f5655 100644
--- a/drivers/gpu/drm/drm_plane_helper.c
+++ b/drivers/gpu/drm/drm_plane_helper.c
@@ -525,10 +525,12 @@  int drm_plane_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
 
 	if (plane->funcs->atomic_duplicate_state)
 		plane_state = plane->funcs->atomic_duplicate_state(plane);
-	else if (plane->state)
+	else {
+		if (!plane->state)
+			drm_atomic_helper_plane_reset(plane);
+
 		plane_state = drm_atomic_helper_plane_duplicate_state(plane);
-	else
-		plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
+	}
 	if (!plane_state)
 		return -ENOMEM;
 	plane_state->plane = plane;
@@ -572,10 +574,12 @@  int drm_plane_helper_disable(struct drm_plane *plane)
 
 	if (plane->funcs->atomic_duplicate_state)
 		plane_state = plane->funcs->atomic_duplicate_state(plane);
-	else if (plane->state)
+	else {
+		if (!plane->state)
+			drm_atomic_helper_plane_reset(plane);
+
 		plane_state = drm_atomic_helper_plane_duplicate_state(plane);
-	else
-		plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
+	}
 	if (!plane_state)
 		return -ENOMEM;
 	plane_state->plane = plane;