Applied patch by JiSheng Zhang:

Synchronized firewire bus manager with FreeBSD current.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24916 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-04-11 17:35:11 +00:00
parent ac0e5c1ce5
commit f156c25d14
2 changed files with 23 additions and 14 deletions
+6 -1
View File
@@ -31,7 +31,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD: src/sys/dev/firewire/firewirereg.h,v 1.49 2007/07/15 13:20:48 simokawa Exp $
* $FreeBSD: src/sys/dev/firewire/firewirereg.h,v 1.50 2007/07/20 03:42:57 simokawa Exp $
*
*/
#ifndef _FIREWIREREG_H
@@ -173,6 +173,11 @@ struct firewire_comm{
*arq, *atq, *ars, *ats, *it[FW_MAX_DMACH],*ir[FW_MAX_DMACH];
struct fw_xferlist tlabels[0x40];
u_char last_tlabel[0x40];
#ifndef __HAIKU__
struct mtx tlabel_lock;
#else
benaphore tlabel_lock;
#endif
STAILQ_HEAD(, fw_bind) binds;
STAILQ_HEAD(, fw_device) devices;
u_int sid_cnt;
@@ -31,7 +31,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD: src/sys/dev/firewire/firewire.c,v 1.99 2007/07/15 13:00:29 simokawa Exp $
* $FreeBSD: src/sys/dev/firewire/firewire.c,v 1.100 2007/07/20 03:42:57 simokawa Exp $
*
*/
#include <OS.h>
@@ -301,7 +301,7 @@ firewire_xfer_timeout(void *arg)
STAILQ_INIT(&xfer_timeout);
s = splfw();
FW_GLOCK(fc);
mtx_lock(&fc->tlabel_lock);
for (i = 0; i < 0x40; i ++) {
while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) {
if ((xfer->flag & FWXF_SENT) == 0)
@@ -320,7 +320,7 @@ firewire_xfer_timeout(void *arg)
STAILQ_INSERT_TAIL(&xfer_timeout, xfer, tlabel);
}
}
FW_GUNLOCK(fc);
mtx_unlock(&fc->tlabel_lock);
splx(s);
fc->timeout(fc);
@@ -436,6 +436,7 @@ firewire_attach(struct firewire_comm *fc, struct firewire_softc *sc)
// fwdev_makedev(sc);
mtx_init(&fc->wait_lock, "fwwait", NULL, MTX_DEF);
mtx_init(&fc->tlabel_lock, "fwtlabel", NULL, MTX_DEF);
// CALLOUT_INIT(&fc->timeout_callout);
// CALLOUT_INIT(&fc->bmr_callout);
// CALLOUT_INIT(&fc->busprobe_callout);
@@ -527,6 +528,7 @@ firewire_detach(struct firewire_softc *sc)
free(fc->speed_map);
free(fc->crom_src_buf);
mtx_destroy(&fc->tlabel_lock);
mtx_destroy(&fc->wait_lock);
// return(0);
}
@@ -569,7 +571,9 @@ fw_drain_txq(struct firewire_comm *fc)
fw_xferq_drain(fc->ats);
for(i = 0; i < fc->nisodma; i++)
fw_xferq_drain(fc->it[i]);
FW_GUNLOCK(fc);
mtx_lock(&fc->tlabel_lock);
for (i = 0; i < 0x40; i ++)
while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) {
if (firewire_debug)
@@ -578,7 +582,7 @@ fw_drain_txq(struct firewire_comm *fc)
STAILQ_REMOVE_HEAD(&fc->tlabels[i], tlabel);
STAILQ_INSERT_TAIL(&xfer_drain, xfer, tlabel);
}
FW_GUNLOCK(fc);
mtx_unlock(&fc->tlabel_lock);
STAILQ_FOREACH_SAFE(xfer, &xfer_drain, tlabel, txfer)
xfer->hand(xfer);
@@ -1035,7 +1039,7 @@ fw_tl_free(struct firewire_comm *fc, struct fw_xfer *xfer)
return;
s = splfw();
FW_GLOCK(fc);
mtx_lock(&fc->tlabel_lock);
#if 1 /* make sure the label is allocated */
STAILQ_FOREACH(txfer, &fc->tlabels[xfer->tl], tlabel)
if(txfer == xfer)
@@ -1047,14 +1051,14 @@ fw_tl_free(struct firewire_comm *fc, struct fw_xfer *xfer)
fw_dump_hdr(&xfer->send.hdr, "send");
fw_dump_hdr(&xfer->recv.hdr, "recv");
// kdb_backtrace();
FW_GUNLOCK(fc);
mtx_unlock(&fc->tlabel_lock);
splx(s);
return;
}
#endif
STAILQ_REMOVE(&fc->tlabels[xfer->tl], xfer, fw_xfer, tlabel);
FW_GUNLOCK(fc);
mtx_unlock(&fc->tlabel_lock);
splx(s);
return;
}
@@ -1069,10 +1073,10 @@ fw_tl2xfer(struct firewire_comm *fc, int node, int tlabel, int tcode)
int s = splfw();
int req;
FW_GLOCK(fc);
mtx_lock(&fc->tlabel_lock);
STAILQ_FOREACH(xfer, &fc->tlabels[tlabel], tlabel)
if(xfer->send.hdr.mode.hdr.dst == node) {
FW_GUNLOCK(fc);
mtx_unlock(&fc->tlabel_lock);
splx(s);
KASSERT(xfer->tl == tlabel,
("xfer->tl 0x%x != 0x%x", xfer->tl, tlabel));
@@ -1089,7 +1093,7 @@ fw_tl2xfer(struct firewire_comm *fc, int node, int tlabel, int tcode)
printf("fw_tl2xfer: found tl=%d\n", tlabel);
return(xfer);
}
FW_GUNLOCK(fc);
mtx_unlock(&fc->tlabel_lock);
if (firewire_debug > 1)
printf("fw_tl2xfer: not found tl=%d\n", tlabel);
splx(s);
@@ -1797,7 +1801,7 @@ fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer)
dst = xfer->send.hdr.mode.hdr.dst & 0x3f;
s = splfw();
FW_GLOCK(fc);
mtx_lock(&fc->tlabel_lock);
new_tlabel = (fc->last_tlabel[dst] + 1) & 0x3f;
STAILQ_FOREACH(txfer, &fc->tlabels[new_tlabel], tlabel)
if ((txfer->send.hdr.mode.hdr.dst & 0x3f) == dst)
@@ -1805,7 +1809,7 @@ fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer)
if(txfer == NULL) {
fc->last_tlabel[dst] = new_tlabel;
STAILQ_INSERT_TAIL(&fc->tlabels[new_tlabel], xfer, tlabel);
FW_GUNLOCK(fc);
mtx_unlock(&fc->tlabel_lock);
splx(s);
xfer->tl = new_tlabel;
xfer->send.hdr.mode.hdr.tlrt = new_tlabel << 2;
@@ -1813,7 +1817,7 @@ fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer)
printf("fw_get_tlabel: dst=%d tl=%d\n", dst, new_tlabel);
return (new_tlabel);
}
FW_GUNLOCK(fc);
mtx_unlock(&fc->tlabel_lock);
splx(s);
if (firewire_debug > 1)