Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "K V P, Satyanarayana" <satyanarayana.k.v.p@intel.com>
To: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v5 4/4] drm/xe/pf: Explicitly use shareable GuC IDs for VFs provisioning
Date: Thu, 8 Oct 2026 11:46:29 +0530	[thread overview]
Message-ID: <be046081-e302-4592-8813-936f22c14f48@intel.com> (raw)
In-Reply-To: <20261005085132.3720685-5-piotr.piorkowski@intel.com>

[-- Attachment #1: Type: text/plain, Size: 8034 bytes --]


On 05-Oct-26 2:21 PM, Piórkowski, Piotr wrote:
> 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.
>
> v2: Use local variable for max shareable GuC IDs in fair profile (Satya)
>
> 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    | 21 ++++---
>   drivers/gpu/drm/xe/xe_guc_id_mgr.c            | 56 ++-----------------
>   drivers/gpu/drm/xe/xe_guc_id_mgr.h            |  2 -
>   4 files changed, 24 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 e6eaa94d4d30f..4d72411cd570c 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 = &gt->uc.guc.submission_state.idm;
> +	mutex_init(&gt->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 de1ac58e31412..0a47458e5bf20 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(&gt->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 = &gt->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(&gt->uc.guc.submission_state.idm))
>   		return -EINVAL;
>   
>   	if (config->num_ctxs) {
> @@ -1170,23 +1170,30 @@ int xe_gt_sriov_pf_config_bulk_set_ctxs(struct xe_gt *gt, unsigned int vfid,
>   
>   static u32 pf_profile_fair_ctxs(struct xe_gt *gt, unsigned int num_vfs)
>   {
> +	u32 max_shareable = xe_guc_id_mgr_max_shareable(&gt->uc.guc.submission_state.idm);
>   	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(max_shareable, SZ_1K);
>   
> -	return rounddown_pow_of_two(GUC_ID_MAX / num_vfs);
> +	return rounddown_pow_of_two(max_shareable / num_vfs);
>   }
>   
>   static u32 pf_estimate_fair_ctxs(struct xe_gt *gt, unsigned int num_vfs)
>   {
>   	struct xe_guc_id_mgr *idm = &gt->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 
> dc918221b78de..6cd73009177af 100644 --- 
> a/drivers/gpu/drm/xe/xe_guc_id_mgr.c +++ 
> b/drivers/gpu/drm/xe/xe_guc_id_mgr.c @@ -120,9 +120,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. @@ -283,37 +287,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)
>   {
> @@ -471,25 +444,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 ed9970829a939..844d68440b0af 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);

LGTM.

Reviewed-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>

[-- Attachment #2: Type: text/html, Size: 10127 bytes --]

  reply	other threads:[~2026-10-08  6:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05  8:51 [PATCH v5 0/4] Split GuC ID space into usable and shareable pools Piórkowski, Piotr
2026-10-05  8:51 ` [PATCH v5 1/4] drm/xe/guc: Split GuC ID manager " Piórkowski, Piotr
2026-10-06  8:35   ` K V P, Satyanarayana
2026-10-05  8:51 ` [PATCH v5 2/4] drm/xe/kunit: Extend GuC ID manager split-pool coverage Piórkowski, Piotr
2026-10-05  9:04   ` sashiko-bot
2026-10-05  8:51 ` [PATCH v5 3/4] drm/xe/guc: Start use explicitly usable GuC IDs for for submission Piórkowski, Piotr
2026-10-08  6:04   ` K V P, Satyanarayana
2026-10-05  8:51 ` [PATCH v5 4/4] drm/xe/pf: Explicitly use shareable GuC IDs for VFs provisioning Piórkowski, Piotr
2026-10-08  6:16   ` K V P, Satyanarayana [this message]
2026-10-05  9:23 ` ✓ CI.KUnit: success for Split GuC ID space into usable and shareable pools (rev5) Patchwork
2026-10-05 10:11 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-05 14:02 ` ✓ 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=be046081-e302-4592-8813-936f22c14f48@intel.com \
    --to=satyanarayana.k.v.p@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