diff mbox series

[v3,26/63] drm/i915: Make __engine_unpark() compatible with ww locking.

Message ID 20201015112627.1142745-27-maarten.lankhorst@linux.intel.com
State New, archived
Headers show
Series drm/i915: Remove obj->mm.lock! | expand

Commit Message

Maarten Lankhorst Oct. 15, 2020, 11:25 a.m. UTC
Take the ww lock around engine_unpark. Because of the
many many places where rpm is used, I chose the safest option
and used a trylock to opportunistically take this lock for
__engine_unpark.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/gt/intel_engine_pm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/intel_engine_pm.c b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
index f7b2e07e2229..1ab9597a5c70 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_pm.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
@@ -33,7 +33,8 @@  static int __engine_unpark(struct intel_wakeref *wf)
 		GEM_BUG_ON(test_bit(CONTEXT_VALID_BIT, &ce->flags));
 
 		/* First poison the image to verify we never fully trust it */
-		if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM) && ce->state) {
+		if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM) && ce->state &&
+		    i915_gem_object_trylock(ce->state->obj)) {
 			struct drm_i915_gem_object *obj = ce->state->obj;
 			int type = i915_coherent_map_type(engine->i915);
 			void *map;
@@ -44,6 +45,7 @@  static int __engine_unpark(struct intel_wakeref *wf)
 				i915_gem_object_flush_map(obj);
 				i915_gem_object_unpin_map(obj);
 			}
+			i915_gem_object_unlock(obj);
 		}
 
 		ce->ops->reset(ce);