Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: intel-xe@lists.freedesktop.org
Subject: [CI 7/7] drm/xe/bo: Allow migrating local bos to TT to make room in VRAM
Date: Tue, 12 Mar 2024 16:34:59 +0100	[thread overview]
Message-ID: <20240312153459.10185-7-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20240312153459.10185-1-thomas.hellstrom@linux.intel.com>

If VRAM is full and we want to evict local bos we can't typically
do that, since we require all local bos to be residient at
execution time.
But we're allowed to migrate to TT if that's a valid placement
for GPU access, so in that case, do that.

Fixes: 24f947d58fe5 ("drm/xe: Use DRM GPUVM helpers for external- and evicted objects")
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
 drivers/gpu/drm/xe/xe_bo.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index da1f28224057..bbc926f9b0c4 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -1049,6 +1049,21 @@ static void xe_ttm_bo_delete_mem_notify(struct ttm_buffer_object *ttm_bo)
 	}
 }
 
+/*
+ * Does @bo have @mem_type as an allowed placement?
+ */
+static bool xe_bo_may_reside_in(const struct xe_bo *bo, unsigned int mem_type)
+{
+	const struct ttm_placement *placement = &bo->placement;
+	unsigned int i;
+
+	for (i = 0; i < placement->num_placement; ++i) {
+		if (placement->placement[i].mem_type == mem_type)
+			return true;
+	}
+	return false;
+}
+
 static bool xe_bo_eviction_valuable(struct ttm_buffer_object *ttm_bo,
 				    const struct ttm_place *place)
 {
@@ -1062,6 +1077,10 @@ static bool xe_bo_eviction_valuable(struct ttm_buffer_object *ttm_bo,
 			/* Not bound to the vm? */
 			if (list_empty(&ttm_bo->base.gpuva.list))
 				goto allow;
+			/* Is the bo gpu accessible even if placed in TT? */
+			if (ttm_bo->resource && ttm_bo->resource->mem_type !=
+			    XE_PL_TT && xe_bo_may_reside_in(xe_bo, XE_PL_TT))
+				goto allow;
 			return false;
 		}
 	}
-- 
2.44.0


  parent reply	other threads:[~2024-03-12 15:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12 15:34 [CI 1/7] drm/xe: Make TLB invalidation fences unordered Thomas Hellström
2024-03-12 15:34 ` [CI 2/7] drm/xe: Rework xe_vm_rebind() Thomas Hellström
2024-03-12 15:34 ` [CI 3/7] drm/xe: Reserve fences where needed Thomas Hellström
2024-03-12 15:34 ` [CI 4/7] drm/xe: Move vma rebinding to the drm_exec locking loop Thomas Hellström
2024-03-12 15:34 ` [CI 5/7] drm/xe/bo: Forward the decision to evict local objects during validation Thomas Hellström
2024-03-12 15:34 ` [CI 6/7] drm/xe/bo: Allow eviction of unbound local bos Thomas Hellström
2024-03-12 15:34 ` Thomas Hellström [this message]
2024-03-12 16:21 ` ✓ CI.Patch_applied: success for series starting with [CI,1/7] drm/xe: Make TLB invalidation fences unordered Patchwork
2024-03-12 16:21 ` ✓ CI.checkpatch: " Patchwork
2024-03-12 16:22 ` ✓ CI.KUnit: " Patchwork
2024-03-12 16:33 ` ✓ CI.Build: " Patchwork
2024-03-12 16:35 ` ✓ CI.Hooks: " Patchwork
2024-03-12 16:37 ` ✓ CI.checksparse: " Patchwork
2024-03-12 17:06 ` ✗ CI.BAT: failure " Patchwork
2024-03-13 10:33 ` ✓ CI.Patch_applied: success for series starting with [CI,1/7] drm/xe: Make TLB invalidation fences unordered (rev2) Patchwork
2024-03-13 10:34 ` ✓ CI.checkpatch: " Patchwork
2024-03-13 10:35 ` ✓ CI.KUnit: " Patchwork
2024-03-13 10:46 ` ✓ CI.Build: " Patchwork
2024-03-13 10:48 ` ✓ CI.Hooks: " Patchwork
2024-03-13 10:49 ` ✓ CI.checksparse: " Patchwork
2024-03-13 11:19 ` ✗ CI.BAT: failure " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2024-03-12 14:04 [CI 1/7] drm/xe: Make TLB invalidation fences unordered Thomas Hellström
2024-03-12 14:04 ` [CI 7/7] drm/xe/bo: Allow migrating local bos to TT to make room in VRAM Thomas Hellström

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=20240312153459.10185-7-thomas.hellstrom@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=intel-xe@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