intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Andi Shyti <andi.shyti@linux.intel.com>
To: dri-devel <dri-devel@lists.freedesktop.org>,
	intel-gfx <intel-gfx@lists.freedesktop.org>
Cc: Chris Wilson <chris.p.wilson@linux.intel.com>,
	Andi Shyti <andi.shyti@kernel.org>,
	Andi Shyti <andi.shyti@linux.intel.com>
Subject: [PATCH] drm/i915: Replace sleep with GT idle wait
Date: Wed, 22 Jul 2026 09:22:28 +0200	[thread overview]
Message-ID: <20260722072228.1080796-1-andi.shyti@linux.intel.com> (raw)

On VT-d systems, the driver must ensure that the GT is idle
before DMA object pages are unmapped.

Currently, the driver simply sleeps for 100-250 microseconds,
which does not guarantee that all requests have completed and no
further ones are being submitted. Replace the sleep with
intel_gt_wait_for_idle() to explicitly wait until the GT has
become idle.

An error is printed if waiting for the GT to become idle fails.

Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Cc: Chris Wilson <chris.p.wilson@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 25295eb626dc..a8463854be64 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -16,6 +16,7 @@
 #include <asm/smp.h>
 
 #include "gt/intel_gt.h"
+#include "gt/intel_gt_print.h"
 #include "gt/intel_gt_requests.h"
 
 #include "i915_drv.h"
@@ -58,10 +59,14 @@ void i915_gem_gtt_finish_pages(struct drm_i915_gem_object *obj,
 	struct drm_i915_private *i915 = to_i915(obj->base.dev);
 	struct i915_ggtt *ggtt = to_gt(i915)->ggtt;
 
-	/* XXX This does not prevent more requests being submitted! */
-	if (unlikely(ggtt->do_idle_maps))
-		/* Wait a bit, in the hope it avoids the hang */
-		usleep_range(100, 250);
+	if (unlikely(ggtt->do_idle_maps)) {
+		struct intel_gt *gt;
+		int i;
+
+		for_each_gt(gt, i915, i)
+			if (intel_gt_wait_for_idle(gt, MAX_SCHEDULE_TIMEOUT))
+				gt_err(gt, "Failed to idle before DMA unmap\n");
+	}
 
 	dma_unmap_sg(i915->drm.dev, pages->sgl, pages->nents,
 		     DMA_BIDIRECTIONAL);
-- 
2.53.0


             reply	other threads:[~2026-07-22  7:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22  7:22 Andi Shyti [this message]
2026-07-22 11:20 ` ✓ i915.CI.BAT: success for drm/i915: Replace sleep with GT idle wait Patchwork
2026-07-23  7:12 ` ✓ i915.CI.Full: " Patchwork
2026-07-30  9:01 ` [PATCH] " Andi Shyti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260722072228.1080796-1-andi.shyti@linux.intel.com \
    --to=andi.shyti@linux.intel.com \
    --cc=andi.shyti@kernel.org \
    --cc=chris.p.wilson@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).