summaryrefslogtreecommitdiff
path: root/lib/drmtest.c
diff options
context:
space:
mode:
authorZhong Li <zhong.li@intel.com>2013-05-03 15:54:48 +0800
committerBen Widawsky <ben@bwidawsk.net>2013-05-03 17:39:14 -0700
commit8ddf84d1295925a831f4e37a33308aa7cb3c0e94 (patch)
tree2df2cc023e870282a1c5ae513eed8f07d2c5f98a /lib/drmtest.c
parent53d251ac23d8a3f5c4d0144794788a1423a5fa14 (diff)
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(). Signed-off-by: Zhong Li <zhong.li@intel.com> [Ben: Wrapped commit message + whitespace fixes] Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Diffstat (limited to 'lib/drmtest.c')
-rw-r--r--lib/drmtest.c61
1 files changed, 53 insertions, 8 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 2ddaff02..3fd6d7df 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -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 {