From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796383064; b=Ne6BNRAhkXhxcfHSg2kmVisgSkJKAqhT1qJCAKxxQKxv+ezhe2zrf//9XbESTwKZOw1d HbakiHm4rI42xHGGR5na4PBc9MK1zlD/RwFQxd3aXj0Bkd+YZGMb2P/m7EPdXEQodIlvb gZAQjV+OfCA5CSVWpCCrAgPCIEtC+DC3Mhb5gtm6yOPQ7L2ea/jS/EkPtSy5QOXbfpKB0 Y3DWBxrVEQRoV1/InmbppXnoFubGYk9iV7zZ8Envt9h+2kXG4ohAZCUtgxeod28ZUV3tq ffsQrVHg43OF08R8Rx7lf8675fzjLHy5I2pfO83UtRCzsRwBdkBMrMc7ssKAurP4jQw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383064; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=FuTZAwsINT2+yYFwSn6bk8lB74nBUdeqWQhpifOOYdo=; b=4LzfrqhJ8Op5tP2gqPvUPkUBVh7z5M535o7+Djkkfk365XLevYi5T850oaeoZmYm/Zpk tNUx4cfi8d0fBq+drxaJml3SfAjIMY13jLrTf7GVOOam1KcLOcVxqZvFbN4ydow0JGE3y OB1NO3X0l7dKYVMnvEtgC2wIHC+L+qyRRcHHXAOQah1z9RVyyCc0GykbjelH88FHjWBKQ +BnNcLFSu4ro2b0buFn9DMe78a1gnh/AhwdH4dUfEi0QW9BTS89g8xq8LdG3O6pt1yJFI Xvz6ocDLoMOwl2C08mheGqik0ejnNV1gSVswpl1CbIvtfueFKMEwFWvF77IV7KPuEyw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=PJlbWKU+; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 600AE606A322; Fri, 4 Dec 2026 11:17:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=PJlbWKU+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 979611F00897; Fri, 4 Dec 2026 11:17:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383064; bh=FuTZAwsINT2+yYFwSn6bk8lB74nBUdeqWQhpifOOYdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PJlbWKU+Su9gE+rjGH7DMlLidu+AyNcp+hNk/TRxW6GhUClcv5LrcN/1mAVjTIcxa JGYocm5ewaJFZVpjI6xHY0SEJHGAPodqYyyvxeTkCAyZeMEGLkA6U1mGEhgQmw9r0q nVtt7xivB0rQYxQraxrmbV0/Kd5arP4PWYMxoXqU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Chen, Junjia" , Matthew Brost , Dave Airlie , Sasha Levin Subject: [PATCH 6.18 677/703] drm/xe: Unwrap sync fences before adding them as job dependencies Date: Fri, 4 Dec 2026 19:09:36 +0900 Message-ID: <20261204100645.822025794@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Chen, Junjia" [ Upstream commit e2cdad51ec53dd0f48e7f767cc1390dec69d54d4 ] A timeline syncobj point is a dma_fence_chain node that carries its own fence context, separate from the contexts of the fences it wraps. xe_sync_entry_add_deps() passed that container straight to drm_sched_job_add_dependency(). drm_sched_entity_add_dependency_cb() only drops a dependency when the fence context is one of the entity's own (fence_context or fence_context + 1). A chain node never matches, so a wait on a point whose inner fence is the finished fence of an earlier job on the same exec queue is treated like a cross-queue dependency: the job is held until the previous job has completed on the GPU. Every job queued behind it waits too, and the ring drains before the next batch of jobs is released. Unwrap the fence with dma_fence_unwrap_for_each() and add each unsignaled underlying fence as a dependency, so drm_sched sees the real fence contexts and ignores same-entity fences. Dependencies on other exec queues still wait for completion. drm_sched_job_add_dependency() keeps only the latest fence per context, so the dependency array does not grow with the length of the chain. Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs") Cc: stable@vger.kernel.org Signed-off-by: Chen, Junjia Reviewed-by: Matthew Brost Signed-off-by: Matthew Brost Link: https://lore.kernel.org/intel-xe/20261028161358.1917359-1-junjia.chen@intel.com/ (cherry picked from commit 3b8860fe2581a8db796150728687ba1c6b78ddab) Signed-off-by: Matthew Brost Signed-off-by: Dave Airlie [ sashal: Adjusted include-list context: the file lacks the error-injection.h include and the next function has no kernel-doc comment, while the changed function body matches upstream. ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/xe/xe_sync.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) --- a/drivers/gpu/drm/xe/xe_sync.c +++ b/drivers/gpu/drm/xe/xe_sync.c @@ -6,6 +6,7 @@ #include "xe_sync.h" #include +#include #include #include #include @@ -233,11 +234,35 @@ ALLOW_ERROR_INJECTION(xe_sync_entry_pars int xe_sync_entry_add_deps(struct xe_sync_entry *sync, struct xe_sched_job *job) { - if (sync->fence) - return drm_sched_job_add_dependency(&job->drm, - dma_fence_get(sync->fence)); + struct dma_fence_unwrap iter; + struct dma_fence *fence; + int err = 0; - return 0; + if (!sync->fence) + return 0; + + /* + * Unwrap fence containers (e.g. dma_fence_chain from a timeline + * syncobj) so the scheduler sees the underlying fences. That lets it + * drop dependencies on jobs from the same entity and only wait for + * jobs on the same scheduler to be scheduled, rather than waiting for + * the container, which forces a full GPU completion wait and drains + * the queue. + */ + dma_fence_unwrap_for_each(fence, &iter, sync->fence) { + /* + * There is no dma_fence_unwrap_stop() helper to drop the + * reference the iterator holds, so keep iterating without + * doing anything once an error has occurred. + */ + if (err || dma_fence_is_signaled(fence)) + continue; + + err = drm_sched_job_add_dependency(&job->drm, + dma_fence_get(fence)); + } + + return err; } void xe_sync_entry_signal(struct xe_sync_entry *sync, struct dma_fence *fence)