aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-11-15 11:46:20 -0500
committerChris Wilson <chris@chris-wilson.co.uk>2016-11-18 06:47:37 -0500
commit4302055b29cbc8566aaa5eb7f594ea9cc78ebf41 (patch)
treefbe87315c83c0d8ceeeaa83aa5f8d80e0dd4f6d5
parent5b8c8aec8e8ef999c8b3eaa699e46ef25550d118 (diff)
drm/i915: Be more careful to drop the GT wakeref
Since we can retire requests from multiple paths, we cannot assume that i915_gem_retire_requests() is the sole path on which we can transition to gt.active_requests == 0. A consequence of this is that we would skip the function if we had already retired all the requests and not scheduled the idle worker. This is fallout from changing the routine from considering active_engines (for which it was the only consumer) to active_requests. v2: Move kicking the idle working to i915_gem_request_retire() otherwise we could postpone the idle callback everytime we called retire_requests even though we did no work. v3: We only need to move the idle work kicking! v4: Drop the BUG_ON(!awake) as we may be called from the shrinker in the middle of constructing a request before we have marked the device awake. v5: Add a BUG_ON() for active_requests underflow upon retirement (Joonas) Fixes: 28176ef4cfa5 ("drm/i915: Reserve space in the global seqno during request allocation") Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/20161115164620.17185-1-chris@chris-wilson.co.uk Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
-rw-r--r--drivers/gpu/drm/i915/i915_gem_request.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c
index b9b5253cf3cd..db2cac7f5d43 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.c
+++ b/drivers/gpu/drm/i915/i915_gem_request.c
@@ -201,6 +201,7 @@ static void i915_gem_request_retire(struct drm_i915_gem_request *request)
201 201
202 lockdep_assert_held(&request->i915->drm.struct_mutex); 202 lockdep_assert_held(&request->i915->drm.struct_mutex);
203 GEM_BUG_ON(!i915_gem_request_completed(request)); 203 GEM_BUG_ON(!i915_gem_request_completed(request));
204 GEM_BUG_ON(!request->i915->gt.active_requests);
204 205
205 trace_i915_gem_request_retire(request); 206 trace_i915_gem_request_retire(request);
206 207
@@ -218,7 +219,12 @@ static void i915_gem_request_retire(struct drm_i915_gem_request *request)
218 */ 219 */
219 list_del(&request->ring_link); 220 list_del(&request->ring_link);
220 request->ring->last_retired_head = request->postfix; 221 request->ring->last_retired_head = request->postfix;
221 request->i915->gt.active_requests--; 222 if (!--request->i915->gt.active_requests) {
223 GEM_BUG_ON(!request->i915->gt.awake);
224 mod_delayed_work(request->i915->wq,
225 &request->i915->gt.idle_work,
226 msecs_to_jiffies(100));
227 }
222 228
223 /* Walk through the active list, calling retire on each. This allows 229 /* Walk through the active list, calling retire on each. This allows
224 * objects to track their GPU activity and mark themselves as idle 230 * objects to track their GPU activity and mark themselves as idle
@@ -763,6 +769,8 @@ static void i915_gem_mark_busy(const struct intel_engine_cs *engine)
763 if (dev_priv->gt.awake) 769 if (dev_priv->gt.awake)
764 return; 770 return;
765 771
772 GEM_BUG_ON(!dev_priv->gt.active_requests);
773
766 intel_runtime_pm_get_noresume(dev_priv); 774 intel_runtime_pm_get_noresume(dev_priv);
767 dev_priv->gt.awake = true; 775 dev_priv->gt.awake = true;
768 776
@@ -1146,13 +1154,6 @@ void i915_gem_retire_requests(struct drm_i915_private *dev_priv)
1146 if (!dev_priv->gt.active_requests) 1154 if (!dev_priv->gt.active_requests)
1147 return; 1155 return;
1148 1156
1149 GEM_BUG_ON(!dev_priv->gt.awake);
1150
1151 for_each_engine(engine, dev_priv, id) 1157 for_each_engine(engine, dev_priv, id)
1152 engine_retire_requests(engine); 1158 engine_retire_requests(engine);
1153
1154 if (!dev_priv->gt.active_requests)
1155 mod_delayed_work(dev_priv->wq,
1156 &dev_priv->gt.idle_work,
1157 msecs_to_jiffies(100));
1158} 1159}