From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.251.105.195 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796211265; b=bW7To/qDlKSnKhDy/h0Ck6L/MlTxYw9CGJ+14LqLm+Wj55Qyqp4kEg3uJqniGfVqWyS4 GUCyPMaWX0OQ6h37ZzJ8SZWrV0LoZ2Q+px/rilrdakwZXfRnH0j75aJpbM1LvGQMQmXfm h6ZylSTUQBUahOdH95VY+W/+nmPb5BbC463v0jLdxFDBNlggHu4GBDxtr5U2ISHfz4rP+ gZ5WlJ1OL5pKq6NljhTZZuBEAhlRwYGh7tPP/dYdbq4J046q2ANrXAQCRa5gYv75UJgTs xZ41GivTvzLQMeYFEQapo4hoemocg982Ahy9FdrsEf9gV3+VicCPHwo9GyDRBR5jWPA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796211265; h=DMARC-Filter:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; bh=1+WhZZd5ajXsI+GHicObLMlmKx7pMZUkSR41alFftl8=; b=iFQOR52/fJomzxHlyIAwrEpbVDYeogTVc6IAPwCw+XDg7RVrAQXUCIj+jUDDFZxyHLEd GQa5DzVLLUkGpFUhrEz/aDKNFlLxxbrL6HKnyVicNADbYNxiGywK6Y9J+N4354vHWjKI7 H/fVxXHaFrXsRHrwY7qwOg9BQGpJ2h9ssCi6FVBuHz0ouNjVBGJJD56+l6ko1fJqveQh7 CA7fqkPv+/qxb8X8w1dhbBWOBQuQgYiG/Dtlmf84eopG0e7EmSIMcOBXIRIZRbLaMcILe P24FNKpTMZVyk/k2FbYjAq5seczzp7PmZ7BJ35PkWq/lvSLSQGlsCX3iv4Qlz/gviFw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=lsMyV5mK; arc=none smtp.remote-ip=148.251.105.195 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (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 CBBB4606A33A; Wed, 2 Dec 2026 11:34:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CBBB4606A33A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=lsMyV5mK DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1796211263; bh=XlLa2+m5ZMw+ze+YpFGprrPGNwYrbrRm8XWRuY8Nwnc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lsMyV5mK9ZvXFxek0Z/i0aULDq6cayTocU8j9MZADrGlwGH+jZDlH5zHytRoJLR3s ssLykF79MOvoAMsQoxSwsbW9GmabehUjO6QMO/c45Gt7evm/Rcnwb4pAOjKfOuewXe jqF2DTqIZwCv4vArj+GSW4/Nd/5Bb5TNTKMkCr8Cg0ifHjnUDyAUqnc7c65BnAVfGT 5bbk58cqDFNv25JmJ804jyGLFdjv/PJQO6UPTyRBiSYLX/X1dyERMXgsuBI2jq7VK7 b2BZjzqtIZY4nW3ZZYm0qRxbur03PR5sSuYv9AHeTGpSULxb23l+H0r9zacQz2j8rh 4FRc4lv7KMZRQ== Received: from fedora1.home (unknown [100.64.0.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id 46D5C17E09D8; Wed, 02 Dec 2026 12:34:22 +0100 (CET) From: Boris Brezillon Date: Wed, 02 Dec 2026 12:34:18 +0100 Subject: [PATCH v4 2/3] drm/sched: Add a drm_sched_job_add_dependency_unwrapped() helper X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261202-panhtor-dep-skip-v4-2-f84482d7a49c@collabora.com> References: <20261202-panhtor-dep-skip-v4-0-f84482d7a49c@collabora.com> In-Reply-To: <20261202-panhtor-dep-skip-v4-0-f84482d7a49c@collabora.com> To: Steven Price , Liviu Dudau , Akash Goel , Karunika Choo , Lukas Zapolskas , Chris Diamand Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Philipp Stanner , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, Xianzhong Li , Boris Brezillon X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796211260; l=3119; i=boris.brezillon@collabora.com; s=20260429; h=from:subject:message-id; bh=XlLa2+m5ZMw+ze+YpFGprrPGNwYrbrRm8XWRuY8Nwnc=; b=9EwBTs8AjoNOgohIGGOqKX3FAJv9G36ZHY/vf7d0v/u6KqtMrrgJaSPQ6HFsr4E3zPmhm4VSy KfC0dajzW+FBUlFQwfe/39Z6ceaNBSV62oiYAauBAcf8iEDlqloiP8y X-Developer-Key: i=boris.brezillon@collabora.com; a=ed25519; pk=eN+ORdOgQY7d5U+0kA8h5bf67XdD8bhKbjD/TCHexSY= drm_sched_job_add_dependency() adds the dependency as is to the job, but drivers like to have containers unwrapped and each individual fence added as a dependency so they can skip same-queue dependencies and benefit from hardware pipelining. We don't make this behavior the default to not regress the existing drm_sched_job_add_dependency() users. Note that drm_sched_job_add_{resv,implicit}_dependencies() don't need this unwrapping because it already happened at resv update time. We could add a drm_sched_job_add_syncobj_dependency_unwrapped() variant, but there's no known user for that yet, so let's postpone this until someone actually needs it. Signed-off-by: Boris Brezillon --- drivers/gpu/drm/scheduler/sched_main.c | 29 +++++++++++++++++++++++++++++ include/drm/gpu_scheduler.h | 2 ++ 2 files changed, 31 insertions(+) diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 5f123a5e39ff..6449d74b5218 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -66,6 +66,7 @@ * This implies waiting for previously executed jobs. */ +#include #include #include #include @@ -708,6 +709,34 @@ int drm_sched_job_add_dependency(struct drm_sched_job *job, } EXPORT_SYMBOL(drm_sched_job_add_dependency); +/** + * drm_sched_job_add_dependency_unwrapped - unwrap the fence (if this is a + * container) and add the resulting fences as job dependencies + * @job: scheduler job to add the dependencies to + * @fence: the dma_fence to add to the list of dependencies. + * + * Note that @fence is consumed in both the success and error cases. + * + * Returns: + * 0 on success, or an error on failing to expand the array. + */ +int drm_sched_job_add_dependency_unwrapped(struct drm_sched_job *job, + struct dma_fence *fence) +{ + struct dma_fence *inner_fence; + int ret; + + dma_fence_unwrap_for_each(inner_fence, fence) { + ret = drm_sched_job_add_dependency(job, dma_fence_get(inner_fence)); + if (ret) + break; + } + + dma_fence_put(fence); + return ret; +} +EXPORT_SYMBOL(drm_sched_job_add_dependency_unwrapped); + /** * drm_sched_job_add_syncobj_dependency - adds a syncobj's fence as a job dependency * @job: scheduler job to add the dependencies to diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h index 3b0978fa8cf0..5308f53d3168 100644 --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h @@ -694,6 +694,8 @@ void drm_sched_job_arm(struct drm_sched_job *job); void drm_sched_entity_push_job(struct drm_sched_job *sched_job); int drm_sched_job_add_dependency(struct drm_sched_job *job, struct dma_fence *fence); +int drm_sched_job_add_dependency_unwrapped(struct drm_sched_job *job, + struct dma_fence *fence); int drm_sched_job_add_syncobj_dependency(struct drm_sched_job *job, struct drm_file *file, u32 handle, -- 2.56.1