All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bernatowicz, Marcin" <marcin.bernatowicz@linux.intel.com>
To: "Piórkowski, Piotr" <piotr.piorkowski@intel.com>,
	intel-xe@lists.freedesktop.org
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Subject: Re: [PATCH v1 2/2] drm/xe/pf: Split VFs enabling into prepare and commit steps
Date: Mon, 23 Nov 2026 11:54:02 +0100	[thread overview]
Message-ID: <5eff17e5-b524-4e8d-b1af-f5f441a3091e@linux.intel.com> (raw)
In-Reply-To: <20261123094607.3300722-3-piotr.piorkowski@intel.com>


On 11/23/2026 10:46 AM, Piórkowski, Piotr wrote:
> From: Michal Wajdeczko <michal.wajdeczko@intel.com>
>
> Split the pf_enable_vfs() into separate steps: prepare, which waits
> for the PF readiness and takes the extra runtime PM reference, and
> commit, which resizes VF VRAM BAR and actually enables the VFs.
> The VFs provisioning is now done between those two steps.
>
> This is a preparation for the upcoming VGPU profiles support, where
> we will want to use a different provisioning step while keeping the
> same prepare and commit steps.
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
> ---
>   drivers/gpu/drm/xe/xe_pci_sriov.c | 91 ++++++++++++++++++++-----------
>   1 file changed, 58 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_pci_sriov.c b/drivers/gpu/drm/xe/xe_pci_sriov.c
> index 6c839eff0db8..e91e75d64174 100644
> --- a/drivers/gpu/drm/xe/xe_pci_sriov.c
> +++ b/drivers/gpu/drm/xe/xe_pci_sriov.c
> @@ -125,36 +125,17 @@ static void pf_finish_vfs_enabling(struct xe_device *xe)
>   	xe_sriov_pf_disarm_guard(xe, &xe->sriov.pf.guard_vfs_enabling, false, NULL);
>   }
>   
> -static void pf_enable_vfs_revert(struct xe_device *xe, int num_vfs)
> +static int pf_enable_vfs_prepare(struct xe_device *xe)
>   {
> -	pf_resize_vf_vram_bar(xe, xe->sriov.pf.device_total_vfs);
> -
> -	xe_sriov_pf_unprovision_vfs(xe, num_vfs);
> -
> -	/* Release additional PM reference obtained in pf_enable_vfs() */
> -	xe_pm_runtime_put(xe);
> -
> -	pf_finish_vfs_enabling(xe);
> -}
> -
> -static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
> -{
> -	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
> -	int total_vfs = xe_sriov_pf_get_totalvfs(xe);
>   	int err;
>   
> -	xe_assert(xe, IS_SRIOV_PF(xe));
> -	xe_assert(xe, num_vfs > 0);
> -	xe_assert(xe, num_vfs <= total_vfs);
> -	xe_sriov_dbg(xe, "enabling %u VF%s\n", num_vfs, str_plural(num_vfs));
> -
>   	err = xe_sriov_pf_wait_ready(xe);
>   	if (err)
> -		goto out;
> +		return err;
>   
>   	err = pf_prepare_vfs_enabling(xe);
>   	if (err)
> -		goto out;
> +		return err;
>   
>   	/*
>   	 * We must hold additional reference to the runtime PM to keep PF in D0
> @@ -167,33 +148,77 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
>   	 */
>   	xe_pm_runtime_get_noresume(xe);
>   
> -	err = xe_sriov_pf_provision_vfs(xe, num_vfs);
> -	if (err < 0)
> -		goto failed;
> +	return 0;
> +}
> +
> +static void pf_enable_vfs_revert(struct xe_device *xe, int num_vfs)
> +{
> +	pf_resize_vf_vram_bar(xe, xe->sriov.pf.device_total_vfs);
> +
> +	xe_sriov_pf_unprovision_vfs(xe, num_vfs);
> +
> +	/* Release additional PM reference obtained in pf_enable_vfs_prepare() */
> +	xe_pm_runtime_put(xe);
> +
> +	pf_finish_vfs_enabling(xe);
> +}
> +
> +static int pf_enable_vfs_commit(struct xe_device *xe, int num_vfs)
> +{
> +	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
> +	int err;
> +
> +	xe_assert(xe, IS_SRIOV_PF(xe));
> +	xe_assert(xe, num_vfs > 0);
> +	xe_assert(xe, num_vfs <= xe_sriov_pf_get_totalvfs(xe));
>   
>   	pf_resize_vf_vram_bar(xe, num_vfs);
>   
>   	err = pci_enable_sriov(pdev, num_vfs);
>   	if (err < 0)
> -		goto failed;
> +		return err;
>   
>   	pf_link_vfs(xe, num_vfs);
>   
> -	xe_sriov_info(xe, "Enabled %u of %u VF%s\n",
> -		      num_vfs, total_vfs, str_plural(total_vfs));
> -
>   	xe_sriov_pf_sysfs_link_vfs(xe, num_vfs);
>   
>   	pf_engine_activity_stats(xe, num_vfs, true);
>   
>   	return num_vfs;
> +}
>   
> -failed:
> +static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
> +{
> +	int total_vfs = xe_sriov_pf_get_totalvfs(xe);
> +	int ret;
> +
> +	xe_assert(xe, IS_SRIOV_PF(xe));
> +	xe_assert(xe, num_vfs > 0);
> +	xe_assert(xe, num_vfs <= total_vfs);
> +	xe_sriov_dbg(xe, "enabling %u VF%s\n", num_vfs, str_plural(num_vfs));
> +
> +	ret = pf_enable_vfs_prepare(xe);
> +	if (ret < 0)
> +		goto failed;
> +
> +	ret = xe_sriov_pf_provision_vfs(xe, num_vfs);
> +	if (ret < 0)
> +		goto revert;
> +
> +	ret = pf_enable_vfs_commit(xe, num_vfs);
> +	if (ret < 0)
> +		goto revert;
> +
> +	xe_sriov_info(xe, "Enabled %u of %u VF%s\n",
> +		      num_vfs, total_vfs, str_plural(total_vfs));
> +	return num_vfs;
> +
> +revert:
>   	pf_enable_vfs_revert(xe, num_vfs);
Now that provisioning is a separate step between prepare and commit,
should xe_sriov_pf_unprovision_vfs() stay in pf_enable_vfs_revert(), or
rather be called here next to xe_sriov_pf_reprovision_default(), so the
VGPU profiles code could use its own unprovisioning step?
--
marcin
> -out:
> +failed:
>   	xe_sriov_notice(xe, "Failed to enable %u VF%s (%pe)\n",
> -			num_vfs, str_plural(num_vfs), ERR_PTR(err));
> -	return err;
> +			num_vfs, str_plural(num_vfs), ERR_PTR(ret));
> +	return ret;
>   }
>   
>   static int pf_disable_vfs(struct xe_device *xe)

  reply	other threads:[~2026-11-23 10:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  9:46 [PATCH v1 0/2] Prepare VFs enabling for VGPU profiles Piórkowski, Piotr
2026-11-23  9:46 ` [PATCH v1 1/2] drm/xe/pf: Extract VFs enabling revert helper Piórkowski, Piotr
2026-11-23 10:42   ` K V P, Satyanarayana
2026-11-23 11:10     ` Bernatowicz, Marcin
2026-11-23 10:48   ` Bernatowicz, Marcin
2026-11-23  9:46 ` [PATCH v1 2/2] drm/xe/pf: Split VFs enabling into prepare and commit steps Piórkowski, Piotr
2026-11-23 10:54   ` Bernatowicz, Marcin [this message]
2026-11-23 10:43 ` [PATCH v1 0/2] Prepare VFs enabling for VGPU profiles Bernatowicz, Marcin
2026-11-23 14:25 ` ✗ CI.KUnit: failure for " 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=5eff17e5-b524-4e8d-b1af-f5f441a3091e@linux.intel.com \
    --to=marcin.bernatowicz@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=michal.wajdeczko@intel.com \
    --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 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.