From: Ben Widawsky <ben@bwidawsk.net>
To: intel-gfx@lists.freedesktop.org
Cc: Ben Widawsky <ben@bwidawsk.net>
Subject: [PATCH] intel: add a timed wait function
Date: Sun, 29 Apr 2012 15:22:35 -0700 [thread overview]
Message-ID: <1335738156-27706-7-git-send-email-ben@bwidawsk.net> (raw)
In-Reply-To: <1335738156-27706-1-git-send-email-ben@bwidawsk.net>
drm_intel_gem_bo_wait(bo, timeout in ns)
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
include/drm/i915_drm.h | 8 ++++++++
intel/intel_bufmgr.h | 1 +
intel/intel_bufmgr_gem.c | 25 +++++++++++++++++++++++++
3 files changed, 34 insertions(+)
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index af3ce17..f71750d 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -191,6 +191,7 @@ typedef struct _drm_i915_sarea {
#define DRM_I915_GEM_EXECBUFFER2 0x29
#define DRM_I915_GET_SPRITE_COLORKEY 0x2a
#define DRM_I915_SET_SPRITE_COLORKEY 0x2b
+#define DRM_I915_GEM_WAIT 0x2c
#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
@@ -234,6 +235,7 @@ typedef struct _drm_i915_sarea {
#define DRM_IOCTL_I915_OVERLAY_ATTRS DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_OVERLAY_ATTRS, struct drm_intel_overlay_attrs)
#define DRM_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
#define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
+#define DRM_IOCTL_I915_GEM_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_WAIT, struct drm_i915_gem_wait)
/* Allow drivers to submit batchbuffers directly to hardware, relying
* on the security mechanisms provided by hardware.
@@ -876,4 +878,10 @@ struct drm_intel_sprite_colorkey {
__u32 flags;
};
+struct drm_i915_gem_wait {
+ __u32 bo_handle;
+ __u32 flags;
+ __u64 timeout_ns;
+};
+
#endif /* _I915_DRM_H_ */
diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
index 45389e1..24a8002 100644
--- a/intel/intel_bufmgr.h
+++ b/intel/intel_bufmgr.h
@@ -174,6 +174,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 3c91090..bc80150 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -1472,6 +1472,31 @@ drm_intel_gem_bo_wait_rendering(drm_intel_bo *bo)
drm_intel_gem_bo_start_gtt_access(bo, 1);
}
+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;
+
+ if (!timeout_ns)
+ return -EINVAL;
+
+ wait.bo_handle = bo_gem->gem_handle;
+ wait.timeout_ns = *timeout_ns;
+ wait.flags = 0;
+ ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_WAIT, &wait);
+ if (ret)
+ return ret;
+
+ if (wait.timeout_ns == 0)
+ DBG("Wait timed out on buffer %d\n", bo_gem->gem_handle);
+
+ *timeout_ns = wait.timeout_ns;
+
+ return ret;
+}
+
/**
* 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
next prev parent reply other threads:[~2012-04-29 22:24 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-29 22:22 [PATCH 0/5 v3] timed BO wait Ben Widawsky
2012-04-29 22:22 ` [PATCH 1/5 v2] drm/i915: timeout parameter for seqno wait Ben Widawsky
2012-05-01 1:39 ` [PATCH 1/5] " Ben Widawsky
2012-05-02 21:47 ` Daniel Vetter
2012-05-03 4:32 ` Ben Widawsky
2012-04-29 22:22 ` [PATCH 2/5] drm/i915: make waiting trace events more useful Ben Widawsky
2012-05-01 1:40 ` Ben Widawsky
2012-05-02 21:12 ` Daniel Vetter
2012-05-02 21:22 ` Chris Wilson
2012-05-02 21:36 ` Daniel Vetter
2012-05-02 21:56 ` Daniel Vetter
2012-04-29 22:22 ` [PATCH 3/5 v2] drm/i915: extract some common olr+wedge code Ben Widawsky
2012-05-02 21:08 ` Daniel Vetter
2012-04-29 22:22 ` [PATCH 4/5 v3] drm/i915: wait render timeout ioctl Ben Widawsky
2012-05-01 1:41 ` [PATCH 4/5] " Ben Widawsky
2012-05-01 17:19 ` Eric Anholt
2012-05-01 18:08 ` Ben Widawsky
2012-05-02 21:26 ` Daniel Vetter
2012-04-29 22:22 ` [PATCH 5/5] drm/i915: s/i915_wait_reqest/i915_wait_seqno/g Ben Widawsky
2012-04-29 22:22 ` Ben Widawsky [this message]
2012-04-29 22:22 ` [PATCH] tests/wait render timeout test Ben Widawsky
2012-05-03 5:49 ` [PATCH 0/5 v3] timed BO wait Ben Widawsky
-- strict thread matches above, loose matches on Subject: below --
2012-05-11 20:54 [PATCH 1/4 v4] drm/i915: timeout parameter for seqno wait Ben Widawsky
2012-05-11 20:54 ` [PATCH] intel: add a timed wait function 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=1335738156-27706-7-git-send-email-ben@bwidawsk.net \
--to=ben@bwidawsk.net \
--cc=intel-gfx@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