All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
	"Jani Nikula" <jani.nikula@intel.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Matthew Auld" <matthew.auld@intel.com>
Subject: [PATCH v3 12/14] drm/xe/sriov: Convert pf_provision_vf_lmem for exhaustive eviction
Date: Mon,  1 Sep 2025 18:12:47 +0200	[thread overview]
Message-ID: <20250901161250.5279-13-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20250901161250.5279-1-thomas.hellstrom@linux.intel.com>

Open-code instead of adding yet another xe_bo_create_xxx() interface
pending a rework of the bo create functionality.

v2:
- Break out this patch from the previous one.
v3:
- Rework commit message.
- Early return on error (Matt Brost).

Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
 drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 52 ++++++++++++++--------
 1 file changed, 34 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
index 906011671b60..742e069d0777 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
@@ -1452,11 +1452,12 @@ static bool pf_release_vf_config_lmem(struct xe_gt *gt, struct xe_gt_sriov_confi
 static int pf_provision_vf_lmem(struct xe_gt *gt, unsigned int vfid, u64 size)
 {
 	struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
-	struct drm_exec *exec = XE_VALIDATION_UNIMPLEMENTED;
 	struct xe_device *xe = gt_to_xe(gt);
 	struct xe_tile *tile = gt_to_tile(gt);
+	struct xe_validation_ctx ctx;
+	struct drm_exec exec;
 	struct xe_bo *bo;
-	int err;
+	int err = 0;
 
 	xe_gt_assert(gt, vfid);
 	xe_gt_assert(gt, IS_DGFX(xe));
@@ -1479,23 +1480,38 @@ static int pf_provision_vf_lmem(struct xe_gt *gt, unsigned int vfid, u64 size)
 		return 0;
 
 	xe_gt_assert(gt, pf_get_lmem_alignment(gt) == SZ_2M);
-	bo = xe_bo_create_locked(xe, tile, NULL,
-				 ALIGN(size, PAGE_SIZE),
-				 ttm_bo_type_kernel,
-				 XE_BO_FLAG_VRAM_IF_DGFX(tile) |
-				 XE_BO_FLAG_NEEDS_2M |
-				 XE_BO_FLAG_PINNED |
-				 XE_BO_FLAG_PINNED_LATE_RESTORE,
-				 exec);
-	if (IS_ERR(bo))
-		return PTR_ERR(bo);
-
-	err = xe_bo_pin(bo, exec);
-	xe_bo_unlock(bo);
-	if (unlikely(err)) {
-		xe_bo_put(bo);
-		return err;
+
+	/*
+	 * Open-code for now, since this is the only instance of
+	 * pinning without mapping.
+	 */
+	xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {.exclusive = true}, err) {
+		bo = xe_bo_create_locked(xe, tile, NULL,
+					 ALIGN(size, PAGE_SIZE),
+					 ttm_bo_type_kernel,
+					 XE_BO_FLAG_VRAM_IF_DGFX(tile) |
+					 XE_BO_FLAG_NEEDS_2M |
+					 XE_BO_FLAG_PINNED |
+					 XE_BO_FLAG_PINNED_LATE_RESTORE,
+					 &exec);
+		if (IS_ERR(bo)) {
+			drm_exec_retry_on_contention(&exec);
+			err = PTR_ERR(bo);
+			xe_validation_retry_on_oom(&ctx, &err);
+			return PTR_ERR(bo);
+		}
+
+		err = xe_bo_pin(bo, &exec);
+		xe_bo_unlock(bo);
+		if (err) {
+			xe_bo_put(bo);
+			drm_exec_retry_on_contention(&exec);
+			xe_validation_retry_on_oom(&ctx, &err);
+			return err;
+		}
 	}
+	if (err)
+		return err;
 
 	config->lmem_obj = bo;
 
-- 
2.50.1


  parent reply	other threads:[~2025-09-01 16:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-01 16:12 [PATCH v3 00/14] Driver-managed exhaustive eviction Thomas Hellström
2025-09-01 16:12 ` [PATCH v3 01/14] drm/xe: Pass down drm_exec context to validation Thomas Hellström
2025-09-01 16:12 ` [PATCH v3 02/14] drm/xe: Introduce an xe_validation wrapper around drm_exec Thomas Hellström
2025-09-01 16:12 ` [PATCH v3 03/14] drm/xe: Convert xe_bo_create_user() for exhaustive eviction Thomas Hellström
2025-09-01 16:12 ` [PATCH v3 04/14] drm/xe: Convert SVM validation " Thomas Hellström
2025-09-01 16:12 ` [PATCH v3 05/14] drm/xe: Convert existing drm_exec transactions " Thomas Hellström
2025-09-01 16:12 ` [PATCH v3 06/14] drm/xe: Convert the CPU fault handler " Thomas Hellström
2025-09-01 16:12 ` [PATCH v3 07/14] drm/xe/display: Convert __xe_pin_fb_vma() Thomas Hellström
2025-09-01 16:12 ` [PATCH v3 08/14] drm/xe: Convert xe_dma_buf.c for exhaustive eviction Thomas Hellström
2025-09-01 16:12 ` [PATCH v3 09/14] drm/xe: Rename ___xe_bo_create_locked() Thomas Hellström
2025-09-01 16:12 ` [PATCH v3 10/14] drm/xe: Convert xe_bo_create_pin_map_at() for exhaustive eviction Thomas Hellström
2025-09-01 16:12 ` [PATCH v3 11/14] drm/xe: Convert xe_bo_create_pin_map() " Thomas Hellström
2025-09-01 16:12 ` Thomas Hellström [this message]
2025-09-01 16:12 ` [PATCH v3 13/14] drm/xe: Convert psmi_alloc_object " Thomas Hellström
2025-09-01 16:12 ` [PATCH v3 14/14] drm/xe: Convert pinned suspend eviction " Thomas Hellström
2025-09-01 16:19 ` ✗ CI.checkpatch: warning for Driver-managed exhaustive eviction (rev3) Patchwork
2025-09-01 16:20 ` ✓ CI.KUnit: success " Patchwork
2025-09-01 16:53 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-01 20:38 ` ✗ Xe.CI.Full: failure " Patchwork
2025-09-02 10:36 ` [PATCH v3 00/14] Driver-managed exhaustive eviction Simon Richter

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=20250901161250.5279-13-thomas.hellstrom@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@intel.com \
    /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.