From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Matthew Brost <matthew.brost@intel.com>, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH] drm/xe: Skip media GT TLB invalidation when VM has no queues mapped
Date: Fri, 20 Mar 2026 14:06:51 +0100 [thread overview]
Message-ID: <140f8047a6c5d798dce8c2970d6c47e4033b3e19.camel@linux.intel.com> (raw)
In-Reply-To: <20260304233728.926378-1-matthew.brost@intel.com>
On Wed, 2026-03-04 at 15:37 -0800, Matthew Brost wrote:
> If no exec queues from a VM are mapped on the media GT, issuing a
> PPGTT TLB invalidation for that GT requires an rc6 wake which is
> expensive.
>
> Skip the media GT TLB invalidation when the VM has no exec queues
> mapped on it. If TLB invalidations are already in-flight on that GT
> we can't break fence ordering, so issue a dummy GGTT invalidation
> instead to maintain seqno ordering.
>
> This optimization is particularly impactful for SVM workloads which
> may or may not use the media GT. Average TLB invalidation time drops
> from ~75us to ~18us in such benchmarks.
>
> Assisted-by: GitHub Copilot:claude-sonnet-4.6 # Documentation only.
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Can we make this gt type agnostic so that regardless of gt type,
we skip tlb invalidations if there are no active exec-queues?
/Thomas
> ---
> drivers/gpu/drm/xe/xe_guc_tlb_inval.c | 43
> +++++++++++++++++++++++++--
> 1 file changed, 41 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_guc_tlb_inval.c
> b/drivers/gpu/drm/xe/xe_guc_tlb_inval.c
> index ced58f46f846..20c34469d9a5 100644
> --- a/drivers/gpu/drm/xe/xe_guc_tlb_inval.c
> +++ b/drivers/gpu/drm/xe/xe_guc_tlb_inval.c
> @@ -205,14 +205,53 @@ static int send_tlb_inval_asid_ppgtt(struct
> xe_tlb_inval *tlb_inval, u32 seqno,
> struct drm_suballoc *prl_sa)
> {
> struct xe_guc *guc = tlb_inval->private;
> + struct xe_device *xe = guc_to_xe(guc);
> + struct xe_gt *gt = guc_to_gt(guc);
> + struct xe_vm *vm;
> + int err = 0, id = guc_to_gt(guc)->info.id;
>
> lockdep_assert_held(&tlb_inval->seqno_lock);
>
> if (guc_to_xe(guc)->info.force_execlist)
> return -ECANCELED;
>
> - return send_tlb_inval_ppgtt(guc, seqno, start, end, asid,
> - XE_GUC_TLB_INVAL_PAGE_SELECTIVE,
> prl_sa);
> + if (!xe_gt_is_media_type(gt))
> + return send_tlb_inval_ppgtt(guc, seqno, start, end,
> asid,
> +
> XE_GUC_TLB_INVAL_PAGE_SELECTIVE,
> + prl_sa);
> +
> + /* Try to skip media GT TLB invalidations */
> +
> + vm = xe_device_asid_to_vm(xe, asid);
> + if (IS_ERR(vm))
> + return PTR_ERR(vm);
> +
> + down_read(&vm->exec_queues.lock);
> +
> + if (!vm->exec_queues.count[id]) {
> + /*
> + * We can't break fence ordering for TLB
> invalidation jobs, if
> + * TLB invalidations are inflight issue a dummy
> invalidation to
> + * maintain ordering. Nor can we move safely the
> seqno_recv when
> + * returning -ECANCELED if TLB invalidations are in
> flight. Use
> + * GGTT invalidation as dummy invalidation given
> ASID
> + * invalidations are unsupported here.
> + */
> + if (xe_tlb_inval_idle(tlb_inval))
> + err = -ECANCELED;
> + else
> + err = send_tlb_inval_ggtt(tlb_inval, seqno);
> + goto err_unlock;
> + }
> +
> + err = send_tlb_inval_ppgtt(guc, seqno, start, end, asid,
> + XE_GUC_TLB_INVAL_PAGE_SELECTIVE,
> prl_sa);
> +
> +err_unlock:
> + up_read(&vm->exec_queues.lock);
> + xe_vm_put(vm);
> +
> + return err;
> }
>
> static int send_tlb_inval_ctx_ppgtt(struct xe_tlb_inval *tlb_inval,
> u32 seqno,
next prev parent reply other threads:[~2026-03-20 13:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-04 23:37 [PATCH] drm/xe: Skip media GT TLB invalidation when VM has no queues mapped Matthew Brost
2026-03-05 22:47 ` ✗ CI.checkpatch: warning for " Patchwork
2026-03-05 22:48 ` ✓ CI.KUnit: success " Patchwork
2026-03-06 0:19 ` ✓ Xe.CI.BAT: " Patchwork
2026-03-06 18:07 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-03-20 13:06 ` Thomas Hellström [this message]
2026-03-23 7:00 ` [PATCH] " Matthew Brost
2026-03-23 16:13 ` Summers, Stuart
2026-03-23 16:17 ` Matthew Brost
2026-03-23 16:26 ` Summers, Stuart
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=140f8047a6c5d798dce8c2970d6c47e4033b3e19.camel@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@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