public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: stanislav.lisovskiy@intel.com, ville.syrjala@intel.com,
	martin.peres@intel.com, juha-pekka.heikkila@intel.com
Subject: [igt-dev] [PATCH i-g-t v8 3/3] igt/tests/kms_atomic_transition: Tolerate if can't have all planes
Date: Tue,  9 Apr 2019 21:03:19 +0300	[thread overview]
Message-ID: <20190409180319.23410-4-stanislav.lisovskiy@intel.com> (raw)
In-Reply-To: <20190409180319.23410-1-stanislav.lisovskiy@intel.com>

With some upcoming changes i915 might not allow
all sprite planes enabled, depending on available
bandwidth limitation. Thus the test need to decrement
amount of planes and try again, instead of panicking.

v2: Removed excessive nested conditions, making code a bit
    more readable(hopefully).

v3: Stopped using global n_planes variable as it might cause
    resources being unreleased.
    Using now parms[i].mask as a way to determine if plane
    has to be included into commit.

v4: Removed unneeded n_overlays initialization.

v5: Randomize which of sprite planes to remove if hitting
    resource limits.

v6: Replace igt_warn with igt_info, to make IGT tests happier.

v7: Removed unneeded retry logic, made plane random removal simplier.
    Great thanks to Maarten Lankhorst for suggestions.

v8: Fail if we have less than 3 planes

Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
---
 tests/kms_atomic_transition.c | 102 ++++++++++++++++++----------------
 1 file changed, 55 insertions(+), 47 deletions(-)

diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index 883f5a9b..5753bed9 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -184,6 +184,9 @@ static void set_sprite_wh(igt_display_t *display, enum pipe pipe,
 		    plane->type == DRM_PLANE_TYPE_CURSOR)
 			continue;
 
+		if (!parms[i].mask)
+			continue;
+
 		parms[i].width = w;
 		parms[i].height = h;
 	}
@@ -212,9 +215,10 @@ static void setup_parms(igt_display_t *display, enum pipe pipe,
 	unsigned sprite_width, sprite_height, prev_w, prev_h;
 	bool max_sprite_width, max_sprite_height, alpha = true;
 	uint32_t n_planes = display->pipes[pipe].n_planes;
-	uint32_t n_overlays = 0, overlays[n_planes];
+	uint32_t n_overlays, overlays[n_planes];
 	igt_plane_t *plane;
-	uint32_t iter_mask = 3;
+	uint32_t iter_mask;
+	int ret = 0;
 
 	do_or_die(drmGetCap(display->drm_fd, DRM_CAP_CURSOR_WIDTH, &cursor_width));
 	if (cursor_width >= mode->hdisplay)
@@ -224,6 +228,9 @@ static void setup_parms(igt_display_t *display, enum pipe pipe,
 	if (cursor_height >= mode->vdisplay)
 		cursor_height = mode->vdisplay;
 
+	n_overlays = 0;
+	iter_mask = 3;
+
 	for_each_plane_on_pipe(display, pipe, plane) {
 		int i = plane->index;
 
@@ -243,9 +250,7 @@ static void setup_parms(igt_display_t *display, enum pipe pipe,
 					DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE);
 			parms[i].fb = sprite_fb;
 			parms[i].mask = 1 << 2;
-
 			iter_mask |= 1 << 2;
-
 			overlays[n_overlays++] = i;
 		}
 	}
@@ -287,9 +292,7 @@ static void setup_parms(igt_display_t *display, enum pipe pipe,
 	max_sprite_width = (sprite_width == mode->hdisplay);
 	max_sprite_height = (sprite_height == mode->vdisplay);
 
-	while (1) {
-		int ret;
-
+	while (!max_sprite_width && !max_sprite_height) {
 		set_sprite_wh(display, pipe, parms, sprite_fb,
 			      alpha, sprite_width, sprite_height);
 
@@ -297,52 +300,59 @@ static void setup_parms(igt_display_t *display, enum pipe pipe,
 		ret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
 		igt_assert(!is_atomic_check_failure_errno(ret));
 
-		if (is_atomic_check_plane_size_errno(ret)) {
-			if (cursor_width == sprite_width &&
-			    cursor_height == sprite_height) {
-				igt_assert_f(alpha,
-					      "Cannot configure the test with all sprite planes enabled\n");
-			}
-
-			sprite_width = prev_w;
-			sprite_height = prev_h;
-
-			if (max_sprite_width && max_sprite_height) {
-				set_sprite_wh(display, pipe, parms, sprite_fb,
-					      alpha, sprite_width, sprite_height);
-				break;
-			}
-
-			if (!max_sprite_width)
-				max_sprite_width = true;
-			else
-				max_sprite_height = true;
-		} else {
+		if (!is_atomic_check_plane_size_errno(ret)) {
 			prev_w = sprite_width;
 			prev_h = sprite_height;
-		}
-
-		if (!max_sprite_width) {
-			sprite_width *= 2;
-
+    
+			sprite_width *= max_sprite_width ? 1 : 2;
 			if (sprite_width >= mode->hdisplay) {
 				max_sprite_width = true;
-
 				sprite_width = mode->hdisplay;
 			}
-		} else if (!max_sprite_height) {
-			sprite_height *= 2;
 
+			sprite_height *= max_sprite_height ? 1 : 2;
 			if (sprite_height >= mode->vdisplay) {
 				max_sprite_height = true;
-
 				sprite_height = mode->vdisplay;
 			}
-		} else
-			/* Max sized sprites for all! */
-			break;
+			continue;
+		}
+
+		if (cursor_width == sprite_width &&
+		    cursor_height == sprite_height) {
+			igt_plane_t *removed_plane = NULL;
+			igt_assert_f(n_planes >= 3, "No planes left to proceed with!");
+			if (n_overlays > 0) {
+				uint32_t plane_to_remove = hars_petruska_f54_1_random_unsafe_max(n_overlays);
+				removed_plane = &display->pipes[pipe].planes[overlays[plane_to_remove]];
+				igt_plane_set_fb(removed_plane, NULL);
+				while (plane_to_remove < (n_overlays - 1)) {
+					overlays[plane_to_remove] = overlays[plane_to_remove + 1];
+					plane_to_remove++;
+				}
+				n_overlays--;
+			}
+			if (removed_plane) {
+				parms[removed_plane->index].mask = 0;
+				igt_info("Removed plane %d\n", removed_plane->index);
+			}
+			n_planes--;
+			igt_info("Reduced available planes to %d\n", n_planes);
+			continue;
+		}
+
+		sprite_width = prev_w;
+		sprite_height = prev_h;
+
+		if (!max_sprite_width)
+			max_sprite_width = true;
+		else
+			max_sprite_height = true;
 	}
 
+	set_sprite_wh(display, pipe, parms, sprite_fb,
+			alpha, sprite_width, sprite_height);
+
 	igt_info("Running test on pipe %s with resolution %dx%d and sprite size %dx%d alpha %i\n",
 		 kmstest_pipe_name(pipe), mode->hdisplay, mode->vdisplay,
 		 sprite_width, sprite_height, alpha);
@@ -434,7 +444,7 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output
 	uint32_t iter_max, i;
 	struct plane_parms parms[pipe_obj->n_planes];
 	unsigned flags = 0;
-	int ret;
+	int ret = 0;
 
 	if (fencing)
 		prepare_fencing(display, pipe);
@@ -461,7 +471,6 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output
 
 	if (flags & DRM_MODE_ATOMIC_ALLOW_MODESET) {
 		igt_output_set_pipe(output, PIPE_NONE);
-
 		igt_display_commit2(display, COMMIT_ATOMIC);
 
 		igt_output_set_pipe(output, pipe);
@@ -496,9 +505,6 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output
 			    plane->type == DRM_PLANE_TYPE_CURSOR)
 				continue;
 
-			if (parms[i].width <= 512)
-				continue;
-
 			parms[i].width /= 2;
 			ret = 1;
 			igt_info("Reducing sprite %i to %ux%u\n", i - 1, parms[i].width, parms[i].height);
@@ -523,8 +529,10 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output
 		}
 
 		/* force planes to be part of commit */
-		for_each_plane_on_pipe(display, pipe, plane)
-			igt_plane_set_position(plane, 0, 0);
+		for_each_plane_on_pipe(display, pipe, plane) {
+			if (parms[plane->index].mask)
+				igt_plane_set_position(plane, 0, 0);
+		}
 
 		igt_display_commit2(display, COMMIT_ATOMIC);
 
-- 
2.17.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2019-04-09 18:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-09 18:03 [igt-dev] [PATCH i-g-t v8 0/3] kms_atomic_transition improvements Stanislav Lisovskiy
2019-04-09 18:03 ` [igt-dev] [PATCH i-g-t v8 1/3] igt/tests: Remove redundant alpha retry Stanislav Lisovskiy
2019-04-09 18:03 ` [igt-dev] [PATCH i-g-t v8 2/3] igt/tests/kms_atomic_transition: Skip transition, if no changes done Stanislav Lisovskiy
2019-04-09 18:03 ` Stanislav Lisovskiy [this message]
2019-04-09 19:13 ` [igt-dev] ✓ Fi.CI.BAT: success for kms_atomic_transition improvements (rev16) Patchwork
2019-04-10  8:32 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190409180319.23410-4-stanislav.lisovskiy@intel.com \
    --to=stanislav.lisovskiy@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=juha-pekka.heikkila@intel.com \
    --cc=martin.peres@intel.com \
    --cc=ville.syrjala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox