Skip to contentSkip to conversation

igt/kms_rotation_crc: exercise invalid rotations

PATCH In review Matthew Auld 3 participants 4 messages Mar 9, 2016 – Mar 10, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 igt/kms_rotation_crc: exercise invalid rotations

Add expect-to-fail tests for invalid rotations on each of the plane types.

Cc Joonas Lahtinen <[email protected]>
---
 tests/kms_rotation_crc.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)
tests/kms_rotation_crc.c +96 -0
index f94f8f1..a0a5a0f 100644
@@ -479,6 +479,68 @@ err_commit:
 	igt_assert(ret == 0);
 }
 
+static void test_plane_rotation_invalid(data_t *data, enum igt_plane plane_type)
+{
+	igt_display_t *display = &data->display;
+	uint64_t tiling = LOCAL_DRM_FORMAT_MOD_NONE;
+	uint32_t format = DRM_FORMAT_XRGB8888;
+	int bpp = igt_drm_format_to_bpp(format);
+	enum igt_commit_style commit = COMMIT_LEGACY;
+	int fd = data->gfx_fd;
+	igt_output_t *output = &display->outputs[0];
+	igt_plane_t *plane;
+	drmModeModeInfo *mode;
+	unsigned int stride, size, w, h;
+	uint32_t gem_handle;
+	int ret;
+
+	igt_require(output != NULL && output->valid == true);
+
+	plane = igt_output_get_plane(output, plane_type);
+	igt_require(igt_plane_supports_rotation(plane));
+
+	if (plane_type == IGT_PLANE_PRIMARY || plane_type == IGT_PLANE_CURSOR) {
+		igt_require(data->display.has_universal_planes);
+		commit = COMMIT_UNIVERSAL;
+	}
+
+	mode = igt_output_get_mode(output);
+	w = mode->hdisplay;
+	h = mode->vdisplay;
+
+	for (stride = 512; stride < (w * bpp / 8); stride *= 2)
+		;
+	for (size = 1024*1024; size < stride * h; size *= 2)
+		;
+
+	gem_handle = gem_create(fd, size);
+	ret = __gem_set_tiling(fd, gem_handle, I915_TILING_Y, stride);
+	igt_assert(ret == 0);
+
+	do_or_die(__kms_addfb(fd, gem_handle, w, h, stride,
+		  format, tiling, LOCAL_DRM_MODE_FB_MODIFIERS,
+		  &data->fb.fb_id));
+	data->fb.width = w;
+	data->fb.height = h;
+	data->fb.gem_handle = gem_handle;
+
+	igt_plane_set_fb(plane, NULL);
+	igt_display_commit(display);
+
+	igt_plane_set_rotation(plane, data->rotation);
+	igt_plane_set_fb(plane, &data->fb);
+
+	drmModeObjectSetProperty(fd, plane->drm_plane->plane_id,
+				 DRM_MODE_OBJECT_PLANE,
+				 plane->rotation_property,
+				 plane->rotation);
+	ret = igt_display_try_commit2(display, commit);
+
+	kmstest_restore_vt_mode();
+	igt_remove_fb(fd, &data->fb);
+	igt_assert_eq(ret, -EINVAL);
+}
+
 igt_main
 {
 	data_t data = {};
@@ -579,6 +641,40 @@ igt_main
 		test_plane_rotation_exhaust_fences(&data, IGT_PLANE_PRIMARY);
 	}
 
+	igt_subtest_f("primary-rotation-90-invalid") {
+		igt_require(gen < 9);
+		data.rotation = IGT_ROTATION_90;
+		test_plane_rotation_invalid(&data, IGT_PLANE_PRIMARY);
+	}
+
+	igt_subtest_f("primary-rotation-270-invalid") {
+		igt_require(gen < 9);
+		data.rotation = IGT_ROTATION_270;
+		test_plane_rotation_invalid(&data, IGT_PLANE_PRIMARY);
+	}
+
+	igt_subtest_f("sprite-rotation-90-invalid") {
+		igt_require(gen < 9);
+		data.rotation = IGT_ROTATION_90;
+		test_plane_rotation_invalid(&data, IGT_PLANE_2);
+	}
+
+	igt_subtest_f("sprite-rotation-270-invalid") {
+		igt_require(gen < 9);
+		data.rotation = IGT_ROTATION_270;
+		test_plane_rotation_invalid(&data, IGT_PLANE_2);
+	}
+
+	igt_subtest_f("cursor-rotation-90-invalid") {
+		data.rotation = IGT_ROTATION_90;
+		test_plane_rotation_invalid(&data, IGT_PLANE_CURSOR);
+	}
+
+	igt_subtest_f("cursor-rotation-270-invalid") {
+		data.rotation = IGT_ROTATION_270;
+		test_plane_rotation_invalid(&data, IGT_PLANE_CURSOR);
+	}
+
 	igt_fixture {
 		igt_display_fini(&data.display);
 	}
Signature · 6 lines
2.4.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 42 lines · Matthew Auld

Add expect-to-fail tests for invalid rotations on each of the plane types.

Cc Joonas Lahtinen <[email protected]>
---
 tests/kms_rotation_crc.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)
tests/kms_rotation_crc.c +26 -0
index f94f8f1..a0a5a0f 100644
@@ -479,6 +479,68 @@ err_commit:
 	igt_assert(ret == 0);
 }
 
+static void test_plane_rotation_invalid(data_t *data, enum igt_plane plane_type)
+{
+	igt_display_t *display = &data->display;
+	uint64_t tiling = LOCAL_DRM_FORMAT_MOD_NONE;
+	uint32_t format = DRM_FORMAT_XRGB8888;
+	int bpp = igt_drm_format_to_bpp(format);
+	enum igt_commit_style commit = COMMIT_LEGACY;
+	int fd = data->gfx_fd;
+	igt_output_t *output = &display->outputs[0];
+	igt_plane_t *plane;
+	drmModeModeInfo *mode;
+	unsigned int stride, size, w, h;
+	uint32_t gem_handle;
+	int ret;
+
+	igt_require(output != NULL && output->valid == true);
+
+	plane = igt_output_get_plane(output, plane_type);
+	igt_require(igt_plane_supports_rotation(plane));
+
+	if (plane_type == IGT_PLANE_PRIMARY || plane_type == IGT_PLANE_CURSOR) {
+		igt_require(data->display.has_universal_planes);
+		commit = COMMIT_UNIVERSAL;
+	}
+
+	mode = igt_output_get_mode(output);

tests/kms_rotation_crc.c err_commit: · line 517

Quoted 10 lines
tests/kms_rotation_crc.c +10 -0
+	w = mode->hdisplay;
+	h = mode->vdisplay;
+
+	for (stride = 512; stride < (w * bpp / 8); stride *= 2)
+		;
+	for (size = 1024*1024; size < stride * h; size *= 2)
+		;
+
+	gem_handle = gem_create(fd, size);
+	ret = __gem_set_tiling(fd, gem_handle, I915_TILING_Y, stride);

Y tiled fb will be rejected for gen < 9, should use X/linear for those. Actually using X/linear for gen >= 9 would also be interesting to make sure we reject 90/270 for those even when they are otherwise listead as supported rotations.

Also why hand roll the fb creation instead of using the igt_fb stuff?

Quoted 9 lines
tests/kms_rotation_crc.c +9 -0
+	igt_assert(ret == 0);
+
+	do_or_die(__kms_addfb(fd, gem_handle, w, h, stride,
+		  format, tiling, LOCAL_DRM_MODE_FB_MODIFIERS,
+		  &data->fb.fb_id));
+	data->fb.width = w;
+	data->fb.height = h;
+	data->fb.gem_handle = gem_handle;
+

tests/kms_rotation_crc.c err_commit: · line 536

Quoted 10 lines
tests/kms_rotation_crc.c +10 -0
+	igt_plane_set_fb(plane, NULL);
+	igt_display_commit(display);
+
+	igt_plane_set_rotation(plane, data->rotation);
+	igt_plane_set_fb(plane, &data->fb);
+
+	drmModeObjectSetProperty(fd, plane->drm_plane->plane_id,
+				 DRM_MODE_OBJECT_PLANE,
+				 plane->rotation_property,
+				 plane->rotation);

What's this doing here?

Quoted 37 lines
tests/kms_rotation_crc.c +30 -0
+	ret = igt_display_try_commit2(display, commit);
+
+	kmstest_restore_vt_mode();
+	igt_remove_fb(fd, &data->fb);
+	igt_assert_eq(ret, -EINVAL);
+}
+
 igt_main
 {
 	data_t data = {};
@@ -579,6 +641,40 @@ igt_main
 		test_plane_rotation_exhaust_fences(&data, IGT_PLANE_PRIMARY);
 	}
 
+	igt_subtest_f("primary-rotation-90-invalid") {
+		igt_require(gen < 9);
+		data.rotation = IGT_ROTATION_90;
+		test_plane_rotation_invalid(&data, IGT_PLANE_PRIMARY);
+	}
+
+	igt_subtest_f("primary-rotation-270-invalid") {
+		igt_require(gen < 9);
+		data.rotation = IGT_ROTATION_270;
+		test_plane_rotation_invalid(&data, IGT_PLANE_PRIMARY);
+	}
+
+	igt_subtest_f("sprite-rotation-90-invalid") {
+		igt_require(gen < 9);
+		data.rotation = IGT_ROTATION_90;
+		test_plane_rotation_invalid(&data, IGT_PLANE_2);
+	}
+
+	igt_subtest_f("sprite-rotation-270-invalid") {
+		igt_require(gen < 9);
+		data.rotation = IGT_ROTATION_270;
+		test_plane_rotation_invalid(&data, IGT_PLANE_2);
+	}

tests/kms_rotation_crc.c igt_main · line 676

Quoted 10 lines
tests/kms_rotation_crc.c +10 -0
+
+	igt_subtest_f("cursor-rotation-90-invalid") {
+		data.rotation = IGT_ROTATION_90;
+		test_plane_rotation_invalid(&data, IGT_PLANE_CURSOR);
+	}
+
+	igt_subtest_f("cursor-rotation-270-invalid") {
+		data.rotation = IGT_ROTATION_270;
+		test_plane_rotation_invalid(&data, IGT_PLANE_CURSOR);
+	}

These seem rather needlessly hardcody. I would suggest looking at the supported rotations for each plane and picking some invalid ones based on that.

Quoted 11 lines
tests/kms_rotation_crc.c +1 -0
+
 	igt_fixture {
 		igt_display_fini(&data.display);
 	}
Signature · 6 lines
2.4.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 1 line

Y tiled fb will be rejected for gen < 9, should use X/linear for those.

Are you referring to the __gem_set_tiling call? Since this didn't fail on BDW and I don't see any logic in i915_gem_set_tiling which implements this.

Quoted 1 line

Actually using X/linear for gen >= 9 would also be interesting to

make sure we reject 90/270

Yup, good point

Quoted 1 line

I would suggest looking at the supported rotations for each plane

and picking some invalid ones based on that.

Sorry, I must be missing something, isn't that what it already does? I've just picked the invalid rotations for the primary, cursor and sprite planes.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
Quoted 5 lines · Matthew Auld
Quoted 1 line

Y tiled fb will be rejected for gen < 9, should use X/linear for those.

Are you referring to the __gem_set_tiling call? Since this didn't fail on BDW and I don't see any logic in i915_gem_set_tiling which implements this.

No, I mean the addfb. Note that the current logic in addfb is sort of silly, and I tried to fix it in
https://lists.freedesktop.org/archives/intel-gfx/2016-February/087670.html
but no review so far.

Quoted 4 lines
Quoted 2 lines

Actually using X/linear for gen >= 9 would also be interesting to

make sure we reject 90/270

Quoted 8 lines

Yup, good point

Quoted 1 line

I would suggest looking at the supported rotations for each plane

and picking some invalid ones based on that.

Sorry, I must be missing something, isn't that what it already does? I've just picked the invalid rotations for the primary, cursor and sprite planes.

I mean that instead of hardcoding the assumption which rotation are unsupported, you could actually look at what the driver reports as supported vs. not.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx