Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Don't hold a spin lock entering usbd_transfer.



details:   https://anonhg.NetBSD.org/src/rev/1f568b2e6bfb
branches:  trunk
changeset: 369885:1f568b2e6bfb
user:      nat <nat%NetBSD.org@localhost>
date:      Tue Sep 06 02:31:08 2022 +0000

description:
Don't hold a spin lock entering usbd_transfer.

This avoids a crash found with LOCKDEBUG.

diffstat:

 sys/dev/usb/udl.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r a13ef23cd758 -r 1f568b2e6bfb sys/dev/usb/udl.c
--- a/sys/dev/usb/udl.c Tue Sep 06 02:28:35 2022 +0000
+++ b/sys/dev/usb/udl.c Tue Sep 06 02:31:08 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: udl.c,v 1.32 2022/09/06 02:28:35 nat Exp $     */
+/*     $NetBSD: udl.c,v 1.33 2022/09/06 02:31:08 nat Exp $     */
 
 /*-
  * Copyright (c) 2009 FUKAUMI Naoki.
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udl.c,v 1.32 2022/09/06 02:28:35 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udl.c,v 1.33 2022/09/06 02:31:08 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1541,7 +1541,9 @@
        mutex_enter(&sc->sc_mtx);
        usbd_setup_xfer(cmdq->cq_xfer, cmdq, cmdq->cq_buf,
            len, 0, USBD_NO_TIMEOUT, udl_cmd_send_async_cb);
+       mutex_exit(&sc->sc_mtx);
        error = usbd_transfer(cmdq->cq_xfer);
+       mutex_enter(&sc->sc_mtx);
        if (error != USBD_NORMAL_COMPLETION && error != USBD_IN_PROGRESS) {
                aprint_error_dev(sc->sc_dev, "%s: %s!\n", __func__,
                    usbd_errstr(error));



Home | Main Index | Thread Index | Old Index