Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Acquire bus lock (if not polling) when changing ...



details:   https://anonhg.NetBSD.org/src/rev/b00780be3745
branches:  trunk
changeset: 1005988:b00780be3745
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sun Dec 29 09:17:51 2019 +0000

description:
Acquire bus lock (if not polling) when changing xfer status, resetting
the timeout and ringing the doorbell in the start methods.

diffstat:

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

diffs (96 lines):

diff -r 19e82e979021 -r b00780be3745 sys/dev/usb/xhci.c
--- a/sys/dev/usb/xhci.c        Sun Dec 29 07:31:36 2019 +0000
+++ b/sys/dev/usb/xhci.c        Sun Dec 29 09:17:51 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xhci.c,v 1.114 2019/09/08 18:58:38 mrg Exp $   */
+/*     $NetBSD: xhci.c,v 1.115 2019/12/29 09:17:51 skrll Exp $ */
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.114 2019/09/08 18:58:38 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.115 2019/12/29 09:17:51 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -3897,7 +3897,6 @@
            XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_STATUS_STAGE) |
            XHCI_TRB_3_IOC_BIT;
        xhci_soft_trb_put(&xx->xx_trb[i++], parameter, status, control);
-       xfer->ux_status = USBD_IN_PROGRESS;
 
        if (!polling)
                mutex_enter(&tr->xr_lock);
@@ -3905,12 +3904,17 @@
        if (!polling)
                mutex_exit(&tr->xr_lock);
 
+       if (!polling)
+               mutex_enter(&sc->sc_lock);
+       xfer->ux_status = USBD_IN_PROGRESS;
        xhci_db_write_4(sc, XHCI_DOORBELL(xs->xs_idx), dci);
 
        if (xfer->ux_timeout && !xhci_polling_p(sc)) {
                callout_reset(&xfer->ux_callout, mstohz(xfer->ux_timeout),
                    xhci_timeout, xfer);
        }
+       if (!polling)
+               mutex_exit(&sc->sc_lock);
 
        return USBD_IN_PROGRESS;
 }
@@ -4017,7 +4021,6 @@
            (usbd_xfer_isread(xfer) ? XHCI_TRB_3_ISP_BIT : 0) |
            XHCI_TRB_3_IOC_BIT;
        xhci_soft_trb_put(&xx->xx_trb[i++], parameter, status, control);
-       xfer->ux_status = USBD_IN_PROGRESS;
 
        if (!polling)
                mutex_enter(&tr->xr_lock);
@@ -4025,12 +4028,17 @@
        if (!polling)
                mutex_exit(&tr->xr_lock);
 
+       if (!polling)
+               mutex_enter(&sc->sc_lock);
+       xfer->ux_status = USBD_IN_PROGRESS;
        xhci_db_write_4(sc, XHCI_DOORBELL(xs->xs_idx), dci);
 
        if (xfer->ux_timeout && !xhci_polling_p(sc)) {
                callout_reset(&xfer->ux_callout, mstohz(xfer->ux_timeout),
                    xhci_timeout, xfer);
        }
+       if (!polling)
+               mutex_exit(&sc->sc_lock);
 
        return USBD_IN_PROGRESS;
 }
@@ -4127,7 +4135,6 @@
            (usbd_xfer_isread(xfer) ? XHCI_TRB_3_ISP_BIT : 0) |
            XHCI_TRB_3_IOC_BIT;
        xhci_soft_trb_put(&xx->xx_trb[i++], parameter, status, control);
-       xfer->ux_status = USBD_IN_PROGRESS;
 
        if (!polling)
                mutex_enter(&tr->xr_lock);
@@ -4135,12 +4142,17 @@
        if (!polling)
                mutex_exit(&tr->xr_lock);
 
+       if (!polling)
+               mutex_enter(&sc->sc_lock);
+       xfer->ux_status = USBD_IN_PROGRESS;
        xhci_db_write_4(sc, XHCI_DOORBELL(xs->xs_idx), dci);
 
        if (xfer->ux_timeout && !polling) {
                callout_reset(&xfer->ux_callout, mstohz(xfer->ux_timeout),
                    xhci_timeout, xfer);
        }
+       if (!polling)
+               mutex_exit(&sc->sc_lock);
 
        return USBD_IN_PROGRESS;
 }



Home | Main Index | Thread Index | Old Index