summaryrefslogtreecommitdiff
path: root/tests/gem_storedw_batches_loop.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-09-18 18:28:18 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-09-18 18:37:10 +0200
commit0a587e24b77707099a21d6ad00cbfd19a4661b8b (patch)
treebdd0b52bae08e4cff0332d8dbd437b8a4f8e6155 /tests/gem_storedw_batches_loop.c
parent195f04c3008c079c8edb762a8907903c264da83c (diff)
tests/gem_storedw_batches_loop: Add testcase to check secure dispatch
v2: Use the mrb_exec function since otherwise we can't pass flags. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests/gem_storedw_batches_loop.c')
-rw-r--r--tests/gem_storedw_batches_loop.c83
1 files changed, 47 insertions, 36 deletions
diff --git a/tests/gem_storedw_batches_loop.c b/tests/gem_storedw_batches_loop.c
index 49fc493e..3be589d4 100644
--- a/tests/gem_storedw_batches_loop.c
+++ b/tests/gem_storedw_batches_loop.c
@@ -45,9 +45,11 @@ static drm_intel_bufmgr *bufmgr;
static drm_intel_bo *target_bo;
static int has_ppgtt = 0;
+#define SECURE_DISPATCH (1<<0)
+
/* Like the store dword test, but we create new command buffers each time */
static void
-store_dword_loop(int divider)
+store_dword_loop(int divider, unsigned flags)
{
int cmd, i, val = 0, ret;
uint32_t *buf;
@@ -66,6 +68,9 @@ store_dword_loop(int divider)
igt_fail(-1);
}
+ /* Upload through cpu mmaps to make sure we don't have a gtt
+ * mapping which could paper over secure batch submission
+ * failing to bind that. */
drm_intel_bo_map(cmd_bo, 1);
buf = cmd_bo->virtual;
@@ -99,7 +104,10 @@ store_dword_loop(int divider)
igt_fail(-1);
}
- ret = drm_intel_bo_exec(cmd_bo, 6 * 4, NULL, 0, 0);
+#define LOCAL_I915_EXEC_SECURE (1<<9)
+ ret = drm_intel_bo_mrb_exec(cmd_bo, 6 * 4, NULL, 0, 0,
+ I915_EXEC_BLT |
+ (flags & SECURE_DISPATCH ? LOCAL_I915_EXEC_SECURE : 0));
if (ret) {
fprintf(stderr, "bo exec failed: %d\n", ret);
igt_fail(-1);
@@ -131,55 +139,58 @@ cont:
printf("completed %d writes successfully\n", i);
}
+int fd;
+int devid;
+
int main(int argc, char **argv)
{
- int fd;
- int devid;
-
+ igt_subtest_init(argc, argv);
igt_skip_on_simulation();
- if (argc != 1) {
- fprintf(stderr, "usage: %s\n", argv[0]);
- igt_fail(-1);
- }
-
- fd = drm_open_any();
- devid = intel_get_drm_devid(fd);
-
- has_ppgtt = gem_uses_aliasing_ppgtt(fd);
+ igt_fixture {
+ fd = drm_open_any();
+ devid = intel_get_drm_devid(fd);
- if (IS_GEN2(devid) || IS_GEN3(devid) || IS_GEN4(devid) || IS_GEN5(devid)) {
+ has_ppgtt = gem_uses_aliasing_ppgtt(fd);
- fprintf(stderr, "MI_STORE_DATA can only use GTT address on gen4+/g33 and"
- "needs snoopable mem on pre-gen6\n");
- return 77;
- }
+ /* storedw needs gtt address on gen4+/g33 and snoopable memory.
+ * Strictly speaking we could implement this now ... */
+ igt_require(intel_gen(devid) >= 6);
+ bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
+ if (!bufmgr) {
+ fprintf(stderr, "failed to init libdrm\n");
+ igt_fail(-1);
+ }
+ // drm_intel_bufmgr_gem_enable_reuse(bufmgr);
- bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
- if (!bufmgr) {
- fprintf(stderr, "failed to init libdrm\n");
- igt_fail(-1);
+ target_bo = drm_intel_bo_alloc(bufmgr, "target bo", 4096, 4096);
+ if (!target_bo) {
+ fprintf(stderr, "failed to alloc target buffer\n");
+ igt_fail(-1);
+ }
}
-// drm_intel_bufmgr_gem_enable_reuse(bufmgr);
- target_bo = drm_intel_bo_alloc(bufmgr, "target bo", 4096, 4096);
- if (!target_bo) {
- fprintf(stderr, "failed to alloc target buffer\n");
- igt_fail(-1);
+ igt_subtest("normal") {
+ store_dword_loop(1, 0);
+ store_dword_loop(2, 0);
+ store_dword_loop(3, 0);
+ store_dword_loop(5, 0);
}
- store_dword_loop(1);
- store_dword_loop(2);
- if (!igt_run_in_simulation()) {
- store_dword_loop(3);
- store_dword_loop(5);
+ igt_subtest("secure-dispatch") {
+ store_dword_loop(1, SECURE_DISPATCH);
+ store_dword_loop(2, SECURE_DISPATCH);
+ store_dword_loop(3, SECURE_DISPATCH);
+ store_dword_loop(5, SECURE_DISPATCH);
}
- drm_intel_bo_unreference(target_bo);
- drm_intel_bufmgr_destroy(bufmgr);
+ igt_fixture {
+ drm_intel_bo_unreference(target_bo);
+ drm_intel_bufmgr_destroy(bufmgr);
- close(fd);
+ close(fd);
+ }
return 0;
}