Skip to content

Commit

Permalink
ehci(4): Fix bug causing missed wakeups since ehci.c 1.308.
Browse files Browse the repository at this point in the history
For reasons beyond me now, I used cv_signal on the same cv that is
used to wait for the doorbell to be available _and_ to wait for the
host controller to acknowledge the doorbell.  Which means when the
host controller acknowledges the doorbell, we might wake some thread
waiting for the doorbell to be available -- and leave the thread
waiting for the doorbell acknowledgment hanging indefinitely.

PR port-i386/57662

XXX pullup-10
  • Loading branch information
riastradh authored and riastradh committed Oct 28, 2023
1 parent b436790 commit 95b733a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sys/dev/usb/ehci.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: ehci.c,v 1.318 2023/10/28 21:18:15 riastradh Exp $ */
/* $NetBSD: ehci.c,v 1.319 2023/10/28 21:18:31 riastradh Exp $ */

/*
* Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
Expand Down Expand Up @@ -54,7 +54,7 @@
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.318 2023/10/28 21:18:15 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.319 2023/10/28 21:18:31 riastradh Exp $");

#include "ohci.h"
#include "uhci.h"
Expand Down Expand Up @@ -826,7 +826,7 @@ ehci_doorbell(void *addr)
if (sc->sc_doorbelllwp == NULL)
DPRINTF("spurious doorbell interrupt", 0, 0, 0, 0);
sc->sc_doorbelllwp = NULL;
cv_signal(&sc->sc_doorbell);
cv_broadcast(&sc->sc_doorbell);
mutex_exit(&sc->sc_lock);
}

Expand Down Expand Up @@ -2279,7 +2279,7 @@ ehci_sync_hc(ehci_softc_t *sc)
now = getticks();
if (now - starttime >= delta) {
sc->sc_doorbelllwp = NULL;
cv_signal(&sc->sc_doorbell);
cv_broadcast(&sc->sc_doorbell);
DPRINTF("doorbell timeout", 0, 0, 0, 0);
#ifdef DIAGNOSTIC /* XXX DIAGNOSTIC abuse, do this differently */
printf("ehci_sync_hc: timed out\n");
Expand Down

0 comments on commit 95b733a

Please sign in to comment.