Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F139526222
D9243.id24192.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D9243.id24192.diff
View Options
Index: sys/dev/mpr/mpr.c
===================================================================
--- sys/dev/mpr/mpr.c
+++ sys/dev/mpr/mpr.c
@@ -1363,7 +1363,7 @@
* Next are the global settings, if they exist. Highest are the per-unit
* settings, if they exist.
*/
-static void
+void
mpr_get_tunables(struct mpr_softc *sc)
{
char tmpstr[80];
@@ -1527,8 +1527,6 @@
{
int error;
- mpr_get_tunables(sc);
-
MPR_FUNCTRACE(sc);
mtx_init(&sc->mpr_mtx, "MPR lock", NULL, MTX_DEF);
Index: sys/dev/mpr/mpr_pci.c
===================================================================
--- sys/dev/mpr/mpr_pci.c
+++ sys/dev/mpr/mpr_pci.c
@@ -68,6 +68,7 @@
static void mpr_pci_free(struct mpr_softc *);
static int mpr_alloc_msix(struct mpr_softc *sc, int msgs);
static int mpr_alloc_msi(struct mpr_softc *sc, int msgs);
+static int mpr_pci_alloc_interrupts(struct mpr_softc *sc);
static device_method_t mpr_methods[] = {
DEVMETHOD(device_probe, mpr_pci_probe),
@@ -172,6 +173,8 @@
m = mpr_find_ident(dev);
sc->mpr_flags = m->flags;
+ mpr_get_tunables(sc);
+
/* Twiddle basic PCI config bits for a sanity check */
pci_enable_busmaster(dev);
@@ -202,28 +205,51 @@
return (ENOMEM);
}
- if ((error = mpr_attach(sc)) != 0)
+ if (((error = mpr_pci_alloc_interrupts(sc)) != 0) ||
+ ((error = mpr_attach(sc)) != 0))
mpr_pci_free(sc);
return (error);
}
+/*
+ * Allocate, but don't assign interrupts early. Doing it before requesting
+ * the IOCFacts message informs the firmware that we want to do MSI-X
+ * multiqueue. We might not use all of the available messages, but there's
+ * no reason to re-alloc if we don't.
+ */
int
-mpr_pci_setup_interrupts(struct mpr_softc *sc)
+mpr_pci_alloc_interrupts(struct mpr_softc *sc)
{
device_t dev;
- int i, error, msgs;
+ int error, msgs;
dev = sc->mpr_dev;
- error = ENXIO;
+ error = 0;
+
if ((sc->disable_msix == 0) &&
((msgs = pci_msix_count(dev)) >= MPR_MSI_COUNT))
error = mpr_alloc_msix(sc, MPR_MSI_COUNT);
if ((error != 0) && (sc->disable_msi == 0) &&
((msgs = pci_msi_count(dev)) >= MPR_MSI_COUNT))
error = mpr_alloc_msi(sc, MPR_MSI_COUNT);
+ else
+ sc->msi_msgs = 0;
+
+ sc->msi_msgs = msgs;
+ return (error);
+}
+
+int
+mpr_pci_setup_interrupts(struct mpr_softc *sc)
+{
+ device_t dev;
+ int i, error;
+
+ dev = sc->mpr_dev;
+ error = ENXIO;
- if (error != 0) {
+ if (sc->msi_msgs == 0) {
sc->mpr_flags |= MPR_FLAGS_INTX;
sc->mpr_irq_rid[0] = 0;
sc->mpr_irq[0] = bus_alloc_resource_any(dev, SYS_RES_IRQ,
Index: sys/dev/mpr/mprvar.h
===================================================================
--- sys/dev/mpr/mprvar.h
+++ sys/dev/mpr/mprvar.h
@@ -260,6 +260,7 @@
u_int mpr_debug;
u_int disable_msix;
u_int disable_msi;
+ int msi_msgs;
int tm_cmds_active;
int io_cmds_active;
int io_cmds_highwater;
@@ -643,6 +644,7 @@
int mpr_pci_setup_interrupts(struct mpr_softc *sc);
int mpr_pci_restore(struct mpr_softc *sc);
+void mpr_get_tunables(struct mpr_softc *sc);
int mpr_attach(struct mpr_softc *sc);
int mpr_free(struct mpr_softc *sc);
void mpr_intr(void *);
Index: sys/dev/mps/mps.c
===================================================================
--- sys/dev/mps/mps.c
+++ sys/dev/mps/mps.c
@@ -1340,7 +1340,7 @@
* Next are the global settings, if they exist. Highest are the per-unit
* settings, if they exist.
*/
-static void
+void
mps_get_tunables(struct mps_softc *sc)
{
char tmpstr[80];
@@ -1512,8 +1512,6 @@
{
int error;
- mps_get_tunables(sc);
-
MPS_FUNCTRACE(sc);
mtx_init(&sc->mps_mtx, "MPT2SAS lock", NULL, MTX_DEF);
Index: sys/dev/mps/mps_pci.c
===================================================================
--- sys/dev/mps/mps_pci.c
+++ sys/dev/mps/mps_pci.c
@@ -68,6 +68,7 @@
static void mps_pci_free(struct mps_softc *);
static int mps_alloc_msix(struct mps_softc *sc, int msgs);
static int mps_alloc_msi(struct mps_softc *sc, int msgs);
+static int mps_pci_alloc_interrupts(struct mps_softc *sc);
static device_method_t mps_methods[] = {
DEVMETHOD(device_probe, mps_pci_probe),
@@ -191,6 +192,8 @@
m = mps_find_ident(dev);
sc->mps_flags = m->flags;
+ mps_get_tunables(sc);
+
/* Twiddle basic PCI config bits for a sanity check */
pci_enable_busmaster(dev);
@@ -221,28 +224,51 @@
return (ENOMEM);
}
- if ((error = mps_attach(sc)) != 0)
+ if (((error = mps_pci_alloc_interrupts(sc)) != 0) ||
+ ((error = mps_attach(sc)) != 0))
mps_pci_free(sc);
return (error);
}
-int
-mps_pci_setup_interrupts(struct mps_softc *sc)
+/*
+ * Allocate, but don't assign interrupts early. Doing it before requesting
+ * the IOCFacts message informs the firmware that we want to do MSI-X
+ * multiqueue. We might not use all of the available messages, but there's
+ * no reason to re-alloc if we don't.
+ */
+static int
+mps_pci_alloc_interrupts(struct mps_softc *sc)
{
device_t dev;
- int i, error, msgs;
+ int error, msgs;
dev = sc->mps_dev;
- error = ENXIO;
+ error = 0;
+
if ((sc->disable_msix == 0) &&
((msgs = pci_msix_count(dev)) >= MPS_MSI_COUNT))
error = mps_alloc_msix(sc, MPS_MSI_COUNT);
if ((error != 0) && (sc->disable_msi == 0) &&
((msgs = pci_msi_count(dev)) >= MPS_MSI_COUNT))
error = mps_alloc_msi(sc, MPS_MSI_COUNT);
+ else
+ sc->msi_msgs = 0;
+
+ sc->msi_msgs = msgs;
+ return (error);
+}
+
+int
+mps_pci_setup_interrupts(struct mps_softc *sc)
+{
+ device_t dev;
+ int i, error;
+
+ dev = sc->mps_dev;
+ error = ENXIO;
- if (error != 0) {
+ if (sc->msi_msgs == 0) {
sc->mps_flags |= MPS_FLAGS_INTX;
sc->mps_irq_rid[0] = 0;
sc->mps_irq[0] = bus_alloc_resource_any(dev, SYS_RES_IRQ,
Index: sys/dev/mps/mpsvar.h
===================================================================
--- sys/dev/mps/mpsvar.h
+++ sys/dev/mps/mpsvar.h
@@ -276,6 +276,7 @@
u_int mps_debug;
u_int disable_msix;
u_int disable_msi;
+ u_int msi_msgs;
int tm_cmds_active;
int io_cmds_active;
int io_cmds_highwater;
@@ -675,6 +676,7 @@
int mps_pci_setup_interrupts(struct mps_softc *sc);
int mps_pci_restore(struct mps_softc *sc);
+void mps_get_tunables(struct mps_softc *sc);
int mps_attach(struct mps_softc *sc);
int mps_free(struct mps_softc *sc);
void mps_intr(void *);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 14, 2:24 AM (1 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26948732
Default Alt Text
D9243.id24192.diff (6 KB)
Attached To
Mode
D9243: Refactor MPR/MPS interrupt setup code.
Attached
Detach File
Event Timeline
Log In to Comment