changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: nusb/usbd: stop sending port enable commands

changeset 7171: f7b606b2be21
parent 7170: 55bc217eb3f5
child 7172: fa96f026264b
author: mischief <mischief@offblast.org>
date: Thu, 18 Apr 2019 02:48:35 -0700
files: sys/src/cmd/nusb/usbd/dat.h sys/src/cmd/nusb/usbd/hub.c
description: nusb/usbd: stop sending port enable commands

from what i can tell, sending port enable is a spec violation.

this fixes a hang during hub enumeration in the ASMedia
xhci controller when i plug in my IBM UltraNav SK-8845.

also, send unsuspend when port is suspended instead of enable.

from the USB 2 specification:

11.24.2.7.1.2 PORT_ENABLE
...
This bit may be set only as a result of a SetPortFeature(PORT_ENABLE).
...
The hub response to a SetPortFeature(PORT_ENABLE) request is not specified.
     1.1--- a/sys/src/cmd/nusb/usbd/dat.h
     1.2+++ b/sys/src/cmd/nusb/usbd/dat.h
     1.3@@ -55,7 +55,6 @@ enum
     1.4 
     1.5 	/* Delays, timeouts (ms) */
     1.6 	Spawndelay	= 250,		/* how often may we re-spawn a driver */
     1.7-	Connectdelay	= 500,		/* how much to wait after a connect */
     1.8 	Resetdelay	= 20,		/* how much to wait after a reset */
     1.9 	Enabledelay	= 20,		/* how much to wait after an enable */
    1.10 	Powerdelay	= 100,		/* after powering up ports */
     2.1--- a/sys/src/cmd/nusb/usbd/hub.c
     2.2+++ b/sys/src/cmd/nusb/usbd/hub.c
     2.3@@ -362,7 +362,7 @@ portattach(Hub *h, int p, u32int sts)
     2.4 	pp->state = Pattached;
     2.5 	dprint(2, "%s: %s: port %d attach sts %#ux\n", argv0, d->dir, p, sts);
     2.6 	if(h->dev->isusb3){
     2.7-		sleep(Connectdelay);
     2.8+		sleep(Enabledelay);
     2.9 		sts = portstatus(h, p);
    2.10 		if(sts == -1)
    2.11 			goto Fail;
    2.12@@ -372,9 +372,6 @@ portattach(Hub *h, int p, u32int sts)
    2.13 		}
    2.14 		sp = "super";
    2.15 	} else {
    2.16-		sleep(Connectdelay);
    2.17-		if(hubfeature(h, p, Fportenable, 1) < 0)
    2.18-			dprint(2, "%s: %s: port %d: enable: %r\n", argv0, d->dir, p);
    2.19 		sleep(Enabledelay);
    2.20 		if(hubfeature(h, p, Fportreset, 1) < 0){
    2.21 			dprint(2, "%s: %s: port %d: reset: %r\n", argv0, d->dir, p);
    2.22@@ -558,12 +555,7 @@ portreset(Hub *h, int p)
    2.23 		goto Fail;
    2.24 	if((sts & PSenable) == 0){
    2.25 		dprint(2, "%s: %s: port %d: not enabled?\n", argv0, d->dir, p);
    2.26-		if(h->dev->isusb3)
    2.27-			goto Fail;
    2.28-		hubfeature(h, p, Fportenable, 1);
    2.29-		sts = portstatus(h, p);
    2.30-		if((sts & PSenable) == 0)
    2.31-			goto Fail;
    2.32+		goto Fail;
    2.33 	}
    2.34 	nd = pp->dev;
    2.35 	opendevdata(nd, ORDWR);
    2.36@@ -635,11 +627,11 @@ enumhub(Hub *h, int p)
    2.37 	onhubs = nhubs;
    2.38 	if(!h->dev->isusb3){
    2.39 		if((sts & PSsuspend) != 0){
    2.40-			if(hubfeature(h, p, Fportenable, 1) < 0)
    2.41-				dprint(2, "%s: %s: port %d: enable: %r\n", argv0, d->dir, p);
    2.42+			if(hubfeature(h, p, Fportsuspend, 0) < 0)
    2.43+				dprint(2, "%s: %s: port %d: unsuspend: %r\n", argv0, d->dir, p);
    2.44 			sleep(Enabledelay);
    2.45 			sts = portstatus(h, p);
    2.46-			fprint(2, "%s: %s: port %d: resumed (sts %#ux)\n", argv0, d->dir, p, sts);
    2.47+			fprint(2, "%s: %s: port %d: unsuspended (sts %#ux)\n", argv0, d->dir, p, sts);
    2.48 		}
    2.49 	}
    2.50 	if((pp->sts & PSpresent) == 0 && (sts & PSpresent) != 0){