Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ieee1394 Kill some more tsleep.



details:   https://anonhg.NetBSD.org/src/rev/403a529d5b26
branches:  trunk
changeset: 349028:403a529d5b26
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Nov 20 22:47:39 2016 +0000

description:
Kill some more tsleep.

And no, surrounding tsleep by mutex_exit/mutex_enter does not fix
problems even if the LOCKDEBUG panic symptom goes away...

diffstat:

 sys/dev/ieee1394/firewire.c    |  18 ++++++++++++++++--
 sys/dev/ieee1394/firewirereg.h |   4 +++-
 sys/dev/ieee1394/fwdev.c       |  25 ++++++++++++-------------
 sys/dev/ieee1394/fwohci.c      |  16 +++++++++-------
 4 files changed, 40 insertions(+), 23 deletions(-)

diffs (209 lines):

diff -r 16119c31e265 -r 403a529d5b26 sys/dev/ieee1394/firewire.c
--- a/sys/dev/ieee1394/firewire.c       Sun Nov 20 22:36:45 2016 +0000
+++ b/sys/dev/ieee1394/firewire.c       Sun Nov 20 22:47:39 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: firewire.c,v 1.46 2016/11/20 22:36:45 riastradh Exp $  */
+/*     $NetBSD: firewire.c,v 1.47 2016/11/20 22:47:39 riastradh Exp $  */
 /*-
  * Copyright (c) 2003 Hidetoshi Shimokawa
  * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: firewire.c,v 1.46 2016/11/20 22:36:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: firewire.c,v 1.47 2016/11/20 22:47:39 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -682,6 +682,20 @@
 
                fc->ir[i]->maxq = FWMAXQUEUE;
                fc->it[i]->maxq = FWMAXQUEUE;
+
+               cv_init(&fc->ir[i]->cv, "fw_read");
+               cv_init(&fc->it[i]->cv, "fw_write");
+       }
+}
+
+void
+fw_destroy_isodma(struct firewire_comm *fc)
+{
+       unsigned i;
+
+       for (i = 0; i < fc->nisodma; i++) {
+               cv_destroy(&fc->ir[i]->cv);
+               cv_destroy(&fc->it[i]->cv);
        }
 }
 
diff -r 16119c31e265 -r 403a529d5b26 sys/dev/ieee1394/firewirereg.h
--- a/sys/dev/ieee1394/firewirereg.h    Sun Nov 20 22:36:45 2016 +0000
+++ b/sys/dev/ieee1394/firewirereg.h    Sun Nov 20 22:47:39 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: firewirereg.h,v 1.19 2016/11/20 22:36:45 riastradh Exp $       */
+/*     $NetBSD: firewirereg.h,v 1.20 2016/11/20 22:47:39 riastradh Exp $       */
 /*-
  * Copyright (c) 2003 Hidetoshi Shimokawa
  * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -200,6 +200,7 @@
        STAILQ_HEAD(, fw_bulkxfer) stfree;
        STAILQ_HEAD(, fw_bulkxfer) stdma;
        struct fw_bulkxfer *stproc;
+       kcondvar_t cv;
        struct selinfo rsel;
        void *sc;
        void (*hand) (struct fw_xferq *);
@@ -284,6 +285,7 @@
 void fw_busreset(struct firewire_comm *, uint32_t);
 void fw_init(struct firewire_comm *);
 void fw_init_isodma(struct firewire_comm *);
+void fw_destroy_isodma(struct firewire_comm *);
 void fw_destroy(struct firewire_comm *);
 struct fw_bind *fw_bindlookup(struct firewire_comm *, uint16_t, uint32_t);
 int fw_bindadd(struct firewire_comm *, struct fw_bind *);
diff -r 16119c31e265 -r 403a529d5b26 sys/dev/ieee1394/fwdev.c
--- a/sys/dev/ieee1394/fwdev.c  Sun Nov 20 22:36:45 2016 +0000
+++ b/sys/dev/ieee1394/fwdev.c  Sun Nov 20 22:47:39 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fwdev.c,v 1.30 2014/07/25 08:10:37 dholland Exp $      */
+/*     $NetBSD: fwdev.c,v 1.31 2016/11/20 22:47:39 riastradh Exp $     */
 /*-
  * Copyright (c) 2003 Hidetoshi Shimokawa
  * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fwdev.c,v 1.30 2014/07/25 08:10:37 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fwdev.c,v 1.31 2016/11/20 22:47:39 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -104,6 +104,7 @@
        struct fw_isobufreq bufreq;
        STAILQ_HEAD(, fw_bind) binds;
        STAILQ_HEAD(, fw_xfer) rq;
+       kcondvar_t cv;
 };
 
 static int fwdev_allocbuf(struct firewire_comm *, struct fw_xferq *,
@@ -145,6 +146,7 @@
        d->fc = sc->fc;
        STAILQ_INIT(&d->binds);
        STAILQ_INIT(&d->rq);
+       cv_init(&d->cv, "fwra");
 
        return err;
 }
@@ -217,6 +219,7 @@
                    ~(FWXFERQ_OPEN | FWXFERQ_MODEMASK | FWXFERQ_CHTAGMASK);
                d->it = NULL;
        }
+       cv_destroy(&d->cv);
        free(sc->si_drv1, M_FW);
        sc->si_drv1 = NULL;
 
@@ -265,9 +268,7 @@
                if (slept == 0) {
                        slept = 1;
                        ir->flag |= FWXFERQ_WAKEUP;
-                       mutex_exit(&fc->fc_mtx);
-                       err = tsleep(ir, FWPRI, "fw_read", hz);
-                       mutex_enter(&fc->fc_mtx);
+                       err = cv_timedwait_sig(&ir->cv, &fc->fc_mtx, hz);
                        ir->flag &= ~FWXFERQ_WAKEUP;
                        if (err == 0)
                                goto readloop;
@@ -343,9 +344,7 @@
                        if (err)
                                goto out;
 #endif
-                       mutex_exit(&fc->fc_mtx);
-                       err = tsleep(it, FWPRI, "fw_write", hz);
-                       mutex_enter(&fc->fc_mtx);
+                       err = cv_timedwait_sig(&it->cv, &fc->fc_mtx, hz);
                        if (err)
                                goto out;
                        goto isoloop;
@@ -824,11 +823,11 @@
        for (;;) {
                xfer = STAILQ_FIRST(&d->rq);
                if (xfer == NULL && err == 0) {
-                       mutex_exit(&d->fc->fc_mtx);
-                       err = tsleep(&d->rq, FWPRI, "fwra", 0);
-                       if (err != 0)
+                       err = cv_wait_sig(&d->cv, &d->fc->fc_mtx);
+                       if (err) {
+                               mutex_exit(&d->fc->fc_mtx);
                                return err;
-                       mutex_enter(&d->fc->fc_mtx);
+                       }
                        continue;
                }
                break;
@@ -924,6 +923,6 @@
        d = (struct fw_drv1 *)fwb->sc;
        mutex_enter(&xfer->fc->fc_mtx);
        STAILQ_INSERT_TAIL(&d->rq, xfer, link);
+       cv_broadcast(&d->cv);
        mutex_exit(&xfer->fc->fc_mtx);
-       wakeup(&d->rq);
 }
diff -r 16119c31e265 -r 403a529d5b26 sys/dev/ieee1394/fwohci.c
--- a/sys/dev/ieee1394/fwohci.c Sun Nov 20 22:36:45 2016 +0000
+++ b/sys/dev/ieee1394/fwohci.c Sun Nov 20 22:47:39 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fwohci.c,v 1.138 2016/11/20 22:36:45 riastradh Exp $   */
+/*     $NetBSD: fwohci.c,v 1.139 2016/11/20 22:47:39 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2003 Hidetoshi Shimokawa
@@ -37,7 +37,7 @@
  *
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.138 2016/11/20 22:36:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.139 2016/11/20 22:47:39 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -534,6 +534,7 @@
                fwohci_db_free(sc, &sc->ir[i]);
        }
 
+       fw_destroy_isodma(&sc->fc);
        fw_destroy(&sc->fc);
 
        return 0;
@@ -2228,9 +2229,9 @@
                STAILQ_INSERT_TAIL(&it->stfree, chunk, link);
                w++;
        }
+       if (w)
+               cv_broadcast(&it->cv);
        mutex_exit(&fc->fc_mtx);
-       if (w)
-               wakeup(it);
 }
 
 static void
@@ -2285,14 +2286,15 @@
                }
                w++;
        }
-       if ((ir->flag & FWXFERQ_HANDLER) == 0)
+       if ((ir->flag & FWXFERQ_HANDLER) == 0) {
+               if (w)
+                       cv_broadcast(&ir->cv);
                mutex_exit(&fc->fc_mtx);
+       }
        if (w == 0)
                return;
        if (ir->flag & FWXFERQ_HANDLER)
                ir->hand(ir);
-       else
-               wakeup(ir);
 }
 
 static void



Home | Main Index | Thread Index | Old Index