Increase ohci maximum transfer size to allow multiple packets per TD. Also fix handling of short transfers under virtualbox. Reference: /n/sources/patch/applied/usbohci-multipacket Date: Fri Sep 2 10:57:03 CES 2011 Signed-off-by: miller@hamnavoe.com --- /sys/src/9/pc/usbohci.c Fri Sep 2 10:54:03 2011 +++ /sys/src/9/pc/usbohci.c Fri Sep 2 10:53:59 2011 @@ -1133,11 +1133,12 @@ switch(err){ case Tddataovr: /* Overrun is not an error */ - case Tdok: - /* can't make this assertion in virtualbox */ -// if(td->cbp != 0) -// panic("ohci: full packet but cbp != 0"); break; + case Tdok: + /* virtualbox doesn't always report underflow on short packets */ + if(td->cbp == 0) + break; + /* fall through */ case Tddataund: /* short input packets are ok */ if(mode == OREAD){ @@ -1326,12 +1327,16 @@ Td *td, *dtd; Block *bp; - if(ep->maxpkt > 0x2000) - panic("ohci: max packet > two pages"); - if(ep->maxpkt < count) - error("maxpkt too short"); - bp = allocb(ep->maxpkt); /* panics if no mem */ - assert(bp != nil); + if(count <= BY2PG) + bp = allocb(count); + else{ + if(count > 2*BY2PG) + panic("ohci: transfer > two pages"); + /* maximum of one physical page crossing allowed */ + bp = allocb(count+BY2PG); + bp->rp = (uchar*)PGROUND((uintptr)bp->rp); + bp->wp = bp->rp; + } dtd = *dtdp; td = dtd; td->bp = bp; @@ -1482,7 +1487,7 @@ ltd = td0 = ed->tds; load = tot = 0; do{ - n = ep->maxpkt; + n = 2*BY2PG; if(count-tot < n) n = count-tot; if(c != nil && io->tok != Tdtokin)