Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci simplify intr establish code - rely on pci_intr_...



details:   https://anonhg.NetBSD.org/src/rev/cf21ca7a2837
branches:  trunk
changeset: 837363:cf21ca7a2837
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Nov 30 17:47:54 2018 +0000

description:
simplify intr establish code - rely on pci_intr_alloc() to allow
also MSI-X, and to return interrupt types which are possible for
pci_intr_establish(); remove fallbacks to retry with MSI/MSI-X
explicitly disabled

discussed on tech-kern@

https://mail-index.netbsd.org/tech-kern/2018/11/27/msg024240.html

diffstat:

 sys/dev/pci/ahcisata_pci.c |  53 ++++++---------------------------------------
 sys/dev/pci/xhci_pci.c     |  51 ++++++-------------------------------------
 2 files changed, 16 insertions(+), 88 deletions(-)

diffs (173 lines):

diff -r a0f3fb52e1ca -r cf21ca7a2837 sys/dev/pci/ahcisata_pci.c
--- a/sys/dev/pci/ahcisata_pci.c        Fri Nov 30 16:28:43 2018 +0000
+++ b/sys/dev/pci/ahcisata_pci.c        Fri Nov 30 17:47:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahcisata_pci.c,v 1.47 2018/11/26 21:56:04 jdolecek Exp $       */
+/*     $NetBSD: ahcisata_pci.c,v 1.48 2018/11/30 17:47:54 jdolecek Exp $       */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.47 2018/11/26 21:56:04 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.48 2018/11/30 17:47:54 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ahcisata_pci.h"
@@ -311,21 +311,8 @@
 
        pci_aprint_devinfo(pa, "AHCI disk controller");
 
-
-       /* Allocation settings */
-       int counts[PCI_INTR_TYPE_SIZE] = {
-               [PCI_INTR_TYPE_INTX] = 1,
-#ifndef AHCISATA_DISABLE_MSI
-               [PCI_INTR_TYPE_MSI] = 1,
-#endif
-#ifndef AHCISATA_DISABLE_MSIX
-               [PCI_INTR_TYPE_MSIX] = 1,
-#endif
-       };
-
-alloc_retry:
        /* Allocate and establish the interrupt. */
-       if (pci_intr_alloc(pa, &psc->sc_pihp, counts, PCI_INTR_TYPE_MSIX)) {
+       if (pci_intr_alloc(pa, &psc->sc_pihp, NULL, 0)) {
                aprint_error_dev(self, "can't allocate handler\n");
                goto fail;
        }
@@ -335,37 +322,13 @@
        psc->sc_ih = pci_intr_establish_xname(pa->pa_pc, psc->sc_pihp[0],
            IPL_BIO, ahci_intr, sc, device_xname(sc->sc_atac.atac_dev));
        if (psc->sc_ih == NULL) {
-               const pci_intr_type_t intr_type = pci_intr_type(pa->pa_pc,
-                   psc->sc_pihp[0]);
                pci_intr_release(pa->pa_pc, psc->sc_pihp, 1);
                psc->sc_ih = NULL;
-               switch (intr_type) {
-#ifndef AHCISATA_DISABLE_MSIX
-               case PCI_INTR_TYPE_MSIX:
-                       /* The next try is for MSI: Disable MSIX */
-                       counts[PCI_INTR_TYPE_INTX] = 1;
-#ifndef AHCISATA_DISABLE_MSI
-                       counts[PCI_INTR_TYPE_MSI] = 1;
-#endif
-                       counts[PCI_INTR_TYPE_MSIX] = 0;
-                       goto alloc_retry;
-#endif
-#ifndef AHCISATA_DISABLE_MSI
-               case PCI_INTR_TYPE_MSI:
-                       /* The next try is for INTx: Disable MSI */
-                       counts[PCI_INTR_TYPE_MSI] = 0;
-                       counts[PCI_INTR_TYPE_INTX] = 1;
-                       goto alloc_retry;
-#endif
-               case PCI_INTR_TYPE_INTX:
-               default:
-                       counts[PCI_INTR_TYPE_INTX] = 1;
-                       aprint_error_dev(self, "couldn't establish interrupt");
-                       if (intrstr != NULL)
-                               aprint_error(" at %s", intrstr);
-                       aprint_error("\n");
-                       goto fail;
-               }
+               aprint_error_dev(self, "couldn't establish interrupt");
+               if (intrstr != NULL)
+                       aprint_error(" at %s", intrstr);
+               aprint_error("\n");
+               goto fail;
        }
        aprint_normal_dev(self, "interrupting at %s\n", intrstr);
 
diff -r a0f3fb52e1ca -r cf21ca7a2837 sys/dev/pci/xhci_pci.c
--- a/sys/dev/pci/xhci_pci.c    Fri Nov 30 16:28:43 2018 +0000
+++ b/sys/dev/pci/xhci_pci.c    Fri Nov 30 17:47:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xhci_pci.c,v 1.17 2018/11/24 14:50:04 skrll Exp $      */
+/*     $NetBSD: xhci_pci.c,v 1.18 2018/11/30 17:47:54 jdolecek Exp $   */
 /*     OpenBSD: xhci_pci.c,v 1.4 2014/07/12 17:38:51 yuo Exp   */
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.17 2018/11/24 14:50:04 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.18 2018/11/30 17:47:54 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_xhci_pci.h"
@@ -123,7 +123,6 @@
        struct pci_attach_args *const pa = (struct pci_attach_args *)aux;
        const pci_chipset_tag_t pc = pa->pa_pc;
        const pcitag_t tag = pa->pa_tag;
-       pci_intr_type_t intr_type;
        char const *intrstr;
        pcireg_t csr, memtype, usbrev;
        int err;
@@ -177,20 +176,8 @@
        pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG,
                       csr | PCI_COMMAND_MASTER_ENABLE);
 
-       /* Allocation settings */
-       int counts[PCI_INTR_TYPE_SIZE] = {
-               [PCI_INTR_TYPE_INTX] = 1,
-#ifndef XHCI_DISABLE_MSI
-               [PCI_INTR_TYPE_MSI] = 1,
-#endif
-#ifndef XHCI_DISABLE_MSIX
-               [PCI_INTR_TYPE_MSIX] = 1,
-#endif
-       };
-
-alloc_retry:
        /* Allocate and establish the interrupt. */
-       if (pci_intr_alloc(pa, &psc->sc_pihp, counts, PCI_INTR_TYPE_MSIX)) {
+       if (pci_intr_alloc(pa, &psc->sc_pihp, NULL, 0)) {
                aprint_error_dev(self, "can't allocate handler\n");
                goto fail;
        }
@@ -199,35 +186,13 @@
        psc->sc_ih = pci_intr_establish_xname(pc, psc->sc_pihp[0], IPL_USB,
            xhci_intr, sc, device_xname(sc->sc_dev));
        if (psc->sc_ih == NULL) {
-               intr_type = pci_intr_type(pc, psc->sc_pihp[0]);
                pci_intr_release(pc, psc->sc_pihp, 1);
                psc->sc_ih = NULL;
-               switch (intr_type) {
-#ifndef XHCI_DISABLE_MSIX
-               case PCI_INTR_TYPE_MSIX:
-                       /* The next try is for MSI: Disable MSIX */
-                       counts[PCI_INTR_TYPE_MSIX] = 0;
-#ifndef XHCI_DISABLE_MSI
-                       counts[PCI_INTR_TYPE_MSI] = 1;
-#endif
-                       counts[PCI_INTR_TYPE_INTX] = 1;
-                       goto alloc_retry;
-#endif
-#ifndef XHCI_DISABLE_MSI
-               case PCI_INTR_TYPE_MSI:
-                       /* The next try is for INTx: Disable MSI */
-                       counts[PCI_INTR_TYPE_MSI] = 0;
-                       counts[PCI_INTR_TYPE_INTX] = 1;
-                       goto alloc_retry;
-#endif
-               case PCI_INTR_TYPE_INTX:
-               default:
-                       aprint_error_dev(self, "couldn't establish interrupt");
-                       if (intrstr != NULL)
-                               aprint_error(" at %s", intrstr);
-                       aprint_error("\n");
-                       goto fail;
-               }
+               aprint_error_dev(self, "couldn't establish interrupt");
+               if (intrstr != NULL)
+                       aprint_error(" at %s", intrstr);
+               aprint_error("\n");
+               goto fail;
        }
        aprint_normal_dev(self, "interrupting at %s\n", intrstr);
 



Home | Main Index | Thread Index | Old Index