Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D42B3CD98CF for ; Sat, 13 Jun 2026 01:39:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7402E10EBAD; Sat, 13 Jun 2026 01:39:06 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="EowLheD2"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5AB7510EBAD for ; Sat, 13 Jun 2026 01:39:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781314744; x=1812850744; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=k2QCXQaOaloPYon4v8DFsZiFN8M0PY8O7VOwr9utW5w=; b=EowLheD2e0c702L54bfHNZluvtTwhHx/3+xQbCXHre6pc68PqF3INPYZ xchaXZRuS/o2aU3uMyL7Xrp9x+JP/JVR0b4aXVLLqWoB/oQlopEVLwd6K ZEfC/mhiSKmQQX0Xefd7FJEzdI5OUzSKawcF5ytBENf1WTh+uojP2VOjx xBh9XHaIiIzFbdZnpo0FjPOg58JeS1Ak8rp2XC9BgjZaALjVQrmV47nWx l+uQODOEp8M8pZE/YvZ1Wz2K/o/0s2JpO77zFb1oBxs8DXPOpI4Gkj1Lz GL3JCf/tBkSa+su928PEmbPxKB22AN2xyGjF50MkgNIMb9n2lHONjzEqV w==; X-CSE-ConnectionGUID: J+58uanVQBaZM8es8UjU+A== X-CSE-MsgGUID: jGtxeIucQSKAa0XnSSfcCw== X-IronPort-AV: E=McAfee;i="6800,10657,11815"; a="93644716" X-IronPort-AV: E=Sophos;i="6.24,201,1774335600"; d="scan'208";a="93644716" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2026 18:39:04 -0700 X-CSE-ConnectionGUID: BRcYc2uwQ16MC5qHsaGmEQ== X-CSE-MsgGUID: XJoXJd/rSVSjqpFvhjkzgA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,201,1774335600"; d="scan'208";a="251249134" Received: from gsse-cloud1.jf.intel.com ([10.54.39.91]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2026 18:39:04 -0700 From: Matthew Brost To: intel-xe@lists.freedesktop.org Subject: [PATCH v4] drm/xe: Disable scheduling early on FD close to avoid CAT error cascade Date: Fri, 12 Jun 2026 18:38:59 -0700 Message-Id: <20260613013859.3886196-1-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" When an FD is closed with many exec queues, teardown relies on the TDR path to clean up scheduling. However, the TDR handling is serialized (i.e., only one exec queue is processed at a time), which can make it too slow compared to GuC scheduling activity. In this window, GuC may continue to schedule contexts backed by invalid page tables, leading to a cascade of CAT errors and repeated engine resets. This significantly increases recovery time and can degrade system stability. To mitigate this, eagerly disable scheduling by sending a self-message outside of the TDR path. This prevents further scheduling of invalid contexts and avoids the CAT error/reset cascade. This change improves robustness and reduces recovery latency in multiple queue teardown scenarios. Cc: Wang Xin Cc: Jia Yao Signed-off-by: Matthew Brost Tested-by: Jia Yao --- v3: - Make kill message static tomake reclaim safe (CI) - Do not issue kill messages for queue which bypass cleanup messages (sashiko) v4: - Add missing message lock --- drivers/gpu/drm/xe/xe_guc_exec_queue_types.h | 2 +- drivers/gpu/drm/xe/xe_guc_submit.c | 44 ++++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_guc_exec_queue_types.h b/drivers/gpu/drm/xe/xe_guc_exec_queue_types.h index e5e53b421f29..247947fd357f 100644 --- a/drivers/gpu/drm/xe/xe_guc_exec_queue_types.h +++ b/drivers/gpu/drm/xe/xe_guc_exec_queue_types.h @@ -31,7 +31,7 @@ struct xe_guc_exec_queue { * a message needs to sent through the GPU scheduler but memory * allocations are not allowed. */ -#define MAX_STATIC_MSG_TYPE 3 +#define MAX_STATIC_MSG_TYPE 4 struct xe_sched_msg static_msgs[MAX_STATIC_MSG_TYPE]; /** @destroy_async: do final destroy async from this worker */ struct work_struct destroy_async; diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c index afe5d99cdd8b..5ec1dca0324c 100644 --- a/drivers/gpu/drm/xe/xe_guc_submit.c +++ b/drivers/gpu/drm/xe/xe_guc_submit.c @@ -1875,11 +1875,21 @@ static void __guc_exec_queue_process_msg_set_multi_queue_priority(struct xe_sche kfree(msg); } +static void __guc_exec_queue_process_msg_kill(struct xe_sched_msg *msg) +{ + struct xe_exec_queue *q = msg->private_data; + struct xe_exec_queue *primary = xe_exec_queue_multi_queue_primary(q); + + if (exec_queue_enabled(primary)) + disable_scheduling(primary, true); +} + #define CLEANUP 1 /* Non-zero values to catch uninitialized msg */ #define SET_SCHED_PROPS 2 #define SUSPEND 3 #define RESUME 4 #define SET_MULTI_QUEUE_PRIORITY 5 +#define KILL 6 #define OPCODE_MASK 0xf #define MSG_LOCKED BIT(8) #define MSG_HEAD BIT(9) @@ -1906,6 +1916,9 @@ static void guc_exec_queue_process_msg(struct xe_sched_msg *msg) case SET_MULTI_QUEUE_PRIORITY: __guc_exec_queue_process_msg_set_multi_queue_priority(msg); break; + case KILL: + __guc_exec_queue_process_msg_kill(msg); + break; default: XE_WARN_ON("Unknown message type"); } @@ -2018,11 +2031,39 @@ static int guc_exec_queue_init(struct xe_exec_queue *q) return err; } +static bool guc_exec_queue_try_add_msg(struct xe_exec_queue *q, + struct xe_sched_msg *msg, + u32 opcode); + +#define STATIC_MSG_CLEANUP 0 +#define STATIC_MSG_SUSPEND 1 +#define STATIC_MSG_RESUME 2 +#define STATIC_MSG_KILL 3 static void guc_exec_queue_kill(struct xe_exec_queue *q) { + struct xe_sched_msg *msg = q->guc->static_msgs + STATIC_MSG_KILL; + trace_xe_exec_queue_kill(q); set_exec_queue_killed(q); __suspend_fence_signal(q); + + /* + * We eagerly send a message to ourselves to disable scheduling, as the + * TDR is serialized (i.e., only one exec queue is processed at a time). + * If an FD is closed with many exec queues, the TDR can be slower than + * the GuC scheduling contexts with invalid page tables, creating a + * cascade of CAT errors and engine resets, which is quite slow. Avoid + * this by immediately disabling scheduling outside of the TDR. + */ + if (!(q->flags & EXEC_QUEUE_FLAG_PERMANENT) && + kref_read(&q->refcount) && !exec_queue_wedged(q)) { + struct xe_gpu_scheduler *sched = &q->guc->sched; + + xe_sched_msg_lock(sched); + guc_exec_queue_try_add_msg(q, msg, KILL); + xe_sched_msg_unlock(sched); + } + xe_guc_exec_queue_trigger_cleanup(q); } @@ -2066,9 +2107,6 @@ static bool guc_exec_queue_try_add_msg(struct xe_exec_queue *q, return true; } -#define STATIC_MSG_CLEANUP 0 -#define STATIC_MSG_SUSPEND 1 -#define STATIC_MSG_RESUME 2 static void guc_exec_queue_destroy(struct xe_exec_queue *q) { struct xe_sched_msg *msg = q->guc->static_msgs + STATIC_MSG_CLEANUP; -- 2.34.1