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=1796141687; b=M+U9so+zsljIT5Te3H2OydSlf/fVQcKu1FZD+vpiFqvI5TFi1sjnwi5R6z4sIju8j8+B HoLV4dDgnzCuNkl/mUlUEh9pobkDc07j8IlncjqlyhpbzlW9s50n1EUiOBoCSx46FDUCq nw4BZkMOTuhPPyMnlvJEtTiEC08KxqF6d5QA+G2eScZtog9TMwwZGBOV83tavSuuYLO4m jNPFBUPGF+IzdyWrylBy8QSJkE7K55D5RGjABf9DaTJKu+KT/zb/NN4jGMbYDlWrSqyHS lsx2TLvpJboWdotqJPUzN0pI2t1ebhwBq/6kqMCnWeXPlOw7c9NOcA9rRjwin3BohUQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796141687; h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject: Message-ID:In-Reply-To:References:Organization:X-Mailer:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=IyI0+T/pZPtHKq7oaDjtjVLhgHTdw8QVhrt24+TheCo=; b=r2oZXWJwv24PZRgkNFBHSdbcDpmA4ZBooxDqxTX51Pw5b/h50R4y3zREd32JVbA015bv +SCtB34RTXUtosuRWnxMA4kna9WUZVUr9rJV3wqJp6DIF4TojTS74RazKP/dts2uAwQp7 +ekL6i66/wNRcDytwLa7pAHkPfy1Faqb+OO9mTF3bbMx4J1OPCwtlAru8t06aE0TFO7ss ngdO3a+7pjxuBC/Pw4d6t074zfWi5sVbS6jiao5MbbPDEtx4/spIiMMk/fT8EUjBWg3HY /yg2uU2gQt+ROWSLL3PGugScq/iBaaLTXNvwRbq9lmy+IxGII+GgYr1YlcNfC+0bDPA== 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=jK0L1eku; 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) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 919D0606A31A; Tue, 1 Dec 2026 16:14:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 919D0606A31A 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, unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=jK0L1eku DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1796141684; bh=rL3lyFMZG+i7mq5j9OA/1SzZ5A+o4oaRfCNyebHc6fw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jK0L1ekuO+NAdvZFAdM0hw5dAUbF5HDIonZKjTIAlQ2IRulXSl6FB9KI6bBLuMDSX Epl+io15A5IdM4tRYxKU0nrrTRcZ9GFz2o14et1nEfMlNABfgU1sq8WVt9OM559WgX z1LVNuWXXqHHWhUq0jbJFPvb16JrrxGJW9nV0Wq00rJsdcp1fxz7bqs+FuL26w6VJh 6eKJ00t3Z78L3pbqmSpvzVznXKa4ZEhhMtyM+XNhDZ1Axwi6GBFBvBJ9BVuqluWejI rHjhTOSAsNmd7dmy12Vib4eIXGzq414dfcp7UT572uycvlWqPvseYQS3nE2oLtGU5t YKOANOgByjRhQ== Received: from fedora1.home (unknown [100.64.0.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange secp256r1 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id CBD7617E0657; Tue, 01 Dec 2026 17:14:43 +0100 (CET) Date: Tue, 1 Dec 2026 17:14:38 +0100 From: Boris Brezillon To: Tvrtko Ursulin Cc: Steven Price , Liviu Dudau , Akash Goel , Karunika Choo , Lukas Zapolskas , Chris Diamand , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Sumit Semwal , Christian =?UTF-8?B?S8O2bmln?= , 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 Subject: Re: [PATCH] drm/panthor: Skip job dependencies when we can Message-ID: <20261201171438.504a0ccd@fedora1.home> In-Reply-To: References: <20261201-panhtor-dep-skip-v1-1-432f313dea0f@collabora.com> Organization: Collabora X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-redhat-linux-gnu) X-Mailing-List: linux-media@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=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 1 Dec 2026 14:11:23 +0000 Tvrtko Ursulin wrote: > On 01/12/2026 13:58, Boris Brezillon wrote: > > If a job is passed a dependency that's coming from the same queue the > > job is targeting, we can get rid of the dependency because of the > > implicit serialization provided by the queue. This will allow us to take > > benefit of the pipelining provided by the ring buffer (no extra > > MCU <-> CPU round-trip to have the job pushed to the ring buffer). > > > > Signed-off-by: Boris Brezillon > > Cc: Xianzhong Li > > --- > > Some recent effort to improve job pipelining [1] showed that the > > MCU <-> CPU round-trip that lets us signal job fences adds a > > non-negligible overhead, and this problem seems to be easier and > > more systematically fixed if it's addressed at the KMD side, so > > here's a patch doing exactly that. > > > > [1]https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/46172 > > --- > > drivers/gpu/drm/panthor/panthor_drv.c | 41 +++++++++++++++++++++++++++++++++++ > > 1 file changed, 41 insertions(+) > > > > diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c > > index dc8d0191aef4..cfffb9e2dec8 100644 > > --- a/drivers/gpu/drm/panthor/panthor_drv.c > > +++ b/drivers/gpu/drm/panthor/panthor_drv.c > > @@ -7,6 +7,8 @@ > > #include > > #endif > > > > +#include > > +#include > > #include > > #include > > #include > > @@ -591,6 +593,40 @@ panthor_submit_ctx_push_fences(struct panthor_submit_ctx *ctx) > > } > > } > > > > +static bool can_skip_dep(const struct drm_sched_job *job, struct dma_fence *fence) > > +{ > > + if (!fence) > > + return true; > > + > > + /* This fence comes from our queue, and the serialization happening at > > + * the queue level makes it so we can skip the CPU wait. > > + */ > > + if (fence->context == job->entity->fence_context || > > + fence->context == job->entity->fence_context + 1) > > + return true; > > + > > + if (dma_fence_is_chain(fence)) { > > + dma_fence_chain_for_each(fence, fence) { > > + if (!can_skip_dep(job, dma_fence_chain_contained(fence))) > > + return false; > > + } > > + > > + return true; > > + } else if (dma_fence_is_array(fence)) { > > + struct dma_fence *sub_fence; > > + u32 index; > > + > > + dma_fence_array_for_each(sub_fence, index, fence) { > > + if (!can_skip_dep(job, sub_fence)) > > + return false; > > + } > > + > > + return true; > > + } > > + > > + return false; > > +} > > + > > /** > > * panthor_submit_ctx_add_sync_deps_to_job() - Add sync wait operations as > > * job dependencies. > > @@ -637,6 +673,11 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx, > > return ret; > > } > > > > + if (can_skip_dep(job, fence)) { > > + dma_fence_put(fence); > > + continue; > > + } > > + > > ret = drm_sched_job_add_dependency(job, fence); > > if (ret) > > return ret; > > Alternatively you could do: > > dma_fence_unwrap_for_each(..) > drm_sched_job_add_dependency(..) > > And no can_skip_dep would be required. Yeah, I guess unwrapping things before adding deps works too and avoids open-coding the is-this-the-same-queue logic. Thanks for the suggestion.