Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Hellstrom, Thomas" <thomas.hellstrom@intel.com>
To: "Tangudu, Tilak Tirumalesh" <tilak.tirumalesh.tangudu@intel.com>,
	"Summers, Stuart" <stuart.summers@intel.com>,
	"intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
	"Ceraolo Spurio, Daniele" <daniele.ceraolospurio@intel.com>,
	"Auld, Matthew" <matthew.auld@intel.com>
Cc: "Brost, Matthew" <matthew.brost@intel.com>
Subject: Re: [PATCH 1/2] drm/xe: include all registered queues in TLB invalidation
Date: Tue, 9 Jun 2026 15:02:18 +0000	[thread overview]
Message-ID: <18d30e971b2763075abb7254b4e2b8d63ab02e35.camel@intel.com> (raw)
In-Reply-To: <20260608162745.338725-2-tilak.tirumalesh.tangudu@intel.com>

On Mon, 2026-06-08 at 21:57 +0530, tilak.tirumalesh.tangudu@intel.com
wrote:
> From: Tangudu Tilak Tirumalesh <tilak.tirumalesh.tangudu@intel.com>
> 
> Context-based TLB invalidation currently selects only scheduling-
> active
> exec queues via q->ops->active(). During rebind flows, queues may be
> suspended (or transitioning through resume) while still owning valid
> translations, causing them to be skipped from invalidation and
> leading
> to missed TLB invalidations on LR rebinds.
> 
> The underlying issue is a TOCTOU: q->guc->state bits are flipped
> lock-free
> from enable_scheduling(), disable_scheduling{,_deregister}(), the
> suspend/resume sched-msg handlers, handle_sched_done(), and
> guc_exec_queue_stop(); nothing in send_tlb_inval_ctx_ppgtt()
> serializes
> against them, so any state-based predicate can race.
> 
> Include all the registered queues so that TLB invalidations are not
> missed. This is race-free because list membership on vm-
> >exec_queues.list
> is stable under vm->exec_queues.lock held by the caller. The
> performance
> impact is expected to be minimal and harmless. If it does turn out to
> be
> a concern, we can come back with a race-safe solution to ignore
> certain
> queues.
> 
> Fixes: 6cdaa5346d6f ("drm/xe: Add context-based invalidation to GuC
> TLB invalidation backend")
> Assisted-by: Claude:claude-opus-4.6
> Suggested-by: Thomas Hellstrom <thomas.hellstrom@linux.intel.com>
> Signed-off-by: Tangudu Tilak Tirumalesh

Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>

But let's hold merging for a little while and see if Matt Brost has a
different idea on how to approach this, and if so whether we should
implement that as a follow up.

Thanks, Thomas



> <tilak.tirumalesh.tangudu@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_guc_tlb_inval.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 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..cf6d106e6036 100644
> --- a/drivers/gpu/drm/xe/xe_guc_tlb_inval.c
> +++ b/drivers/gpu/drm/xe/xe_guc_tlb_inval.c
> @@ -255,9 +255,8 @@ static int send_tlb_inval_ctx_ppgtt(struct
> xe_tlb_inval *tlb_inval, u32 seqno,
>  #undef EXEC_QUEUE_COUNT_FULL_THRESHOLD
>  
>  	/*
> -	 * Move exec queues to a temporary list to issue
> invalidations. The exec
> -	 * queue must active and a reference must be taken to
> prevent concurrent
> -	 * deregistrations.
> +	 * Move exec queues to a temporary list to issue
> invalidations. A
> +	 * reference must be taken to prevent concurrent
> deregistrations.
>  	 *
>  	 * List modification is safe because we hold 'vm-
> >exec_queues.lock' for
>  	 * reading, which prevents external modifications. Using a
> per-GT list
> @@ -266,7 +265,7 @@ static int send_tlb_inval_ctx_ppgtt(struct
> xe_tlb_inval *tlb_inval, u32 seqno,
>  	 */
>  	list_for_each_entry_safe(q, next, &vm->exec_queues.list[id],
>  				 vm_exec_queue_link) {
> -		if (q->ops->active(q) &&
> xe_exec_queue_get_unless_zero(q)) {
> +		if (xe_exec_queue_get_unless_zero(q)) {
>  			last_q = q;
>  			list_move_tail(&q->vm_exec_queue_link,
> &tlb_inval_list);
>  		}

  reply	other threads:[~2026-06-09 15:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08 16:27 [PATCH 0/2] drm/xe: include all registered queues in TLB invalidation tilak.tirumalesh.tangudu
2026-06-08 16:27 ` [PATCH 1/2] " tilak.tirumalesh.tangudu
2026-06-09 15:02   ` Hellstrom, Thomas [this message]
2026-06-09 15:04     ` Matthew Brost
2026-06-08 16:27 ` [PATCH 2/2] drm/xe: drop unused xe_exec_queue_ops::active callback tilak.tirumalesh.tangudu
2026-06-09 15:03   ` Hellstrom, Thomas
2026-06-09 15:04   ` Matthew Brost
2026-06-08 16:38 ` ✓ CI.KUnit: success for drm/xe: include all registered queues in TLB invalidation Patchwork
2026-06-09  6:49 ` ✓ CI.KUnit: success for drm/xe: include all registered queues in TLB invalidation (rev2) Patchwork
2026-06-09  7:55 ` ✓ Xe.CI.BAT: " Patchwork
2026-06-09 17:53 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-06-09 18:22   ` Tangudu, Tilak Tirumalesh
2026-06-09 20:12     ` Lin, Shuicheng

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=18d30e971b2763075abb7254b4e2b8d63ab02e35.camel@intel.com \
    --to=thomas.hellstrom@intel.com \
    --cc=daniele.ceraolospurio@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=stuart.summers@intel.com \
    --cc=tilak.tirumalesh.tangudu@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