shithub: riscv

Download patch

ref: 14bb9734a611556f14ce17d810993588b3075a1b
parent: 4b637a24f9c2db696b6660bc7116441a43281302
author: cinap_lenrek <[email protected]>
date: Mon Feb 21 13:46:47 EST 2022

usbxhci: endpoint address needs to be masked with Epmax from endpoint number

--- a/sys/src/9/port/usbxhci.c
+++ b/sys/src/9/port/usbxhci.c
@@ -1059,7 +1059,7 @@
 		w[0] = (w[0] & ~(0x1F<<27)) | slot->nep<<27;
 
 		/* (input) ep context */
-		w += ep->nb*2*8<<ctlr->csz;
+		w += (ep->nb&Epmax)*2*8<<ctlr->csz;
 		memset(w, 0, 2*32<<ctlr->csz);
 
 		dmaflush(1, slot->ibase, 32*33 << ctlr->csz);
@@ -1147,8 +1147,8 @@
 		nexterror();
 	}
 	if(ep->mode != OREAD){
-		ring = initring(io[OWRITE].ring = &slot->epr[ep->nb*2-1], 8);
-		ring->id = ep->nb*2;
+		ring = initring(io[OWRITE].ring = &slot->epr[(ep->nb&Epmax)*2-1], 8);
+		ring->id = (ep->nb&Epmax)*2;
 		if(ring->id > slot->nep)
 			slot->nep = ring->id;
 		ring->slot = slot;
@@ -1157,8 +1157,8 @@
 		w[1] |= 1 << ring->id;
 	}
 	if(ep->mode != OWRITE){
-		ring = initring(io[OREAD].ring = &slot->epr[ep->nb*2], 8);
-		ring->id = ep->nb*2+1;
+		ring = initring(io[OREAD].ring = &slot->epr[(ep->nb&Epmax)*2], 8);
+		ring->id = (ep->nb&Epmax)*2+1;
 		if(ring->id > slot->nep)
 			slot->nep = ring->id;
 		ring->slot = slot;
@@ -1174,7 +1174,7 @@
 		w[0] &= ~(1<<25);	// MTT
 
 	/* (input) ep context */
-	w += ep->nb*2*8<<ctlr->csz;
+	w += (ep->nb&Epmax)*2*8<<ctlr->csz;
 	if(io[OWRITE].ring != nil){
 		memset(w, 0, 5*4);
 		initepctx(w, io[OWRITE].ring, ep);