Skip to contentSkip to conversation

gem_ring_sync_loop: check the rings supported by the kernel

PATCH New Xiang, Haihao 1 participant 2 messages Nov 15, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 gem_ring_sync_loop: check the rings supported by the kernel

From: "Xiang, Haihao" <[email protected]>

---
 tests/gem_ring_sync_loop.c |   37 ++++++++++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)
tests/gem_ring_sync_loop.c +34 -3
index b689bcd..2875cf3 100644
@@ -55,15 +55,46 @@ 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;
+
+skip:	
+	return num_rings;
+}
+
 static void
-store_dword_loop(void)
+store_dword_loop(int fd)
 {
 	int i;
+	int num_rings = get_num_rings(fd);
 
 	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);
@@ -127,7 +158,7 @@ int main(int argc, char **argv)
 		exit(-1);
 	}
 
-	store_dword_loop();
+	store_dword_loop(fd);
 
 	drm_intel_bo_unreference(target_buffer);
 	intel_batchbuffer_free(batch);
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 2/2 gem_ring_sync_loop: test the new ring

From: "Xiang, Haihao" <[email protected]>

The code is surround by a #ifdef...#endif to avoid to break compiling against the current libdrm release

---
 tests/gem_ring_sync_loop.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
tests/gem_ring_sync_loop.c +12 -0
index 2875cf3..955bf34 100644
@@ -81,6 +81,18 @@ get_num_rings(int fd)
 	else
 		goto skip;
 
+#ifdef I915_PARAM_HAS_VEBOX /* remove it once the upstream libdrm support VEBOX */
+
+	gp.param = I915_PARAM_HAS_VEBOX;
+	ret = drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+
+	if ((ret == 0) & (*gp.value > 0))
+		num_rings++;
+	else
+		goto skip;
+
+#endif
+
 skip:	
 	return num_rings;
 }
Signature · 1 line
1.7.9.5