aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mpr/mpr.c
diff options
context:
space:
mode:
authorScott Long <scottl@FreeBSD.org>2017-09-10 04:09:18 +0000
committerScott Long <scottl@FreeBSD.org>2017-09-10 04:09:18 +0000
commit1415db6ca214c2d14ab73a552d8d3509691f8231 (patch)
treea987ddec3fc6c11804854595071580a36bdd0573 /sys/dev/mpr/mpr.c
parentf47cbbee8aec2cdeabb23853606b81a5429abd95 (diff)
downloadsrc-1415db6ca214c2d14ab73a552d8d3509691f8231.tar.gz
src-1415db6ca214c2d14ab73a552d8d3509691f8231.zip
More code refactoring in preparation for enabling multiqueue.
Sponsored by: Netflix
Notes
Notes: svn path=/head/; revision=323383
Diffstat (limited to 'sys/dev/mpr/mpr.c')
-rw-r--r--sys/dev/mpr/mpr.c98
1 files changed, 54 insertions, 44 deletions
diff --git a/sys/dev/mpr/mpr.c b/sys/dev/mpr/mpr.c
index aada1738771b..0d83b4a2becd 100644
--- a/sys/dev/mpr/mpr.c
+++ b/sys/dev/mpr/mpr.c
@@ -89,6 +89,7 @@ static void mpr_iocfacts_free(struct mpr_softc *sc);
static void mpr_startup(void *arg);
static int mpr_send_iocinit(struct mpr_softc *sc);
static int mpr_alloc_queues(struct mpr_softc *sc);
+static int mpr_alloc_hw_queues(struct mpr_softc *sc);
static int mpr_alloc_replies(struct mpr_softc *sc);
static int mpr_alloc_requests(struct mpr_softc *sc);
static int mpr_alloc_nvme_prp_pages(struct mpr_softc *sc);
@@ -565,21 +566,23 @@ mpr_iocfacts_allocate(struct mpr_softc *sc, uint8_t attaching)
* IOC Facts are different from the previous IOC Facts after a Diag
* Reset. Targets have already been allocated above if needed.
*/
- if (attaching || reallocating) {
- if (((error = mpr_alloc_queues(sc)) != 0) ||
- ((error = mpr_alloc_replies(sc)) != 0) ||
- ((error = mpr_alloc_requests(sc)) != 0)) {
- if (attaching ) {
- mpr_dprint(sc, MPR_INIT|MPR_ERROR,
- "Failed to alloc queues with error %d\n",
- error);
- mpr_free(sc);
- return (error);
- } else {
- panic("%s failed to alloc queues with error "
- "%d\n", __func__, error);
- }
- }
+ error = 0;
+ while (attaching || reallocating) {
+ if ((error = mpr_alloc_hw_queues(sc)) != 0)
+ break;
+ if ((error = mpr_alloc_replies(sc)) != 0)
+ break;
+ if ((error = mpr_alloc_requests(sc)) != 0)
+ break;
+ if ((error = mpr_alloc_queues(sc)) != 0)
+ break;
+ break;
+ }
+ if (error) {
+ mpr_dprint(sc, MPR_INIT|MPR_ERROR,
+ "Failed to alloc queues with error %d\n", error);
+ mpr_free(sc);
+ return (error);
}
/* Always initialize the queues */
@@ -593,15 +596,10 @@ mpr_iocfacts_allocate(struct mpr_softc *sc, uint8_t attaching)
*/
error = mpr_transition_operational(sc);
if (error != 0) {
- if (attaching) {
- mpr_dprint(sc, MPR_INIT|MPR_FAULT, "Failed to "
- "transition to operational with error %d\n", error);
- mpr_free(sc);
- return (error);
- } else {
- panic("%s failed to transition to operational with "
- "error %d\n", __func__, error);
- }
+ mpr_dprint(sc, MPR_INIT|MPR_FAULT, "Failed to "
+ "transition to operational with error %d\n", error);
+ mpr_free(sc);
+ return (error);
}
/*
@@ -620,26 +618,31 @@ mpr_iocfacts_allocate(struct mpr_softc *sc, uint8_t attaching)
/*
* Attach the subsystems so they can prepare their event masks.
+ * XXX Should be dynamic so that IM/IR and user modules can attach
*/
- /* XXX Should be dynamic so that IM/IR and user modules can attach */
- if (attaching) {
+ error = 0;
+ while (attaching) {
mpr_dprint(sc, MPR_INIT, "Attaching subsystems\n");
- if (((error = mpr_attach_log(sc)) != 0) ||
- ((error = mpr_attach_sas(sc)) != 0) ||
- ((error = mpr_attach_user(sc)) != 0)) {
- mpr_dprint(sc, MPR_INIT|MPR_ERROR,
- "Failed to attach all subsystems: error %d\n",
- error);
- mpr_free(sc);
- return (error);
- }
+ if ((error = mpr_attach_log(sc)) != 0)
+ break;
+ if ((error = mpr_attach_sas(sc)) != 0)
+ break;
+ if ((error = mpr_attach_user(sc)) != 0)
+ break;
+ break;
+ }
+ if (error) {
+ mpr_dprint(sc, MPR_INIT|MPR_ERROR,
+ "Failed to attach all subsystems: error %d\n", error);
+ mpr_free(sc);
+ return (error);
+ }
- if ((error = mpr_pci_setup_interrupts(sc)) != 0) {
- mpr_dprint(sc, MPR_INIT|MPR_ERROR,
- "Failed to setup interrupts\n");
- mpr_free(sc);
- return (error);
- }
+ if ((error = mpr_pci_setup_interrupts(sc)) != 0) {
+ mpr_dprint(sc, MPR_INIT|MPR_ERROR,
+ "Failed to setup interrupts\n");
+ mpr_free(sc);
+ return (error);
}
return (error);
@@ -1140,10 +1143,8 @@ mpr_memaddr_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
static int
mpr_alloc_queues(struct mpr_softc *sc)
{
- bus_addr_t queues_busaddr;
struct mpr_queue *q;
- uint8_t *queues;
- int qsize, fqsize, pqsize, nq, i;
+ int nq, i;
nq = MIN(sc->msi_msgs, mp_ncpus);
sc->msi_msgs = nq;
@@ -1159,6 +1160,15 @@ mpr_alloc_queues(struct mpr_softc *sc)
q->sc = sc;
q->qnum = i;
}
+ return (0);
+}
+
+static int
+mpr_alloc_hw_queues(struct mpr_softc *sc)
+{
+ bus_addr_t queues_busaddr;
+ uint8_t *queues;
+ int qsize, fqsize, pqsize;
/*
* The reply free queue contains 4 byte entries in multiples of 16 and