[Intel-gfx] [RFC PATCH 156/162] drm/i915: Use a ww transaction in i915_gem_object_pin_map_unlocked()

Matthew Auld matthew.auld at intel.com
Fri Nov 27 12:07:12 UTC 2020


From: Thomas Hellström <thomas.hellstrom at intel.com>

By using a ww transaction, anybody using this function and ending up
evicting objects can use sleeping waits when locking objects to evict.

Signed-off-by: Thomas Hellström <thomas.hellstrom at intel.com>
Cc: Matthew Auld <matthew.auld at intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_pages.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
index d0f3da0925f5..0c20f9b18956 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
@@ -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;
 }
-- 
2.26.2



More information about the Intel-gfx mailing list