lib/igt_dummyload: add igt_cork
PATCH v3 1/11 lib/igt_dummyload: add igt_cork
From: Daniele Ceraolo Spurio <[email protected]>
The "cork" bo (imported bo with attached fence) and fence is used in several tests to stall execution. Moving it to a common place makes the codebase cleaner.
Note that the actual test updates is done in follow up patches as it is simpler to do in one go after one more common function is added in the next patch.
v2: don't use new/free naming, don't use dynamic alloc (Chris)
v3: add sw_sync common functions. (Chris)
--- lib/igt_dummyload.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_dummyload.h | 15 +++++++ 2 files changed, 134 insertions(+)
lib/igt_dummyload.c +119 -0
@@ -29,12 +29,14 @@#include <i915_drm.h> #include "igt_core.h" +#include "drmtest.h" #include "igt_dummyload.h" #include "igt_gt.h" #include "intel_chipset.h" #include "intel_reg.h" #include "ioctl_wrappers.h" #include "sw_sync.h" +#include "igt_vgem.h" /** * SECTION:igt_dummyload
@@ -371,3 +373,120 @@ void igt_terminate_spin_batches(void)igt_spin_batch_end (iter);pthread_mutex_unlock (&list_lock); } + +static uint32_t igt_cork_plug_vgem (int fd,struct igt_cork_vgem *cork) +{ +struct vgem_bo bo; +int dmabuf; +uint32_t handle; + + cork->device =drm_open_driver (DRIVER_VGEM ); +igt_require (vgem_has_fences (cork->device)); + + bo.width = bo.height =1 ; + bo.bpp =4 ; +vgem_create (cork->device, &bo); + cork->fence =vgem_fence_attach (cork->device, &bo,VGEM_FENCE_WRITE ); + + dmabuf =prime_handle_to_fd (cork->device, bo.handle); + handle =prime_fd_to_handle (fd, dmabuf); +close (dmabuf); + +return handle; +} + +static void igt_cork_unplug_vgem (struct igt_cork_vgem *cork) +{ +igt_assert (cork->device); + +vgem_fence_signal (cork->device, cork->fence); +close (cork->device); + cork->device =-1 ; +} + +static uint32_t igt_cork_plug_sw_sync (struct igt_cork_sw_sync *cork) +{ +int fence; + +igt_require_sw_sync (); + + cork->timeline =sw_sync_timeline_create (); + fence =sw_sync_timeline_create_fence (cork->timeline,1 ); + +return fence; +} + +static void igt_cork_unplug_sw_sync (struct igt_cork_sw_sync *cork) +{ +sw_sync_timeline_inc (cork->timeline,1 ); +close (cork->timeline); +} + +/** +* igt_cork_plug: +* @fd: open drm file descriptor +* @method: method to utilize for corking. +* @cork: structure that will be filled with the state of the cork bo. +* Note: this has to match the corking method. +* +* This function provides a mechanism to stall submission. It provides two +* blocking methods: +* +* VGEM_BO. +* Imports a vgem bo with a fence attached to it. This bo can be used as a +* dependency during submission to stall execution until the fence is signaled. +* +* SW_SYNC: +* Creates a timeline and then a fence on that timeline. The fence can be used +* as an input fence to a request, the request will be stalled until the fence +* is signaled. +* +* The parameters required to unblock the execution and to cleanup are stored in +* the provided cork structure. +* +* Returns: +* Handle of the imported BO / Sw sync fence FD. +*/ +uint32_t igt_cork_plug (int fd,unsigned method,void *cork) +{ +igt_assert (cork); + +switch (method) { +case SW_SYNC : +return igt_cork_plug_sw_sync ((struct igt_cork_sw_sync *) cork); +break ; +case VGEM_BO : +return igt_cork_plug_vgem (fd, (struct igt_cork_vgem *) cork); +break ; +default : +igt_assert_f (0 ,"Invalid corking method!" ); +break ; + }; +} + +/** +* igt_cork_unplug: +* @method: method to utilize for corking. +* @cork: cork state from igt_cork_plug() +* +* This function unblocks the execution by signaling the fence attached to the +* imported bo and does the necessary post-processing. +* +* NOTE: the handle returned by igt_cork_plug is not closed during this phase. +*/ +void igt_cork_unplug (unsigned method,void *cork) +{ +igt_assert (cork); + +switch (method) { +case SW_SYNC : +igt_cork_unplug_sw_sync ((struct igt_cork_sw_sync *) cork); +break ; +case VGEM_BO : +igt_cork_unplug_vgem ((struct igt_cork_vgem *) cork); +break ; +default : +igt_assert_f (0 ,"Invalid unplugging method!" ); +break ; + }; +}
lib/igt_dummyload.h +15 -0
@@ -61,4 +61,19 @@ void igt_spin_batch_free(int fd, igt_spin_t *spin);void igt_terminate_spin_batches (void ); +#define SW_SYNC 1 +#define VGEM_BO 2 + +struct igt_cork_vgem { +int device; +uint32_t fence; +}; + +struct igt_cork_sw_sync { +int timeline; +}; + +uint32_t igt_cork_plug (int fd,unsigned method,void *cork); +void igt_cork_unplug (unsigned method,void *cork); +#endif /* __IGT_DUMMYLOAD_H__ */
Signature · 6 lines
2.14.2 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v3 3/11 tests/gem_exec_schedule: use new common functions
From: Daniele Ceraolo Spurio <[email protected]>
With intel_measure_ring_size and igt_cork added as common utilities we can use them instead of the local copy of those utilities
--- tests/gem_exec_schedule.c | 162 ++++++++++++---------------------------------- 1 file changed, 41 insertions(+), 121 deletions(-)
tests/gem_exec_schedule.c +41 -121
@@ -32,6 +32,7 @@#include "igt_vgem.h" #include "igt_rand.h" #include "igt_sysfs.h" +#include "i915/gem_ring.h" #define LO 0#define HI 1
@@ -99,35 +100,6 @@ static void store_dword(int fd, uint32_t ctx, unsigned ring,gem_close (fd, obj[2 ].handle); } -struct cork { -int device; -uint32_t handle; -uint32_t fence; -}; - -static void plug (int fd,struct cork *c) -{ -struct vgem_bo bo; -int dmabuf; - - c->device =drm_open_driver (DRIVER_VGEM ); - - bo.width = bo.height =1 ; - bo.bpp =4 ; -vgem_create (c->device, &bo); - c->fence =vgem_fence_attach (c->device, &bo,VGEM_FENCE_WRITE ); - - dmabuf =prime_handle_to_fd (c->device, bo.handle); - c->handle =prime_fd_to_handle (fd, dmabuf); -close (dmabuf); -} - -static void unplug (struct cork *c) -{ -vgem_fence_signal (c->device, c->fence); -close (c->device); -} -static uint32_t create_highest_priority (int fd) {uint32_t ctx =gem_context_create (fd);
@@ -142,7 +114,7 @@ static uint32_t create_highest_priority(int fd)return ctx; } -static void unplug_show_queue (int fd,struct cork *c,unsigned int engine) +static void unplug_show_queue (int fd,struct igt_cork_vgem *c,unsigned int engine) {igt_spin_t *spin[BUSY_QLEN ];
@@ -152,7 +124,7 @@ static void unplug_show_queue(int fd, struct cork *c, unsigned int engine)gem_context_destroy (fd, ctx); } -unplug (c);/* batches will now be queued on the engine */ +igt_cork_unplug (VGEM_BO , c);/* batches will now be queued on the engine */ igt_debugfs_dump (fd,"i915_engine_info" );for (int n =0 ; n <ARRAY_SIZE (spin); n++)
@@ -162,19 +134,20 @@ static void unplug_show_queue(int fd, struct cork *c, unsigned int engine)static void fifo (int fd,unsigned ring) { -struct cork cork; -uint32_t scratch; +struct igt_cork_vgem cork; +uint32_t scratch, plug;uint32_t *ptr; scratch =gem_create (fd,4096 ); -plug (fd, &cork); + plug =igt_cork_plug (fd,VGEM_BO , &cork);/* Same priority, same timeline, final result will be the second eb */ -store_dword (fd,0 , ring, scratch,0 ,1 , cork.handle,0 ); -store_dword (fd,0 , ring, scratch,0 ,2 , cork.handle,0 ); +store_dword (fd,0 , ring, scratch,0 ,1 , plug,0 ); +store_dword (fd,0 , ring, scratch,0 ,2 , plug,0 );unplug_show_queue (fd, &cork, ring); +gem_close (fd, plug); ptr =gem_mmap__gtt (fd, scratch,4096 ,PROT_READ ); gem_set_domain(fd, scratch, /* no write hazard lies! */
@@ -266,8 +239,8 @@ static void smoketest(int fd, unsigned ring, unsigned timeout) static void reorder(int fd, unsigned ring, unsigned flags)#define EQUAL 1 { -struct cork cork; -uint32_t scratch; +struct igt_cork_vgem cork; +uint32_t scratch, plug;uint32_t *ptr;uint32_t ctx[2 ];
@@ -278,15 +251,16 @@ static void reorder(int fd, unsigned ring, unsigned flags)gem_context_set_priority (fd, ctx[HI ], flags &EQUAL ?MIN_PRIO :0 ); scratch =gem_create (fd,4096 ); -plug (fd, &cork); + plug =igt_cork_plug (fd,VGEM_BO , &cork);/* We expect the high priority context to be executed first, and * so the final result will be value from the low priority context. */ -store_dword (fd, ctx[LO ], ring, scratch,0 , ctx[LO ], cork.handle,0 ); -store_dword (fd, ctx[HI ], ring, scratch,0 , ctx[HI ], cork.handle,0 ); +store_dword (fd, ctx[LO ], ring, scratch,0 , ctx[LO ], plug,0 ); +store_dword (fd, ctx[HI ], ring, scratch,0 , ctx[HI ], plug,0 );unplug_show_queue (fd, &cork, ring); +gem_close (fd, plug);gem_context_destroy (fd, ctx[LO ]);gem_context_destroy (fd, ctx[HI ]);
@@ -305,10 +279,11 @@ static void reorder(int fd, unsigned ring, unsigned flags)static void promotion (int fd,unsigned ring) { -struct cork cork; +struct igt_cork_vgem cork;uint32_t result, dep;uint32_t *ptr;uint32_t ctx[3 ]; +uint32_t plug; ctx[LO ] =gem_context_create (fd);gem_context_set_priority (fd, ctx[LO ],MIN_PRIO );
@@ -322,15 +297,15 @@ static void promotion(int fd, unsigned ring) result =gem_create (fd,4096 ); dep =gem_create (fd,4096 ); -plug (fd, &cork); + plug =igt_cork_plug (fd,VGEM_BO , &cork);/* Expect that HI promotes LO, so the order will be LO, HI, NOISE. * * fifo would be NOISE, LO, HI. * strict priority would be HI, NOISE, LO */ -store_dword (fd, ctx[NOISE ], ring, result,0 , ctx[NOISE ], cork.handle,0 ); -store_dword (fd, ctx[LO ], ring, result,0 , ctx[LO ], cork.handle,0 ); +store_dword (fd, ctx[NOISE ], ring, result,0 , ctx[NOISE ], plug,0 ); +store_dword (fd, ctx[LO ], ring, result,0 , ctx[LO ], plug,0 );/* link LO <-> HI via a dependency on another buffer */ store_dword (fd, ctx[LO ], ring, dep,0 , ctx[LO ],0 ,I915_GEM_DOMAIN_INSTRUCTION );
@@ -339,6 +314,7 @@ static void promotion(int fd, unsigned ring)store_dword (fd, ctx[HI ], ring, result,0 , ctx[HI ],0 ,0 );unplug_show_queue (fd, &cork, ring); +gem_close (fd, plug);gem_context_destroy (fd, ctx[NOISE ]);gem_context_destroy (fd, ctx[LO ]);
@@ -559,7 +535,8 @@ static void deep(int fd, unsigned ring)const unsigned int nctx =MAX_PRIO -MIN_PRIO ;const unsigned size =ALIGN (4 *nctx,4096 );struct timespec tv = {}; -struct cork cork; +struct igt_cork_vgem cork; +uint32_t plug;uint32_t result, dep[XS ];uint32_t expected =0 ;uint32_t *ptr;
@@ -600,12 +577,12 @@ static void deep(int fd, unsigned ring)gem_sync (fd, result); } -plug (fd, &cork); + plug =igt_cork_plug (fd,VGEM_BO , &cork);/* Create a deep dependency chain, with a few branches */ for (int n =0 ; n < nctx &&igt_seconds_elapsed (&tv) <8 ; n++)for (int m =0 ; m <XS ; m++) -store_dword (fd, ctx[n], ring, dep[m],4 *n, ctx[n], cork.handle,I915_GEM_DOMAIN_INSTRUCTION ); +store_dword (fd, ctx[n], ring, dep[m],4 *n, ctx[n], plug,I915_GEM_DOMAIN_INSTRUCTION );for (int n =0 ; n < nctx &&igt_seconds_elapsed (&tv) <6 ; n++) {for (int m =0 ; m <XS ; m++) {
@@ -616,6 +593,7 @@ static void deep(int fd, unsigned ring) }unplug_show_queue (fd, &cork, ring); +gem_close (fd, plug);igt_require (expected);/* too slow */ for (int n =0 ; n < nctx; n++)
@@ -658,72 +636,14 @@ static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)return err; } -static unsigned int measure_ring_size (int fd,unsigned int ring) -{ -struct sigaction sa = { .sa_handler = alarm_handler }; -struct drm_i915_gem_exec_object2 obj[2 ]; -struct drm_i915_gem_execbuffer2 execbuf; -const uint32_t bbe =MI_BATCH_BUFFER_END ; -unsigned int count, last; -struct itimerval itv; -struct cork c; - -memset (obj,0 ,sizeof (obj)); - obj[1 ].handle =gem_create (fd,4096 ); -gem_write (fd, obj[1 ].handle,0 , &bbe,sizeof (bbe)); - -memset (&execbuf,0 ,sizeof (execbuf)); - execbuf.buffers_ptr =to_user_pointer (obj +1 ); - execbuf.buffer_count =1 ; - execbuf.flags = ring; -gem_execbuf (fd, &execbuf); -gem_sync (fd, obj[1 ].handle); - -plug (fd, &c); - obj[0 ].handle = c.handle; - - execbuf.buffers_ptr =to_user_pointer (obj); - execbuf.buffer_count =2 ; - execbuf.rsvd1 =gem_context_create (fd); - -sigaction (SIGALRM , &sa,NULL ); - itv.it_interval.tv_sec =0 ; - itv.it_interval.tv_usec =100 ; - itv.it_value.tv_sec =0 ; - itv.it_value.tv_usec =1000 ; -setitimer (ITIMER_REAL , &itv,NULL ); - - last =-1 ; - count =0 ; -do { -if (__execbuf (fd, &execbuf) ==0 ) { - count++; -continue ; - } - -if (last == count) -break ; - - last = count; - }while (1 ); - -memset (&itv,0 ,sizeof (itv)); -setitimer (ITIMER_REAL , &itv,NULL ); - -unplug (&c); -gem_close (fd, obj[1 ].handle); -gem_context_destroy (fd, execbuf.rsvd1); - -return count; -} -static void wide (int fd,unsigned ring) {#define NCTX 4096struct timespec tv = {}; -unsigned int ring_size =measure_ring_size (fd, ring); +unsigned int ring_size =intel_measure_ring_size (fd, ring, true); -struct cork cork; +struct igt_cork_vgem cork; +uint32_t plug;uint32_t result;uint32_t *ptr;uint32_t *ctx;
@@ -735,20 +655,21 @@ static void wide(int fd, unsigned ring) result =gem_create (fd,4 *NCTX ); -plug (fd, &cork); + plug =igt_cork_plug (fd,VGEM_BO , &cork);/* Lots of in-order requests, plugged and submitted simultaneously */ for (count =0 ;igt_seconds_elapsed (&tv) <5 && count < ring_size; count++) {for (int n =0 ; n <NCTX ; n++) { -store_dword (fd, ctx[n], ring, result,4 *n, ctx[n], cork.handle,I915_GEM_DOMAIN_INSTRUCTION ); +store_dword (fd, ctx[n], ring, result,4 *n, ctx[n], plug,I915_GEM_DOMAIN_INSTRUCTION ); } }igt_info ("Submitted %d requests over %d contexts in %.1fms\n" , count,NCTX ,igt_nsec_elapsed (&tv) *1e-6 );unplug_show_queue (fd, &cork, ring); +gem_close (fd, plug);for (int n =0 ; n <NCTX ; n++)gem_context_destroy (fd, ctx[n]);
@@ -772,21 +693,20 @@ static void reorder_wide(int fd, unsigned ring)struct drm_i915_gem_exec_object2 obj[3 ];struct drm_i915_gem_execbuffer2 execbuf;struct timespec tv = {}; -unsigned int ring_size =measure_ring_size (fd, ring); -struct cork cork; -uint32_t result, target; +unsigned int ring_size =intel_measure_ring_size (fd, ring, true); +struct igt_cork_vgem cork; +uint32_t result, target, plug;uint32_t *found, *expected; result =gem_create (fd,4096 ); target =gem_create (fd,4096 ); - -plug (fd, &cork); + plug =igt_cork_plug (fd,VGEM_BO , &cork); expected =gem_mmap__cpu (fd, target,0 ,4096 ,PROT_WRITE );gem_set_domain (fd, target,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU );memset (obj,0 ,sizeof (obj)); - obj[0 ].handle = cork.handle; + obj[0 ].handle = plug; obj[1 ].handle = result; obj[2 ].relocs_ptr =to_user_pointer (&reloc); obj[2 ].relocation_count =1 ;
@@ -854,6 +774,7 @@ static void reorder_wide(int fd, unsigned ring) }unplug_show_queue (fd, &cork, ring); +gem_close (fd, plug); found =gem_mmap__gtt (fd, result,4096 ,PROT_READ ); gem_set_domain(fd, result, /* no write hazard lies! */
@@ -888,7 +809,7 @@ static void test_pi_ringfull(int fd, unsigned int engine)struct drm_i915_gem_exec_object2 obj[2 ];unsigned int last, count;struct itimerval itv; -struct cork c; +struct igt_cork_vgem c;bool *result; result =mmap (NULL ,4096 ,PROT_WRITE ,MAP_SHARED |MAP_ANON ,-1 ,0 );
@@ -910,8 +831,7 @@ static void test_pi_ringfull(int fd, unsigned int engine)gem_sync (fd, obj[1 ].handle);/* Fill the low-priority ring */ -plug (fd, &c); - obj[0 ].handle = c.handle; + obj[0 ].handle =igt_cork_plug (fd,VGEM_BO , &c); execbuf.buffers_ptr =to_user_pointer (obj); execbuf.buffer_count =2 ;
@@ -985,7 +905,7 @@ static void test_pi_ringfull(int fd, unsigned int engine)igt_assert_f (result[2 ],"High priority child unable to submit within 10ms\n" ); -unplug (&c); +igt_cork_unplug (VGEM_BO , &c);igt_waitchildren ();gem_context_destroy (fd, execbuf.rsvd1);
Signature · 6 lines
2.14.2 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v3 4/11 tests/gem_exec_fence: use new common functions
In reply to Antonio ArgenzianoFrom: Daniele Ceraolo Spurio <[email protected]>
With intel_measure_ring_size and igt_cork added as common utilities we can use them instead of the local copy of those utilities
--- tests/gem_exec_fence.c | 107 ++++++------------------------------------------- 1 file changed, 12 insertions(+), 95 deletions(-)
tests/gem_exec_fence.c +12 -95
@@ -25,6 +25,7 @@#include "igt_sysfs.h" #include "igt_vgem.h" #include "sw_sync.h" +#include "i915/gem_ring.h" #include <sys/ioctl.h> #include <sys/poll.h>
@@ -321,36 +322,6 @@ static void resubmit(int fd, uint32_t handle, unsigned int ring, int count)gem_execbuf (fd, &execbuf); } -struct cork { -int device; -uint32_t handle; -uint32_t fence; -}; - -static void plug (int fd,struct cork *c) -{ -struct vgem_bo bo; -int dmabuf; - - c->device =drm_open_driver (DRIVER_VGEM ); - - bo.width = bo.height =1 ; - bo.bpp =4 ; -vgem_create (c->device, &bo); - c->fence =vgem_fence_attach (c->device, &bo,VGEM_FENCE_WRITE ); - - dmabuf =prime_handle_to_fd (c->device, bo.handle); - c->handle =prime_fd_to_handle (fd, dmabuf); -close (dmabuf); -} - -static void unplug (int fd,struct cork *c) -{ -vgem_fence_signal (c->device, c->fence); -gem_close (fd, c->handle); -close (c->device); -} -static void alarm_handler (int sig) { }
@@ -367,62 +338,6 @@ static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)return err; } -static unsigned int measure_ring_size (int fd) -{ -struct sigaction sa = { .sa_handler = alarm_handler }; -struct drm_i915_gem_exec_object2 obj[2 ]; -struct drm_i915_gem_execbuffer2 execbuf; -const uint32_t bbe =MI_BATCH_BUFFER_END ; -unsigned int count, last; -struct itimerval itv; -struct cork c; - -memset (obj,0 ,sizeof (obj)); - obj[1 ].handle =gem_create (fd,4096 ); -gem_write (fd, obj[1 ].handle,0 , &bbe,sizeof (bbe)); - -memset (&execbuf,0 ,sizeof (execbuf)); - execbuf.buffers_ptr =to_user_pointer (&obj[1 ]); - execbuf.buffer_count =1 ; -gem_execbuf (fd, &execbuf); -gem_sync (fd, obj[1 ].handle); - -plug (fd, &c); - obj[0 ].handle = c.handle; - - execbuf.buffers_ptr =to_user_pointer (obj); - execbuf.buffer_count =2 ; - -sigaction (SIGALRM , &sa,NULL ); - itv.it_interval.tv_sec =0 ; - itv.it_interval.tv_usec =100 ; - itv.it_value.tv_sec =0 ; - itv.it_value.tv_usec =1000 ; -setitimer (ITIMER_REAL , &itv,NULL ); - - last =-1 ; - count =0 ; -do { -if (__execbuf (fd, &execbuf) ==0 ) { - count++; -continue ; - } - -if (last == count) -break ; - - last = count; - }while (1 ); - -memset (&itv,0 ,sizeof (itv)); -setitimer (ITIMER_REAL , &itv,NULL ); - -unplug (fd, &c); -gem_close (fd, obj[1 ].handle); - -return count; -} -static void test_parallel (int fd,unsigned int master) {const int SCRATCH =0 ;
@@ -437,15 +352,16 @@ static void test_parallel(int fd, unsigned int master)uint32_t batch[16 ];igt_spin_t *spin;unsigned engine; -struct cork c; +struct igt_cork_vgem c; +uint32_t plug;int i, x =0 ; -plug (fd, &c); + plug =igt_cork_plug (fd,VGEM_BO , &c);/* Fill the queue with many requests so that the next one has to * wait before it can be executed by the hardware. */ - spin =igt_spin_batch_new (fd,0 , master, c.handle); + spin =igt_spin_batch_new (fd,0 , master, plug);resubmit (fd, spin->handle, master,16 );/* Now queue the master request and its secondaries */
@@ -566,7 +482,8 @@ static void test_parallel(int fd, unsigned int master) }/* Unblock the master */ -unplug (fd, &c); +igt_cork_unplug (VGEM_BO , &c); +gem_close (fd, plug);igt_spin_batch_end (spin);/* Wait for all secondaries to complete. If we used a regular fence
@@ -692,7 +609,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags)unsigned int nengine, n, s;unsigned long limit;int all_fences; -struct cork c; +struct igt_cork_vgem c; limit =-1 ;if (!gem_uses_full_ppgtt (fd))
@@ -727,8 +644,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags) execbuf.buffers_ptr =to_user_pointer (obj); execbuf.buffer_count =2 ; -plug (fd, &c); - obj[0 ].handle = c.handle; + obj[0 ].handle =igt_cork_plug (fd,VGEM_BO , &c); igt_until_timeout(5) { execbuf.rsvd1 =gem_context_create (fd);
@@ -756,7 +672,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags)if (!--limit)break ; } -unplug (fd, &c); +igt_cork_unplug (VGEM_BO , &c);igt_info ("History depth = %d\n" ,sync_fence_count (all_fences));
@@ -780,6 +696,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags)gem_sync (fd, obj[1 ].handle);gem_close (fd, obj[1 ].handle); +gem_close (fd, obj[0 ].handle); }static void test_fence_flip (int i915)
@@ -1630,7 +1547,7 @@ igt_mainlong ring_size =0 ; igt_fixture { - ring_size =measure_ring_size (i915) -1 ; + ring_size =intel_measure_ring_size (i915,0 , false) -1 ;igt_info ("Ring size: %ld batches\n" , ring_size);igt_require (ring_size);
Signature · 6 lines
2.14.2 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v3 5/11 tests/gem_exec_latency: use new common functions
In reply to Antonio ArgenzianoFrom: Daniele Ceraolo Spurio <[email protected]>
With intel_measure_ring_size and igt_cork added as common utilities we can use them instead of the local copy of those utilities
--- tests/gem_exec_latency.c | 99 +++++++----------------------------------------- 1 file changed, 13 insertions(+), 86 deletions(-)
tests/gem_exec_latency.c +13 -86
@@ -41,6 +41,7 @@#include "igt_sysfs.h" #include "igt_vgem.h" +#include "i915/gem_ring.h" #define LOCAL_I915_EXEC_NO_RELOC (1<<11)#define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
@@ -55,83 +56,6 @@static unsigned int ring_size; -struct cork { -int device; -uint32_t handle; -uint32_t fence; -}; - -static void plug (int fd,struct cork *c) -{ -struct vgem_bo bo; -int dmabuf; - - c->device =drm_open_driver (DRIVER_VGEM ); - - bo.width = bo.height =1 ; - bo.bpp =4 ; -vgem_create (c->device, &bo); - c->fence =vgem_fence_attach (c->device, &bo,VGEM_FENCE_WRITE ); - - dmabuf =prime_handle_to_fd (c->device, bo.handle); - c->handle =prime_fd_to_handle (fd, dmabuf); -close (dmabuf); -} - -static void unplug (struct cork *c) -{ -vgem_fence_signal (c->device, c->fence); -close (c->device); -} - -static void alarm_handler (int sig) -{ -} - -static void set_timeout (int seconds) -{ -struct sigaction sa = { .sa_handler = alarm_handler }; - -sigaction (SIGALRM , seconds ? &sa :NULL ,NULL ); -alarm (seconds); -} - -static int __execbuf (int fd,struct drm_i915_gem_execbuffer2 *execbuf) -{ -return ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , execbuf); -} - -static unsigned int measure_ring_size (int fd) -{ -struct drm_i915_gem_exec_object2 obj[2 ]; -struct drm_i915_gem_execbuffer2 execbuf; -const uint32_t bbe =MI_BATCH_BUFFER_END ; -unsigned int count; -struct cork c; - -memset (obj,0 ,sizeof (obj)); - obj[1 ].handle =gem_create (fd,4096 ); -gem_write (fd, obj[1 ].handle,0 , &bbe,sizeof (bbe)); - -plug (fd, &c); - obj[0 ].handle = c.handle; - -memset (&execbuf,0 ,sizeof (execbuf)); - execbuf.buffers_ptr =to_user_pointer (obj); - execbuf.buffer_count =2 ; - - count =0 ; -set_timeout (1 ); -while (__execbuf (fd, &execbuf) ==0 ) - count++; -set_timeout (0 ); - -unplug (&c); -gem_close (fd, obj[1 ].handle); - -return count; -} -#define RCS_TIMESTAMP (0x2000 + 0x358) static void latency_on_ring(int fd, unsigned ring, const char *name,
@@ -142,7 +66,7 @@ static void latency_on_ring(int fd,struct drm_i915_gem_exec_object2 obj[3 ];struct drm_i915_gem_relocation_entry reloc;struct drm_i915_gem_execbuffer2 execbuf; -struct cork c; +struct igt_cork_vgem c;volatile uint32_t *reg;unsigned repeats = ring_size;uint32_t start, end, *map, *results;
@@ -206,8 +130,7 @@ static void latency_on_ring(int fd, }if (flags &CORK ) { -plug (fd, &c); - obj[0 ].handle = c.handle; + obj[0 ].handle =igt_cork_plug (fd,VGEM_BO , &c); execbuf.buffers_ptr =to_user_pointer (&obj[0 ]); execbuf.buffer_count =3 ; }
@@ -228,7 +151,7 @@ static void latency_on_ring(int fd,igt_assert (reloc.presumed_offset == obj[1 ].offset);if (flags &CORK ) -unplug (&c); +igt_cork_unplug (VGEM_BO , &c);gem_set_domain (fd, obj[1 ].handle,I915_GEM_DOMAIN_GTT ,0 ); gpu_latency = (results[repeats-1 ] - results[0 ]) / (double )(repeats-1 );
@@ -269,6 +192,8 @@ static void latency_on_ring(int fd,munmap (map,64 *1024 );munmap (results,4096 ); +if (flags &CORK ) +gem_close (fd, obj[0 ].handle);gem_close (fd, obj[1 ].handle);gem_close (fd, obj[2 ].handle); }
@@ -331,7 +256,7 @@ static void latency_from_ring(int fd,for (e = intel_execution_engines; e->name; e++) {igt_spin_t *spin =NULL ; -struct cork c; +struct igt_cork_vgem c;if (e->exec_id ==0 )continue ;
@@ -347,8 +272,7 @@ static void latency_from_ring(int fd, spin =igt_spin_batch_new (fd, ctx[0 ], ring,0 );if (flags &CORK ) { -plug (fd, &c); - obj[0 ].handle = c.handle; + obj[0 ].handle =igt_cork_plug (fd,VGEM_BO , &c); execbuf.buffers_ptr =to_user_pointer (&obj[0 ]); execbuf.buffer_count =3 ; }
@@ -408,7 +332,7 @@ static void latency_from_ring(int fd, }if (flags &CORK ) -unplug (&c); +igt_cork_unplug (VGEM_BO , &c);gem_set_domain (fd, obj[1 ].handle,I915_GEM_DOMAIN_GTT ,I915_GEM_DOMAIN_GTT );
@@ -420,6 +344,9 @@ static void latency_from_ring(int fd,munmap (map,64 *1024 );munmap (results,4096 ); + +if (flags &CORK ) +gem_close (fd, obj[0 ].handle);gem_close (fd, obj[1 ].handle);gem_close (fd, obj[2 ].handle);
@@ -441,7 +368,7 @@ igt_maingem_submission_print_method (device); - ring_size =measure_ring_size (device); + ring_size =intel_measure_ring_size (device,0 , false);igt_info ("Ring size: %d batches\n" , ring_size);igt_require (ring_size >8 ); ring_size -=8 ;/* leave some spare */
Signature · 6 lines
2.14.2 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v3 6/11 tests/gem_wait: use igt_cork
In reply to Antonio ArgenzianoFrom: Daniele Ceraolo Spurio <[email protected]>
With igt_cork added as common utility we can use it instead of the local copy
--- tests/gem_wait.c | 58 ++++++++++++++------------------------------------------ 1 file changed, 14 insertions(+), 44 deletions(-)
tests/gem_wait.c +14 -44
@@ -69,51 +69,15 @@ static void invalid_buf(int fd)#define AWAIT 4#define WRITE 8 -struct cork { -int device; -uint32_t handle; -uint32_t fence; -}; - -static struct cork plug (int fd,unsigned flags) -{ -struct cork c; -struct vgem_bo bo; -int dmabuf; - -if ((flags & (WRITE |AWAIT )) ==0 ) -return (struct cork ){0 }; - - c.device =drm_open_driver (DRIVER_VGEM ); - - bo.width = bo.height =1 ; - bo.bpp =4 ; -vgem_create (c.device, &bo); - c.fence =vgem_fence_attach (c.device, &bo,VGEM_FENCE_WRITE ); - - dmabuf =prime_handle_to_fd (c.device, bo.handle); - c.handle =prime_fd_to_handle (fd, dmabuf); -close (dmabuf); - -return c; -} - -static void unplug (struct cork *c) -{ -if (!c->device) -return ; - -vgem_fence_signal (c->device, c->fence); -close (c->device); -} -static void basic (int fd,unsigned engine,unsigned flags) { -struct cork cork =plug (fd, flags); -igt_spin_t *spin =igt_spin_batch_new (fd,0 , engine, cork.handle); +struct igt_cork_vgem cork = {0 }; +uint32_t plug = + flags & (WRITE |AWAIT ) ?igt_cork_plug (fd,VGEM_BO , &cork) :0 ; +igt_spin_t *spin =igt_spin_batch_new (fd,0 , engine, plug);struct drm_i915_gem_wait wait = { - flags &WRITE ? cork.handle : spin->handle - }; + flags &WRITE ? plug : spin->handle + };igt_assert_eq (__gem_wait (fd, &wait), -ETIME );
@@ -127,7 +91,9 @@ static void basic(int fd, unsigned engine, unsigned flags) timeout =1 ; } -unplug (&cork); +if (flags & (WRITE |AWAIT )) +igt_cork_unplug (VGEM_BO , &cork); +igt_assert_eq (__gem_wait (fd, &wait), -ETIME );while (__gem_wait (fd, &wait) == -ETIME )
@@ -137,7 +103,9 @@ static void basic(int fd, unsigned engine, unsigned flags)igt_assert_eq (__gem_wait (fd, &wait), -ETIME );igt_assert_eq_s64 (wait.timeout_ns,0 ); -unplug (&cork); +if (flags & (WRITE |AWAIT )) +igt_cork_unplug (VGEM_BO , &cork); + wait.timeout_ns =0 ;igt_assert_eq (__gem_wait (fd, &wait), -ETIME );
@@ -157,6 +125,8 @@ static void basic(int fd, unsigned engine, unsigned flags)igt_assert (wait.timeout_ns ==0 ); } +if (plug) +gem_close (fd, plug);igt_spin_batch_free (fd, spin); }
Signature · 6 lines
2.14.2 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v3 7/11 tests/gem_eio: use igt_cork
In reply to Antonio ArgenzianoWith igt_cork added as common utility we can use it instead of the local copy
--- tests/gem_eio.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
tests/gem_eio.c +4 -6
@@ -338,13 +338,12 @@ static void test_inflight_external(int fd)struct drm_i915_gem_exec_object2 obj;uint32_t bbe =MI_BATCH_BUFFER_END ;igt_hang_t hang; -int timeline, fence; +uint32_t fence; +struct igt_cork_sw_sync cork; -igt_require_sw_sync ();igt_require (gem_has_exec_fence (fd)); - timeline =sw_sync_timeline_create (); - fence =sw_sync_timeline_create_fence (timeline,1 ); + fence =igt_cork_plug (fd,SW_SYNC , &cork);igt_require (i915_reset_control (false)); hang =igt_hang_ring (fd,I915_EXEC_DEFAULT );
@@ -366,7 +365,7 @@ static void test_inflight_external(int fd)igt_assert (fence !=-1 );igt_post_hang_ring (fd, hang);/* wedged, with an unready batch */ -sw_sync_timeline_inc (timeline,1 );/* only now submit our batches */ +igt_cork_unplug (SW_SYNC , &cork);/* only now submit our batches */ igt_assert_eq (__gem_wait (fd, obj.handle,-1 ),0 );igt_assert_eq (sync_fence_status (fence), -EIO );
@@ -374,7 +373,6 @@ static void test_inflight_external(int fd)igt_assert (i915_reset_control (true));trigger_reset (fd); -close (timeline); }static void test_inflight_internal (int fd)
Signature · 6 lines
2.14.2 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v3 8/11 tests/gem_exec_await: use intel_measure_ring_size
In reply to Antonio ArgenzianoFrom: Daniele Ceraolo Spurio <[email protected]>
With intel_measure_ring_size added as common function we can use it instead of the local copy
--- tests/gem_exec_await.c | 91 ++------------------------------------------------ 1 file changed, 2 insertions(+), 89 deletions(-)
tests/gem_exec_await.c +2 -89
@@ -26,6 +26,7 @@#include "igt_rand.h" #include "igt_sysfs.h" #include "igt_vgem.h" +#include "i915/gem_ring.h" #include <sys/ioctl.h> #include <sys/signal.h>
@@ -237,94 +238,6 @@ static void wide(int fd, int ring_size, int timeout, unsigned int flags)free (exec); } -struct cork { -int device; -uint32_t handle; -uint32_t fence; -}; - -static void plug (int fd,struct cork *c) -{ -struct vgem_bo bo; -int dmabuf; - - c->device =drm_open_driver (DRIVER_VGEM ); - - bo.width = bo.height =1 ; - bo.bpp =4 ; -vgem_create (c->device, &bo); - c->fence =vgem_fence_attach (c->device, &bo,VGEM_FENCE_WRITE ); - - dmabuf =prime_handle_to_fd (c->device, bo.handle); - c->handle =prime_fd_to_handle (fd, dmabuf); -close (dmabuf); -} - -static void unplug (struct cork *c) -{ -vgem_fence_signal (c->device, c->fence); -close (c->device); -} - -static void alarm_handler (int sig) -{ -} - -static int __execbuf (int fd,struct drm_i915_gem_execbuffer2 *execbuf) -{ -return ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , execbuf); -} - -static unsigned int measure_ring_size (int fd) -{ -struct sigaction sa = { .sa_handler = alarm_handler }; -struct drm_i915_gem_exec_object2 obj[2 ]; -struct drm_i915_gem_execbuffer2 execbuf; -const uint32_t bbe =MI_BATCH_BUFFER_END ; -unsigned int count, last; -struct itimerval itv; -struct cork c; - -memset (obj,0 ,sizeof (obj)); - obj[1 ].handle =gem_create (fd,4096 ); -gem_write (fd, obj[1 ].handle,0 , &bbe,sizeof (bbe)); - -plug (fd, &c); - obj[0 ].handle = c.handle; - -memset (&execbuf,0 ,sizeof (execbuf)); - execbuf.buffers_ptr =to_user_pointer (obj); - execbuf.buffer_count =2 ; - -sigaction (SIGALRM , &sa,NULL ); - itv.it_interval.tv_sec =0 ; - itv.it_interval.tv_usec =100 ; - itv.it_value.tv_sec =0 ; - itv.it_value.tv_usec =1000 ; -setitimer (ITIMER_REAL , &itv,NULL ); - - last = count =0 ; -do { -if (__execbuf (fd, &execbuf) ==0 ) { - count++; -continue ; - } - -if (last == count) -break ; - - last = count; - }while (1 ); - -memset (&itv,0 ,sizeof (itv)); -setitimer (ITIMER_REAL , &itv,NULL ); - -unplug (&c); -gem_close (fd, obj[1 ].handle); - -return count; -} - igt_main {int ring_size =0 ;
@@ -336,7 +249,7 @@ igt_mainigt_require_gem (device);gem_submission_print_method (device); - ring_size =measure_ring_size (device) -10 ; + ring_size =intel_measure_ring_size (device,0 , false) -10 ;if (!gem_has_execlists (device)) ring_size /=2 ;igt_info ("Ring size: %d batches\n" , ring_size);
Signature · 6 lines
2.14.2 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v3 9/11 tests/gem_ringfill: use intel_measure_ring_size
In reply to Antonio ArgenzianoFrom: Daniele Ceraolo Spurio <[email protected]>
With intel_measure_ring_size added as common function we can use it instead of the local copy
--- tests/gem_ringfill.c | 97 ++-------------------------------------------------- 1 file changed, 2 insertions(+), 95 deletions(-)
tests/gem_ringfill.c +2 -95
@@ -35,6 +35,7 @@#include "igt_device.h" #include "igt_gt.h" #include "igt_vgem.h" +#include "i915/gem_ring.h" #include <signal.h> #include <sys/ioctl.h>
@@ -237,100 +238,6 @@ static void run_test(int fd, unsigned ring, unsigned flags, unsigned timeout)run_test (fd, ring,0 ,0 ); } -struct cork { -int device; -uint32_t handle; -uint32_t fence; -}; - -static void plug (int fd,struct cork *c) -{ -struct vgem_bo bo; -int dmabuf; - - c->device =drm_open_driver (DRIVER_VGEM ); - - bo.width = bo.height =1 ; - bo.bpp =4 ; -vgem_create (c->device, &bo); - c->fence =vgem_fence_attach (c->device, &bo,VGEM_FENCE_WRITE ); - - dmabuf =prime_handle_to_fd (c->device, bo.handle); - c->handle =prime_fd_to_handle (fd, dmabuf); -close (dmabuf); -} - -static void unplug (struct cork *c) -{ -vgem_fence_signal (c->device, c->fence); -close (c->device); -} - -static void alarm_handler (int sig) -{ -} - -static int __execbuf (int fd,struct drm_i915_gem_execbuffer2 *execbuf) -{ -return ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , execbuf); -} - -static unsigned int measure_ring_size (int fd) -{ -struct sigaction sa = { .sa_handler = alarm_handler }; -struct drm_i915_gem_exec_object2 obj[2 ]; -struct drm_i915_gem_execbuffer2 execbuf; -const uint32_t bbe =MI_BATCH_BUFFER_END ; -unsigned int count, last; -struct itimerval itv; -struct cork c; - -memset (obj,0 ,sizeof (obj)); - obj[1 ].handle =gem_create (fd,4096 ); -gem_write (fd, obj[1 ].handle,0 , &bbe,sizeof (bbe)); - -memset (&execbuf,0 ,sizeof (execbuf)); - execbuf.buffers_ptr =to_user_pointer (obj +1 ); - execbuf.buffer_count =1 ; -gem_execbuf (fd, &execbuf); -gem_sync (fd, obj[1 ].handle); - -plug (fd, &c); - obj[0 ].handle = c.handle; - - execbuf.buffers_ptr =to_user_pointer (obj); - execbuf.buffer_count =2 ; - -sigaction (SIGALRM , &sa,NULL ); - itv.it_interval.tv_sec =0 ; - itv.it_interval.tv_usec =100 ; - itv.it_value.tv_sec =0 ; - itv.it_value.tv_usec =1000 ; -setitimer (ITIMER_REAL , &itv,NULL ); - - last =-1 ; - count =0 ; -do { -if (__execbuf (fd, &execbuf) ==0 ) { - count++; -continue ; - } - -if (last == count) -break ; - - last = count; - }while (1 ); - -memset (&itv,0 ,sizeof (itv)); -setitimer (ITIMER_REAL , &itv,NULL ); - -unplug (&c); -gem_close (fd, obj[1 ].handle); - -return count; -} -igt_main {const struct {
@@ -365,7 +272,7 @@ igt_main master = true; } - ring_size =measure_ring_size (fd); + ring_size =intel_measure_ring_size (fd,0 , false);igt_info ("Ring size: %d batches\n" , ring_size);igt_require (ring_size); }
Signature · 6 lines
2.14.2 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v3 10/11 tests/gem_busy: Use intel_measure_ring_size
In reply to Antonio ArgenzianoWith intel_measure_ring_size added as common function we can use it instead of the local copy
--- tests/gem_busy.c | 92 ++------------------------------------------------------ 1 file changed, 2 insertions(+), 90 deletions(-)
tests/gem_busy.c +2 -90
@@ -28,6 +28,7 @@#include "igt.h" #include "igt_rand.h" #include "igt_vgem.h" +#include "i915/gem_ring.h" #define LOCAL_EXEC_NO_RELOC (1<<11)#define PAGE_ALIGN (x) ALIGN(x, 4096)
@@ -305,99 +306,10 @@ struct cork {uint32_t fence; }; -static void plug (int fd,struct cork *c) -{ -struct vgem_bo bo; -int dmabuf; - - c->device =drm_open_driver (DRIVER_VGEM ); - - bo.width = bo.height =1 ; - bo.bpp =4 ; -vgem_create (c->device, &bo); - c->fence =vgem_fence_attach (c->device, &bo,VGEM_FENCE_WRITE ); - - dmabuf =prime_handle_to_fd (c->device, bo.handle); - c->handle =prime_fd_to_handle (fd, dmabuf); -close (dmabuf); -} - -static void unplug (struct cork *c) -{ -vgem_fence_signal (c->device, c->fence); -close (c->device); -} - -static void alarm_handler (int sig) -{ -} - -static int __execbuf (int fd,struct drm_i915_gem_execbuffer2 *execbuf) -{ -return ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , execbuf); -} - -static unsigned int measure_ring_size (int fd) -{ -struct sigaction sa = { .sa_handler = alarm_handler }; -struct drm_i915_gem_exec_object2 obj[2 ]; -struct drm_i915_gem_execbuffer2 execbuf; -const uint32_t bbe =MI_BATCH_BUFFER_END ; -unsigned int count, last; -struct itimerval itv; -struct cork c; - -memset (obj,0 ,sizeof (obj)); - obj[1 ].handle =gem_create (fd,4096 ); -gem_write (fd, obj[1 ].handle,0 , &bbe,sizeof (bbe)); - -memset (&execbuf,0 ,sizeof (execbuf)); - execbuf.buffers_ptr =to_user_pointer (obj +1 ); - execbuf.buffer_count =1 ; -gem_execbuf (fd, &execbuf); -gem_sync (fd, obj[1 ].handle); - -plug (fd, &c); - obj[0 ].handle = c.handle; - - execbuf.buffers_ptr =to_user_pointer (obj); - execbuf.buffer_count =2 ; - -sigaction (SIGALRM , &sa,NULL ); - itv.it_interval.tv_sec =0 ; - itv.it_interval.tv_usec =100 ; - itv.it_value.tv_sec =0 ; - itv.it_value.tv_usec =1000 ; -setitimer (ITIMER_REAL , &itv,NULL ); - - last =-1 ; - count =0 ; -do { -if (__execbuf (fd, &execbuf) ==0 ) { - count++; -continue ; - } - -if (last == count) -break ; - - last = count; - }while (1 ); - -memset (&itv,0 ,sizeof (itv)); -setitimer (ITIMER_REAL , &itv,NULL ); - -unplug (&c); -gem_close (fd, obj[1 ].handle); -gem_quiescent_gpu (fd); - -return count; -} -static void close_race (int fd) {const unsigned int ncpus =sysconf (_SC_NPROCESSORS_ONLN); -const unsigned int nhandles =measure_ring_size (fd) /2 ; +const unsigned int nhandles =intel_measure_ring_size (fd,0 , false) /2 ;unsigned int engines[16 ], nengine;unsigned long *control;uint32_t *handles;
Signature · 6 lines
2.14.2 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v3 11/11 igt: Use lib gem_execbuf where possible
In reply to Antonio ArgenzianoReplace custom execbuf ioctl wrapper with the ones in lib.
v2:
- Lib execbuf wrapper is not signal handling friendly. (Chris)
--- tests/gem_close_race.c | 3 +-- tests/gem_ctx_exec.c | 15 +++++---------- tests/gem_evict_alignment.c | 7 ++----- tests/gem_exec_bad_domains.c | 6 +----- tests/gem_exec_blt.c | 4 ++-- tests/gem_exec_fence.c | 14 +------------- tests/gem_exec_lut_handle.c | 2 +- tests/gem_exec_params.c | 9 ++------- tests/gem_gtt_hog.c | 2 +- tests/gem_lut_handle.c | 13 ++----------- tests/gem_pwrite_pread.c | 12 ++++++------ tests/gen3_mixed_blits.c | 16 ++-------------- tests/gen3_render_linear_blits.c | 6 +++--- tests/gen3_render_mixed_blits.c | 6 +++--- tests/gen3_render_tiledx_blits.c | 4 ++-- tests/gen3_render_tiledy_blits.c | 6 +++--- tests/pm_rpm.c | 6 +++--- 17 files changed, 40 insertions(+), 91 deletions(-)
tests/gem_close_race.c +1 -2
@@ -119,8 +119,7 @@ static void selfcopy(int fd, uint32_t handle, int loops) gem_pwrite.size =sizeof (buf); gem_pwrite.data_ptr =to_user_pointer (buf);if (drmIoctl (fd,DRM_IOCTL_I915_GEM_PWRITE , &gem_pwrite) ==0 ) { -while (loops-- && -drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf) ==0 ) +while (loops-- &&__gem_execbuf (fd, &execbuf) ==0 ) ; }
tests/gem_ctx_exec.c +5 -10
@@ -52,7 +52,6 @@ static int exec(int fd, uint32_t handle, int ring, int ctx_id) {struct drm_i915_gem_execbuffer2 execbuf;struct drm_i915_gem_exec_object2 gem_exec; -int ret =0 ; gem_exec.handle = handle; gem_exec.relocation_count =0 ;
@@ -75,10 +74,7 @@ static int exec(int fd, uint32_t handle, int ring, int ctx_id)i915_execbuffer2_set_context_id (execbuf, ctx_id); execbuf.rsvd2 =0 ; - ret =drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , - &execbuf); - -return ret; +return __gem_execbuf (fd, &execbuf); }static void big_exec (int fd,uint32_t handle,int ring)
@@ -116,7 +112,7 @@ static void big_exec(int fd, uint32_t handle, int ring) execbuf.buffer_count =1 ;i915_execbuffer2_set_context_id (execbuf, ctx_id1); -do_ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf); +gem_execbuf (fd, &execbuf);for (i =0 ; i < num_buffers; i++) {uint32_t tmp_handle =gem_create (fd,4096 );
@@ -127,8 +123,7 @@ static void big_exec(int fd, uint32_t handle, int ring) execbuf.buffer_count = i +1 ;/* figure out how many buffers we can exactly fit */ -while (drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , - &execbuf) !=0 ) { +while (__gem_execbuf (fd, &execbuf) !=0 ) { i--;gem_close (fd, gem_exec[i].handle); gem_exec[i].handle = handle;
@@ -140,10 +135,10 @@ static void big_exec(int fd, uint32_t handle, int ring) i - 1, num_buffers);/* double check that it works */ -do_ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf); +gem_execbuf (fd, &execbuf);i915_execbuffer2_set_context_id (execbuf, ctx_id2); -do_ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf); +gem_execbuf (fd, &execbuf);gem_sync (fd, handle); }
tests/gem_evict_alignment.c +2 -5
@@ -61,7 +61,7 @@ copy(int fd, uint32_t dst, uint32_t src, uint32_t *all_bo,struct drm_i915_gem_exec_object2 *obj;struct drm_i915_gem_execbuffer2 exec;uint32_t handle; -int n, ret, i=0 ; +int n, i=0 ; batch[i++] = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
@@ -121,10 +121,7 @@ copy(int fd, uint32_t dst, uint32_t src, uint32_t *all_bo,i915_execbuffer2_set_context_id (exec,0 ); exec.rsvd2 =0 ; - ret =drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &exec); -if (ret) - ret = errno; -igt_assert_eq (ret, error); +igt_assert_eq (__gem_execbuf (fd, &exec), -error);gem_close (fd, handle);free (obj);
tests/gem_exec_bad_domains.c +1 -5
@@ -95,7 +95,6 @@ static void multi_write_domain(int fd)struct drm_i915_gem_exec_object2 exec[2 ];struct drm_i915_gem_relocation_entry reloc[1 ];uint32_t handle, handle_target; -int ret; handle =gem_create (fd,4096 ); handle_target =gem_create (fd,4096 );
@@ -137,10 +136,7 @@ static void multi_write_domain(int fd)i915_execbuffer2_set_context_id (execbuf,0 ); execbuf.rsvd2 =0 ; - ret =drmIoctl (fd, -DRM_IOCTL_I915_GEM_EXECBUFFER2 , - &execbuf); -igt_assert (ret !=0 && errno ==EINVAL ); +igt_assert_eq (__gem_execbuf (fd, &execbuf), -EINVAL );gem_close (fd, handle);gem_close (fd, handle_target);
tests/gem_exec_blt.c +2 -2
@@ -228,12 +228,12 @@ static void run(int object_size, bool dumb) execbuf.flags |=LOCAL_I915_EXEC_HANDLE_LUT ; execbuf.flags |=LOCAL_I915_EXEC_NO_RELOC ; -if (drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf)) { +if (__gem_execbuf (fd, &execbuf)) { len =gem_linear_blt (fd, buf, src, dst, object_size, reloc);igt_assert (len == execbuf.batch_len);gem_write (fd, handle,0 , buf, len); execbuf.flags = ring; -do_ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf); +gem_execbuf (fd, &execbuf); }gem_sync (fd, handle);
tests/gem_exec_fence.c +1 -13
@@ -326,18 +326,6 @@ static void alarm_handler(int sig) { } -static int __execbuf (int fd,struct drm_i915_gem_execbuffer2 *execbuf) -{ -int err; - - err =0 ; -if (ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2_WR , execbuf)) - err = -errno; - - errno =0 ; -return err; -} -static void test_parallel (int fd,unsigned int master) {const int SCRATCH =0 ;
@@ -565,7 +553,7 @@ static void test_keep_in_fence(int fd, unsigned int engine, unsigned int flags) last =-1 ; count =0 ; do { - int err = __execbuf(fd, &execbuf); + int err = __gem_execbuf(fd, &execbuf); igt_assert_eq(lower_32_bits(execbuf.rsvd2), fence);
tests/gem_exec_lut_handle.c +1 -1
@@ -77,7 +77,7 @@ static int has_exec_lut(int fd) execbuf.buffer_count =1 ; execbuf.flags =LOCAL_I915_EXEC_HANDLE_LUT ; -return drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf) ==0 ; +return __gem_execbuf (fd, &execbuf) ==0 ; }#define ELAPSED (a,b) (1e6*((b)->tv_sec - (a)->tv_sec) + ((b)->tv_usec - (a)->tv_usec))
tests/gem_exec_params.c +2 -7
@@ -233,10 +233,7 @@ igt_main }#define RUN_FAIL (expected_errno) do { \ - igt_assert(drmIoctl(fd, \ - DRM_IOCTL_I915_GEM_EXECBUFFER2, \ - &execbuf) == -1); \ - igt_assert_eq(errno, expected_errno); \ + igt_assert_eq(__gem_execbuf(fd, &execbuf), -expected_errno); \ } while(0) igt_subtest("no-bsd") {
@@ -350,9 +347,7 @@ igt_mainRUN_FAIL (EPERM );igt_device_set_master (fd); -igt_assert (drmIoctl (fd, -DRM_IOCTL_I915_GEM_EXECBUFFER2 , - &execbuf) ==0 ); +gem_execbuf (fd, &execbuf);igt_device_drop_master (fd);/* Only needs temporary master */ }
tests/gem_gtt_hog.c +1 -1
@@ -113,7 +113,7 @@ static void busy(data_t *data, uint32_t handle, int size, int loops) gem_pwrite.data_ptr =to_user_pointer (buf);if (drmIoctl (data->fd,DRM_IOCTL_I915_GEM_PWRITE , &gem_pwrite) ==0 ) {while (loops--) -drmIoctl (data->fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf); +gem_execbuf (data->fd, &execbuf); }drmIoctl (data->fd,DRM_IOCTL_GEM_CLOSE , &create.handle);
tests/gem_lut_handle.c +2 -11
@@ -84,12 +84,7 @@ static int exec(int fd, uint32_t handle, unsigned int flags)i915_execbuffer2_set_context_id (execbuf,0 ); execbuf.rsvd2 =0 ; -if (drmIoctl (fd, -DRM_IOCTL_I915_GEM_EXECBUFFER2 , - &execbuf)) -return -errno; - -return 0 ; +return __gem_execbuf (fd, &execbuf); }static int many_exec (int fd,uint32_t batch,int num_exec,int num_reloc,unsigned flags)
@@ -156,11 +151,7 @@ static int many_exec(int fd, uint32_t batch, int num_exec, int num_reloc, unsigni915_execbuffer2_set_context_id (execbuf,0 ); execbuf.rsvd2 =0 ; - ret =drmIoctl (fd, -DRM_IOCTL_I915_GEM_EXECBUFFER2 , - &execbuf); -if (ret <0 ) - ret = -errno; + ret =__gem_execbuf (fd, &execbuf);for (n =0 ; n < num_exec; n++)gem_close (fd, gem_exec[n].handle);
tests/gem_pwrite_pread.c +6 -6
@@ -100,7 +100,7 @@ static void copy(int fd, uint32_t src, uint32_t dst, void *buf, int len, int loowhile (loops--) {gem_write (fd, src,0 , buf, len); -do_ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf); +gem_execbuf (fd, &execbuf);gem_read (fd, dst,0 , buf, len); }
@@ -120,7 +120,7 @@ static void as_gtt_mmap(int fd, uint32_t src, uint32_t dst, void *buf, int len, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);memcpy (src_ptr, buf, len); -do_ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf); +gem_execbuf (fd, &execbuf);gem_set_domain (fd, dst,I915_GEM_DOMAIN_GTT ,0 );memcpy (buf, dst_ptr, len);
@@ -145,7 +145,7 @@ static void as_cpu_mmap(int fd, uint32_t src, uint32_t dst, void *buf, int len, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);memcpy (src_ptr, buf, len); -do_ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf); +gem_execbuf (fd, &execbuf);gem_set_domain (fd, dst,I915_GEM_DOMAIN_CPU ,0 );memcpy (buf, dst_ptr, len);
@@ -167,7 +167,7 @@ static void test_copy(int fd, uint32_t src, uint32_t dst, uint32_t *buf, int lengem_write (fd, src,0 , buf, len);memset (buf,0 , len); -do_ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf); +gem_execbuf (fd, &execbuf);gem_read (fd, dst,0 , buf, len);gem_close (fd, exec[2 ].handle);
@@ -189,7 +189,7 @@ static void test_as_gtt_mmap(int fd, uint32_t src, uint32_t dst, int len)for (i =0 ; i < len/4 ; i++) src_ptr[i] = i; -do_ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf); +gem_execbuf (fd, &execbuf);gem_close (fd, exec[2 ].handle);gem_set_domain (fd, dst,I915_GEM_DOMAIN_GTT ,0 );
@@ -213,7 +213,7 @@ static void test_as_cpu_mmap(int fd, uint32_t src, uint32_t dst, int len)for (i =0 ; i < len/4 ; i++) src_ptr[i] = i; -do_ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf); +gem_execbuf (fd, &execbuf);gem_close (fd, exec[2 ].handle);gem_set_domain (fd, dst,I915_GEM_DOMAIN_CPU ,0 );
tests/gen3_mixed_blits.c +2 -14
@@ -88,7 +88,6 @@ render_copy(int fd,struct drm_i915_gem_execbuffer2 exec;uint32_t handle;uint32_t tiling_bits; -int ret;/* invariant state */ *b++ = (_3DSTATE_AA_CMD |
@@ -310,12 +309,7 @@ render_copy(int fd,i915_execbuffer2_set_context_id (exec,0 ); exec.rsvd2 =0 ; - ret =drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &exec); -while (ret && errno ==EBUSY ) { -drmCommandNone (fd,DRM_I915_GEM_THROTTLE ); - ret =drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &exec); - } -igt_assert_eq (ret,0 ); +gem_execbuf (fd, &exec);gem_close (fd, handle); }
@@ -327,7 +321,6 @@ static void blt_copy(int fd, uint32_t dst, uint32_t src)struct drm_i915_gem_exec_object2 obj[3 ];struct drm_i915_gem_execbuffer2 exec;uint32_t handle; -int ret; *b++ = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
@@ -388,12 +381,7 @@ static void blt_copy(int fd, uint32_t dst, uint32_t src)i915_execbuffer2_set_context_id (exec,0 ); exec.rsvd2 =0 ; - ret =drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &exec); -while (ret && errno ==EBUSY ) { -drmCommandNone (fd,DRM_I915_GEM_THROTTLE ); - ret =drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &exec); - } -igt_assert_eq (ret,0 ); +gem_execbuf (fd, &exec);gem_close (fd, handle); }
tests/gen3_render_linear_blits.c +3 -3
@@ -280,10 +280,10 @@ copy(int fd, uint32_t dst, uint32_t src)i915_execbuffer2_set_context_id (exec,0 ); exec.rsvd2 =0 ; - ret =drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &exec); -while (ret && errno ==EBUSY ) { + ret =__gem_execbuf (fd, &exec); +while (ret ==EBUSY ) {drmCommandNone (fd,DRM_I915_GEM_THROTTLE ); - ret =drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &exec); + ret =__gem_execbuf (fd, &exec); }igt_assert_eq (ret,0 );
tests/gen3_render_mixed_blits.c +3 -3
@@ -293,10 +293,10 @@ copy(int fd,i915_execbuffer2_set_context_id (exec,0 ); exec.rsvd2 =0 ; - ret =drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &exec); -while (ret && errno ==EBUSY ) { + ret =__gem_execbuf (fd, &exec); +while (ret ==EBUSY ) {drmCommandNone (fd,DRM_I915_GEM_THROTTLE ); - ret =drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &exec); + ret =__gem_execbuf (fd, &exec); }igt_assert_eq (ret,0 );
tests/gen3_render_tiledx_blits.c +2 -2
@@ -280,10 +280,10 @@ copy(int fd, uint32_t dst, uint32_t src)i915_execbuffer2_set_context_id (exec,0 ); exec.rsvd2 =0 ; - ret =drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &exec); + ret =__gem_execbuf (fd, &exec);while (ret && errno ==EBUSY ) {drmCommandNone (fd,DRM_I915_GEM_THROTTLE ); - ret =drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &exec); + ret =__gem_execbuf (fd, &exec); }igt_assert_eq (ret,0 );
tests/gen3_render_tiledy_blits.c +3 -3
@@ -280,10 +280,10 @@ copy(int fd, uint32_t dst, uint32_t src)i915_execbuffer2_set_context_id (exec,0 ); exec.rsvd2 =0 ; - ret =drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &exec); -while (ret && errno ==EBUSY ) { + ret =__gem_execbuf (fd, &exec); +while (ret ==EBUSY ) {drmCommandNone (fd,DRM_I915_GEM_THROTTLE ); - ret =drmIoctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &exec); + ret =__gem_execbuf (fd, &exec); }igt_assert_eq (ret,0 );
tests/pm_rpm.c +3 -3
@@ -1116,7 +1116,7 @@ static void submit_blt_cmd(uint32_t dst_handle, uint16_t x, uint16_t y, execbuf.flags =I915_EXEC_BLT ;i915_execbuffer2_set_context_id (execbuf,0 ); -do_ioctl (drm_fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf); +gem_execbuf (drm_fd, &execbuf); *presumed_dst_offset = relocs[0 ].presumed_offset;
@@ -1257,7 +1257,7 @@ static void gem_execbuf_stress_subtest(int rounds, int wait_flags)i915_execbuffer2_set_context_id (execbuf,0 );for (i =0 ; i < rounds; i++) { -do_ioctl (drm_fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf); +gem_execbuf (drm_fd, &execbuf);if (wait_flags &WAIT_STATUS )igt_assert (wait_for_suspended ());
@@ -1387,7 +1387,7 @@ static void system_suspend_execbuf_subtest(void)igt_assert (wait_for_suspended ());for (i =0 ; i <20 ; i++) { -do_ioctl (drm_fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf); +gem_execbuf (drm_fd, &execbuf);igt_assert (wait_for_suspended ()); }
Signature · 6 lines
2.14.2 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,v3,01/11] lib/igt_dummyload: add igt_cork
In reply to Antonio Argenziano== Series Details ==
== Series Details ==
Series: series starting with [i-g-t,v3,01/11] lib/igt_dummyload: add igt_cork
URL : https://patchwork.freedesktop.org/series/38401/
State : failure
== Summary ==
IGT patchset tested on top of latest successful build 2b64cac7d858d0c63b87e7a889a21a36bfcc4138 lib/i915_pciids.h: Add Cannonlake PCI IDs for another SKU.
with latest DRM-Tip kernel build CI_DRM_37825b7aaf330f88 drm-tip: 2018y-02m-16d-00h-00m-51s UTC integration manifest
No testlist changes.
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-b:
pass -> INCOMPLETE (fi-snb-2520m) fdo#103713
Subgroup suspend-read-crc-pipe-c:
pass -> INCOMPLETE (fi-bxt-dsi)fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fi-bdw-5557u total:288 pass:267 dwarn:0 dfail:0 fail:0 skip:21 time:419s fi-bdw-gvtdvm total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:425s fi-blb-e6850 total:288 pass:223 dwarn:1 dfail:0 fail:0 skip:64 time:376s fi-bsw-n3050 total:288 pass:242 dwarn:0 dfail:0 fail:0 skip:46 time:490s fi-bwr-2160 total:288 pass:183 dwarn:0 dfail:0 fail:0 skip:105 time:289s fi-bxt-dsi total:246 pass:219 dwarn:0 dfail:0 fail:0 skip:26 fi-bxt-j4205 total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:490s fi-byt-j1900 total:288 pass:253 dwarn:0 dfail:0 fail:0 skip:35 time:473s fi-byt-n2820 total:288 pass:249 dwarn:0 dfail:0 fail:0 skip:39 time:462s fi-cfl-s2 total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:566s fi-cnl-y3 total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:587s fi-elk-e7500 total:288 pass:229 dwarn:0 dfail:0 fail:0 skip:59 time:420s fi-gdg-551 total:288 pass:180 dwarn:0 dfail:0 fail:0 skip:108 time:286s fi-glk-1 total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:516s fi-hsw-4770 total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:393s fi-ilk-650 total:288 pass:228 dwarn:0 dfail:0 fail:0 skip:60 time:413s fi-ivb-3520m total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:468s fi-kbl-7500u total:288 pass:263 dwarn:1 dfail:0 fail:0 skip:24 time:458s fi-kbl-7560u total:288 pass:269 dwarn:0 dfail:0 fail:0 skip:19 time:499s fi-kbl-7567u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:454s fi-kbl-r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:502s fi-pnv-d510 total:288 pass:222 dwarn:1 dfail:0 fail:0 skip:65 time:594s fi-skl-6260u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:431s fi-skl-6600u total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:510s fi-skl-6700hq total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:530s fi-skl-6770hq total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:475s fi-skl-guc total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:415s fi-skl-gvtdvm total:288 pass:265 dwarn:0 dfail:0 fail:0 skip:23 time:432s fi-snb-2520m total:245 pass:211 dwarn:0 dfail:0 fail:0 skip:33 fi-snb-2600 total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:406s
Blacklisted hosts:
fi-glk-dsi total:117 pass:104 dwarn:0 dfail:0 fail:0 skip:12
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_934/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoting Antonio Argenziano (2018-02-16 00:43:00)
Quoted 110 lines
From: Daniele Ceraolo Spurio <[email protected]>
The "cork" bo (imported bo with attached fence) and fence is used in several tests to stall execution. Moving it to a common place makes the codebase cleaner.
Note that the actual test updates is done in follow up patches as it is simpler to do in one go after one more common function is added in the next patch.
v2: don't use new/free naming, don't use dynamic alloc (Chris)
v3: addsw_synccommon functions. (Chris)Signed-off-by Daniele Ceraolo Spurio <[email protected]>Signed-off-by Antonio Argenziano <[email protected]>Cc Chris Wilson <[email protected]>Cc Daniele Ceraolo Spurio <[email protected]>--- lib/igt_dummyload.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_dummyload.h | 15 +++++++ 2 files changed, 134 insertions(+)lib/igt_dummyload.c +67
-0@@ -29,12 +29,14 @@#include <i915_drm.h> #include "igt_core.h" +#include "drmtest.h" #include "igt_dummyload.h" #include "igt_gt.h" #include "intel_chipset.h" #include "intel_reg.h" #include "ioctl_wrappers.h" #include "sw_sync.h" +#include "igt_vgem.h" /** * SECTION:igt_dummyload @@ -371,3 +373,120 @@ void igt_terminate_spin_batches(void)igt_spin_batch_end (iter);pthread_mutex_unlock (&list_lock); } + +static uint32_t igt_cork_plug_vgem (int fd,struct igt_cork_vgem *cork) +{ +struct vgem_bo bo; +int dmabuf; +uint32_t handle; + + cork->device =drm_open_driver (DRIVER_VGEM ); +igt_require (vgem_has_fences (cork->device)); + + bo.width = bo.height =1 ; + bo.bpp =4 ; +vgem_create (cork->device, &bo); + cork->fence =vgem_fence_attach (cork->device, &bo,VGEM_FENCE_WRITE ); + + dmabuf =prime_handle_to_fd (cork->device, bo.handle); + handle =prime_fd_to_handle (fd, dmabuf); +close (dmabuf); + +return handle; +} + +static void igt_cork_unplug_vgem (struct igt_cork_vgem *cork) +{ +igt_assert (cork->device); + +vgem_fence_signal (cork->device, cork->fence); +close (cork->device); + cork->device =-1 ; +} + +static uint32_t igt_cork_plug_sw_sync (struct igt_cork_sw_sync *cork) +{ +int fence; + +igt_require_sw_sync (); + + cork->timeline =sw_sync_timeline_create (); + fence =sw_sync_timeline_create_fence (cork->timeline,1 ); + +return fence; +} + +static void igt_cork_unplug_sw_sync (struct igt_cork_sw_sync *cork) +{ +sw_sync_timeline_inc (cork->timeline,1 ); +close (cork->timeline); +} + +/** +* igt_cork_plug: +* @fd: open drm file descriptor +* @method: method to utilize for corking. +* @cork: structure that will be filled with the state of the cork bo. +* Note: this has to match the corking method. +* +* This function provides a mechanism to stall submission. It provides two +* blocking methods: +* +* VGEM_BO. +* Imports a vgem bo with a fence attached to it. This bo can be used as a +* dependency during submission to stall execution until the fence is signaled. +* +* SW_SYNC: +* Creates a timeline and then a fence on that timeline. The fence can be used
lib/igt_dummyload.c void igt_terminate_spin_batches(void) · line 450
Quoted 10 lines
lib/igt_dummyload.c +10
-0+* as an input fence to a request, the request will be stalled until the fence +* is signaled. +* +* The parameters required to unblock the execution and to cleanup are stored in +* the provided cork structure. +* +* Returns: +* Handle of the imported BO / Sw sync fence FD. +*/ +uint32_t igt_cork_plug (int fd,unsigned method,void *cork)
unions are your friend here.
struct igt_cork {
enum igt_cork_type type;
union igt_cork_type {
int fd;
struct igt_cork_vgem {
int device;
uint32_t fence;
} vgem;
struct igt_cork_sw_sync {
int timeline;
} sw_sync;
};
}void igt_cork_init(struct igt_cork *cork, enum igt_cork_type)
{
cork->type = type;
cork->fd = -1;
}#define IGT_CORK(name, type) struct igt_cork name = { .type = type, .fd = -1} #define IGT_CORK_HANDLE(name) IGT_CORK(name, CORK_VGEM_HANDLE) #define IGT_CORK_FENCE(name) IGT_CORK(name, CORK_SYNC_FD)
uint32_t igt_cork_plug(struct igt_cork *cork, int fd)
{
igt_assert(cork->fd == -1);
switch (method) {
case CORK_SYNC_FD:
return plug_sync_fd(&cork->sw_sync, fd);
case CORK_VGEM_HANDLE:
return plug_vgem_handle(&cork->vgem, fd);
default:...
}
}void igt_cork_unplug(struct igt_cork *cork)
{
switch (cork->type) {
case CORK_SYNC_FD:
return unplug_sync_fd(&cork->sw_sync);
case CORK_VGEM_HANDLE:
return unplug_vgem_handle(&cork->vgem);
}
}_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [igt-dev] [PATCH i-g-t v3 02/11] lib/igt_gt: add intel_measure_ring_size
Quoting Antonio Argenziano (2018-02-16 00:43:01)
Quoted 84 lines
From: Daniele Ceraolo Spurio <[email protected]>
The logic to measure the ring size is replicated almost identically in several tests. Adding it as a common function will make the code cleaner.
The tests are updated in follow up patches.
v2:
- Move into a new file: 'gem_ring'. (Chris)Signed-off-by Daniele Ceraolo Spurio <[email protected]>Signed-off-by Antonio Argenziano <[email protected]>Cc Daniele Ceraolo Spurio <[email protected]>Cc Chris Wilson <[email protected]>--- lib/Makefile.sources | 2 + lib/i915/gem_ring.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/i915/gem_ring.h | 31 ++++++++++++++ lib/meson.build | 2 + 4 files changed, 149 insertions(+) create mode 100644 lib/i915/gem_ring.c create mode 100644 lib/i915/gem_ring.hlib/Makefile.sources +2
-0@@ -9,6 +9,8 @@ lib_source_list = \ i915/gem_scheduler.h \ i915/gem_submission.c \ i915/gem_submission.h \ + i915/gem_ring.h \ + i915/gem_ring.c \ i915_3d.h \ i915_reg.h \ i915_pciids.h \lib/i915/gem_ring.c new file +40
-0@@ -0,0 +1,114 @@ +/* +* Copyright �� 2014 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#include "gem_ring.h" + +#include <signal.h> +#include <sys/ioctl.h> + +#include "intel_reg.h" +#include "drmtest.h" +#include "ioctl_wrappers.h" +#include "igt_dummyload.h" + +static void alarm_handler (int sig) +{ +} + +/** +* intel_measure_ring_size: +* @fd: open i915 drm file descriptor
lib/i915/gem_ring.c line 50
Quoted 10 lines
lib/i915/gem_ring.c new file +10
-0+* @engine: execbuf engine flag +* @new_ctx: use a new context to account for the space used by the lrc init +* +* This function calculates the maximum number of batches that can be inserted +* at the same time in the ring on the selected engine. +* +* Returns: +* Number of batches that fit in the ring +*/ +unsigned int intel_measure_ring_size (int fd,unsigned int engine,bool new_ctx)
Inside gem_ring.c, that would suggest gem_ring_measure() (_inflight? thinking for a future gem_context_measure_inflight).
s/bool new_ctx/unsigned int flags/ saves adding another bool every time we want to extend this.
lib/i915/gem_ring.c
Quoted 9 lines
lib/i915/gem_ring.c new file +8
-0+struct sigaction old_sa, sa = { .sa_handler = alarm_handler }; +struct drm_i915_gem_exec_object2 obj[2 ]; +struct drm_i915_gem_execbuffer2 execbuf; +const uint32_t bbe =MI_BATCH_BUFFER_END ; +unsigned int count, last; +struct itimerval itv; +struct igt_cork_vgem cork; +igt_require_intel (fd);
That should be redundant and just spam by this point. The callers should have a igt_require_gem() in their initial fixture.
Quoted 42 lines
lib/i915/gem_ring.c new file +42
-0+ +memset (obj,0 ,sizeof (obj)); + obj[1 ].handle =gem_create (fd,4096 ); +gem_write (fd, obj[1 ].handle,0 , &bbe,sizeof (bbe)); + +memset (&execbuf,0 ,sizeof (execbuf)); + execbuf.buffers_ptr =to_user_pointer (&obj[1 ]); + execbuf.buffer_count =1 ; + execbuf.flags = engine; +gem_execbuf (fd, &execbuf); +gem_sync (fd, obj[1 ].handle); + + obj[0 ].handle =igt_cork_plug (fd,VGEM_BO , &cork); + + execbuf.buffers_ptr =to_user_pointer (obj); + execbuf.buffer_count =2 ; + +if (new_ctx) + execbuf.rsvd1 =gem_context_create (fd); + +sigaction (SIGALRM , &sa, &old_sa); + itv.it_interval.tv_sec =0 ; + itv.it_interval.tv_usec =100 ; + itv.it_value.tv_sec =0 ; + itv.it_value.tv_usec =1000 ; +setitimer (ITIMER_REAL , &itv,NULL ); + + last =-1 ; + count =0 ; +do { +if (ioctl (fd,DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf) ==0 ) { + count++; +continue ; + } + +if (last == count) +break ; + + last = count; + }while (1 ); + +memset (&itv,0 ,sizeof (itv));
lib/i915/gem_ring.c
Quoted 10 lines
lib/i915/gem_ring.c new file +10
-0+setitimer (ITIMER_REAL , &itv,NULL ); +sigaction (SIGALRM , &old_sa,NULL ); + +igt_cork_unplug (VGEM_BO , &cork); +gem_close (fd, obj[0 ].handle); +gem_close (fd, obj[1 ].handle); + +if (new_ctx) +gem_context_destroy (fd, execbuf.rsvd1); +
gem_quiescent_gpu(fd) to flush the nops before we return. -Chris
_______________________________________________
igt-dev mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev