aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLyude Paul <lyude@redhat.com>2018-01-25 18:29:53 -0500
committerBen Skeggs <bskeggs@redhat.com>2018-01-25 18:44:39 -0500
commit0fd189a95fdbc631737df5f27a0fc0a3dd31b75e (patch)
tree50938d5e6a83a920cc40d0fa4ccdbcc4fddff0f1 /drivers
parent2ffa64eba94fc8cc23d431cbec7365f3f07ff0ae (diff)
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. Signed-off-by: Lyude Paul <lyude@redhat.com> Cc: Karol Herbst <kherbst@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Mike Galbraith <efault@gmx.de> Cc: stable@vger.kernel.org Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c
index deb96de54b00..ee2431a7804e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c
@@ -71,6 +71,10 @@ nvkm_pci_intr(int irq, void *arg)
71 struct nvkm_pci *pci = arg; 71 struct nvkm_pci *pci = arg;
72 struct nvkm_device *device = pci->subdev.device; 72 struct nvkm_device *device = pci->subdev.device;
73 bool handled = false; 73 bool handled = false;
74
75 if (pci->irq < 0)
76 return IRQ_HANDLED;
77
74 nvkm_mc_intr_unarm(device); 78 nvkm_mc_intr_unarm(device);
75 if (pci->msi) 79 if (pci->msi)
76 pci->func->msi_rearm(pci); 80 pci->func->msi_rearm(pci);
@@ -84,11 +88,6 @@ nvkm_pci_fini(struct nvkm_subdev *subdev, bool suspend)
84{ 88{
85 struct nvkm_pci *pci = nvkm_pci(subdev); 89 struct nvkm_pci *pci = nvkm_pci(subdev);
86 90
87 if (pci->irq >= 0) {
88 free_irq(pci->irq, pci);
89 pci->irq = -1;
90 }
91
92 if (pci->agp.bridge) 91 if (pci->agp.bridge)
93 nvkm_agp_fini(pci); 92 nvkm_agp_fini(pci);
94 93
@@ -108,8 +107,20 @@ static int
108nvkm_pci_oneinit(struct nvkm_subdev *subdev) 107nvkm_pci_oneinit(struct nvkm_subdev *subdev)
109{ 108{
110 struct nvkm_pci *pci = nvkm_pci(subdev); 109 struct nvkm_pci *pci = nvkm_pci(subdev);
111 if (pci_is_pcie(pci->pdev)) 110 struct pci_dev *pdev = pci->pdev;
112 return nvkm_pcie_oneinit(pci); 111 int ret;
112
113 if (pci_is_pcie(pci->pdev)) {
114 ret = nvkm_pcie_oneinit(pci);
115 if (ret)
116 return ret;
117 }
118
119 ret = request_irq(pdev->irq, nvkm_pci_intr, IRQF_SHARED, "nvkm", pci);
120 if (ret)
121 return ret;
122
123 pci->irq = pdev->irq;
113 return 0; 124 return 0;
114} 125}
115 126
@@ -117,7 +128,6 @@ static int
117nvkm_pci_init(struct nvkm_subdev *subdev) 128nvkm_pci_init(struct nvkm_subdev *subdev)
118{ 129{
119 struct nvkm_pci *pci = nvkm_pci(subdev); 130 struct nvkm_pci *pci = nvkm_pci(subdev);
120 struct pci_dev *pdev = pci->pdev;
121 int ret; 131 int ret;
122 132
123 if (pci->agp.bridge) { 133 if (pci->agp.bridge) {
@@ -131,28 +141,34 @@ nvkm_pci_init(struct nvkm_subdev *subdev)
131 if (pci->func->init) 141 if (pci->func->init)
132 pci->func->init(pci); 142 pci->func->init(pci);
133 143
134 ret = request_irq(pdev->irq, nvkm_pci_intr, IRQF_SHARED, "nvkm", pci);
135 if (ret)
136 return ret;
137
138 pci->irq = pdev->irq;
139
140 /* Ensure MSI interrupts are armed, for the case where there are 144 /* Ensure MSI interrupts are armed, for the case where there are
141 * already interrupts pending (for whatever reason) at load time. 145 * already interrupts pending (for whatever reason) at load time.
142 */ 146 */
143 if (pci->msi) 147 if (pci->msi)
144 pci->func->msi_rearm(pci); 148 pci->func->msi_rearm(pci);
145 149
146 return ret; 150 return 0;
147} 151}
148 152
149static void * 153static void *
150nvkm_pci_dtor(struct nvkm_subdev *subdev) 154nvkm_pci_dtor(struct nvkm_subdev *subdev)
151{ 155{
152 struct nvkm_pci *pci = nvkm_pci(subdev); 156 struct nvkm_pci *pci = nvkm_pci(subdev);
157
153 nvkm_agp_dtor(pci); 158 nvkm_agp_dtor(pci);
159
160 if (pci->irq >= 0) {
161 /* freq_irq() will call the handler, we use pci->irq == -1
162 * to signal that it's been torn down and should be a noop.
163 */
164 int irq = pci->irq;
165 pci->irq = -1;
166 free_irq(irq, pci);
167 }
168
154 if (pci->msi) 169 if (pci->msi)
155 pci_disable_msi(pci->pdev); 170 pci_disable_msi(pci->pdev);
171
156 return nvkm_pci(subdev); 172 return nvkm_pci(subdev);
157} 173}
158 174