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 99587606A31A for ; Tue, 1 Dec 2026 14:15:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BBgZUhQp Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EF26B10F931; Tue, 1 Dec 2026 14:15:11 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7E3DC10F93C for ; Tue, 1 Dec 2026 14:15:06 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 35BF8417D0; Tue, 1 Dec 2026 14:15:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A60A1F0089A; Tue, 1 Dec 2026 14:15:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796134505; bh=9sMxCRjh9Pdx2MywnfWTzcopqkAJryVz4RzkMuCifMY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=BBgZUhQpmR3uD9wAoSdRcZdlsAkMaTZ3nQTqj5vL3xHZc+MBn7akBcjlgXZvK0cBq T9Yj7awe/ntKuCTt2rjLoVyGH/1fDppKj7zw3imDxW5qlv+r4opaQELygyCOUxnXnA 0HrJq7idowY1rzK+v0oHbTi9t1S5DhqlErnYW0Dh8Oxz0vQM8KjivR5MdtYftAsUD2 0rBWRMFKwqew9Q/2hVXpkGjhChwCa+0Q/rFZaQKaoZLvjYWcmjS542rof9FHtQOWwI 7PPLfnFGfCWUATMTA1IWleKMH4Zvv+DWMFYPh+tCWSPGLt2ZZqEWsxR0WbKzxy0TyL +mHZX2Kep8GZg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] drm/panthor: Skip job dependencies when we can To: "Boris Brezillon" Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org In-Reply-To: <20261201-panhtor-dep-skip-v1-1-432f313dea0f@collabora.com> References: <20261201-panhtor-dep-skip-v1-1-432f313dea0f@collabora.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 14:15:05 +0000 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: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-Archived-By: Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] drm/panthor: dma_fence reference leak on early return in can_skip_dep() - [Medium] drm/panthor: incomplete dependency skipping in can_skip_dep() for containers -- commit f23961b342c7dac68cd73ec6ae60320b789f8887 Author: Boris Brezillon drm/panthor: Skip job dependencies when we can This commit adds can_skip_dep() to drop sync wait dependencies that originate from the same queue as the target job, including when wrapped in a dma_fence_chain or dma_fence_array. > diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/pant= hor/panthor_drv.c > index dc8d0191aef42..cfffb9e2dec8d 100644 > --- a/drivers/gpu/drm/panthor/panthor_drv.c > +++ b/drivers/gpu/drm/panthor/panthor_drv.c [ ... ] > @@ -591,6 +593,40 @@ panthor_submit_ctx_push_fences(struct panthor_submit= _ctx *ctx) > } > } > =20 > +static bool can_skip_dep(const struct drm_sched_job *job, struct dma_fen= ce *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 =3D=3D job->entity->fence_context || > + fence->context =3D=3D 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; > + } [Severity: High] Does returning false from inside dma_fence_chain_for_each() leak the iterator's reference on fence? dma_fence_chain_for_each() takes a reference via dma_fence_get() on entry and advances it with dma_fence_chain_walk(), so breaking or returning out of the loop early requires a dma_fence_put(fence) on the current chain node. > + > + 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 panth= or_submit_ctx *ctx, > return ret; > } > =20 > + if (can_skip_dep(job, fence)) { > + dma_fence_put(fence); > + continue; > + } > + > ret =3D drm_sched_job_add_dependency(job, fence); [Severity: Medium] Can container fences still force an unnecessary wait on a same-queue fence here? First, can_skip_dep() does not check dma_fence_is_signaled(fence), so an already-signaled fence from another context (such as a stub fence or an already-completed cross-queue fence at a chain head or inside a dma_fence_array) causes can_skip_dep() to return false even when the only unsignaled fences in the container belong to the same queue. Second, when a dma_fence_chain or dma_fence_array mixes a same-queue fence with an unsignaled cross-queue fence, can_skip_dep() returns false and the entire container fence is passed to drm_sched_job_add_dependency(). If a timeline syncobj chain has a newer same-queue fence at the head and an older unsignaled cross-queue fence behind it, waiting on the outer chain still blocks the new job in drm_sched until the same-queue fence signals via an MCU <-> CPU round-trip. Unwrapping the container with dma_fence_unwrap_for_each() and adding only the unsignaled non-local leaf fences would avoid both issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201-panhtor-de= p-skip-v1-1-432f313dea0f@collabora.com?part=3D1