drm/i915/scheduler: Signal the arrival of a new request
authorChris Wilson <chris@chris-wilson.co.uk>
Mon, 14 Nov 2016 20:41:01 +0000 (20:41 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 14 Nov 2016 21:00:26 +0000 (21:00 +0000)
The start of the scheduler, add a hook into request submission for the
scheduler to see the arrival of new requests and prepare its runqueues.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161114204105.29171-6-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/i915_gem_request.c
drivers/gpu/drm/i915/intel_engine_cs.c
drivers/gpu/drm/i915/intel_ringbuffer.h
include/uapi/drm/i915_drm.h

index 847794d387d69c7fd0dd744916826bc3b1f0951e..874fe857a34554d0af983457701c8a2225516acb 100644 (file)
@@ -323,6 +323,10 @@ static int i915_getparam(struct drm_device *dev, void *data,
                 */
                value = i915_gem_mmap_gtt_version();
                break;
+       case I915_PARAM_HAS_SCHEDULER:
+               value = dev_priv->engine[RCS] &&
+                       dev_priv->engine[RCS]->schedule;
+               break;
        case I915_PARAM_MMAP_VERSION:
                /* Remember to bump this if the version changes! */
        case I915_PARAM_HAS_GEM:
index 952d2aec5244329d1e88c48a0c2762e829bce9c7..1118cf48d6f0577a5be83a85a976cb6bf5cb12ae 100644 (file)
@@ -762,6 +762,19 @@ void __i915_add_request(struct drm_i915_gem_request *request, bool flush_caches)
 
        i915_gem_mark_busy(engine);
 
+       /* Let the backend know a new request has arrived that may need
+        * to adjust the existing execution schedule due to a high priority
+        * request - i.e. we may want to preempt the current request in order
+        * to run a high priority dependency chain *before* we can execute this
+        * request.
+        *
+        * This is called before the request is ready to run so that we can
+        * decide whether to preempt the entire chain so that it is ready to
+        * run at the earliest possible convenience.
+        */
+       if (engine->schedule)
+               engine->schedule(request, 0);
+
        local_bh_disable();
        i915_sw_fence_commit(&request->submit);
        local_bh_enable(); /* Kick the execlists tasklet if just scheduled */
index 298f0f95dd3f83696d7b1473a89cf06c61a28c7e..c9171a058478a8da9aae3139e83b5d97e80b6b16 100644 (file)
@@ -102,6 +102,9 @@ intel_engine_setup(struct drm_i915_private *dev_priv,
        engine->mmio_base = info->mmio_base;
        engine->irq_shift = info->irq_shift;
 
+       /* Nothing to do here, execute in order of dependencies */
+       engine->schedule = NULL;
+
        dev_priv->engine[id] = engine;
        return 0;
 }
index e1351870c2034c7a59969da104cc214b3998a931..b9583941eb6b432b3fff7fc555c2c5c6ec21c7e6 100644 (file)
@@ -267,6 +267,15 @@ struct intel_engine_cs {
         */
        void            (*submit_request)(struct drm_i915_gem_request *req);
 
+       /* Call when the priority on a request has changed and it and its
+        * dependencies may need rescheduling. Note the request itself may
+        * not be ready to run!
+        *
+        * Called under the struct_mutex.
+        */
+       void            (*schedule)(struct drm_i915_gem_request *request,
+                                   int priority);
+
        /* Some chipsets are not quite as coherent as advertised and need
         * an expensive kick to force a true read of the up-to-date seqno.
         * However, the up-to-date seqno is not always required and the last
index 03725fe89859746391f63e23af622d10b5d5d0b0..1c12a350eca391a1442acc40f6a75728ea9b11f9 100644 (file)
@@ -389,6 +389,11 @@ typedef struct drm_i915_irq_wait {
 #define I915_PARAM_MIN_EU_IN_POOL       39
 #define I915_PARAM_MMAP_GTT_VERSION     40
 
+/* Query whether DRM_I915_GEM_EXECBUFFER2 supports user defined execution
+ * priorities and the driver will attempt to execute batches in priority order.
+ */
+#define I915_PARAM_HAS_SCHEDULER        41
+
 typedef struct drm_i915_getparam {
        __s32 param;
        /*