From: Matthew Brost <matthew.brost@intel.com>
To: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
Michal Wajdeczko <michal.wajdeczko@intel.com>
Subject: Re: [PATCH 1/4] drm/xe: Use PPGTT addresses for TLB invalidation to avoid GGTT fixups
Date: Mon, 22 Sep 2025 10:47:07 -0700 [thread overview]
Message-ID: <aNGLm+8aW+w24xz3@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20250918073002.15242-7-satyanarayana.k.v.p@intel.com>
On Thu, Sep 18, 2025 at 01:00:04PM +0530, Satyanarayana K V P wrote:
> The migrate VM builds the CCS metadata save/restore batch buffer (BB) in
> advance and retains it so the GuC can submit it directly when saving a
> VM’s state.
>
> When a VM migrates between VFs, the GGTT base can change. Any GGTT-based
> addresses embedded in the BB would then have to be parsed and patched.
>
> Use PPGTT addresses in the BB (including for TLB invalidation) so the BB
> remains GGTT-agnostic and requires no address fixups during migration.
>
> Signed-off-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
Longterm we need a bit of cleanup in xe_migrate.c to really make it
clear how the kernel PTEs are being used + kernel doc but as far as I
can tell this change should work with the current code base.
With that:
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/xe/xe_migrate.c | 28 ++++++++++++++++++++--------
> 1 file changed, 20 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
> index 6fad5d469629..d375ebc9323d 100644
> --- a/drivers/gpu/drm/xe/xe_migrate.c
> +++ b/drivers/gpu/drm/xe/xe_migrate.c
> @@ -971,15 +971,27 @@ struct xe_lrc *xe_migrate_lrc(struct xe_migrate *migrate)
> return migrate->q->lrc[0];
> }
>
> -static int emit_flush_invalidate(struct xe_exec_queue *q, u32 *dw, int i,
> - u32 flags)
> +static u64 migrate_vm_ppgtt_addr_tlb_inval(void)
> {
> - struct xe_lrc *lrc = xe_exec_queue_lrc(q);
> + /*
> + * The migrate VM is self-referential so it can modify its own PTEs (see
> + * pte_update_size() or emit_pte() functions). We reserve NUM_KERNEL_PDE
> + * entries for kernel operations (copies, clears, CCS migrate), and
> + * suballocate the rest to user operations (binds/unbinds). With
> + * NUM_KERNEL_PDE = 15, NUM_KERNEL_PDE - 1 is already used for PTE updates,
> + * so assign NUM_KERNEL_PDE - 2 for TLB invalidation.
> + */
> + return (NUM_KERNEL_PDE - 2) * XE_PAGE_SIZE;
> +}
> +
> +static int emit_flush_invalidate(u32 *dw, int i, u32 flags)
> +{
> + u64 addr = migrate_vm_ppgtt_addr_tlb_inval();
> +
> dw[i++] = MI_FLUSH_DW | MI_INVALIDATE_TLB | MI_FLUSH_DW_OP_STOREDW |
> MI_FLUSH_IMM_DW | flags;
> - dw[i++] = lower_32_bits(xe_lrc_start_seqno_ggtt_addr(lrc)) |
> - MI_FLUSH_DW_USE_GTT;
> - dw[i++] = upper_32_bits(xe_lrc_start_seqno_ggtt_addr(lrc));
> + dw[i++] = lower_32_bits(addr);
> + dw[i++] = upper_32_bits(addr);
> dw[i++] = MI_NOOP;
> dw[i++] = MI_NOOP;
>
> @@ -1092,11 +1104,11 @@ int xe_migrate_ccs_rw_copy(struct xe_tile *tile, struct xe_exec_queue *q,
>
> emit_pte(m, bb, ccs_pt, false, false, &ccs_it, ccs_size, src);
>
> - bb->len = emit_flush_invalidate(q, bb->cs, bb->len, flush_flags);
> + bb->len = emit_flush_invalidate(bb->cs, bb->len, flush_flags);
> flush_flags = xe_migrate_ccs_copy(m, bb, src_L0_ofs, src_is_pltt,
> src_L0_ofs, dst_is_pltt,
> src_L0, ccs_ofs, true);
> - bb->len = emit_flush_invalidate(q, bb->cs, bb->len, flush_flags);
> + bb->len = emit_flush_invalidate(bb->cs, bb->len, flush_flags);
>
> size -= src_L0;
> }
> --
> 2.51.0
>
next prev parent reply other threads:[~2025-09-22 17:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-18 7:30 [PATCH 0/4] Improve CCS save/restore series (cont..) Satyanarayana K V P
2025-09-18 7:20 ` ✓ CI.KUnit: success for " Patchwork
2025-09-18 7:30 ` [PATCH 1/4] drm/xe: Use PPGTT addresses for TLB invalidation to avoid GGTT fixups Satyanarayana K V P
2025-09-22 17:47 ` Matthew Brost [this message]
2025-09-22 17:58 ` Matthew Brost
2025-09-18 7:30 ` [PATCH 2/4] drm/xe/lrc: Add helper to query post-init ring tail Satyanarayana K V P
2025-09-18 7:30 ` [PATCH 3/4] drm/xe/vf: Post migration fixups for CCS save/restore Satyanarayana K V P
2025-09-22 17:57 ` Matthew Brost
2025-09-18 7:30 ` [PATCH 4/4] drm/xe/guc: Increase wait timeout to 2sec after BUSY reply from GuC Satyanarayana K V P
2025-09-22 18:18 ` Matthew Brost
2025-09-18 8:08 ` ✓ Xe.CI.BAT: success for Improve CCS save/restore series (cont..) Patchwork
2025-09-18 13:28 ` ✗ Xe.CI.Full: failure " 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=aNGLm+8aW+w24xz3@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=michal.wajdeczko@intel.com \
--cc=satyanarayana.k.v.p@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