Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci adjus...



details:   https://anonhg.NetBSD.org/src/rev/aa6a1f22c537
branches:  trunk
changeset: 1007282:aa6a1f22c537
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Wed Feb 12 22:34:51 2020 +0000

description:
adjust the PCI interrupt allocation code to work the same as
drm_pci_request_irq(), now the driver successfully allocates MSI interrupt

[   3.6619808] nouveau0: info: NVIDIA GK208B (b06070b1)
[   3.7685336] nouveau0: info: bios: version 80.28.78.00.4b
[   3.7785491] nouveau0: interrupting at msi8 vec 0 (nouveau0)

related to PR kern/52440 by John D. Baker

diffstat:

 sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_base.c |  55 +++++++--
 1 files changed, 42 insertions(+), 13 deletions(-)

diffs (81 lines):

diff -r e8a416695bab -r aa6a1f22c537 sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_base.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_base.c     Wed Feb 12 20:31:46 2020 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_base.c     Wed Feb 12 22:34:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_nvkm_subdev_pci_base.c,v 1.6 2020/02/07 18:13:33 jmcneill Exp $        */
+/*     $NetBSD: nouveau_nvkm_subdev_pci_base.c,v 1.7 2020/02/12 22:34:51 jdolecek Exp $        */
 
 /*
  * Copyright 2015 Red Hat Inc.
@@ -24,7 +24,7 @@
  * Authors: Ben Skeggs <bskeggs%redhat.com@localhost>
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_pci_base.c,v 1.6 2020/02/07 18:13:33 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_pci_base.c,v 1.7 2020/02/12 22:34:51 jdolecek Exp $");
 
 #include "priv.h"
 #include "agp.h"
@@ -141,22 +141,51 @@
 
 #ifdef __NetBSD__
     {
+       const char *const name = device_xname(pci_dev_dev(pdev));
        const struct pci_attach_args *pa = &pdev->pd_pa;
-       int counts[PCI_INTR_TYPE_SIZE] =  {
-                       [PCI_INTR_TYPE_INTX] = 1,
-                       [PCI_INTR_TYPE_MSI] = 0,
-                       [PCI_INTR_TYPE_MSIX] = 0,
-       };
+       const char *intrstr;
+       char intrbuf[PCI_INTRSTR_LEN];
 
-       /* XXX errno NetBSD->Linux */
-       ret = -pci_intr_alloc(pa, &pci->pci_ihp, counts, PCI_INTR_TYPE_INTX);
-       if (ret)
-               return ret;
+       /* XXX convert to use drm_pci_request_irq() */
+       if (pdev->msi_enabled) {
+               if (pdev->pd_intr_handles == NULL) {
+                       if ((ret = pci_msi_alloc_exact(pa, &pci->pci_ihp,
+                           1))) {
+                               aprint_error_dev(pci_dev_dev(pdev),
+                                   "couldn't allocate MSI (%s)\n", name);
+                               /* XXX errno NetBSD->Linux */
+                               return -ret;
+                       }
+               } else {
+                       pci->pci_ihp = pdev->pd_intr_handles;
+                       pdev->pd_intr_handles = NULL;
+               }
+       } else {
+               if ((ret = pci_intx_alloc(pa, &pci->pci_ihp))) {
+                       aprint_error_dev(pci_dev_dev(pdev),
+                           "couldn't allocate INTx interrupt (%s)\n",
+                           name);
+
+                       /* XXX errno NetBSD->Linux */
+                       return -ret;
+               }
+       }
+
+       intrstr = pci_intr_string(pa->pa_pc, pci->pci_ihp[0],
+           intrbuf, sizeof(intrbuf));
        pci->pci_intrcookie = pci_intr_establish_xname(pa->pa_pc,
            pci->pci_ihp[0], IPL_DRM, nvkm_pci_intr, pci,
-           device_xname(pci_dev_dev(pdev)));
-       if (pci->pci_intrcookie == NULL)
+           name);
+       if (pci->pci_intrcookie == NULL) {
+               aprint_error_dev(pci_dev_dev(pdev),
+                   "couldn't establish interrupt at %s (%s)\n", intrstr, name);
+               pci_intr_release(pa->pa_pc, pci->pci_ihp, 1);
+               pci->pci_ihp = NULL;
                return -EIO;    /* XXX er? */
+       }
+
+       aprint_normal_dev(pci_dev_dev(pdev), "interrupting at %s (%s)\n",
+           intrstr, name);
     }
 #else
        ret = request_irq(pdev->irq, nvkm_pci_intr, IRQF_SHARED, "nvkm", pci);



Home | Main Index | Thread Index | Old Index