From: "K V P, Satyanarayana" <satyanarayana.k.v.p@intel.com>
To: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v1 1/2] drm/xe/pf: Extract VFs enabling revert helper
Date: Mon, 23 Nov 2026 16:12:17 +0530 [thread overview]
Message-ID: <429660af-db1d-4593-a5a1-54066cf85b3a@intel.com> (raw)
In-Reply-To: <20261123094607.3300722-2-piotr.piorkowski@intel.com>
On 23-Nov-26 3:16 PM, Piórkowski, Piotr wrote:
> From: Michal Wajdeczko <michal.wajdeczko@intel.com>
>
> Both the error path of the pf_enable_vfs() and the pf_disable_vfs()
> are releasing the same set of resources acquired during VFs enabling:
> VF VRAM BAR size, VFs provisioning, extra runtime PM reference and
> the VFs enabling guard. Extract this common code into a helper.
>
> Note that in pf_disable_vfs() the VF VRAM BAR will now be resized
> back after the PF reprovisioning and VFs reset, but since at this
> point the VFs are already disabled, this should not matter.
>
> 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 | 28 +++++++++++++++-------------
> 1 file changed, 15 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_pci_sriov.c b/drivers/gpu/drm/xe/xe_pci_sriov.c
> index 31abcee55211..6c839eff0db8 100644
> --- a/drivers/gpu/drm/xe/xe_pci_sriov.c
> +++ b/drivers/gpu/drm/xe/xe_pci_sriov.c
> @@ -125,6 +125,18 @@ 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)
> +{
> + 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);
> @@ -151,7 +163,7 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
> * With PF being in D0 state, all VFs will also behave as in D0 state.
> * This will also keep GuC alive with all VFs' configurations.
> *
> - * We will release this additional PM reference in pf_disable_vfs().
> + * We will release this additional PM reference in pf_enable_vfs_revert().
> */
> xe_pm_runtime_get_noresume(xe);
>
> @@ -177,10 +189,7 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
> return num_vfs;
>
> failed:
> - pf_resize_vf_vram_bar(xe, xe->sriov.pf.device_total_vfs);
> - xe_sriov_pf_unprovision_vfs(xe, num_vfs);
> - xe_pm_runtime_put(xe);
> - pf_finish_vfs_enabling(xe);
> + pf_enable_vfs_revert(xe, num_vfs);
> out:
> xe_sriov_notice(xe, "Failed to enable %u VF%s (%pe)\n",
> num_vfs, str_plural(num_vfs), ERR_PTR(err));
> @@ -205,18 +214,11 @@ static int pf_disable_vfs(struct xe_device *xe)
>
> pci_disable_sriov(pdev);
>
> - pf_resize_vf_vram_bar(xe, xe->sriov.pf.device_total_vfs);
> -
> xe_sriov_pf_reprovision_default(xe);
>
> pf_reset_vfs(xe, num_vfs);
>
> - xe_sriov_pf_unprovision_vfs(xe, num_vfs);
> -
> - /* not needed anymore - see pf_enable_vfs() */
> - xe_pm_runtime_put(xe);
> -
> - pf_finish_vfs_enabling(xe);
> + pf_enable_vfs_revert(xe, num_vfs);
This new function name looks good when reverting in the error case while
enabling VFs, but does not sound good while disabling VFs.
How about using pf_clean_vfs() which can be safely used for both cases?
-Satya.
>
> xe_sriov_info(xe, "Disabled %u VF%s\n", num_vfs, str_plural(num_vfs));
> return 0;
next prev parent reply other threads:[~2026-11-23 10:42 UTC|newest]
Thread overview: 8+ 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 [this message]
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
2026-11-23 10:43 ` [PATCH v1 0/2] Prepare VFs enabling for VGPU profiles Bernatowicz, Marcin
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=429660af-db1d-4593-a5a1-54066cf85b3a@intel.com \
--to=satyanarayana.k.v.p@intel.com \
--cc=intel-xe@lists.freedesktop.org \
/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