NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-i386/57662: StarTech ICUSB23208FD 8-Port USB-to-Serial Adapter Hub fails on Alix with NetBSD/i386 9.3



Can you please try the attached patch and see if it makes a
difference?

Note that it might not fix whatever the underlying problem is, but it
should at least cause the timeout on ehci sync to work instead of
hanging forever.
From 2ccb4d42055737abfb68af0222d8871cbbc8cb6e Mon Sep 17 00:00:00 2001
From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
Date: Sat, 28 Oct 2023 01:42:37 +0000
Subject: [PATCH] ehci(4): Fix cv_timedwait loop in ehci_sync_hc.

Stop when

	now - starttime >= delta,

i.e., when at least delta ticks have elapsed since the start, not
when

	endtime - now > delta,

i.e., more than delta ticks _remain_ to sleep, which is never going
to happen (except on arithmetic overflow).

As is, what will happen in the case that should time out is that we
wake up after delta ticks, and find now = getticks() is exactly
endtime, so we retry cv_timedwait with timo=(endtime - now)=0 which
means sleep indefinitely with no timeout as if with cv_wait.

PR kern/57662

XXX pullup-10
---
 sys/dev/usb/ehci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c
index 111957b34bd8..b59ad33b6395 100644
--- a/sys/dev/usb/ehci.c
+++ b/sys/dev/usb/ehci.c
@@ -2277,7 +2277,7 @@ ehci_sync_hc(ehci_softc_t *sc)
 	 */
 	while (sc->sc_doorbelllwp == curlwp) {
 		now = getticks();
-		if (endtime - now > delta) {
+		if (now - starttime >= delta) {
 			sc->sc_doorbelllwp = NULL;
 			cv_signal(&sc->sc_doorbell);
 			DPRINTF("doorbell timeout", 0, 0, 0, 0);


Home | Main Index | Thread Index | Old Index