[Intel-gfx] [PATCH i-g-t] kms_rotation_crc: Do not leak framebuffers during test duration

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Mon Apr 27 04:29:11 PDT 2015


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Test used to call prepare_crtc twice in the plane loop and leaked two
framebuffers per [subtest]x[pipe]x[plane].

What the loops really wants to do, instead of second invocation of
prepare_crtc, is to just turn on the display with the unrotated fb to
verify that the plane property has been restored by the VT transition
from previous to graphics mode.

To enable that factor out code which does that from prepare_crtc into
commit_crtc and call it instead.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Cc: Sonika Jindal <sonika.jindal at intel.com>
---
 tests/kms_rotation_crc.c | 59 +++++++++++++++++++++++++++---------------------
 1 file changed, 33 insertions(+), 26 deletions(-)

diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index 0661b6b..e16056d 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -87,19 +87,46 @@ paint_squares(data_t *data, drmModeModeInfo *mode, igt_rotation_t rotation,
 	cairo_destroy(cr);
 }
 
+static void commit_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	enum igt_commit_style commit = COMMIT_LEGACY;
+	igt_plane_t *primary;
+
+	/*
+	 * With igt_display_commit2 and COMMIT_UNIVERSAL, we call just the
+	 * setplane without a modeset. So, to be able to call
+	 * igt_display_commit and ultimately setcrtc to do the first modeset,
+	 * we create an fb covering the crtc and call commit
+	 */
+
+	primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+	igt_plane_set_fb(primary, &data->fb_modeset);
+	igt_display_commit(display);
+
+	igt_plane_set_fb(plane, &data->fb);
+
+	if (!plane->is_cursor)
+		igt_plane_set_position(plane, data->pos_x, data->pos_y);
+
+	if (plane->is_primary || plane->is_cursor) {
+		igt_require(data->display.has_universal_planes);
+		commit = COMMIT_UNIVERSAL;
+	}
+
+	igt_display_commit2(display, commit);
+}
+
 static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 			 igt_plane_t *plane)
 {
 	drmModeModeInfo *mode;
-	igt_display_t *display = &data->display;
 	int fb_id, fb_modeset_id;
 	unsigned int w, h;
 	uint64_t tiling = data->override_tiling ?
 			  data->override_tiling : LOCAL_DRM_FORMAT_MOD_NONE;
 	uint32_t pixel_format = data->override_fmt ?
 				data->override_fmt : DRM_FORMAT_XRGB8888;
-	enum igt_commit_style commit = COMMIT_LEGACY;
-	igt_plane_t *primary;
 
 	igt_output_set_pipe(output, pipe);
 
@@ -120,17 +147,6 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 	igt_assert(fb_modeset_id);
 
 	/*
-	 * With igt_display_commit2 and COMMIT_UNIVERSAL, we call just the
-	 * setplane without a modeset. So, to be able to call
-	 * igt_display_commit and ultimately setcrtc to do the first modeset,
-	 * we create an fb covering the crtc and call commit
-	 */
-
-	primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
-	igt_plane_set_fb(primary, &data->fb_modeset);
-	igt_display_commit(display);
-
-	/*
 	 * For 90/270, we will use create smaller fb so that the rotated
 	 * frame can fit in
 	 */
@@ -156,18 +172,8 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 	igt_assert(fb_id);
 
 	/* Step 1: create a reference CRC for a software-rotated fb */
-
 	paint_squares(data, mode, data->rotation, plane);
-	igt_plane_set_fb(plane, &data->fb);
-	if (!plane->is_cursor)
-		igt_plane_set_position(plane, data->pos_x, data->pos_y);
-
-	if (plane->is_primary || plane->is_cursor) {
-		igt_require(data->display.has_universal_planes);
-		commit = COMMIT_UNIVERSAL;
-	}
-
-	igt_display_commit2(display, commit);
+	commit_crtc(data, output, plane);
 	igt_pipe_crc_collect_crc(data->pipe_crc, &data->ref_crc);
 
 	/*
@@ -251,7 +257,8 @@ static void test_plane_rotation(data_t *data, enum igt_plane plane_type)
 			 */
 			kmstest_restore_vt_mode();
 			kmstest_set_vt_graphics_mode();
-			prepare_crtc(data, output, pipe, plane);
+
+			commit_crtc(data, output, plane);
 
 			igt_pipe_crc_collect_crc(data->pipe_crc, &crc_output);
 			igt_assert_crc_equal(&crc_unrotated, &crc_output);
-- 
2.3.5



More information about the Intel-gfx mailing list