public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ben Widawsky <ben@bwidawsk.net>
To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: mesa-dev@lists.freedesktop.org, Ben Widawsky <ben@bwidawsk.net>
Subject: [PATCH 3/3] intel: wait render timeout implementation
Date: Tue,  5 Jun 2012 11:58:13 -0700	[thread overview]
Message-ID: <1338922693-17532-3-git-send-email-ben@bwidawsk.net> (raw)
In-Reply-To: <1338922693-17532-1-git-send-email-ben@bwidawsk.net>

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@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

  parent reply	other threads:[~2012-06-05 18:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-05 18:58 [PATCH 1/3] intel: sanitize i915_drm.h Ben Widawsky
2012-06-05 18:58 ` [PATCH 2/3] intel: wait render header updates Ben Widawsky
2012-06-05 22:42   ` Ben Widawsky
2012-06-06 21:13     ` Ben Widawsky
2012-06-05 18:58 ` Ben Widawsky [this message]
2012-06-05 22:35   ` [PATCH 3/3] intel: wait render timeout implementation Ben Widawsky
2012-06-05 22:43   ` Ben Widawsky
2012-06-06  9:33     ` Daniel Vetter
2012-06-06 21:26       ` Ben Widawsky
2012-06-06 21:16 ` [PATCH 1/3] intel: sanitize i915_drm.h Ben Widawsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1338922693-17532-3-git-send-email-ben@bwidawsk.net \
    --to=ben@bwidawsk.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=mesa-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox