From d38dbf6415cbff7a43997f80f1be9492b496665e Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 15 Dec 2024 21:19:57 +0000 Subject: [PATCH] nusb/usbd: use longer reset delay for rootports Make reset delays more conservative: The usb spec says root ports need 50ms reset minimum, use 100ms. The usb spec says hub ports need 20ms minimum, use 50ms. --- sys/src/cmd/nusb/usbd/dat.h | 5 +++-- sys/src/cmd/nusb/usbd/hub.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/src/cmd/nusb/usbd/dat.h b/sys/src/cmd/nusb/usbd/dat.h index 6f8b9daae..4580a1b7f 100644 --- a/sys/src/cmd/nusb/usbd/dat.h +++ b/sys/src/cmd/nusb/usbd/dat.h @@ -56,8 +56,9 @@ enum Pconfigured, /* Delays, timeouts (ms) */ - Resetdelay = 20, /* how much to wait after a reset */ - Resumedelay = 20, /* how much to wait after a resume */ + Rootresetdelay = 100, /* how much to wait after a root port reset (50ms by standard) */ + Portresetdelay = 50, /* how much to wait after a hub port reset (20ms by standard) */ + Resumedelay = 50, /* how much to wait after a resume (20ms by standard) */ Powerdelay = 100, /* after powering up ports */ Pollms = 250, /* port poll interval */ diff --git a/sys/src/cmd/nusb/usbd/hub.c b/sys/src/cmd/nusb/usbd/hub.c index f423f8e92..fab87ed24 100644 --- a/sys/src/cmd/nusb/usbd/hub.c +++ b/sys/src/cmd/nusb/usbd/hub.c @@ -452,7 +452,7 @@ portattach(Hub *h, int p) dprint(2, "%s: %s: port %d: set reset: %r\n", argv0, d->dir, p); return -1; } - sleep(Resetdelay); + sleep(d->depth<0? Rootresetdelay: Portresetdelay); if((sts = portstatus(h, p)) == -1) return -1; sp = "full";