Commit 05425249 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Generalise wait for execlists to be idle

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: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/20170303121947.20482-2-chris@chris-wilson.co.ukReviewed-by: default avatarMika Kuoppala <mika.kuoppala@intel.com>
parent 5400367a
...@@ -2959,8 +2959,8 @@ i915_gem_idle_work_handler(struct work_struct *work) ...@@ -2959,8 +2959,8 @@ i915_gem_idle_work_handler(struct work_struct *work)
* new request is submitted. * new request is submitted.
*/ */
wait_for(READ_ONCE(dev_priv->gt.active_requests) || 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)) if (READ_ONCE(dev_priv->gt.active_requests))
return; return;
...@@ -2985,7 +2985,7 @@ i915_gem_idle_work_handler(struct work_struct *work) ...@@ -2985,7 +2985,7 @@ i915_gem_idle_work_handler(struct work_struct *work)
if (dev_priv->gt.active_requests) if (dev_priv->gt.active_requests)
goto out_unlock; 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"); DRM_ERROR("Timeout waiting for engines to idle\n");
for_each_engine(engine, dev_priv, id) { for_each_engine(engine, dev_priv, id) {
...@@ -4287,7 +4287,7 @@ int i915_gem_suspend(struct drm_i915_private *dev_priv) ...@@ -4287,7 +4287,7 @@ int i915_gem_suspend(struct drm_i915_private *dev_priv)
* reset the GPU back to its idle, low power state. * reset the GPU back to its idle, low power state.
*/ */
WARN_ON(dev_priv->gt.awake); 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 * Neither the BIOS, ourselves or any other kernel
......
...@@ -1102,6 +1102,19 @@ bool intel_engine_is_idle(struct intel_engine_cs *engine) ...@@ -1102,6 +1102,19 @@ bool intel_engine_is_idle(struct intel_engine_cs *engine)
return true; 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) #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
#include "selftests/mock_engine.c" #include "selftests/mock_engine.c"
#endif #endif
...@@ -498,34 +498,6 @@ static bool execlists_elsp_idle(struct intel_engine_cs *engine) ...@@ -498,34 +498,6 @@ static bool execlists_elsp_idle(struct intel_engine_cs *engine)
return !engine->execlist_port[0].request; 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) static bool execlists_elsp_ready(const struct intel_engine_cs *engine)
{ {
const struct execlist_port *port = engine->execlist_port; const struct execlist_port *port = engine->execlist_port;
......
...@@ -88,6 +88,5 @@ uint64_t intel_lr_context_descriptor(struct i915_gem_context *ctx, ...@@ -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 intel_sanitize_enable_execlists(struct drm_i915_private *dev_priv,
int enable_execlists); int enable_execlists);
void intel_execlists_enable_submission(struct drm_i915_private *dev_priv); 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_ */ #endif /* _INTEL_LRC_H_ */
...@@ -665,5 +665,6 @@ static inline u32 *gen8_emit_pipe_control(u32 *batch, u32 flags, u32 offset) ...@@ -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_engine_is_idle(struct intel_engine_cs *engine);
bool intel_engines_are_idle(struct drm_i915_private *dev_priv);
#endif /* _INTEL_RINGBUFFER_H_ */ #endif /* _INTEL_RINGBUFFER_H_ */
...@@ -303,7 +303,7 @@ static int end_live_test(struct live_test *t) ...@@ -303,7 +303,7 @@ static int end_live_test(struct live_test *t)
{ {
struct drm_i915_private *i915 = t->i915; 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); pr_err("%s(%s): GPU not idle\n", t->func, t->name);
return -EIO; return -EIO;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment