From 4e0df4f6b25d41e299fe341a87904f8a2925b588 Mon Sep 17 00:00:00 2001 From: jakllsch Date: Mon, 14 Dec 2015 20:01:17 +0000 Subject: Switch PCI re(4) attachment from pci_intr_map() to pci_intr_alloc()/pci_intr_release(). This enables MSI where available. --- sys/dev/pci/if_re_pci.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/pci/if_re_pci.c b/sys/dev/pci/if_re_pci.c index bdb42f01a9c..fd002447889 100644 --- a/sys/dev/pci/if_re_pci.c +++ b/sys/dev/pci/if_re_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_re_pci.c,v 1.44 2015/05/03 00:04:06 matt Exp $ */ +/* $NetBSD: if_re_pci.c,v 1.45 2015/12/14 20:01:17 jakllsch Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -46,7 +46,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_re_pci.c,v 1.44 2015/05/03 00:04:06 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_re_pci.c,v 1.45 2015/12/14 20:01:17 jakllsch Exp $"); #include @@ -75,6 +75,7 @@ struct re_pci_softc { struct rtk_softc sc_rtk; void *sc_ih; + pci_intr_handle_t *sc_pihp; pci_chipset_tag_t sc_pc; }; @@ -174,7 +175,6 @@ re_pci_attach(device_t parent, device_t self, void *aux) struct rtk_softc *sc = &psc->sc_rtk; struct pci_attach_args *pa = aux; pci_chipset_tag_t pc = pa->pa_pc; - pci_intr_handle_t ih; const char *intrstr = NULL; const struct rtk_type *t; uint32_t hwrev; @@ -253,12 +253,14 @@ re_pci_attach(device_t parent, device_t self, void *aux) /* Hook interrupt last to avoid having to lock softc */ /* Allocate interrupt */ - if (pci_intr_map(pa, &ih)) { + if (pci_intr_alloc(pa, &psc->sc_pihp, NULL, 0)) { aprint_error_dev(self, "couldn't map interrupt\n"); return; } - intrstr = pci_intr_string(pc, ih, intrbuf, sizeof(intrbuf)); - psc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, re_intr, sc); + intrstr = pci_intr_string(pc, psc->sc_pihp[0], intrbuf, + sizeof(intrbuf)); + psc->sc_ih = pci_intr_establish(pc, psc->sc_pihp[0], IPL_NET, + re_intr, sc); if (psc->sc_ih == NULL) { aprint_error_dev(self, "couldn't establish interrupt"); if (intrstr != NULL) @@ -305,6 +307,11 @@ re_pci_detach(device_t self, int flags) psc->sc_ih = NULL; } + if (psc->sc_pihp != NULL) { + pci_intr_release(psc->sc_pc, psc->sc_pihp, 1); + psc->sc_pihp = NULL; + } + if (sc->rtk_bsize != 0) { bus_space_unmap(sc->rtk_btag, sc->rtk_bhandle, sc->rtk_bsize); sc->rtk_bsize = 0; -- cgit