]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
drm/i915/guc: pass request (not client) to i915_guc_{wq_check_space, submit}()
authorDave Gordon <david.s.gordon@intel.com>
Fri, 13 May 2016 14:36:32 +0000 (15:36 +0100)
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>
Mon, 23 May 2016 13:21:53 +0000 (14:21 +0100)
The knowledge of how to derive the relevant client from the request
should be localised within i915_guc_submission.c; the LRC code shouldn't
have to know about the internal details of the GuC submission process.
And all the information the GuC code needs should be encapsulated in (or
reachable from) the request.

v2:
    GEM_BUG_ON() for bad GuC client (Tvrtko Ursulin).
    Add/update kerneldoc explaining check_space/submit protocol

Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
drivers/gpu/drm/i915/i915_guc_submission.c
drivers/gpu/drm/i915/intel_guc.h
drivers/gpu/drm/i915/intel_lrc.c

index 916cd6778cf3640815ecabc639d2a42ca3f8b238..87cb7396ff93b9117fea521da003ef35c8f569f1 100644 (file)
@@ -450,14 +450,30 @@ static void guc_fini_ctx_desc(struct intel_guc *guc,
                             sizeof(desc) * client->ctx_index);
 }
 
-int i915_guc_wq_check_space(struct i915_guc_client *gc)
+/**
+ * i915_guc_wq_check_space() - check that the GuC can accept a request
+ * @request:   request associated with the commands
+ *
+ * Return:     0 if space is available
+ *             -EAGAIN if space is not currently available
+ *
+ * This function must be called (and must return 0) before a request
+ * is submitted to the GuC via i915_guc_submit() below. Once a result
+ * of 0 has been returned, it remains valid until (but only until)
+ * the next call to submit().
+ *
+ * This precheck allows the caller to determine in advance that space
+ * will be available for the next submission before committing resources
+ * to it, and helps avoid late failures with complicated recovery paths.
+ */
+int i915_guc_wq_check_space(struct drm_i915_gem_request *request)
 {
+       const size_t size = sizeof(struct guc_wq_item);
+       struct i915_guc_client *gc = request->i915->guc.execbuf_client;
        struct guc_process_desc *desc;
-       u32 size = sizeof(struct guc_wq_item);
        int ret = -ETIMEDOUT, timeout_counter = 200;
 
-       if (!gc)
-               return 0;
+       GEM_BUG_ON(gc == NULL);
 
        desc = gc->client_base + gc->proc_desc_offset;
 
@@ -531,16 +547,28 @@ static int guc_add_workqueue_item(struct i915_guc_client *gc,
 
 /**
  * i915_guc_submit() - Submit commands through GuC
- * @client:    the guc client where commands will go through
  * @rq:                request associated with the commands
  *
- * Return:     0 if succeed
+ * Return:     0 on success, otherwise an errno.
+ *             (Note: nonzero really shouldn't happen!)
+ *
+ * The caller must have already called i915_guc_wq_check_space() above
+ * with a result of 0 (success) since the last request submission. This
+ * guarantees that there is space in the work queue for the new request,
+ * so enqueuing the item cannot fail.
+ *
+ * Bad Things Will Happen if the caller violates this protocol e.g. calls
+ * submit() when check() says there's no space, or calls submit() multiple
+ * times with no intervening check().
+ *
+ * The only error here arises if the doorbell hardware isn't functioning
+ * as expected, which really shouln't happen.
  */
-int i915_guc_submit(struct i915_guc_client *client,
-                   struct drm_i915_gem_request *rq)
+int i915_guc_submit(struct drm_i915_gem_request *rq)
 {
-       struct intel_guc *guc = client->guc;
        unsigned int engine_id = rq->engine->guc_id;
+       struct intel_guc *guc = &rq->i915->guc;
+       struct i915_guc_client *client = guc->execbuf_client;
        int q_ret, b_ret;
 
        q_ret = guc_add_workqueue_item(client, rq);
index 3984136584ea53ed94f7ade73e18113c7cb0be80..91f315cf073b1566eb128b596785bb1233507e1b 100644 (file)
@@ -148,10 +148,9 @@ extern int intel_guc_resume(struct drm_device *dev);
 /* i915_guc_submission.c */
 int i915_guc_submission_init(struct drm_device *dev);
 int i915_guc_submission_enable(struct drm_device *dev);
-int i915_guc_submit(struct i915_guc_client *client,
-                   struct drm_i915_gem_request *rq);
+int i915_guc_wq_check_space(struct drm_i915_gem_request *rq);
+int i915_guc_submit(struct drm_i915_gem_request *rq);
 void i915_guc_submission_disable(struct drm_device *dev);
 void i915_guc_submission_fini(struct drm_device *dev);
-int i915_guc_wq_check_space(struct i915_guc_client *client);
 
 #endif
index affca6d5ce7e219c01163788d1c46c38d3539454..0d1772a122feefab7c270096df716337ed227d31 100644 (file)
@@ -696,9 +696,7 @@ int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request
                 * going any further, as the i915_add_request() call
                 * later on mustn't fail ...
                 */
-               struct intel_guc *guc = &request->i915->guc;
-
-               ret = i915_guc_wq_check_space(guc->execbuf_client);
+               ret = i915_guc_wq_check_space(request);
                if (ret)
                        return ret;
        }
@@ -747,7 +745,6 @@ static int
 intel_logical_ring_advance_and_submit(struct drm_i915_gem_request *request)
 {
        struct intel_ringbuffer *ringbuf = request->ringbuf;
-       struct drm_i915_private *dev_priv = request->i915;
        struct intel_engine_cs *engine = request->engine;
 
        intel_logical_ring_advance(ringbuf);
@@ -775,8 +772,8 @@ intel_logical_ring_advance_and_submit(struct drm_i915_gem_request *request)
        request->previous_context = engine->last_context;
        engine->last_context = request->ctx;
 
-       if (dev_priv->guc.execbuf_client)
-               i915_guc_submit(dev_priv->guc.execbuf_client, request);
+       if (i915.enable_guc_submission)
+               i915_guc_submit(request);
        else
                execlists_context_queue(request);