From: "Bernatowicz, Marcin" <marcin.bernatowicz@linux.intel.com>
To: "Piórkowski, Piotr" <piotr.piorkowski@intel.com>,
intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v1 3/5] drm/xe/pf: Add locked variant of the fair VFs provisioning
Date: Tue, 10 Nov 2026 11:47:13 +0100 [thread overview]
Message-ID: <0ec4bf5a-ef46-485f-89f0-9cc5073817f3@linux.intel.com> (raw)
In-Reply-To: <20261027103009.1259199-4-piotr.piorkowski@intel.com>
LGTM,
Reviewed-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
On 10/27/2026 11:30 AM, Piórkowski, Piotr wrote:
> From: Piotr Piórkowski <piotr.piorkowski@intel.com>
>
> We will want to provision the VFs with fair resources while already
> holding the master mutex, to make the provisioning mode check and the
> actual provisioning atomic.
>
> Convert the per-resource fair provisioning functions, which are only
> called from xe_gt_sriov_pf_config_set_fair(), into the _locked variants
> and add xe_gt_sriov_pf_config_set_fair_locked(). The existing function
> now takes the master mutex once for all resources, instead of taking
> it separately for each resource.
>
> Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
> ---
> drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 71 +++++++++++++++-------
> drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h | 15 +++--
> 2 files changed, 58 insertions(+), 28 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 0a47458e5bf2..c8ab4138f6a8 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -774,17 +774,18 @@ static u64 pf_profile_fair_ggtt(struct xe_gt *gt, unsigned int num_vfs)
> }
>
> /**
> - * xe_gt_sriov_pf_config_set_fair_ggtt - Provision many VFs with fair GGTT.
> + * xe_gt_sriov_pf_config_set_fair_ggtt_locked - Provision many VFs with fair GGTT.
> * @gt: the &xe_gt (can't be media)
> * @vfid: starting VF identifier (can't be 0)
> * @num_vfs: number of VFs to provision
> *
> + * The caller must hold the master PF mutex.
> * 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_set_fair_ggtt(struct xe_gt *gt, unsigned int vfid,
> - unsigned int num_vfs)
> +int xe_gt_sriov_pf_config_set_fair_ggtt_locked(struct xe_gt *gt, unsigned int vfid,
> + unsigned int num_vfs)
> {
> u64 profile = pf_profile_fair_ggtt(gt, num_vfs);
> u64 fair;
> @@ -793,7 +794,7 @@ int xe_gt_sriov_pf_config_set_fair_ggtt(struct xe_gt *gt, unsigned int vfid,
> xe_gt_assert(gt, num_vfs);
> xe_gt_assert(gt, xe_gt_is_main_type(gt));
>
> - guard(mutex)(xe_gt_sriov_pf_master_mutex(gt));
> + lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
>
> fair = pf_estimate_fair_ggtt(gt, num_vfs);
> if (!fair)
> @@ -1205,17 +1206,18 @@ static u32 pf_estimate_fair_ctxs(struct xe_gt *gt, unsigned int num_vfs)
> }
>
> /**
> - * xe_gt_sriov_pf_config_set_fair_ctxs - Provision many VFs with fair GuC context IDs.
> + * xe_gt_sriov_pf_config_set_fair_ctxs_locked - Provision many VFs with fair GuC context IDs.
> * @gt: the &xe_gt
> * @vfid: starting VF identifier (can't be 0)
> * @num_vfs: number of VFs to provision (can't be 0)
> *
> + * The caller must hold the master PF mutex.
> * 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_set_fair_ctxs(struct xe_gt *gt, unsigned int vfid,
> - unsigned int num_vfs)
> +int xe_gt_sriov_pf_config_set_fair_ctxs_locked(struct xe_gt *gt, unsigned int vfid,
> + unsigned int num_vfs)
> {
> u32 profile = pf_profile_fair_ctxs(gt, num_vfs);
> u32 fair;
> @@ -1223,7 +1225,7 @@ 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);
>
> - guard(mutex)(xe_gt_sriov_pf_master_mutex(gt));
> + lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
>
> fair = pf_estimate_fair_ctxs(gt, num_vfs);
> if (!fair)
> @@ -1487,17 +1489,18 @@ static u32 pf_estimate_fair_dbs(struct xe_gt *gt, unsigned int num_vfs)
> }
>
> /**
> - * xe_gt_sriov_pf_config_set_fair_dbs - Provision many VFs with fair GuC doorbell IDs.
> + * xe_gt_sriov_pf_config_set_fair_dbs_locked - Provision many VFs with fair GuC doorbell IDs.
> * @gt: the &xe_gt
> * @vfid: starting VF identifier (can't be 0)
> * @num_vfs: number of VFs to provision (can't be 0)
> *
> + * The caller must hold the master PF mutex.
> * 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_set_fair_dbs(struct xe_gt *gt, unsigned int vfid,
> - unsigned int num_vfs)
> +int xe_gt_sriov_pf_config_set_fair_dbs_locked(struct xe_gt *gt, unsigned int vfid,
> + unsigned int num_vfs)
> {
> u32 profile = pf_profile_fair_dbs(gt, num_vfs);
> u32 fair;
> @@ -1505,7 +1508,7 @@ int xe_gt_sriov_pf_config_set_fair_dbs(struct xe_gt *gt, unsigned int vfid,
> xe_gt_assert(gt, vfid);
> xe_gt_assert(gt, num_vfs);
>
> - guard(mutex)(xe_gt_sriov_pf_master_mutex(gt));
> + lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
>
> fair = pf_estimate_fair_dbs(gt, num_vfs);
> if (!fair)
> @@ -2062,17 +2065,18 @@ static bool pf_needs_provision_lmem(struct xe_gt *gt, unsigned int first_vf,
> }
>
> /**
> - * xe_gt_sriov_pf_config_set_fair_lmem - Provision many VFs with fair LMEM.
> + * xe_gt_sriov_pf_config_set_fair_lmem_locked - Provision many VFs with fair LMEM.
> * @gt: the &xe_gt (can't be media)
> * @vfid: starting VF identifier (can't be 0)
> * @num_vfs: number of VFs to provision (can't be 0)
> *
> + * The caller must hold the master PF mutex.
> * 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_set_fair_lmem(struct xe_gt *gt, unsigned int vfid,
> - unsigned int num_vfs)
> +int xe_gt_sriov_pf_config_set_fair_lmem_locked(struct xe_gt *gt, unsigned int vfid,
> + unsigned int num_vfs)
> {
> u64 profile;
> u64 fair;
> @@ -2084,7 +2088,7 @@ int xe_gt_sriov_pf_config_set_fair_lmem(struct xe_gt *gt, unsigned int vfid,
> if (!xe_device_has_lmtt(gt_to_xe(gt)))
> return 0;
>
> - guard(mutex)(xe_gt_sriov_pf_master_mutex(gt));
> + lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
>
> if (!pf_needs_provision_lmem(gt, vfid, num_vfs))
> return 0;
> @@ -2103,17 +2107,18 @@ int xe_gt_sriov_pf_config_set_fair_lmem(struct xe_gt *gt, unsigned int vfid,
> }
>
> /**
> - * xe_gt_sriov_pf_config_set_fair - Provision many VFs with fair resources.
> + * xe_gt_sriov_pf_config_set_fair_locked() - Provision many VFs with fair resources.
> * @gt: the &xe_gt
> * @vfid: starting VF identifier (can't be 0)
> * @num_vfs: number of VFs to provision (can't be 0)
> *
> + * The caller must hold the master PF mutex.
> * 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_set_fair(struct xe_gt *gt, unsigned int vfid,
> - unsigned int num_vfs)
> +int xe_gt_sriov_pf_config_set_fair_locked(struct xe_gt *gt, unsigned int vfid,
> + unsigned int num_vfs)
> {
> int result = 0;
> int err;
> @@ -2121,20 +2126,40 @@ int xe_gt_sriov_pf_config_set_fair(struct xe_gt *gt, unsigned int vfid,
> xe_gt_assert(gt, vfid);
> xe_gt_assert(gt, num_vfs);
>
> + lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
> +
> if (xe_gt_is_main_type(gt)) {
> - err = xe_gt_sriov_pf_config_set_fair_ggtt(gt, vfid, num_vfs);
> + err = xe_gt_sriov_pf_config_set_fair_ggtt_locked(gt, vfid, num_vfs);
> result = result ?: err;
> - err = xe_gt_sriov_pf_config_set_fair_lmem(gt, vfid, num_vfs);
> + err = xe_gt_sriov_pf_config_set_fair_lmem_locked(gt, vfid, num_vfs);
> result = result ?: err;
> }
> - err = xe_gt_sriov_pf_config_set_fair_ctxs(gt, vfid, num_vfs);
> + err = xe_gt_sriov_pf_config_set_fair_ctxs_locked(gt, vfid, num_vfs);
> result = result ?: err;
> - err = xe_gt_sriov_pf_config_set_fair_dbs(gt, vfid, num_vfs);
> + err = xe_gt_sriov_pf_config_set_fair_dbs_locked(gt, vfid, num_vfs);
> result = result ?: err;
>
> return result;
> }
>
> +/**
> + * xe_gt_sriov_pf_config_set_fair - Provision many VFs with fair resources.
> + * @gt: the &xe_gt
> + * @vfid: starting VF identifier (can't be 0)
> + * @num_vfs: number of VFs to provision (can't be 0)
> + *
> + * 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_set_fair(struct xe_gt *gt, unsigned int vfid,
> + unsigned int num_vfs)
> +{
> + guard(mutex)(xe_gt_sriov_pf_master_mutex(gt));
> +
> + return xe_gt_sriov_pf_config_set_fair_locked(gt, vfid, num_vfs);
> +}
> +
> static const char *exec_quantum_unit(u32 exec_quantum)
> {
> return exec_quantum ? "ms" : "(infinity)";
> 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 3e10697d2174..69841b0fcddb 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h
> @@ -14,8 +14,8 @@ struct xe_gt;
>
> u64 xe_gt_sriov_pf_config_get_ggtt(struct xe_gt *gt, unsigned int vfid);
> int xe_gt_sriov_pf_config_set_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size);
> -int xe_gt_sriov_pf_config_set_fair_ggtt(struct xe_gt *gt,
> - unsigned int vfid, unsigned int num_vfs);
> +int xe_gt_sriov_pf_config_set_fair_ggtt_locked(struct xe_gt *gt,
> + unsigned int vfid, unsigned int num_vfs);
> int xe_gt_sriov_pf_config_bulk_set_ggtt(struct xe_gt *gt,
> unsigned int vfid, unsigned int num_vfs, u64 size);
> int xe_gt_sriov_pf_config_bulk_set_ggtt_locked(struct xe_gt *gt,
> @@ -23,7 +23,8 @@ int xe_gt_sriov_pf_config_bulk_set_ggtt_locked(struct xe_gt *gt,
>
> u32 xe_gt_sriov_pf_config_get_ctxs(struct xe_gt *gt, unsigned int vfid);
> int xe_gt_sriov_pf_config_set_ctxs(struct xe_gt *gt, unsigned int vfid, u32 num_ctxs);
> -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_set_fair_ctxs_locked(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,
> @@ -31,7 +32,8 @@ int xe_gt_sriov_pf_config_bulk_set_ctxs_locked(struct xe_gt *gt, unsigned int vf
>
> 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);
> -int xe_gt_sriov_pf_config_set_fair_dbs(struct xe_gt *gt, unsigned int vfid, unsigned int num_vfs);
> +int xe_gt_sriov_pf_config_set_fair_dbs_locked(struct xe_gt *gt, unsigned int vfid,
> + unsigned int num_vfs);
> int xe_gt_sriov_pf_config_bulk_set_dbs(struct xe_gt *gt, unsigned int vfid, unsigned int num_vfs,
> u32 num_dbs);
> int xe_gt_sriov_pf_config_bulk_set_dbs_locked(struct xe_gt *gt, unsigned int vfid,
> @@ -39,7 +41,8 @@ int xe_gt_sriov_pf_config_bulk_set_dbs_locked(struct xe_gt *gt, unsigned int vfi
>
> u64 xe_gt_sriov_pf_config_get_lmem(struct xe_gt *gt, unsigned int vfid);
> int xe_gt_sriov_pf_config_set_lmem(struct xe_gt *gt, unsigned int vfid, u64 size);
> -int xe_gt_sriov_pf_config_set_fair_lmem(struct xe_gt *gt, unsigned int vfid, unsigned int num_vfs);
> +int xe_gt_sriov_pf_config_set_fair_lmem_locked(struct xe_gt *gt, unsigned int vfid,
> + unsigned int num_vfs);
> int xe_gt_sriov_pf_config_bulk_set_lmem(struct xe_gt *gt, unsigned int vfid, unsigned int num_vfs,
> u64 size);
> u64 xe_gt_sriov_pf_config_get_lmem_locked(struct xe_gt *gt, unsigned int vfid);
> @@ -89,6 +92,8 @@ int xe_gt_sriov_pf_config_set_threshold(struct xe_gt *gt, unsigned int vfid,
> int xe_gt_sriov_pf_config_set_fair_sched(struct xe_gt *gt, unsigned int num_vfs);
> int xe_gt_sriov_pf_config_set_fair_sched_locked(struct xe_gt *gt, unsigned int num_vfs);
> int xe_gt_sriov_pf_config_set_fair(struct xe_gt *gt, unsigned int vfid, unsigned int num_vfs);
> +int xe_gt_sriov_pf_config_set_fair_locked(struct xe_gt *gt, unsigned int vfid,
> + unsigned int num_vfs);
> int xe_gt_sriov_pf_config_sanitize(struct xe_gt *gt, unsigned int vfid, long timeout);
> int xe_gt_sriov_pf_config_release(struct xe_gt *gt, unsigned int vfid, bool force);
> int xe_gt_sriov_pf_config_release_locked(struct xe_gt *gt, unsigned int vfid, bool force);
next prev parent reply other threads:[~2026-11-10 10:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 10:30 [PATCH v1 0/5] Prepare SR-IOV provisioning for VGPU profiles Piórkowski, Piotr
2026-10-27 10:30 ` [PATCH v1 1/5] drm/xe/pf: Split the bulk priority provisioning function Piórkowski, Piotr
2026-11-10 10:44 ` Bernatowicz, Marcin
2026-10-27 10:30 ` [PATCH v1 2/5] drm/xe/pf: Change provisioning mode under mutex Piórkowski, Piotr
2026-11-10 10:46 ` Bernatowicz, Marcin
2026-10-27 10:30 ` [PATCH v1 3/5] drm/xe/pf: Add locked variant of the fair VFs provisioning Piórkowski, Piotr
2026-11-10 10:47 ` Bernatowicz, Marcin [this message]
2026-10-27 10:30 ` [PATCH v1 4/5] drm/xe/pf: Provision VFs under mutex Piórkowski, Piotr
2026-11-10 10:48 ` Bernatowicz, Marcin
2026-10-27 10:30 ` [PATCH v1 5/5] drm/xe/pf: Split the provisioning mode change function Piórkowski, Piotr
2026-11-10 10:49 ` Bernatowicz, Marcin
2026-10-27 10:39 ` ✓ CI.KUnit: success for Prepare SR-IOV provisioning for VGPU profiles Patchwork
2026-10-27 11:15 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-27 13:07 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-11-10 12:36 ` Piotr Piórkowski
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=0ec4bf5a-ef46-485f-89f0-9cc5073817f3@linux.intel.com \
--to=marcin.bernatowicz@linux.intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=piotr.piorkowski@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