<div dir="ltr">Tested-by: Tom St Denis <<a href="mailto:tom.stdenis@amd.com">tom.stdenis@amd.com</a>><div><br></div><div>Cheers,</div><div>Tom</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 3, 2019 at 1:30 PM Alex Deucher <<a href="mailto:alexdeucher@gmail.com">alexdeucher@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Check the number of supported vectors and fall back to MSI if<br>
we return or error or 0 MSI-X vectors.<br>
<br>
v2: only allocate one vector.  We can't currently use more than<br>
one anyway.<br>
<br>
v3: install the irq on vector 0.<br>
<br>
Signed-off-by: Alex Deucher <<a href="mailto:alexander.deucher@amd.com" target="_blank">alexander.deucher@amd.com</a>><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 17 +++++++++++++----<br>
 1 file changed, 13 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c<br>
index 50771b2757dc..6f3b03f6224f 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c<br>
@@ -245,11 +245,19 @@ int amdgpu_irq_init(struct amdgpu_device *adev)<br>
        adev->irq.msi_enabled = false;<br>
<br>
        if (amdgpu_msi_ok(adev)) {<br>
-               int nvec = pci_alloc_irq_vectors(adev->pdev, 1, pci_msix_vec_count(adev->pdev),<br>
-                                       PCI_IRQ_MSI | PCI_IRQ_MSIX);<br>
+               int nvec = pci_msix_vec_count(adev->pdev);<br>
+               unsigned int flags;<br>
+<br>
+               if (nvec <= 0) {<br>
+                       flags = PCI_IRQ_MSI;<br>
+               } else {<br>
+                       flags = PCI_IRQ_MSI | PCI_IRQ_MSIX;<br>
+               }<br>
+               /* we only need one vector */<br>
+               nvec = pci_alloc_irq_vectors(adev->pdev, 1, 1, flags);<br>
                if (nvec > 0) {<br>
                        adev->irq.msi_enabled = true;<br>
-                       dev_dbg(adev->dev, "amdgpu: using MSI.\n");<br>
+                       dev_dbg(adev->dev, "amdgpu: using MSI/MSI-X.\n");<br>
                }<br>
        }<br>
<br>
@@ -272,7 +280,8 @@ int amdgpu_irq_init(struct amdgpu_device *adev)<br>
        INIT_WORK(&adev->irq.ih2_work, amdgpu_irq_handle_ih2);<br>
<br>
        adev->irq.installed = true;<br>
-       r = drm_irq_install(adev->ddev, adev->ddev->pdev->irq);<br>
+       /* Use vector 0 for MSI-X */<br>
+       r = drm_irq_install(adev->ddev, pci_irq_vector(adev->pdev, 0));<br>
        if (r) {<br>
                adev->irq.installed = false;<br>
                if (!amdgpu_device_has_dc_support(adev))<br>
-- <br>
2.20.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org" target="_blank">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></blockquote></div>