Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Clean up timeout logic. Now the system survives ...



details:   https://anonhg.NetBSD.org/src/rev/17261ca3f5bf
branches:  trunk
changeset: 998615:17261ca3f5bf
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Wed Apr 24 09:21:01 2019 +0000

description:
Clean up timeout logic. Now the system survives to a ccb timeout; before
the filesystem would stall because one I/O did never completes.

diffstat:

 sys/dev/pci/mfii.c |  36 +++++++++++++-----------------------
 1 files changed, 13 insertions(+), 23 deletions(-)

diffs (108 lines):

diff -r 43de8485afae -r 17261ca3f5bf sys/dev/pci/mfii.c
--- a/sys/dev/pci/mfii.c        Wed Apr 24 08:54:35 2019 +0000
+++ b/sys/dev/pci/mfii.c        Wed Apr 24 09:21:01 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mfii.c,v 1.3 2018/12/03 22:34:36 bouyer Exp $ */
+/* $NetBSD: mfii.c,v 1.4 2019/04/24 09:21:01 bouyer Exp $ */
 /* $OpenBSD: mfii.c,v 1.58 2018/08/14 05:22:21 jmatthew Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.3 2018/12/03 22:34:36 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.4 2019/04/24 09:21:01 bouyer Exp $");
 
 #include "bio.h"
 
@@ -265,7 +265,6 @@
        u_int32_t               ccb_flags;
 #define MFI_CCB_F_ERR                  (1<<0)
        u_int                   ccb_smid;
-       u_int                   ccb_refcnt;
        SIMPLEQ_ENTRY(mfii_ccb) ccb_link;
 };
 SIMPLEQ_HEAD(mfii_ccb_list, mfii_ccb);
@@ -2160,7 +2159,6 @@
                return;
        }
 
-       ccb->ccb_refcnt = 2; /* one for the chip, one for the timeout */
        mfii_start(sc, ccb);
 
        return;
@@ -2177,10 +2175,9 @@
        struct scsipi_xfer *xs = ccb->ccb_cookie;
        struct mpii_msg_scsi_io *io = ccb->ccb_request;
        struct mfii_raid_context *ctx = (struct mfii_raid_context *)(io + 1);
-       u_int refs = 2;
 
        if (callout_stop(&xs->xs_callout) != 0)
-               refs = 1;
+               return;
 
        switch (ctx->status) {
        case MFI_STAT_OK:
@@ -2202,10 +2199,8 @@
                break;
        }
 
-       if (atomic_add_int_nv(&ccb->ccb_refcnt, -refs) == 0) {
-               scsipi_done(xs);
-               mfii_put_ccb(sc, ccb);
-       }
+       scsipi_done(xs);
+       mfii_put_ccb(sc, ccb);
 }
 
 int
@@ -2344,7 +2339,6 @@
                return;
        }
 
-       ccb->ccb_refcnt = 2; /* one for the chip, one for the timeout */
        // XXX timeout_add_msec(&xs->stimeout, xs->timeout);
        mfii_start(sc, ccb);
 
@@ -2544,10 +2538,9 @@
 
                if (!sc->sc_ld[periph->periph_target].ld_present) {
                        /* device is gone */
-                       if (atomic_dec_uint_nv(&ccb->ccb_refcnt) == 0) {
-                               scsipi_done(xs);
-                               mfii_put_ccb(sc, ccb);
-                       }
+                       xs->error = XS_SELTIMEOUT;
+                       scsipi_done(xs);
+                       mfii_put_ccb(sc, ccb);
                        continue;
                }
 
@@ -2592,12 +2585,11 @@
        /* XXX check accb completion? */
 
        mfii_put_ccb(sc, accb);
-
-       if (atomic_dec_uint_nv(&ccb->ccb_refcnt) == 0) {
-               xs->error = XS_TIMEOUT;
-               scsipi_done(xs);
-               mfii_put_ccb(sc, ccb);
-       }
+       printf("%s: cmd aborted ccb %p\n", DEVNAME(sc), ccb);
+
+       xs->error = XS_TIMEOUT;
+       scsipi_done(xs);
+       mfii_put_ccb(sc, ccb);
 }
 
 struct mfii_ccb *
@@ -2628,8 +2620,6 @@
        ccb->ccb_dma64 = false;
        ccb->ccb_len = 0;
        ccb->ccb_sgl_len = 0;
-       ccb->ccb_refcnt = 1;
-
        memset(&ccb->ccb_req, 0, sizeof(ccb->ccb_req));
        memset(ccb->ccb_request, 0, MFII_REQUEST_SIZE);
        memset(ccb->ccb_mfi, 0, MFI_FRAME_SIZE);



Home | Main Index | Thread Index | Old Index