Skip to contentSkip to conversation

lib/igt_fb: don't forget to close parens on message printed

PATCH New Paulo Zanoni 1 participant 6 messages Oct 5, 2015 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 lib/igt_fb: don't forget to close parens on message printed

Restore the anxiety levels back to the normal values.

---
 lib/igt_fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/igt_fb.c +1 -1
index 1234ed9..d04f02c 100644
@@ -424,7 +424,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
 
 	bpp = igt_drm_format_to_bpp(format);
 
-	igt_debug("%s(width=%d, height=%d, format=0x%x [bpp=%d], tiling=0x%"PRIx64", size=%d\n",
+	igt_debug("%s(width=%d, height=%d, format=0x%x [bpp=%d], tiling=0x%"PRIx64", size=%d)\n",
 		  __func__, width, height, format, bpp, tiling, bo_size);
 	do_or_die(create_bo_for_fb(fd, width, height, bpp, tiling, bo_size,
 				   &fb->gem_handle, &fb->size, &fb->stride));
Signature · 6 lines
2.5.3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/6 kms_frontbuffer_tracking: change pattern 1's last rect to 1x1

Make sure the tracking mechanism is able to track a write in the very last pixel.

---
 tests/kms_frontbuffer_tracking.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tests/kms_frontbuffer_tracking.c +4 -4
index 971e3e9..88a7384 100644
@@ -903,10 +903,10 @@ static struct rect pat1_get_rect(struct fb_region *fb, int r)
 		rect.color = pick_color(fb->fb, COLOR_MAGENTA);
 		break;
 	case 3:
-		rect.x = fb->w - 64;
-		rect.y = fb->h - 64;
-		rect.w = 64;
-		rect.h = 64;
+		rect.x = fb->w - 1;
+		rect.y = fb->h - 1;
+		rect.w = 1;
+		rect.h = 1;
 		rect.color = pick_color(fb->fb, COLOR_CYAN);
 		break;
 	default:
Signature · 6 lines
2.5.3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 3/6 kms_frontbuffer_tracking: set the universal planes cap in the setup

In reply to Paulo Zanoni

... instead of just setting it for the fullscreen_plane subtest and then unsetting it. We want to use it more, so just make sure all the code knows how to deal with multiple planes per CRTC.

This also allows us to do some upfront caching of the plane information, so the code for the tests gets simpler.

There's a new test that's going to use all these changes.

---
 tests/kms_frontbuffer_tracking.c | 133 ++++++++++++++-------------------------
 1 file changed, 46 insertions(+), 87 deletions(-)
tests/kms_frontbuffer_tracking.c +46 -87
index 88a7384..6692dd8 100644
@@ -144,11 +144,14 @@ struct rect {
 };
 
 #define MAX_CONNECTORS 32
+#define MAX_PLANES 32
 struct {
 	int fd;
 	drmModeResPtr res;
 	drmModeConnectorPtr connectors[MAX_CONNECTORS];
-	drmModePlaneResPtr planes;
+	drmModePlaneResPtr plane_res;
+	drmModePlanePtr planes[MAX_PLANES];
+	uint64_t plane_types[MAX_PLANES];
 	drm_intel_bufmgr *bufmgr;
 } drm;
 
@@ -367,17 +370,11 @@ static void init_mode_params(struct modeset_params *params, uint32_t crtc_id,
 	uint32_t plane_id = 0;
 	int i;
 
-	for (i = 0; i < drm.planes->count_planes && plane_id == 0; i++) {
-		drmModePlanePtr plane;
+	for (i = 0; i < drm.plane_res->count_planes && plane_id == 0; i++)
+		if ((drm.planes[i]->possible_crtcs & (1 << crtc_index)) &&
+		    drm.plane_types[i] == DRM_PLANE_TYPE_OVERLAY)
+			plane_id = drm.planes[i]->plane_id;
 
-		plane = drmModeGetPlane(drm.fd, drm.planes->planes[i]);
-		igt_assert(plane);
-
-		if (plane->possible_crtcs & (1 << crtc_index))
-			plane_id = plane->plane_id;
-
-		drmModeFreePlane(plane);
-	}
 	igt_assert(plane_id);
 
 	params->crtc_id = crtc_id;
@@ -1069,9 +1066,9 @@ static void unset_all_crtcs(void)
 		igt_assert(rc == 0);
 	}
 
-	for (i = 0; i < drm.planes->count_planes; i++) {
-		rc = drmModeSetPlane(drm.fd, drm.planes->planes[i], 0, 0, 0, 0,
-				     0, 0, 0, 0, 0, 0, 0);
+	for (i = 0; i < drm.plane_res->count_planes; i++) {
+		rc = drmModeSetPlane(drm.fd, drm.plane_res->planes[i], 0, 0, 0,
+				     0, 0, 0, 0, 0, 0, 0, 0);
 		igt_assert(rc == 0);
 	}
 }
@@ -1240,9 +1237,25 @@ static void init_crcs(enum pixel_format format,
 	pattern->initialized[format] = true;
 }
 
+static uint64_t get_plane_type(uint32_t plane_id)
+{
+	bool found;
+	uint64_t prop_value;
+	drmModePropertyPtr prop;
+
+	found = kmstest_get_property(drm.fd, plane_id, DRM_MODE_OBJECT_PLANE,
+				     "type", NULL, &prop_value, &prop);
+	igt_assert(found);
+	igt_assert(prop->flags & DRM_MODE_PROP_ENUM);
+	igt_assert(prop_value < prop->count_enums);
+
+	drmModeFreeProperty(prop);
+	return prop_value;
+}
+
 static void setup_drm(void)
 {
-	int i;
+	int i, rc;
 
 	drm.fd = drm_open_driver_master(DRIVER_INTEL);
 
@@ -1253,7 +1266,16 @@ static void setup_drm(void)
 		drm.connectors[i] = drmModeGetConnector(drm.fd,
 						drm.res->connectors[i]);
 
-	drm.planes = drmModeGetPlaneResources(drm.fd);
+	rc = drmSetClientCap(drm.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
+	igt_require(rc == 0);
+
+	drm.plane_res = drmModeGetPlaneResources(drm.fd);
+	igt_assert(drm.plane_res->count_planes <= MAX_PLANES);
+
+	for (i = 0; i < drm.plane_res->count_planes; i++) {
+		drm.planes[i] = drmModeGetPlane(drm.fd, drm.plane_res->planes[i]);
+		drm.plane_types[i] = get_plane_type(drm.plane_res->planes[i]);
+	}
 
 	drm.bufmgr = drm_intel_bufmgr_gem_init(drm.fd, 4096);
 	igt_assert(drm.bufmgr);
@@ -1266,7 +1288,9 @@ static void teardown_drm(void)
 
 	drm_intel_bufmgr_destroy(drm.bufmgr);
 
-	drmModeFreePlaneResources(drm.planes);
+	for (i = 0; i < drm.plane_res->count_planes; i++)
+		drmModeFreePlane(drm.planes[i]);
+	drmModeFreePlaneResources(drm.plane_res);
 
 	for (i = 0; i < drm.res->count_connectors; i++)
 		drmModeFreeConnector(drm.connectors[i]);
@@ -2383,91 +2407,26 @@ static void onoff_subtest(const struct test_mode *t)
 	}
 }
 
-static bool plane_is_primary(uint32_t plane_id)
-{
-	int i;
-	bool found, is_primary;
-	uint64_t prop_value;
-	drmModePropertyPtr prop;
-	const char *enum_name = NULL;
-
-	found = kmstest_get_property(drm.fd, plane_id, DRM_MODE_OBJECT_PLANE,
-				     "type", NULL, &prop_value, &prop);
-	if (!found) {
-		igt_debug("Property not found\n");
-		return false;
-	}
-	if (!(prop->flags & DRM_MODE_PROP_ENUM)) {
-		igt_debug("Property is not an enum\n");
-		return false;
-	}
-	if (prop_value >= prop->count_enums) {
-		igt_debug("Bad property value\n");
-		return false;
-	}
-
-	for (i = 0; i < prop->count_enums; i++) {
-		if (prop->enums[i].value == prop_value) {
-			enum_name = prop->enums[i].name;
-			break;
-		}
-	}
-	if (!enum_name) {
-		igt_debug("Enum name not found\n");
-		return false;
-	}
-
-	is_primary = (strcmp(enum_name, "Primary") == 0);
-	drmModeFreeProperty(prop);
-	return is_primary;
-}
-
 static bool prim_plane_disabled(void)
 {
 	int i, rc;
 	bool disabled, found = false;
-	drmModePlaneResPtr planes;
-
-	rc = drmSetClientCap(drm.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
-	igt_assert(rc == 0);
-
-	planes = drmModeGetPlaneResources(drm.fd);
-	for (i = 0; i < planes->count_planes; i++) {
-		drmModePlanePtr plane;
-
-		plane = drmModeGetPlane(drm.fd, planes->planes[i]);
-		if (!plane) {
-			igt_debug("Failed to get plane\n");
-			goto fail;
-		}
 
+	for (i = 0; i < drm.plane_res->count_planes; i++) {
 		/* We just pick the first CRTC for the primary plane. */
-		if ((plane->possible_crtcs & 0x1) &&
-		    plane_is_primary(plane->plane_id)) {
+		if ((drm.planes[i]->possible_crtcs & 0x1) &&
+		    drm.plane_types[i] == DRM_PLANE_TYPE_PRIMARY) {
 			found = true;
-			disabled = (plane->crtc_id == 0);
+			disabled = (drm.planes[i]->crtc_id == 0);
 		}
-		drmModeFreePlane(plane);
 	}
-	drmModeFreePlaneResources(planes);
 
-	if (!found) {
-		igt_debug("Primary plane not found\n");
-		goto fail;
-	}
+	igt_assert(found);
 
 	rc = drmSetClientCap(drm.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 0);
 	igt_assert(rc == 0);
 
 	return disabled;
-
-fail:
-	/* Make sure we do this before failing any assertions so we don't mess
-	 * the other subtests. */
-	rc = drmSetClientCap(drm.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 0);
-	igt_assert(rc == 0);
-	igt_assert(false);
-	return false;
 }
 
 /*
Signature · 6 lines
2.5.3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH 4/6 kms_frontbuffer_tracking: add scaledprimary subtest

In reply to Paulo Zanoni

It's not testing a lot since we lack the Kernel Stolen Memory Checker, but some day this will be useful.

---
 tests/kms_frontbuffer_tracking.c | 131 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 131 insertions(+)
tests/kms_frontbuffer_tracking.c +131 -0
index 6692dd8..47fc0c8 100644
@@ -2496,6 +2496,125 @@ static void fullscreen_plane_subtest(const struct test_mode *t)
 	igt_remove_fb(drm.fd, &fullscreen_fb);
 }
 
+/*
+ * scaledprimary - try different primary plane scaling strategies
+ *
+ * METHOD
+ *    Enable the primary plane, use drmModeSetPlane to force scaling in
+ *    different ways.
+ *
+ * EXPECTED RESULTS
+ *   SKIP on platforms that don't support primary plane scaling. Success on all
+ *   others.
+ *
+ * FAILURES
+ *   TODO: although we're exercising the code here, we're not really doing
+ *   assertions in order to check if things are working properly. The biggest
+ *   issue this code would be able to find would be an incorrectly calculated
+ *   CFB size, and today we don't have means to assert this. One day we might
+ *   implement some sort of stolen memory checking mechanism, then we'll be able
+ *   to force it to run after every drmModeSetPlane call here, so we'll be
+ *   checking if the expected CFB size is actually what we think it is.
+ */
+static void scaledprimary_subtest(const struct test_mode *t)
+{
+	struct igt_fb new_fb, *old_fb;
+	struct modeset_params *params = pick_params(t);
+	int i, rc;
+	uint32_t plane_id;
+
+	igt_require_f(intel_gen(intel_get_drm_devid(drm.fd)) >= 9,
+		      "Can't test primary plane scaling before gen 9\n");
+
+	prepare_subtest(t, NULL);
+
+	old_fb = params->fb.fb;
+
+	create_fb(t->format, params->fb.fb->width, params->fb.fb->height,
+		  LOCAL_I915_FORMAT_MOD_X_TILED,
+		  t->plane, &new_fb);
+	fill_fb(&new_fb, COLOR_BLUE);
+
+	igt_draw_rect_fb(drm.fd, drm.bufmgr, NULL, &new_fb, t->method,
+			 params->fb.x, params->fb.y,
+			 params->fb.w / 2, params->fb.h / 2,
+			 pick_color(&new_fb, COLOR_GREEN));
+	igt_draw_rect_fb(drm.fd, drm.bufmgr, NULL, &new_fb, t->method,
+			 params->fb.x + params->fb.w / 2,
+			 params->fb.y + params->fb.h / 2,
+			 params->fb.w / 2, params->fb.h / 2,
+			 pick_color(&new_fb, COLOR_RED));
+	igt_draw_rect_fb(drm.fd, drm.bufmgr, NULL, &new_fb, t->method,
+			 params->fb.x + params->fb.w / 2,
+			 params->fb.y + params->fb.h / 2,
+			 params->fb.w / 4, params->fb.h / 4,
+			 pick_color(&new_fb, COLOR_MAGENTA));
+
+	for (i = 0; i < drm.plane_res->count_planes; i++)
+		if ((drm.planes[i]->possible_crtcs & 1) &&
+		    drm.plane_types[i] == DRM_PLANE_TYPE_PRIMARY)
+			plane_id = drm.planes[i]->plane_id;
+
+	/* No scaling. */
+	rc = drmModeSetPlane(drm.fd, plane_id, params->crtc_id,
+			     new_fb.fb_id, 0,
+			     0, 0,
+			     params->mode->hdisplay, params->mode->vdisplay,
+			     params->fb.x << 16, params->fb.y << 16,
+			     params->fb.w << 16, params->fb.h << 16);
+	igt_assert(rc == 0);
+	do_assertions(DONT_ASSERT_CRC);
+
+	/* Source upscaling. */
+	rc = drmModeSetPlane(drm.fd, plane_id, params->crtc_id,
+			     new_fb.fb_id, 0,
+			     0, 0,
+			     params->mode->hdisplay, params->mode->vdisplay,
+			     params->fb.x << 16, params->fb.y << 16,
+			     (params->fb.w / 2) << 16,
+			     (params->fb.h / 2) << 16);
+	igt_assert(rc == 0);
+	do_assertions(DONT_ASSERT_CRC);
+
+	/* Destination doesn't fill the entire CRTC, no scaling. */
+	rc = drmModeSetPlane(drm.fd, plane_id, params->crtc_id,
+			     new_fb.fb_id, 0,
+			     params->mode->hdisplay / 4,
+			     params->mode->vdisplay / 4,
+			     params->mode->hdisplay / 2,
+			     params->mode->vdisplay / 2,
+			     params->fb.x << 16, params->fb.y << 16,
+			     (params->fb.w / 2) << 16,
+			     (params->fb.h / 2) << 16);
+	igt_assert(rc == 0);
+	do_assertions(DONT_ASSERT_CRC);
+
+	/* Destination doesn't fill the entire CRTC, upscaling. */
+	rc = drmModeSetPlane(drm.fd, plane_id, params->crtc_id,
+			     new_fb.fb_id, 0,
+			     params->mode->hdisplay / 4,
+			     params->mode->vdisplay / 4,
+			     params->mode->hdisplay / 2,
+			     params->mode->vdisplay / 2,
+			     (params->fb.x + params->fb.w / 2) << 16,
+			     (params->fb.y + params->fb.h / 2) << 16,
+			     (params->fb.w / 4) << 16,
+			     (params->fb.h / 4) << 16);
+	igt_assert(rc == 0);
+	do_assertions(DONT_ASSERT_CRC);
+
+	/* Back to the good and old blue fb. */
+	rc = drmModeSetPlane(drm.fd, plane_id, params->crtc_id,
+			     old_fb->fb_id, 0,
+			     0, 0,
+			     params->mode->hdisplay, params->mode->vdisplay,
+			     params->fb.x << 16, params->fb.y << 16,
+			     params->fb.w << 16, params->fb.h << 16);
+	igt_assert(rc == 0);
+	do_assertions(0);
+
+	igt_remove_fb(drm.fd, &new_fb);
+}
 /**
  * modesetfrombusy - modeset from a busy buffer to a non-busy buffer
  *
@@ -3071,6 +3190,18 @@ int main(int argc, char *argv[])
 		if (t.pipes != PIPE_SINGLE ||
 		    t.screen != SCREEN_PRIM ||
 		    t.plane != PLANE_PRI ||
+		    t.method != IGT_DRAW_MMAP_CPU)
+			continue;
+		igt_subtest_f("%s-%s-scaledprimary",
+			      feature_str(t.feature),
+			      fbs_str(t.fbs))
+			scaledprimary_subtest(&t);
+	TEST_MODE_ITER_END
+
+	TEST_MODE_ITER_BEGIN(t)
+		if (t.pipes != PIPE_SINGLE ||
+		    t.screen != SCREEN_PRIM ||
+		    t.plane != PLANE_PRI ||
 		    t.fbs != FBS_INDIVIDUAL ||
 		    t.method != IGT_DRAW_MMAP_CPU)
 			continue;
Signature · 6 lines
2.5.3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

PATCH 5/6 kms_frontbuffer_tracking: don't mode unset when checking sink CRC support

In reply to Paulo Zanoni

There's no reason to do a mode unset since we don't care about whether FBC or PSR are enabled or disabled. This should save about a second for each time you invoke the program.

---
 tests/kms_frontbuffer_tracking.c | 1 -
 1 file changed, 1 deletion(-)
tests/kms_frontbuffer_tracking.c +0 -1
index 47fc0c8..94b9e01 100644
@@ -1333,7 +1333,6 @@ static void setup_sink_crc(void)
 	prim_mode_params.fb.fb = &fbs[FORMAT_DEFAULT].prim_pri;
 	prim_mode_params.fb.x = prim_mode_params.fb.y = 0;
 	fill_fb_region(&prim_mode_params.fb, COLOR_PRIM_BG);
-	unset_all_crtcs();
 	set_mode_for_params(&prim_mode_params);
 
 	sink_crc.fd = igt_debugfs_open("i915_sink_crc_eDP1", O_RDONLY);
Signature · 6 lines
2.5.3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH 6/6 kms_frontbuffer_tracking: add fliptrack subtest

In reply to Paulo Zanoni

The current upstream Kernel code stops and then restarts FBC at every page flip. I am working on patches to keep FBC enabled all the time, so this brings the possibility of having the hardware tracking mechanism looking at the old buffer instead of the new one. This test should catch this problem.

---
 tests/kms_frontbuffer_tracking.c | 63 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)
tests/kms_frontbuffer_tracking.c +63 -0
index 94b9e01..d97e148 100644
@@ -2265,6 +2265,54 @@ static void flip_subtest(const struct test_mode *t, enum flip_type type)
 }
 
 /*
+ * fliptrack - check if the hardware tracking works after page flips
+ *
+ * METHOD
+ *   Flip to a new buffer, then draw on it using MMAP_GTT and check the CRC to
+ *   make sure the hardware tracking detected the write.
+ *
+ * EXPECTED RESULTS
+ *   Everything works as expected, screen contents are properly updated.
+ *
+ * FAILURES
+ *   First you need to check if the draw and flip subtests pass. Only after both
+ *   are passing this test can be useful. If we're failing only on this subtest,
+ *   then maybe we are not properly updating the hardware tracking registers
+ *   during the flip operations.
+ */
+static void fliptrack_subtest(const struct test_mode *t, enum flip_type type)
+{
+	int r;
+	struct igt_fb fb2, *orig_fb;
+	struct modeset_params *params = pick_params(t);
+	struct draw_pattern_info *pattern = &pattern1;
+
+	prepare_subtest(t, pattern);
+
+	create_fb(t->format, params->fb.fb->width, params->fb.fb->height,
+		  LOCAL_I915_FORMAT_MOD_X_TILED, t->plane, &fb2);
+	fill_fb(&fb2, COLOR_PRIM_BG);
+	orig_fb = params->fb.fb;
+
+	for (r = 0; r < pattern->n_rects; r++) {
+		params->fb.fb = (r % 2 == 0) ? &fb2 : orig_fb;
+
+		if (r != 0)
+			draw_rect(pattern, &params->fb, t->method, r - 1);
+
+		page_flip_for_params(params, type);
+		do_assertions(0);
+
+		draw_rect(pattern, &params->fb, t->method, r);
+		update_wanted_crc(t, &pattern->crcs[t->format][r]);
+
+		do_assertions(ASSERT_PSR_DISABLED);
+	}
+
+	igt_remove_fb(drm.fd, &fb2);
+}
+
+/*
  * move - just move the sprite or cursor around
  *
  * METHOD
@@ -3098,6 +3146,21 @@ int main(int argc, char *argv[])
 			      fbs_str(t.fbs),
 			      igt_draw_get_method_name(t.method))
 			flip_subtest(&t, FLIP_MODESET);
+
+	TEST_MODE_ITER_END
+
+	TEST_MODE_ITER_BEGIN(t)
+		if (t.plane != PLANE_PRI ||
+		    t.screen != SCREEN_PRIM ||
+		    t.method != IGT_DRAW_MMAP_GTT ||
+		    (t.feature & FEATURE_FBC) == 0)
+			continue;
+
+		igt_subtest_f("%s-%s-%s-fliptrack",
+			      feature_str(t.feature),
+			      pipes_str(t.pipes),
+			      fbs_str(t.fbs))
+			fliptrack_subtest(&t, FLIP_PAGEFLIP);
 	TEST_MODE_ITER_END
 
 	TEST_MODE_ITER_BEGIN(t)
Signature · 6 lines
2.5.3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx