Simplify the freeing of the interrupt pipe transfer. Inspired by OpenBSD.

This commit is contained in:
skrll 2014-08-05 06:35:24 +00:00
parent 6a77b28bb3
commit 9d539301e4
7 changed files with 35 additions and 62 deletions

View File

@ -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 @@ ehci_root_intr_abort(usbd_xfer_handle xfer)
#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 @@ Static void
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

View File

@ -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 @@ motg_root_intr_abort(usbd_xfer_handle xfer)
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);
}

View File

@ -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 @@ ohci_root_intr_abort(usbd_xfer_handle xfer)
#endif
KASSERT(mutex_owned(&sc->sc_lock));
KASSERT(xfer->pipe->intrxfer == xfer);
if (xfer->pipe->intrxfer == xfer) {
DPRINTF(("ohci_root_intr_abort: remove\n"));
xfer->pipe->intrxfer = NULL;
}
xfer->status = USBD_CANCELLED;
usb_transfer_complete(xfer);
}
@ -3256,11 +3253,8 @@ ohci_device_intr_abort(usbd_xfer_handle xfer)
#endif
KASSERT(mutex_owned(&sc->sc_lock));
KASSERT(xfer->pipe->intrxfer == xfer);
if (xfer->pipe->intrxfer == xfer) {
DPRINTF(("ohci_device_intr_abort: remove\n"));
xfer->pipe->intrxfer = NULL;
}
ohci_abort_xfer(xfer, USBD_CANCELLED);
}

View File

@ -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 @@ uhci_device_intr_abort(usbd_xfer_handle xfer)
#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_root_intr_abort(usbd_xfer_handle xfer)
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;

View File

@ -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_status
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_abort_pipe(usbd_pipe_handle pipe)
usbd_lock_pipe(pipe);
err = usbd_ar_pipe(pipe);
usbd_unlock_pipe(pipe);
if (pipe->intrxfer != intrxfer)
usbd_free_xfer(intrxfer);
return (err);
}

View File

@ -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 @@ xhci_root_intr_abort(usbd_xfer_handle xfer)
#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 @@ xhci_device_intr_abort(usbd_xfer_handle xfer)
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);
}

View File

@ -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 @@ dwc2_root_intr_abort(usbd_xfer_handle xfer)
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 @@ dwc2_device_intr_abort(usbd_xfer_handle xfer)
#endif
KASSERT(mutex_owned(&sc->sc_lock));
KASSERT(xfer->pipe->intrxfer == xfer);
if (xfer->pipe->intrxfer == xfer) {
DPRINTF("remove\n");
xfer->pipe->intrxfer = NULL;
}
DPRINTF("xfer=%p\n", xfer);
dwc2_abort_xfer(xfer, USBD_CANCELLED);
}