* [PATCH v1 0/2] Prepare VFs enabling for VGPU profiles
@ 2026-11-23 9:46 Piórkowski, Piotr
2026-11-23 9:46 ` [PATCH v1 1/2] drm/xe/pf: Extract VFs enabling revert helper Piórkowski, Piotr
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Piórkowski, Piotr @ 2026-11-23 9:46 UTC (permalink / raw)
To: intel-xe; +Cc: Piotr Piórkowski
From: Piotr Piórkowski <piotr.piorkowski@intel.com>
Split pf_enable_vfs() into prepare, provision and commit steps,
so the upcoming VGPU profiles code can reuse it with its own
provisioning step. Error handling stays the same.
Michal Wajdeczko (2):
drm/xe/pf: Extract VFs enabling revert helper
drm/xe/pf: Split VFs enabling into prepare and commit steps
drivers/gpu/drm/xe/xe_pci_sriov.c | 93 ++++++++++++++++++++-----------
1 file changed, 60 insertions(+), 33 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v1 1/2] drm/xe/pf: Extract VFs enabling revert helper 2026-11-23 9:46 [PATCH v1 0/2] Prepare VFs enabling for VGPU profiles Piórkowski, Piotr @ 2026-11-23 9:46 ` Piórkowski, Piotr 2026-11-23 10:42 ` K V P, Satyanarayana 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:43 ` [PATCH v1 0/2] Prepare VFs enabling for VGPU profiles Bernatowicz, Marcin 2 siblings, 2 replies; 8+ messages in thread From: Piórkowski, Piotr @ 2026-11-23 9:46 UTC (permalink / raw) To: intel-xe; +Cc: Michal Wajdeczko, Piotr Piórkowski 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); xe_sriov_info(xe, "Disabled %u VF%s\n", num_vfs, str_plural(num_vfs)); return 0; -- 2.34.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/2] drm/xe/pf: Extract VFs enabling revert helper 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 1 sibling, 1 reply; 8+ messages in thread From: K V P, Satyanarayana @ 2026-11-23 10:42 UTC (permalink / raw) To: intel-xe 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; ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/2] drm/xe/pf: Extract VFs enabling revert helper 2026-11-23 10:42 ` K V P, Satyanarayana @ 2026-11-23 11:10 ` Bernatowicz, Marcin 0 siblings, 0 replies; 8+ messages in thread From: Bernatowicz, Marcin @ 2026-11-23 11:10 UTC (permalink / raw) To: K V P, Satyanarayana, intel-xe On 11/23/2026 11:42 AM, K V P, Satyanarayana wrote: > > 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. With 2/2 this becomes a prepare/commit/revert triplet, so the _revert name seems to fit, also in the disable path. Just my 2c. > >> xe_sriov_info(xe, "Disabled %u VF%s\n", num_vfs, >> str_plural(num_vfs)); >> return 0; ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/2] drm/xe/pf: Extract VFs enabling revert helper 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 10:48 ` Bernatowicz, Marcin 1 sibling, 0 replies; 8+ messages in thread From: Bernatowicz, Marcin @ 2026-11-23 10:48 UTC (permalink / raw) To: Piórkowski, Piotr, intel-xe; +Cc: Michal Wajdeczko On 11/23/2026 10:46 AM, 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); I assume xe_sriov_pf_reprovision_default() is intentionally kept out of pf_enable_vfs_revert() so the PF is restored before the potentially slow pf_reset_vfs() (as per 24ac010a97b6)? If so, the error path would need it explicitly too (see link in the cover letter reply). -- marcin > > - 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); > > xe_sriov_info(xe, "Disabled %u VF%s\n", num_vfs, str_plural(num_vfs)); > return 0; ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v1 2/2] drm/xe/pf: Split VFs enabling into prepare and commit steps 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 9:46 ` 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 2 siblings, 1 reply; 8+ messages in thread From: Piórkowski, Piotr @ 2026-11-23 9:46 UTC (permalink / raw) To: intel-xe; +Cc: Michal Wajdeczko, Piotr Piórkowski 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); -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) -- 2.34.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v1 2/2] drm/xe/pf: Split VFs enabling into prepare and commit steps 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 0 siblings, 0 replies; 8+ messages in thread From: Bernatowicz, Marcin @ 2026-11-23 10:54 UTC (permalink / raw) To: Piórkowski, Piotr, intel-xe; +Cc: Michal Wajdeczko 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) ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 0/2] Prepare VFs enabling for VGPU profiles 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 9:46 ` [PATCH v1 2/2] drm/xe/pf: Split VFs enabling into prepare and commit steps Piórkowski, Piotr @ 2026-11-23 10:43 ` Bernatowicz, Marcin 2 siblings, 0 replies; 8+ messages in thread From: Bernatowicz, Marcin @ 2026-11-23 10:43 UTC (permalink / raw) To: Piórkowski, Piotr, intel-xe On 11/23/2026 10:46 AM, Piórkowski, Piotr wrote: > From: Piotr Piórkowski <piotr.piorkowski@intel.com> > > Split pf_enable_vfs() into prepare, provision and commit steps, > so the upcoming VGPU profiles code can reuse it with its own > provisioning step. Error handling stays the same. The current error path misses xe_sriov_pf_reprovision_default(), leaving the PF with fair-sched EQ/PT after a failed VFs enabling. I posted a fix for that some time ago: https://lore.kernel.org/all/20260806095046.1360538-1-marcin.bernatowicz@linux.intel.com/ As it's a fix (Fixes: afc480ff55c5), could it go in first and this series be rebased on top? Alternatively I can resend it on top of this series, or you can pick it up as 1/3. -- marcin > > Michal Wajdeczko (2): > drm/xe/pf: Extract VFs enabling revert helper > drm/xe/pf: Split VFs enabling into prepare and commit steps > > drivers/gpu/drm/xe/xe_pci_sriov.c | 93 ++++++++++++++++++++----------- > 1 file changed, 60 insertions(+), 33 deletions(-) > ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-23 11:11 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2026-11-23 10:43 ` [PATCH v1 0/2] Prepare VFs enabling for VGPU profiles Bernatowicz, Marcin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox