Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci PR/54045



details:   https://anonhg.NetBSD.org/src/rev/cdeb22c1d4c6
branches:  trunk
changeset: 449577:cdeb22c1d4c6
user:      kardel <kardel%NetBSD.org@localhost>
date:      Mon Mar 11 14:35:22 2019 +0000

description:
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

diffstat:

 sys/dev/pci/mpii.c |  35 ++++++++++++++++++++---------------
 1 files changed, 20 insertions(+), 15 deletions(-)

diffs (98 lines):

diff -r f157af4142bf -r cdeb22c1d4c6 sys/dev/pci/mpii.c
--- a/sys/dev/pci/mpii.c        Mon Mar 11 09:20:13 2019 +0000
+++ b/sys/dev/pci/mpii.c        Mon Mar 11 14:35:22 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mpii.c,v 1.21 2019/02/03 03:19:27 mrg Exp $ */
+/* $NetBSD: mpii.c,v 1.22 2019/03/11 14:35:22 kardel Exp $ */
 /*     $OpenBSD: mpii.c,v 1.115 2018/08/14 05:22:21 jmatthew Exp $     */
 /*
  * Copyright (c) 2010, 2012 Mike Belopuhov
@@ -20,7 +20,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.21 2019/02/03 03:19:27 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.22 2019/03/11 14:35:22 kardel Exp $");
 
 #include "bio.h"
 
@@ -1921,7 +1921,7 @@
                                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;
@@ -1995,7 +1995,7 @@
                                }
 
                                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);
@@ -3022,8 +3022,8 @@
                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;
@@ -3221,13 +3221,14 @@
 
                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;
        }
 
@@ -3278,9 +3279,11 @@
        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;
 
@@ -3319,12 +3322,14 @@
        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);
 }
 



Home | Main Index | Thread Index | Old Index