Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <saurabhg.gupta@intel.com>,
	<alex.zuo@intel.com>, <stuart.summers@intel.com>
Subject: Re: [PATCH] drm/xe/xe_guc_ct: Exit CT submission fence wait on GT reset
Date: Tue, 9 Dec 2025 12:59:26 -0800	[thread overview]
Message-ID: <aTiNrtW2pl3gK+do@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20251209203516.155703-2-jonathan.cavitt@intel.com>

On Tue, Dec 09, 2025 at 08:35:17PM +0000, Jonathan Cavitt wrote:
> It's possible if unlikely that the GuC could be reset in the time
> between performing a guc_ct_send and the G2H fence completing in
> guc_ct_send_recv.  Exit early if this is occurs.
> 
> Suggested-by: Stuart Summers <stuart.summers@intel.com>
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_guc_ct.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_ct.c
> index 648f0f523abb..438a460106db 100644
> --- a/drivers/gpu/drm/xe/xe_guc_ct.c
> +++ b/drivers/gpu/drm/xe/xe_guc_ct.c
> @@ -1231,6 +1231,10 @@ int xe_guc_ct_send_g2h_handler(struct xe_guc_ct *ct, const u32 *action, u32 len)
>  	return ret;
>  }
>  
> +#define ct_alive(ct)    \
> +	(xe_guc_ct_enabled(ct) && !ct->ctbs.h2g.info.broken && \

I just noticed this - xe_guc_ct_enabled probably needs a READ_ONCE to
avoid the compiler optimizing this out too. The existing code is in
retry_failure is dead code in Xe and actually probably doesn't work.
Also we probably want WRITE_ONCE on ct->state in guc_ct_change_state too
pair with this read once.

Likewise g2h.done should set / read with these macros. I think we are
just getting luckly compilers are not optimizing this stuff out.

The broken checks I think are fine as is as when we toggle those states
we don't wakeup the waiters.

Matt

> +	 !ct->ctbs.g2h.info.broken)
> +
>  /*
>   * Check if a GT reset is in progress or will occur and if GT reset brought the
>   * CT back up. Randomly picking 5 seconds for an upper limit to do a GT a reset.
> @@ -1240,12 +1244,8 @@ static bool retry_failure(struct xe_guc_ct *ct, int ret)
>  	if (!(ret == -EDEADLK || ret == -EPIPE || ret == -ENODEV))
>  		return false;
>  
> -#define ct_alive(ct)	\
> -	(xe_guc_ct_enabled(ct) && !ct->ctbs.h2g.info.broken && \
> -	 !ct->ctbs.g2h.info.broken)
>  	if (!wait_event_interruptible_timeout(ct->wq, ct_alive(ct), HZ * 5))
>  		return false;
> -#undef ct_alive
>  
>  	return true;
>  }
> @@ -1294,7 +1294,7 @@ static int guc_ct_send_recv(struct xe_guc_ct *ct, const u32 *action, u32 len,
>  		return ret;
>  	}
>  
> -	ret = wait_event_timeout(ct->g2h_fence_wq, g2h_fence.done, HZ);
> +	ret = wait_event_timeout(ct->g2h_fence_wq, !ct_alive(ct) || g2h_fence.done, HZ);
>  	if (!ret) {
>  		LNL_FLUSH_WORK(&ct->g2h_worker);
>  		if (g2h_fence.done) {
> -- 
> 2.43.0
> 

  reply	other threads:[~2025-12-09 20:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-09 20:35 [PATCH] drm/xe/xe_guc_ct: Exit CT submission fence wait on GT reset Jonathan Cavitt
2025-12-09 20:59 ` Matthew Brost [this message]
2025-12-10 11:55 ` ✗ CI.checkpatch: warning for " Patchwork
2025-12-10 11:56 ` ✓ CI.KUnit: success " Patchwork
2025-12-10 12:38 ` ✓ Xe.CI.BAT: " Patchwork
2025-12-10 18:07 ` ✗ 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=aTiNrtW2pl3gK+do@lstrano-desk.jf.intel.com \
    --to=matthew.brost@intel.com \
    --cc=alex.zuo@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jonathan.cavitt@intel.com \
    --cc=saurabhg.gupta@intel.com \
    --cc=stuart.summers@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