Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ieee1394 Defer initialization of isodma channels unt...



details:   https://anonhg.NetBSD.org/src/rev/16119c31e265
branches:  trunk
changeset: 349027:16119c31e265
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Nov 20 22:36:45 2016 +0000

description:
Defer initialization of isodma channels until we know how many.

Should fix a bug I introduced four years ago in:
https://mail-index.netbsd.org/source-changes/2012/08/04/msg036211.html

diffstat:

 sys/dev/ieee1394/firewire.c    |  56 ++++++++++++++++++++++++------------------
 sys/dev/ieee1394/firewirereg.h |   3 +-
 sys/dev/ieee1394/fwohci.c      |   6 +++-
 3 files changed, 38 insertions(+), 27 deletions(-)

diffs (133 lines):

diff -r 9ca63192f02a -r 16119c31e265 sys/dev/ieee1394/firewire.c
--- a/sys/dev/ieee1394/firewire.c       Sun Nov 20 21:49:24 2016 +0000
+++ b/sys/dev/ieee1394/firewire.c       Sun Nov 20 22:36:45 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: firewire.c,v 1.45 2014/10/18 08:33:28 snj Exp $        */
+/*     $NetBSD: firewire.c,v 1.46 2016/11/20 22:36:45 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.45 2014/10/18 08:33:28 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: firewire.c,v 1.46 2016/11/20 22:36:45 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -622,33 +622,11 @@
        mutex_init(&fc->atq->q_mtx, MUTEX_DEFAULT, IPL_VM);
        mutex_init(&fc->ats->q_mtx, MUTEX_DEFAULT, IPL_VM);
 
-       for (i = 0; i < fc->nisodma; i++) {
-               fc->it[i]->queued = 0;
-               fc->ir[i]->queued = 0;
-
-               fc->it[i]->start = NULL;
-               fc->ir[i]->start = NULL;
-
-               fc->it[i]->buf = NULL;
-               fc->ir[i]->buf = NULL;
-
-               fc->it[i]->flag = FWXFERQ_STREAM;
-               fc->ir[i]->flag = FWXFERQ_STREAM;
-
-               STAILQ_INIT(&fc->it[i]->q);
-               STAILQ_INIT(&fc->ir[i]->q);
-       }
-
        fc->arq->maxq = FWMAXQUEUE;
        fc->ars->maxq = FWMAXQUEUE;
        fc->atq->maxq = FWMAXQUEUE;
        fc->ats->maxq = FWMAXQUEUE;
 
-       for (i = 0; i < fc->nisodma; i++) {
-               fc->ir[i]->maxq = FWMAXQUEUE;
-               fc->it[i]->maxq = FWMAXQUEUE;
-       }
-
        CSRARC(fc, TOPO_MAP) = 0x3f1 << 16;
        CSRARC(fc, TOPO_MAP + 4) = 1;
        CSRARC(fc, SPED_MAP) = 0x3f1 << 16;
@@ -677,6 +655,36 @@
        fc->crom_src_buf = NULL;
 }
 
+/*
+ * Called by HCI driver when it has determined the number of
+ * isochronous DMA channels.
+ */
+void
+fw_init_isodma(struct firewire_comm *fc)
+{
+       unsigned i;
+
+       for (i = 0; i < fc->nisodma; i++) {
+               fc->it[i]->queued = 0;
+               fc->ir[i]->queued = 0;
+
+               fc->it[i]->start = NULL;
+               fc->ir[i]->start = NULL;
+
+               fc->it[i]->buf = NULL;
+               fc->ir[i]->buf = NULL;
+
+               fc->it[i]->flag = FWXFERQ_STREAM;
+               fc->ir[i]->flag = FWXFERQ_STREAM;
+
+               STAILQ_INIT(&fc->it[i]->q);
+               STAILQ_INIT(&fc->ir[i]->q);
+
+               fc->ir[i]->maxq = FWMAXQUEUE;
+               fc->it[i]->maxq = FWMAXQUEUE;
+       }
+}
+
 void
 fw_destroy(struct firewire_comm *fc)
 {
diff -r 9ca63192f02a -r 16119c31e265 sys/dev/ieee1394/firewirereg.h
--- a/sys/dev/ieee1394/firewirereg.h    Sun Nov 20 21:49:24 2016 +0000
+++ b/sys/dev/ieee1394/firewirereg.h    Sun Nov 20 22:36:45 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: firewirereg.h,v 1.18 2012/08/04 03:55:43 riastradh Exp $       */
+/*     $NetBSD: firewirereg.h,v 1.19 2016/11/20 22:36:45 riastradh Exp $       */
 /*-
  * Copyright (c) 2003 Hidetoshi Shimokawa
  * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -283,6 +283,7 @@
 void fw_drain_txq(struct firewire_comm *);
 void fw_busreset(struct firewire_comm *, uint32_t);
 void fw_init(struct firewire_comm *);
+void fw_init_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 9ca63192f02a -r 16119c31e265 sys/dev/ieee1394/fwohci.c
--- a/sys/dev/ieee1394/fwohci.c Sun Nov 20 21:49:24 2016 +0000
+++ b/sys/dev/ieee1394/fwohci.c Sun Nov 20 22:36:45 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fwohci.c,v 1.137 2014/02/25 18:30:09 pooka Exp $       */
+/*     $NetBSD: fwohci.c,v 1.138 2016/11/20 22:36:45 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2003 Hidetoshi Shimokawa
@@ -37,7 +37,7 @@
  *
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.137 2014/02/25 18:30:09 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.138 2016/11/20 22:36:45 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -428,6 +428,8 @@
        if (i == 0)
                return ENXIO;
 
+       fw_init_isodma(&sc->fc);
+
        for (i = 0; i < sc->fc.nisodma; i++) {
                sc->fc.it[i] = &sc->it[i].xferq;
                sc->fc.ir[i] = &sc->ir[i].xferq;



Home | Main Index | Thread Index | Old Index