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=1796354475; b=RJEg0rvtMDTXXQF46K43SQe/qfv8gBbhuJA0g3yd1Vo0ZOK2gTsY05/+nwn8RkBgNf5o 6GXWNC7M/ABfTDbgBWk4VFiTAFgu0M3dTkNB73qpD7JWemzX42ZvU4GK2L76bISuE6fQ7 D1j58BqO7s5bh9AuNvv3s+h9gPzr2VCK5Atw1cDLgsRIgytpzwUu3W7ckWxXKoq32GI3u 0YcVGXn5JfpmXWlAr5EArbzldH8ILjGv9otbRRXMLpf6BCw0zVWliSXt0MO8aBor2z2wL GVBeKpQRhHEe3dck/n7UwVq9Pe8hWKbSZDZaomFQE97++V81FknWyGvrV/C1S+JweBw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796354475; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=2jI2ZvXQGL7JnmbGSqr7TsUYGUiIpNZPBKPx3V/1MOY=; b=KY1HSjgWNd3NvR1sYMaIvQSzxH/CLDfeIwBFkaJ5lhOcqhEerO9xeuN3pNQkdBn/RuCw oGNGUF68XzBQYxn9SKOCM9p4jcfZrhPcxayFtofwWpG8Ynrj9ZDZ0yVxGHNn3OoWNlYiL tVs9VYRmhXlMoaVgL5XMqN7LmfZy2z2/Ml/JI/02GIX6+1LNNXO0Vm4X/Wu+GZhU8yRTG J4I6GED2SgabH07F+l4eH5j3Pe82Hh/dGz3fKn3b44icpiVEcWSWy109VKpUmDafiT8O5 aVw5HfFNlxghRvb14zEl6fNr3xG2vHo8qTV2w0sIzxmrsp0TdhuxIp1wGLz5cG9dffQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oeV5E1Wv; 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 A630F606A322 for ; Fri, 4 Dec 2026 03:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oeV5E1Wv Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE73B1F000C2; Fri, 4 Dec 2026 03:21:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796354475; bh=2jI2ZvXQGL7JnmbGSqr7TsUYGUiIpNZPBKPx3V/1MOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oeV5E1WvA1s7JhIIAqOwNGvncwaXdr9lloammSb9a07MYi9Mhhl0d0r+LwV1ybYPN NWOgt5NdBY0131mBqsnI1lUrHUSiXHaaUzRZZ6V1j5ZBXwaI9uhef8QpYLRNpxMhAY 3HzUPP9zgf2Yzwi46xkwsuhGMtQWtMIbL0nq1J+w5Cmp/FEHZ60iGqhNXtjCIHFm8O XXDghdZtzE7MnOrqHtud6PFrA1MsS2nmYEDv5YLmUPOjWZniABnpuoYjeosq33ePht vptR5+eAF4V+lUuX3N8DpmlhkdmUm01EBT4Uu24n1wc4FuAFhUYddPkmT8L6HKsDwo yRs6zAmzgXMzA== From: Sasha Levin To: stable@vger.kernel.org Cc: "Chen, Junjia" , Matthew Brost , Dave Airlie , Sasha Levin Subject: [PATCH 6.12.y] drm/xe: Unwrap sync fences before adding them as job dependencies Date: Thu, 3 Dec 2026 22:21:13 -0500 Message-ID: <20261204031946.2334318-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120233-consensus-unison-69ec@gregkh> References: <2026120233-consensus-unison-69ec@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: Dropped the error-injection include and context lines (ALLOW_ERROR_INJECTION) that don't exist in this tree, so the hunk context differs while the unwrap change is the same. ] Signed-off-by: Sasha Levin --- drivers/gpu/drm/xe/xe_sync.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_sync.c b/drivers/gpu/drm/xe/xe_sync.c index 6affdd0a80958..5f88230541f77 100644 --- 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 @@ -221,11 +222,35 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef, 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) -- 2.53.0