diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-08-17 01:02:32 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-08-17 01:02:32 +0000 |
commit | 97193ecbd5404e9e154c9971e3fc47c98a356af8 (patch) | |
tree | 99efacd7c49258dd1a0495e5ece3fbca1eaf1551 /sys/dev | |
parent | dd65dc24739e11c6f268e736e1cec66347422ba2 (diff) |
Make error handling (esp. DATA_UNDERRUN) clearer and avoid losing resid
value.
Specs from mikeb@, ok dlg@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ic/mpi.c | 15 | ||||
-rw-r--r-- | sys/dev/pci/mpii.c | 28 |
2 files changed, 18 insertions, 25 deletions
diff --git a/sys/dev/ic/mpi.c b/sys/dev/ic/mpi.c index 3689881f254..1234a88f546 100644 --- a/sys/dev/ic/mpi.c +++ b/sys/dev/ic/mpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpi.c,v 1.204 2016/08/14 04:08:03 dlg Exp $ */ +/* $OpenBSD: mpi.c,v 1.205 2016/08/17 01:02:31 krw Exp $ */ /* * Copyright (c) 2005, 2006, 2009 David Gwynne <dlg@openbsd.org> @@ -1449,20 +1449,21 @@ mpi_scsi_cmd_done(struct mpi_ccb *ccb) DNPRINTF(MPI_D_CMD, "%s: tag: 0x%04x\n", DEVNAME(sc), letoh16(sie->tag)); - xs->status = sie->scsi_status; + if (sie->scsi_state & MPI_SCSIIO_ERR_STATE_NO_SCSI_STATUS) + xs->status = SCSI_TERMINATED; + else + xs->status = sie->scsi_status; + xs->resid = 0; + switch (lemtoh16(&sie->ioc_status)) { case MPI_IOCSTATUS_SCSI_DATA_UNDERRUN: xs->resid = xs->datalen - lemtoh32(&sie->transfer_count); - if (sie->scsi_state & MPI_SCSIIO_ERR_STATE_NO_SCSI_STATUS) { - xs->error = XS_DRIVER_STUFFUP; - break; - } /* FALLTHROUGH */ case MPI_IOCSTATUS_SUCCESS: case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR: switch (xs->status) { case SCSI_OK: - xs->resid = 0; + xs->error = XS_NOERROR; break; case SCSI_CHECK: diff --git a/sys/dev/pci/mpii.c b/sys/dev/pci/mpii.c index b6d010dfe88..7e21bd69f21 100644 --- a/sys/dev/pci/mpii.c +++ b/sys/dev/pci/mpii.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpii.c,v 1.103 2016/08/09 15:04:34 krw Exp $ */ +/* $OpenBSD: mpii.c,v 1.104 2016/08/17 01:02:31 krw Exp $ */ /* * Copyright (c) 2010, 2012 Mike Belopuhov * Copyright (c) 2009 James Giannoules @@ -2918,30 +2918,22 @@ mpii_scsi_cmd_done(struct mpii_ccb *ccb) DNPRINTF(MPII_D_CMD, "%s: bidirectional_transfer_count: 0x%08x\n", DEVNAME(sc), letoh32(sie->bidirectional_transfer_count)); - xs->status = sie->scsi_status; + if (sie->scsi_state & MPII_SCSIIO_ERR_STATE_NO_SCSI_STATUS) + xs->status = SCSI_TERMINATED; + else + xs->status = sie->scsi_status; + xs->resid = 0; + switch (lemtoh16(&sie->ioc_status) & MPII_IOCSTATUS_MASK) { case MPII_IOCSTATUS_SCSI_DATA_UNDERRUN: - switch (xs->status) { - case SCSI_OK: - xs->resid = xs->datalen - - lemtoh32(&sie->transfer_count); - break; - - case SCSI_CHECK: - xs->error = XS_SENSE; - break; - - default: - xs->error = XS_DRIVER_STUFFUP; - break; - } - break; + xs->resid = xs->datalen - lemtoh32(&sie->transfer_count); + /* FALLTHROUGH */ case MPII_IOCSTATUS_SUCCESS: case MPII_IOCSTATUS_SCSI_RECOVERED_ERROR: switch (xs->status) { case SCSI_OK: - xs->resid = 0; + xs->error = XS_NOERROR; break; case SCSI_CHECK: |