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=1796218593; b=tLZhgxWbt73MlvkldH2rBdnS6i0eqB8Lq5yqiod4lN02r1bISK8iRkunmYy2//Wk1YEL rwZIS+Q8JmAxc4oRW5NigYH57pGe9AFy+0F43xfTNp2XX5pqVkquw6liAu7CTFcigekjK HnufZutFQFMMeNJvQ5V8XlvJirQsurLY0+UQZraQ/q060dTNutG0kh6jTOs4cIbU83pYh wwhcthwuAN94e/A0c7XcX1RbeqL2Ka0UPTC8OT4kWyTtG+XIOi3IvAI1fx4HLbH7PeyzQ 1jP75wuOoQXFqxquc/B9KQ5zUYXEir9silZixm/ddZx8nb0AlxaXmbN4qf/6e/F5ONQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796218593; 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=jjdScLFououM2LoN5bglgVuMXR/DqscvVXjvg72JGrc=; b=A+vQ/Xq65H1ZdJN8nnRFFQIAz2ayiei0gqdij+cQePcbPHDu/pis7aA5yV9DAr63FPGz 8UOLaHOl1HjGxBSWWWr0xjP47gIox74K4xYmHeodLoBMO7L5a6yZLda2PK2BLhUHKedlH v1kF1xs5EFBa4fjSEvtIF2guklTV83ToZVbWz4z2mSVuOFtyYgKQofPbqeoR9JhNtYG1G zraN1VR/zcJln3A55hnODoIFlipFfsvbH+dz9BJ3S/ITDc4tZMyy5gEhWfrntMiDxG+5T KJojNOJQEHs6HHupkd3SQ2M+aW0pvPqqA8/DXKJgf99Pch+SzRO2wHTwwcUWoQW7hBw== 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=HSHYfHn5; 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 4A86B606A31A; Wed, 2 Dec 2026 13:36:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4A86B606A31A 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=HSHYfHn5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1796218590; bh=zLrek6Rii4UzUMHIV9rtf5CcTgza1Ta5EVcjLPCcRew=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=HSHYfHn5Bfx6h2KI2u4lmBTHO4l7iFfAkXkmDJBfNtZuBSM66ys7gDNUwx5xQO7DC dUpjFUEuDChku+ASZLzFGS42b1/rvynPmOdgb4Lg3SIh3AgLtLvl/4apnH9RfteQwS qXwr8d1TO2ZwVvM6TOzNZzLS9ntB6zgkO3drurVUcFpRfinzu3XQORrmV+dIVHDp7n 5YM0LPRCR1OPTtBw/rkYMNPv/hVV/yk4oEjeFCjlmsOkvk3XwvlnXKbeshjddgYD5P 5As9RhKi5zvLNDi3+Irzql7za87BQEOz7uZckMDolivx27/PNd1m4kfFLXRzg/nmde mMGs6OWSS4oHg== 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 44C6117E079B; Wed, 02 Dec 2026 14:36:29 +0100 (CET) Date: Wed, 2 Dec 2026 14:36:17 +0100 From: Boris Brezillon To: Philipp Stanner Cc: phasta@kernel.org, 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?= , 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 v4 1/3] drm/sched: Eliminate NOP dependencies at insertion time Message-ID: <20261202143617.70bec705@fedora1.home> In-Reply-To: <132576bb9d5bac3f5a51f739436d2d2db4106341.camel@mailbox.org> References: <20261202-panhtor-dep-skip-v4-0-f84482d7a49c@collabora.com> <20261202-panhtor-dep-skip-v4-1-f84482d7a49c@collabora.com> <132576bb9d5bac3f5a51f739436d2d2db4106341.camel@mailbox.org> 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=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Philipp, On Wed, 02 Dec 2026 13:37:34 +0100 Philipp Stanner wrote: > Yo Boris, >=20 > On Wed, 2026-12-02 at 12:34 +0100, Boris Brezillon wrote: > > All dependencies get added through drm_sched_job_add_dependency() or > > variants that call drm_sched_job_add_dependency() internally. At this > > point, the job is already attached an entity, and we can do the =20 >=20 > typo, attached *to* an entity Will fix. >=20 > [=E2=80=A6] >=20 > > =C2=A0 } > > diff --git a/drivers/gpu/drm/scheduler/sched_internal.h b/drivers/gpu/d= rm/scheduler/sched_internal.h > > index 32d3ddb820be..b7afed36b915 100644 > > --- a/drivers/gpu/drm/scheduler/sched_internal.h > > +++ b/drivers/gpu/drm/scheduler/sched_internal.h =20 >=20 > Personally, I'm not a huge fan of code in headers anymore since it > makes finding things more bothersome than when it'd be concentrated in > sched_entity.c; but I'm not sure whether the kernel has a policy on > that. For such simple helpers, it lets the compiler inline things directly rather than relying on LTO to figure it out (note that if both users were in sched_main.c, I would have put the helper there, but here we have one caller in sched_main.c and the other one in sched_entity.c). BTW, we have such inline helpers defined in header files spread throughout the codebase, so I'd be surprised if it was forbidden/discouraged. It's this sort of things where you have to trust you own judgment (is the helper short enough, is this violating API layering, ...). As for searching stuff in the code base, I think we have good enough LSPs with decent IDE integration that it shouldn't really be a problem. And for old school devs, "git grep to the rescue" ;-). >=20 > > @@ -122,6 +122,26 @@ drm_sched_entity_is_ready(struct drm_sched_entity = *entity) > > =C2=A0 return true; > > =C2=A0} > > =C2=A0 > > +/** > > + * drm_sched_entity_can_skip_dependency() - Check if a dependency can = be skipped. > > + * @entity: entity the dependency will be waited on =20 >=20 > This reads confusing. >=20 > "entity for whose job the dependency will be set"? It's still confusing, I think, especially since there's no notion of job at this level. How about "entity that waits on this dependency"? >=20 > > + * @fence: fence representing the dependency =20 >=20 > Maybe call it dependency, or dep_fence? I was just trying to be consistent with the existing helpers which name this parameter "fence". >=20 > > + * > > + * Returns true if the dependency can be skipped, false if it can't. = =20 >=20 > nit: Official kernel doc style says that the return statement should be > marked with "Return: " Will fix. >=20 > > + */ > > +static inline bool > > +drm_sched_entity_can_skip_dependency(struct drm_sched_entity *entity, > > + =C2=A0=C2=A0=C2=A0=C2=A0 struct dma_fence *fence) > > +{ > > + /* > > + * Fence is a scheduled/finished fence from a job > > + * which belongs to the same entity, we can ignore > > + * fences from ourself > > + */ =20 >=20 > nit: > since you're already touching it, maybe wrapp the comment to 80 chars? Sure, I can do that. >=20 > > + return fence->context =3D=3D entity->fence_context || > > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 fence->context =3D=3D entity->fe= nce_context + 1; > > +} > > + > > =C2=A0void drm_sched_entity_stats_release(struct kref *kref); > > =C2=A0 > > =C2=A0/** > > diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/s= cheduler/sched_main.c > > index 85a49e219837..5f123a5e39ff 100644 > > --- a/drivers/gpu/drm/scheduler/sched_main.c > > +++ b/drivers/gpu/drm/scheduler/sched_main.c > > @@ -678,6 +678,11 @@ int drm_sched_job_add_dependency(struct drm_sched_= job *job, > > =C2=A0 if (!fence) > > =C2=A0 return 0; > > =C2=A0 > > + if (drm_sched_entity_can_skip_dependency(job->entity, fence)) { > > + dma_fence_put(fence); > > + return 0; > > + } =20 >=20 >=20 > But otherwise cool patch. Just the other day I had been wondering why > we do that check so late currently. Thanks for the review. Boris