Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb xhci: Fix logic in waiting for command queue acc...



details:   https://anonhg.NetBSD.org/src/rev/1fcbb41a48d1
branches:  trunk
changeset: 379295:1fcbb41a48d1
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed May 26 22:37:21 2021 +0000

description:
xhci: Fix logic in waiting for command queue access.

_Either_ an existing command in progress, _or_ an existing suspend in
progress that is not done by us, should block us; the logic I wrote
previously erroneously blocked only if both conditions happened at
the same time.

Should fix issue reported by Andrius V in the PR kern/56050 followup
discussion.

diffstat:

 sys/dev/usb/xhci.c |  9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diffs (30 lines):

diff -r 34d1a4e2e078 -r 1fcbb41a48d1 sys/dev/usb/xhci.c
--- a/sys/dev/usb/xhci.c        Wed May 26 22:26:16 2021 +0000
+++ b/sys/dev/usb/xhci.c        Wed May 26 22:37:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xhci.c,v 1.140 2021/05/23 21:12:28 riastradh Exp $     */
+/*     $NetBSD: xhci.c,v 1.141 2021/05/26 22:37:21 riastradh Exp $     */
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.140 2021/05/23 21:12:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.141 2021/05/26 22:37:21 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -3194,9 +3194,8 @@ xhci_do_command_locked(struct xhci_softc
        KASSERTMSG(!cpu_intr_p() && !cpu_softintr_p(), "called from intr ctx");
        KASSERT(mutex_owned(&sc->sc_lock));
 
-       while (sc->sc_command_addr != 0 &&
-           sc->sc_suspender != NULL &&
-           sc->sc_suspender != curlwp)
+       while (sc->sc_command_addr != 0 ||
+           (sc->sc_suspender != NULL && sc->sc_suspender != curlwp))
                cv_wait(&sc->sc_cmdbusy_cv, &sc->sc_lock);
 
        /*



Home | Main Index | Thread Index | Old Index