Module Name:    src
Committed By:   riastradh
Date:           Sat Oct 28 21:18:32 UTC 2023

Modified Files:
        src/sys/dev/usb: ehci.c

Log Message:
ehci(4): Fix bug causing missed wakeups since ehci.c 1.308.

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


To generate a diff of this commit:
cvs rdiff -u -r1.318 -r1.319 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.318 src/sys/dev/usb/ehci.c:1.319
--- src/sys/dev/usb/ehci.c:1.318	Sat Oct 28 21:18:15 2023
+++ src/sys/dev/usb/ehci.c	Sat Oct 28 21:18:31 2023
@@ -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.
@@ -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"
@@ -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);
 }
 
@@ -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");

Reply via email to