Skip to contentSkip to conversation

drm/nouveau: Move irq setup/teardown to pci ctor/dtor

PATCH Superseded Lyude Paul 1 participant 1 message Jan 25, 2018

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Lyude Paul

author maintainer
#0 lore raw

PATCH v2 1/1 drm/nouveau: Move irq setup/teardown to pci ctor/dtor

For a while we've been having issues with seemingly random interrupts coming from nvidia cards when resuming them. Originally the fix for this was thought to be just re-arming the MSI interrupt registers right after re-allocating our IRQs, however it seems a lot of what we do is both wrong and not even nessecary.

This was made apparent by what appeared to be a regression in the mainline kernel that started introducing suspend/resume issues for nouveau:

a0c9259dc4e1 (irq/matrix: Spread interrupts on allocation)

After this commit was introduced, we started getting interrupts from the GPU before we actually re-allocated our own IRQ (see references below) and assigned the IRQ handler. Investigating this turned out that the problem was not with the commit, but the fact that nouveau even free/allocates it's irqs before and after suspend/resume.

For starters: drivers in the linux kernel haven't had to handle freeing/re-allocating their IRQs during suspend/resume cycles for quite a while now. Nouveau seems to be one of the few drivers left that still does this, despite the fact there's no reason we actually need to since disabling interrupts from the device side should be enough, as the kernel is already smart enough to know to disable host-side interrupts for us before going into suspend. Since we were tearing down our IRQs by hand however, that means there was a short period during resume where interrupts could be received before we re-allocated our IRQ which would lead to us getting an unhandled IRQ. Since we never handle said IRQ and re-arm the interrupt registers, this would cause us to miss all of the interrupts from the GPU and cause our init process to start timing out on anything requiring interrupts.

So, since this whole setup/teardown every suspend/resume cycle is useless anyway, move irq setup/teardown into the pci subdev's ctor/dtor functions instead so they're only called at driver load and driver unload. This should fix most of the issues with pending interrupts on resume, along with getting suspend/resume for nouveau to work again.

As well, this probably means we can also just remove the msi rearm call inside nvkm_pci_init(). But since our main focus here is to fix suspend/resume before 4.15, we'll save that for a later patch.

Cc Karol Herbst <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Mike Galbraith <[email protected]>

---
Changes since v1:
- Fix small typo in commit message
No functional changes

 drivers/gpu/drm/nouveau/include/nvkm/subdev/pci.h |  1 +
 drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c    | 43 +++++++++++++++--------
 2 files changed, 29 insertions(+), 15 deletions(-)
drivers/gpu/drm/nouveau/include/nvkm/subdev/pci.h +1 -0
index 23803cc859fd..378bfc8d5fa8 100644
@@ -31,6 +31,7 @@ struct nvkm_pci {
 	} pcie;
 
 	bool msi;
+	bool teardown;
 };
 
 u32 nvkm_pci_rd32(struct nvkm_pci *, u16 addr);
drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c +28 -15

94 lines not on this page · raw message

Signature · 6 lines
2.14.3

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau