Module Name: src
Committed By: martin
Date: Fri Mar 15 14:50:36 UTC 2019
Modified Files:
src/sys/dev/pci [netbsd-8]: mpii.c
Log Message:
Pull up following revision(s) (requested by kardel in ticket #1217):
sys/dev/pci/mpii.c: revision 1.22
PR/54045
fix mpii to adhere to physio diagnostic invariant that
fully processed data must not post an error:
1) verify expected scspi state via KASSERT() instead of just
setting the variables.
2) set xs->resid only in known good conditions
3) insure setting errors in all error paths and refrain
from clearing xs->resid in error paths.
While there do some cosmectic clean up:
1) extend and relocate some debug output
2) mpii HBAs can also manage non-disk devices like tapes etc,
so log that physical "devices" instead of physical "disks" are
attached or detached.
Tested with NEOSeries FlexStor II and luckily a broken tape drive 8-(
mpii0 at pci1 dev 0 function 0: vendor 1000 product 00ab (rev. 0x01)
mpii0: interrupting at irq 11
mpii0: HBA 9400-8i8e, firmware 3.0.4.0, MPI 2.6
mpii0: physical device inserted in slot 9
mpii0: physical device inserted in slot 13
mpii0: physical device inserted in slot 16
st0 at scsibus0 target 9 lun 0: <IBM, ULTRIUM-HH7, J4D1> tape removable
st0: density code 92, variable blocks, write-enabled
ch0 at scsibus0 target 9 lun 1: <BDT, FlexStor II, 5.50> changer removable
ch0: 23 slots, 2 drives, 1 picker, 1 portal
st0: tagged queueing
ch0: tagged queueing
st1 at scsibus0 target 13 lun 0: <IBM, ULTRIUM-HH7, J4D1> tape removable
st1: density code 92, variable blocks, write-enabled
st1: tagged queueing
ses0 at scsibus0 target 16 lun 0: <LSI, VirtualSES, 01> enclosure
services fixed
Note: pullup-8
To generate a diff of this commit:
cvs rdiff -u -r1.8.10.4 -r1.8.10.5 src/sys/dev/pci/mpii.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/mpii.c
diff -u src/sys/dev/pci/mpii.c:1.8.10.4 src/sys/dev/pci/mpii.c:1.8.10.5
--- src/sys/dev/pci/mpii.c:1.8.10.4 Mon Jan 7 13:49:39 2019
+++ src/sys/dev/pci/mpii.c Fri Mar 15 14:50:36 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: mpii.c,v 1.8.10.4 2019/01/07 13:49:39 martin Exp $ */
+/* $NetBSD: mpii.c,v 1.8.10.5 2019/03/15 14:50:36 martin Exp $ */
/* OpenBSD: mpii.c,v 1.115 2012/04/11 13:29:14 naddy Exp */
/*
* Copyright (c) 2010 Mike Belopuhov <[email protected]>
@@ -20,7 +20,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.8.10.4 2019/01/07 13:49:39 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.8.10.5 2019/03/15 14:50:36 martin Exp $");
#include "bio.h"
@@ -1920,7 +1920,7 @@ mpii_event_sas(struct mpii_softc *sc, st
free(dev, M_DEVBUF);
break;
}
- printf("%s: physical disk inserted in slot %d\n",
+ printf("%s: physical device inserted in slot %d\n",
DEVNAME(sc), dev->slot);
mutex_exit(&sc->sc_devs_mtx);
break;
@@ -1994,7 +1994,7 @@ mpii_event_sas_work(struct work *wq, voi
}
printf(
- "%s: physical disk removed from slot %d\n",
+ "%s: physical device removed from slot %d\n",
DEVNAME(sc), dev->slot);
mpii_remove_dev(sc, dev);
mutex_exit(&sc->sc_devs_mtx);
@@ -3021,8 +3021,8 @@ mpii_scsipi_request(struct scsipi_channe
scsipi_done(xs);
return;
}
- DNPRINTF(MPII_D_CMD, "%s: ccb_smid: %d xs->xs_control: 0x%x\n",
- DEVNAME(sc), ccb->ccb_smid, xs->xs_control);
+ DNPRINTF(MPII_D_CMD, "%s: ccb_smid: %d xs->cmd->opcode: 0x%02x xs->xs_control: 0x%x\n",
+ DEVNAME(sc), ccb->ccb_smid, xs->cmd->opcode, xs->xs_control);
ccb->ccb_cookie = xs;
ccb->ccb_done = mpii_scsi_cmd_done;
@@ -3220,13 +3220,14 @@ mpii_scsi_cmd_done(struct mpii_ccb *ccb)
bus_dmamap_unload(sc->sc_dmat, dmap);
}
-
- xs->error = XS_NOERROR;
- xs->resid = 0;
-
+
+ KASSERT(xs->error == XS_NOERROR);
+ KASSERT(xs->resid == xs->datalen);
+ KASSERT(xs->status == SCSI_OK);
+
if (ccb->ccb_rcb == NULL) {
/* no scsi error, we're ok so drop out early */
- xs->status = SCSI_OK;
+ xs->resid = 0;
goto done;
}
@@ -3276,9 +3277,11 @@ mpii_scsi_cmd_done(struct mpii_ccb *ccb)
case MPII_IOCSTATUS_SCSI_RECOVERED_ERROR:
switch (sie->scsi_status) {
case MPII_SCSIIO_STATUS_GOOD:
+ xs->resid = 0;
break;
case MPII_SCSIIO_STATUS_CHECK_COND:
+ xs->resid = 0;
xs->error = XS_SENSE;
break;
@@ -3317,12 +3320,14 @@ mpii_scsi_cmd_done(struct mpii_ccb *ccb)
if (sie->scsi_state & MPII_SCSIIO_STATE_AUTOSENSE_VALID)
memcpy(&xs->sense, sense, sizeof(xs->sense));
- DNPRINTF(MPII_D_CMD, "%s: xs err: %d status: %#x\n", DEVNAME(sc),
- xs->error, xs->status);
-
mpii_push_reply(sc, ccb->ccb_rcb);
-done:
+
+ done:
mpii_put_ccb(sc, ccb);
+
+ DNPRINTF(MPII_D_CMD, "%s: xs err: %d status: %#x len: %d resid: %d\n",
+ DEVNAME(sc), xs->error, xs->status, xs->datalen, xs->resid);
+
scsipi_done(xs);
}