Module Name: src
Committed By: riastradh
Date: Thu Mar 3 06:08:50 UTC 2022
Modified Files:
src/sys/dev/usb: ehci.c motg.c ohci.c uhci.c usbdi.c xhci.c
src/sys/external/bsd/dwc2: dwc2.c
Log Message:
usb: Factor usb_transfer_complete out of ubm_abortx method.
To generate a diff of this commit:
cvs rdiff -u -r1.303 -r1.304 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/usb/motg.c
cvs rdiff -u -r1.319 -r1.320 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.309 -r1.310 src/sys/dev/usb/uhci.c
cvs rdiff -u -r1.226 -r1.227 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.156 -r1.157 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.78 -r1.79 src/sys/external/bsd/dwc2/dwc2.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.303 src/sys/dev/usb/ehci.c:1.304
--- src/sys/dev/usb/ehci.c:1.303 Thu Mar 3 06:04:31 2022
+++ src/sys/dev/usb/ehci.c Thu Mar 3 06:08:50 2022
@@ -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 @@ ehci_abortx(struct usbd_xfer *xfer)
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));
Index: src/sys/dev/usb/motg.c
diff -u src/sys/dev/usb/motg.c:1.38 src/sys/dev/usb/motg.c:1.39
--- src/sys/dev/usb/motg.c:1.38 Thu Mar 3 06:04:31 2022
+++ src/sys/dev/usb/motg.c Thu Mar 3 06:08:50 2022
@@ -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 @@ motg_abortx(struct usbd_xfer *xfer)
}
}
dying:
- usb_transfer_complete(xfer);
KASSERT(mutex_owned(&sc->sc_lock));
}
Index: src/sys/dev/usb/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.319 src/sys/dev/usb/ohci.c:1.320
--- src/sys/dev/usb/ohci.c:1.319 Thu Mar 3 06:04:31 2022
+++ src/sys/dev/usb/ohci.c Thu Mar 3 06:08:50 2022
@@ -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 @@ ohci_abortx(struct usbd_xfer *xfer)
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));
Index: src/sys/dev/usb/uhci.c
diff -u src/sys/dev/usb/uhci.c:1.309 src/sys/dev/usb/uhci.c:1.310
--- src/sys/dev/usb/uhci.c:1.309 Thu Mar 3 06:04:31 2022
+++ src/sys/dev/usb/uhci.c Thu Mar 3 06:08:50 2022
@@ -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 @@ uhci_abortx(struct usbd_xfer *xfer)
*/
/* 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));
Index: src/sys/dev/usb/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.226 src/sys/dev/usb/usbdi.c:1.227
--- src/sys/dev/usb/usbdi.c:1.226 Thu Mar 3 06:07:11 2022
+++ src/sys/dev/usb/usbdi.c Thu Mar 3 06:08:50 2022
@@ -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_abort(struct usbd_xfer *xfer)
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 @@ usbd_xfer_timeout_task(void *cookie)
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);
Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.156 src/sys/dev/usb/xhci.c:1.157
--- src/sys/dev/usb/xhci.c:1.156 Thu Mar 3 06:04:31 2022
+++ src/sys/dev/usb/xhci.c Thu Mar 3 06:08:50 2022
@@ -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"
@@ -2154,8 +2154,6 @@ xhci_abortx(struct usbd_xfer *xfer)
xhci_pipe_restart(xfer->ux_pipe);
- usb_transfer_complete(xfer);
-
DPRINTFN(14, "end", 0, 0, 0, 0);
}
Index: src/sys/external/bsd/dwc2/dwc2.c
diff -u src/sys/external/bsd/dwc2/dwc2.c:1.78 src/sys/external/bsd/dwc2/dwc2.c:1.79
--- src/sys/external/bsd/dwc2/dwc2.c:1.78 Thu Mar 3 06:04:31 2022
+++ src/sys/external/bsd/dwc2/dwc2.c Thu Mar 3 06:08:50 2022
@@ -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 @@ dwc2_abortx(struct usbd_xfer *xfer)
}
/*
- * HC Step 1: Handle the hardware.
+ * Handle the hardware.
*/
err = dwc2_hcd_urb_dequeue(hsotg, dxfer->urb);
if (err) {
@@ -524,11 +524,6 @@ dwc2_abortx(struct usbd_xfer *xfer)
dying:
mutex_spin_exit(&hsotg->lock);
-
- /*
- * Final Step: Notify completion to waiting xfers.
- */
- usb_transfer_complete(xfer);
KASSERT(mutex_owned(&sc->sc_lock));
}