[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b8ffe136ca4dcfc94530e1fe7dbac889930f03be.camel@mailbox.org>
Date: Mon, 10 Nov 2025 09:30:54 +0100
From: Philipp Stanner <phasta@...lbox.org>
To: Tvrtko Ursulin <tursulin@...ulin.net>, Philipp Stanner
<phasta@...nel.org>, Matthew Brost <matthew.brost@...el.com>, Danilo
Krummrich <dakr@...nel.org>, Christian König
<ckoenig.leichtzumerken@...il.com>, Maarten Lankhorst
<maarten.lankhorst@...ux.intel.com>, Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>, David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>
Cc: dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm/sched: Don't crash kernel on wrong params
On Fri, 2025-11-07 at 14:42 +0000, Tvrtko Ursulin wrote:
>
> On 07/11/2025 12:55, Philipp Stanner wrote:
> > drm_sched_job_arm() just panics the kernel with BUG_ON() in case of an
> > entity being NULL. While drm_sched_job_arm() crashing or not effectively
> > arming jobs is certainly a huge issue that needs to be noticed,
> > completely shooting down the kernel reduces the probability of reaching
> > and debugging a system to 0.
> >
> > Moreover, the checkpatch script by now strongly discourages all new uses
> > of BUG_ON() for this reason.
> >
> > Replace the BUG_ON() in drm_sched_job_arm() with a WARN_ON().
> >
> > Signed-off-by: Philipp Stanner <phasta@...nel.org>
> > ---
> > drivers/gpu/drm/scheduler/sched_main.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> > index 1d4f1b822e7b..3bf4ae0ca4bc 100644
> > --- a/drivers/gpu/drm/scheduler/sched_main.c
> > +++ b/drivers/gpu/drm/scheduler/sched_main.c
> > @@ -857,7 +857,7 @@ void drm_sched_job_arm(struct drm_sched_job *job)
> > struct drm_gpu_scheduler *sched;
> > struct drm_sched_entity *entity = job->entity;
> >
> > - BUG_ON(!entity);
> > + WARN_ON(!entity);
> > drm_sched_entity_select_rq(entity);
>
> void drm_sched_entity_select_rq(struct drm_sched_entity *entity)
> {
> struct dma_fence *fence;
> struct drm_gpu_scheduler *sched;
> struct drm_sched_rq *rq;
>
> /* single possible engine and already selected */
> if (!entity->sched_list)
>
> Still the same end result.
>
> I believe best practice is to simply not have BUG_ON's followed by null
> pointer dereferences since they add no value. Ie. it should just be
> removed and not replaced.
Hm, right. I agree. Both jobs and entities are initialized to 0
anyways. Existing users work, and new users would notice a null ptr
crash.
Let's remove it altogether.
P.
Powered by blists - more mailing lists