@@ -425,11 +425,22 @@ void *i915_gem_object_pin_map(struct drm_i915_gem_object *obj,
void *i915_gem_object_pin_map_unlocked(struct drm_i915_gem_object *obj,
enum i915_map_type type)
{
+ struct i915_gem_ww_ctx ww;
void *ret;
+ int err;
- i915_gem_object_lock(obj, NULL);
- ret = i915_gem_object_pin_map(obj, type);
- i915_gem_object_unlock(obj);
+ for_i915_gem_ww(&ww, err, false) {
+ err = i915_gem_object_lock(obj, &ww);
+ if (err)
+ continue;
+
+ ret = i915_gem_object_pin_map(obj, type);
+ if (IS_ERR(ret))
+ err = PTR_ERR(ret);
+ /* Implicit unlock */
+ }
+ if (err)
+ return ERR_PTR(err);
return ret;
}