mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-17 10:26:15 +00:00
- Add sysctl knob for bus manager. (hw.firewire.try_bmr)
- Check invalid SID length. - Add some debug messages.
This commit is contained in:
parent
32c8cd2915
commit
16e0f48443
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=109736
@ -57,10 +57,12 @@
|
||||
#include <dev/firewire/iec13213.h>
|
||||
#include <dev/firewire/iec68113.h>
|
||||
|
||||
int firewire_debug=0;
|
||||
SYSCTL_NODE(_hw, OID_AUTO, firewire, CTLFLAG_RD, 0, "FireWire Subsystem");
|
||||
int firewire_debug=0, try_bmr=1;
|
||||
SYSCTL_INT(_debug, OID_AUTO, firewire_debug, CTLFLAG_RW, &firewire_debug, 0,
|
||||
"FireWire driver debug flag");
|
||||
SYSCTL_NODE(_hw, OID_AUTO, firewire, CTLFLAG_RD, 0, "FireWire Subsystem");
|
||||
SYSCTL_INT(_hw_firewire, OID_AUTO, try_bmr, CTLFLAG_RW, &try_bmr, 0,
|
||||
"Try to be a bus manager");
|
||||
|
||||
#define FW_MAXASYRTY 4
|
||||
#define FW_MAXDEVRCNT 4
|
||||
@ -1195,32 +1197,29 @@ void fw_sidrcv(struct firewire_comm* fc, caddr_t buf, u_int len, u_int off)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if((fc->irm != -1) && (CSRARC(fc, BUS_MGR_ID) == 0x3f) ){
|
||||
if(fc->irm == ((CSRARC(fc, NODE_IDS) >> 16 ) & 0x3f)){
|
||||
if (try_bmr && (fc->irm != -1) && (CSRARC(fc, BUS_MGR_ID) == 0x3f)) {
|
||||
if (fc->irm == ((CSRARC(fc, NODE_IDS) >> 16 ) & 0x3f)) {
|
||||
fc->status = FWBUSMGRDONE;
|
||||
CSRARC(fc, BUS_MGR_ID) = fc->set_bmr(fc, fc->irm);
|
||||
}else{
|
||||
} else {
|
||||
fc->status = FWBUSMGRELECT;
|
||||
fc->bmrhandle = timeout((timeout_t *)fw_try_bmr,(void *)fc, hz / 8);
|
||||
fc->bmrhandle = timeout((timeout_t *)fw_try_bmr,
|
||||
(void *)fc, hz / 8);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
fc->status = FWBUSMGRDONE;
|
||||
#if 0
|
||||
device_printf(fc->bdev, "BMR = %x\n",
|
||||
CSRARC(fc, BUS_MGR_ID));
|
||||
#endif
|
||||
}
|
||||
free(buf, M_DEVBUF);
|
||||
#if 1
|
||||
/* XXX optimize gap_count, if I am BMGR */
|
||||
/* Optimize gap_count, if I am BMGR */
|
||||
if(fc->irm == ((CSRARC(fc, NODE_IDS) >> 16 ) & 0x3f)){
|
||||
fw_phy_config(fc, -1, gap_cnt[fc->max_hop]);
|
||||
}
|
||||
#endif
|
||||
#if 1
|
||||
callout_reset(&fc->busprobe_callout, hz/4,
|
||||
(void *)fw_bus_probe, (void *)fc);
|
||||
#else
|
||||
fw_bus_probe(fc);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -660,7 +660,11 @@ fwohci_init(struct fwohci_softc *sc, device_t dev)
|
||||
device_printf(dev, "sid_buf alloc failed.\n");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if (((u_int32_t) sc->fc.sid_buf & (OHCI_SIDSIZE - 1)) != 0) {
|
||||
device_printf(dev, "sid_buf(%p) not aligned.\n",
|
||||
sc->fc.sid_buf);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
fwohci_db_init(&sc->arrq);
|
||||
if ((sc->arrq.flags & FWOHCI_DBCH_INIT) == 0)
|
||||
@ -1541,6 +1545,7 @@ fwohci_irxbuf_enable(struct firewire_comm *fc, int dmach)
|
||||
struct fwohci_softc *sc = (struct fwohci_softc *)fc;
|
||||
int err = 0;
|
||||
unsigned short tag, ich;
|
||||
u_int32_t stat;
|
||||
|
||||
if(!(sc->ir[dmach].xferq.flag & FWXFERQ_RUNNING)){
|
||||
tag = (sc->ir[dmach].xferq.flag >> 6) & 3;
|
||||
@ -1566,7 +1571,8 @@ fwohci_irxbuf_enable(struct firewire_comm *fc, int dmach)
|
||||
if(err)
|
||||
return err;
|
||||
|
||||
if(OREAD(sc, OHCI_IRCTL(dmach)) & OHCI_CNTL_DMA_ACTIVE){
|
||||
stat = OREAD(sc, OHCI_IRCTL(dmach));
|
||||
if (stat & OHCI_CNTL_DMA_ACTIVE) {
|
||||
if(sc->ir[dmach].xferq.stdma2 != NULL){
|
||||
((struct fwohcidb_tr *)(sc->ir[dmach].xferq.stdma->end))->db[sc->ir[dmach].ndesc - 1].db.desc.depend =
|
||||
vtophys(((struct fwohcidb_tr *)(sc->ir[dmach].xferq.stdma2->start))->db) | sc->ir[dmach].ndesc;
|
||||
@ -1575,8 +1581,10 @@ fwohci_irxbuf_enable(struct firewire_comm *fc, int dmach)
|
||||
((struct fwohcidb_tr *)(sc->ir[dmach].xferq.stdma2->end))->db[sc->ir[dmach].ndesc - 1].db.desc.depend &= ~0xf;
|
||||
((struct fwohcidb_tr *)(sc->ir[dmach].xferq.stdma2->end))->db[0].db.desc.depend &= ~0xf;
|
||||
}
|
||||
}else if(!(OREAD(sc, OHCI_IRCTL(dmach)) & OHCI_CNTL_DMA_ACTIVE)
|
||||
&& !(sc->ir[dmach].xferq.flag & FWXFERQ_PACKET)){
|
||||
} else if (!(stat & OHCI_CNTL_DMA_ACTIVE)
|
||||
&& !(sc->ir[dmach].xferq.flag & FWXFERQ_PACKET)) {
|
||||
if (firewire_debug)
|
||||
device_printf(sc->fc.dev, "IR DMA stat %x\n", stat);
|
||||
fw_rbuf_update(&sc->fc, dmach, 0);
|
||||
|
||||
OWRITE(sc, OHCI_IRCTLCLR(dmach), OHCI_CNTL_DMA_RUN);
|
||||
@ -1829,6 +1837,10 @@ fwohci_intr_body(struct fwohci_softc *sc, u_int32_t stat, int count)
|
||||
fc->nodeid = OREAD(sc, FWOHCI_NODEID) & 0x3f;
|
||||
|
||||
plen = OREAD(sc, OHCI_SID_CNT) & OHCI_SID_CNT_MASK;
|
||||
if (plen < 4 || plen > OHCI_SIDSIZE) {
|
||||
device_printf(fc->dev, "invalid SID len = %d\n", plen);
|
||||
goto sidout;
|
||||
}
|
||||
plen -= 4; /* chop control info */
|
||||
buf = malloc(OHCI_SIDSIZE, M_DEVBUF, M_NOWAIT);
|
||||
if(buf == NULL) goto sidout;
|
||||
|
Loading…
Reference in New Issue
Block a user