Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/scsipi Add more KASSERTS about locking.



details:   https://anonhg.NetBSD.org/src/rev/eb9b52cb6f62
branches:  trunk
changeset: 446148:eb9b52cb6f62
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sat Nov 24 18:15:23 2018 +0000

description:
Add more KASSERTS about locking.

diffstat:

 sys/dev/scsipi/scsipi_base.c |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (68 lines):

diff -r 7ca67a6d649c -r eb9b52cb6f62 sys/dev/scsipi/scsipi_base.c
--- a/sys/dev/scsipi/scsipi_base.c      Sat Nov 24 18:14:43 2018 +0000
+++ b/sys/dev/scsipi/scsipi_base.c      Sat Nov 24 18:15:23 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsipi_base.c,v 1.179 2018/09/03 16:29:33 riastradh Exp $      */
+/*     $NetBSD: scsipi_base.c,v 1.180 2018/11/24 18:15:23 bouyer Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.179 2018/09/03 16:29:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.180 2018/11/24 18:15:23 bouyer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_scsi.h"
@@ -348,6 +348,8 @@
        int bit, tag;
        u_int word;
 
+       KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
+
        bit = 0;        /* XXX gcc */
        for (word = 0; word < PERIPH_NTAGWORDS; word++) {
                bit = ffs(periph->periph_freetags[word]);
@@ -389,6 +391,8 @@
        struct scsipi_periph *periph = xs->xs_periph;
        int word, bit;
 
+       KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
+
        word = xs->xs_tag_id >> 5;
        bit = xs->xs_tag_id & 0x1f;
 
@@ -466,6 +470,7 @@
                    (periph->periph_flags & PERIPH_RECOVERING) != 0)
                        goto wait_for_opening;
                periph->periph_active++;
+               KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
                break;
 
  wait_for_opening:
@@ -511,6 +516,7 @@
                if ((flags & XS_CTL_NOSLEEP) == 0)
                        mutex_enter(chan_mtx(periph->periph_channel));
                TAILQ_INSERT_TAIL(&periph->periph_xferq, xs, device_q);
+               KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
                if ((flags & XS_CTL_NOSLEEP) == 0)
                        mutex_exit(chan_mtx(periph->periph_channel));
        }
@@ -534,6 +540,7 @@
        int flags = xs->xs_control;
 
        SC_DEBUG(periph, SCSIPI_DB3, ("scsipi_free_xs\n"));
+       KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
 
        TAILQ_REMOVE(&periph->periph_xferq, xs, device_q);
        callout_destroy(&xs->xs_callout);
@@ -1790,6 +1797,7 @@
         * If the xfer is to be polled, and there are already jobs on
         * the queue, we can't proceed.
         */
+       KASSERT(mutex_owned(chan_mtx(chan)));
        if ((xs->xs_control & XS_CTL_POLL) != 0 &&
            TAILQ_FIRST(&chan->chan_queue) != NULL) {
                xs->error = XS_DRIVER_STUFFUP;



Home | Main Index | Thread Index | Old Index