[igt-dev] [PATCH i-g-t 4/5] tests/i915/gem_exec_bad_domains: Removal libdrm dependency
Dominik Grzegorzek
dominik.grzegorzek at intel.com
Wed Jul 8 08:58:59 UTC 2020
Replace an intel_batchbuffer with an intel_bb in gem_exec_bad_domains.
Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
tests/i915/gem_exec_bad_domains.c | 133 ++++++++++++------------------
1 file changed, 53 insertions(+), 80 deletions(-)
diff --git a/tests/i915/gem_exec_bad_domains.c b/tests/i915/gem_exec_bad_domains.c
index 733964f4..2322b360 100644
--- a/tests/i915/gem_exec_bad_domains.c
+++ b/tests/i915/gem_exec_bad_domains.c
@@ -37,7 +37,6 @@
#include "drm.h"
#include "i915/gem.h"
#include "igt.h"
-#include "intel_bufmgr.h"
/* Testcase: Test whether the kernel rejects relocations with non-gpu domains
*
@@ -47,39 +46,20 @@
IGT_TEST_DESCRIPTION("Test whether the kernel rejects relocations with non-gpu"
" domains.");
-static drm_intel_bufmgr *bufmgr;
-struct intel_batchbuffer *batch;
-
#define BAD_GTT_DEST ((512*1024*1024)) /* past end of aperture */
static int
-run_batch(void)
+run_batch(struct intel_bb *ibb)
{
- unsigned int used = batch->ptr - batch->buffer;
int ret;
- if (used == 0)
- return 0;
-
- /* Round batchbuffer usage to 2 DWORDs. */
- if ((used & 4) == 0) {
- *(uint32_t *) (batch->ptr) = 0; /* noop */
- batch->ptr += 4;
- }
-
/* Mark the end of the buffer. */
- *(uint32_t *)(batch->ptr) = MI_BATCH_BUFFER_END; /* noop */
- batch->ptr += 4;
- used = batch->ptr - batch->buffer;
-
- ret = drm_intel_bo_subdata(batch->bo, 0, used, batch->buffer);
- igt_assert_eq(ret, 0);
+ intel_bb_out(ibb, MI_BATCH_BUFFER_END);
+ intel_bb_ptr_align(ibb, 8);
- batch->ptr = NULL;
-
- ret = drm_intel_bo_mrb_exec(batch->bo, used, NULL, 0, 0, 0);
-
- intel_batchbuffer_reset(batch);
+ ret = __intel_bb_exec(ibb, intel_bb_offset(ibb), ibb->ctx,
+ 0, true);
+ intel_bb_reset(ibb, false);
return ret;
}
@@ -144,87 +124,80 @@ static void multi_write_domain(int fd)
gem_close(fd, handle_target);
}
-int fd;
-drm_intel_bo *tmp;
-
igt_main
{
+ struct intel_buf *tmp;
+ struct intel_bb *ibb;
+ struct buf_ops *bops;
+ int fd;
+
igt_fixture {
fd = drm_open_driver(DRIVER_INTEL);
igt_require_gem(fd);
- bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
- drm_intel_bufmgr_gem_enable_reuse(bufmgr);
- batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
+ ibb = intel_bb_create(fd, 4096);
+ bops = buf_ops_create(fd);
- tmp = drm_intel_bo_alloc(bufmgr, "tmp", 128 * 128, 4096);
+ tmp = intel_buf_create(bops, 128, 128, 32,
+ I915_TILING_NONE, 0, 0);
}
igt_subtest("cpu-domain") {
- BEGIN_BATCH(2, 1);
- OUT_BATCH(0);
- OUT_RELOC(tmp, I915_GEM_DOMAIN_CPU, 0, 0);
- ADVANCE_BATCH();
- igt_assert(run_batch() == -EINVAL);
-
- BEGIN_BATCH(2, 1);
- OUT_BATCH(0);
- OUT_RELOC(tmp, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU, 0);
- ADVANCE_BATCH();
- igt_assert(run_batch() == -EINVAL);
+ intel_bb_out(ibb, 0);
+ intel_bb_emit_reloc(ibb, tmp->handle, I915_GEM_DOMAIN_CPU,
+ 0, 0, 0x0);
+ igt_assert(run_batch(ibb) == -EINVAL);
+
+ intel_bb_out(ibb, 0);
+ intel_bb_emit_reloc(ibb, tmp->handle, I915_GEM_DOMAIN_CPU,
+ I915_GEM_DOMAIN_CPU, 0, 0x0);
+ igt_assert(run_batch(ibb) == -EINVAL);
}
igt_subtest("gtt-domain") {
- BEGIN_BATCH(2, 1);
- OUT_BATCH(0);
- OUT_RELOC(tmp, I915_GEM_DOMAIN_GTT, 0, 0);
- ADVANCE_BATCH();
- igt_assert(run_batch() == -EINVAL);
-
- BEGIN_BATCH(2, 1);
- OUT_BATCH(0);
- OUT_RELOC(tmp, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT, 0);
- ADVANCE_BATCH();
- igt_assert(run_batch() == -EINVAL);
+ intel_bb_out(ibb, 0);
+ intel_bb_emit_reloc(ibb, tmp->handle, I915_GEM_DOMAIN_GTT,
+ 0, 0, 0x0);
+ igt_assert(run_batch(ibb) == -EINVAL);
+
+ intel_bb_out(ibb, 0);
+ intel_bb_emit_reloc(ibb, tmp->handle, I915_GEM_DOMAIN_GTT,
+ I915_GEM_DOMAIN_GTT, 0, 0x0);
+ igt_assert(run_batch(ibb) == -EINVAL);
}
/* Note: Older kernels disallow this. Punt on the skip check though
* since this is too old. */
igt_subtest("conflicting-write-domain") {
- BEGIN_BATCH(4, 2);
- OUT_BATCH(0);
- OUT_RELOC(tmp, I915_GEM_DOMAIN_RENDER,
- I915_GEM_DOMAIN_RENDER, 0);
- OUT_BATCH(0);
- OUT_RELOC(tmp, I915_GEM_DOMAIN_INSTRUCTION,
- I915_GEM_DOMAIN_INSTRUCTION, 0);
- ADVANCE_BATCH();
- igt_assert(run_batch() == 0);
+ intel_bb_out(ibb, 0);
+ intel_bb_emit_reloc(ibb, tmp->handle, I915_GEM_DOMAIN_RENDER,
+ I915_GEM_DOMAIN_RENDER, 0, 0x0);
+ intel_bb_out(ibb, 0);
+ intel_bb_emit_reloc(ibb, tmp->handle, I915_GEM_DOMAIN_INSTRUCTION,
+ I915_GEM_DOMAIN_INSTRUCTION, 0, 0x0);
+
+ igt_assert(run_batch(ibb) == 0);
}
igt_subtest("double-write-domain")
multi_write_domain(fd);
igt_subtest("invalid-gpu-domain") {
- BEGIN_BATCH(2, 1);
- OUT_BATCH(0);
- OUT_RELOC(tmp, ~(I915_GEM_GPU_DOMAINS | I915_GEM_DOMAIN_GTT | I915_GEM_DOMAIN_CPU),
- 0, 0);
- ADVANCE_BATCH();
- igt_assert(run_batch() == -EINVAL);
-
- BEGIN_BATCH(2, 1);
- OUT_BATCH(0);
- OUT_RELOC(tmp, I915_GEM_DOMAIN_GTT << 1,
- I915_GEM_DOMAIN_GTT << 1, 0);
- ADVANCE_BATCH();
- igt_assert(run_batch() == -EINVAL);
+ intel_bb_out(ibb, 0);
+ intel_bb_emit_reloc(ibb, tmp->handle, ~(I915_GEM_GPU_DOMAINS | I915_GEM_DOMAIN_GTT | I915_GEM_DOMAIN_CPU),
+ 0, 0, 0x0);
+ igt_assert(run_batch(ibb) == -EINVAL);
+
+ intel_bb_out(ibb, 0);
+ intel_bb_emit_reloc(ibb, tmp->handle, I915_GEM_DOMAIN_GTT << 1,
+ I915_GEM_DOMAIN_GTT << 1, 0, 0x0);
+ igt_assert(run_batch(ibb) == -EINVAL);
}
igt_fixture {
- intel_batchbuffer_free(batch);
- drm_intel_bufmgr_destroy(bufmgr);
-
+ intel_buf_close(bops, tmp);
+ buf_ops_destroy(bops);
+ intel_bb_destroy(ibb);
close(fd);
}
}
--
2.20.1
More information about the igt-dev
mailing list