i-g-t: check kernel enable rings or not
PATCH 1/2 i-g-t: check kernel enable rings or not
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_blt (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
Quoted 5 lines · Zhong Li
Signed-off-by Zhong Li <[email protected]>1. add functions check kernel enable a ring or not.
2. add functiongem_get_num_rings()to check how many rings kernel has enable.
3.gem_ring_sync_loop.cwill callgem_get_num_rings()directly instead of original static fucntionget_number_rings().
Please wrap commit messages, and place the Signed-off-by at the bottom.
Quoted 21 lines
--- 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 +6
-0@@ -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)); +
lib/drmtest.c void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride) · line 288
Quoted 10 lines
lib/drmtest.c +10
-0+ 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; +}
Whitespace problems again. Again, please fix your editor, or whatever you must do.
Quoted 40 lines
lib/drmtest.c +32
-5+ +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))
lib/drmtest.c void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride) · line 330
Quoted 10 lines
lib/drmtest.c +5
-3+ num_rings++; + else + goto skip; -if (ioctl (fd,DRM_IOCTL_I915_GETPARAM , &gp,sizeof (gp))) -return 0 ; -return val !=0 ; +skip: +return num_rings;
I know you just copied this from Haihao's original code... the goto is a bit superfluous.
Quoted 77 lines
lib/drmtest.c +0
-0}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_blt (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
With the whitespace fix, I've merged this patch to master.
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center