All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [Intel-gfx] [CI 2/2] drm/i915: Try hard to bind the context
Date: Wed,  4 Dec 2019 19:23:43 +0000	[thread overview]
Message-ID: <20191204192343.3939007-2-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20191204192343.3939007-1-chris@chris-wilson.co.uk>

It is not acceptable for context pinning to fail with -ENOSPC as we
should always be able to make space in the GGTT. The only reason we may
fail is that other "temporary" context pins are reserving their space
and we need to wait for an available slot.

Closes: https://gitlab.freedesktop.org/drm/intel/issues/676
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 10b3d6d44045..7e20c6f62cd5 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -1934,9 +1934,24 @@ int gen6_ppgtt_pin(struct i915_ppgtt *base)
 	 * size. We allocate at the top of the GTT to avoid fragmentation.
 	 */
 	if (!atomic_read(&ppgtt->pin_count)) {
-		err = i915_vma_pin(ppgtt->vma,
-				   0, GEN6_PD_ALIGN,
-				   PIN_GLOBAL | PIN_HIGH);
+		do {
+			struct i915_address_space *vm = ppgtt->vma->vm;
+
+			err = i915_vma_pin(ppgtt->vma,
+					   0, GEN6_PD_ALIGN,
+					   PIN_GLOBAL | PIN_HIGH);
+			if (err != -ENOSPC)
+				break;
+
+			/* We don't take no for an answer! */
+			err = mutex_lock_interruptible(&vm->mutex);
+			if (err == 0) {
+				err = i915_gem_evict_vm(vm);
+				mutex_unlock(&vm->mutex);
+			}
+			if (err)
+				break;
+		} while (1);
 	}
 	if (!err)
 		atomic_inc(&ppgtt->pin_count);
-- 
2.24.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-12-04 19:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-04 19:23 [Intel-gfx] [CI 1/2] drm/i915: Ignore most failures during evict-vm Chris Wilson
2019-12-04 19:23 ` Chris Wilson [this message]
2019-12-05  0:48 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [CI,1/2] " Patchwork

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=20191204192343.3939007-2-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.