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 v2 3/3] drm/xe/pf: Split VFs enabling into prepare and commit steps
Date: Tue, 24 Nov 2026 16:45:42 +0100 [thread overview]
Message-ID: <a0221841-7b74-44fa-a0d5-70164bb7490a@linux.intel.com> (raw)
In-Reply-To: <20261124105009.3431301-4-piotr.piorkowski@intel.com>
On 11/24/2026 11:50 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 | 69 +++++++++++++++++++++----------
> 1 file changed, 47 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_pci_sriov.c b/drivers/gpu/drm/xe/xe_pci_sriov.c
> index d0536322dc05..b0cfa6e46d8b 100644
> --- a/drivers/gpu/drm/xe/xe_pci_sriov.c
> +++ b/drivers/gpu/drm/xe/xe_pci_sriov.c
> @@ -129,30 +129,23 @@ static void pf_enable_vfs_revert(struct xe_device *xe)
> {
> pf_resize_vf_vram_bar(xe, xe->sriov.pf.device_total_vfs);
>
> - /* Release additional PM reference obtained in pf_enable_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(struct xe_device *xe, int num_vfs)
> +static int pf_enable_vfs_prepare(struct xe_device *xe)
> {
> - 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
> @@ -165,35 +158,67 @@ 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 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:
> xe_sriov_pf_reprovision_default(xe);
> xe_sriov_pf_unprovision_vfs(xe, num_vfs);
> pf_enable_vfs_revert(xe);
> -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;
LGTM,
Reviewed-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
> }
>
> static int pf_disable_vfs(struct xe_device *xe)
next prev parent reply other threads:[~2026-11-24 15:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 10:50 [PATCH v2 0/3] Prepare VFs enabling for VGPU profiles Piórkowski, Piotr
2026-11-24 10:50 ` [PATCH v2 1/3] drm/xe/pf: Restore default PF scheduling on failed VF enable Piórkowski, Piotr
2026-11-24 10:50 ` [PATCH v2 2/3] drm/xe/pf: Extract VFs enabling revert helper Piórkowski, Piotr
2026-11-24 15:45 ` Bernatowicz, Marcin
2026-11-24 10:50 ` [PATCH v2 3/3] drm/xe/pf: Split VFs enabling into prepare and commit steps Piórkowski, Piotr
2026-11-24 15:45 ` Bernatowicz, Marcin [this message]
2026-11-24 11:05 ` ✗ CI.KUnit: failure for Prepare VFs enabling for VGPU profiles (rev2) 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=a0221841-7b74-44fa-a0d5-70164bb7490a@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox