Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Use MSI/MSI-X instead of legacy INTx, if available.



details:   https://anonhg.NetBSD.org/src/rev/6b569845862d
branches:  trunk
changeset: 340436:6b569845862d
user:      nonaka <nonaka%NetBSD.org@localhost>
date:      Sat Sep 05 04:56:53 2015 +0000

description:
Use MSI/MSI-X instead of legacy INTx, if available.

diffstat:

 sys/dev/pci/rtsx_pci.c |  23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diffs (72 lines):

diff -r 3b316e77c9c5 -r 6b569845862d sys/dev/pci/rtsx_pci.c
--- a/sys/dev/pci/rtsx_pci.c    Sat Sep 05 04:44:29 2015 +0000
+++ b/sys/dev/pci/rtsx_pci.c    Sat Sep 05 04:56:53 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtsx_pci.c,v 1.3 2014/10/29 14:24:09 nonaka Exp $      */
+/*     $NetBSD: rtsx_pci.c,v 1.4 2015/09/05 04:56:53 nonaka Exp $      */
 /*     $OpenBSD: rtsx_pci.c,v 1.7 2014/08/19 17:55:03 phessler Exp $   */
 
 
@@ -20,7 +20,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsx_pci.c,v 1.3 2014/10/29 14:24:09 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsx_pci.c,v 1.4 2015/09/05 04:56:53 nonaka Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -42,6 +42,10 @@
        struct rtsx_softc sc;
        pci_chipset_tag_t sc_pc;
        void *sc_ih;
+
+#ifdef __HAVE_PCI_MSI_MSIX
+       pci_intr_handle_t *sc_pihp;
+#endif
 };
 
 static int rtsx_pci_match(device_t , cfdata_t, void *);
@@ -92,7 +96,9 @@
        struct pci_attach_args *pa = (struct pci_attach_args *)aux;
        pci_chipset_tag_t pc = pa->pa_pc;
        pcitag_t tag = pa->pa_tag;
+#ifndef __HAVE_PCI_MSI_MSIX
        pci_intr_handle_t ih;
+#endif
        pcireg_t reg;
        char const *intrstr;
        bus_space_tag_t iot;
@@ -117,12 +123,22 @@
                return;
        }
 
+#ifdef __HAVE_PCI_MSI_MSIX
+       if (pci_intr_alloc(pa, &sc->sc_pihp, NULL, 0)) {
+               aprint_error_dev(self, "couldn't map interrupt\n");
+               return;
+       }
+       intrstr = pci_intr_string(pc, sc->sc_pihp[0], intrbuf, sizeof(intrbuf));
+       sc->sc_ih = pci_intr_establish(pc, sc->sc_pihp[0], IPL_SDMMC, rtsx_intr,
+           &sc->sc);
+#else  /* !__HAVE_PCI_MSI_MSIX */
        if (pci_intr_map(pa, &ih)) {
                aprint_error_dev(self, "couldn't map interrupt\n");
                return;
        }
        intrstr = pci_intr_string(pc, ih, intrbuf, sizeof(intrbuf));
        sc->sc_ih = pci_intr_establish(pc, ih, IPL_SDMMC, rtsx_intr, &sc->sc);
+#endif /* __HAVE_PCI_MSI_MSIX */
        if (sc->sc_ih == NULL) {
                aprint_error_dev(self, "couldn't establish interrupt\n");
                return;
@@ -182,6 +198,9 @@
                return rv;
 
        pci_intr_disestablish(sc->sc_pc, sc->sc_ih);
+#ifdef __HAVE_PCI_MSI_MSIX
+       pci_intr_release(sc->sc_pc, sc->sc_pihp, 1);
+#endif /* __HAVE_PCI_MSI_MSIX */
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index