...and some mpsafety in the scsi_cmd path.
this is working well for me, but considering how used it is i would
appreciate some extra tests.
ok?
Index: pci/mfi_pci.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/mfi_pci.c,v
retrieving revision 1.28
diff -u -p -r1.28 mfi_pci.c
--- pci/mfi_pci.c 14 Aug 2012 04:10:14 -0000 1.28
+++ pci/mfi_pci.c 8 Sep 2014 04:47:03 -0000
@@ -133,8 +133,8 @@ mfi_pci_attach(struct device *parent, st
}
printf(": %s\n", pci_intr_string(pa->pa_pc, ih));
- sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, mfi_intr, sc,
- sc->sc_dev.dv_xname);
+ sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO | IPL_MPSAFE,
+ mfi_intr, sc, sc->sc_dev.dv_xname);
if (!sc->sc_ih) {
printf("%s: can't establish interrupt\n", DEVNAME(sc));
goto unmap;
Index: ic/mfi.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/mfi.c,v
retrieving revision 1.155
diff -u -p -r1.155 mfi.c
--- ic/mfi.c 15 Aug 2014 02:27:02 -0000 1.155
+++ ic/mfi.c 8 Sep 2014 04:47:03 -0000
@@ -199,6 +199,8 @@ mfi_get_ccb(void *cookie)
struct mfi_softc *sc = cookie;
struct mfi_ccb *ccb;
+ KERNEL_UNLOCK();
+
mtx_enter(&sc->sc_ccb_mtx);
ccb = SLIST_FIRST(&sc->sc_ccb_freeq);
if (ccb != NULL) {
@@ -208,6 +210,7 @@ mfi_get_ccb(void *cookie)
mtx_leave(&sc->sc_ccb_mtx);
DNPRINTF(MFI_D_CCB, "%s: mfi_get_ccb: %p\n", DEVNAME(sc), ccb);
+ KERNEL_LOCK();
return (ccb);
}
@@ -220,9 +223,11 @@ mfi_put_ccb(void *cookie, void *io)
DNPRINTF(MFI_D_CCB, "%s: mfi_put_ccb: %p\n", DEVNAME(sc), ccb);
+ KERNEL_UNLOCK();
mtx_enter(&sc->sc_ccb_mtx);
SLIST_INSERT_HEAD(&sc->sc_ccb_freeq, ccb, ccb_link);
mtx_leave(&sc->sc_ccb_mtx);
+ KERNEL_LOCK();
}
void
@@ -1108,7 +1113,9 @@ mfi_scsi_xs_done(struct mfi_softc *sc, s
break;
}
+ KERNEL_LOCK();
scsi_done(xs);
+ KERNEL_UNLOCK();
}
int
@@ -1174,6 +1181,8 @@ mfi_scsi_cmd(struct scsi_xfer *xs)
DNPRINTF(MFI_D_CMD, "%s: mfi_scsi_cmd opcode: %#x\n",
DEVNAME(sc), xs->cmd->opcode);
+ KERNEL_UNLOCK();
+
if (!sc->sc_ld[target].ld_present) {
DNPRINTF(MFI_D_CMD, "%s: invalid target %d\n",
DEVNAME(sc), target);
@@ -1236,11 +1245,13 @@ mfi_scsi_cmd(struct scsi_xfer *xs)
else
mfi_start(sc, ccb);
+ KERNEL_LOCK();
return;
stuffup:
xs->error = XS_DRIVER_STUFFUP;
complete:
+ KERNEL_LOCK();
scsi_done(xs);
}
@@ -2492,6 +2503,8 @@ mfi_pd_scsi_cmd(struct scsi_xfer *xs)
struct mfi_pass_frame *pf = &ccb->ccb_frame->mfr_pass;
struct mfi_pd_link *pl = sc->sc_pd->pd_links[link->target];
+ KERNEL_UNLOCK();
+
mfi_scrub_ccb(ccb);
xs->error = XS_NOERROR;
@@ -2532,9 +2545,11 @@ mfi_pd_scsi_cmd(struct scsi_xfer *xs)
else
mfi_start(sc, ccb);
+ KERNEL_LOCK();
return;
stuffup:
xs->error = XS_DRIVER_STUFFUP;
+ KERNEL_LOCK();
scsi_done(xs);
}