From: "Lis, Tomasz" <tomasz.lis@intel.com>
To: "Piórkowski, Piotr" <piotr.piorkowski@intel.com>,
intel-xe@lists.freedesktop.org
Cc: Varun Gupta <varun.gupta@intel.com>,
Matt Atwood <matthew.s.atwood@intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Satyanarayana K V P <satyanarayana.k.v.p@intel.com>,
Tangudu Tilak Tirumalesh <tilak.tirumalesh.tangudu@intel.com>
Subject: Re: [PATCH v2 5/5] drm/xe/xe3p_lpg: Apply Wa_14028597154 to SR-IOV VF
Date: Thu, 3 Dec 2026 22:39:04 +0100 [thread overview]
Message-ID: <c6e599ee-51ff-4354-93ec-e4ffc4b1ebc4@intel.com> (raw)
In-Reply-To: <20261203181408.362175-6-piotr.piorkowski@intel.com>
[-- Attachment #1: Type: text/plain, Size: 11718 bytes --]
On 2026-12-03 19:14, Piórkowski, Piotr wrote:
> From: Varun Gupta<varun.gupta@intel.com>
>
> The PF assigns the low-4MB GGTT PTEs matching a VF GGTT range to the VF
> together with the range, but it is the VF that has to back them with its
> own dummy page for Wa_14028597154.
Compound sentence, which uses terms VF and PF meaning drivers. Maybe:
"The Wa_14028597154 defines special driver behavior for low-4MB GGTT PTEs.
The PF driver assigns these low-4MB GGTT PTEs to VFs, in ranges matching
GGTT provisioning of each VF. Then, driver for each VF has to back them
with its own dummy page, as that area needs to be writeable from GFX HW."
> When the WA is active, map the VF dummy page into the low-4MB PTEs
> matching the VF GGTT range at probe, on resume and in
> xe_ggtt_shift_nodes(), even if the GGTT base did not change, as these
> PTEs are not migrated with the VF. Read them back and fail the probe if
> they were not written. Also fail the probe if the VF GGTT range is not
> 4MB aligned, starts below 4MB or is smaller than 8MB. Keep the top 4MB
> chunk of the VF GGTT range out of the usable range.
>
> Let xe_ggtt_shift_nodes() return an error, without moving the nodes, so
> the post-migration recovery fails if the low-4MB PTEs of the new GGTT
> range can't be mapped.
>
> Cc: Matt Atwood<matthew.s.atwood@intel.com>
> Cc: Rodrigo Vivi<rodrigo.vivi@intel.com>
> Cc: Satyanarayana K V P<satyanarayana.k.v.p@intel.com>
> Cc: Tangudu Tilak Tirumalesh<tilak.tirumalesh.tangudu@intel.com>
> Cc: Tomasz Lis<tomasz.lis@intel.com>
> Signed-off-by: Varun Gupta<varun.gupta@intel.com>
> Signed-off-by: Piotr Piórkowski<piotr.piorkowski@intel.com>
The 3 issues marked are with comments and minor function structure
change, so as long as that's somewhat addressed:
Reviewed-by: Tomasz Lis <tomasz.lis@intel.com>
> ---
> drivers/gpu/drm/xe/xe_ggtt.c | 123 ++++++++++++++++++++++++----
> drivers/gpu/drm/xe/xe_ggtt.h | 2 +-
> drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 12 ++-
> 3 files changed, 116 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index 64b81c0c48a3..4cf0ee203cd9 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -497,10 +497,16 @@ static void ggtt_init_generic(struct xe_ggtt *ggtt, u64 start, u64 size)
> {
> struct xe_device *xe = tile_to_xe(ggtt->tile);
>
> - if (!IS_SRIOV_PF(xe))
> - ggtt_init_native(ggtt, start, size);
> - else
> + if (IS_SRIOV_PF(xe))
> ggtt_init_shared(ggtt, start, size);
> + else if (IS_SRIOV_VF(xe) && ggtt_needs_low_4m_wa(ggtt))
> + /*
> + * Wa_14028597154: keep the top 4MB chunk of the VF GGTT range
> + * out of the usable range.
> + */
> + ggtt_init_ranges(ggtt, start, size, size - SZ_4M, 0);
We have created readability-improving sub-functions for simpler cases,
but the more complex case which
require direct comment is inserted without sub-function?
Please create a static function for this as well.
> + else
> + ggtt_init_native(ggtt, start, size);
>
> xe_tile_info(ggtt->tile, "GGTT usable %#llx-%#llx = %lluK\n",
> ggtt->start, ggtt->start + ggtt->size - 1,
> @@ -563,6 +569,20 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
> else
> ggtt->pt_ops = &xelp_pt_ops;
>
> + /*
> + * Wa_14028597154: the PF provisions VF GGTT ranges 4MB aligned, above
> + * 4MB and of at least 8MB. Refuse any other range, as the WA can't be
> + * applied to it.
> + */
> + if (IS_SRIOV_VF(xe) && ggtt_needs_low_4m_wa(ggtt) &&
> + (ggtt_start < SZ_4M || ggtt_size < SZ_8M ||
> + !IS_ALIGNED(ggtt_start | ggtt_size, SZ_4M))) {
> + xe_log_err_fatal(ggtt->tile, GGTT, -ERANGE,
> + "GGTT %#llx-%#llx unusable for Wa_14028597154\n",
> + ggtt_start, ggtt_start + ggtt_size - 1);
> + return -ERANGE;
> + }
> +
> ggtt->wq = alloc_workqueue("xe-ggtt-wq", WQ_MEM_RECLAIM | WQ_PERCPU, 0);
> if (!ggtt->wq)
> return -ENOMEM;
> @@ -581,6 +601,14 @@ ALLOW_ERROR_INJECTION(xe_ggtt_init_early, ERRNO); /* See xe_pci_probe() */
> static void xe_ggtt_invalidate(struct xe_ggtt *ggtt);
> static void xe_ggtt_invalidate_engine(struct xe_ggtt *ggtt);
>
> +static u64 ggtt_get_low_4m_pte(struct xe_ggtt *ggtt, u64 addr)
> +{
> + xe_tile_assert(ggtt->tile, addr >= XE_PAGE_SIZE && addr < SZ_4M);
> + xe_tile_assert(ggtt->tile, !(addr & XE_PTE_MASK));
> +
> + return readq(&ggtt->gsm[addr >> XE_PTE_SHIFT]);
> +}
> +
> /*
> * Return the low-4MB PTEs of the VF chunks in [start, start + size) to the PF
> * dummy page. Chunks not assigned to a VF are left alone, so releasing a PF
> @@ -662,8 +690,40 @@ static u64 ggtt_low_4m_hole_start(struct xe_ggtt *ggtt, u64 hole_start)
> return hole_start + SZ_4M;
> }
>
> +/*
> + * Map the VF dummy page into the low-4MB PTEs matching the whole VF GGTT
> + * range from @start. The VF can only modify them if the PF has assigned them
> + * to it, so read them back to verify the mapping.
> + */
> +static int ggtt_vf_map_low_4m_locked(struct xe_ggtt *ggtt, u64 start)
> +{
> + u64 mask = XE_PAGE_ADDR_MASK(XE_PTE_SHIFT) | XE_PAGE_PRESENT;
> + u64 end = start + ggtt->full_size;
> + u64 va;
> +
> + xe_tile_assert(ggtt->tile, IS_SRIOV_VF(tile_to_xe(ggtt->tile)));
> + xe_tile_assert(ggtt->tile, ggtt->low_4m_pte);
> + lockdep_assert_held(&ggtt->lock);
> +
> + if (start < SZ_4M || !IS_ALIGNED(start | ggtt->full_size, SZ_4M))
> + return -ERANGE;
> +
> + for (va = start; va < end; va += SZ_4M)
> + ggtt_set_low_4m_pte(ggtt, va >> 10, ggtt->low_4m_pte);
> +
> + for (va = start; va < end; va += SZ_4M) {
> + u64 pte = ggtt_get_low_4m_pte(ggtt, va >> 10);
> +
> + if ((pte & mask) != (ggtt->low_4m_pte & mask))
> + return -EPERM;
> + }
> +
> + return 0;
> +}
> +
> static void ggtt_restore_low_4m_locked(struct xe_ggtt *ggtt)
> {
> + struct xe_device *xe = tile_to_xe(ggtt->tile);
> u64 low_start = max_t(u64, ALIGN_DOWN(ggtt->start, SZ_4M) >> 10,
> XE_PAGE_SIZE);
> u64 low_end = min_t(u64,
> @@ -676,6 +736,14 @@ static void ggtt_restore_low_4m_locked(struct xe_ggtt *ggtt)
> if (!ggtt->low_4m_pte)
> return;
>
> + /* A VF only owns the low-4MB PTEs matching its own GGTT range */
> + if (IS_SRIOV_VF(xe)) {
> + if (ggtt_vf_map_low_4m_locked(ggtt, ggtt->start))
> + xe_tile_err(ggtt->tile,
> + "Failed to restore low-4MB GGTT PTEs for Wa_14028597154\n");
> + return;
> + }
> +
> for (addr = low_start; addr < low_end; addr += XE_PAGE_SIZE) {
> if (test_bit(addr >> XE_PTE_SHIFT, ggtt->vf_chunks))
> continue;
> @@ -694,16 +762,9 @@ static int ggtt_map_low_4m_wa(struct xe_ggtt *ggtt)
> struct xe_device *xe = tile_to_xe(tile);
> u16 pat_index = xe_cache_pat_idx(xe, XE_CACHE_WB);
> struct xe_bo *bo;
> + int err = 0;
> u64 pte;
>
> - /*
> - * TODO: SR-IOV VF support for Wa_14028597154 is deferred to a follow-up
> - * (requires PF 4MB-aligned VF GGTT provisioning, low-4MB VFID PTE
> - * assignment, and VF dummy-page mapping).
> - */
> - if (IS_SRIOV_VF(xe))
> - return 0;
> -
> if (!ggtt_needs_low_4m_wa(ggtt))
> return 0;
>
> @@ -716,7 +777,19 @@ static int ggtt_map_low_4m_wa(struct xe_ggtt *ggtt)
>
> scoped_guard(mutex, &ggtt->lock) {
> ggtt->low_4m_pte = pte;
> - ggtt_restore_low_4m_locked(ggtt);
> + if (IS_SRIOV_VF(xe))
> + err = ggtt_vf_map_low_4m_locked(ggtt, ggtt->start);
> + else
> + ggtt_restore_low_4m_locked(ggtt);
> + }
> +
> + /* The PF has to assign the low-4MB PTEs together with the VF range */
> + if (err) {
> + xe_log_err_fatal(tile, GGTT, err,
> + "Low-4MB GGTT range %#llx-%#llx not writable, required by Wa_14028597154\n",
> + ggtt->start >> 10,
> + ((ggtt->start + ggtt->full_size) >> 10) - 1);
> + return err;
> }
>
> return 0;
> @@ -945,23 +1018,41 @@ static void xe_ggtt_invalidate_engine(struct xe_ggtt *ggtt)
> * Ensure that all struct &xe_ggtt_node are moved to the @new_start base address
> * by changing the base offset of the GGTT.
> *
> - * This function may be called multiple times during recovery, but if
> - * @new_start is unchanged from the current base, it's a noop.
> + * This function may be called multiple times during recovery. If @new_start
> + * is unchanged from the current base, the nodes stay where they are.
> + *
> + * When Wa_14028597154 is applied, the low-4MB PTEs matching the VF GGTT range
> + * are mapped to the VF dummy page again on every call, even if the base is
> + * unchanged, as they are not migrated with the VF.
> *
> * @new_start should be a value between the WOPCM size and #GUC_GGTT_TOP. VFs
> * don't have access to the WOPCM size so we can't test against that.
> + *
> + * Return: 0 on success or a negative error code if @new_start is unusable for
> + * Wa_14028597154 or the low-4MB PTEs can't be mapped.
> */
> -void xe_ggtt_shift_nodes(struct xe_ggtt *ggtt, u64 new_start)
> +int xe_ggtt_shift_nodes(struct xe_ggtt *ggtt, u64 new_start)
> {
> + int err;
> +
> guard(mutex)(&ggtt->lock);
>
> - xe_tile_assert(ggtt->tile, new_start + ggtt->size <= GUC_GGTT_TOP);
> + xe_tile_assert(ggtt->tile, new_start + ggtt->full_size <= GUC_GGTT_TOP);
> #ifdef CONFIG_PCI_IOV
> xe_tile_assert(ggtt->tile, ggtt->shareable_size == 0);
> #endif
>
> + /* Don't move the nodes to a range unusable for Wa_14028597154 */
This comment is confusing rather than helping. There are no nodes which
it mentions.
Maybe:
"The GGTT range which need setting for Wa_14028597154 does not have
&xe_ggtt_node assigned as it is outside of space provisioned for the VF.
But it needs to be mapped again after every VF migration."
-Tomasz
> + if (ggtt->low_4m_pte) {
> + err = ggtt_vf_map_low_4m_locked(ggtt, new_start);
> + if (err)
> + return err;
> + }
> +
> /* pairs with READ_ONCE in xe_ggtt_node_addr() */
> WRITE_ONCE(ggtt->start, new_start);
> +
> + return 0;
> }
>
> static int ggtt_insert_node_in_range_locked(struct xe_ggtt_node *node, u32 size,
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> index 7b5221d6f733..22cf19d2b8eb 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> @@ -20,7 +20,7 @@ int xe_ggtt_init(struct xe_ggtt *ggtt);
> void xe_ggtt_resume(struct xe_ggtt *ggtt);
> bool xe_ggtt_has_low_4m_wa(struct xe_ggtt *ggtt);
>
> -void xe_ggtt_shift_nodes(struct xe_ggtt *ggtt, u64 new_base);
> +int xe_ggtt_shift_nodes(struct xe_ggtt *ggtt, u64 new_base);
> u64 xe_ggtt_start(struct xe_ggtt *ggtt);
> u64 xe_ggtt_size(struct xe_ggtt *ggtt);
>
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> index 60f1b29358f9..1a5395486327 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> @@ -531,12 +531,16 @@ static int vf_get_ggtt_info(struct xe_gt *gt)
> /*
> * This function can be called repeatedly from post migration fixups,
> * at which point we inform the GGTT of the new base address.
> - * xe_ggtt_shift_nodes() may be called multiple times for each migration,
> - * but will be a noop if the base is unchanged.
> + * xe_ggtt_shift_nodes() may be called multiple times for each migration.
> + * The nodes stay in place if the base is unchanged, but the low-4MB PTEs
> + * of Wa_14028597154 are mapped again, as they are not migrated.
> */
> - xe_ggtt_shift_nodes(tile->mem.ggtt, start);
> + err = xe_ggtt_shift_nodes(tile->mem.ggtt, start);
> + if (err)
> + xe_gt_sriov_err(gt, "Failed to apply Wa_14028597154 to GGTT %#llx-%#llx (%pe)\n",
> + start, start + size - 1, ERR_PTR(err));
>
> - return 0;
> + return err;
> }
>
> static int vf_get_lmem_info(struct xe_gt *gt)
[-- Attachment #2: Type: text/html, Size: 13551 bytes --]
next prev parent reply other threads:[~2026-12-03 21:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 18:14 [PATCH v2 0/5] Apply Wa_14028597154 to SR-IOV VF Piórkowski, Piotr
2026-12-03 18:14 ` [PATCH v2 1/5] drm/xe: Don't allow disabling multi-queue on PF Piórkowski, Piotr
2026-12-03 20:06 ` Piotr Piórkowski
2026-12-03 20:30 ` Rodrigo Vivi
2026-12-03 18:14 ` [PATCH v2 2/5] drm/xe/ggtt: Align shareable GGTT nodes by GGTT address Piórkowski, Piotr
2026-12-03 20:06 ` Rodrigo Vivi
2026-12-03 18:14 ` [PATCH v2 3/5] drm/xe/tests: Test shareable GGTT alignment " Piórkowski, Piotr
2026-12-03 20:07 ` Rodrigo Vivi
2026-12-03 18:14 ` [PATCH v2 4/5] drm/xe/xe3p_lpg: Apply Wa_14028597154 to SR-IOV PF Piórkowski, Piotr
2026-12-03 20:30 ` Rodrigo Vivi
2026-12-03 18:14 ` [PATCH v2 5/5] drm/xe/xe3p_lpg: Apply Wa_14028597154 to SR-IOV VF Piórkowski, Piotr
2026-12-03 20:31 ` Rodrigo Vivi
2026-12-03 21:39 ` Lis, Tomasz [this message]
2026-12-03 18:28 ` ✓ CI.KUnit: success for Apply Wa_14028597154 to SR-IOV VF (rev2) Patchwork
2026-12-03 19:04 ` ✓ Xe.CI.BAT: " 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=c6e599ee-51ff-4354-93ec-e4ffc4b1ebc4@intel.com \
--to=tomasz.lis@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.s.atwood@intel.com \
--cc=piotr.piorkowski@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=satyanarayana.k.v.p@intel.com \
--cc=tilak.tirumalesh.tangudu@intel.com \
--cc=varun.gupta@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