diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 97d164d0c04736254f018624c6c92908ef5e2bea..4ea3e537eceb9bdec72f6cdd3c6952d11567a1e3 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2934,11 +2934,20 @@ static int wait_for_timeline(struct i915_gem_timeline *tl, unsigned int flags) int i915_gem_wait_for_idle(struct drm_i915_private *i915, unsigned int flags) { - struct i915_gem_timeline *tl; int ret; - list_for_each_entry(tl, &i915->gt.timelines, link) { - ret = wait_for_timeline(tl, flags); + if (flags & I915_WAIT_LOCKED) { + struct i915_gem_timeline *tl; + + lockdep_assert_held(&i915->drm.struct_mutex); + + list_for_each_entry(tl, &i915->gt.timelines, link) { + ret = wait_for_timeline(tl, flags); + if (ret) + return ret; + } + } else { + ret = wait_for_timeline(&i915->gt.global_timeline, flags); if (ret) return ret; }