tests/gem_exec_parse: fix batch_len setting for cmd-crossing-page
PATCH 1/2 tests/gem_exec_parse: fix batch_len setting for cmd-crossing-page
From: Brad Volkin <[email protected]>
The size of the batch buffer passed to the kernel is significantly larger than the size of the batch buffer passed to the function. A proposed optimization as part of the batch copy kernel series is to use batch_len for the copy and parse operations, which leads to a false "batch without MI_BATCH_BUFFER_END" failure for this test.
To fix this, modify the test to set batch_start_offset and batch_len such that they define the range of actual commands in the batch, including a few of the surrounding nops for alignment purposes.
v2: update batch_start_offset as well
--- tests/gem_exec_parse.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
tests/gem_exec_parse.c +12 -4
@@ -144,16 +144,18 @@ static void exec_split_batch(int fd, uint32_t *cmds,struct drm_i915_gem_exec_object2 objs[1 ];uint32_t cmd_bo;uint32_t noop[1024 ] = {0 }; +const int alloc_size =4096 *2 ; +const int actual_start_offset =4096 -sizeof (uint32_t );// Allocate and fill a 2-page batch with noops - cmd_bo =gem_create (fd,4096 *2 ); + cmd_bo =gem_create (fd, alloc_size);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); +gem_write (fd, cmd_bo, actual_start_offset, cmds, size); objs[0 ].handle = cmd_bo; objs[0 ].relocation_count =0 ;
@@ -166,8 +168,14 @@ static void exec_split_batch(int fd, uint32_t *cmds, execbuf.buffers_ptr = (uintptr_t )objs; execbuf.buffer_count =1 ; - execbuf.batch_start_offset =0 ; - execbuf.batch_len = size; +// 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), +// but have to adjust both the start offset and length to meet the +// kernel driver's requirements on the alignment of those fields. + execbuf.batch_start_offset = actual_start_offset & ~0x7 ; + execbuf.batch_len = +ALIGN (size + actual_start_offset - execbuf.batch_start_offset, +0x8 ); execbuf.cliprects_ptr =0 ; execbuf.num_cliprects =0 ; execbuf.DR1 =0 ;
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 tests/gem_madvise: set execbuf.batch_len before doing an execbuf
From: Brad Volkin <[email protected]>
The command parser's batch_len optimization causes the parser to reject this batch as not having an MI_BATCH_BUFFER_END because the length was not set correctly.
--- tests/gem_madvise.c | 1 + 1 file changed, 1 insertion(+)
tests/gem_madvise.c +1 -0
@@ -131,6 +131,7 @@ dontneed_before_exec(void) execbuf.buffers_ptr = (uintptr_t )&exec; execbuf.buffer_count =1 ; + execbuf.batch_len =sizeof (buf);gem_execbuf (fd, &execbuf);gem_close (fd, exec.handle);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Ping on this series. They're related to the batch copy series, but the changes are valid and tests should still pass even without the kernel changes being merged.
Quoted 64 lines · Bradley D
From: Brad Volkin <[email protected]>
The size of the batch buffer passed to the kernel is significantly larger than the size of the batch buffer passed to the function. A proposed optimization as part of the batch copy kernel series is to use
batch_lenfor the copy and parse operations, which leads to a false "batch withoutMI_BATCH_BUFFER_END" failure for this test.To fix this, modify the test to set
batch_start_offsetandbatch_lensuch that they define the range of actual commands in the batch, including a few of the surrounding nops for alignment purposes.v2: update
batch_start_offsetas wellSigned-off-by Brad Volkin <[email protected]>--- tests/gem_exec_parse.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)tests/gem_exec_parse.c +12
-4@@ -144,16 +144,18 @@ static void exec_split_batch(int fd, uint32_t *cmds,struct drm_i915_gem_exec_object2 objs[1 ];uint32_t cmd_bo;uint32_t noop[1024 ] = {0 }; +const int alloc_size =4096 *2 ; +const int actual_start_offset =4096 -sizeof (uint32_t );// Allocate and fill a 2-page batch with noops - cmd_bo =gem_create (fd,4096 *2 ); + cmd_bo =gem_create (fd, alloc_size);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); +gem_write (fd, cmd_bo, actual_start_offset, cmds, size); objs[0 ].handle = cmd_bo; objs[0 ].relocation_count =0 ;@@ -166,8 +168,14 @@ static void exec_split_batch(int fd, uint32_t *cmds, execbuf.buffers_ptr = (uintptr_t )objs; execbuf.buffer_count =1 ; - execbuf.batch_start_offset =0 ; - execbuf.batch_len = size; +// 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), +// but have to adjust both the start offset and length to meet the +// kernel driver's requirements on the alignment of those fields. + execbuf.batch_start_offset = actual_start_offset & ~0x7 ; + execbuf.batch_len = +ALIGN (size + actual_start_offset - execbuf.batch_start_offset, +0x8 ); execbuf.cliprects_ptr =0 ; execbuf.num_cliprects =0 ; execbuf.DR1 =0 ;Signature · 1 line
1.9.1
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 3 lines · Bradley D
Ping on this series. They're related to the batch copy series, but the changes are valid and tests should still pass even without the kernel changes being merged.
Merged - I kinda forgotten that you don't have commit access.
Quoted 48 lines · Bradley D
Quoted 46 lines
From: Brad Volkin <[email protected]>
The size of the batch buffer passed to the kernel is significantly larger than the size of the batch buffer passed to the function. A proposed optimization as part of the batch copy kernel series is to use
batch_lenfor the copy and parse operations, which leads to a false "batch withoutMI_BATCH_BUFFER_END" failure for this test.To fix this, modify the test to set
batch_start_offsetandbatch_lensuch that they define the range of actual commands in the batch, including a few of the surrounding nops for alignment purposes.v2: update
batch_start_offsetas wellSigned-off-by Brad Volkin <[email protected]>--- tests/gem_exec_parse.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)tests/gem_exec_parse.c +4
-2@@ -144,16 +144,18 @@ static void exec_split_batch(int fd, uint32_t *cmds,struct drm_i915_gem_exec_object2 objs[1 ];uint32_t cmd_bo;uint32_t noop[1024 ] = {0 }; +const int alloc_size =4096 *2 ; +const int actual_start_offset =4096 -sizeof (uint32_t );// Allocate and fill a 2-page batch with noops - cmd_bo =gem_create (fd,4096 *2 ); + cmd_bo =gem_create (fd, alloc_size);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); +gem_write (fd, cmd_bo, actual_start_offset, cmds, size); objs[0 ].handle = cmd_bo; objs[0 ].relocation_count =0 ;@@ -166,8 +168,14 @@ static void exec_split_batch(int fd, uint32_t *cmds,
Quoted 8 lines
tests/gem_exec_parse.c static void exec_split_batch(int fd, uint32_t *cmds, · line 174
Quoted 8 lines
tests/gem_exec_parse.c +4
-2execbuf.buffers_ptr = (uintptr_t )objs; execbuf.buffer_count =1 ; - execbuf.batch_start_offset =0 ; - execbuf.batch_len = size; +// 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), +// but have to adjust both the start offset and length to meet the +// kernel driver's requirements on the alignment of those fields.
Also pushed a patch on top to change all the comments to C-style, just for my OCD ;-)
-Daniel
Quoted 14 lines
Quoted 10 lines
tests/gem_exec_parse.c +4
-0+ execbuf.batch_start_offset = actual_start_offset & ~0x7 ; + execbuf.batch_len = +ALIGN (size + actual_start_offset - execbuf.batch_start_offset, +0x8 ); execbuf.cliprects_ptr =0 ; execbuf.num_cliprects =0 ; execbuf.DR1 =0 ;Signature · 1 line
1.9.1_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx