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=1796143469; b=dg7Bc+rWbOTTtPhzyuejj7AOLrw5QRqMhokBzVNyWMbEJkoHvbnJzJmgMpQvTTEjHiE7 IsJ/88RM0+Mrj/F6WwzGsK7lXWkUZoklcpbZsaOQt9HJgLGIdFA51YtYhO/RhF64mZNMF tzWjnrWB17zVf3dLV17Cw3zovuE/pGSnRF0lJVLiIUDIIKX/zvqXJuJ5U3FeJ6WpYPWvm jkg8tHZknI7e74NkR+k7nBx3OrRAMqK4bIhMrwdCeO6jlIk8DpP38wa5POynC/BlE/Mn3 fv3nMvuDdKwOYnyfCzgqP1iuJRxJFN9GSS0bGctghc5YkA0FkgELBrTqaHV3lqmJxzw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796143469; 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=u997MXmjPHnI1sj6+dt+ODXIWWH3zej6CO7JhR7gqjs=; b=42LZb67FT6yjFdGS+ilnvhsFHMUcbAbrrYLHKm2U4R4M7woKib5qAQjSdBtGO3H3tX+c hp7oIxwQktDFMsp31863rfeaqsuERtvWkyWWp7G6uyvFDqUm1bU8MRP1JzwBw0Xwb3PIW EaAXzJZVJEtjBEk2hPmTycPX5E/yLHWBn+YlNqDooHdP9xKhqwXJ4DrivoZETAaUzh2Y6 nqNInd/QY7YzVjZ1bP1dZp7WNKaJeXgX7xzOzSMO8UshmIL2qfExzk4bl9jP5tRzRIPXK /kIudd00jk1LEBMizcyxeDIKw4gWxDnrO5DbeoH+2fi5PmNUaN+PUb7sdxUgDVKp4mQ== 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=ewtHRSpY; 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 E3EFD606A31A; Tue, 1 Dec 2026 16:44:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E3EFD606A31A 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=ewtHRSpY DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1796143467; bh=7zaWDA5P84DmsTXmkHORbYOtuG8QbTfbpihkH/RLV8c=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ewtHRSpYmvFsn9b+1ghjgfuE+t09pOMHJWgDPMmrxNZq3LVVaTT1ZOmRM7I17j5R5 5mY0CmZko93jmCrZ7SdhxN+Ao9rP6KvXj+NHRfdINo3pOrXozxEy3qVX+CXz4NCmfb hdgaoeZznOqBKoQo9GTjSD8vnMN0f+T4agWadSfOrbQOneWSnenuLwe5MZ1eU0miSL rzvq0pLPI0Ihpm7QuqzFy4HPPNXd0w4hopQunW/toXQRrrWuwxlxKTj0LXIQrL7REX csArBoNx02WzM53iZ8tsKZRM/iu69vvuHWb3vUEfqMg3qzs800fftnCDa8nBep3+dP RlmC4AroErL7w== 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 1496817E03C7; Tue, 01 Dec 2026 17:44:26 +0100 (CET) Date: Tue, 1 Dec 2026 17:44:21 +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: <20261201174421.40287b7e@fedora1.home> In-Reply-To: <39c6db02-b9c0-4542-bb71-da0ca3efc166@ursulin.net> References: <20261201-panhtor-dep-skip-v1-1-432f313dea0f@collabora.com> <20261201171438.504a0ccd@fedora1.home> <20261201172039.00326c32@fedora1.home> <39c6db02-b9c0-4542-bb71-da0ca3efc166@ursulin.net> 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 16:28:58 +0000 Tvrtko Ursulin wrote: > On 01/12/2026 16:20, Boris Brezillon wrote: > > 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. > > I cannot guarantee I am not forgetting some gotcha, but from the top of > my head I can't remember a reason why we couldn't do that. On balance > it's probably cheaper to do it straight away. Send a patch? :) Oops, sorry, I was to quick. I can send a separate patch for that though.