[PATCH 3/3] intel: wait render timeout implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



int drm_intel_gem_bo_wait(drm_intel_bo *bo, uint64_t timeout_ns)

This should bump the libdrm version. We're waiting for context support
so we can do both features in one bump.

v2: don't return remaining timeout amount
use get param and fallback for older kernels

Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
 intel/intel_bufmgr.h     |    1 +
 intel/intel_bufmgr_gem.c |   29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
index c197abc..10ccc25 100644
--- a/intel/intel_bufmgr.h
+++ b/intel/intel_bufmgr.h
@@ -184,6 +184,7 @@ int drm_intel_get_pipe_from_crtc_id(drm_intel_bufmgr *bufmgr, int crtc_id);
 
 int drm_intel_get_aperture_sizes(int fd, size_t *mappable, size_t *total);
 int drm_intel_bufmgr_gem_get_devid(drm_intel_bufmgr *bufmgr);
+int drm_intel_gem_bo_wait(drm_intel_bo *bo, uint64_t timeout_ns);
 
 /* drm_intel_bufmgr_fake.c */
 drm_intel_bufmgr *drm_intel_bufmgr_fake_init(int fd,
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index b776d2f..78aec08 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -1479,6 +1479,35 @@ drm_intel_gem_bo_wait_rendering(drm_intel_bo *bo)
 }
 
 /**
+ * Same as drm_intel_gem_bo_wait_rendering except a timeout parameter allows the
+ * operation to give up after a certain amount of time.
+ *
+ * A 0 return value implies that the wait was successful. Otherwise some
+ * negative return value describes the error.
+ */
+int drm_intel_gem_bo_wait(drm_intel_bo *bo, uint64_t timeout_ns)
+{
+	drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr;
+	drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
+	struct drm_i915_gem_wait wait;
+	int ret, val = 0;
+	struct drm_i915_getparam gp = {I915_PARAM_HAS_WAIT_TIMEOUT, &val};
+
+	ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	if (!ret || !val) {
+		DBG("Wait timeout not supported by kernel. "
+		    "Falling back to unconstrained wait\n");
+		drm_intel_gem_bo_wait_rendering(bo);
+		return 0;
+	}
+
+	wait.bo_handle = bo_gem->gem_handle;
+	wait.timeout_ns = timeout_ns;
+	wait.flags = 0;
+	return drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_WAIT, &wait);
+}
+
+/**
  * Sets the object to the GTT read and possibly write domain, used by the X
  * 2D driver in the absence of kernel support to do drm_intel_gem_bo_map_gtt().
  *
-- 
1.7.10.3



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux