Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Simplify the freeing of the interrupt pipe transfer. In...
details: https://anonhg.NetBSD.org/src/rev/4df8543d25e7
branches: trunk
changeset: 331189:4df8543d25e7
user: skrll <skrll%NetBSD.org@localhost>
date: Tue Aug 05 06:35:24 2014 +0000
description:
Simplify the freeing of the interrupt pipe transfer. Inspired by OpenBSD.
diffstat:
sys/dev/usb/ehci.c | 18 ++++++++----------
sys/dev/usb/motg.c | 11 ++++-------
sys/dev/usb/ohci.c | 18 ++++++------------
sys/dev/usb/uhci.c | 15 +++++----------
sys/dev/usb/usbdi.c | 7 ++-----
sys/dev/usb/xhci.c | 17 +++++++----------
sys/external/bsd/dwc2/dwc2.c | 15 +++++----------
7 files changed, 37 insertions(+), 64 deletions(-)
diffs (truncated from 305 to 300 lines):
diff -r 7dd699d80fc1 -r 4df8543d25e7 sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c Tue Aug 05 06:24:56 2014 +0000
+++ b/sys/dev/usb/ehci.c Tue Aug 05 06:35:24 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ehci.c,v 1.226 2014/08/04 06:17:04 skrll Exp $ */
+/* $NetBSD: ehci.c,v 1.227 2014/08/05 06:35:24 skrll Exp $ */
/*
* Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.226 2014/08/04 06:17:04 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.227 2014/08/05 06:35:24 skrll Exp $");
#include "ohci.h"
#include "uhci.h"
@@ -2609,10 +2609,10 @@
#endif
KASSERT(mutex_owned(&sc->sc_lock));
- if (xfer->pipe->intrxfer == xfer) {
- DPRINTF(("ehci_root_intr_abort: remove\n"));
- xfer->pipe->intrxfer = NULL;
- }
+ KASSERT(xfer->pipe->intrxfer == xfer);
+
+ sc->sc_intrxfer = NULL;
+
xfer->status = USBD_CANCELLED;
usb_transfer_complete(xfer);
}
@@ -3832,10 +3832,8 @@
ehci_device_intr_abort(usbd_xfer_handle xfer)
{
DPRINTFN(1, ("ehci_device_intr_abort: xfer=%p\n", xfer));
- if (xfer->pipe->intrxfer == xfer) {
- DPRINTFN(1, ("echi_device_intr_abort: remove\n"));
- xfer->pipe->intrxfer = NULL;
- }
+ KASSERT(xfer->pipe->intrxfer == xfer);
+
/*
* XXX - abort_xfer uses ehci_sync_hc, which syncs via the advance
* async doorbell. That's dependent on the async list, wheras
diff -r 7dd699d80fc1 -r 4df8543d25e7 sys/dev/usb/motg.c
--- a/sys/dev/usb/motg.c Tue Aug 05 06:24:56 2014 +0000
+++ b/sys/dev/usb/motg.c Tue Aug 05 06:35:24 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: motg.c,v 1.4 2014/07/25 21:16:31 joerg Exp $ */
+/* $NetBSD: motg.c,v 1.5 2014/08/05 06:35:24 skrll 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.4 2014/07/25 21:16:31 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.5 2014/08/05 06:35:24 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1185,17 +1185,14 @@
struct motg_softc *sc = xfer->pipe->device->bus->hci_private;
KASSERT(mutex_owned(&sc->sc_lock));
+ KASSERT(xfer->pipe->intrxfer == xfer);
sc->sc_intr_xfer = NULL;
- if (xfer->pipe->intrxfer == xfer) {
- DPRINTFN(MD_ROOT, ("motg_root_intr_abort: remove\n"));
- xfer->pipe->intrxfer = 0;
- }
- xfer->status = USBD_CANCELLED;
#ifdef DIAGNOSTIC
// XXX UXFER(xfer)->iinfo.isdone = 1;
#endif
+ xfer->status = USBD_CANCELLED;
usb_transfer_complete(xfer);
}
diff -r 7dd699d80fc1 -r 4df8543d25e7 sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c Tue Aug 05 06:24:56 2014 +0000
+++ b/sys/dev/usb/ohci.c Tue Aug 05 06:35:24 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ohci.c,v 1.250 2014/02/17 07:34:21 skrll Exp $ */
+/* $NetBSD: ohci.c,v 1.251 2014/08/05 06:35:24 skrll Exp $ */
/*
* Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.250 2014/02/17 07:34:21 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.251 2014/08/05 06:35:24 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -2870,11 +2870,8 @@
#endif
KASSERT(mutex_owned(&sc->sc_lock));
-
- if (xfer->pipe->intrxfer == xfer) {
- DPRINTF(("ohci_root_intr_abort: remove\n"));
- xfer->pipe->intrxfer = NULL;
- }
+ KASSERT(xfer->pipe->intrxfer == xfer);
+
xfer->status = USBD_CANCELLED;
usb_transfer_complete(xfer);
}
@@ -3256,11 +3253,8 @@
#endif
KASSERT(mutex_owned(&sc->sc_lock));
-
- if (xfer->pipe->intrxfer == xfer) {
- DPRINTF(("ohci_device_intr_abort: remove\n"));
- xfer->pipe->intrxfer = NULL;
- }
+ KASSERT(xfer->pipe->intrxfer == xfer);
+
ohci_abort_xfer(xfer, USBD_CANCELLED);
}
diff -r 7dd699d80fc1 -r 4df8543d25e7 sys/dev/usb/uhci.c
--- a/sys/dev/usb/uhci.c Tue Aug 05 06:24:56 2014 +0000
+++ b/sys/dev/usb/uhci.c Tue Aug 05 06:35:24 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uhci.c,v 1.263 2013/12/01 07:28:48 skrll Exp $ */
+/* $NetBSD: uhci.c,v 1.264 2014/08/05 06:35:24 skrll Exp $ */
/*
* Copyright (c) 1998, 2004, 2011, 2012 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.263 2013/12/01 07:28:48 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.264 2014/08/05 06:35:24 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -2451,12 +2451,10 @@
#endif
KASSERT(mutex_owned(&sc->sc_lock));
+ KASSERT(xfer->pipe->intrxfer == xfer);
DPRINTFN(1,("uhci_device_intr_abort: xfer=%p\n", xfer));
- if (xfer->pipe->intrxfer == xfer) {
- DPRINTFN(1,("uhci_device_intr_abort: remove\n"));
- xfer->pipe->intrxfer = NULL;
- }
+
uhci_abort_xfer(xfer, USBD_CANCELLED);
}
@@ -3920,14 +3918,11 @@
uhci_softc_t *sc = xfer->pipe->device->bus->hci_private;
KASSERT(mutex_owned(&sc->sc_lock));
+ KASSERT(xfer->pipe->intrxfer == xfer);
callout_stop(&sc->sc_poll_handle);
sc->sc_intr_xfer = NULL;
- if (xfer->pipe->intrxfer == xfer) {
- DPRINTF(("uhci_root_intr_abort: remove\n"));
- xfer->pipe->intrxfer = 0;
- }
xfer->status = USBD_CANCELLED;
#ifdef DIAGNOSTIC
UXFER(xfer)->iinfo.isdone = 1;
diff -r 7dd699d80fc1 -r 4df8543d25e7 sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c Tue Aug 05 06:24:56 2014 +0000
+++ b/sys/dev/usb/usbdi.c Tue Aug 05 06:35:24 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.c,v 1.160 2013/11/30 12:16:14 skrll Exp $ */
+/* $NetBSD: usbdi.c,v 1.161 2014/08/05 06:35:24 skrll Exp $ */
/*
* Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.160 2013/11/30 12:16:14 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.161 2014/08/05 06:35:24 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -548,7 +548,6 @@
usbd_abort_pipe(usbd_pipe_handle pipe)
{
usbd_status err;
- usbd_xfer_handle intrxfer = pipe->intrxfer;
#ifdef DIAGNOSTIC
if (pipe == NULL) {
@@ -559,8 +558,6 @@
usbd_lock_pipe(pipe);
err = usbd_ar_pipe(pipe);
usbd_unlock_pipe(pipe);
- if (pipe->intrxfer != intrxfer)
- usbd_free_xfer(intrxfer);
return (err);
}
diff -r 7dd699d80fc1 -r 4df8543d25e7 sys/dev/usb/xhci.c
--- a/sys/dev/usb/xhci.c Tue Aug 05 06:24:56 2014 +0000
+++ b/sys/dev/usb/xhci.c Tue Aug 05 06:35:24 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xhci.c,v 1.20 2014/07/26 00:17:57 pgoyette Exp $ */
+/* $NetBSD: xhci.c,v 1.21 2014/08/05 06:35:24 skrll Exp $ */
/*
* Copyright (c) 2013 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.20 2014/07/26 00:17:57 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.21 2014/08/05 06:35:24 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -2457,10 +2457,10 @@
#endif
KASSERT(mutex_owned(&sc->sc_lock));
- if (xfer->pipe->intrxfer == xfer) {
- DPRINTF(("%s: remove\n", __func__));
- xfer->pipe->intrxfer = NULL;
- }
+ KASSERT(xfer->pipe->intrxfer == xfer);
+
+ DPRINTF(("%s: remove\n", __func__));
+
xfer->status = USBD_CANCELLED;
usb_transfer_complete(xfer);
}
@@ -2865,10 +2865,7 @@
KASSERT(mutex_owned(&sc->sc_lock));
device_printf(sc->sc_dev, "%s %p\n", __func__, xfer);
- /* XXX */
- if (xfer->pipe->intrxfer == xfer) {
- xfer->pipe->intrxfer = NULL;
- }
+ KASSERT(xfer->pipe->intrxfer == xfer);
xfer->status = USBD_CANCELLED;
usb_transfer_complete(xfer);
}
diff -r 7dd699d80fc1 -r 4df8543d25e7 sys/external/bsd/dwc2/dwc2.c
--- a/sys/external/bsd/dwc2/dwc2.c Tue Aug 05 06:24:56 2014 +0000
+++ b/sys/external/bsd/dwc2/dwc2.c Tue Aug 05 06:35:24 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc2.c,v 1.28 2014/06/28 07:01:51 skrll Exp $ */
+/* $NetBSD: dwc2.c,v 1.29 2014/08/05 06:35:24 skrll Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.28 2014/06/28 07:01:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.29 2014/08/05 06:35:24 skrll Exp $");
#include "opt_usb.h"
@@ -910,11 +910,8 @@
DPRINTF("xfer=%p\n", xfer);
KASSERT(mutex_owned(&sc->sc_lock));
+ KASSERT(xfer->pipe->intrxfer == xfer);
- if (xfer->pipe->intrxfer == xfer) {
- DPRINTF("remove\n");
- xfer->pipe->intrxfer = NULL;
- }
xfer->status = USBD_CANCELLED;
usb_transfer_complete(xfer);
}
@@ -1124,12 +1121,10 @@
#endif
KASSERT(mutex_owned(&sc->sc_lock));
+ KASSERT(xfer->pipe->intrxfer == xfer);
- if (xfer->pipe->intrxfer == xfer) {
- DPRINTF("remove\n");
- xfer->pipe->intrxfer = NULL;
- }
Home |
Main Index |
Thread Index |
Old Index