tests: Add a test for the command parser
PATCH 1/6 tests: Add a test for the command parser
From: Brad Volkin <[email protected]>
Start with a simple testcase that should pass.
v2: Switch to I915_PARAM_CMD_PARSER_VERSION
--- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/gem_exec_parse.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 tests/gem_exec_parse.c
tests/.gitignore +1 -0
@@ -35,6 +35,7 @@ gem_exec_blt gem_exec_faulting_reloc gem_exec_lut_handle gem_exec_nop +gem_exec_parse gem_fd_exhaustion gem_fenced_exec_thrash gem_fence_thrash
tests/Makefile.sources +1 -0
@@ -29,6 +29,7 @@ TESTS_progs_M = \ gem_exec_bad_domains \ gem_exec_faulting_reloc \ gem_exec_nop \ + gem_exec_parse \ gem_fenced_exec_thrash \ gem_fence_thrash \ gem_flink \
tests/gem_exec_parse.c new file +140 -0
140 lines not on this page · raw message
Signature · 6 lines
1.8.3.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/6 tests/gem_exec_parse: Add tests for rejected commands
From: Brad Volkin <[email protected]>
--- tests/gem_exec_parse.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)
tests/gem_exec_parse.c +81 -0
@@ -93,9 +93,55 @@ static int exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds,return 1 ; } +static int exec_batch (int fd,uint32_t cmd_bo,uint32_t *cmds, +int size,int ring,int expected_ret) +{ +struct drm_i915_gem_execbuffer2 execbuf; +struct drm_i915_gem_exec_object2 objs[1 ]; +int ret; + +gem_write (fd, cmd_bo,0 , cmds, size); + + objs[0 ].handle = cmd_bo; + objs[0 ].relocation_count =0 ; + objs[0 ].relocs_ptr =0 ; + objs[0 ].alignment =0 ; + objs[0 ].offset =0 ; + objs[0 ].flags =0 ; + objs[0 ].rsvd1 =0 ; + objs[0 ].rsvd2 =0 ; + + execbuf.buffers_ptr = (uintptr_t )objs; + execbuf.buffer_count =1 ; + execbuf.batch_start_offset =0 ; + execbuf.batch_len = size; + execbuf.cliprects_ptr =0 ; + execbuf.num_cliprects =0 ; + execbuf.DR1 =0 ; + execbuf.DR4 =0 ; + execbuf.flags = ring; +i915_execbuffer2_set_context_id (execbuf,0 ); + execbuf.rsvd2 =0 ; + + ret =drmIoctl (fd, +DRM_IOCTL_I915_GEM_EXECBUFFER2 , + &execbuf); +if (ret ==0 ) +igt_assert (expected_ret ==0 ); +else +igt_assert (-errno == expected_ret); + +gem_sync (fd, cmd_bo); + +return 1 ; +} +uint32_t handle;int fd; +#define MI_ARB_ON_OFF (0x8 << 23) +#define MI_DISPLAY_FLIP ((0x14 << 23) | 1) +#define GFX_OP_PIPE_CONTROL ((0x3<<29)|(0x3<<27)|(0x2<<24)|2)#define PIPE_CONTROL_QW_WRITE (1<<14)
@@ -132,6 +178,41 @@ igt_main 0x12000000)); } + igt_subtest("basic-rejected") { +uint32_t arb_on_off[] = { +MI_ARB_ON_OFF , +MI_BATCH_BUFFER_END , + }; +uint32_t display_flip[] = { +MI_DISPLAY_FLIP , +0 ,0 ,0 , +MI_BATCH_BUFFER_END , +0 + }; +igt_assert ( +exec_batch (fd, handle, + arb_on_off,sizeof (arb_on_off), +I915_EXEC_RENDER , + -EINVAL )); +igt_assert ( +exec_batch (fd, handle, + arb_on_off,sizeof (arb_on_off), +I915_EXEC_BSD , + -EINVAL )); +if (gem_has_vebox (fd)) { +igt_assert ( +exec_batch (fd, handle, + arb_on_off,sizeof (arb_on_off), +I915_EXEC_VEBOX , + -EINVAL )); + } +igt_assert ( +exec_batch (fd, handle, + display_flip,sizeof (display_flip), +I915_EXEC_BLT , + -EINVAL )); + } + igt_fixture {gem_close (fd, handle);
Signature · 1 line
1.8.3.2
PATCH 3/6 tests/gem_exec_parse: Add tests for register whitelist
In reply to [email protected]From: Brad Volkin <[email protected]>
--- tests/gem_exec_parse.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
tests/gem_exec_parse.c +26 -0
@@ -141,6 +141,7 @@ int fd;#define MI_ARB_ON_OFF (0x8 << 23)#define MI_DISPLAY_FLIP ((0x14 << 23) | 1) +#define MI_LOAD_REGISTER_IMM ((0x22 << 23) | 1)#define GFX_OP_PIPE_CONTROL ((0x3<<29)|(0x3<<27)|(0x2<<24)|2)#define PIPE_CONTROL_QW_WRITE (1<<14)
@@ -213,6 +214,31 @@ igt_main -EINVAL)); } + igt_subtest("registers") { +uint32_t lri_bad[] = { +MI_LOAD_REGISTER_IMM , +0 ,// disallowed register address +0x12000000 , +MI_BATCH_BUFFER_END , + }; +uint32_t lri_ok[] = { +MI_LOAD_REGISTER_IMM , +0x5280 ,// allowed register address (SO_WRITE_OFFSET[0]) +0x1 , +MI_BATCH_BUFFER_END , + }; +igt_assert ( +exec_batch (fd, handle, + lri_bad,sizeof (lri_bad), +I915_EXEC_RENDER , + -EINVAL )); +igt_assert ( +exec_batch (fd, handle, + lri_ok,sizeof (lri_ok), +I915_EXEC_RENDER , +0 )); + } + igt_fixture {gem_close (fd, handle);
Signature · 1 line
1.8.3.2
PATCH 4/6 tests/gem_exec_parse: Add tests for bitmask checks
In reply to [email protected]From: Brad Volkin <[email protected]>
--- tests/gem_exec_parse.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
tests/gem_exec_parse.c +18 -0
@@ -145,6 +145,7 @@ int fd;#define GFX_OP_PIPE_CONTROL ((0x3<<29)|(0x3<<27)|(0x2<<24)|2)#define PIPE_CONTROL_QW_WRITE (1<<14) +#define PIPE_CONTROL_LRI_POST_OP (1<<23) igt_main {
@@ -239,6 +240,23 @@ igt_main 0)); } + igt_subtest("bitmasks") { +uint32_t pc[] = { +GFX_OP_PIPE_CONTROL , + (PIPE_CONTROL_QW_WRITE | +PIPE_CONTROL_LRI_POST_OP ), +0 ,// To be patched +0x12000000 , +0 , +MI_BATCH_BUFFER_END , + }; +igt_assert ( +exec_batch (fd, handle, + pc,sizeof (pc), +I915_EXEC_RENDER , + -EINVAL )); + } + igt_fixture {gem_close (fd, handle);
Signature · 1 line
1.8.3.2
PATCH 5/6 tests/gem_exec_parse: Test for batches w/o MI_BATCH_BUFFER_END
In reply to [email protected]From: Brad Volkin <[email protected]>
--- tests/gem_exec_parse.c | 9 +++++++++ 1 file changed, 9 insertions(+)
tests/gem_exec_parse.c +9 -0
@@ -257,6 +257,15 @@ igt_main -EINVAL)); } + igt_subtest("batch-without-end") { +uint32_t noop[1024 ] = {0 }; +igt_assert ( +exec_batch (fd, handle, + noop,sizeof (noop), +I915_EXEC_RENDER , + -EINVAL )); + } + igt_fixture {gem_close (fd, handle);
Signature · 1 line
1.8.3.2
PATCH 6/6 tests/gem_exec_parse: Test a command crossing a page boundary
In reply to [email protected]From: Brad Volkin <[email protected]>
This is a speculative test in that it's not particularly relevant today, but is important if we switch the parser implementation to use kmap_atomic instead of vmap.
--- tests/gem_exec_parse.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)
tests/gem_exec_parse.c +68 -0
@@ -136,6 +136,60 @@ static int exec_batch(int fd, uint32_t cmd_bo, uint32_t *cmds,return 1 ; } +static int exec_split_batch (int fd,uint32_t *cmds, +int size,int ring,int expected_ret) +{ +struct drm_i915_gem_execbuffer2 execbuf; +struct drm_i915_gem_exec_object2 objs[1 ]; +uint32_t cmd_bo; +uint32_t noop[1024 ] = {0 }; +int ret; + +// Allocate and fill a 2-page batch with noops + cmd_bo =gem_create (fd,4096 *2 ); +gem_write (fd, cmd_bo,0 , noop,sizeof (noop)); +gem_write (fd, cmd_bo,4096 , noop,sizeof (noop)); + +// Write the provided commands such that the first dword +// of the command buffer is the last dword of the first +// page (i.e. the command is split across the two pages). +gem_write (fd, cmd_bo,4096 -sizeof (uint32_t ), cmds, size); + + objs[0 ].handle = cmd_bo; + objs[0 ].relocation_count =0 ; + objs[0 ].relocs_ptr =0 ; + objs[0 ].alignment =0 ; + objs[0 ].offset =0 ; + objs[0 ].flags =0 ; + objs[0 ].rsvd1 =0 ; + objs[0 ].rsvd2 =0 ; + + execbuf.buffers_ptr = (uintptr_t )objs; + execbuf.buffer_count =1 ; + execbuf.batch_start_offset =0 ; + execbuf.batch_len = size; + execbuf.cliprects_ptr =0 ; + execbuf.num_cliprects =0 ; + execbuf.DR1 =0 ; + execbuf.DR4 =0 ; + execbuf.flags = ring; +i915_execbuffer2_set_context_id (execbuf,0 ); + execbuf.rsvd2 =0 ; + + ret =drmIoctl (fd, +DRM_IOCTL_I915_GEM_EXECBUFFER2 , + &execbuf); +if (ret ==0 ) +igt_assert (expected_ret ==0 ); +else +igt_assert (-errno == expected_ret); + +gem_sync (fd, cmd_bo); +gem_close (fd, cmd_bo); + +return 1 ; +} +uint32_t handle;int fd;
@@ -266,6 +320,20 @@ igt_main -EINVAL)); } + igt_subtest("cmd-crossing-page") { +uint32_t lri_ok[] = { +MI_LOAD_REGISTER_IMM , +0x5280 ,// allowed register address (SO_WRITE_OFFSET[0]) +0x1 , +MI_BATCH_BUFFER_END , + }; +igt_assert ( +exec_split_batch (fd, + lri_ok,sizeof (lri_ok), +I915_EXEC_RENDER , +0 )); + } + igt_fixture {gem_close (fd, handle);
Signature · 1 line
1.8.3.2