Lyude Paul
2022-Aug-10 21:35 UTC
[Nouveau] Advice about debugging nouveau driver suspend issue (init_on_alloc=1 and init_on_free=1)
On Wed, 2022-08-10 at 13:59 +0200, Karol Herbst wrote:> On Wed, Aug 10, 2022 at 12:42 PM Computer Enthusiastic > <computer.enthusiastic at gmail.com> wrote: > > > > Hello, > > > > The "supend to ram" issue (system freeze when resuming after suspend > > to ram or disk hibernation) is still affecting the nouveau kernel > > module from linux version 5 and above with nvidia GeForce 9600M GT and > > other nvidia graphic card with the same chipset [1][2][3]. > > > > I've been successfully using the "work in progress" patch by Karol > > Herbst [4] to solve the "supend to ram" issue since it was proposed > > for an apparent different issue ("[GT216][Linux 5.16.4] Long stalls in > > dma_fence_default_wait") [5] whose root cause is probably the same. > > > > I send this message to bring to your attention the aforementioned > > patch [4] (below in the message as text) to evaluate it for the next > > steps for possible inclusion in the upstream kernel version. > > > > I think it might be better to CC Ben and Lyude, who _might_ have a > good idea on what's the proper patch, but maybe the patch is fine as > it is?When the GPU starts going into suspend, TTM migrates all of the active bos in vram over to system ram so they aren't lost. Based on what's described here and the fact that a fence wait seems to fix it, it sounds like to me that TTM may still be migrating bos (buffer objects) from the GPU over to system RAM when the suspend process starts. Of course this causes those operations to get interrupted and lose access to VRAM unexpectedly, which likely causes the world to go boom. So, I'm not 100% sure but I think this patch is potentially overkill since it looks like it would fix this issue by just making all m2mf bo moves synchronous. Thisis something we probably(?) don't want to do since if my theory is correct, the only time we should need to do a fence wait is before suspending the GPU in order to ensure that all m2mf operations have been completed before continuing suspend. I think Ben would likely need to weigh in, or you might be able to figure out the answer to this just by seeing how we handle this with the newer method of vram blitting - the CE (copy engine). Let me know if you need any more input, or are able to come up with a patch that more or less does what I just described.> > > Thanks. > > > > [1] https://gitlab.freedesktop.org/xorg/driver/xf86-video-nouveau/-/issues/547 > > [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=989705#5 > > [3] https://bugzilla.kernel.org/show_bug.cgi?id=213617 > > [4] https://gitlab.freedesktop.org/drm/nouveau/-/issues/156#note_1385770 > > [5] https://gitlab.freedesktop.org/drm/nouveau/-/issues/156 > > > > ----- %= ----- %= ----- %> > > > From 70271cb0aa30e4523d39c3942e84b16fe18338f5 Mon Sep 17 00:00:00 2001 > > From: Karol Herbst <kherbst at redhat.com> > > Date: Mon, 16 May 2022 17:40:20 +0200 > > Subject: [PATCH] nouveau WIP > > > > --- > > drivers/gpu/drm/nouveau/nouveau_bo.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c > > b/drivers/gpu/drm/nouveau/nouveau_bo.c > > index 05076e530e7d..b6343741eda6 100644 > > --- a/drivers/gpu/drm/nouveau/nouveau_bo.c > > +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c > > @@ -820,6 +820,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, > > int evict, > > if (ret == 0) { > > ret = nouveau_fence_new(chan, false, &fence); > > if (ret == 0) { > > + nouveau_fence_wait(fence, false, false); > > ret = ttm_bo_move_accel_cleanup(bo, > > &fence->base, > > evict, false, > > -- > > 2.35.3 > > >-- Cheers, Lyude Paul (she/her) Software Engineer at Red Hat
Karol Herbst
2022-Aug-10 22:08 UTC
[Nouveau] Advice about debugging nouveau driver suspend issue (init_on_alloc=1 and init_on_free=1)
On Wed, Aug 10, 2022 at 11:35 PM Lyude Paul <lyude at redhat.com> wrote:> > On Wed, 2022-08-10 at 13:59 +0200, Karol Herbst wrote: > > On Wed, Aug 10, 2022 at 12:42 PM Computer Enthusiastic > > <computer.enthusiastic at gmail.com> wrote: > > > > > > Hello, > > > > > > The "supend to ram" issue (system freeze when resuming after suspend > > > to ram or disk hibernation) is still affecting the nouveau kernel > > > module from linux version 5 and above with nvidia GeForce 9600M GT and > > > other nvidia graphic card with the same chipset [1][2][3]. > > > > > > I've been successfully using the "work in progress" patch by Karol > > > Herbst [4] to solve the "supend to ram" issue since it was proposed > > > for an apparent different issue ("[GT216][Linux 5.16.4] Long stalls in > > > dma_fence_default_wait") [5] whose root cause is probably the same. > > > > > > I send this message to bring to your attention the aforementioned > > > patch [4] (below in the message as text) to evaluate it for the next > > > steps for possible inclusion in the upstream kernel version. > > > > > > > I think it might be better to CC Ben and Lyude, who _might_ have a > > good idea on what's the proper patch, but maybe the patch is fine as > > it is? > > When the GPU starts going into suspend, TTM migrates all of the active bos in > vram over to system ram so they aren't lost. Based on what's described here > and the fact that a fence wait seems to fix it, it sounds like to me that TTM > may still be migrating bos (buffer objects) from the GPU over to system RAM > when the suspend process starts. Of course this causes those operations to get > interrupted and lose access to VRAM unexpectedly, which likely causes the > world to go boom. >the thing is, without this patch, the "hw path" fails with a timeout of... 30 seconds?, the code falls back to sw and it takes up to 2-3 minutes to finish up. So even if this solution is overkill, it fixes a real issue. I suspect _something_ is bonkers with the fencing we do here and we don't see that the stuff is actually finished or whatever, or maybe we never emit the fence in the first place.. I didn't dig deep enough. With this, it's really quick and everything.> So, I'm not 100% sure but I think this patch is potentially overkill since it > looks like it would fix this issue by just making all m2mf bo moves > synchronous. Thisis something we probably(?) don't want to do since if my > theory is correct, the only time we should need to do a fence wait is before > suspending the GPU in order to ensure that all m2mf operations have been > completed before continuing suspend. I think Ben would likely need to weigh > in, or you might be able to figure out the answer to this just by seeing how > we handle this with the newer method of vram blitting - the CE (copy engine). > Let me know if you need any more input, or are able to come up with a patch > that more or less does what I just described. > > > > > > Thanks. > > > > > > [1] https://gitlab.freedesktop.org/xorg/driver/xf86-video-nouveau/-/issues/547 > > > [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=989705#5 > > > [3] https://bugzilla.kernel.org/show_bug.cgi?id=213617 > > > [4] https://gitlab.freedesktop.org/drm/nouveau/-/issues/156#note_1385770 > > > [5] https://gitlab.freedesktop.org/drm/nouveau/-/issues/156 > > > > > > ----- %= ----- %= ----- %> > > > > > From 70271cb0aa30e4523d39c3942e84b16fe18338f5 Mon Sep 17 00:00:00 2001 > > > From: Karol Herbst <kherbst at redhat.com> > > > Date: Mon, 16 May 2022 17:40:20 +0200 > > > Subject: [PATCH] nouveau WIP > > > > > > --- > > > drivers/gpu/drm/nouveau/nouveau_bo.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c > > > b/drivers/gpu/drm/nouveau/nouveau_bo.c > > > index 05076e530e7d..b6343741eda6 100644 > > > --- a/drivers/gpu/drm/nouveau/nouveau_bo.c > > > +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c > > > @@ -820,6 +820,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, > > > int evict, > > > if (ret == 0) { > > > ret = nouveau_fence_new(chan, false, &fence); > > > if (ret == 0) { > > > + nouveau_fence_wait(fence, false, false); > > > ret = ttm_bo_move_accel_cleanup(bo, > > > &fence->base, > > > evict, false, > > > -- > > > 2.35.3 > > > > > > > -- > Cheers, > Lyude Paul (she/her) > Software Engineer at Red Hat >