shithub: riscv

Download patch

ref: 5ea80693baf1b870e36973e1d2f3fd474f2462b7
parent: 68c89f4a437739857ef6fc9627a30ccc69fd8751
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Dec 29 12:09:51 EST 2024

usbuhci, usbehci: remove portlck qlock

Everything is already serialized by usbd. For ehci, portlck
also doubled for waiting for doorbell, so rename it to match
its use case.

--- a/sys/src/9/kw/usbehci.h
+++ b/sys/src/9/kw/usbehci.h
@@ -167,7 +167,7 @@
 {
 	Rendez;			/* for waiting to async advance doorbell */
 	Lock;			/* for ilock. qh lists and basic ctlr I/O */
-	QLock	portlck;	/* for port resets/enable... (and doorbell) */
+	QLock	doorbell;	/* for doorbell */
 	int	active;		/* in use or not */
 	Ecapio*	capio;		/* Capability i/o regs */
 	Eopio*	opio;		/* Operational i/o regs */
--- a/sys/src/9/omap/usbehci.h
+++ b/sys/src/9/omap/usbehci.h
@@ -145,7 +145,7 @@
 {
 	Rendez;			/* for waiting to async advance doorbell */
 	Lock;			/* for ilock. qh lists and basic ctlr I/O */
-	QLock	portlck;	/* for port resets/enable... (and doorbell) */
+	QLock	doorbell;	/* for doorbell */
 	int	active;		/* in use or not */
 	Ecapio*	capio;		/* Capability i/o regs */
 	Eopio*	opio;		/* Operational i/o regs */
--- a/sys/src/9/pc/usbehci.h
+++ b/sys/src/9/pc/usbehci.h
@@ -168,7 +168,7 @@
 {
 	Rendez;			/* for waiting to async advance doorbell */
 	Lock;			/* for ilock. qh lists and basic ctlr I/O */
-	QLock	portlck;	/* for port resets/enable... (and doorbell) */
+	QLock	doorbell;	/* for doorbell */
 	int	active;		/* in use or not */
 	Ctlr*	next;
 	uvlong	base;
--- a/sys/src/9/pc/usbuhci.c
+++ b/sys/src/9/pc/usbuhci.c
@@ -141,7 +141,6 @@
 struct Ctlr
 {
 	Lock;			/* for ilock. qh lists and basic ctlr I/O */
-	QLock	portlck;	/* for port resets/enable... */
 	Pcidev*	pcidev;
 	Ctlr	*next;
 	int	active;
@@ -2030,7 +2029,6 @@
 
 	ctlr = hp->aux;
 	ioport = PORT(port-1);
-	eqlock(&ctlr->portlck);
 	ilock(ctlr);
 	s = INS(ioport);
 	if(on)
@@ -2038,7 +2036,6 @@
 	else
 		OUTS(ioport, s & ~PSenable);
 	iunlock(ctlr);
-	qunlock(&ctlr->portlck);
 }
 
 static void
@@ -2049,7 +2046,6 @@
 
 	ctlr = hp->aux;
 	ioport = PORT(port-1);
-	eqlock(&ctlr->portlck);
 	ilock(ctlr);
 	if(on)
 		OUTS(ioport, PSreset);
@@ -2056,7 +2052,6 @@
 	else
 		OUTS(ioport, INS(ioport) & ~PSreset);
 	iunlock(ctlr);
-	qunlock(&ctlr->portlck);
 }
 
 static int
@@ -2067,7 +2062,6 @@
 
 	ctlr = hp->aux;
 	ioport = PORT(port-1);
-	eqlock(&ctlr->portlck);
 	ilock(ctlr);
 	s = INS(ioport);
 	if(s & (PSstatuschg | PSchange)){
@@ -2075,7 +2069,6 @@
 		ddprint("uhci %#ux port %d status %#x\n", ctlr->port, port, s);
 	}
 	iunlock(ctlr);
-	qunlock(&ctlr->portlck);
 
 	/*
 	 * We must return status bits as a
--- a/sys/src/9/port/usbehci.c
+++ b/sys/src/9/port/usbehci.c
@@ -738,7 +738,7 @@
 {
 	int i;
 
-	qlock(&ctlr->portlck);
+	qlock(&ctlr->doorbell);
 	ctlr->opio->cmd |= Ciasync;	/* ask for intr. on async advance */
 	coherence();
 	for(i = 0; i < 3 && qhadvanced(ctlr) == 0; i++){
@@ -751,7 +751,7 @@
 	if(i == 3)
 		print("ehci: async advance doorbell did not ring\n");
 	ctlr->opio->cmd &= ~Ciasync;	/* try to clean */
-	qunlock(&ctlr->portlck);
+	qunlock(&ctlr->doorbell);
 }
 
 static void
@@ -1657,7 +1657,6 @@
 
 	ctlr = hp->aux;
 	opio = ctlr->opio;
-	eqlock(&ctlr->portlck);
 	ilock(ctlr);
 	s = opio->portsc[port-1] & ~(Pschange|Psstatuschg);
 	if(on)
@@ -1666,7 +1665,6 @@
 		s &= ~Pspower;
 	opio->portsc[port-1] = s;
 	iunlock(ctlr);
-	qunlock(&ctlr->portlck);
 }
 
 static void
@@ -1678,7 +1676,6 @@
 
 	ctlr = hp->aux;
 	opio = ctlr->opio;
-	eqlock(&ctlr->portlck);
 	ilock(ctlr);
 	s = opio->portsc[port-1];
 	if(s & (Psstatuschg | Pschange))
@@ -1691,7 +1688,6 @@
 		opio->portsc[port-1] &= ~Psenable;
 	}
 	iunlock(ctlr);
-	qunlock(&ctlr->portlck);
 }
 
 static void
@@ -1702,7 +1698,6 @@
 
 	ctlr = hp->aux;
 	opio = ctlr->opio;
-	eqlock(&ctlr->portlck);
 	ilock(ctlr);
 	if(on)
 		opio->portsc[port-1] = (opio->portsc[port-1] & ~Psenable) | Psreset;	/* initiate reset */
@@ -1709,7 +1704,6 @@
 	else
 		opio->portsc[port-1] &= ~Psreset;	/* terminate reset */
 	iunlock(ctlr);
-	qunlock(&ctlr->portlck);
 }
 
 static int
@@ -1721,7 +1715,6 @@
 
 	ctlr = hp->aux;
 	opio = ctlr->opio;
-	eqlock(&ctlr->portlck);
 	ilock(ctlr);
 	s = opio->portsc[port-1];
 	if(s & (Psstatuschg | Pschange))
@@ -1735,7 +1728,6 @@
 		s &= ~Pspresent;		/* not for us this time */
 	}
 	iunlock(ctlr);
-	qunlock(&ctlr->portlck);
 
 	/*
 	 * We must return status bits as a
--- a/sys/src/9/zynq/usbehci.h
+++ b/sys/src/9/zynq/usbehci.h
@@ -122,7 +122,7 @@
 {
 	Rendez;			/* for waiting to async advance doorbell */
 	Lock;			/* for ilock. qh lists and basic ctlr I/O */
-	QLock	portlck;	/* for port resets/enable... (and doorbell) */
+	QLock	doorbell;	/* for doorbell */
 	int	active;		/* in use or not */
 	void*	capio;		/* base address for debug info */
 	Eopio*	opio;		/* Operational i/o regs */
--