Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: Shuicheng Lin <shuicheng.lin@intel.com>, intel-xe@lists.freedesktop.org
Cc: lucas.demarchi@intel.com, michal.wajdeczko@intel.com,
	Matthew Brost <matthew.brost@intel.com>
Subject: Re: [PATCH v2] drm/xe/guc: Check GuC running state before deregistering exec queue
Date: Tue, 14 Oct 2025 09:58:46 +0100	[thread overview]
Message-ID: <9d6c807a-0d7a-4141-abb0-0ea115666614@intel.com> (raw)
In-Reply-To: <20251010172529.2967639-2-shuicheng.lin@intel.com>

On 10/10/2025 18:25, Shuicheng Lin wrote:
> In normal operation, a registered exec queue is disabled and
> deregistered through the GuC, and freed only after the GuC confirms
> completion. However, if the driver is forced to unbind while the exec

With forced to unbind do you mean the device unplug/unbind flow? If so, 
would it make sense to use the drm_dev_enter/exit API here? Checking 
xe_uc_fw_is_running sounds like it could be racy?

> queue is still running, the user may call exec_destroy() after the GuC
> has already been stopped and CT communication disabled.
> 
> In this case, the driver cannot receive a response from the GuC,
> preventing proper cleanup of exec queue resources. Fix this by directly
> releasing the resources when GuC is not running.
> 
> Here is the failure dmesg log:
> "
> [  468.089581] ---[ end trace 0000000000000000 ]---
> [  468.089608] pci 0000:03:00.0: [drm] *ERROR* GT0: GUC ID manager unclean (1/65535)
> [  468.090558] pci 0000:03:00.0: [drm] GT0:     total 65535
> [  468.090562] pci 0000:03:00.0: [drm] GT0:     used 1
> [  468.090564] pci 0000:03:00.0: [drm] GT0:     range 1..1 (1)
> [  468.092716] ------------[ cut here ]------------
> [  468.092719] WARNING: CPU: 14 PID: 4775 at drivers/gpu/drm/xe/xe_ttm_vram_mgr.c:298 ttm_vram_mgr_fini+0xf8/0x130 [xe]
> "
> 
> v2: use xe_uc_fw_is_running() instead of xe_guc_ct_enabled().
>      As CT may go down and come back during VF migration.
> 
> Cc: Matthew Brost <matthew.brost@intel.com>
> Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
> ---
>   drivers/gpu/drm/xe/xe_guc_submit.c | 13 ++++++++++++-
>   1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> index e9aa0625ce60..0ef67d3523a7 100644
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -44,6 +44,7 @@
>   #include "xe_ring_ops_types.h"
>   #include "xe_sched_job.h"
>   #include "xe_trace.h"
> +#include "xe_uc_fw.h"
>   #include "xe_vm.h"
>   
>   static struct xe_guc *
> @@ -1501,7 +1502,17 @@ static void __guc_exec_queue_process_msg_cleanup(struct xe_sched_msg *msg)
>   	xe_gt_assert(guc_to_gt(guc), !(q->flags & EXEC_QUEUE_FLAG_PERMANENT));
>   	trace_xe_exec_queue_cleanup_entity(q);
>   
> -	if (exec_queue_registered(q))
> +	/*
> +	 * Expected state transitions for cleanup:
> +	 * - If the exec queue is registered and GuC firmware is running, we must first
> +	 *   disable scheduling and deregister the queue to ensure proper teardown and
> +	 *   resource release in the GuC, then destroy the exec queue on driver side.
> +	 * - If the GuC is already stopped (e.g., during driver unload or GPU reset),
> +	 *   we cannot expect a response for the deregister request. In this case,
> +	 *   it is safe to directly destroy the exec queue on driver side, as the GuC
> +	 *   will not process further requests and all resources must be cleaned up locally.
> +	 */
> +	if (exec_queue_registered(q) && xe_uc_fw_is_running(&guc->fw))
>   		disable_scheduling_deregister(guc, q);
>   	else
>   		__guc_exec_queue_destroy(guc, q);


  parent reply	other threads:[~2025-10-14  8:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-04 17:30 [PATCH] drm/xe/guc: Check CT enable state before deregistering exec queue Shuicheng Lin
2025-10-04 17:52 ` ✓ CI.KUnit: success for " Patchwork
2025-10-04 18:27 ` ✓ Xe.CI.BAT: " Patchwork
2025-10-04 19:43 ` ✓ Xe.CI.Full: " Patchwork
2025-10-07 14:59 ` [PATCH] " Lin, Shuicheng
2025-10-07 15:09   ` Matthew Brost
2025-10-07 17:59     ` Lin, Shuicheng
2025-10-07 18:37       ` Matthew Brost
2025-10-08 17:49         ` Lin, Shuicheng
2025-10-10 17:25 ` [PATCH v2] drm/xe/guc: Check GuC running " Shuicheng Lin
2025-10-11 15:13   ` Matthew Brost
2025-10-11 21:35     ` Lin, Shuicheng
2025-10-13  2:06       ` Matthew Brost
2025-10-14  8:58   ` Matthew Auld [this message]
2025-10-14 15:15     ` Lin, Shuicheng
2025-10-10 17:36 ` ✓ CI.KUnit: success for drm/xe/guc: Check CT enable state before deregistering exec queue (rev2) Patchwork
2025-10-10 18:28 ` ✓ Xe.CI.BAT: " Patchwork
2025-10-11  0:11 ` ✓ Xe.CI.Full: " 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=9d6c807a-0d7a-4141-abb0-0ea115666614@intel.com \
    --to=matthew.auld@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=shuicheng.lin@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