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 instead of legacy INTx, if available.
details: https://anonhg.NetBSD.org/src/rev/3694824f42aa
branches: trunk
changeset: 337808:3694824f42aa
user: nonaka <nonaka%NetBSD.org@localhost>
date: Tue Apr 28 15:38:02 2015 +0000
description:
Use MSI instead of legacy INTx, if available.
should fix PR/49663.
diffstat:
sys/dev/pci/if_iwm.c | 38 ++++++++++++++++++++++++++++++++++++--
sys/dev/pci/if_iwmvar.h | 11 ++++++++++-
2 files changed, 46 insertions(+), 3 deletions(-)
diffs (107 lines):
diff -r 598960ce9412 -r 3694824f42aa sys/dev/pci/if_iwm.c
--- a/sys/dev/pci/if_iwm.c Tue Apr 28 15:15:53 2015 +0000
+++ b/sys/dev/pci/if_iwm.c Tue Apr 28 15:38:02 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_iwm.c,v 1.30 2015/04/15 05:40:48 nonaka Exp $ */
+/* $NetBSD: if_iwm.c,v 1.31 2015/04/28 15:38:02 nonaka Exp $ */
/* OpenBSD: if_iwm.c,v 1.39 2015/03/23 00:35:19 jsg Exp */
/*
@@ -105,7 +105,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.30 2015/04/15 05:40:48 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.31 2015/04/28 15:38:02 nonaka Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -6628,7 +6628,9 @@
{
struct iwm_softc *sc = device_private(self);
struct pci_attach_args *pa = aux;
+#ifndef __HAVE_PCI_MSI_MSIX
pci_intr_handle_t ih;
+#endif
pcireg_t reg, memtype;
const char *intrstr;
int error;
@@ -6676,14 +6678,46 @@
}
/* Install interrupt handler. */
+ sc->sc_intr_type = IWM_INTR_INTX;
+#ifdef __HAVE_PCI_MSI_MSIX
+ error = ENODEV;
+ if (pci_msi_count(pa) > 0) {
+ error = pci_msi_alloc_exact(pa, &sc->sc_pihp, 1);
+ if (error == 0)
+ sc->sc_intr_type = IWM_INTR_MSI;
+ }
+ if (error != 0) {
+ if (pci_intx_alloc(pa, &sc->sc_pihp)) {
+ aprint_error_dev(self, "can't map interrupt\n");
+ return;
+ }
+ }
+#else /* !__HAVE_PCI_MSI_MSIX */
if (pci_intr_map(pa, &ih)) {
aprint_error_dev(self, "can't map interrupt\n");
return;
}
+#endif /* __HAVE_PCI_MSI_MSIX */
char intrbuf[PCI_INTRSTR_LEN];
+#ifdef __HAVE_PCI_MSI_MSIX
+ intrstr = pci_intr_string(sc->sc_pct, sc->sc_pihp[0], intrbuf,
+ sizeof(intrbuf));
+ switch (sc->sc_intr_type) {
+ case IWM_INTR_MSI:
+ sc->sc_ih = pci_msi_establish(sc->sc_pct, sc->sc_pihp[0],
+ IPL_NET, iwm_intr, sc);
+ break;
+
+ case IWM_INTR_INTX:
+ sc->sc_ih = pci_intr_establish(sc->sc_pct, sc->sc_pihp[0],
+ IPL_NET, iwm_intr, sc);
+ break;
+ }
+#else /* !__HAVE_PCI_MSI_MSIX */
intrstr = pci_intr_string(sc->sc_pct, ih, intrbuf, sizeof(intrbuf));
sc->sc_ih = pci_intr_establish(sc->sc_pct, ih, IPL_NET, iwm_intr, sc);
+#endif /* __HAVE_PCI_MSI_MSIX */
if (sc->sc_ih == NULL) {
aprint_error_dev(self, "can't establish interrupt");
if (intrstr != NULL)
diff -r 598960ce9412 -r 3694824f42aa sys/dev/pci/if_iwmvar.h
--- a/sys/dev/pci/if_iwmvar.h Tue Apr 28 15:15:53 2015 +0000
+++ b/sys/dev/pci/if_iwmvar.h Tue Apr 28 15:38:02 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_iwmvar.h,v 1.5 2015/03/03 09:10:45 nonaka Exp $ */
+/* $NetBSD: if_iwmvar.h,v 1.6 2015/04/28 15:38:02 nonaka Exp $ */
/* OpenBSD: if_iwmvar.h,v 1.7 2015/03/02 13:51:10 jsg Exp */
/*
@@ -363,6 +363,11 @@
int last_cqm_event;
};
+enum iwm_intr_type {
+ IWM_INTR_INTX,
+ IWM_INTR_MSI
+};
+
struct iwm_softc {
device_t sc_dev;
struct ethercom sc_ec;
@@ -376,6 +381,10 @@
bus_space_tag_t sc_st;
bus_space_handle_t sc_sh;
+ enum iwm_intr_type sc_intr_type;
+#ifdef __HAVE_PCI_MSI_MSIX
+ pci_intr_handle_t *sc_pihp;
+#endif
bus_size_t sc_sz;
bus_dma_tag_t sc_dmat;
Home |
Main Index |
Thread Index |
Old Index