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 1/3] drm/xe/pf: Skip fair VFs provisioning if already provisioned
Date: Mon, 1 Jul 2024 13:24:06 +0200	[thread overview]
Message-ID: <20240701112406.3z6b3lkvqhqbukoe@intel.com> (raw)
In-Reply-To: <20240701102738.934-2-michal.wajdeczko@intel.com>

Michal Wajdeczko <michal.wajdeczko@intel.com> wrote on pon [2024-lip-01 12:27:36 +0200]:
> Our debugfs allows to view and change VFs' provisioning configs.
> 
> If we attempt to experiment with VFs provisioning before enabling
> them, this early config will affect fair provisioning calculations,
> and will also be overwritten, which is undesirable behavior.
> 
> To improve this, check if the VFs configs are empty (unprovisioned)
> before starting the fair provisioning procedure.
> 
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 48 ++++++++++++++++++++++
>  drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h |  2 +
>  drivers/gpu/drm/xe/xe_pci_sriov.c          | 13 ++++++
>  3 files changed, 63 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 694671497f6e..810b579a0025 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -1922,6 +1922,54 @@ int xe_gt_sriov_pf_config_push(struct xe_gt *gt, unsigned int vfid, bool refresh
>  	return err;
>  }
>  
> +static int pf_validate_vf_config(struct xe_gt *gt, unsigned int vfid)
> +{
> +	struct xe_gt *primary_gt = gt_to_tile(gt)->primary_gt;
> +	struct xe_device *xe = gt_to_xe(gt);
> +	bool valid_ggtt, valid_ctxs, valid_dbs;
> +	bool valid_any, valid_all;
> +
> +	valid_ggtt = pf_get_vf_config_ggtt(primary_gt, vfid);
> +	valid_ctxs = pf_get_vf_config_ctxs(gt, vfid);
> +	valid_dbs = pf_get_vf_config_dbs(gt, vfid);
> +
> +	/* note that GuC doorbells are optional */
> +	valid_any = valid_ggtt || valid_ctxs || valid_dbs;
> +	valid_all = valid_ggtt && valid_ctxs;
> +
> +	if (IS_DGFX(xe)) {
> +		bool valid_lmem = pf_get_vf_config_ggtt(primary_gt, vfid);
> +
> +		valid_any = valid_any || valid_lmem;
> +		valid_all = valid_all && valid_lmem;
> +	}
> +
> +	return valid_all ? 1 : valid_any ? -ENOKEY : -ENODATA;
> +}
> +
> +/**
> + * xe_gt_sriov_pf_config_is_empty - Check VF's configuration.
> + * @gt: the &xe_gt
> + * @vfid: the VF identifier (can't be PF)
> + *
> + * This function can only be called on PF.
> + *
> + * Return: true if VF mandatory configuration (GGTT, LMEM, ...) is empty.
> + */
> +bool xe_gt_sriov_pf_config_is_empty(struct xe_gt *gt, unsigned int vfid)
> +{
> +	bool empty;
> +
> +	xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
> +	xe_gt_assert(gt, vfid);
> +
> +	mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
> +	empty = pf_validate_vf_config(gt, vfid) == -ENODATA;
> +	mutex_unlock(xe_gt_sriov_pf_master_mutex(gt));
> +
> +	return empty;
> +}
> +
>  /**
>   * xe_gt_sriov_pf_config_print_ggtt - Print GGTT configurations.
>   * @gt: the &xe_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 e8238c1ad06a..58c8f879d7ab 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h
> @@ -53,6 +53,8 @@ int xe_gt_sriov_pf_config_set_fair(struct xe_gt *gt, unsigned int vfid, unsigned
>  int xe_gt_sriov_pf_config_release(struct xe_gt *gt, unsigned int vfid, bool force);
>  int xe_gt_sriov_pf_config_push(struct xe_gt *gt, unsigned int vfid, bool refresh);
>  
> +bool xe_gt_sriov_pf_config_is_empty(struct xe_gt *gt, unsigned int vfid);
> +
>  int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p);
>  int xe_gt_sriov_pf_config_print_ctxs(struct xe_gt *gt, struct drm_printer *p);
>  int xe_gt_sriov_pf_config_print_dbs(struct xe_gt *gt, struct drm_printer *p);
> diff --git a/drivers/gpu/drm/xe/xe_pci_sriov.c b/drivers/gpu/drm/xe/xe_pci_sriov.c
> index 74c8fadc9365..aaceee748287 100644
> --- a/drivers/gpu/drm/xe/xe_pci_sriov.c
> +++ b/drivers/gpu/drm/xe/xe_pci_sriov.c
> @@ -13,6 +13,17 @@
>  #include "xe_sriov_pf_helpers.h"
>  #include "xe_sriov_printk.h"
>  
> +static int pf_needs_provisioning(struct xe_gt *gt, unsigned int num_vfs)
> +{
> +	unsigned int n;
> +
> +	for (n = 1; n <= num_vfs; n++)
> +		if (!xe_gt_sriov_pf_config_is_empty(gt, n))
> +			return false;
> +
> +	return true;
> +}
> +
>  static int pf_provision_vfs(struct xe_device *xe, unsigned int num_vfs)
>  {
>  	struct xe_gt *gt;
> @@ -20,6 +31,8 @@ static int pf_provision_vfs(struct xe_device *xe, unsigned int num_vfs)
>  	int result = 0, err;
>  
>  	for_each_gt(gt, xe, id) {
> +		if (!pf_needs_provisioning(gt, num_vfs))
> +			continue;
>  		err = xe_gt_sriov_pf_config_set_fair(gt, VFID(1), num_vfs);
>  		result = result ?: err;
>  	}

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

> -- 
> 2.43.0
> 

-- 

  reply	other threads:[~2024-07-01 11:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-01 10:27 [PATCH 0/3] PF: Provisioning improvements Michal Wajdeczko
2024-07-01 10:27 ` [PATCH 1/3] drm/xe/pf: Skip fair VFs provisioning if already provisioned Michal Wajdeczko
2024-07-01 11:24   ` Piotr Piórkowski [this message]
2024-07-01 10:27 ` [PATCH 2/3] drm/xe/pf: Restart VFs provisioning after GT reset Michal Wajdeczko
2024-07-01 11:31   ` Piotr Piórkowski
2024-07-01 10:27 ` [PATCH 3/3] HAX: Try SR-IOV on ADLP/ATSM Michal Wajdeczko
2024-07-01 13:26 ` ✓ CI.Patch_applied: success for PF: Provisioning improvements (rev2) Patchwork
2024-07-01 13:26 ` ✓ CI.checkpatch: " Patchwork
2024-07-01 13:28 ` ✓ CI.KUnit: " Patchwork
2024-07-01 13:39 ` ✓ CI.Build: " Patchwork
2024-07-01 13:42 ` ✓ CI.Hooks: " Patchwork
2024-07-01 13:43 ` ✓ CI.checksparse: " Patchwork
2024-07-01 14:06 ` ✓ CI.BAT: " Patchwork
2024-07-01 15:15 ` ✗ CI.FULL: failure " Patchwork
2024-07-01 17:23   ` 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=20240701112406.3z6b3lkvqhqbukoe@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