i-g-t: check kernel enable rings or not Signed-off-by: Zhong Li <[email protected]> 1. add functions check kernel enable a ring or not. 2. add function gem_get_num_rings() to check how many rings kernel has enable. 3. gem_ring_sync_loop.c will call gem_get_num_rings() directly instead of original static fucntion get_number_rings().
PATCH 1/2 i-g-t: check kernel enable rings or not Signed-off-by: Zhong Li <[email protected]> 1. add functions check kernel enable a ring or not. 2. add function gem_get_num_rings() to check how many rings kernel has enable. 3. gem_ring_sync_loop.c will call gem_get_num_rings() directly instead of original static fucntion get_number_rings().
--- lib/drmtest.c | 61 ++++++++++++++++++++++++++++++++++++++------ lib/drmtest.h | 6 ++++- tests/gem_ring_sync_loop.c | 38 +-------------------------- 3 files changed, 59 insertions(+), 46 deletions(-)
lib/drmtest.c +53 -8
@@ -270,19 +270,64 @@ void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride)assert (st.tiling_mode == tiling); } +bool gem_has_enable_ring (int fd,int param) +{ +drm_i915_getparam_t gp; +int ret, tmp; +memset (&gp,0 ,sizeof (gp)); + + gp.value = &tmp; + gp.param = param; + + ret =drmIoctl (fd,DRM_IOCTL_I915_GETPARAM , &gp); + +if ((ret ==0 ) && (*gp.value >0 )) +return true; +else +return false; +} + +bool gem_has_bsd (int fd) +{ + +return gem_has_enable_ring (fd,I915_PARAM_HAS_BSD ); +} + +bool gem_has_blt (int fd) +{ + +return gem_has_enable_ring (fd,I915_PARAM_HAS_BLT ); +} +#define LOCAL_I915_PARAM_HAS_VEBOX 22 -int gem_has_vebox (int fd) +bool gem_has_vebox (int fd) { -struct drm_i915_getparam gp; -int val; - gp.param =LOCAL_I915_PARAM_HAS_VEBOX ; - gp.value = &val; +return gem_has_enable_ring (fd,LOCAL_I915_PARAM_HAS_VEBOX ); +} + +int gem_get_num_rings (int fd) +{ +int num_rings =1 ;/* render ring is always available */ + +if (gem_has_bsd (fd)) + num_rings++; +else + goto skip; + + if (gem_has_blt(fd) + num_rings++; +else + goto skip; + +if (gem_has_vebox (fd)) + num_rings++; +else + goto skip; -if (ioctl (fd,DRM_IOCTL_I915_GETPARAM , &gp,sizeof (gp))) -return 0 ; -return val !=0 ; +skip: +return num_rings; }struct local_drm_i915_gem_cacheing {
lib/drmtest.h +5 -1
@@ -47,8 +47,12 @@ int drm_open_any_master(void);void gem_quiescent_gpu (int fd);/* ioctl wrappers and similar stuff for bare metal testing */ -int gem_has_vebox (int fd);void gem_set_tiling (int fd,uint32_t handle,int tiling,int stride); +bool gem_has_enable_ring (int fd,int param); +bool gem_has_bsd (int fd); +bool gem_has_bls (int fd); +bool gem_has_vebox (int fd); +int gem_get_num_rings (int fd);int gem_has_cacheing (int fd);void gem_set_cacheing (int fd,uint32_t handle,int cacheing);int gem_get_cacheing (int fd,uint32_t handle);
tests/gem_ring_sync_loop.c +1 -37
@@ -55,47 +55,11 @@ static drm_intel_bo *target_buffer;#define MI_COND_BATCH_BUFFER_END (0x36<<23 | 1)#define MI_DO_COMPARE (1<<21) -static int -get_num_rings (int fd) -{ -int num_rings =1 ;/* render ring is always available */ -drm_i915_getparam_t gp; -int ret, tmp; - -memset (&gp,0 ,sizeof (gp)); - gp.value = &tmp; - - gp.param =I915_PARAM_HAS_BSD ; - ret =drmIoctl (fd,DRM_IOCTL_I915_GETPARAM , &gp); - -if ((ret ==0 ) && (*gp.value >0 )) - num_rings++; -else - goto skip; - - gp.param =I915_PARAM_HAS_BLT ; - ret =drmIoctl (fd,DRM_IOCTL_I915_GETPARAM , &gp); - -if ((ret ==0 ) && (*gp.value >0 )) - num_rings++; -else - goto skip; - -if (gem_has_vebox (fd)) - num_rings++; -else - goto skip; - - -skip: -return num_rings; -} -static void store_dword_loop (int fd) {int i; -int num_rings =get_num_rings (fd); +int num_rings =gem_get_num_rings (fd);srandom (0xdeadbeef );
Signature · 1 line
1.7.9.5
PATCH 2/2 i-g-t: gem_dummy_reloc_loop.c: add vebox test case Signed-off-by: Zhong Li <[email protected]>
--- tests/gem_dummy_reloc_loop.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
tests/gem_dummy_reloc_loop.c +17 -4
@@ -42,6 +42,8 @@#include "intel_gpu_tools.h" #include "i830_reg.h" +#define LOCACL_I915_EXEC_VEBOX (4<<0) +static drm_intel_bufmgr *bufmgr;struct intel_batchbuffer *batch;static drm_intel_bo *target_buffer;
@@ -88,14 +90,14 @@ dummy_reloc_loop(int ring) }static void -dummy_reloc_loop_random_ring (void ) +dummy_reloc_loop_random_ring (int fd,int num_rings) {int i;srandom (0xdeadbeef );for (i =0 ; i <0x100000 ; i++) { -int ring =random () %3 +1 ; +int ring =random () % num_rings +1 ;if (ring ==I915_EXEC_RENDER ) {BEGIN_BATCH (4 );
@@ -126,11 +128,13 @@ int main(int argc, char **argv) {int fd;int devid; +int num_rings =1 ;/*render ring is alwyas available*/ drmtest_subtest_init (argc, argv); fd =drm_open_any (); devid =intel_get_drm_devid (fd); + num_rings =gem_get_num_rings (fd);if (!HAS_BLT_RING (devid)) {fprintf (stderr,"not (yet) implemented for pre-snb\n" );return 77 ;
@@ -179,11 +183,20 @@ int main(int argc, char **argv) } } +if (drmtest_run_subtest ("vebox" )) { +if (gem_has_vebox (fd)) { +sleep (2 ); +printf ("running dummy loop on vebox\n" ); +dummy_reloc_loop (LOCACL_I915_EXEC_VEBOX ); +printf ("dummy loop run on vebox completed\n" ); + } + } +if (drmtest_run_subtest ("mixed" )) { -if (HAS_BLT_RING (devid) &&HAS_BSD_RING (devid)) { +if (num_rings >1 ) {sleep (2 );printf ("running dummy loop on random rings\n" ); -dummy_reloc_loop_random_ring (); +dummy_reloc_loop_random_ring (fd, num_rings);printf ("dummy loop run on random rings completed\n" ); } }
Signature · 1 line
1.7.9.5
Re: [PATCH 2/2]i-g-t: gem_dummy_reloc_loop.c: add vebox test case Signed-off-by: Zhong Li <[email protected]>
I made a mistake for the patch subject. I will send a new series of patch. Please ignore this patch.
-----Original Message-----
From: Li, Zhong
Sent: Friday, May 03, 2013 2:26 PM
To: [email protected]
Cc: Li, Zhong; Xiang, Haihao; Li, Jocelyn; Vetter, Daniel; [email protected]
Subject: [Intel-gfx][PATCH 2/2]i-g-t: gem_dummy_reloc_loop.c: add vebox test case Signed-off-by: Zhong Li <[email protected]>
--- tests/gem_dummy_reloc_loop.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
tests/gem_dummy_reloc_loop.c +17 -4
@@ -42,6 +42,8 @@#include "intel_gpu_tools.h" #include "i830_reg.h" +#define LOCACL_I915_EXEC_VEBOX (4<<0) +static drm_intel_bufmgr *bufmgr;struct intel_batchbuffer *batch;static drm_intel_bo *target_buffer;
@@ -88,14 +90,14 @@ dummy_reloc_loop(int ring) }static void -dummy_reloc_loop_random_ring (void ) +dummy_reloc_loop_random_ring (int fd,int num_rings) {int i;srandom (0xdeadbeef );for (i =0 ; i <0x100000 ; i++) { -int ring =random () %3 +1 ; +int ring =random () % num_rings +1 ;if (ring ==I915_EXEC_RENDER ) {BEGIN_BATCH (4 );
@@ -126,11 +128,13 @@ int main(int argc, char **argv) {int fd;int devid; +int num_rings =1 ;/*render ring is alwyas available*/ drmtest_subtest_init (argc, argv); fd =drm_open_any (); devid =intel_get_drm_devid (fd); + num_rings =gem_get_num_rings (fd);if (!HAS_BLT_RING (devid)) {fprintf (stderr,"not (yet) implemented for pre-snb\n" );return 77 ;
@@ -179,11 +183,20 @@ int main(int argc, char **argv) } } +if (drmtest_run_subtest ("vebox" )) { +if (gem_has_vebox (fd)) { +sleep (2 ); +printf ("running dummy loop on vebox\n" ); +dummy_reloc_loop (LOCACL_I915_EXEC_VEBOX ); +printf ("dummy loop run on vebox completed\n" ); + } + } +if (drmtest_run_subtest ("mixed" )) { -if (HAS_BLT_RING (devid) &&HAS_BSD_RING (devid)) { +if (num_rings >1 ) {sleep (2 );printf ("running dummy loop on random rings\n" ); -dummy_reloc_loop_random_ring (); +dummy_reloc_loop_random_ring (fd, num_rings);printf ("dummy loop run on random rings completed\n" ); } }
--
1.7.9.5