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=1796142046; b=kb6jDfhvL4Yahl1phCCshYYGDSdgD5iIQcoC/NgAlgUtR7pwc8NoIW6NJZpT5NETjGzj awp9i/LXKmmlk3EiJyE42/C2F/Qa6Yw8RmRdigc+kELWfqyiJiDNEfEs9HnDCgcZvqcL1 a6lVrSitJ1abZxrfhxEm/N9WhOqOl8BRue5XRLanEl1NvOIVG/PapZupLZkjrHETaxQjo Fpb/1XzUFz9bz6NcDyh7kFL6WxX/DeOLf2Xrp28BrUy1ZngEyy2XUmuCoL5kU5660GJV6 BfyhnFNKnNyX2YO2xH9pgGazmQl4D8bcDqJTa1MVrBoiGjhLPfWsIizaCtohifZdujw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796142046; 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=INidFGQlHhFm0Y0Z+wpS7axmBU+Kt3iS+Gp7MubEDlQ=; b=4UJ4r2pDATxnkVIHkJ0AEsThD+Q6Qwl9VrpWnDRy0/LD9y/LtXmSANvhZFJMS73bg6cA CSMmUL3VxGCK5Hx6RA8n499A+lBBZ2vROjYxKk3+JhBliekWei5wCPlVigGgGVA87Gk4Y OOkmZdcC7DUqd8F37WS2qey6vIzEmpSUEkcMTpl0dRzQtGV+VIfoDOPK/TUHJqw5RboRR YUMFP5dPipckgZ2gEpg9F8+oqvin0iOm546qonIpXceMCaUfhsFjlJeHYnEiEbiGI9YWy 2e/alX0np01JfE0BP5tFeWp8xMVFt+ThhrJammvfHRPgfywoUXlqwVqQVqFQ5DbG+bA== 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=cYMrlox4; 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 3FE6B606A337; Tue, 1 Dec 2026 16:20:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3FE6B606A337 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=cYMrlox4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1796142044; bh=qdCOO+ja4gfAX6gESrqu5s9/F58YWW1EVAqQEbm2Zok=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cYMrlox410y0N2uJ8bQ/YJ9Whk7BKd9wzYu8JiB/zY1u0TmglkjgGZfIQz5g0gI1l p7ssmSnAkHx2VGsbpVFLJ08lMvs63wcnLPVSXbDkjk8wcwfy1kmeqoLyd5ICNmWOAs hy2TcZlT+Ed6SBRTXYWU8zm3gkZ4shUXxKwmtkkLYL499rHtSeQQSd+mEQGrFi9d20 zgD9y0GD8QZsb5S/ZhKt6hiZkJ93kPWSvb53BrMqqPxdLmaWmLYMP76X7uc4sWBd9c llRGAQA9TPitLQm8nkRMmnXvxOgpuRhhVkO+ST/ZVjm/uvtq0jkBrB3rGstTI47+96 q5nXL2jn23dlw== 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 6D8C917E004B; Tue, 01 Dec 2026 17:20:43 +0100 (CET) Date: Tue, 1 Dec 2026 17:20:39 +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: <20261201172039.00326c32@fedora1.home> In-Reply-To: <20261201171438.504a0ccd@fedora1.home> References: <20261201-panhtor-dep-skip-v1-1-432f313dea0f@collabora.com> <20261201171438.504a0ccd@fedora1.home> Organization: Collabora X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-redhat-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 1 Dec 2026 17:14:38 +0100 Boris Brezillon wrote: > 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. It's a bit of shame those are not eliminated before being inserted in the Xarray, but that's good enough for me.