update pi usb take care of a few nits Reference: /n/atom/patch/applied/piusbupd Date: Thu Jan 7 00:44:30 CET 2016 Signed-off-by: quanstro@quanstro.net --- /sys/src/9/bcm/usbdwc.c Thu Jan 7 00:43:36 2016 +++ /sys/src/9/bcm/usbdwc.c Thu Jan 7 00:43:38 2016 @@ -39,6 +39,7 @@ typedef struct Epio Epio; struct Ctlr { + Lock; Dwcregs *regs; /* controller registers */ int nchan; /* number of host channels */ ulong chanbusy; /* bitmap of in-use channels */ @@ -66,6 +67,22 @@ static void clog(Ep *ep, Hostchan *hc); static void logdump(Ep *ep); +static void +filock(Lock *l) +{ + int x; + + x = splfhi(); + ilock(l); + l->sr = x; +} + +static void +fiunlock(Lock *l) +{ + iunlock(l); +} + static Hostchan* chanalloc(Ep *ep) { @@ -158,23 +175,22 @@ Dwcregs *r; r = a; - return r->gintsts & Sofintr; + return (r->gintmsk & Sofintr) == 0; } static void sofwait(Ctlr *ctlr, int n) { Dwcregs *r; - int x; r = ctlr->regs; do{ + filock(ctlr); r->gintsts = Sofintr; - x = splfhi(); ctlr->sofchan |= 1<gintmsk |= Sofintr; + fiunlock(ctlr); sleep(&ctlr->chanintr[n], sofdone, r); - splx(x); }while((r->hfnum & 7) == 6); } @@ -192,7 +208,7 @@ static int chanwait(Ep *ep, Ctlr *ctlr, Hostchan *hc, int mask) { - int intr, n, x, ointr; + int intr, n, ointr; ulong start, now; Dwcregs *r; @@ -200,12 +216,12 @@ n = hc - r->hchan; for(;;){ restart: - x = splfhi(); + filock(ctlr); r->haintmsk |= 1<hcintmsk = mask; + fiunlock(ctlr); sleep(&ctlr->chanintr[n], chandone, hc); hc->hcintmsk = 0; - splx(x); intr = hc->hcint; if(intr & Chhltd) return intr; @@ -524,8 +540,8 @@ if(datalen <= 0 || datalen > Maxctllen) error(Ebadlen); /* XXX cache madness */ - epio->cb = b = allocb(ROUND(datalen, ep->maxpkt) + BLOCKALIGN); - b->wp = (uchar*)ROUND((uintptr)b->wp, BLOCKALIGN); + epio->cb = b = allocb(ROUND(datalen, ep->maxpkt)); + assert(((uintptr)b->wp & (BLOCKALIGN-1)) == 0); memset(b->wp, 0x55, b->lim - b->wp); cachedwbinvse(b->wp, b->lim - b->wp); data = b->wp; @@ -654,6 +670,7 @@ ctlr = hp->aux; r = ctlr->regs; wakechan = 0; + filock(ctlr); intr = r->gintsts; if(intr & Hcintr){ haint = r->haint & r->haintmsk; @@ -679,6 +696,7 @@ ctlr->wakechan |= wakechan; armtimerset(1); } + fiunlock(ctlr); } static void @@ -686,14 +704,14 @@ { Ctlr *ctlr; uint wakechan; - int i, x; + int i; ctlr = a; - x = splfhi(); + filock(ctlr); armtimerset(0); wakechan = ctlr->wakechan; ctlr->wakechan = 0; - splx(x); + fiunlock(ctlr); for(i = 0; wakechan; i++){ if(wakechan & 1) wakeup(&ctlr->chanintr[i]); @@ -773,10 +791,12 @@ /* fall through */ case Tbulk: /* XXX cache madness */ - b = allocb(ROUND(n, ep->maxpkt) + BLOCKALIGN); - p = (uchar*)ROUND((uintptr)b->base, BLOCKALIGN); - cachedwbinvse(p, n); + b = allocb(ROUND(n, ep->maxpkt)); + p = b->rp; + assert(((uintptr)p & (BLOCKALIGN-1)) == 0); + cachedinvse(p, n); nr = eptrans(ep, Read, p, n); + cachedinvse(p, nr); epio->lastpoll = TK2MS(m->ticks); memmove(a, p, nr); qunlock(epio); @@ -815,8 +835,9 @@ case Tctl: case Tbulk: /* XXX cache madness */ - b = allocb(n + BLOCKALIGN); - p = (uchar*)ROUND((uintptr)b->base, BLOCKALIGN); + b = allocb(n); + p = b->wp; + assert(((uintptr)p & (BLOCKALIGN-1)) == 0); memmove(p, a, n); cachedwbse(p, n); if(ep->ttype == Tctl) --- /sys/src/9/bcm/devarch.c Thu Jan 7 00:43:40 2016 +++ /sys/src/9/bcm/devarch.c Thu Jan 7 00:43:41 2016 @@ -162,7 +162,7 @@ { char str[16]; - snprint(str, sizeof str, "%d±%d\n", gettemp(TempCpu) / 1000, 1); + snprint(str, sizeof str, "%d±%d\n", (gettemp(TempCpu)+500)/1000, 1); return readstr(offset, a, n, str); } --- /sys/src/9/bcm/arm.s Thu Jan 7 00:43:43 2016 +++ /sys/src/9/bcm/arm.s Thu Jan 7 00:43:44 2016 @@ -11,8 +11,6 @@ #define L1X(va) (((((va))>>20) & 0x0fff)<<2) -#define PTEDRAM (Dom0|L1AP(Krw)|Section|Cached|Buffered) - /* * new instructions */