From: "Piotr Piórkowski" <piotr.piorkowski@intel.com>
To: Lukasz Laguna <lukasz.laguna@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <satyanarayana.k.v.p@intel.com>,
<tomasz.lis@intel.com>, <raag.jadav@intel.com>
Subject: Re: [PATCH 3/5] drm/xe/pf: Recover VF state after PF FLR
Date: Wed, 2 Dec 2026 10:59:43 +0100 [thread overview]
Message-ID: <20261202095943.b65tlsysycalwrbs@intel.com> (raw)
In-Reply-To: <20261130150315.1954064-4-lukasz.laguna@intel.com>
Lukasz Laguna <lukasz.laguna@intel.com> wrote on pon [2026-lis-30 16:03:13 +0100]:
> After PF FLR, VF-related state set up by the PF is lost, including VF
> GGTT ownership and LMTT. This also applies to VFs that are provisioned
> but not enabled.
>
> Recover VF GGTT ownership and LMTT from the existing VF provisioning
> during device re-initialization, once LMEM is accessible and before
> the GTs resume. This puts them in place before GT resume queues the
> workers that push VF configurations to GuC.
>
> A failure to recover VF state only affects the VFs, so don't fail
> the PF FLR because of it.
>
> Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com>
> ---
> drivers/gpu/drm/xe/xe_device.c | 5 ++
> drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 77 ++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h | 1 +
> drivers/gpu/drm/xe/xe_sriov_pf.c | 25 +++++++
> drivers/gpu/drm/xe/xe_sriov_pf.h | 2 +
> 5 files changed, 110 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> index 36693df65594..a9e1b8782551 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
> @@ -71,6 +71,7 @@
> #include "xe_soc_remapper.h"
> #include "xe_survivability_mode.h"
> #include "xe_sriov.h"
> +#include "xe_sriov_pf.h"
> #include "xe_sriov_vf_ccs.h"
> #include "xe_svm.h"
> #include "xe_sysctrl.h"
> @@ -1497,6 +1498,10 @@ int xe_device_resume(struct xe_device *xe, bool flr)
> if (err)
> return err;
>
> + /* Failed VF recovery only affects VFs, don't fail the PF FLR */
> + if (IS_SRIOV_PF(xe))
> + xe_sriov_pf_recover_vfs(xe);
> +
> for_each_gt(gt, xe, id) {
> err = xe_gt_reinit(gt);
> if (err)
> 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 c848dd9e0a0d..f4ab16a380be 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -31,6 +31,7 @@
> #include "xe_lmtt.h"
> #include "xe_migrate.h"
> #include "xe_sriov.h"
> +#include "xe_sriov_pf_helpers.h"
> #include "xe_ttm_vram_mgr.h"
> #include "xe_vram_types.h"
>
> @@ -3422,6 +3423,82 @@ int xe_gt_sriov_pf_config_init(struct xe_gt *gt)
> return devm_add_action_or_reset(xe->drm.dev, fini_config, gt);
> }
>
> +static void pf_reassign_ggtt(struct xe_tile *tile)
> +{
> + struct xe_device *xe = tile_to_xe(tile);
> + unsigned int total_vfs = xe_sriov_pf_get_totalvfs(xe);
> + unsigned int n;
> +
> + xe_assert(xe, IS_SRIOV_PF(xe));
> +
> + for (n = 1; n <= total_vfs; n++) {
> + struct xe_gt *gt = tile->primary_gt;
> + struct xe_gt_sriov_config *config;
> +
> + config = pf_pick_vf_config(gt, n);
> + pf_sanitize_ggtt(config->ggtt_region, n);
> + }
> +}
> +
> +static int pf_rebuild_lmtt(struct xe_tile *tile)
> +{
> + struct xe_lmtt *lmtt = &tile->sriov.pf.lmtt;
> + struct xe_device *xe = tile_to_xe(tile);
> + unsigned int total_vfs = xe_sriov_pf_get_totalvfs(xe);
> + unsigned int n;
> + int err;
> +
> + xe_assert(xe, xe_device_has_lmtt(xe));
> + xe_assert(xe, IS_SRIOV_PF(xe));
> +
> + err = xe_lmtt_reinit_pages(lmtt);
> + if (err)
> + return err;
> +
> + for (n = 1; n <= total_vfs; n++) {
> + err = pf_populate_lmtt_pages(tile, n);
> + if (err)
> + return err;
> + }
It seems to me that you need to call `xe_device_wmb()` here to ensure that the writes are
written to the hardware. In the init path, this isn't necessary because we perform
an invalidation there, which implicitly calls a barrier. Here, invalidation isn't needed,
but a barrier would be useful.
Thanks
Piotr
> +
> + return 0;
> +}
> +
> +/**
> + * xe_gt_sriov_pf_config_recover() - Recover VF GGTT and LMTT after PF FLR.
> + * @gt: the &xe_gt (can't be media)
> + *
> + * VF GGTT ownership and LMTT are lost on PF FLR. Restore them from the
> + * existing VF provisioning, before VF configurations are pushed to GuC.
> + *
> + * This function can only be called on PF.
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> +int xe_gt_sriov_pf_config_recover(struct xe_gt *gt)
> +{
> + struct xe_tile *tile = gt_to_tile(gt);
> + struct xe_device *xe = gt_to_xe(gt);
> +
> + xe_gt_assert(gt, xe_gt_is_main_type(gt));
> +
> + guard(mutex)(xe_gt_sriov_pf_master_mutex(gt));
> +
> + pf_reassign_ggtt(tile);
> +
> + if (xe_device_has_lmtt(xe)) {
> + int err;
> +
> + err = pf_rebuild_lmtt(tile);
> + if (unlikely(err)) {
> + xe_tile_sriov_err(tile, "Failed to rebuild LMTT (%pe)\n", ERR_PTR(err));
> + return err;
> + }
> + }
> +
> + return 0;
> +}
> +
> /**
> * xe_gt_sriov_pf_config_restart - Restart SR-IOV configurations after a GT reset.
> * @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 0d45dc9672e7..658a5dcfa65f 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h
> @@ -109,6 +109,7 @@ int xe_gt_sriov_pf_config_ggtt_restore(struct xe_gt *gt, unsigned int vfid,
> bool xe_gt_sriov_pf_config_is_empty(struct xe_gt *gt, unsigned int vfid);
>
> int xe_gt_sriov_pf_config_init(struct xe_gt *gt);
> +int xe_gt_sriov_pf_config_recover(struct xe_gt *gt);
> void xe_gt_sriov_pf_config_restart(struct xe_gt *gt);
>
> int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p);
> diff --git a/drivers/gpu/drm/xe/xe_sriov_pf.c b/drivers/gpu/drm/xe/xe_sriov_pf.c
> index ce0db26203ec..a6c70fe4ae03 100644
> --- a/drivers/gpu/drm/xe/xe_sriov_pf.c
> +++ b/drivers/gpu/drm/xe/xe_sriov_pf.c
> @@ -11,6 +11,7 @@
> #include "xe_configfs.h"
> #include "xe_device.h"
> #include "xe_gt_sriov_pf.h"
> +#include "xe_gt_sriov_pf_config.h"
> #include "xe_module.h"
> #include "xe_sriov.h"
> #include "xe_sriov_pf.h"
> @@ -170,6 +171,30 @@ int xe_sriov_pf_wait_ready(struct xe_device *xe)
> return 0;
> }
>
> +/**
> + * xe_sriov_pf_recover_vfs() - Recover provisioned VFs after PF FLR.
> + * @xe: the PF &xe_device
> + *
> + * Call once LMEM is accessible and before the GTs resume.
> + *
> + * Return: 0 on success or the first error reported by a tile.
> + */
> +int xe_sriov_pf_recover_vfs(struct xe_device *xe)
> +{
> + struct xe_tile *tile;
> + int ret = 0;
> + u8 id;
> +
> + for_each_tile(tile, xe, id) {
> + int err;
> +
> + err = xe_gt_sriov_pf_config_recover(tile->primary_gt);
> + ret = ret ?: err;
> + }
> +
> + return ret;
> +}
> +
> /**
> * xe_sriov_pf_arm_guard() - Arm the guard for exclusive/lockdown mode.
> * @xe: the PF &xe_device
> diff --git a/drivers/gpu/drm/xe/xe_sriov_pf.h b/drivers/gpu/drm/xe/xe_sriov_pf.h
> index b4d050ad5b7c..0c6a404878c2 100644
> --- a/drivers/gpu/drm/xe/xe_sriov_pf.h
> +++ b/drivers/gpu/drm/xe/xe_sriov_pf.h
> @@ -17,6 +17,7 @@ bool xe_sriov_pf_readiness(struct xe_device *xe);
> int xe_sriov_pf_init_early(struct xe_device *xe);
> int xe_sriov_pf_init_late(struct xe_device *xe);
> int xe_sriov_pf_wait_ready(struct xe_device *xe);
> +int xe_sriov_pf_recover_vfs(struct xe_device *xe);
> int xe_sriov_pf_lockdown(struct xe_device *xe);
> void xe_sriov_pf_end_lockdown(struct xe_device *xe);
> void xe_sriov_pf_print_vfs_summary(struct xe_device *xe, struct drm_printer *p);
> @@ -24,6 +25,7 @@ void xe_sriov_pf_print_vfs_summary(struct xe_device *xe, struct drm_printer *p);
> static inline bool xe_sriov_pf_readiness(struct xe_device *xe) { return false; }
> static inline int xe_sriov_pf_init_early(struct xe_device *xe) { return 0; }
> static inline int xe_sriov_pf_init_late(struct xe_device *xe) { return 0; }
> +static inline int xe_sriov_pf_recover_vfs(struct xe_device *xe) { return 0; }
> static inline int xe_sriov_pf_lockdown(struct xe_device *xe) { return 0; }
> static inline void xe_sriov_pf_end_lockdown(struct xe_device *xe) { }
> #endif
> --
> 2.43.0
>
--
next prev parent reply other threads:[~2026-12-02 10:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 15:03 [PATCH 0/5] drm/xe/pf: Support PCIe FLR when VFs are enabled Lukasz Laguna
2026-11-30 15:03 ` [PATCH 1/5] drm/xe/pf: Add helper to rewrite VF LMTT page table tree Lukasz Laguna
2026-12-02 9:37 ` Piotr Piórkowski
2026-11-30 15:03 ` [PATCH 2/5] drm/xe/pf: Extract VF LMTT pages population into helper Lukasz Laguna
2026-12-02 9:40 ` Piotr Piórkowski
2026-11-30 15:03 ` [PATCH 3/5] drm/xe/pf: Recover VF state after PF FLR Lukasz Laguna
2026-12-02 9:59 ` Piotr Piórkowski [this message]
2026-11-30 15:03 ` [PATCH 4/5] drm/xe/pf: Preserve VF PCI config space across " Lukasz Laguna
2026-12-02 10:38 ` Piotr Piórkowski
2026-11-30 15:03 ` [PATCH 5/5] drm/xe/pf: Support PCIe FLR when VFs are enabled Lukasz Laguna
2026-12-02 10:44 ` Piotr Piórkowski
2026-11-30 17:23 ` ✓ CI.KUnit: success for " Patchwork
2026-11-30 18:13 ` ✓ Xe.CI.BAT: " Patchwork
2026-12-01 2:30 ` ✓ Xe.CI.FULL: " 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=20261202095943.b65tlsysycalwrbs@intel.com \
--to=piotr.piorkowski@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lukasz.laguna@intel.com \
--cc=raag.jadav@intel.com \
--cc=satyanarayana.k.v.p@intel.com \
--cc=tomasz.lis@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.