Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Fix mistake in use of usbd_xfer_schedule_timeout...



details:   https://anonhg.NetBSD.org/src/rev/a9244a191c8c
branches:  trunk
changeset: 1007601:a9244a191c8c
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Feb 23 08:54:47 2020 +0000

description:
Fix mistake in use of usbd_xfer_schedule_timeout in motg.

This code path is used both for xfers that are new, and xfers that
are being done piece by piece and are partway done.  For the latter
case, skip usbd_xfer_schedule_timeout so we schedule it only once per
xfer.

diffstat:

 sys/dev/usb/motg.c |  20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diffs (48 lines):

diff -r 056af8691f7a -r a9244a191c8c sys/dev/usb/motg.c
--- a/sys/dev/usb/motg.c        Sun Feb 23 08:53:25 2020 +0000
+++ b/sys/dev/usb/motg.c        Sun Feb 23 08:54:47 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: motg.c,v 1.31 2020/02/19 16:01:37 riastradh Exp $      */
+/*     $NetBSD: motg.c,v 1.32 2020/02/23 08:54:47 riastradh Exp $      */
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012, 2014 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.31 2020/02/19 16:01:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.32 2020/02/23 08:54:47 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1350,8 +1350,12 @@
                err = USBD_NOT_STARTED;
                goto end;
        }
-       usbd_xfer_schedule_timeout(xfer);
-       xfer->ux_status = USBD_IN_PROGRESS;
+       if (xfer->ux_status == USBD_NOT_STARTED) {
+               usbd_xfer_schedule_timeout(xfer);
+               xfer->ux_status = USBD_IN_PROGRESS;
+       } else {
+               KASSERT(xfer->ux_status == USBD_IN_PROGRESS);
+       }
        KASSERT(otgpipe == MOTG_PIPE2MPIPE(xfer->ux_pipe));
        KASSERT(otgpipe->hw_ep == ep);
        KASSERT(xfer->ux_rqflags & URQ_REQUEST);
@@ -1807,8 +1811,12 @@
                err = USBD_NOT_STARTED;
                goto end;
        }
-       usbd_xfer_schedule_timeout(xfer);
-       xfer->ux_status = USBD_IN_PROGRESS;
+       if (xfer->ux_status == USBD_NOT_STARTED) {
+               usbd_xfer_schedule_timeout(xfer);
+               xfer->ux_status = USBD_IN_PROGRESS;
+       } else {
+               KASSERT(xfer->ux_status == USBD_IN_PROGRESS);
+       }
        KASSERT(otgpipe == MOTG_PIPE2MPIPE(xfer->ux_pipe));
        KASSERT(otgpipe->hw_ep == ep);
        KASSERT(!(xfer->ux_rqflags & URQ_REQUEST));



Home | Main Index | Thread Index | Old Index