Thu Mar 3 06:08:50 2022 UTC ()
usb: Factor usb_transfer_complete out of ubm_abortx method.
(riastradh)
diff -r1.303 -r1.304 src/sys/dev/usb/ehci.c
diff -r1.38 -r1.39 src/sys/dev/usb/motg.c
diff -r1.319 -r1.320 src/sys/dev/usb/ohci.c
diff -r1.309 -r1.310 src/sys/dev/usb/uhci.c
diff -r1.226 -r1.227 src/sys/dev/usb/usbdi.c
diff -r1.156 -r1.157 src/sys/dev/usb/xhci.c
diff -r1.78 -r1.79 src/sys/external/bsd/dwc2/dwc2.c
--- src/sys/dev/usb/ehci.c 2022/03/03 06:04:31 1.303
+++ src/sys/dev/usb/ehci.c 2022/03/03 06:08:50 1.304
@@ -1,4 +1,4 @@
-/* $NetBSD: ehci.c,v 1.303 2022/03/03 06:04:31 riastradh Exp $ */
+/* $NetBSD: ehci.c,v 1.304 2022/03/03 06:08:50 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.303 2022/03/03 06:04:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.304 2022/03/03 06:08:50 riastradh Exp $");
#include "ohci.h"
#include "uhci.h"
@@ -3388,14 +3388,10 @@
BUS_DMASYNC_PREREAD);
}
- /*
- * Final step: Notify completion to waiting xfers.
- */
dying:
#ifdef DIAGNOSTIC
exfer->ex_isdone = true;
#endif
- usb_transfer_complete(xfer);
DPRINTFN(14, "end", 0, 0, 0, 0);
KASSERT(mutex_owned(&sc->sc_lock));
--- src/sys/dev/usb/motg.c 2022/03/03 06:04:31 1.38
+++ src/sys/dev/usb/motg.c 2022/03/03 06:08:50 1.39
@@ -1,4 +1,4 @@
-/* $NetBSD: motg.c,v 1.38 2022/03/03 06:04:31 riastradh Exp $ */
+/* $NetBSD: motg.c,v 1.39 2022/03/03 06:08:50 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.38 2022/03/03 06:04:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.39 2022/03/03 06:08:50 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -2222,6 +2222,5 @@
}
}
dying:
- usb_transfer_complete(xfer);
KASSERT(mutex_owned(&sc->sc_lock));
}
--- src/sys/dev/usb/ohci.c 2022/03/03 06:04:31 1.319
+++ src/sys/dev/usb/ohci.c 2022/03/03 06:08:50 1.320
@@ -1,4 +1,4 @@
-/* $NetBSD: ohci.c,v 1.319 2022/03/03 06:04:31 riastradh Exp $ */
+/* $NetBSD: ohci.c,v 1.320 2022/03/03 06:08:50 riastradh Exp $ */
/*
* Copyright (c) 1998, 2004, 2005, 2012, 2016, 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.319 2022/03/03 06:04:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.320 2022/03/03 06:08:50 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -2409,12 +2409,7 @@
usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_flags),
sizeof(sed->ed.ed_flags),
BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
-
- /*
- * Final step: Notify completion to waiting xfers.
- */
dying:
- usb_transfer_complete(xfer);
DPRINTFN(14, "end", 0, 0, 0, 0);
KASSERT(mutex_owned(&sc->sc_lock));
--- src/sys/dev/usb/uhci.c 2022/03/03 06:04:31 1.309
+++ src/sys/dev/usb/uhci.c 2022/03/03 06:08:50 1.310
@@ -1,4 +1,4 @@
-/* $NetBSD: uhci.c,v 1.309 2022/03/03 06:04:31 riastradh Exp $ */
+/* $NetBSD: uhci.c,v 1.310 2022/03/03 06:08:50 riastradh Exp $ */
/*
* Copyright (c) 1998, 2004, 2011, 2012, 2016, 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.309 2022/03/03 06:04:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.310 2022/03/03 06:08:50 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -2402,15 +2402,10 @@
*/
/* Hardware finishes in 1ms */
usb_delay_ms_locked(upipe->pipe.up_dev->ud_bus, 2, &sc->sc_lock);
-
- /*
- * HC Step 3: Notify completion to waiting xfers.
- */
dying:
#ifdef DIAGNOSTIC
ux->ux_isdone = true;
#endif
- usb_transfer_complete(xfer);
DPRINTFN(14, "end", 0, 0, 0, 0);
KASSERT(mutex_owned(&sc->sc_lock));
--- src/sys/dev/usb/usbdi.c 2022/03/03 06:07:11 1.226
+++ src/sys/dev/usb/usbdi.c 2022/03/03 06:08:50 1.227
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.c,v 1.226 2022/03/03 06:07:11 riastradh Exp $ */
+/* $NetBSD: usbdi.c,v 1.227 2022/03/03 06:08:50 riastradh Exp $ */
/*
* Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.226 2022/03/03 06:07:11 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.227 2022/03/03 06:08:50 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -1533,11 +1533,13 @@
usbd_xfer_cancel_timeout_async(xfer);
/*
- * We beat everyone else. Claim the status as cancelled and do
- * the bus-specific dance to abort the hardware.
+ * We beat everyone else. Claim the status as cancelled, do
+ * the bus-specific dance to abort the hardware, and complete
+ * the xfer.
*/
xfer->ux_status = USBD_CANCELLED;
bus->ub_methods->ubm_abortx(xfer);
+ usb_transfer_complete(xfer);
}
/*
@@ -1617,11 +1619,13 @@
goto out;
/*
- * We beat everyone else. Claim the status as timed out and do
- * the bus-specific dance to abort the hardware.
+ * We beat everyone else. Claim the status as timed out, do
+ * the bus-specific dance to abort the hardware, and complete
+ * the xfer.
*/
xfer->ux_status = USBD_TIMEOUT;
bus->ub_methods->ubm_abortx(xfer);
+ usb_transfer_complete(xfer);
out: /* All done -- release the lock. */
mutex_exit(bus->ub_lock);
--- src/sys/dev/usb/xhci.c 2022/03/03 06:04:31 1.156
+++ src/sys/dev/usb/xhci.c 2022/03/03 06:08:50 1.157
@@ -1,4 +1,4 @@
-/* $NetBSD: xhci.c,v 1.156 2022/03/03 06:04:31 riastradh Exp $ */
+/* $NetBSD: xhci.c,v 1.157 2022/03/03 06:08:50 riastradh Exp $ */
/*
* Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.156 2022/03/03 06:04:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.157 2022/03/03 06:08:50 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -2153,8 +2153,6 @@
"bad abort status: %d", xfer->ux_status);
xhci_pipe_restart(xfer->ux_pipe);
-
- usb_transfer_complete(xfer);
DPRINTFN(14, "end", 0, 0, 0, 0);
}
--- src/sys/external/bsd/dwc2/dwc2.c 2022/03/03 06:04:31 1.78
+++ src/sys/external/bsd/dwc2/dwc2.c 2022/03/03 06:08:50 1.79
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc2.c,v 1.78 2022/03/03 06:04:31 riastradh Exp $ */
+/* $NetBSD: dwc2.c,v 1.79 2022/03/03 06:08:50 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.78 2022/03/03 06:04:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.79 2022/03/03 06:08:50 riastradh Exp $");
#include "opt_usb.h"
@@ -515,7 +515,7 @@
}
/*
- * HC Step 1: Handle the hardware.
+ * Handle the hardware.
*/
err = dwc2_hcd_urb_dequeue(hsotg, dxfer->urb);
if (err) {
@@ -524,11 +524,6 @@
dying:
mutex_spin_exit(&hsotg->lock);
-
- /*
- * Final Step: Notify completion to waiting xfers.
- */
- usb_transfer_complete(xfer);
KASSERT(mutex_owned(&sc->sc_lock));
}