Skip to content

Commit 9f64b3c

Browse files
ShuichengLinlucasdemarchi
authored andcommitted
drm/xe/guc: Check GuC running state before deregistering exec queue
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 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. Fixes: dd08ebf ("drm/xe: Introduce a new DRM driver for Intel GPUs") Cc: stable@vger.kernel.org Cc: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Matthew Brost <matthew.brost@intel.com> Link: https://lore.kernel.org/r/20251010172529.2967639-2-shuicheng.lin@intel.com (cherry picked from commit 9b42321a02c50a12b2beb6ae9469606257fbecea) Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
1 parent 1852d27 commit 9f64b3c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/gpu/drm/xe/xe_guc_submit.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "xe_ring_ops_types.h"
4545
#include "xe_sched_job.h"
4646
#include "xe_trace.h"
47+
#include "xe_uc_fw.h"
4748
#include "xe_vm.h"
4849

4950
static struct xe_guc *
@@ -1489,7 +1490,17 @@ static void __guc_exec_queue_process_msg_cleanup(struct xe_sched_msg *msg)
14891490
xe_gt_assert(guc_to_gt(guc), !(q->flags & EXEC_QUEUE_FLAG_PERMANENT));
14901491
trace_xe_exec_queue_cleanup_entity(q);
14911492

1492-
if (exec_queue_registered(q))
1493+
/*
1494+
* Expected state transitions for cleanup:
1495+
* - If the exec queue is registered and GuC firmware is running, we must first
1496+
* disable scheduling and deregister the queue to ensure proper teardown and
1497+
* resource release in the GuC, then destroy the exec queue on driver side.
1498+
* - If the GuC is already stopped (e.g., during driver unload or GPU reset),
1499+
* we cannot expect a response for the deregister request. In this case,
1500+
* it is safe to directly destroy the exec queue on driver side, as the GuC
1501+
* will not process further requests and all resources must be cleaned up locally.
1502+
*/
1503+
if (exec_queue_registered(q) && xe_uc_fw_is_running(&guc->fw))
14931504
disable_scheduling_deregister(guc, q);
14941505
else
14951506
__guc_exec_queue_destroy(guc, q);

0 commit comments

Comments
 (0)