summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/drm/i915_drm.h12
-rw-r--r--intel/intel_bufmgr.c43
-rw-r--r--intel/intel_bufmgr.h9
-rw-r--r--intel/intel_bufmgr_gem.c44
-rw-r--r--intel/intel_bufmgr_priv.h5
5 files changed, 99 insertions, 14 deletions
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index 8d9f06360942..d2222debb6cf 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -250,7 +250,7 @@ typedef struct _drm_i915_sarea {
#define DRM_IOCTL_I915_HWS_ADDR DRM_IOW(DRM_COMMAND_BASE + DRM_I915_HWS_ADDR, struct drm_i915_gem_init)
#define DRM_IOCTL_I915_GEM_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_INIT, struct drm_i915_gem_init)
#define DRM_IOCTL_I915_GEM_EXECBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER, struct drm_i915_gem_execbuffer)
-#define DRM_IOCTL_I915_GEM_EXECBUFFER2 DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
+#define DRM_IOCTL_I915_GEM_EXECBUFFER2 DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
#define DRM_IOCTL_I915_GEM_PIN DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_PIN, struct drm_i915_gem_pin)
#define DRM_IOCTL_I915_GEM_UNPIN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_UNPIN, struct drm_i915_gem_unpin)
#define DRM_IOCTL_I915_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_BUSY, struct drm_i915_gem_busy)
@@ -784,7 +784,15 @@ struct drm_i915_gem_execbuffer2 {
*/
#define I915_EXEC_RESOURCE_STREAMER (1<<15)
-#define __I915_EXEC_UNKNOWN_FLAGS -(I915_EXEC_RESOURCE_STREAMER<<1)
+/* Caller supplies a sync fence fd in the rsvd2 field.
+ * Wait for it to be signalled before starting the work */
+#define I915_EXEC_WAIT_FENCE (1<<16)
+
+/* Caller wants a sync fence fd for this execbuffer.
+ * It will be returned in rsvd2 */
+#define I915_EXEC_CREATE_FENCE (1<<17)
+
+#define __I915_EXEC_UNKNOWN_FLAGS -(I915_EXEC_CREATE_FENCE<<1)
#define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)
#define i915_execbuffer2_set_context_id(eb2, context) \
diff --git a/intel/intel_bufmgr.c b/intel/intel_bufmgr.c
index a285340039fe..93c580fe2266 100644
--- a/intel/intel_bufmgr.c
+++ b/intel/intel_bufmgr.c
@@ -153,7 +153,19 @@ int
drm_intel_bo_exec(drm_intel_bo *bo, int used,
drm_clip_rect_t * cliprects, int num_cliprects, int DR4)
{
- return bo->bufmgr->bo_exec(bo, used, cliprects, num_cliprects, DR4);
+ return bo->bufmgr->bo_exec(bo, used, cliprects, num_cliprects, DR4, -1, NULL);
+}
+
+int
+drm_intel_bo_fence_exec(drm_intel_bo *bo, int used,
+ drm_clip_rect_t * cliprects, int num_cliprects, int DR4,
+ int fence_in, int* fence_out)
+{
+ if (fence_out)
+ *fence_out = -1;
+
+ return bo->bufmgr->bo_exec(bo, used, cliprects, num_cliprects, DR4,
+ fence_in, fence_out);
}
int
@@ -164,13 +176,38 @@ drm_intel_bo_mrb_exec(drm_intel_bo *bo, int used,
if (bo->bufmgr->bo_mrb_exec)
return bo->bufmgr->bo_mrb_exec(bo, used,
cliprects, num_cliprects, DR4,
- rings);
+ rings, -1, NULL);
+
+ switch (rings) {
+ case I915_EXEC_DEFAULT:
+ case I915_EXEC_RENDER:
+ return bo->bufmgr->bo_exec(bo, used,
+ cliprects, num_cliprects, DR4,
+ -1, NULL);
+ default:
+ return -ENODEV;
+ }
+}
+
+int
+drm_intel_bo_mrb_fence_exec(drm_intel_bo *bo, int used,
+ drm_clip_rect_t *cliprects, int num_cliprects, int DR4,
+ unsigned int rings, int fence_in, int* fence_out)
+{
+ if (fence_out)
+ *fence_out = -1;
+
+ if (bo->bufmgr->bo_mrb_exec)
+ return bo->bufmgr->bo_mrb_exec(bo, used,
+ cliprects, num_cliprects, DR4,
+ rings, fence_in, fence_out);
switch (rings) {
case I915_EXEC_DEFAULT:
case I915_EXEC_RENDER:
return bo->bufmgr->bo_exec(bo, used,
- cliprects, num_cliprects, DR4);
+ cliprects, num_cliprects, DR4,
+ fence_in, fence_out);
default:
return -ENODEV;
}
diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
index 49d41256fd67..5c819665030d 100644
--- a/intel/intel_bufmgr.h
+++ b/intel/intel_bufmgr.h
@@ -143,9 +143,15 @@ void drm_intel_bufmgr_set_debug(drm_intel_bufmgr *bufmgr, int enable_debug);
void drm_intel_bufmgr_destroy(drm_intel_bufmgr *bufmgr);
int drm_intel_bo_exec(drm_intel_bo *bo, int used,
struct drm_clip_rect *cliprects, int num_cliprects, int DR4);
+int drm_intel_bo_fence_exec(drm_intel_bo *bo, int used,
+ struct drm_clip_rect *cliprects, int num_cliprects, int DR4,
+ int fence_in, int *fence_out);
int drm_intel_bo_mrb_exec(drm_intel_bo *bo, int used,
struct drm_clip_rect *cliprects, int num_cliprects, int DR4,
unsigned int flags);
+int drm_intel_bo_mrb_fence_exec(drm_intel_bo *bo, int used,
+ struct drm_clip_rect *cliprects, int num_cliprects, int DR4,
+ unsigned int flags, int fence_in, int *fence_out);
int drm_intel_bufmgr_check_aperture_space(drm_intel_bo ** bo_array, int count);
int drm_intel_bo_emit_reloc(drm_intel_bo *bo, uint32_t offset,
@@ -216,6 +222,9 @@ int drm_intel_gem_context_get_priority(drm_intel_context *ctx, int *priority);
int drm_intel_gem_context_set_priority(drm_intel_context *ctx, int priority);
int drm_intel_gem_bo_context_exec(drm_intel_bo *bo, drm_intel_context *ctx,
int used, unsigned int flags);
+int drm_intel_gem_bo_context_fence_exec(drm_intel_bo *bo, drm_intel_context *ctx,
+ int used, unsigned int flags,
+ int fence_in, int *fence_out);
int drm_intel_bo_gem_export_to_prime(drm_intel_bo *bo, int *prime_fd);
drm_intel_bo *drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr,
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index 591ccd5486e7..0ddb94db79c3 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -2335,7 +2335,7 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used,
static int
do_exec2(drm_intel_bo *bo, int used, drm_intel_context *ctx,
drm_clip_rect_t *cliprects, int num_cliprects, int DR4,
- unsigned int flags)
+ unsigned int flags, int fence_in, int *fence_out)
{
drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr;
struct drm_i915_gem_execbuffer2 execbuf;
@@ -2384,11 +2384,21 @@ do_exec2(drm_intel_bo *bo, int used, drm_intel_context *ctx,
execbuf.DR1 = 0;
execbuf.DR4 = DR4;
execbuf.flags = flags;
+
+ if (fence_in >= 0) {
+ execbuf.flags |= I915_EXEC_WAIT_FENCE;
+ execbuf.rsvd2 = fence_in;
+ } else
+ execbuf.rsvd2 = 0;
+
+ if (fence_out != NULL) {
+ execbuf.flags |= I915_EXEC_CREATE_FENCE;
+ }
+
if (ctx == NULL)
i915_execbuffer2_set_context_id(execbuf, 0);
else
i915_execbuffer2_set_context_id(execbuf, ctx->ctx_id);
- execbuf.rsvd2 = 0;
if (bufmgr_gem->no_exec)
goto skip_execution;
@@ -2408,6 +2418,15 @@ do_exec2(drm_intel_bo *bo, int used, drm_intel_context *ctx,
(unsigned int) bufmgr_gem->gtt_size);
}
}
+
+ if (fence_in >= 0) {
+ /* Ownership is transferred so close it */
+ close(fence_in);
+ }
+
+ if (fence_out != NULL)
+ *fence_out = (int) (execbuf.rsvd2 >> 32);
+
drm_intel_update_buffer_offsets2(bufmgr_gem);
skip_execution:
@@ -2432,26 +2451,37 @@ skip_execution:
static int
drm_intel_gem_bo_exec2(drm_intel_bo *bo, int used,
drm_clip_rect_t *cliprects, int num_cliprects,
- int DR4)
+ int DR4, int fence_in, int *fence_out)
{
return do_exec2(bo, used, NULL, cliprects, num_cliprects, DR4,
- I915_EXEC_RENDER);
+ I915_EXEC_RENDER, fence_in, fence_out);
}
static int
drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
drm_clip_rect_t *cliprects, int num_cliprects, int DR4,
- unsigned int flags)
+ unsigned int flags, int fence_in, int *fence_out)
{
return do_exec2(bo, used, NULL, cliprects, num_cliprects, DR4,
- flags);
+ flags, fence_in, fence_out);
}
int
drm_intel_gem_bo_context_exec(drm_intel_bo *bo, drm_intel_context *ctx,
int used, unsigned int flags)
{
- return do_exec2(bo, used, ctx, NULL, 0, 0, flags);
+ return do_exec2(bo, used, ctx, NULL, 0, 0, flags, -1, NULL);
+}
+
+int
+drm_intel_gem_bo_context_fence_exec(drm_intel_bo *bo, drm_intel_context *ctx,
+ int used, unsigned int flags,
+ int fence_in, int *fence_out)
+{
+ if (fence_out)
+ *fence_out = -1;
+
+ return do_exec2(bo, used, ctx, NULL, 0, 0, flags, fence_in, fence_out);
}
static int
diff --git a/intel/intel_bufmgr_priv.h b/intel/intel_bufmgr_priv.h
index 7e360a0b23d4..c50229ee55a1 100644
--- a/intel/intel_bufmgr_priv.h
+++ b/intel/intel_bufmgr_priv.h
@@ -197,14 +197,15 @@ struct _drm_intel_bufmgr {
/** Executes the command buffer pointed to by bo. */
int (*bo_exec) (drm_intel_bo *bo, int used,
drm_clip_rect_t *cliprects, int num_cliprects,
- int DR4);
+ int DR4, int fence_in, int *fence_out);
/** Executes the command buffer pointed to by bo on the selected
* ring buffer
*/
int (*bo_mrb_exec) (drm_intel_bo *bo, int used,
drm_clip_rect_t *cliprects, int num_cliprects,
- int DR4, unsigned flags);
+ int DR4, unsigned flags,
+ int fence_in, int *fence_out);
/**
* Pin a buffer to the aperture and fix the offset until unpinned