Intel-XE Archive on 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 8/9] drm/xe/pf: Skip VRAM auto-provisioning if already provisioned
Date: Mon, 16 Feb 2026 17:59:38 +0100	[thread overview]
Message-ID: <20260216165938.tndepv3wsjhtwpzi@intel.com> (raw)
In-Reply-To: <20260215203323.595-9-michal.wajdeczko@intel.com>

Michal Wajdeczko <michal.wajdeczko@intel.com> wrote on nie [2026-lut-15 21:33:22 +0100]:
> In case VF's VRAM provisioning using sysfs is done by the admin
> prior to VFs enabling, this provisioning will be lost as PF will
> run VRAM auto-provisioning anyway. To avoid that skip this auto-
> provisioning if any VF has been already provisioned with VRAM.
> 
> To help admin find any mistakes, add diagnostics messages about
> which VFs were provisioned with VRAM and which were missed.
> 
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 56 ++++++++++++++++++++++
>  1 file changed, 56 insertions(+)
> 
> 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 1a9f3b85526c..b1eccd6712f4 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -1939,6 +1939,59 @@ static u64 pf_profile_fair_lmem(struct xe_gt *gt, unsigned int num_vfs)
>  	return ALIGN_DOWN(fair, alignment);
>  }
>  
> +static void __pf_show_provisioning_lmem(struct xe_gt *gt, unsigned int first_vf,
> +					unsigned int num_vfs, bool provisioned)
> +{
> +	unsigned int allvfs = 1 + xe_gt_sriov_pf_get_totalvfs(gt); /* PF plus VFs */
> +	unsigned long *bitmap __free(bitmap) = bitmap_zalloc(allvfs, GFP_KERNEL);
> +	unsigned int weight;
> +	unsigned int n;
> +
> +	if (!bitmap)
> +		return;
> +
> +	for (n = first_vf; n < first_vf + num_vfs; n++) {
> +		if (!!pf_get_vf_config_lmem(gt, VFID(n)) == provisioned)
> +			bitmap_set(bitmap, n, 1);
> +	}
> +
> +	weight = bitmap_weight(bitmap, allvfs);
> +	if (!weight)
> +		return;
> +
> +	xe_gt_sriov_info(gt, "VF%s%*pbl %s provisioned with VRAM\n",
> +			 weight > 1 ? "s " : "", allvfs, bitmap,
> +			 provisioned ? "already" : "not");
> +}
> +
> +static void pf_show_all_provisioned_lmem(struct xe_gt *gt)
> +{
> +	__pf_show_provisioning_lmem(gt, 1, xe_gt_sriov_pf_get_totalvfs(gt), true);

NIT: In my opinion, I would give it here VFID(1)
This makes it so we don't have a magic number here.

> +}
> +
> +static void pf_show_unprovisioned_lmem(struct xe_gt *gt, unsigned int first_vf,
> +				       unsigned int num_vfs)
> +{
> +	__pf_show_provisioning_lmem(gt, first_vf, num_vfs, false);
> +}
> +
> +static bool pf_needs_provision_lmem(struct xe_gt *gt, unsigned int first_vf,
> +				    unsigned int num_vfs)
> +{
> +	unsigned int vfid;
> +
> +	for (vfid = first_vf; vfid < first_vf + num_vfs; vfid++) {
> +		if (pf_get_vf_config_lmem(gt, vfid)) {
> +			pf_show_all_provisioned_lmem(gt);
> +			pf_show_unprovisioned_lmem(gt, first_vf, num_vfs);
> +			return false;
> +		}
> +	}
> +
> +	pf_show_all_provisioned_lmem(gt);
> +	return true;
> +}
> +
>  /**
>   * xe_gt_sriov_pf_config_set_fair_lmem - Provision many VFs with fair LMEM.
>   * @gt: the &xe_gt (can't be media)
> @@ -1964,6 +2017,9 @@ int xe_gt_sriov_pf_config_set_fair_lmem(struct xe_gt *gt, unsigned int vfid,
>  
>  	guard(mutex)(xe_gt_sriov_pf_master_mutex(gt));
>  
> +	if (!pf_needs_provision_lmem(gt, vfid, num_vfs))
> +		return 0;
> +
>  	fair = pf_estimate_fair_lmem(gt, num_vfs);
>  	if (!fair)
>  		return -ENOSPC;


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

> -- 
> 2.47.1
> 

-- 

  reply	other threads:[~2026-02-16 16:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-15 20:33 [PATCH 0/9] drm/xe/pf: Allow to change VFs VRAM quota using sysfs Michal Wajdeczko
2026-02-15 20:33 ` [PATCH 1/9] drm/xe/pf: Add locked variants of VRAM configuration functions Michal Wajdeczko
2026-02-16 14:37   ` Piotr Piórkowski
2026-02-15 20:33 ` [PATCH 2/9] drm/xe/pf: Add functions for VRAM provisioning Michal Wajdeczko
2026-02-16 15:02   ` Piotr Piórkowski
2026-02-16 15:11     ` Piotr Piórkowski
2026-02-15 20:33 ` [PATCH 3/9] drm/xe/pf: Allow to change VFs VRAM quota using sysfs Michal Wajdeczko
2026-02-16 15:29   ` Piotr Piórkowski
2026-02-18 21:07   ` Rodrigo Vivi
2026-02-15 20:33 ` [PATCH 4/9] drm/xe/pf: Use migration-friendly VRAM auto-provisioning Michal Wajdeczko
2026-02-16 16:14   ` Piotr Piórkowski
2026-02-15 20:33 ` [PATCH 5/9] drm/xe/tests: Add KUnit tests for new VRAM fair provisioning Michal Wajdeczko
2026-02-16 16:23   ` Piotr Piórkowski
2026-02-15 20:33 ` [PATCH 6/9] drm/xe/pf: Don't check for empty config Michal Wajdeczko
2026-02-16 16:27   ` Piotr Piórkowski
2026-02-15 20:33 ` [PATCH 7/9] drm/xe/pf: Prefer guard(mutex) when doing fair LMEM provisioning Michal Wajdeczko
2026-02-16 16:36   ` Piotr Piórkowski
2026-02-15 20:33 ` [PATCH 8/9] drm/xe/pf: Skip VRAM auto-provisioning if already provisioned Michal Wajdeczko
2026-02-16 16:59   ` Piotr Piórkowski [this message]
2026-02-15 20:33 ` [PATCH 9/9] drm/xe/pf: Add documentation for vram_quota Michal Wajdeczko
2026-02-16 17:04   ` 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=20260216165938.tndepv3wsjhtwpzi@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