corresponding changes for i915-perf interface
v4 cover corresponding changes for i915-perf interface
The i915-perf series affects the command parser and itself includes new uapi which these i-g-t changes try to cover.
This update follows up on review from both Matt and Chris.
A minor change I ended up making was to rename the hsw_oa_formats[] array to oa_formats[] indexed by the format ID so the test could more easily get to the C counter offset for a given format which I think helps make test_oa_exponents clearer, avoiding using '224' with a /* C offset */ comment. The same array may be extended later for testing gen8+ so I've removed the hsw_ prefix for now.
I noticed the existing handle and fd global variables could be made local to main() and so added a minor patch for that.
perf.c no longer depends on the i915_drm.h copy in libdrm including the i915 perf interface since the test itself includes a guarded copy of the new uapi for now.
- Robert
Robert Bragg (13):
igt/perf: add i915 perf stream tests for Haswell igt/gem_exec_parse: some minor cleanups igt/gem_exec_parse: move hsw_load_register_reg down igt/gem_exec_parse: update hsw_load_register_reg igt/gem_exec_parse: make global vars local to main() igt/gem_exec_parse: init global parser_version in fixture igt/gem_exec_parse: req. v < 9 for oacontrol tracking test igt/gem_exec_parse: make basic-rejected version agnostic igt/gem_exec_parse: update bitmasks test for v >=8 igt/gem_exec_parse: update cmd-crossing-page for >= v8 igt/gem_exec_parse: update hsw_load_register_reg for v >= 8 igt/gem_exec_parse: update registers test for v >= 8 igt/gem_exec_parse: check oacontrol lri bad for >= v9
tests/Makefile.sources | 1 + tests/gem_exec_parse.c | 568 ++++++------ tests/perf.c | 2373 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2656 insertions(+), 286 deletions(-) create mode 100644 tests/perf.c
Signature · 6 lines
2.10.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 1/13 igt/perf: add i915 perf stream tests for Haswell
--- tests/Makefile.sources | 1 + tests/perf.c | 2373 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 2374 insertions(+) create mode 100644 tests/perf.c
tests/Makefile.sources +1 -0
@@ -214,6 +214,7 @@ TESTS_progs = \ kms_pwrite_crc \ kms_sink_crc_basic \ prime_udl \ + perf \ $(NULL) # IMPORTANT: The ZZ_ tests need to be run last!
tests/perf.c new file +2373 -0
2,373 lines not on this page · raw message
Signature · 6 lines
2.10.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 2/13 igt/gem_exec_parse: some minor cleanups
In reply to Robert BraggThis normalizes the execbuf utilities in this file to all use memset to clear obj, reloc and execbuf structures and set them up in the same order. As I was debugging some unpredictable test failures I was getting unsure that all these structures were being fully initialized.
The same I915_GEM_DOMAIN_COMMAND domain is now used with all relocs.
The register/command defines have been moved to the top of the file to be available to all tests/utilities.
The handle + fd variables are now static.
--- tests/gem_exec_parse.c | 196 +++++++++++++++++-------------------------------- 1 file changed, 66 insertions(+), 130 deletions(-)
tests/gem_exec_parse.c +66 -130
@@ -37,6 +37,20 @@#define OACONTROL 0x2360#define DERRMR 0x44050 +#define HSW_CS_GPR (n) (0x2600 + 8*(n)) +#define HSW_CS_GPR0 HSW_CS_GPR(0) +#define HSW_CS_GPR1 HSW_CS_GPR(1) + +#define MI_LOAD_REGISTER_REG (0x2a << 23) +#define MI_STORE_REGISTER_MEM (0x24 << 23) +#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) +#define PIPE_CONTROL_LRI_POST_OP (1<<23) + +static int command_parser_version (int fd) {int version =-1 ;
@@ -51,12 +65,6 @@ static int command_parser_version(int fd)return -1 ; } -#define HSW_CS_GPR (n) (0x2600 + 8*(n)) -#define HSW_CS_GPR0 HSW_CS_GPR(0) -#define HSW_CS_GPR1 HSW_CS_GPR(1) - -#define MI_LOAD_REGISTER_REG (0x2a << 23) -#define MI_STORE_REGISTER_MEM (0x24 << 23)static void hsw_load_register_reg (void ) {uint32_t buf[16 ] = {
@@ -100,13 +108,13 @@ static void hsw_load_register_reg(void) reloc[0 ].offset =7 *sizeof (uint32_t ); reloc[0 ].target_handle = obj[0 ].handle; reloc[0 ].delta =0 ; - reloc[0 ].read_domains =I915_GEM_DOMAIN_INSTRUCTION ; - reloc[0 ].write_domain =I915_GEM_DOMAIN_INSTRUCTION ; + reloc[0 ].read_domains =I915_GEM_DOMAIN_COMMAND ; + reloc[0 ].write_domain =I915_GEM_DOMAIN_COMMAND ; reloc[1 ].offset =13 *sizeof (uint32_t ); reloc[1 ].target_handle = obj[0 ].handle; reloc[1 ].delta =sizeof (uint32_t ); - reloc[1 ].read_domains =I915_GEM_DOMAIN_INSTRUCTION ; - reloc[1 ].write_domain =I915_GEM_DOMAIN_INSTRUCTION ; + reloc[1 ].read_domains =I915_GEM_DOMAIN_COMMAND ; + reloc[1 ].write_domain =I915_GEM_DOMAIN_COMMAND ; obj[1 ].relocs_ptr = (uintptr_t )&reloc; obj[1 ].relocation_count =2 ;
@@ -152,7 +160,7 @@ static void exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds, int size, int patch_offset, uint64_t expected_value) { struct drm_i915_gem_execbuffer2 execbuf; -struct drm_i915_gem_exec_object2 objs[2 ]; +struct drm_i915_gem_exec_object2 obj[2 ];struct drm_i915_gem_relocation_entry reloc[1 ];uint32_t target_bo =gem_create (fd,4096 );
@@ -160,42 +168,24 @@ static void exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds,gem_write (fd, cmd_bo,0 , cmds, size); +memset (obj,0 ,sizeof (obj)); + obj[0 ].handle = target_bo; + obj[1 ].handle = cmd_bo; + +memset (reloc,0 ,sizeof (reloc)); reloc[0 ].offset = patch_offset; + reloc[0 ].target_handle = obj[0 ].handle; reloc[0 ].delta =0 ; - reloc[0 ].target_handle = target_bo; - reloc[0 ].read_domains =I915_GEM_DOMAIN_RENDER ; - reloc[0 ].write_domain =I915_GEM_DOMAIN_RENDER ; - reloc[0 ].presumed_offset =0 ; - - objs[0 ].handle = target_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 ; - - objs[1 ].handle = cmd_bo; - objs[1 ].relocation_count =1 ; - objs[1 ].relocs_ptr = (uintptr_t )reloc; - objs[1 ].alignment =0 ; - objs[1 ].offset =0 ; - objs[1 ].flags =0 ; - objs[1 ].rsvd1 =0 ; - objs[1 ].rsvd2 =0 ; - - execbuf.buffers_ptr = (uintptr_t )objs; + reloc[0 ].read_domains =I915_GEM_DOMAIN_COMMAND ; + reloc[0 ].write_domain =I915_GEM_DOMAIN_COMMAND ; + obj[1 ].relocs_ptr = (uintptr_t )reloc; + obj[1 ].relocation_count =1 ; + +memset (&execbuf,0 ,sizeof (execbuf)); + execbuf.buffers_ptr = (uintptr_t )obj; execbuf.buffer_count =2 ; - 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 =I915_EXEC_RENDER ; -i915_execbuffer2_set_context_id (execbuf,0 ); - execbuf.rsvd2 =0 ;gem_execbuf (fd, &execbuf);gem_sync (fd, cmd_bo);
@@ -210,30 +200,18 @@ static int __exec_batch(int fd, uint32_t cmd_bo, uint32_t *cmds, int size, int ring) {struct drm_i915_gem_execbuffer2 execbuf; -struct drm_i915_gem_exec_object2 objs[1 ]; +struct drm_i915_gem_exec_object2 obj[1 ];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 ; +memset (obj,0 ,sizeof (obj)); + obj[0 ].handle = cmd_bo; - execbuf.buffers_ptr = (uintptr_t )objs; +memset (&execbuf,0 ,sizeof (execbuf)); + execbuf.buffers_ptr = (uintptr_t )obj; 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 ;return __gem_execbuf (fd, &execbuf); }
@@ -244,7 +222,7 @@ static void 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 ]; +struct drm_i915_gem_exec_object2 obj[1 ];uint32_t cmd_bo;uint32_t noop[1024 ] = {0 };const int alloc_size =4096 *2 ;
@@ -261,16 +239,11 @@ static void exec_split_batch(int fd, uint32_t *cmds,*/ gem_write (fd, cmd_bo, actual_start_offset, 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 ; +memset (obj,0 ,sizeof (obj)); + obj[0 ].handle = cmd_bo; - execbuf.buffers_ptr = (uintptr_t )objs; +memset (&execbuf,0 ,sizeof (execbuf)); + execbuf.buffers_ptr = (uintptr_t )obj; execbuf.buffer_count =1 ;/* NB: We want batch_start_offset and batch_len to point to the block * of the actual commands (i.e. at the last dword of the first page),
@@ -281,13 +254,7 @@ static void exec_split_batch(int fd, uint32_t *cmds, execbuf.batch_len =ALIGN (size + actual_start_offset - execbuf.batch_start_offset,0x8 ); - 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 ;igt_assert_eq (__gem_execbuf (fd, &execbuf), expected_ret);
@@ -300,8 +267,8 @@ static void exec_batch_chained(int fd, uint32_t cmd_bo, uint32_t *cmds, uint64_t expected_value) {struct drm_i915_gem_execbuffer2 execbuf; -struct drm_i915_gem_exec_object2 objs[3 ]; -struct drm_i915_gem_relocation_entry reloc; +struct drm_i915_gem_exec_object2 obj[3 ]; +struct drm_i915_gem_relocation_entry reloc[1 ];struct drm_i915_gem_relocation_entry first_level_reloc;uint32_t target_bo =gem_create (fd,4096 );
@@ -322,58 +289,34 @@ static void exec_batch_chained(int fd, uint32_t cmd_bo, uint32_t *cmds, first_level_cmds, sizeof(first_level_cmds));gem_write (fd, cmd_bo,0 , cmds, size); - reloc.offset = patch_offset; - reloc.delta =0 ; - reloc.target_handle = target_bo; - reloc.read_domains =I915_GEM_DOMAIN_RENDER ; - reloc.write_domain =I915_GEM_DOMAIN_RENDER ; - reloc.presumed_offset =0 ; +memset (obj,0 ,sizeof (obj)); + obj[0 ].handle = target_bo; + obj[1 ].handle = cmd_bo; + obj[2 ].handle = first_level_bo; + +memset (reloc,0 ,sizeof (reloc)); + reloc[0 ].offset = patch_offset; + reloc[0 ].delta =0 ; + reloc[0 ].target_handle = target_bo; + reloc[0 ].read_domains =I915_GEM_DOMAIN_COMMAND ; + reloc[0 ].write_domain =I915_GEM_DOMAIN_COMMAND ; + obj[1 ].relocation_count =1 ; + obj[1 ].relocs_ptr = (uintptr_t )&reloc; +memset (&first_level_reloc,0 ,sizeof (first_level_reloc)); first_level_reloc.offset =4 ; first_level_reloc.delta =0 ; first_level_reloc.target_handle = cmd_bo; - first_level_reloc.read_domains =I915_GEM_DOMAIN_INSTRUCTION ; + first_level_reloc.read_domains =I915_GEM_DOMAIN_COMMAND ; first_level_reloc.write_domain =0 ; - first_level_reloc.presumed_offset =0 ; - - objs[0 ].handle = target_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 ; - - objs[1 ].handle = cmd_bo; - objs[1 ].relocation_count =1 ; - objs[1 ].relocs_ptr = (uintptr_t )&reloc; - objs[1 ].alignment =0 ; - objs[1 ].offset =0 ; - objs[1 ].flags =0 ; - objs[1 ].rsvd1 =0 ; - objs[1 ].rsvd2 =0 ; - - objs[2 ].handle = first_level_bo; - objs[2 ].relocation_count =1 ; - objs[2 ].relocs_ptr = (uintptr_t )&first_level_reloc; - objs[2 ].alignment =0 ; - objs[2 ].offset =0 ; - objs[2 ].flags =0 ; - objs[2 ].rsvd1 =0 ; - objs[2 ].rsvd2 =0 ; - - execbuf.buffers_ptr = (uintptr_t )objs; + obj[2 ].relocation_count =1 ; + obj[2 ].relocs_ptr = (uintptr_t )&first_level_reloc; + +memset (&execbuf,0 ,sizeof (execbuf)); + execbuf.buffers_ptr = (uintptr_t )obj; execbuf.buffer_count =3 ; - execbuf.batch_start_offset =0 ; execbuf.batch_len =sizeof (first_level_cmds); - execbuf.cliprects_ptr =0 ; - execbuf.num_cliprects =0 ; - execbuf.DR1 =0 ; - execbuf.DR4 =0 ; execbuf.flags =I915_EXEC_RENDER ; -i915_execbuffer2_set_context_id (execbuf,0 ); - execbuf.rsvd2 =0 ;gem_execbuf (fd, &execbuf);gem_sync (fd, cmd_bo);
@@ -441,15 +384,8 @@ static void test_allocations(int fd) } } -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) -#define PIPE_CONTROL_LRI_POST_OP (1<<23) +static uint32_t handle; +static int fd; igt_main {
Signature · 6 lines
2.10.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 3/13 igt/gem_exec_parse: move hsw_load_register_reg down
In reply to Robert BraggNo functional change, just moving hsw_load_regster_reg test code down below the execbuf utilities in preparation for updating to use them.
--- tests/gem_exec_parse.c | 182 ++++++++++++++++++++++++------------------------- 1 file changed, 91 insertions(+), 91 deletions(-)
tests/gem_exec_parse.c +91 -91
@@ -65,97 +65,6 @@ static int command_parser_version(int fd)return -1 ; } -static void hsw_load_register_reg (void ) -{ -uint32_t buf[16 ] = { -MI_LOAD_REGISTER_IMM | (5 -2 ), -HSW_CS_GPR0 , -0xabcdabcd , -HSW_CS_GPR1 , -0xdeadbeef , - -MI_STORE_REGISTER_MEM | (3 -2 ), -HSW_CS_GPR1 , -0 ,/* address0 */ - -MI_LOAD_REGISTER_REG | (3 -2 ), -HSW_CS_GPR0 , -HSW_CS_GPR1 , - -MI_STORE_REGISTER_MEM | (3 -2 ), -HSW_CS_GPR1 , -4 ,/* address1 */ - -MI_BATCH_BUFFER_END , - }; -struct drm_i915_gem_execbuffer2 execbuf; -struct drm_i915_gem_exec_object2 obj[2 ]; -struct drm_i915_gem_relocation_entry reloc[2 ]; -int fd; - -/* Open again to get a non-master file descriptor */ - fd =drm_open_driver (DRIVER_INTEL ); - -igt_require (IS_HASWELL (intel_get_drm_devid (fd))); -igt_require (command_parser_version (fd) >=7 ); - -memset (obj,0 ,sizeof (obj)); - obj[0 ].handle =gem_create (fd,4096 ); - obj[1 ].handle =gem_create (fd,4096 ); -gem_write (fd, obj[1 ].handle,0 , buf,sizeof (buf)); - -memset (reloc,0 ,sizeof (reloc)); - reloc[0 ].offset =7 *sizeof (uint32_t ); - reloc[0 ].target_handle = obj[0 ].handle; - reloc[0 ].delta =0 ; - reloc[0 ].read_domains =I915_GEM_DOMAIN_COMMAND ; - reloc[0 ].write_domain =I915_GEM_DOMAIN_COMMAND ; - reloc[1 ].offset =13 *sizeof (uint32_t ); - reloc[1 ].target_handle = obj[0 ].handle; - reloc[1 ].delta =sizeof (uint32_t ); - reloc[1 ].read_domains =I915_GEM_DOMAIN_COMMAND ; - reloc[1 ].write_domain =I915_GEM_DOMAIN_COMMAND ; - obj[1 ].relocs_ptr = (uintptr_t )&reloc; - obj[1 ].relocation_count =2 ; - -memset (&execbuf,0 ,sizeof (execbuf)); - execbuf.buffers_ptr = (uintptr_t )obj; - execbuf.buffer_count =2 ; - execbuf.batch_len =sizeof (buf); - execbuf.flags =I915_EXEC_RENDER ; -gem_execbuf (fd, &execbuf); -gem_close (fd, obj[1 ].handle); - -gem_read (fd, obj[0 ].handle,0 , buf,2 *sizeof (buf[0 ])); -igt_assert_eq_u32 (buf[0 ],0xdeadbeef );/* before copy */ -igt_assert_eq_u32 (buf[1 ],0xabcdabcd );/* after copy */ - -/* Now a couple of negative tests that should be filtered */ - execbuf.buffer_count =1 ; - execbuf.batch_len =4 *sizeof (buf[0 ]); - - buf[0 ] =MI_LOAD_REGISTER_REG | (3 -2 ); - buf[1 ] =HSW_CS_GPR0 ; - buf[2 ] =0 ; - buf[3 ] =MI_BATCH_BUFFER_END ; -gem_write (fd, obj[0 ].handle,0 , buf, execbuf.batch_len); -igt_assert_eq (__gem_execbuf (fd, &execbuf), -EINVAL ); - - buf[2 ] =OACONTROL ;/* filtered */ -gem_write (fd, obj[0 ].handle,0 , buf, execbuf.batch_len); -igt_assert_eq (__gem_execbuf (fd, &execbuf), -EINVAL ); - - buf[2 ] =DERRMR ;/* master only */ -gem_write (fd, obj[0 ].handle,0 , buf, execbuf.batch_len); -igt_assert_eq (__gem_execbuf (fd, &execbuf), -EINVAL ); - - buf[2 ] =0x2038 ;/* RING_START: invalid */ -gem_write (fd, obj[0 ].handle,0 , buf, execbuf.batch_len); -igt_assert_eq (__gem_execbuf (fd, &execbuf), -EINVAL ); - -close (fd); -} -static void exec_batch_patched (int fd,uint32_t cmd_bo,uint32_t *cmds,int size,int patch_offset,uint64_t expected_value) {
@@ -384,6 +293,97 @@ static void test_allocations(int fd) } } +static void hsw_load_register_reg (void ) +{ +uint32_t buf[16 ] = { +MI_LOAD_REGISTER_IMM | (5 -2 ), +HSW_CS_GPR0 , +0xabcdabcd , +HSW_CS_GPR1 , +0xdeadbeef , + +MI_STORE_REGISTER_MEM | (3 -2 ), +HSW_CS_GPR1 , +0 ,/* address0 */ + +MI_LOAD_REGISTER_REG | (3 -2 ), +HSW_CS_GPR0 , +HSW_CS_GPR1 , + +MI_STORE_REGISTER_MEM | (3 -2 ), +HSW_CS_GPR1 , +4 ,/* address1 */ + +MI_BATCH_BUFFER_END , + }; +struct drm_i915_gem_execbuffer2 execbuf; +struct drm_i915_gem_exec_object2 obj[2 ]; +struct drm_i915_gem_relocation_entry reloc[2 ]; +int fd; + +/* Open again to get a non-master file descriptor */ + fd =drm_open_driver (DRIVER_INTEL ); + +igt_require (IS_HASWELL (intel_get_drm_devid (fd))); +igt_require (command_parser_version (fd) >=7 ); + +memset (obj,0 ,sizeof (obj)); + obj[0 ].handle =gem_create (fd,4096 ); + obj[1 ].handle =gem_create (fd,4096 ); +gem_write (fd, obj[1 ].handle,0 , buf,sizeof (buf)); + +memset (reloc,0 ,sizeof (reloc)); + reloc[0 ].offset =7 *sizeof (uint32_t ); + reloc[0 ].target_handle = obj[0 ].handle; + reloc[0 ].delta =0 ; + reloc[0 ].read_domains =I915_GEM_DOMAIN_COMMAND ; + reloc[0 ].write_domain =I915_GEM_DOMAIN_COMMAND ; + reloc[1 ].offset =13 *sizeof (uint32_t ); + reloc[1 ].target_handle = obj[0 ].handle; + reloc[1 ].delta =sizeof (uint32_t ); + reloc[1 ].read_domains =I915_GEM_DOMAIN_COMMAND ; + reloc[1 ].write_domain =I915_GEM_DOMAIN_COMMAND ; + obj[1 ].relocs_ptr = (uintptr_t )&reloc; + obj[1 ].relocation_count =2 ; + +memset (&execbuf,0 ,sizeof (execbuf)); + execbuf.buffers_ptr = (uintptr_t )obj; + execbuf.buffer_count =2 ; + execbuf.batch_len =sizeof (buf); + execbuf.flags =I915_EXEC_RENDER ; +gem_execbuf (fd, &execbuf); +gem_close (fd, obj[1 ].handle); + +gem_read (fd, obj[0 ].handle,0 , buf,2 *sizeof (buf[0 ])); +igt_assert_eq_u32 (buf[0 ],0xdeadbeef );/* before copy */ +igt_assert_eq_u32 (buf[1 ],0xabcdabcd );/* after copy */ + +/* Now a couple of negative tests that should be filtered */ + execbuf.buffer_count =1 ; + execbuf.batch_len =4 *sizeof (buf[0 ]); + + buf[0 ] =MI_LOAD_REGISTER_REG | (3 -2 ); + buf[1 ] =HSW_CS_GPR0 ; + buf[2 ] =0 ; + buf[3 ] =MI_BATCH_BUFFER_END ; +gem_write (fd, obj[0 ].handle,0 , buf, execbuf.batch_len); +igt_assert_eq (__gem_execbuf (fd, &execbuf), -EINVAL ); + + buf[2 ] =OACONTROL ;/* filtered */ +gem_write (fd, obj[0 ].handle,0 , buf, execbuf.batch_len); +igt_assert_eq (__gem_execbuf (fd, &execbuf), -EINVAL ); + + buf[2 ] =DERRMR ;/* master only */ +gem_write (fd, obj[0 ].handle,0 , buf, execbuf.batch_len); +igt_assert_eq (__gem_execbuf (fd, &execbuf), -EINVAL ); + + buf[2 ] =0x2038 ;/* RING_START: invalid */ +gem_write (fd, obj[0 ].handle,0 , buf, execbuf.batch_len); +igt_assert_eq (__gem_execbuf (fd, &execbuf), -EINVAL ); + +close (fd); +} +static uint32_t handle;static int fd;
Signature · 6 lines
2.10.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 4/13 igt/gem_exec_parse: update hsw_load_register_reg
In reply to Robert BraggThis generalises hsw_load_register_reg to loop through an array of allowed and disallowed registers and to use the exec_batch[_patched] utilities.
--- tests/gem_exec_parse.c | 137 +++++++++++++++++++++++-------------------------- 1 file changed, 64 insertions(+), 73 deletions(-)
tests/gem_exec_parse.c +64 -73
@@ -34,8 +34,9 @@#define I915_PARAM_CMD_PARSER_VERSION 28#endif -#define OACONTROL 0x2360#define DERRMR 0x44050 +#define OACONTROL 0x2360 +#define SO_WRITE_OFFSET_0 0x5280#define HSW_CS_GPR (n) (0x2600 + 8*(n))#define HSW_CS_GPR0 HSW_CS_GPR(0)
@@ -65,8 +66,8 @@ static int command_parser_version(int fd)return -1 ; } -static void exec_batch_patched (int fd,uint32_t cmd_bo,uint32_t *cmds, -int size,int patch_offset,uint64_t expected_value) +static uint64_t __exec_batch_patched (int fd,uint32_t cmd_bo,uint32_t *cmds, +int size,int patch_offset) {struct drm_i915_gem_execbuffer2 execbuf;struct drm_i915_gem_exec_object2 obj[2 ];
@@ -100,9 +101,19 @@ static void exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds,gem_sync (fd, cmd_bo);gem_read (fd,target_bo,0 , &actual_value,sizeof (actual_value)); -igt_assert_eq (expected_value, actual_value);gem_close (fd, target_bo); + +return actual_value; +} + +static void exec_batch_patched (int fd,uint32_t cmd_bo,uint32_t *cmds, +int size,int patch_offset, +uint64_t expected_value) +{ +igt_assert_eq (__exec_batch_patched (fd, cmd_bo, cmds, + size, patch_offset), + expected_value); } static int __exec_batch(int fd, uint32_t cmd_bo, uint32_t *cmds,
@@ -295,31 +306,36 @@ static void test_allocations(int fd)static void hsw_load_register_reg (void ) { -uint32_t buf[16 ] = { -MI_LOAD_REGISTER_IMM | (5 -2 ), +uint32_t init_gpr0[16 ] = { +MI_LOAD_REGISTER_IMM | (3 -2 ),HSW_CS_GPR0 , -0xabcdabcd , -HSW_CS_GPR1 , -0xdeadbeef , - +0xabcdabc0 ,/* leave [1:0] zero */ +MI_BATCH_BUFFER_END , + }; +uint32_t store_gpr0[16 ] = {MI_STORE_REGISTER_MEM | (3 -2 ), -HSW_CS_GPR1 , -0 ,/* address0 */ - -MI_LOAD_REGISTER_REG | (3 -2 ),HSW_CS_GPR0 , -HSW_CS_GPR1 , - -MI_STORE_REGISTER_MEM | (3 -2 ), -HSW_CS_GPR1 , -4 ,/* address1 */ - +0 ,/* reloc*/ MI_BATCH_BUFFER_END , }; -struct drm_i915_gem_execbuffer2 execbuf; -struct drm_i915_gem_exec_object2 obj[2 ]; -struct drm_i915_gem_relocation_entry reloc[2 ]; +uint32_t do_lrr[16 ] = { +MI_LOAD_REGISTER_REG | (3 -2 ), +0 ,/* [1] = src */ +HSW_CS_GPR0 ,/* dst */ +MI_BATCH_BUFFER_END , + }; +uint32_t allowed_regs[] = { +HSW_CS_GPR1 , +SO_WRITE_OFFSET_0 , + }; +uint32_t disallowed_regs[] = { +0 , +OACONTROL ,/* filtered */ +DERRMR ,/* master only */ +0x2038 ,/* RING_START: invalid */ + };int fd; +uint32_t handle;/* Open again to get a non-master file descriptor */ fd =drm_open_driver (DRIVER_INTEL );
@@ -327,59 +343,34 @@ static void hsw_load_register_reg(void)igt_require (IS_HASWELL (intel_get_drm_devid (fd)));igt_require (command_parser_version (fd) >=7 ); -memset (obj,0 ,sizeof (obj)); - obj[0 ].handle =gem_create (fd,4096 ); - obj[1 ].handle =gem_create (fd,4096 ); -gem_write (fd, obj[1 ].handle,0 , buf,sizeof (buf)); + handle =gem_create (fd,4096 ); -memset (reloc,0 ,sizeof (reloc)); - reloc[0 ].offset =7 *sizeof (uint32_t ); - reloc[0 ].target_handle = obj[0 ].handle; - reloc[0 ].delta =0 ; - reloc[0 ].read_domains =I915_GEM_DOMAIN_COMMAND ; - reloc[0 ].write_domain =I915_GEM_DOMAIN_COMMAND ; - reloc[1 ].offset =13 *sizeof (uint32_t ); - reloc[1 ].target_handle = obj[0 ].handle; - reloc[1 ].delta =sizeof (uint32_t ); - reloc[1 ].read_domains =I915_GEM_DOMAIN_COMMAND ; - reloc[1 ].write_domain =I915_GEM_DOMAIN_COMMAND ; - obj[1 ].relocs_ptr = (uintptr_t )&reloc; - obj[1 ].relocation_count =2 ; +for (int i =0 ; i <ARRAY_SIZE (allowed_regs); i++) { +uint32_t var; -memset (&execbuf,0 ,sizeof (execbuf)); - execbuf.buffers_ptr = (uintptr_t )obj; - execbuf.buffer_count =2 ; - execbuf.batch_len =sizeof (buf); - execbuf.flags =I915_EXEC_RENDER ; -gem_execbuf (fd, &execbuf); -gem_close (fd, obj[1 ].handle); - -gem_read (fd, obj[0 ].handle,0 , buf,2 *sizeof (buf[0 ])); -igt_assert_eq_u32 (buf[0 ],0xdeadbeef );/* before copy */ -igt_assert_eq_u32 (buf[1 ],0xabcdabcd );/* after copy */ +exec_batch (fd, handle, init_gpr0,sizeof (init_gpr0), +I915_EXEC_RENDER , +0 ); +exec_batch_patched (fd, handle, + store_gpr0,sizeof (store_gpr0), +2 *sizeof (uint32_t ),/* reloc */ +0xabcdabc0 ); + do_lrr[1 ] = allowed_regs[i]; +exec_batch (fd, handle, do_lrr,sizeof (do_lrr), +I915_EXEC_RENDER , +0 ); + var =__exec_batch_patched (fd, handle, + store_gpr0,sizeof (store_gpr0), +2 *sizeof (uint32_t ));/* reloc */ +igt_assert_neq (var,0xabcdabc0 ); + } -/* Now a couple of negative tests that should be filtered */ - execbuf.buffer_count =1 ; - execbuf.batch_len =4 *sizeof (buf[0 ]); - - buf[0 ] =MI_LOAD_REGISTER_REG | (3 -2 ); - buf[1 ] =HSW_CS_GPR0 ; - buf[2 ] =0 ; - buf[3 ] =MI_BATCH_BUFFER_END ; -gem_write (fd, obj[0 ].handle,0 , buf, execbuf.batch_len); -igt_assert_eq (__gem_execbuf (fd, &execbuf), -EINVAL ); - - buf[2 ] =OACONTROL ;/* filtered */ -gem_write (fd, obj[0 ].handle,0 , buf, execbuf.batch_len); -igt_assert_eq (__gem_execbuf (fd, &execbuf), -EINVAL ); - - buf[2 ] =DERRMR ;/* master only */ -gem_write (fd, obj[0 ].handle,0 , buf, execbuf.batch_len); -igt_assert_eq (__gem_execbuf (fd, &execbuf), -EINVAL ); - - buf[2 ] =0x2038 ;/* RING_START: invalid */ -gem_write (fd, obj[0 ].handle,0 , buf, execbuf.batch_len); -igt_assert_eq (__gem_execbuf (fd, &execbuf), -EINVAL ); +for (int i =0 ; i <ARRAY_SIZE (disallowed_regs); i++) { + do_lrr[1 ] = disallowed_regs[i]; +exec_batch (fd, handle, do_lrr,sizeof (do_lrr), +I915_EXEC_RENDER , + -EINVAL ); + }close (fd); }
Signature · 6 lines
2.10.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 5/13 igt/gem_exec_parse: make global vars local to main()
In reply to Robert Bragg--- tests/gem_exec_parse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tests/gem_exec_parse.c +3 -3
@@ -375,11 +375,11 @@ static void hsw_load_register_reg(void)close (fd); } -static uint32_t handle; -static int fd; - igt_main { +uint32_t handle; +int fd; + igt_fixture {int parser_version =0 ;drm_i915_getparam_t gp;
Signature · 6 lines
2.10.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH igt v4 05/13] igt/gem_exec_parse: make global vars local to main()
Quoted 1 line · Robert Bragg
Signed-off-by Robert Bragg <[email protected]>
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 6/13 igt/gem_exec_parse: init global parser_version in fixture
In reply to Robert BraggThis adds a static global int parser_version that can be referenced by all subtests without needing multiple GETPARAM requests.
--- tests/gem_exec_parse.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
tests/gem_exec_parse.c +4 -9
@@ -51,6 +51,7 @@#define PIPE_CONTROL_QW_WRITE (1<<14)#define PIPE_CONTROL_LRI_POST_OP (1<<23) +static int parser_version;static int command_parser_version (int fd) {
@@ -341,7 +342,7 @@ static void hsw_load_register_reg(void) fd =drm_open_driver (DRIVER_INTEL );igt_require (IS_HASWELL (intel_get_drm_devid (fd))); -igt_require (command_parser_version (fd) >=7 ); +igt_require (parser_version >=7 ); handle =gem_create (fd,4096 );
@@ -381,16 +382,10 @@ igt_mainint fd; igt_fixture { -int parser_version =0 ; -drm_i915_getparam_t gp; -int rc; - fd =drm_open_driver (DRIVER_INTEL ); - gp.param =I915_PARAM_CMD_PARSER_VERSION ; - gp.value = &parser_version; - rc =drmIoctl (fd,DRM_IOCTL_I915_GETPARAM , &gp); -igt_require (!rc && parser_version >0 ); + parser_version =command_parser_version (fd); +igt_require (parser_version !=-1 );igt_require (gem_uses_ppgtt (fd));
Signature · 6 lines
2.10.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH igt v4 06/13] igt/gem_exec_parse: init global parser_version in fixture
Quoted 4 lines · Robert Bragg
This adds a static global int
parser_versionthat can be referenced by all subtests without needing multiple GETPARAM requests.Signed-off-by Robert Bragg <[email protected]>
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 7/13 igt/gem_exec_parse: req. v < 9 for oacontrol tracking test
In reply to Robert BraggThis limits testing the oacontrol tracking (required pairing of oa enable/disable per batch buffer) to version <= 8 of the command parser.
Version 9 of the command parser removes all special handling for OACONTROL which is now going to be managed by i915-perf and not programmed from userspace.
--- tests/gem_exec_parse.c | 3 +++ 1 file changed, 3 insertions(+)
tests/gem_exec_parse.c +3 -0
@@ -551,6 +551,9 @@ igt_main0x31337000 ,MI_BATCH_BUFFER_END , }; + +igt_require (parser_version <9 ); + exec_batch(fd, handle, lri_ok, sizeof(lri_ok), I915_EXEC_RENDER,
Signature · 6 lines
2.10.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 8/13 igt/gem_exec_parse: make basic-rejected version agnostic
In reply to Robert BraggThis adapts the basic-rejected test to focus on invalid commands that will result in an EINVAL errno being returned to userspace even with the upcoming version 8 parser change to stop reporting access violations as EINVAL errors.
--- tests/gem_exec_parse.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
tests/gem_exec_parse.c +20 -11
@@ -42,6 +42,10 @@#define HSW_CS_GPR0 HSW_CS_GPR(0)#define HSW_CS_GPR1 HSW_CS_GPR(1) +/* To help craft commands known to be invalid across all engines */ +#define INSTR_CLIENT_SHIFT 29 +#define INSTR_INVALID_CLIENT 0x7 +#define MI_LOAD_REGISTER_REG (0x2a << 23)#define MI_STORE_REGISTER_MEM (0x24 << 23)#define MI_ARB_ON_OFF (0x8 << 23)
@@ -411,33 +415,38 @@ igt_main } igt_subtest("basic-rejected") { -uint32_t arb_on_off[] = { -MI_ARB_ON_OFF , +uint32_t invalid_cmd[] = { +INSTR_INVALID_CLIENT <<INSTR_CLIENT_SHIFT ,MI_BATCH_BUFFER_END , }; -uint32_t display_flip[] = { -MI_DISPLAY_FLIP , -0 ,0 ,0 , +uint32_t invalid_set_context[] = { +MI_SET_CONTEXT |32 ,/* invalid length */ MI_BATCH_BUFFER_END , -0 };exec_batch (fd, handle, - arb_on_off,sizeof (arb_on_off), + invalid_cmd,sizeof (invalid_cmd),I915_EXEC_RENDER , -EINVAL );exec_batch (fd, handle, - arb_on_off,sizeof (arb_on_off), + invalid_cmd,sizeof (invalid_cmd),I915_EXEC_BSD , -EINVAL ); +if (gem_has_blt (fd)) { +exec_batch (fd, handle, + invalid_cmd,sizeof (invalid_cmd), +I915_EXEC_BLT , + -EINVAL ); + }if (gem_has_vebox (fd)) {exec_batch (fd, handle, - arb_on_off,sizeof (arb_on_off), + invalid_cmd,sizeof (invalid_cmd),I915_EXEC_VEBOX , -EINVAL ); } +exec_batch (fd, handle, - display_flip,sizeof (display_flip), -I915_EXEC_BLT , + invalid_set_context,sizeof (invalid_set_context), +I915_EXEC_RENDER , -EINVAL ); }
Signature · 6 lines
2.10.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 9/13 igt/gem_exec_parse: update bitmasks test for v >=8
In reply to Robert BraggWith v8 of the command parser (where we won't get an EINVAL for an access violation) this updates the bitmasks test to explicitly confirm that the command became a NOOP by reading back from where the QW_WRITE would have otherwise landed.
--- tests/gem_exec_parse.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
tests/gem_exec_parse.c +14 -4
@@ -504,10 +504,20 @@ igt_main0 , MI_BATCH_BUFFER_END, }; -exec_batch (fd, handle, - pc,sizeof (pc), -I915_EXEC_RENDER , - -EINVAL ); +if (parser_version >=8 ) { +/* Expect to read back zero since the command should be +* squashed to a NOOP +*/ +exec_batch_patched (fd, handle, + pc,sizeof (pc), +8 ,/* patch offset, */ +0x0 ); + }else { +exec_batch (fd, handle, + pc,sizeof (pc), +I915_EXEC_RENDER , + -EINVAL ); + } } igt_subtest("batch-without-end") {
Signature · 6 lines
2.10.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 10/13 igt/gem_exec_parse: update cmd-crossing-page for >= v8
In reply to Robert BraggSince an access violation won't return an error to userspace for v >= 8 of the command parser this updates the cmd-crossing-page test to explicitly read back from SO_WRITE_OFFSET[0] to see that the command wasn't squashed to a NOOP.
--- tests/gem_exec_parse.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
tests/gem_exec_parse.c +13 -2
@@ -531,14 +531,25 @@ igt_main igt_subtest("cmd-crossing-page") {uint32_t lri_ok[] = {MI_LOAD_REGISTER_IMM , -0x5280 ,/* allowed register address (SO_WRITE_OFFSET[0]) */ -0x1 , +SO_WRITE_OFFSET_0 ,/* allowed register address */ +0xdcbaabc0 ,/* [1:0] MBZ */ +MI_BATCH_BUFFER_END , + }; +uint32_t store_reg[] = { +MI_STORE_REGISTER_MEM | (3 -2 ), +SO_WRITE_OFFSET_0 , +0 ,/* reloc */ MI_BATCH_BUFFER_END , };exec_split_batch (fd, lri_ok,sizeof (lri_ok),I915_EXEC_RENDER ,0 ); +exec_batch_patched (fd, handle, + store_reg, +sizeof (store_reg), +2 *sizeof (uint32_t ),/* reloc */ +0xdcbaabc0 ); } igt_subtest("oacontrol-tracking") {
Signature · 6 lines
2.10.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 11/13 igt/gem_exec_parse: update hsw_load_register_reg for v >= 8
In reply to Robert BraggThis updates the checking of disallowed loads to set a distinguishable value before the load and explicitly check the load was a NOOP by reading back the final value.
--- tests/gem_exec_parse.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
tests/gem_exec_parse.c +13 -1
@@ -341,6 +341,7 @@ static void hsw_load_register_reg(void) };int fd;uint32_t handle; +int bad_lrr_errno = parser_version >=8 ?0 : -EINVAL ;/* Open again to get a non-master file descriptor */ fd =drm_open_driver (DRIVER_INTEL );
@@ -371,10 +372,21 @@ static void hsw_load_register_reg(void) }for (int i =0 ; i <ARRAY_SIZE (disallowed_regs); i++) { +exec_batch (fd, handle, init_gpr0,sizeof (init_gpr0), +I915_EXEC_RENDER , +0 ); +exec_batch_patched (fd, handle, + store_gpr0,sizeof (store_gpr0), +2 *sizeof (uint32_t ),/* reloc */ +0xabcdabc0 ); do_lrr[1 ] = disallowed_regs[i];exec_batch (fd, handle, do_lrr,sizeof (do_lrr),I915_EXEC_RENDER , - -EINVAL ); + bad_lrr_errno); +exec_batch_patched (fd, handle, + store_gpr0,sizeof (store_gpr0), +2 *sizeof (uint32_t ),/* reloc */ +0xabcdabc0 ); }close (fd);
Signature · 6 lines
2.10.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 12/13 igt/gem_exec_parse: update registers test for v >= 8
In reply to Robert BraggThis combines some parts of the recently added store_lri test with the registers test to be able to first load a distinguishable value before the LRI and explicitly read back the register to determine if the command succeeded or was a NOOP.
For now though we won't look at OACONTROL without checking for version 9 of the command parser.
This updates the 'bad' test to check the OASTATUS2 register so that we can explicitly read back from the register to check it becomes a NOOP.
This adds a struct test_lri for associating a mask with the init/test values so we ignore things like hw status bits that might interfere with the result.
--- tests/gem_exec_parse.c | 94 ++++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 45 deletions(-)
tests/gem_exec_parse.c +49 -45
@@ -35,6 +35,7 @@#endif #define DERRMR 0x44050 +#define OASTATUS2 0x2368#define OACONTROL 0x2360#define SO_WRITE_OFFSET_0 0x5280
@@ -253,27 +254,35 @@ static void exec_batch_chained(int fd, uint32_t cmd_bo, uint32_t *cmds,gem_close (fd, target_bo); } -static void stray_lri (int fd,uint32_t handle) +/* Be careful to take into account what register bits we can store and read +* from... +*/ +struct test_lri { +uint32_t reg, read_mask, init_val, test_val; +}; + +static void +test_lri (int fd,uint32_t handle, +struct test_lri *test,int expected_errno,uint32_t expect) { -/* Ideally this would test all once whitelisted registers */ uint32_t lri[] = {MI_LOAD_REGISTER_IMM , -OACONTROL , -0x31337000 , + test->reg, + test->test_val,MI_BATCH_BUFFER_END , }; -int err; -igt_assert_eq_u32 (intel_register_read (OACONTROL ),0xdeadbeef ); +intel_register_write (test->reg, test->init_val); - err =__exec_batch (fd, handle, lri,sizeof (lri),I915_EXEC_RENDER ); -if (err == -EINVAL ) -return ; - -igt_assert_eq (err,0 ); +exec_batch (fd, handle, + lri,sizeof (lri), +I915_EXEC_RENDER , + expected_errno);gem_sync (fd, handle); -igt_assert_eq_u32 (intel_register_read (OACONTROL ),0xdeadbeef ); +igt_assert_eq_u32 ((intel_register_read (test->reg) & + test->read_mask), + expect); }static void test_allocations (int fd)
@@ -462,50 +471,45 @@ igt_main -EINVAL); } + igt_subtest("basic-allocation") { +test_allocations (fd); + } + igt_subtest_group { igt_fixture {intel_register_access_init (intel_get_pci_device (),0 ); - -intel_register_write (OACONTROL ,0xdeadbeef ); -igt_assert_eq_u32 (intel_register_read (OACONTROL ),0xdeadbeef ); } - igt_subtest("basic-stray-lri") -stray_lri (fd, handle); + igt_subtest("registers") { +struct test_lri bad_lris[] = { +/* dummy head pointer */ + {OASTATUS2 ,0xffffff80 ,0xdeadf000 ,0xbeeff000 } + }; +struct test_lri ok_lris[] = { +/* NB: [1:0] MBZ */ + {SO_WRITE_OFFSET_0 ,0xfffffffc , +0xabcdabc0 ,0xbeefbee0 } + }; +int bad_lri_errno = parser_version >=8 ?0 : -EINVAL ; + +for (int i =0 ; i <ARRAY_SIZE (ok_lris); i++) { +test_lri (fd, handle, + ok_lris + i,0 , + ok_lris[i].test_val); + } + +for (int i =0 ; i <ARRAY_SIZE (bad_lris); i++) { +test_lri (fd, handle, + bad_lris + i, bad_lri_errno, + bad_lris[i].init_val); + } + } igt_fixture { -intel_register_write (OACONTROL ,0 );intel_register_access_fini (); } } - igt_subtest("basic-allocation") { -test_allocations (fd); - } - - 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 , - }; -exec_batch (fd, handle, - lri_bad,sizeof (lri_bad), -I915_EXEC_RENDER , - -EINVAL ); -exec_batch (fd, handle, - lri_ok,sizeof (lri_ok), -I915_EXEC_RENDER , -0 ); - } - igt_subtest("bitmasks") { uint32_t pc[] = { GFX_OP_PIPE_CONTROL,
Signature · 6 lines
2.10.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH igt v4 12/13] igt/gem_exec_parse: update registers test for v >= 8
Quoted 34 lines · Robert Bragg
This combines some parts of the recently added
store_lritest with the registers test to be able to first load a distinguishable value before the LRI and explicitly read back the register to determine if the command succeeded or was a NOOP.For now though we won't look at OACONTROL without checking for version 9 of the command parser.
This updates the 'bad' test to check the OASTATUS2 register so that we can explicitly read back from the register to check it becomes a NOOP.
This adds a struct
test_lrifor associating a mask with the init/test values so we ignore things like hw status bits that might interfere with the result.Signed-off-by Robert Bragg <[email protected]>Reviewed-by Matthew Auld <[email protected]>--- tests/gem_exec_parse.c | 94 ++++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 45 deletions(-)tests/gem_exec_parse.c +1
-0@@ -35,6 +35,7 @@#endif #define DERRMR 0x44050 +#define OASTATUS2 0x2368#define OACONTROL 0x2360#define SO_WRITE_OFFSET_0 0x5280
tests/gem_exec_parse.c static void exec_batch_chained(int fd, uint32_t cmd_bo, uint32_t *cmds, · line 256
Quoted 4 lines
tests/gem_exec_parse.c +0
-1@@ -253,27 +254,35 @@ static void exec_batch_chained(int fd, uint32_t cmd_bo, uint32_t *cmds,gem_close (fd, target_bo); } -static void stray_lri (int fd,uint32_t handle)
Ahem. Why did you remove that agnostic test without replacing it? -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH igt v4 12/13] igt/gem_exec_parse: update registers test for v >= 8
Quoted 34 lines · Chris Wilson
Quoted 33 lines · Robert Bragg
This combines some parts of the recently added
store_lritest with the registers test to be able to first load a distinguishable value before the LRI and explicitly read back the register to determine if the command succeeded or was a NOOP.For now though we won't look at OACONTROL without checking for version 9 of the command parser.
This updates the 'bad' test to check the OASTATUS2 register so that we can explicitly read back from the register to check it becomes a NOOP.
This adds a struct
test_lrifor associating a mask with the init/test values so we ignore things like hw status bits that might interfere with the result.Signed-off-by Robert Bragg <[email protected]>Reviewed-by Matthew Auld <[email protected]>--- tests/gem_exec_parse.c | 94 ++++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 45 deletions(-)tests/gem_exec_parse.c +1
-0@@ -35,6 +35,7 @@#endif #define DERRMR 0x44050 +#define OASTATUS2 0x2368#define OACONTROL 0x2360#define SO_WRITE_OFFSET_0 0x5280
Quoted 7 lines
tests/gem_exec_parse.c static void exec_batch_chained(int fd, uint32_t cmd_bo, uint32_t *cmds, · line 256
Quoted 5 lines
tests/gem_exec_parse.c +0
-1@@ -253,27 +254,35 @@ static void exec_batch_chained(int fd, uint32_t cmd_bo, uint32_t *cmds,gem_close (fd, target_bo); } -static void stray_lri (int fd,uint32_t handle)Ahem. Why did you remove that agnostic test without replacing it?
In a later patch, that was annoying. But it is not being tested for the rejection. test_lri() doesn't check the register write took (always useful to test the setup first), nor does it provide a good hint as to which lri failed. Either that needs expanding upon, or the multiple tests extracted into separate subtests.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 igt/gem_exec_parse: test_lri check init + add debug msg
Just to note I haven't tested yet as I don't have hsw to hand, but seems simple enough to send out anyway...
--- >8 ---
To make it clear on failure what register was being tested the test_lri helper now uses igt_debug to log the register address and value being tested. The test_lri helper now also double checks that the initial intel_register_write() takes before issuing the LRI.
--- tests/gem_exec_parse.c | 7 +++++++ 1 file changed, 7 insertions(+)
tests/gem_exec_parse.c +7 -0
@@ -272,8 +272,15 @@ test_lri(int fd, uint32_t handle,MI_BATCH_BUFFER_END , }; +igt_debug ("testing lri, reg=%x, val=%x, expected errno=%d\n" , + test->reg, test->test_val, expected_errno); +intel_register_write (test->reg, test->init_val); +igt_assert_eq_u32 ((intel_register_read (test->reg) & + test->read_mask), + test->init_val); + exec_batch(fd, handle, lri, sizeof(lri), I915_EXEC_RENDER,
Signature · 6 lines
2.10.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH igt] igt/gem_exec_parse: test_lri check init + add debug msg
Quoted 21 lines · Robert Bragg
Just to note I haven't tested yet as I don't have hsw to hand, but seems simple enough to send out anyway...
--- >8 ---
To make it clear on failure what register was being tested the
test_lrihelper now usesigt_debugto log the register address and value being tested. Thetest_lrihelper now also double checks that the initialintel_register_write()takes before issuing the LRI.Signed-off-by Robert Bragg <[email protected]>--- tests/gem_exec_parse.c | 7 +++++++ 1 file changed, 7 insertions(+)tests/gem_exec_parse.c +0
-0@@ -272,8 +272,15 @@ test_lri(int fd, uint32_t handle, MI_BATCH_BUFFER_END,
tests/gem_exec_parse.c test_lri(int fd, uint32_t handle, · line 282
Quoted 10 lines
tests/gem_exec_parse.c +6
-0}; +igt_debug ("testing lri, reg=%x, val=%x, expected errno=%d\n" , + test->reg, test->test_val, expected_errno); +intel_register_write (test->reg, test->init_val); +igt_assert_eq_u32 ((intel_register_read (test->reg) & + test->read_mask), + test->init_val);
igt_assert_f((intel_register_read(test->reg) & test->read_mask) == test->init_val,
"LRI reg=%x overwrote initial value of %x with %x [LRI value=%x]\n", test->reg, test->init_val, intel_register_read(test->reg) & test->read_mask, test->val);
Something like that. I was also hoping to pass in test->name [name of the register for convenience], which equally lends itself to igt_subtest_f("test-lri-%s", test->name)
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 igt/gem_exec_parse: generalise test_lri + debug info
This further generalises the description passed to test_lri so we only need one loop over the entries with test_lri deducing the exected errno and value based on whether the register is marked as whitelisted and depending on the current command parser version.
Each tested register LRI now test gets its own subtest like:igt_subtest_f("test-lri-%s", reg_name)
The test_lri helper now also double checks that the initial intel_register_write() takes before issuing the LRI.
In case of a failure the test_lri helper now uses igt_debug to log the register name, address and value being tested.
--- tests/gem_exec_parse.c | 102 +++++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 50 deletions(-)
tests/gem_exec_parse.c +52 -50
@@ -258,12 +258,17 @@ static void exec_batch_chained(int fd, uint32_t cmd_bo, uint32_t *cmds,* from... */ struct test_lri { -uint32_t reg, read_mask, init_val, test_val; +const char *name;/* register name for debug info */ +uint32_t reg;/* address to test */ +uint32_t read_mask;/* ignore things like HW status bits */ +uint32_t init_val;/* initial identifiable value to set without LRI */ +uint32_t test_val;/* value to attempt loading via LRI command */ +bool whitelisted;/* expect to become NOOP / fail if not whitelisted */ +int min_ver;/* required command parser version to test */ };static void -test_lri (int fd,uint32_t handle, -struct test_lri *test,int expected_errno,uint32_t expect) +test_lri (int fd,uint32_t handle,struct test_lri *test) {uint32_t lri[] = {MI_LOAD_REGISTER_IMM ,
@@ -271,9 +276,20 @@ test_lri(int fd, uint32_t handle, test->test_val, MI_BATCH_BUFFER_END, }; +int bad_lri_errno = parser_version >=8 ?0 : -EINVAL ; +int expected_errno = test->whitelisted ?0 : bad_lri_errno; +uint32_t expect = test->whitelisted ? test->test_val : test->init_val; + +igt_debug ("Testing %s LRI: addr=%x, val=%x, expected errno=%d, expected val=%x\n" , + test->name, test->reg, test->test_val, + expected_errno, expect);intel_register_write (test->reg, test->init_val); +igt_assert_eq_u32 ((intel_register_read (test->reg) & + test->read_mask), + test->init_val); + exec_batch(fd, handle, lri, sizeof(lri), I915_EXEC_RENDER,
@@ -476,57 +492,43 @@ igt_main } igt_subtest_group { +#define REG (R ,MSK ,INI ,V ,OK ,MIN_V ) { #R, R, MSK, INI, V, OK, MIN_V } +struct test_lri lris[] = { +/* dummy head pointer */ +REG (OASTATUS2 , +0xffffff80 ,0xdeadf000 ,0xbeeff000 , false,0 ), +/* NB: [1:0] MBZ */ +REG (SO_WRITE_OFFSET_0 , +0xfffffffc ,0xabcdabc0 ,0xbeefbee0 , true,0 ), + +/* It's really important for us to check that +* an LRI to OACONTROL doesn't result in an +* EINVAL error because Mesa attempts writing +* to OACONTROL to determine what extensions to +* expose and will abort() for execbuffer() +* errors. +* +* Mesa can gracefully recognise and handle the +* LRI becoming a NOOP. +* +* The test values represent dummy context IDs +* while leaving the OA unit disabled +*/ +REG (OACONTROL , +0xfffff000 ,0xfeed0000 ,0x31337000 , false,9 ) + }; +#undef REG + igt_fixture {intel_register_access_init (intel_get_pci_device (),0 ); } - igt_subtest("registers") { -struct test_lri bad_lris[] = { -/* dummy head pointer */ - {OASTATUS2 ,0xffffff80 ,0xdeadf000 ,0xbeeff000 } - }; -struct test_lri v9_bad_lris[] = { -/* It's really important for us to check that -* an LRI to OACONTROL doesn't result in an -* EINVAL error because Mesa attempts writing -* to OACONTROL to determine what extensions to -* expose and will abort() for execbuffer() -* errors. -* -* Mesa can gracefully recognise and handle the -* LRI becoming a NOOP. -* -* The test values represent dummy context IDs -* while leaving the OA unit disabled -*/ - {OACONTROL ,0xfffff000 ,0xfeed0000 ,0x31337000 } - }; -struct test_lri ok_lris[] = { -/* NB: [1:0] MBZ */ - {SO_WRITE_OFFSET_0 ,0xfffffffc , -0xabcdabc0 ,0xbeefbee0 } - }; -int bad_lri_errno = parser_version >=8 ?0 : -EINVAL ; - -for (int i =0 ; i <ARRAY_SIZE (ok_lris); i++) { -test_lri (fd, handle, - ok_lris + i,0 , - ok_lris[i].test_val); - } - -for (int i =0 ; i <ARRAY_SIZE (bad_lris); i++) { -test_lri (fd, handle, - bad_lris + i, bad_lri_errno, - bad_lris[i].init_val); - } - -if (parser_version >=9 ) { -for (int i =0 ; i <ARRAY_SIZE (v9_bad_lris); i++) { -test_lri (fd, handle, - v9_bad_lris + i, -0 , - v9_bad_lris[i].init_val); - } +for (int i =0 ; i <ARRAY_SIZE (lris); i++) { + igt_subtest_f("test-lri-%s", lris[i].name) { +igt_require_f (parser_version >= lris[i].min_ver, +"minimum required parser version for test = %d\n" , + lris[i].min_ver); +test_lri (fd, handle, lris + i); } }
Signature · 6 lines
2.10.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH igt] igt/gem_exec_parse: generalise test_lri + debug info
Quoted 5 lines · Robert Bragg
This further generalises the description passed to
test_lriso we only need one loop over the entries withtest_lrideducing the exected errno and value based on whether the register is marked as whitelisted and depending on the current command parser version.
Quoted 8 lines
Each tested register LRI now test gets its own subtest like:
igt_subtest_f("test-lri-%s", reg_name)The
test_lrihelper now also double checks that the initialintel_register_write()takes before issuing the LRI.In case of a failure the
test_lrihelper now usesigt_debugto log the register name, address and value being tested.
That looks like it should help immensely if one of these should ever fire. Thanks.
Quoted 2 lines
Signed-off-by Robert Bragg <[email protected]>Cc Chris Wilson <[email protected]>
Quoted 9 lines
--- tests/gem_exec_parse.c | 102 +++++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 50 deletions(-)tests/gem_exec_parse.c +0
-0
tests/gem_exec_parse.c static void exec_batch_chained(int fd, uint32_t cmd_bo, uint32_t *cmds, · line 262
Quoted 6 lines
tests/gem_exec_parse.c +2
-1@@ -258,12 +258,17 @@ static void exec_batch_chained(int fd, uint32_t cmd_bo, uint32_t *cmds,* from... */ struct test_lri { -uint32_t reg, read_mask, init_val, test_val; +const char *name;/* register name for debug info */ +uint32_t reg;/* address to test */
I would use offset, but we often mix the two anyway.
Quoted 25 lines
tests/gem_exec_parse.c +13
-2+uint32_t read_mask;/* ignore things like HW status bits */ +uint32_t init_val;/* initial identifiable value to set without LRI */ +uint32_t test_val;/* value to attempt loading via LRI command */ +bool whitelisted;/* expect to become NOOP / fail if not whitelisted */ +int min_ver;/* required command parser version to test */ };static void -test_lri (int fd,uint32_t handle, -struct test_lri *test,int expected_errno,uint32_t expect) +test_lri (int fd,uint32_t handle,struct test_lri *test) {uint32_t lri[] = {MI_LOAD_REGISTER_IMM ,@@ -271,9 +276,20 @@ test_lri(int fd, uint32_t handle, test->test_val, MI_BATCH_BUFFER_END, }; +int bad_lri_errno = parser_version >=8 ?0 : -EINVAL ; +int expected_errno = test->whitelisted ?0 : bad_lri_errno; +uint32_t expect = test->whitelisted ? test->test_val : test->init_val; + +igt_debug ("Testing %s LRI: addr=%x, val=%x, expected errno=%d, expected val=%x\n" , + test->name, test->reg, test->test_val, + expected_errno, expect);
tests/gem_exec_parse.c test_lri(int fd, uint32_t handle, · line 295
Quoted 10 lines
tests/gem_exec_parse.c +4
-0intel_register_write (test->reg, test->init_val); +igt_assert_eq_u32 ((intel_register_read (test->reg) & + test->read_mask), + test->init_val); + exec_batch(fd, handle, lri, sizeof(lri), I915_EXEC_RENDER,
I would still be verbose in the assert, it is the first thing you read on seeing the error before digging through the debug log. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 13/13 igt/gem_exec_parse: check oacontrol lri bad for >= v9
In reply to Robert BraggOACONTROL is no longer white listed in the command parser so this checks at attempted LRI will be disallowed and (more importantly) checks that userspace doesn't get an EINVAL error for an attempted OACONTROL LRI. This is important becase Mesa application attempt OACONTROL LRIs while initializing and will abort for any execbuf error.
--- tests/gem_exec_parse.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
tests/gem_exec_parse.c +25 -0
@@ -485,6 +485,22 @@ igt_main/* dummy head pointer */ { OASTATUS2, 0xffffff80, 0xdeadf000, 0xbeeff000 } }; +struct test_lri v9_bad_lris[] = { +/* It's really important for us to check that +* an LRI to OACONTROL doesn't result in an +* EINVAL error because Mesa attempts writing +* to OACONTROL to determine what extensions to +* expose and will abort() for execbuffer() +* errors. +* +* Mesa can gracefully recognise and handle the +* LRI becoming a NOOP. +* +* The test values represent dummy context IDs +* while leaving the OA unit disabled +*/ + {OACONTROL ,0xfffff000 ,0xfeed0000 ,0x31337000 } + };struct test_lri ok_lris[] = {/* NB: [1:0] MBZ */ {SO_WRITE_OFFSET_0 ,0xfffffffc ,
@@ -503,6 +519,15 @@ igt_main bad_lris + i, bad_lri_errno, bad_lris[i].init_val); } + +if (parser_version >=9 ) { +for (int i =0 ; i <ARRAY_SIZE (v9_bad_lris); i++) { +test_lri (fd, handle, + v9_bad_lris + i, +0 , + v9_bad_lris[i].init_val); + } + } } igt_fixture {
Signature · 6 lines
2.10.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx