]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
drm/i915: Allow execbuffer to use the first object as the batch
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 16 Jun 2017 14:05:23 +0000 (15:05 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 16 Jun 2017 15:54:05 +0000 (16:54 +0100)
Currently, the last object in the execlist is the always the batch.
However, when building the batch buffer we often know the batch object
first and if we can use the first slot in the execlist we can emit
relocation instructions relative to it immediately and avoid a separate
pass to adjust the relocations to point to the last execlist slot.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/i915_gem_execbuffer.c
include/uapi/drm/i915_drm.h

index e33a2ed9244c8c36a93208c699b74f2a6f03076d..3c2af70034cf9994118472ec5c8dd24f4680e5f4 100644 (file)
@@ -367,6 +367,7 @@ static int i915_getparam(struct drm_device *dev, void *data,
        case I915_PARAM_HAS_EXEC_ASYNC:
        case I915_PARAM_HAS_EXEC_FENCE:
        case I915_PARAM_HAS_EXEC_CAPTURE:
+       case I915_PARAM_HAS_EXEC_BATCH_FIRST:
                /* For the time being all of these are always true;
                 * if some supported hardware does not have one of these
                 * features this value needs to be provided from
index f4b02ef3987fee722032e7f7b397326d8e06510c..e262133a7cf571cbdd3d5a5eee57b675d1b1b6ad 100644 (file)
@@ -645,7 +645,10 @@ ht_needs_resize(const struct i915_gem_context_vma_lut *lut)
 
 static unsigned int eb_batch_index(const struct i915_execbuffer *eb)
 {
-       return eb->buffer_count - 1;
+       if (eb->args->flags & I915_EXEC_BATCH_FIRST)
+               return 0;
+       else
+               return eb->buffer_count - 1;
 }
 
 static int eb_select_context(struct i915_execbuffer *eb)
index 15bc9f78ba4d504bfb8fcf4bdd181ccbe508c0a2..7ccbd6a2bbe07b387b43bb8b4ac5eba0f52d1cd0 100644 (file)
@@ -418,7 +418,6 @@ typedef struct drm_i915_irq_wait {
  */
 #define I915_PARAM_HAS_EXEC_CAPTURE     45
 
-/* Query the mask of slices available for this system */
 #define I915_PARAM_SLICE_MASK           46
 
 /* Assuming it's uniform for each slice, this queries the mask of subslices
@@ -426,6 +425,12 @@ typedef struct drm_i915_irq_wait {
  */
 #define I915_PARAM_SUBSLICE_MASK        47
 
+/*
+ * Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying the batch buffer
+ * as the first execobject as opposed to the last. See I915_EXEC_BATCH_FIRST.
+ */
+#define I915_PARAM_HAS_EXEC_BATCH_FIRST         48
+
 typedef struct drm_i915_getparam {
        __s32 param;
        /*
@@ -912,7 +917,17 @@ struct drm_i915_gem_execbuffer2 {
  */
 #define I915_EXEC_FENCE_OUT            (1<<17)
 
-#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_OUT<<1))
+/*
+ * Traditionally the execbuf ioctl has only considered the final element in
+ * the execobject[] to be the executable batch. Often though, the client
+ * will known the batch object prior to construction and being able to place
+ * it into the execobject[] array first can simplify the relocation tracking.
+ * Setting I915_EXEC_BATCH_FIRST tells execbuf to use element 0 of the
+ * execobject[] as the * batch instead (the default is to use the last
+ * element).
+ */
+#define I915_EXEC_BATCH_FIRST          (1<<18)
+#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_BATCH_FIRST<<1))
 
 #define I915_EXEC_CONTEXT_ID_MASK      (0xffffffff)
 #define i915_execbuffer2_set_context_id(eb2, context) \