From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 566D3606A31A for ; Tue, 1 Dec 2026 16:52:38 +0000 (UTC) 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=UfZmeaDe Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD53F10E409; Tue, 1 Dec 2026 16:52:32 +0000 (UTC) Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id BB85A10E9EA for ; Tue, 1 Dec 2026 16:52:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1796143945; bh=TOVZWLUtnO1u0fOgw0uEDrliPyRciyE092Xk0eRyNcg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UfZmeaDeiVzteSzFBD++XhXRm8al2P9E2KNSjr4QHtMnzm8mvX9lRfQHv2sEpQilg 0HitI1f66qb02Zwnau7iTxC6RyHg3zt4w4JIc2XXFmmCQ6fmf2cKmye0Iy2WfngKYx ss9bsKfQNjwoNomjMp9iFs+4/Aa0jd39f+Ih/PKsjp8vNr98/ql/qUCbxUoTpv3gXE /QAoDoQ4vURWTUmW/ybSxWvZ9l2/UK7y853bB+kUSAGE32cFHntorJBKuqp26R9AO1 igBWW/CmLhXQk3TMKkye+b5PjKR2XCspgKzs8sFZ1eBAHnBKkcDnsdV3M/a9MnMXOn jw+gFAwdXWYFw== 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 7C6BA17E0390; Tue, 01 Dec 2026 17:52:24 +0100 (CET) Date: Tue, 1 Dec 2026 17:52:19 +0100 From: Boris Brezillon 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 , 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 v2] drm/panthor: Explode container fences to optimize pipelining Message-ID: <20261201175219.0ac7186d@fedora1.home> In-Reply-To: <20261201-panhtor-dep-skip-v2-1-1b38efda8a0d@collabora.com> References: <20261201-panhtor-dep-skip-v2-1-1b38efda8a0d@collabora.com> Organization: Collabora X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-redhat-linux-gnu) X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Tue, 01 Dec 2026 17:35:28 +0100 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 > benefit from the pipelining provided by the ring buffer (no extra > MCU <-> CPU round-trip to have the job pushed to the ring buffer). > > drm_sched_entity_add_dependency_cb() already has this optimization in > place, all we need to do is explode the chain/array containers with a > dma_fence_unwrap_for_each() when we add job dependencies. > > 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 > --- > Changes in v2: > - Explode container fences with dma_fence_unwrap_for_each() instead of > and rely on drm_sched_entity_add_dependency_cb() elimination instead > of open-coding it > --- > drivers/gpu/drm/panthor/panthor_drv.c | 17 +++++++++++++---- > 1 file changed, 13 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c > index dc8d0191aef4..a527ce86a113 100644 > --- a/drivers/gpu/drm/panthor/panthor_drv.c > +++ b/drivers/gpu/drm/panthor/panthor_drv.c > @@ -7,6 +7,7 @@ > #include > #endif > > +#include > #include > #include > #include > @@ -612,8 +613,9 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx, > int ret = 0; > > for (u32 i = 0; i < sync_op_count; i++) { > + struct dma_fence *fence, *inner_fence; > struct panthor_sync_signal *sig_sync; > - struct dma_fence *fence; > + struct dma_fence_unwrap iter; > > if (!sync_op_is_wait(&sync_ops[i])) > continue; > @@ -637,9 +639,16 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx, > return ret; > } > > - ret = drm_sched_job_add_dependency(job, fence); > - if (ret) > - return ret; > + /* Explode containers so that drm_sched_entity_add_dependency_cb() can > + * eliminate fences that are coming from the same queue. > + */ > + dma_fence_unwrap_for_each(inner_fence, &iter, fence) { > + ret = drm_sched_job_add_dependency(job, inner_fence); Missing dma_fence_get(inner_fence) here, as reported by Sashiko. > + if (ret) { > + dma_fence_put(iter.chain); > + return ret; > + } > + } > } > > return 0; > > --- > base-commit: 28f286b0dfa9610d4ee2447415e964e8bc603056 > change-id: 20261201-panhtor-dep-skip-9c6a3e2f7cc7 > > Best regards,