Module Name: src Committed By: nonaka Date: Sat Sep 5 04:56:53 UTC 2015
Modified Files: src/sys/dev/pci: rtsx_pci.c Log Message: Use MSI/MSI-X instead of legacy INTx, if available. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/rtsx_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/rtsx_pci.c diff -u src/sys/dev/pci/rtsx_pci.c:1.3 src/sys/dev/pci/rtsx_pci.c:1.4 --- src/sys/dev/pci/rtsx_pci.c:1.3 Wed Oct 29 14:24:09 2014 +++ src/sys/dev/pci/rtsx_pci.c Sat Sep 5 04:56:53 2015 @@ -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_pci_softc { 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 @@ rtsx_pci_attach(device_t parent, device_ 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 @@ rtsx_pci_attach(device_t parent, device_ 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 @@ rtsx_pci_detach(device_t self, int flags 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; }