tests/kms_flip: Refactor blit code
PATCH 1/4 tests/kms_flip: Refactor blit code
From: Ville Syrjälä <[email protected]>
Pull the code to emit a single blit to a separate function.
--- tests/kms_flip.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-)
tests/kms_flip.c +28 -19
@@ -162,6 +162,31 @@ static unsigned long gettime_us(void)return ts.tv_sec *1000000 + ts.tv_nsec /1000 ; } +static void blit_copy (drm_intel_bo *dst,drm_intel_bo *src, +unsigned int width,unsigned int height, +unsigned int dst_pitch,unsigned int src_pitch) +{ +BLIT_COPY_BATCH_START (0 ); +OUT_BATCH ((3 <<24 ) |/* 32 bits */ + (0xcc <<16 ) |/* copy ROP */ + dst_pitch); +OUT_BATCH (0 <<16 |0 ); +OUT_BATCH (height <<16 | width); +OUT_RELOC_FENCED (dst,I915_GEM_DOMAIN_RENDER ,I915_GEM_DOMAIN_RENDER ,0 ); +OUT_BATCH (0 <<16 |0 ); +OUT_BATCH (src_pitch); +OUT_RELOC_FENCED (src,I915_GEM_DOMAIN_RENDER ,0 ,0 ); +ADVANCE_BATCH (); + +if (batch->gen >=6 ) { +BEGIN_BATCH (3 ,0 ); +OUT_BATCH (XY_SETUP_CLIP_BLT_CMD ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +ADVANCE_BATCH (); + } +} +static void emit_dummy_load__bcs (struct test_output *o) {int i, limit;
@@ -177,25 +202,9 @@ static void emit_dummy_load__bcs(struct test_output *o)igt_assert (target_bo);for (i =0 ; i < limit; i++) { -BLIT_COPY_BATCH_START (0 ); -OUT_BATCH ((3 <<24 ) |/* 32 bits */ - (0xcc <<16 ) |/* copy ROP */ - pitch); -OUT_BATCH (0 <<16 |0 ); -OUT_BATCH (o->fb_height <<16 | o->fb_width); -OUT_RELOC_FENCED (dummy_bo,I915_GEM_DOMAIN_RENDER ,I915_GEM_DOMAIN_RENDER ,0 ); -OUT_BATCH (0 <<16 |0 ); -OUT_BATCH (pitch); -OUT_RELOC_FENCED (target_bo,I915_GEM_DOMAIN_RENDER ,0 ,0 ); -ADVANCE_BATCH (); - -if (batch->gen >=6 ) { -BEGIN_BATCH (3 ,0 ); -OUT_BATCH (XY_SETUP_CLIP_BLT_CMD ); -OUT_BATCH (0 ); -OUT_BATCH (0 ); -ADVANCE_BATCH (); - } +blit_copy (dummy_bo, target_bo, + o->fb_width, o->fb_height, + pitch, pitch);swap (dummy_bo, target_bo); }
Signature · 6 lines
2.0.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/4 tests/kms_flip: Use fixed size (2kx2k) buffers for dummy load
From: Ville Syrjälä <[email protected]>
Make the dummy load independent of the display resolution by using a two fixed size dummy bos to generate the load. As a final step do another copy from one of the dummy bos to the fb to make sure there's a dependency between the dummy load and any subsequent operation on the fb.
--- tests/kms_flip.c | 59 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 19 deletions(-)
tests/kms_flip.c +40 -19
@@ -190,28 +190,35 @@ static void blit_copy(drm_intel_bo *dst, drm_intel_bo *src,static void emit_dummy_load__bcs (struct test_output *o) {int i, limit; -drm_intel_bo *dummy_bo, *target_bo; +drm_intel_bo *src_bo, *dst_bo, *fb_bo;struct igt_fb *fb_info = &o->fb_info[o->current_fb_id]; -unsigned pitch = fb_info->stride; limit =intel_gen (devid) <6 ?500 :5000 ; - dummy_bo =drm_intel_bo_alloc (bufmgr,"dummy_bo" , fb_info->size,4096 ); -igt_assert (dummy_bo); - target_bo =gem_handle_to_libdrm_bo (bufmgr, drm_fd,"imported" , fb_info->gem_handle); -igt_assert (target_bo); + src_bo =drm_intel_bo_alloc (bufmgr,"dummy_bo" ,2048 *2048 *4 ,4096 ); +igt_assert (src_bo); + + dst_bo =drm_intel_bo_alloc (bufmgr,"dummy_bo" ,2048 *2048 *4 ,4096 ); +igt_assert (dst_bo); + + fb_bo =gem_handle_to_libdrm_bo (bufmgr, drm_fd,"imported" , fb_info->gem_handle); +igt_assert (fb_bo);for (i =0 ; i < limit; i++) { -blit_copy (dummy_bo, target_bo, - o->fb_width, o->fb_height, - pitch, pitch); +blit_copy (dst_bo, src_bo, +2048 ,2048 , +2048 *4 ,2048 *4 ); -swap (dummy_bo, target_bo); +swap (src_bo, dst_bo); } +blit_copy (fb_bo, src_bo, +min (o->fb_width,2048 ),min (o->fb_height,2048 ), + fb_info->stride,2048 *4 );intel_batchbuffer_flush (batch); -drm_intel_bo_unreference (dummy_bo); -drm_intel_bo_unreference (target_bo); +drm_intel_bo_unreference (src_bo); +drm_intel_bo_unreference (dst_bo); +drm_intel_bo_unreference (fb_bo); }static void emit_fence_stress (struct test_output *o)
@@ -260,7 +267,7 @@ static void emit_dummy_load__rcs(struct test_output *o) {const struct igt_fb *fb_info = &o->fb_info[o->current_fb_id];igt_render_copyfunc_t copyfunc; -struct igt_buf sb[2 ], *src, *dst; +struct igt_buf sb[3 ], *src, *dst, *fb;int i, limit; copyfunc =igt_get_render_copyfunc (devid);
@@ -269,37 +276,51 @@ static void emit_dummy_load__rcs(struct test_output *o) limit =intel_gen (devid) <6 ?500 :5000 ; - sb[0 ].bo =drm_intel_bo_alloc (bufmgr,"dummy_bo" , fb_info->size,4096 ); + sb[0 ].bo =drm_intel_bo_alloc (bufmgr,"dummy_bo" ,2048 *2048 *4 ,4096 );igt_assert (sb[0 ].bo); sb[0 ].size = sb[0 ].bo->size; sb[0 ].tiling =I915_TILING_NONE ; sb[0 ].data =NULL ; sb[0 ].num_tiles = sb[0 ].bo->size; - sb[0 ].stride =4 * o->fb_width; + sb[0 ].stride =4 *2048 ; - sb[1 ].bo =gem_handle_to_libdrm_bo (bufmgr, drm_fd,"imported" , fb_info->gem_handle); + sb[1 ].bo =drm_intel_bo_alloc (bufmgr,"dummy_bo" ,2048 *2048 *4 ,4096 );igt_assert (sb[1 ].bo); sb[1 ].size = sb[1 ].bo->size; - sb[1 ].tiling = fb_info->tiling; + sb[1 ].tiling =I915_TILING_NONE ; sb[1 ].data =NULL ; sb[1 ].num_tiles = sb[1 ].bo->size; - sb[1 ].stride = fb_info->stride; + sb[1 ].stride =4 *2048 ; + + sb[2 ].bo =gem_handle_to_libdrm_bo (bufmgr, drm_fd,"imported" , fb_info->gem_handle); +igt_assert (sb[2 ].bo); + sb[2 ].size = sb[2 ].bo->size; + sb[2 ].tiling = fb_info->tiling; + sb[2 ].data =NULL ; + sb[2 ].num_tiles = sb[2 ].bo->size; + sb[2 ].stride = fb_info->stride; src = &sb[0 ]; dst = &sb[1 ]; + fb = &sb[2 ];for (i =0 ; i < limit; i++) {copyfunc (batch,NULL , src,0 ,0 , - o->fb_width, o->fb_height, +2048 ,2048 , dst,0 ,0 );swap (src, dst); } +copyfunc (batch,NULL , + src,0 ,0 , +min (o->fb_width,2048 ),min (o->fb_height,2048 ), + fb,0 ,0 );intel_batchbuffer_flush (batch);drm_intel_bo_unreference (sb[0 ].bo);drm_intel_bo_unreference (sb[1 ].bo); +drm_intel_bo_unreference (sb[2 ].bo); }static void dpms_off_other_outputs (struct test_output *o)
Signature · 6 lines
2.0.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/4 tests/kms_flip: Calibrate the dummy load delay in kms_flip
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Try to tune the dummy load to ~1 second. The calibration happens the first time dummy load is generated.
--- tests/kms_flip.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 11 deletions(-)
tests/kms_flip.c +70 -11
@@ -84,6 +84,9 @@#define DRM_CAP_TIMESTAMP_MONOTONIC 6#endif +#define USEC_PER_SEC 1000000L +#define NSEC_PER_SEC 1000000000L +drmModeRes *resources;int drm_fd;static drm_intel_bufmgr *bufmgr;
@@ -162,6 +165,34 @@ static unsigned long gettime_us(void)return ts.tv_sec *1000000 + ts.tv_nsec /1000 ; } +static int calibrate_dummy_load (struct test_output *o, +const char *ring_name, +int (*emit)(struct test_output *o,int limit,int timeout)) +{ +unsigned long start; +int ops =1 ; + + start =gettime_us (); + +do { +unsigned long diff; +int ret; + + ret =emit (o, ops,10 ); + diff =gettime_us () - start; + +if (ret || diff /USEC_PER_SEC >1 ) +break ; + + ops += ops; + }while (ops <100000 ); + +igt_debug ("%s dummy load calibrated: %d operations / second\n" , + ring_name, ops); + +return ops; +} +static void blit_copy (drm_intel_bo *dst,drm_intel_bo *src,unsigned int width,unsigned int height,unsigned int dst_pitch,unsigned int src_pitch)
@@ -187,14 +218,12 @@ static void blit_copy(drm_intel_bo *dst, drm_intel_bo *src, } } -static void emit_dummy_load__bcs (struct test_output *o) +static int _emit_dummy_load__bcs (struct test_output *o,int limit,int timeout) { -int i, limit; +int i, ret =0 ;drm_intel_bo *src_bo, *dst_bo, *fb_bo;struct igt_fb *fb_info = &o->fb_info[o->current_fb_id]; - limit =intel_gen (devid) <6 ?500 :5000 ; - src_bo =drm_intel_bo_alloc (bufmgr,"dummy_bo" ,2048 *2048 *4 ,4096 );igt_assert (src_bo);
@@ -216,9 +245,25 @@ static void emit_dummy_load__bcs(struct test_output *o) fb_info->stride, 2048*4);intel_batchbuffer_flush (batch); +if (timeout >0 ) + ret =drm_intel_gem_bo_wait (fb_bo, timeout *NSEC_PER_SEC ); +drm_intel_bo_unreference (src_bo);drm_intel_bo_unreference (dst_bo);drm_intel_bo_unreference (fb_bo); + +return ret; +} + +static void emit_dummy_load__bcs (struct test_output *o,int seconds) +{ +static int ops_per_sec; + +if (ops_per_sec ==0 ) + ops_per_sec =calibrate_dummy_load (o,"bcs" , + _emit_dummy_load__bcs); + +_emit_dummy_load__bcs (o, seconds * ops_per_sec,0 ); }static void emit_fence_stress (struct test_output *o)
@@ -263,18 +308,16 @@ static void emit_fence_stress(struct test_output *o)free (exec); } -static void emit_dummy_load__rcs (struct test_output *o) +static int _emit_dummy_load__rcs (struct test_output *o,int limit,int timeout) {const struct igt_fb *fb_info = &o->fb_info[o->current_fb_id];igt_render_copyfunc_t copyfunc;struct igt_buf sb[3 ], *src, *dst, *fb; -int i, limit; +int i, ret =0 ; copyfunc =igt_get_render_copyfunc (devid);if (copyfunc ==NULL ) -return emit_dummy_load__bcs (o); - - limit =intel_gen (devid) <6 ?500 :5000 ; +return _emit_dummy_load__bcs (o, limit, timeout); sb[0 ].bo =drm_intel_bo_alloc (bufmgr,"dummy_bo" ,2048 *2048 *4 ,4096 );igt_assert (sb[0 ].bo);
@@ -318,9 +361,25 @@ static void emit_dummy_load__rcs(struct test_output *o) fb, 0, 0);intel_batchbuffer_flush (batch); +if (timeout >0 ) + ret =drm_intel_gem_bo_wait (fb->bo, timeout *NSEC_PER_SEC ); +drm_intel_bo_unreference (sb[0 ].bo);drm_intel_bo_unreference (sb[1 ].bo);drm_intel_bo_unreference (sb[2 ].bo); + +return ret; +} + +static void emit_dummy_load__rcs (struct test_output *o,int seconds) +{ +static int ops_per_sec; + +if (ops_per_sec ==0 ) + ops_per_sec =calibrate_dummy_load (o,"rcs" , + _emit_dummy_load__rcs); + +_emit_dummy_load__bcs (o, seconds * ops_per_sec,0 ); }static void dpms_off_other_outputs (struct test_output *o)
@@ -820,10 +879,10 @@ static unsigned int run_test_step(struct test_output *o)dpms_off_other_outputs (o);if (o->flags &TEST_WITH_DUMMY_BCS ) -emit_dummy_load__bcs (o); +emit_dummy_load__bcs (o,1 );if (o->flags &TEST_WITH_DUMMY_RCS ) -emit_dummy_load__rcs (o); +emit_dummy_load__rcs (o,1 );if (!(o->flags &TEST_SINGLE_BUFFER )) o->current_fb_id = !o->current_fb_id;
Signature · 6 lines
2.0.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 3/4 tests/kms_flip: Calibrate the dummy load delay in kms_flip
From: Ville Syrjälä <[email protected]>
Try to tune the dummy load to ~1 second. The calibration happens the first time dummy load is generated.
v2: Actually do the number of ops intended and
calibrate to 1 second and not 2
--- tests/kms_flip.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 11 deletions(-)
tests/kms_flip.c +70 -11
@@ -84,6 +84,9 @@#define DRM_CAP_TIMESTAMP_MONOTONIC 6#endif +#define USEC_PER_SEC 1000000L +#define NSEC_PER_SEC 1000000000L +drmModeRes *resources;int drm_fd;static drm_intel_bufmgr *bufmgr;
@@ -162,6 +165,34 @@ static unsigned long gettime_us(void)return ts.tv_sec *1000000 + ts.tv_nsec /1000 ; } +static int calibrate_dummy_load (struct test_output *o, +const char *ring_name, +int (*emit)(struct test_output *o,int limit,int timeout)) +{ +unsigned long start; +int ops =1 ; + + start =gettime_us (); + +do { +unsigned long diff; +int ret; + + ret =emit (o, (ops+1 )/2 ,10 ); + diff =gettime_us () - start; + +if (ret || diff /USEC_PER_SEC >=1 ) +break ; + + ops += ops; + }while (ops <100000 ); + +igt_debug ("%s dummy load calibrated: %d operations / second\n" , + ring_name, ops); + +return ops; +} +static void blit_copy (drm_intel_bo *dst,drm_intel_bo *src,unsigned int width,unsigned int height,unsigned int dst_pitch,unsigned int src_pitch)
@@ -187,14 +218,12 @@ static void blit_copy(drm_intel_bo *dst, drm_intel_bo *src, } } -static void emit_dummy_load__bcs (struct test_output *o) +static int _emit_dummy_load__bcs (struct test_output *o,int limit,int timeout) { -int i, limit; +int i, ret =0 ;drm_intel_bo *src_bo, *dst_bo, *fb_bo;struct igt_fb *fb_info = &o->fb_info[o->current_fb_id]; - limit =intel_gen (devid) <6 ?500 :5000 ; - src_bo =drm_intel_bo_alloc (bufmgr,"dummy_bo" ,2048 *2048 *4 ,4096 );igt_assert (src_bo);
@@ -216,9 +245,25 @@ static void emit_dummy_load__bcs(struct test_output *o) fb_info->stride, 2048*4);intel_batchbuffer_flush (batch); +if (timeout >0 ) + ret =drm_intel_gem_bo_wait (fb_bo, timeout *NSEC_PER_SEC ); +drm_intel_bo_unreference (src_bo);drm_intel_bo_unreference (dst_bo);drm_intel_bo_unreference (fb_bo); + +return ret; +} + +static void emit_dummy_load__bcs (struct test_output *o,int seconds) +{ +static int ops_per_sec; + +if (ops_per_sec ==0 ) + ops_per_sec =calibrate_dummy_load (o,"bcs" , + _emit_dummy_load__bcs); + +_emit_dummy_load__bcs (o, seconds * ops_per_sec,0 ); }static void emit_fence_stress (struct test_output *o)
@@ -263,18 +308,16 @@ static void emit_fence_stress(struct test_output *o)free (exec); } -static void emit_dummy_load__rcs (struct test_output *o) +static int _emit_dummy_load__rcs (struct test_output *o,int limit,int timeout) {const struct igt_fb *fb_info = &o->fb_info[o->current_fb_id];igt_render_copyfunc_t copyfunc;struct igt_buf sb[3 ], *src, *dst, *fb; -int i, limit; +int i, ret =0 ; copyfunc =igt_get_render_copyfunc (devid);if (copyfunc ==NULL ) -return emit_dummy_load__bcs (o); - - limit =intel_gen (devid) <6 ?500 :5000 ; +return _emit_dummy_load__bcs (o, limit, timeout); sb[0 ].bo =drm_intel_bo_alloc (bufmgr,"dummy_bo" ,2048 *2048 *4 ,4096 );igt_assert (sb[0 ].bo);
@@ -318,9 +361,25 @@ static void emit_dummy_load__rcs(struct test_output *o) fb, 0, 0);intel_batchbuffer_flush (batch); +if (timeout >0 ) + ret =drm_intel_gem_bo_wait (fb->bo, timeout *NSEC_PER_SEC ); +drm_intel_bo_unreference (sb[0 ].bo);drm_intel_bo_unreference (sb[1 ].bo);drm_intel_bo_unreference (sb[2 ].bo); + +return ret; +} + +static void emit_dummy_load__rcs (struct test_output *o,int seconds) +{ +static int ops_per_sec; + +if (ops_per_sec ==0 ) + ops_per_sec =calibrate_dummy_load (o,"rcs" , + _emit_dummy_load__rcs); + +_emit_dummy_load__bcs (o, seconds * ops_per_sec,0 ); }static void dpms_off_other_outputs (struct test_output *o)
@@ -820,10 +879,10 @@ static unsigned int run_test_step(struct test_output *o)dpms_off_other_outputs (o);if (o->flags &TEST_WITH_DUMMY_BCS ) -emit_dummy_load__bcs (o); +emit_dummy_load__bcs (o,1 );if (o->flags &TEST_WITH_DUMMY_RCS ) -emit_dummy_load__rcs (o); +emit_dummy_load__rcs (o,1 );if (!(o->flags &TEST_SINGLE_BUFFER )) o->current_fb_id = !o->current_fb_id;
Signature · 6 lines
2.0.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/4 tests/kms_flip: Target the back buffer with the dummy load
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Aim the dummy load to the current back buffer instead if the front buffer. Assuming the idea is to get the next flip to be stuck behind the dummy load?
--- tests/kms_flip.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tests/kms_flip.c +3 -3
@@ -878,15 +878,15 @@ static unsigned int run_test_step(struct test_output *o)if (o->flags &TEST_DPMS_OFF_OTHERS )dpms_off_other_outputs (o); +if (!(o->flags &TEST_SINGLE_BUFFER )) + o->current_fb_id = !o->current_fb_id; +if (o->flags &TEST_WITH_DUMMY_BCS )emit_dummy_load__bcs (o,1 );if (o->flags &TEST_WITH_DUMMY_RCS )emit_dummy_load__rcs (o,1 ); -if (!(o->flags &TEST_SINGLE_BUFFER )) - o->current_fb_id = !o->current_fb_id; -if (o->flags &TEST_FB_RECREATE )recreate_fb (o); new_fb_id = o->fb_ids[o->current_fb_id];
Signature · 6 lines
2.0.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 4/4] tests/kms_flip: Target the back buffer with the dummy load
Quoted 5 lines · On Fri, Dec 05, 2014 at 05:13:17PM +0200, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Aim the dummy load to the current back buffer instead if the front buffer. Assuming the idea is to get the next flip to be stuck behind the dummy load?
Yeah that makes more sense. Ack on the entire series. I still think it'd be useful to extract a solid dummy load tuner into lib, but that's a bit more work really. I'll do an igt jira for it so we don't forget. -Daniel
Quoted 36 lines
Signed-off-by Ville Syrjälä <[email protected]>--- tests/kms_flip.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)tests/kms_flip.c +3
-3@@ -878,15 +878,15 @@ static unsigned int run_test_step(struct test_output *o)if (o->flags &TEST_DPMS_OFF_OTHERS )dpms_off_other_outputs (o); +if (!(o->flags &TEST_SINGLE_BUFFER )) + o->current_fb_id = !o->current_fb_id; +if (o->flags &TEST_WITH_DUMMY_BCS )emit_dummy_load__bcs (o,1 );if (o->flags &TEST_WITH_DUMMY_RCS )emit_dummy_load__rcs (o,1 ); -if (!(o->flags &TEST_SINGLE_BUFFER )) - o->current_fb_id = !o->current_fb_id; -if (o->flags &TEST_FB_RECREATE )recreate_fb (o); new_fb_id = o->fb_ids[o->current_fb_id];Signature · 6 lines
2.0.4 _______________________________________________ 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