diff mbox

igt/kms_rotation_crc: Add a new subtest to exhaustively test for fence leaks

Message ID 1446513959-29917-1-git-send-email-vivek.kasireddy@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kasireddy, Vivek Nov. 3, 2015, 1:25 a.m. UTC
In this subtest, as a first step, MAX_FENCES+1 number of framebuffers are
created backed up by objects that have multiple GGTT views (normal and
rotated). Next, we have the i915 driver instantiate a normal view followed
by a rotated view. We continue doing the above MAX_FENCES + 1 times.

Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
---
 tests/kms_rotation_crc.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

Comments

Tvrtko Ursulin Nov. 3, 2015, 10:02 a.m. UTC | #1
Hi,

On 03/11/15 01:25, Vivek Kasireddy wrote:
> In this subtest, as a first step, MAX_FENCES+1 number of framebuffers are
> created backed up by objects that have multiple GGTT views (normal and
> rotated). Next, we have the i915 driver instantiate a normal view followed
> by a rotated view. We continue doing the above MAX_FENCES + 1 times.
>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
> ---
>   tests/kms_rotation_crc.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 79 insertions(+)
>
> diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
> index ed6eeef..44691d1 100644
> --- a/tests/kms_rotation_crc.c
> +++ b/tests/kms_rotation_crc.c
> @@ -25,6 +25,7 @@
>   #include "igt.h"
>   #include <math.h>
>
> +#define MAX_FENCES 32
>
>   typedef struct {
>   	int gfx_fd;
> @@ -376,6 +377,78 @@ static void test_plane_rotation_ytiled_obj(data_t *data, enum igt_plane plane_ty
>   	igt_assert(ret == 0);
>   }
>
> +static void test_plane_rotation_exhaust_fences(data_t *data, data_t *data2,
> +					       enum igt_plane plane_type)
> +{
> +	igt_display_t *display = &data->display;
> +	uint64_t tiling = LOCAL_I915_FORMAT_MOD_Y_TILED;
> +	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 i, 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)
> +		;

Looking good, just two minor comments:

I think a good addition would be to verify that we have enough GTT space 
for size * MAX_FENCES objects. Because if we don't then the test can't 
test what it is trying to test I think. So something like:

igt_require(size * MAX_FENCES < gem_total_aperture()) or whatever it is 
called. Maybe fudge down by a percentage to allow for other stuff, 10% 
or so.

> +	igt_plane_set_fb(plane, NULL);
> +	igt_display_commit(display);
> +
> +	for (i = 0; i < MAX_FENCES + 1; i++) {
> +		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,
> +			  &data2[i].fb.fb_id));
> +		data2[i].fb.width = w;
> +		data2[i].fb.height = h;
> +		data2[i].fb.gem_handle = gem_handle;
> +
> +		igt_plane_set_fb(plane, &data2[i].fb);
> +		igt_plane_set_rotation(plane, IGT_ROTATION_0);
> +
> +		ret = igt_display_try_commit2(display, commit);
> +		igt_assert(ret == 0);
> +
> +		igt_plane_set_rotation(plane, IGT_ROTATION_90);
> +
> +		drmModeObjectSetProperty(fd, plane->drm_plane->plane_id,
> +					 DRM_MODE_OBJECT_PLANE,
> +					 plane->rotation_property,
> +					 plane->rotation);
> +		ret = igt_display_try_commit2(display, commit);
> +		igt_assert(ret == 0);
> +	}
> +
> +	kmstest_restore_vt_mode();
> +
> +	for (i = 0; i < MAX_FENCES + 1; i++)
> +		igt_remove_fb(fd, &data2[i].fb);
> +}
> +
>   igt_main
>   {
>   	data_t data = {};
> @@ -471,6 +544,12 @@ igt_main
>   		test_plane_rotation_ytiled_obj(&data, IGT_PLANE_PRIMARY);
>   	}
>
> +	igt_subtest_f("exhaust-fences") {
> +		data_t data2[MAX_FENCES+1] = {};
> +		igt_require(gen >= 9);
> +		test_plane_rotation_exhaust_fences(&data, data2, IGT_PLANE_PRIMARY);

Second minor comment is that data2 could be local to 
test_plane_rotation_exhaust_fences just as well and would probably be 
cleaner like that.

Regards,

Tvrtko
diff mbox

Patch

diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index ed6eeef..44691d1 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -25,6 +25,7 @@ 
 #include "igt.h"
 #include <math.h>
 
+#define MAX_FENCES 32
 
 typedef struct {
 	int gfx_fd;
@@ -376,6 +377,78 @@  static void test_plane_rotation_ytiled_obj(data_t *data, enum igt_plane plane_ty
 	igt_assert(ret == 0);
 }
 
+static void test_plane_rotation_exhaust_fences(data_t *data, data_t *data2,
+					       enum igt_plane plane_type)
+{
+	igt_display_t *display = &data->display;
+	uint64_t tiling = LOCAL_I915_FORMAT_MOD_Y_TILED;
+	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 i, 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)
+		;
+
+	igt_plane_set_fb(plane, NULL);
+	igt_display_commit(display);
+
+	for (i = 0; i < MAX_FENCES + 1; i++) {
+		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,
+			  &data2[i].fb.fb_id));
+		data2[i].fb.width = w;
+		data2[i].fb.height = h;
+		data2[i].fb.gem_handle = gem_handle;
+
+		igt_plane_set_fb(plane, &data2[i].fb);
+		igt_plane_set_rotation(plane, IGT_ROTATION_0);
+
+		ret = igt_display_try_commit2(display, commit);
+		igt_assert(ret == 0);
+
+		igt_plane_set_rotation(plane, IGT_ROTATION_90);
+
+		drmModeObjectSetProperty(fd, plane->drm_plane->plane_id,
+					 DRM_MODE_OBJECT_PLANE,
+					 plane->rotation_property,
+					 plane->rotation);
+		ret = igt_display_try_commit2(display, commit);
+		igt_assert(ret == 0);
+	}
+
+	kmstest_restore_vt_mode();
+
+	for (i = 0; i < MAX_FENCES + 1; i++)
+		igt_remove_fb(fd, &data2[i].fb);
+}
+
 igt_main
 {
 	data_t data = {};
@@ -471,6 +544,12 @@  igt_main
 		test_plane_rotation_ytiled_obj(&data, IGT_PLANE_PRIMARY);
 	}
 
+	igt_subtest_f("exhaust-fences") {
+		data_t data2[MAX_FENCES+1] = {};
+		igt_require(gen >= 9);
+		test_plane_rotation_exhaust_fences(&data, data2, IGT_PLANE_PRIMARY);
+	}
+
 	igt_fixture {
 		igt_display_fini(&data.display);
 	}