From: "Piórkowski, Piotr" <piotr.piorkowski@intel.com>
To: <intel-xe@lists.freedesktop.org>
Cc: "Piotr Piórkowski" <piotr.piorkowski@intel.com>,
"Michal Wajdeczko" <michal.wajdeczko@intel.com>
Subject: [PATCH v3 4/4] drm/xe/pf: Explicitly use shareable GuC IDs for VFs provisioning
Date: Thu, 27 Aug 2026 12:29:02 +0200 [thread overview]
Message-ID: <20260827102902.1236918-5-piotr.piorkowski@intel.com> (raw)
In-Reply-To: <20260827102902.1236918-1-piotr.piorkowski@intel.com>
From: Piotr Piórkowski <piotr.piorkowski@intel.com>
Switch PF VF-context provisioning to explicitly allocate IDs from
the dedicated shareable ID pool.
Also, lets remove the legacy GuC ID reservation API now that all VFs
provisioning paths use the shareable allocation helpers.
Assisted-by: Claude:claude-5-sonnet
Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
---
.../xe/tests/xe_gt_sriov_pf_config_kunit.c | 5 ++
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 22 +++++---
drivers/gpu/drm/xe/xe_guc_id_mgr.c | 56 ++-----------------
drivers/gpu/drm/xe/xe_guc_id_mgr.h | 2 -
4 files changed, 25 insertions(+), 60 deletions(-)
diff --git a/drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c b/drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c
index e6eaa94d4d30..4d72411cd570 100644
--- a/drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c
+++ b/drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c
@@ -68,6 +68,7 @@ static int pf_gt_config_test_init(struct kunit *test)
.graphics_verx100 = 2001,
};
struct xe_vram_region *vram;
+ struct xe_guc_id_mgr *idm;
struct xe_device *xe;
struct xe_gt *gt;
@@ -102,6 +103,10 @@ static int pf_gt_config_test_init(struct kunit *test)
pf_set_admin_mode(xe, false);
KUNIT_ASSERT_EQ(test, xe_sriov_init(xe), 0);
+ idm = >->uc.guc.submission_state.idm;
+ mutex_init(>->uc.guc.submission_state.lock);
+ KUNIT_ASSERT_EQ(test, xe_guc_id_mgr_init_shared(idm), 0);
+
/* more sanity checks */
KUNIT_EXPECT_EQ(test, GUC_ID_MAX + 1, SZ_64K);
KUNIT_EXPECT_EQ(test, GUC_NUM_DOORBELLS, SZ_256);
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 9445e5f32fe8..bd55617295fd 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
@@ -889,7 +889,7 @@ static int pf_set_spare_ctxs(struct xe_gt *gt, u32 spare)
xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
- if (spare > GUC_ID_MAX)
+ if (spare > xe_guc_id_mgr_max_shareable(>->uc.guc.submission_state.idm))
return -EINVAL;
if (spare && spare < pf_get_min_spare_ctxs(gt))
@@ -906,7 +906,7 @@ static int pf_reserve_ctxs(struct xe_gt *gt, u32 num)
struct xe_guc_id_mgr *idm = >->uc.guc.submission_state.idm;
unsigned int spare = pf_get_spare_ctxs(gt);
- return xe_guc_id_mgr_reserve(idm, num, spare);
+ return xe_guc_id_mgr_reserve_shareable(idm, num, spare);
}
static void pf_release_ctxs(struct xe_gt *gt, u32 start, u32 num)
@@ -933,7 +933,7 @@ static int pf_provision_vf_ctxs(struct xe_gt *gt, unsigned int vfid, u32 num_ctx
xe_gt_assert(gt, vfid);
- if (num_ctxs > GUC_ID_MAX)
+ if (num_ctxs > xe_guc_id_mgr_max_shareable(>->uc.guc.submission_state.idm))
return -EINVAL;
if (config->num_ctxs) {
@@ -1173,20 +1173,28 @@ static u32 pf_profile_fair_ctxs(struct xe_gt *gt, unsigned int num_vfs)
bool admin_only_pf = xe_sriov_pf_admin_only(gt_to_xe(gt));
if (admin_only_pf && num_vfs == 1)
- return ALIGN_DOWN(GUC_ID_MAX, SZ_1K);
+ return ALIGN_DOWN(xe_guc_id_mgr_max_shareable(>->uc.guc.submission_state.idm),
+ SZ_1K);
- return rounddown_pow_of_two(GUC_ID_MAX / num_vfs);
+ return rounddown_pow_of_two(xe_guc_id_mgr_max_shareable(>->uc.guc.submission_state.idm) /
+ num_vfs);
}
static u32 pf_estimate_fair_ctxs(struct xe_gt *gt, unsigned int num_vfs)
{
struct xe_guc_id_mgr *idm = >->uc.guc.submission_state.idm;
+ u32 max_shareable = xe_guc_id_mgr_max_shareable(idm);
u32 spare = pf_get_spare_ctxs(gt);
- u32 fair = (xe_guc_id_mgr_max_usable(idm) - spare) / num_vfs;
+ u32 fair;
int ret;
+ if (max_shareable <= spare)
+ return 0;
+
+ fair = (max_shareable - spare) / num_vfs;
+
for (; fair; --fair) {
- ret = xe_guc_id_mgr_reserve(idm, fair * num_vfs, spare);
+ ret = xe_guc_id_mgr_reserve_shareable(idm, fair * num_vfs, spare);
if (ret < 0)
continue;
xe_guc_id_mgr_release(idm, ret, fair * num_vfs);
diff --git a/drivers/gpu/drm/xe/xe_guc_id_mgr.c b/drivers/gpu/drm/xe/xe_guc_id_mgr.c
index 5675325665fb..20ce16bda973 100644
--- a/drivers/gpu/drm/xe/xe_guc_id_mgr.c
+++ b/drivers/gpu/drm/xe/xe_guc_id_mgr.c
@@ -124,9 +124,13 @@ static int idm_init(struct xe_guc_id_mgr *idm, unsigned int usable, unsigned int
}
/**
- * xe_guc_id_mgr_init() - Initialize GuC context ID manager in native mode.
+ * xe_guc_id_mgr_init() - Initialize GuC ID manager for native.
* @idm: the &xe_guc_id_mgr to initialize
*
+ * This function initializes the GuC ID manager to manage the full range of
+ * GuC context IDs (0..GUC_ID_MAX - 1) for use by the GuC submission code.
+ * No GuC context IDs will be reserved for sharing with VFs.
+ *
* Can only be called when the device is not in SR-IOV mode.
*
* Return: 0 on success or a negative error code on failure.
@@ -287,37 +291,6 @@ static int idm_reserve_chunk_shareable_locked(struct xe_guc_id_mgr *idm, unsigne
return id;
}
-static int idm_reserve_chunk_locked(struct xe_guc_id_mgr *idm, unsigned int count,
- unsigned int retain)
-{
- unsigned int total = idm_total(idm);
- int id;
-
- idm_assert(idm, count);
- lockdep_assert_held(idm_mutex(idm));
-
- if (!total)
- return -ENODATA;
-
- if (retain) {
- unsigned int used = bitmap_weight(idm->bitmap, total);
-
- if (used + count + retain > total)
- return -EDQUOT;
-
- id = idm_find_last_zero_area_in_range(idm->bitmap, 0, total, count);
- } else {
- id = bitmap_find_next_zero_area(idm->bitmap, total, 0, count, 0);
- }
-
- if (id >= total)
- return -ENOSPC;
-
- bitmap_set(idm->bitmap, id, count);
-
- return id;
-}
-
static void idm_release_chunk_locked(struct xe_guc_id_mgr *idm,
unsigned int start, unsigned int count)
{
@@ -475,25 +448,6 @@ int xe_guc_id_mgr_reserve_shareable(struct xe_guc_id_mgr *idm, unsigned int coun
return idm_reserve_chunk_shareable_locked(idm, count, spare);
}
-int xe_guc_id_mgr_reserve_locked(struct xe_guc_id_mgr *idm, unsigned int count)
-{
- return idm_reserve_chunk_locked(idm, count, 0);
-}
-
-int xe_guc_id_mgr_reserve(struct xe_guc_id_mgr *idm, unsigned int count,
- unsigned int retain)
-{
- int ret;
-
- idm_assert(idm, count);
- idm_assert(idm, retain);
-
- guard(mutex)(idm_mutex(idm));
- ret = idm_reserve_chunk_locked(idm, count, retain);
-
- return ret;
-}
-
/**
* xe_guc_id_mgr_release() - Release one or more GuC context IDs.
* @idm: the &xe_guc_id_mgr
diff --git a/drivers/gpu/drm/xe/xe_guc_id_mgr.h b/drivers/gpu/drm/xe/xe_guc_id_mgr.h
index ed9970829a93..844d68440b0a 100644
--- a/drivers/gpu/drm/xe/xe_guc_id_mgr.h
+++ b/drivers/gpu/drm/xe/xe_guc_id_mgr.h
@@ -31,8 +31,6 @@ int xe_guc_id_mgr_reserve_shareable_locked(struct xe_guc_id_mgr *idm, unsigned i
unsigned int spare);
int xe_guc_id_mgr_reserve_shareable(struct xe_guc_id_mgr *idm, unsigned int count,
unsigned int spare);
-int xe_guc_id_mgr_reserve_locked(struct xe_guc_id_mgr *idm, unsigned int count);
-int xe_guc_id_mgr_reserve(struct xe_guc_id_mgr *idm, unsigned int count, unsigned int retain);
void xe_guc_id_mgr_release_locked(struct xe_guc_id_mgr *idm, unsigned int id, unsigned int count);
int xe_guc_id_mgr_release_usable_locked(struct xe_guc_id_mgr *idm, unsigned int id,
unsigned int count);
--
2.34.1
next prev parent reply other threads:[~2026-08-27 10:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 10:28 [PATCH v3 0/4] Split GuC ID space into usable and shareable pools Piórkowski, Piotr
2026-08-27 10:28 ` [PATCH v3 1/4] drm/xe/guc: Split GuC ID manager " Piórkowski, Piotr
2026-08-27 10:29 ` [PATCH v3 2/4] drm/xe/kunit: Extend GuC ID manager split-pool coverage Piórkowski, Piotr
2026-08-27 10:44 ` sashiko-bot
2026-08-27 10:29 ` [PATCH v3 3/4] drm/xe/guc: Start use explicitly usable GuC IDs for for submission Piórkowski, Piotr
2026-08-27 10:29 ` Piórkowski, Piotr [this message]
2026-08-27 11:04 ` ✓ CI.KUnit: success for Split GuC ID space into usable and shareable pools (rev3) Patchwork
2026-08-27 11:45 ` ✓ Xe.CI.BAT: " Patchwork
2026-08-27 12:52 ` ✓ Xe.CI.FULL: " 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=20260827102902.1236918-5-piotr.piorkowski@intel.com \
--to=piotr.piorkowski@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=michal.wajdeczko@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox