From 51d4c641cfce8b5a1a89cd4eff50c79bc0b268f2 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Thu, 5 Jan 2012 00:29:38 +0100 Subject: [PATCH] mfi(4): Use MSI if it is supported by the device. --- sys/dev/raid/mfi/mfi.c | 13 +++++++++++-- sys/dev/raid/mfi/mfivar.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sys/dev/raid/mfi/mfi.c b/sys/dev/raid/mfi/mfi.c index 85e3728bf9..03e435f9f7 100644 --- a/sys/dev/raid/mfi/mfi.c +++ b/sys/dev/raid/mfi/mfi.c @@ -103,6 +103,8 @@ #include +#include + #include #include #include @@ -168,6 +170,9 @@ TUNABLE_INT("hw.mfi.max_cmds", &mfi_max_cmds); SYSCTL_INT(_hw_mfi, OID_AUTO, max_cmds, CTLFLAG_RD, &mfi_max_cmds, 0, "Max commands"); +static int mfi_msi_enable = 1; +TUNABLE_INT("hw.mfi.msi.enable", &mfi_msi_enable); + /* Management interface */ static d_open_t mfi_open; static d_close_t mfi_close; @@ -371,6 +376,7 @@ mfi_attach(struct mfi_softc *sc) uint32_t status; int error, commsz, framessz, sensesz; int frames, unit, max_fw_sge; + u_int irq_flags; device_printf(sc->mfi_dev, "Megaraid SAS driver Ver 3.981\n"); @@ -571,8 +577,10 @@ mfi_attach(struct mfi_softc *sc) * mfi_pci.c */ sc->mfi_irq_rid = 0; + sc->mfi_irq_type = pci_alloc_1intr(sc->mfi_dev, mfi_msi_enable, + &sc->mfi_irq_rid, &irq_flags); if ((sc->mfi_irq = bus_alloc_resource_any(sc->mfi_dev, SYS_RES_IRQ, - &sc->mfi_irq_rid, RF_SHAREABLE | RF_ACTIVE)) == NULL) { + &sc->mfi_irq_rid, irq_flags)) == NULL) { device_printf(sc->mfi_dev, "Cannot allocate interrupt\n"); return (EINVAL); } @@ -971,7 +979,8 @@ mfi_free(struct mfi_softc *sc) if (sc->mfi_irq != NULL) bus_release_resource(sc->mfi_dev, SYS_RES_IRQ, sc->mfi_irq_rid, sc->mfi_irq); - + if (sc->mfi_irq_type == PCI_INTR_TYPE_MSI) + pci_release_msi(sc->mfi_dev); if (sc->mfi_sense_busaddr != 0) bus_dmamap_unload(sc->mfi_sense_dmat, sc->mfi_sense_dmamap); if (sc->mfi_sense != NULL) diff --git a/sys/dev/raid/mfi/mfivar.h b/sys/dev/raid/mfi/mfivar.h index 36664d5eaf..478700b494 100644 --- a/sys/dev/raid/mfi/mfivar.h +++ b/sys/dev/raid/mfi/mfivar.h @@ -240,6 +240,7 @@ struct mfi_softc { struct resource *mfi_irq; void *mfi_intr; int mfi_irq_rid; + int mfi_irq_type; struct intr_config_hook mfi_ich; eventhandler_tag eh; -- 2.11.4.GIT