diff mbox

[v2,2/2] tests/kms_flip: test a fb backed by a bo too big/small for its own good

Message ID 1400245632-12928-2-git-send-email-oscar.mateo@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

oscar.mateo@intel.com May 16, 2014, 1:07 p.m. UTC
From: Oscar Mateo <oscar.mateo@intel.com>

This is a "review by igt test" for a bug located in
i915_gem_object_pin_to_display_plane and fixed by:

commit 392013bdd4b6128795e33c84bd6d6d3fd66ff0a3
Author: Oscar Mateo <oscar.mateo@intel.com>
Date:   Fri May 16 11:23:12 2014 +0100

    drm/i915: Gracefully handle obj not bound to GGTT in is_pin_display

    Otherwise, we do a NULL pointer dereference.

    I've seen this happen while handling an error in
    i915_gem_object_pin_to_display_plane():

    If i915_gem_object_set_cache_level() fails, we call is_pin_display()
    to handle the error. At this point, the object is still not pinned
    to GGTT and maybe not even bound, so we have to check before we
    dereference its GGTT vma.

    v2: Chris Wilson says restoring the old value is easier, but that
    is_pin_display is useful as a theory of operation. Take the solomonic
    decision: at least this way is_pin_display is a little more robust
    (until Chris can kill it off).

v2: Avoid code duplication by using igt_create_fb_with_bo_size() as
requested by Ville Syrjälä (original author of the "too big" test idea).

Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
---
 tests/kms_flip.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

Comments

Ville Syrjälä May 16, 2014, 2:49 p.m. UTC | #1
On Fri, May 16, 2014 at 02:07:12PM +0100, oscar.mateo@intel.com wrote:
> From: Oscar Mateo <oscar.mateo@intel.com>
> 
> This is a "review by igt test" for a bug located in
> i915_gem_object_pin_to_display_plane and fixed by:

Thanks. Both patches pushed.
diff mbox

Patch

diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index bb4f71d..f2ec9ef 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -74,6 +74,7 @@ 
 #define TEST_RPM		(1 << 25)
 #define TEST_SUSPEND		(1 << 26)
 #define TEST_TS_CONT		(1 << 27)
+#define TEST_BO_TOOBIG		(1 << 28)
 
 #define EVENT_FLIP		(1 << 0)
 #define EVENT_VBLANK		(1 << 1)
@@ -1213,6 +1214,7 @@  static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,
 {
 	char test_name[128];
 	unsigned elapsed;
+	unsigned bo_size = 0;
 	bool tiled;
 	int i;
 
@@ -1249,12 +1251,17 @@  static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,
 	if (o->flags & TEST_FENCE_STRESS)
 		tiled = true;
 
+	/* 256 MB is usually the maximum mappable aperture,
+	 * (make it 4x times that to ensure failure) */
+	if (o->flags & TEST_BO_TOOBIG)
+		bo_size = 4*256*1024*1024;
+
 	o->fb_ids[0] = igt_create_fb(drm_fd, o->fb_width, o->fb_height,
 					 igt_bpp_depth_to_drm_format(o->bpp, o->depth),
 					 tiled, &o->fb_info[0]);
-	o->fb_ids[1] = igt_create_fb(drm_fd, o->fb_width, o->fb_height,
+	o->fb_ids[1] = igt_create_fb_with_bo_size(drm_fd, o->fb_width, o->fb_height,
 					 igt_bpp_depth_to_drm_format(o->bpp, o->depth),
-					 tiled, &o->fb_info[1]);
+					 tiled, &o->fb_info[1], bo_size);
 	o->fb_ids[2] = igt_create_fb(drm_fd, o->fb_width, o->fb_height,
 					 igt_bpp_depth_to_drm_format(o->bpp, o->depth),
 					 true, &o->fb_info[2]);
@@ -1264,7 +1271,8 @@  static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,
 		igt_require(o->fb_ids[2]);
 
 	paint_flip_mode(&o->fb_info[0], false);
-	paint_flip_mode(&o->fb_info[1], true);
+	if (!(o->flags & TEST_BO_TOOBIG))
+		paint_flip_mode(&o->fb_info[1], true);
 	if (o->fb_ids[2])
 		paint_flip_mode(&o->fb_info[2], true);
 
@@ -1288,10 +1296,15 @@  static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,
 	if (o->flags & TEST_CHECK_TS)
 		sleep(1);
 
-	igt_assert(do_page_flip(o, o->fb_ids[1], true) == 0);
+	if (o->flags & TEST_BO_TOOBIG) {
+		igt_assert(do_page_flip(o, o->fb_ids[1], true) == -E2BIG);
+		goto out;
+	} else
+		igt_assert(do_page_flip(o, o->fb_ids[1], true) == 0);
 	wait_for_events(o);
 
 	o->current_fb_id = 1;
+
 	if (o->flags & TEST_FLIP)
 		o->flip_state.seq_step = 1;
 	else
@@ -1543,6 +1556,7 @@  int main(int argc, char **argv)
 		{ 10, TEST_VBLANK | TEST_DPMS | TEST_SUSPEND | TEST_TS_CONT, "dpms-vs-suspend" },
 		{ 0, TEST_VBLANK | TEST_MODESET | TEST_RPM | TEST_TS_CONT, "modeset-vs-rpm" },
 		{ 0, TEST_VBLANK | TEST_MODESET | TEST_SUSPEND | TEST_TS_CONT, "modeset-vs-suspend" },
+		{ 0, TEST_BO_TOOBIG | TEST_NO_2X_OUTPUT, "bo-too-big" },
 	};
 	int i;