Module Name: src Committed By: riastradh Date: Sat Oct 28 21:18:15 UTC 2023
Modified Files: src/sys/dev/usb: ehci.c Log Message: 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 port-i386/57662 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.317 -r1.318 src/sys/dev/usb/ehci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/ehci.c diff -u src/sys/dev/usb/ehci.c:1.317 src/sys/dev/usb/ehci.c:1.318 --- src/sys/dev/usb/ehci.c:1.317 Sun Jul 30 12:17:02 2023 +++ src/sys/dev/usb/ehci.c Sat Oct 28 21:18:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ehci.c,v 1.317 2023/07/30 12:17:02 skrll Exp $ */ +/* $NetBSD: ehci.c,v 1.318 2023/10/28 21:18:15 riastradh Exp $ */ /* * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc. @@ -54,7 +54,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.317 2023/07/30 12:17:02 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.318 2023/10/28 21:18:15 riastradh Exp $"); #include "ohci.h" #include "uhci.h" @@ -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);