diff mbox

[i-g-t,1/3] igt_kms: Don't assume we have cursor planes if we have primary ones

Message ID 1479767559-9654-2-git-send-email-lyude@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lyude Paul Nov. 21, 2016, 10:32 p.m. UTC
On certain models of nvidia and AMD GPUs, we can have a primary plane
without any DRM plane for the cursor plane. Check for this so we don't
segfault on non-intel hardware.

Signed-off-by: Lyude <lyude@redhat.com>
---
 lib/igt_kms.c | 27 +++++++++++++++------------
 lib/igt_kms.h |  1 +
 2 files changed, 16 insertions(+), 12 deletions(-)

Comments

Tomeu Vizoso Dec. 7, 2016, 7:34 a.m. UTC | #1
On 21 November 2016 at 23:32, Lyude <lyude@redhat.com> wrote:
> On certain models of nvidia and AMD GPUs, we can have a primary plane
> without any DRM plane for the cursor plane. Check for this so we don't
> segfault on non-intel hardware.
>
> Signed-off-by: Lyude <lyude@redhat.com>
> ---
>  lib/igt_kms.c | 27 +++++++++++++++------------
>  lib/igt_kms.h |  1 +
>  2 files changed, 16 insertions(+), 12 deletions(-)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 433a721..13d323e 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -1419,7 +1419,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
>                                 plane = &pipe->planes[IGT_PLANE_CURSOR];
>                                 plane->is_cursor = 1;
>                                 plane->index = IGT_PLANE_CURSOR;
> -                               display->has_universal_planes = 1;
> +                               display->has_cursor_plane = 1;

Looks good to me, but Daniel Vetter voiced support the other day for
dropping support for !has_universal_planes so it may not be a good
idea to complicate this further.

But if we go this way, the has_cursor_plane name could be misleading
in the !universal_plane case if there's a cursor plane.

Regards,

Tomeu

>                                 break;
>                         default:
>                                 plane = &pipe->planes[p];
> @@ -1444,9 +1444,20 @@ void igt_display_init(igt_display_t *display, int drm_fd)
>                         plane->rotation = (igt_rotation_t)prop_value;
>                 }
>
> -               if (display->has_universal_planes) {
> +               if (!display->has_universal_planes) {
> +                       /*
> +                        * No universal plane support.  Add drm_plane-less
> +                        * primary and cursor planes.
> +                        */
> +                       plane = &pipe->planes[IGT_PLANE_PRIMARY];
> +                       plane->pipe = pipe;
> +                       plane->index = IGT_PLANE_PRIMARY;
> +                       plane->is_primary = true;
> +               }
> +
> +               if (display->has_cursor_plane) {
>                         /*
> -                        * If we have universal planes, we should have both
> +                        * If we have a cursor plane, we should have both
>                          * primary and cursor planes setup now.
>                          */
>                         igt_assert(pipe->planes[IGT_PLANE_PRIMARY].drm_plane &&
> @@ -1464,15 +1475,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
>                                        sizeof *plane);
>                         }
>                 } else {
> -                       /*
> -                        * No universal plane support.  Add drm_plane-less
> -                        * primary and cursor planes.
> -                        */
> -                       plane = &pipe->planes[IGT_PLANE_PRIMARY];
> -                       plane->pipe = pipe;
> -                       plane->index = IGT_PLANE_PRIMARY;
> -                       plane->is_primary = true;
> -
> +                       /* Add drm_plane-less cursor */
>                         plane = &pipe->planes[p];
>                         plane->pipe = pipe;
>                         plane->index = p;
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 95395cd..95d81c3 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -312,6 +312,7 @@ struct igt_display {
>         igt_output_t *outputs;
>         igt_pipe_t pipes[I915_MAX_PIPES];
>         bool has_universal_planes;
> +       bool has_cursor_plane;
>         bool is_atomic;
>  };
>
> --
> 2.7.4
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 433a721..13d323e 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1419,7 +1419,7 @@  void igt_display_init(igt_display_t *display, int drm_fd)
 				plane = &pipe->planes[IGT_PLANE_CURSOR];
 				plane->is_cursor = 1;
 				plane->index = IGT_PLANE_CURSOR;
-				display->has_universal_planes = 1;
+				display->has_cursor_plane = 1;
 				break;
 			default:
 				plane = &pipe->planes[p];
@@ -1444,9 +1444,20 @@  void igt_display_init(igt_display_t *display, int drm_fd)
 			plane->rotation = (igt_rotation_t)prop_value;
 		}
 
-		if (display->has_universal_planes) {
+		if (!display->has_universal_planes) {
+			/*
+			 * No universal plane support.  Add drm_plane-less
+			 * primary and cursor planes.
+			 */
+			plane = &pipe->planes[IGT_PLANE_PRIMARY];
+			plane->pipe = pipe;
+			plane->index = IGT_PLANE_PRIMARY;
+			plane->is_primary = true;
+		}
+
+		if (display->has_cursor_plane) {
 			/*
-			 * If we have universal planes, we should have both
+			 * If we have a cursor plane, we should have both
 			 * primary and cursor planes setup now.
 			 */
 			igt_assert(pipe->planes[IGT_PLANE_PRIMARY].drm_plane &&
@@ -1464,15 +1475,7 @@  void igt_display_init(igt_display_t *display, int drm_fd)
 				       sizeof *plane);
 			}
 		} else {
-			/*
-			 * No universal plane support.  Add drm_plane-less
-			 * primary and cursor planes.
-			 */
-			plane = &pipe->planes[IGT_PLANE_PRIMARY];
-			plane->pipe = pipe;
-			plane->index = IGT_PLANE_PRIMARY;
-			plane->is_primary = true;
-
+			/* Add drm_plane-less cursor */
 			plane = &pipe->planes[p];
 			plane->pipe = pipe;
 			plane->index = p;
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 95395cd..95d81c3 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -312,6 +312,7 @@  struct igt_display {
 	igt_output_t *outputs;
 	igt_pipe_t pipes[I915_MAX_PIPES];
 	bool has_universal_planes;
+	bool has_cursor_plane;
 	bool is_atomic;
 };