kms_flip: Exercise flip-vs-render
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 29 Aug 2013 14:11:47 +0000 (15:11 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 29 Aug 2013 15:19:41 +0000 (16:19 +0100)
For machine with split BCS/RCS rings, we also need to test whether we
correctly wait upon outstanding render work before flipping and changing
modes. This should also serve to exercise the ring selection code for
flips.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
lib/drmtest.c
lib/drmtest.h
lib/rendercopy.h
tests/kms_flip.c

index e1522b7..70483ea 100644 (file)
@@ -1304,6 +1304,7 @@ unsigned int kmstest_create_fb(int fd, int width, int height, int bpp,
 
        fb->width = width;
        fb->height = height;
+       fb->tiling = tiled;
        fb->drm_format = bpp_depth_to_drm_format(bpp, depth);
 
        return fb->fb_id;
@@ -1352,6 +1353,7 @@ unsigned int kmstest_create_fb2(int fd, int width, int height, uint32_t format,
 
        fb->width = width;
        fb->height = height;
+       fb->tiling = tiled;
        fb->drm_format = format;
        fb->fb_id = fb_id;
 
index 5fecb2b..ece478b 100644 (file)
@@ -25,6 +25,9 @@
  *
  */
 
+#ifndef DRMTEST_H
+#define DRMTEST_H
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -269,6 +272,7 @@ struct kmstest_fb {
        int height;
        int depth;
        unsigned stride;
+       unsigned tiling;
        unsigned size;
        cairo_t *cairo_ctx;
 };
@@ -326,3 +330,5 @@ int igt_enable_prefault(void);
 
 /* suspend and auto-resume system */
 void igt_system_suspend_autoresume(void);
+
+#endif /* DRMTEST_H */
index b03c147..8fd9222 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef RENDERCOPY_H
+#define RENDERCOPY_H
+
 #include <stdlib.h>
 #include <sys/ioctl.h>
 #include <stdio.h>
@@ -81,3 +84,5 @@ void gen2_render_copyfunc(struct intel_batchbuffer *batch,
                          struct scratch_buf *src, unsigned src_x, unsigned src_y,
                          unsigned width, unsigned height,
                          struct scratch_buf *dst, unsigned dst_x, unsigned dst_y);
+
+#endif /* RENDERCOPY_H */
index cb9ccd1..acd12ed 100644 (file)
 #include "i915_drm.h"
 #include "drmtest.h"
 #include "testdisplay.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
+#include "rendercopy.h"
 
 #define TEST_DPMS              (1 << 0)
-#define TEST_WITH_DUMMY_LOAD   (1 << 1)
-#define TEST_PAN               (1 << 2)
-#define TEST_MODESET           (1 << 3)
-#define TEST_CHECK_TS          (1 << 4)
-#define TEST_EBUSY             (1 << 5)
-#define TEST_EINVAL            (1 << 6)
-#define TEST_FLIP              (1 << 7)
-#define TEST_VBLANK            (1 << 8)
-#define TEST_VBLANK_BLOCK      (1 << 9)
-#define TEST_VBLANK_ABSOLUTE   (1 << 10)
-#define TEST_VBLANK_EXPIRED_SEQ        (1 << 11)
-#define TEST_FB_RECREATE       (1 << 12)
-#define TEST_RMFB              (1 << 13)
-#define TEST_HANG              (1 << 14)
-#define TEST_NOEVENT           (1 << 15)
-#define TEST_FB_BAD_TILING     (1 << 16)
-#define TEST_SINGLE_BUFFER     (1 << 17)
-#define TEST_DPMS_OFF          (1 << 18)
+#define TEST_WITH_DUMMY_BCS    (1 << 1)
+#define TEST_WITH_DUMMY_RCS    (1 << 2)
+#define TEST_PAN               (1 << 3)
+#define TEST_MODESET           (1 << 4)
+#define TEST_CHECK_TS          (1 << 5)
+#define TEST_EBUSY             (1 << 6)
+#define TEST_EINVAL            (1 << 7)
+#define TEST_FLIP              (1 << 8)
+#define TEST_VBLANK            (1 << 9)
+#define TEST_VBLANK_BLOCK      (1 << 10)
+#define TEST_VBLANK_ABSOLUTE   (1 << 11)
+#define TEST_VBLANK_EXPIRED_SEQ        (1 << 12)
+#define TEST_FB_RECREATE       (1 << 13)
+#define TEST_RMFB              (1 << 14)
+#define TEST_HANG              (1 << 15)
+#define TEST_NOEVENT           (1 << 16)
+#define TEST_FB_BAD_TILING     (1 << 17)
+#define TEST_SINGLE_BUFFER     (1 << 18)
+#define TEST_DPMS_OFF          (1 << 19)
 
 #define EVENT_FLIP             (1 << 0)
 #define EVENT_VBLANK           (1 << 1)
@@ -144,7 +143,7 @@ static unsigned long gettime_us(void)
        return ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
 }
 
-static void emit_dummy_load(struct test_output *o)
+static void emit_dummy_load__bcs(struct test_output *o)
 {
        int i, limit;
        drm_intel_bo *dummy_bo, *target_bo, *tmp_bo;
@@ -192,6 +191,56 @@ static void emit_dummy_load(struct test_output *o)
        drm_intel_bo_unreference(target_bo);
 }
 
+static void emit_dummy_load__rcs(struct test_output *o)
+{
+       const struct kmstest_fb *fb_info = &o->fb_info[o->current_fb_id];
+       render_copyfunc_t copyfunc;
+       struct scratch_buf sb[2], *src, *dst;
+       int i, limit;
+
+       copyfunc = get_render_copyfunc(devid);
+       if (copyfunc == NULL)
+               return emit_dummy_load__bcs(o);
+
+       limit = intel_gen(devid) < 6 ? 500 : 5000;
+
+       sb[0].bo = drm_intel_bo_alloc(bufmgr, "dummy_bo", fb_info->size, 4096);
+       igt_assert(sb[0].bo);
+       sb[0].size = sb[0].bo->size;
+       sb[0].tiling = I915_TILING_NONE;
+       sb[0].data = NULL;
+       sb[0].num_tiles = sb[0].bo->size;
+       sb[0].stride = 4 * o->mode.hdisplay;
+
+       sb[1].bo = gem_handle_to_libdrm_bo(bufmgr, drm_fd, "imported", fb_info->gem_handle);
+       igt_assert(sb[1].bo);
+       sb[1].size = sb[1].bo->size;
+       sb[1].tiling = fb_info->tiling;
+       sb[1].data = NULL;
+       sb[1].num_tiles = sb[1].bo->size;
+       sb[1].stride = fb_info->stride;
+
+       src = &sb[0];
+       dst = &sb[1];
+
+       for (i = 0; i < limit; i++) {
+               struct scratch_buf *tmp;
+
+               copyfunc(batch,
+                        src, 0, 0,
+                        o->mode.hdisplay, o->mode.vdisplay,
+                        dst, 0, 0);
+
+               tmp = src;
+               src = dst;
+               dst = tmp;
+       }
+       intel_batchbuffer_flush(batch);
+
+       drm_intel_bo_unreference(sb[0].bo);
+       drm_intel_bo_unreference(sb[1].bo);
+}
+
 static int set_connector_dpms(drmModeConnector *connector, int mode)
 {
        int i, dpms = 0;
@@ -672,9 +721,11 @@ static unsigned int run_test_step(struct test_output *o)
        do_vblank = (o->flags & TEST_VBLANK) &&
                    !(o->pending_events & EVENT_VBLANK);
 
-       if (o->flags & TEST_WITH_DUMMY_LOAD)
-               emit_dummy_load(o);
+       if (o->flags & TEST_WITH_DUMMY_BCS)
+               emit_dummy_load__bcs(o);
 
+       if (o->flags & TEST_WITH_DUMMY_RCS)
+               emit_dummy_load__rcs(o);
 
        if (!(o->flags & TEST_SINGLE_BUFFER))
                o->current_fb_id = !o->current_fb_id;
@@ -916,7 +967,7 @@ static unsigned int wait_for_events(struct test_output *o)
        evctx.page_flip_handler = page_flip_handler;
 
        /* make timeout lax with the dummy load */
-       if (o->flags & TEST_WITH_DUMMY_LOAD)
+       if (o->flags & (TEST_WITH_DUMMY_BCS | TEST_WITH_DUMMY_RCS))
                timeout.tv_sec *= 10;
 
        FD_ZERO(&fds);
@@ -1128,11 +1179,15 @@ int main(int argc, char **argv)
                { 5,  TEST_VBLANK | TEST_VBLANK_BLOCK | TEST_VBLANK_ABSOLUTE,
                                        "blocking-absolute-wf_vblank" },
                { 30,  TEST_VBLANK | TEST_DPMS | TEST_EINVAL, "wf_vblank-vs-dpms" },
-               { 30,  TEST_VBLANK | TEST_DPMS | TEST_WITH_DUMMY_LOAD,
-                                       "delayed-wf_vblank-vs-dpms" },
+               { 30,  TEST_VBLANK | TEST_DPMS | TEST_WITH_DUMMY_BCS,
+                                       "bcs-wf_vblank-vs-dpms" },
+               { 30,  TEST_VBLANK | TEST_DPMS | TEST_WITH_DUMMY_RCS,
+                                       "rcs-wf_vblank-vs-dpms" },
                { 30,  TEST_VBLANK | TEST_MODESET | TEST_EINVAL, "wf_vblank-vs-modeset" },
-               { 30,  TEST_VBLANK | TEST_MODESET | TEST_WITH_DUMMY_LOAD,
-                                       "delayed-wf_vblank-vs-modeset" },
+               { 30,  TEST_VBLANK | TEST_MODESET | TEST_WITH_DUMMY_BCS,
+                                       "bcs-wf_vblank-vs-modeset" },
+               { 30,  TEST_VBLANK | TEST_MODESET | TEST_WITH_DUMMY_RCS,
+                                       "rcs-wf_vblank-vs-modeset" },
 
                { 15, TEST_FLIP | TEST_EBUSY , "plain-flip" },
                { 15, TEST_FLIP | TEST_CHECK_TS | TEST_EBUSY , "plain-flip-ts-check" },
@@ -1140,11 +1195,14 @@ int main(int argc, char **argv)
                        "plain-flip-fb-recreate" },
                { 15, TEST_FLIP | TEST_EBUSY | TEST_RMFB | TEST_MODESET , "flip-vs-rmfb" },
                { 30, TEST_FLIP | TEST_DPMS | TEST_EINVAL, "flip-vs-dpms" },
-               { 30, TEST_FLIP | TEST_DPMS | TEST_WITH_DUMMY_LOAD, "delayed-flip-vs-dpms" },
+               { 30, TEST_FLIP | TEST_DPMS | TEST_WITH_DUMMY_BCS, "bcs-flip-vs-dpms" },
+               { 30, TEST_FLIP | TEST_DPMS | TEST_WITH_DUMMY_RCS, "rcs-flip-vs-dpms" },
                { 5,  TEST_FLIP | TEST_PAN, "flip-vs-panning" },
-               { 30, TEST_FLIP | TEST_PAN | TEST_WITH_DUMMY_LOAD, "delayed-flip-vs-panning" },
+               { 30, TEST_FLIP | TEST_PAN | TEST_WITH_DUMMY_BCS, "bcs-flip-vs-panning" },
+               { 30, TEST_FLIP | TEST_PAN | TEST_WITH_DUMMY_RCS, "rcs-flip-vs-panning" },
                { 30, TEST_FLIP | TEST_MODESET | TEST_EINVAL, "flip-vs-modeset" },
-               { 30, TEST_FLIP | TEST_MODESET | TEST_WITH_DUMMY_LOAD, "delayed-flip-vs-modeset" },
+               { 30, TEST_FLIP | TEST_MODESET | TEST_WITH_DUMMY_BCS, "bcs-flip-vs-modeset" },
+               { 30, TEST_FLIP | TEST_MODESET | TEST_WITH_DUMMY_RCS, "rcs-flip-vs-modeset" },
                { 5,  TEST_FLIP | TEST_VBLANK_EXPIRED_SEQ,
                                        "flip-vs-expired-vblank" },