drm/i915: Generalise wait for execlists to be idle
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 3 Mar 2017 12:19:47 +0000 (12:19 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 3 Mar 2017 13:08:15 +0000 (13:08 +0000)
The code to check for execlists completion is generic, so move it to
intel_engine_cs.c, where we can reuse the new intel_engine_is_idle().

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/20170303121947.20482-2-chris@chris-wilson.co.uk
Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com>
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/intel_engine_cs.c
drivers/gpu/drm/i915/intel_lrc.c
drivers/gpu/drm/i915/intel_lrc.h
drivers/gpu/drm/i915/intel_ringbuffer.h
drivers/gpu/drm/i915/selftests/i915_gem_request.c

index edc59bd45f53331fb0313e2b0a621888d45b96b3..f7e85fb1464f44613b1050e559a5e81d898b69fb 100644 (file)
@@ -2959,8 +2959,8 @@ i915_gem_idle_work_handler(struct work_struct *work)
         * new request is submitted.
         */
        wait_for(READ_ONCE(dev_priv->gt.active_requests) ||
-                intel_execlists_idle(dev_priv), 10);
-
+                intel_engines_are_idle(dev_priv),
+                10);
        if (READ_ONCE(dev_priv->gt.active_requests))
                return;
 
@@ -2985,7 +2985,7 @@ i915_gem_idle_work_handler(struct work_struct *work)
        if (dev_priv->gt.active_requests)
                goto out_unlock;
 
-       if (wait_for(intel_execlists_idle(dev_priv), 10))
+       if (wait_for(intel_engines_are_idle(dev_priv), 10))
                DRM_ERROR("Timeout waiting for engines to idle\n");
 
        for_each_engine(engine, dev_priv, id) {
@@ -4287,7 +4287,7 @@ int i915_gem_suspend(struct drm_i915_private *dev_priv)
         * reset the GPU back to its idle, low power state.
         */
        WARN_ON(dev_priv->gt.awake);
-       WARN_ON(!intel_execlists_idle(dev_priv));
+       WARN_ON(!intel_engines_are_idle(dev_priv));
 
        /*
         * Neither the BIOS, ourselves or any other kernel
index 53d65dc0c9fb1ba253e2e1d3863453cd3c2be82d..5fd4883db2358270258a2f503a3d25ef15c527dd 100644 (file)
@@ -1102,6 +1102,19 @@ bool intel_engine_is_idle(struct intel_engine_cs *engine)
        return true;
 }
 
+bool intel_engines_are_idle(struct drm_i915_private *dev_priv)
+{
+       struct intel_engine_cs *engine;
+       enum intel_engine_id id;
+
+       for_each_engine(engine, dev_priv, id) {
+               if (!intel_engine_is_idle(engine))
+                       return false;
+       }
+
+       return true;
+}
+
 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
 #include "selftests/mock_engine.c"
 #endif
index f9a8545474bc99702ee87e33bbdabde50571c9ca..3834a84fe084a84ccd4c3dc3ddfe0f1c5d3cb914 100644 (file)
@@ -498,34 +498,6 @@ static bool execlists_elsp_idle(struct intel_engine_cs *engine)
        return !engine->execlist_port[0].request;
 }
 
-/**
- * intel_execlists_idle() - Determine if all engine submission ports are idle
- * @dev_priv: i915 device private
- *
- * Return true if there are no requests pending on any of the submission ports
- * of any engines.
- */
-bool intel_execlists_idle(struct drm_i915_private *dev_priv)
-{
-       struct intel_engine_cs *engine;
-       enum intel_engine_id id;
-
-       if (!i915.enable_execlists)
-               return true;
-
-       for_each_engine(engine, dev_priv, id) {
-               /* Interrupt/tasklet pending? */
-               if (test_bit(ENGINE_IRQ_EXECLIST, &engine->irq_posted))
-                       return false;
-
-               /* Both ports drained, no more ELSP submission? */
-               if (!execlists_elsp_idle(engine))
-                       return false;
-       }
-
-       return true;
-}
-
 static bool execlists_elsp_ready(const struct intel_engine_cs *engine)
 {
        const struct execlist_port *port = engine->execlist_port;
index c8009c7bfbdd8aa6e622471fa2f5526d86f403d8..5fc07761caff75bb1abd695c11334be6bf190735 100644 (file)
@@ -88,6 +88,5 @@ uint64_t intel_lr_context_descriptor(struct i915_gem_context *ctx,
 int intel_sanitize_enable_execlists(struct drm_i915_private *dev_priv,
                                    int enable_execlists);
 void intel_execlists_enable_submission(struct drm_i915_private *dev_priv);
-bool intel_execlists_idle(struct drm_i915_private *dev_priv);
 
 #endif /* _INTEL_LRC_H_ */
index 38580765bfd6cdc4d6d457ff78c63bdbe83042ea..55a6a3f8274cc7438668abf46a786814b8979a9f 100644 (file)
@@ -665,5 +665,6 @@ static inline u32 *gen8_emit_pipe_control(u32 *batch, u32 flags, u32 offset)
 }
 
 bool intel_engine_is_idle(struct intel_engine_cs *engine);
+bool intel_engines_are_idle(struct drm_i915_private *dev_priv);
 
 #endif /* _INTEL_RINGBUFFER_H_ */
index 42bdeac93324278b6630b6e061a4d0b87c719905..926b24c117d6a505be413b42ef44e961e1662277 100644 (file)
@@ -303,7 +303,7 @@ static int end_live_test(struct live_test *t)
 {
        struct drm_i915_private *i915 = t->i915;
 
-       if (wait_for(intel_execlists_idle(i915), 1)) {
+       if (wait_for(intel_engines_are_idle(i915), 1)) {
                pr_err("%s(%s): GPU not idle\n", t->func, t->name);
                return -EIO;
        }