[PATCH 2/7] drm/i915/gem: Push clflush display work after the fence signal

Thomas Hellström thomas.hellstrom at linux.intel.com
Wed Oct 6 06:59:43 UTC 2021


From: Chris Wilson <chris at chris-wilson.co.uk>

Signal the fence, then start the display callbacks.
Avoids taking a lock in the fence critical path, which is then allocated
under.

v2: Include a reminder to check for fallout with PSR/flips.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Imre Deak <imre.deak at intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_clflush.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_clflush.c b/drivers/gpu/drm/i915/gem/i915_gem_clflush.c
index 2143ebaf5b6f..d55f25d8699c 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_clflush.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_clflush.c
@@ -20,8 +20,6 @@ static void __do_clflush(struct drm_i915_gem_object *obj)
 {
 	GEM_BUG_ON(!i915_gem_object_has_pages(obj));
 	drm_clflush_sg(obj->mm.pages);
-
-	i915_gem_object_flush_frontbuffer(obj, ORIGIN_CPU);
 }
 
 static void clflush_work(struct dma_fence_work *base)
@@ -39,9 +37,21 @@ static void clflush_work(struct dma_fence_work *base)
 static void clflush_release(struct dma_fence_work *base)
 {
 	struct clflush *clflush = container_of(base, typeof(*clflush), base);
+	struct drm_i915_gem_object *obj = clflush->obj;
+
+	/*
+	 * Note that by deferring the frontbuffer flush to after the signal,
+	 * listeners may proceed before the frontbuffer flush is completed.
+	 * This may affect intel_atomic_tail() as the flip may depend on PSR
+	 * state. At present no impact has yet to be seen (look for sporadic
+	 * CRC failures with flips and PSR), and pushing the flush after the
+	 * critical path does avoid some nasty lock dependencies.
+	 */
+	if (!base->error)
+		i915_gem_object_flush_frontbuffer(obj, ORIGIN_CPU);
 
-	i915_gem_object_unpin_pages(clflush->obj);
-	i915_gem_object_put(clflush->obj);
+	i915_gem_object_unpin_pages(obj);
+	i915_gem_object_put(obj);
 }
 
 static const struct dma_fence_work_ops clflush_ops = {
-- 
2.31.1



More information about the Intel-gfx-trybot mailing list