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=1796353608; b=0Hz3ONQyyzdMPvCdewnQjb8k/N/TksnlcDf7YadcCHanm402tyNF2SFPEnvhE+kK12SW XhvXvPpAT4yDbxHxYvjYiQHYyHwIlIXVIeC/fu1xrv7pidGZ9sx91IHO+31CBinsy7SlS MmDiEnBZQYOZzFx5Bi534YF8XVTURzm0PTD+ZvczZmk7DFMd+P1AO4R87yx85SOVIVVsD GZ6RX+8eRaVcL5ujuzjPssZL1Qc7ul9Uz3o6XqMDTgbhdNwX9PtFp/AipGoYtlxoDX7Ep KNdn7VqIuPHDC4UGHqctQd080CfZmFcq4LZf3uhPEiq5groS3XYBuc8/n71ffX1H0uA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796353608; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=qloHbGEs+Hx4QR+EgXaJe5D1m/qi863D9AsT4rk8MF0=; b=Jg9p8Zt3sjkSKoRsgIlmG1+a+Jkmfb4stDfyyEA5ZrQwY0HFXkT+MhQNCdF19xFAa1Bm PZlWOsXvvrWo7ZzgncG6ErpUvw5rOoEw7WRd8D2fVWTvqzolTZ4x1RbcuibyUieM606XA Ot2NQ3IPEfNOet4apDULNF9c5GUD2aRmxDiwq2qy/n3zpo0S2FWmY1UkYJ6G7M68UQhDi vVcZ6Iwy/yTgzyZvAIuDSCEid6Mmq8+k6njO4r80CQgNfqKsWGlI77Uzlx9PIktFp+HK2 3eUXNoBesDNqr7IkD2Dd714iKMG6nqWACI49Sv2QbBJQyBmq2F9c5xld22d4kY6Leog== 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=WGtw5FAP; 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 35E5D606A322 for ; Fri, 4 Dec 2026 03:06:48 +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=WGtw5FAP Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56C041F00897; Fri, 4 Dec 2026 03:06:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796353608; bh=qloHbGEs+Hx4QR+EgXaJe5D1m/qi863D9AsT4rk8MF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WGtw5FAPugp06vTFSXHFnu1YwLBKwW38uSb9A22x/TVpGTo5ajrxjXZmSvsHGs2pl 4SBzLPIc1gk05GLzg0XgjozXnLt+uOrkFtziTVxl+P77GC0VnXC2bZPAxuIT+9He4B zDA2efAeQqTZBUuqELRm0jXKLu7IgcGuxs6RaVqbGtSQoBtV4eCagi/9/h7L70slPQ FM/j0NBrT+es3khcSIuJq5mSS2JzD4JQM0g1OvCLLHfmZU3BOpPTiUVrEpeF2JBVg5 fD7lke3Upu4fpPxS2u7NKMAhd0cu9jGZ1oOnMJu+kbYyQhVrr9hsyABHb6DNPeLKST XkYBv6K+CCOWw== From: Sasha Levin To: stable@vger.kernel.org Cc: "Chen, Junjia" , Matthew Brost , Dave Airlie , Sasha Levin Subject: [PATCH 7.3.y 2/2] drm/xe: Unwrap sync fences before adding them as job dependencies Date: Thu, 3 Dec 2026 22:06:45 -0500 Message-ID: <20261204030546.2305577-2-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261204030546.2305577-1-sashal@kernel.org> References: <2026120232-dragonfly-active-f474@gregkh> <20261204030546.2305577-1-sashal@kernel.org> 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 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 711de22f49864..d9876771d9629 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 @@ -234,11 +235,35 @@ ALLOW_ERROR_INJECTION(xe_sync_entry_parse, ERRNO); 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; } /** -- 2.53.0