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 D57B4D711C8 for ; Thu, 18 Dec 2025 21:44:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 81D0210EB8B; Thu, 18 Dec 2025 21:44:25 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="F2xKBoS+"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9E29910EB8B for ; Thu, 18 Dec 2025 21:44:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1766094264; x=1797630264; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=IZyNz54wsWfN379pGAfAeHhWYiueHxwugKlBN6W94zo=; b=F2xKBoS+Oj9vje1acyzM4m8kfKW7P3PAr+6w0LyW1hZoP9E9Idl0NJci WtPXEVVASY6fXEAQv0FQ4GGj+dZ7Ogy0G2DVH4ve28aaXMcTvjuVrWKEE hUM7zcj5FxIEH3koCbouEDBt4mUtOEby+Dv4GFV6/u9fcNSrrlfsdWF8w 5xFG+QryEZnFgw2MbQnkELPQjJIW3kCqRSbgGvmhjzlMsA2QD0Zr5fIhn rIpwMFyJPVHExaBcFEeTNSeaAUcr4HTKoKnhYAFVAgDJZSvRVoAfjZrTo 4NBmVhqT2Q1xjPGkJO5Y8TMBVp0lQj/BRTuVe/bg84kxk2sY4skYF1dwS w==; X-CSE-ConnectionGUID: qq4C9GcQRSqsVN1YkEFY8Q== X-CSE-MsgGUID: G7NQonIuQe+VRJGMftbJVg== X-IronPort-AV: E=McAfee;i="6800,10657,11646"; a="68104130" X-IronPort-AV: E=Sophos;i="6.21,159,1763452800"; d="scan'208";a="68104130" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2025 13:44:24 -0800 X-CSE-ConnectionGUID: C1Xd2ex7QIq66WZC4Dt4+w== X-CSE-MsgGUID: 4Q0TamgjSKu3HLG0obMumg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,159,1763452800"; d="scan'208";a="199166552" Received: from lstrano-desk.jf.intel.com ([10.54.39.91]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2025 13:44:24 -0800 From: Matthew Brost To: intel-xe@lists.freedesktop.org Subject: [PATCH v2 2/3] drm/xe: Forcefully tear down exec queues in GuC submit fini Date: Thu, 18 Dec 2025 13:44:17 -0800 Message-Id: <20251218214418.4037401-3-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251218214418.4037401-1-matthew.brost@intel.com> References: <20251218214418.4037401-1-matthew.brost@intel.com> 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" In GuC submit fini, forcefully tear down any exec queues by disabling CTs, stopping the scheduler (which cleans up lost G2H), killing all remaining queues, and resuming scheduling to allow any remaining cleanup actions to complete and signal any remaining fences. v2: - Fix VF failure (CI) Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs") Cc: stable@vger.kernel.org Signed-off-by: Zhanjun Dong Signed-off-by: Matthew Brost --- This fix will not apply outright to any stable kernel as it depeneds on functions which have added in the KMD since the original commit. Likely will have to manually send out patches to stable for kernel which we'd like to fix. --- drivers/gpu/drm/xe/xe_guc_submit.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c index 071cbfec2401..58ec94439df1 100644 --- a/drivers/gpu/drm/xe/xe_guc_submit.c +++ b/drivers/gpu/drm/xe/xe_guc_submit.c @@ -289,6 +289,8 @@ static bool exec_queue_killed_or_banned_or_wedged(struct xe_exec_queue *q) EXEC_QUEUE_STATE_BANNED)); } +static int __xe_guc_submit_reset_prepare(struct xe_guc *guc); + static void guc_submit_fini(struct drm_device *drm, void *arg) { struct xe_guc *guc = arg; @@ -296,6 +298,12 @@ static void guc_submit_fini(struct drm_device *drm, void *arg) struct xe_gt *gt = guc_to_gt(guc); int ret; + /* Forcefully kill any remaining exec queues */ + xe_guc_ct_stop(&guc->ct); + __xe_guc_submit_reset_prepare(guc); + xe_guc_submit_stop(guc); + xe_guc_submit_pause_abort(guc); + ret = wait_event_timeout(guc->submission_state.fini_wq, xa_empty(&guc->submission_state.exec_queue_lookup), HZ * 5); @@ -2459,16 +2467,10 @@ static void guc_exec_queue_stop(struct xe_guc *guc, struct xe_exec_queue *q) } } -int xe_guc_submit_reset_prepare(struct xe_guc *guc) +static int __xe_guc_submit_reset_prepare(struct xe_guc *guc) { int ret; - if (xe_gt_WARN_ON(guc_to_gt(guc), vf_recovery(guc))) - return 0; - - if (!guc->submission_state.initialized) - return 0; - /* * Using an atomic here rather than submission_state.lock as this * function can be called while holding the CT lock (engine reset @@ -2483,6 +2485,17 @@ int xe_guc_submit_reset_prepare(struct xe_guc *guc) return ret; } +int xe_guc_submit_reset_prepare(struct xe_guc *guc) +{ + if (xe_gt_WARN_ON(guc_to_gt(guc), vf_recovery(guc))) + return 0; + + if (!guc->submission_state.initialized) + return 0; + + return __xe_guc_submit_reset_prepare(guc); +} + void xe_guc_submit_reset_wait(struct xe_guc *guc) { wait_event(guc->ct.wq, xe_device_wedged(guc_to_xe(guc)) || -- 2.34.1