All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Piotr Piórkowski" <piotr.piorkowski@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 2/3] drm/xe/pf: Add _locked variant of the contexts bulk config function
Date: Fri, 7 Aug 2026 09:52:36 +0200	[thread overview]
Message-ID: <20260807075236.b3llemip3o6jwr2l@intel.com> (raw)
In-Reply-To: <20260805154733.604-3-michal.wajdeczko@intel.com>

Michal Wajdeczko <michal.wajdeczko@intel.com> wrote on śro [2026-sie-05 17:47:32 +0200]:
> We will soon want to provision all VFs, including their GuC context
> IDs config, in one step. Split existing GuC IDs bulk configuration
> function into two functions, one of which will expect the master
> lock to be already taken. Use this new function in the fair GuC IDs
> provisioning.
> 
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 37 ++++++++++++++++------
>  drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h |  2 ++
>  2 files changed, 29 insertions(+), 10 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 47623315d615..4976d8c018ce 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -1116,7 +1116,7 @@ static int pf_config_bulk_set_u32_done(struct xe_gt *gt, unsigned int first, uns
>  }
>  
>  /**
> - * xe_gt_sriov_pf_config_bulk_set_ctxs - Provision many VFs with GuC context IDs.
> + * xe_gt_sriov_pf_config_bulk_set_ctxs_locked() - Provision many VFs with GuC context IDs.
>   * @gt: the &xe_gt
>   * @vfid: starting VF identifier
>   * @num_vfs: number of VFs to provision
> @@ -1126,30 +1126,48 @@ static int pf_config_bulk_set_u32_done(struct xe_gt *gt, unsigned int first, uns
>   *
>   * Return: 0 on success or a negative error code on failure.
>   */
> -int xe_gt_sriov_pf_config_bulk_set_ctxs(struct xe_gt *gt, unsigned int vfid,
> -					unsigned int num_vfs, u32 num_ctxs)
> +int xe_gt_sriov_pf_config_bulk_set_ctxs_locked(struct xe_gt *gt, unsigned int vfid,
> +					       unsigned int num_vfs, u32 num_ctxs)
>  {
>  	unsigned int n;
>  	int err = 0;
>  
>  	xe_gt_assert(gt, vfid);
> +	lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
>  
>  	if (!num_vfs)
>  		return 0;
>  
> -	mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
>  	for (n = vfid; n < vfid + num_vfs; n++) {
>  		err = pf_provision_vf_ctxs(gt, n, num_ctxs);
>  		if (err)
>  			break;
>  	}
> -	mutex_unlock(xe_gt_sriov_pf_master_mutex(gt));
>  
>  	return pf_config_bulk_set_u32_done(gt, vfid, num_vfs, num_ctxs,
> -					   xe_gt_sriov_pf_config_get_ctxs,
> +					   pf_get_vf_config_ctxs,
>  					   "GuC context IDs", no_unit, n, err);
>  }
>  
> +/**
> + * xe_gt_sriov_pf_config_bulk_set_ctxs() - Provision many VFs with GuC context IDs.
> + * @gt: the &xe_gt
> + * @vfid: starting VF identifier
> + * @num_vfs: number of VFs to provision
> + * @num_ctxs: requested number of GuC contexts IDs (0 to release)
> + *
> + * This function can only be called on PF.
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> +int xe_gt_sriov_pf_config_bulk_set_ctxs(struct xe_gt *gt, unsigned int vfid,
> +					unsigned int num_vfs, u32 num_ctxs)
> +{
> +	guard(mutex)(xe_gt_sriov_pf_master_mutex(gt));
> +
> +	return xe_gt_sriov_pf_config_bulk_set_ctxs_locked(gt, vfid, num_vfs, num_ctxs);
> +}
> +
>  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));
> @@ -1198,10 +1216,9 @@ int xe_gt_sriov_pf_config_set_fair_ctxs(struct xe_gt *gt, unsigned int vfid,
>  	xe_gt_assert(gt, vfid);
>  	xe_gt_assert(gt, num_vfs);
>  
> -	mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
> +	guard(mutex)(xe_gt_sriov_pf_master_mutex(gt));
> +
>  	fair = pf_estimate_fair_ctxs(gt, num_vfs);
> -	mutex_unlock(xe_gt_sriov_pf_master_mutex(gt));
> -
>  	if (!fair)
>  		return -ENOSPC;
>  
> @@ -1210,7 +1227,7 @@ int xe_gt_sriov_pf_config_set_fair_ctxs(struct xe_gt *gt, unsigned int vfid,
>  		xe_gt_sriov_info(gt, "Using non-profile provisioning (%s %u vs %u)\n",
>  				 "GuC context IDs", fair, profile);
>  
> -	return xe_gt_sriov_pf_config_bulk_set_ctxs(gt, vfid, num_vfs, fair);
> +	return xe_gt_sriov_pf_config_bulk_set_ctxs_locked(gt, vfid, num_vfs, fair);
>  }
>  
>  static u32 pf_get_min_spare_dbs(struct xe_gt *gt)
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h
> index 3741202908ee..a14ca7bf7e4d 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h
> @@ -26,6 +26,8 @@ int xe_gt_sriov_pf_config_set_ctxs(struct xe_gt *gt, unsigned int vfid, u32 num_
>  int xe_gt_sriov_pf_config_set_fair_ctxs(struct xe_gt *gt, unsigned int vfid, unsigned int num_vfs);
>  int xe_gt_sriov_pf_config_bulk_set_ctxs(struct xe_gt *gt, unsigned int vfid, unsigned int num_vfs,
>  					u32 num_ctxs);
> +int xe_gt_sriov_pf_config_bulk_set_ctxs_locked(struct xe_gt *gt, unsigned int vfid,
> +					       unsigned int num_vfs, u32 num_ctxs);
>  
>  u32 xe_gt_sriov_pf_config_get_dbs(struct xe_gt *gt, unsigned int vfid);
>  int xe_gt_sriov_pf_config_set_dbs(struct xe_gt *gt, unsigned int vfid, u32 num_dbs);
> -- 
> 2.47.1
> 


Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>


-- 

  reply	other threads:[~2026-08-07  7:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05 15:47 [PATCH 0/3] drm/xe/pf: Add _locked variants of some config functions Michal Wajdeczko
2026-08-05 15:47 ` [PATCH 1/3] drm/xe/pf: Add _locked variant of the GGTT bulk config function Michal Wajdeczko
2026-08-07  7:40   ` Piotr Piórkowski
2026-08-05 15:47 ` [PATCH 2/3] drm/xe/pf: Add _locked variant of the contexts " Michal Wajdeczko
2026-08-07  7:52   ` Piotr Piórkowski [this message]
2026-08-05 15:47 ` [PATCH 3/3] drm/xe/pf: Add _locked variant of the doorbells " Michal Wajdeczko
2026-08-07  7:32   ` K V P, Satyanarayana
2026-08-07 16:48   ` [PATCH v2 " Michal Wajdeczko
2026-08-10  3:21     ` K V P, Satyanarayana
2026-08-05 16:00 ` ✓ CI.KUnit: success for drm/xe/pf: Add _locked variants of some config functions Patchwork
2026-08-05 16:52 ` ✓ Xe.CI.BAT: " Patchwork
2026-08-06  4:37 ` ✓ Xe.CI.FULL: " Patchwork
2026-08-07 16:55 ` ✓ CI.KUnit: success for drm/xe/pf: Add _locked variants of some config functions (rev2) Patchwork
2026-08-07 17:36 ` ✓ Xe.CI.BAT: " Patchwork
2026-08-08  2:06 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-08-10  8:44   ` Michal Wajdeczko

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=20260807075236.b3llemip3o6jwr2l@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 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.