From: Philipp Stanner <pstanner@redhat.com>
To: "Christian König" <christian.koenig@amd.com>,
"Philipp Reisner" <philipp.reisner@linbit.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Simona Vetter <simona@ffwll.ch>,
Danilo Krummrich <dakr@kernel.org>,
Philipp Stanner <phasta@kernel.org>
Subject: Re: [PATCH] drm/sched: Fix amdgpu crash upon suspend/resume
Date: Mon, 13 Jan 2025 09:43:12 +0100 [thread overview]
Message-ID: <582e10673bb749f18ebf8a18f46ca573df396576.camel@redhat.com> (raw)
In-Reply-To: <eb5f3198-7625-40f4-bc23-cac969664e85@amd.com>
+cc Danilo
+cc myself
On Wed, 2025-01-08 at 09:19 +0100, Christian König wrote:
> Am 07.01.25 um 16:21 schrieb Philipp Reisner:
> > [...]
> > > > The OOPS happens because the rq member of entity is NULL in
> > > > drm_sched_job_arm() after the call to
> > > > drm_sched_entity_select_rq().
> > > >
> > > > In drm_sched_entity_select_rq(), the code considers that
> > > > drb_sched_pick_best() might return a NULL value. When NULL, it
> > > > assigns
> > > > NULL to entity->rq even if it had a non-NULL value before.
> > > >
> > > > drm_sched_job_arm() does not deal with entities having a rq of
> > > > NULL.
> > > >
> > > > Fix this by leaving the entity on the engine it was instead of
> > > > assigning a NULL to its run queue member.
> > > Well that is clearly not the correct approach to fixing this. So
> > > clearly
> > > a NAK from my side.
> > >
> > > The real question is why is amdgpu_cs_ioctl() called when all of
> > > userspace should be frozen?
> > >
> > > Regards,
> > > Christian.
> > >
> > Could the OOPS happen at resume time? Might it be that the kernel
> > activates user-space
> > before all the components of the GPU finished their wakeup?
> >
> > Maybe drm_sched_pick_best() returns NULL since no scheduler is
> > ready yet?
>
> Yeah that is exactly what I meant. It looks like either the suspend
> or
> the resume order is somehow messed up.
>
> In other words either some application tries to submit GPU work while
> it
> should already been stopped, or it tries to submit GPU work before it
> is
> started.
>
> > Apart from whether amdgpu_cs_ioctl() should run at this point, I
> > still think the
> > suggested change improves the code. drm_sched_pick_best() can
> > return NULL.
> > drm_sched_entity_select_rq() can handle the NULL (partially).
> >
> > drm_sched_job_arm() crashes on an entity that has rq set to NULL.
>
> Which is actually not the worst outcome :)
>
> With your patch applied we don't immediately crash any more in the
> submission path, but the whole system could then later deadlock
> because
> the core memory management waits for a GPU submission which never
> returns.
>
> That is an even worse situation because you then can't pinpoint any
> more
> where that is coming from.
>
> > The handling of NULL values is half-baked.
> >
> > In my opinion, you should define if drm_sched_pick_best() may put a
> > NULL into
> > rq. If your answer is yes, it might put a NULL there; then, there
> > should be a
> > BUG_ON(!entity->rq) after the invocation of
> > drm_sched_entity_select_rq().
> > If your answer is no, the BUG_ON() should be in
> > drm_sched_pick_best().
>
> Yeah good point.
>
> We might not want a BUG_ON(), that is only justified when we prevent
> further damage (e.g. random data corruption or similar).
>
> I suggest using a WARN(!shed, "Submission without activated
> sheduler!").
> This way the system has at least a chance of survival should the
> scheduler become ready later on.
>
> On the other hand the BUG_ON() or the NULL pointer deref should only
> kill the application thread which is submitting something before the
> driver is resumed. So that might help to pinpoint where the actually
> issue is.
As I see it the BUG_ON() would just be a more pretty NULL pointer
deref. If we agree that this is effectively a misuse of the scheduler
API we probably want to add it to make it more pretty, though?
@Philipp:
BTW, I only just discovered this thread by coincidence. Please use
get_maintainer. The scheduler currently has 4 maintainers, and none of
them is on CC.
Danke,
P.
>
> Regards,
> Christian.
>
> >
> > That helps guys with zero domain knowledge, like me, to figure out
> > how
> > this is all
> > supposed to work.
> >
> > best regards,
> > Philipp
>
next prev parent reply other threads:[~2025-01-13 8:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-07 14:02 Philipp Reisner
2025-01-07 14:08 ` Christian König
2025-01-07 15:21 ` Philipp Reisner
2025-01-08 8:19 ` Christian König
2025-01-13 8:43 ` Philipp Stanner [this message]
[not found] ` <b055ff59-4653-44d9-a2e0-bb43eb158315@amd.com>
2025-05-28 9:55 ` Christopher Snowhill
2025-06-02 10:25 ` Philipp Reisner
2025-06-04 10:19 ` Christopher Snowhill
2025-01-08 14:26 ` Alex Deucher
2025-01-08 14:35 ` Christian König
2025-01-10 7:37 ` Philipp Reisner
2025-01-10 8:44 ` Christian König
2025-01-10 14:32 ` Philipp Reisner
2025-01-10 14:47 ` Christian König
2025-01-10 15:10 ` Alex Deucher
2025-01-13 8:32 ` Christian König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=582e10673bb749f18ebf8a18f46ca573df396576.camel@redhat.com \
--to=pstanner@redhat.com \
--cc=christian.koenig@amd.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=phasta@kernel.org \
--cc=philipp.reisner@linbit.com \
--cc=simona@ffwll.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®