Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/nick-nhusb]: src/sys/dev/usb Strictly follow the sequence abort pipe, de...
details: https://anonhg.NetBSD.org/src/rev/95d8e04351ef
branches: nick-nhusb
changeset: 334351:95d8e04351ef
user: skrll <skrll%NetBSD.org@localhost>
date: Mon Dec 28 09:26:33 2015 +0000
description:
Strictly follow the sequence abort pipe, destroy xfers, and close pipe as
API now requires. Plug some memory leaks in some drivers while doing
this.
Also, remove up_refcnt as it was broken and helped leak more memory.
diffstat:
sys/dev/usb/auvitek_dtv.c | 22 +++++++++++++++---
sys/dev/usb/auvitek_video.c | 11 +++++----
sys/dev/usb/emdtv_dtv.c | 28 +++++++++++++++--------
sys/dev/usb/if_athn_usb.c | 30 ++++++++++++++++++++----
sys/dev/usb/if_atu.c | 31 +++++++++++++++----------
sys/dev/usb/if_aue.c | 35 +++++++++++++++++-----------
sys/dev/usb/if_axe.c | 50 +++++++++++++++++++++++++----------------
sys/dev/usb/if_axen.c | 50 +++++++++++++++++++++++++----------------
sys/dev/usb/if_cdce.c | 30 +++++++++++++++----------
sys/dev/usb/if_cue.c | 54 +++++++++++++++++++++++++--------------------
sys/dev/usb/if_kue.c | 50 +++++++++++++++++++++++++----------------
sys/dev/usb/if_rum.c | 33 ++++++++++-----------------
sys/dev/usb/if_run.c | 10 +++++---
sys/dev/usb/if_smsc.c | 47 +++++++++++++++++++++++---------------
sys/dev/usb/if_udav.c | 33 +++++++++++++++++----------
sys/dev/usb/if_upgt.c | 14 ++++++++---
sys/dev/usb/if_upl.c | 54 +++++++++++++++++++++++++--------------------
sys/dev/usb/if_ural.c | 33 ++++++++++-----------------
sys/dev/usb/if_url.c | 33 +++++++++++++++++----------
sys/dev/usb/if_urndis.c | 31 +++++++++++++++----------
sys/dev/usb/if_urtwn.c | 8 ++----
sys/dev/usb/if_zyd.c | 6 ++--
sys/dev/usb/irmce.c | 26 +++++++++++++--------
sys/dev/usb/pseye.c | 10 +++++--
sys/dev/usb/uaudio.c | 30 +++++++++++++++++++-----
sys/dev/usb/ubt.c | 39 ++++++++++++++++++++++----------
sys/dev/usb/ucom.c | 14 ++++++++++-
sys/dev/usb/udl.c | 9 +++++--
sys/dev/usb/udsir.c | 33 +++++++++++++++++++++-----
sys/dev/usb/ugen.c | 8 +++---
sys/dev/usb/uhso.c | 39 ++++++++++++++++++--------------
sys/dev/usb/uirda.c | 32 ++++++++++++++++++++-----
sys/dev/usb/ulpt.c | 17 ++++++++-----
sys/dev/usb/umass.c | 17 ++++++++++----
sys/dev/usb/umidi.c | 6 ++--
sys/dev/usb/usb_subr.c | 5 +--
sys/dev/usb/usbdi.c | 28 ++++++++++++----------
sys/dev/usb/usbdivar.h | 3 +-
sys/dev/usb/uscanner.c | 27 ++++++++++++----------
sys/dev/usb/usscanner.c | 28 +++++++++++-----------
sys/dev/usb/ustir.c | 30 ++++++++++++++++++++----
sys/dev/usb/utoppy.c | 13 +++++-----
sys/dev/usb/uvideo.c | 17 +++++++++-----
43 files changed, 693 insertions(+), 431 deletions(-)
diffs (truncated from 2658 to 300 lines):
diff -r 031f4176c64c -r 95d8e04351ef sys/dev/usb/auvitek_dtv.c
--- a/sys/dev/usb/auvitek_dtv.c Mon Dec 28 09:20:24 2015 +0000
+++ b/sys/dev/usb/auvitek_dtv.c Mon Dec 28 09:26:33 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek_dtv.c,v 1.6.14.4 2015/10/06 21:32:15 skrll Exp $ */
+/* $NetBSD: auvitek_dtv.c,v 1.6.14.5 2015/12/28 09:26:33 skrll Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.6.14.4 2015/10/06 21:32:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.6.14.5 2015/12/28 09:26:33 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -66,6 +66,7 @@
static int auvitek_dtv_stop_transfer(void *);
static int auvitek_dtv_init_pipes(struct auvitek_softc *);
+static int auvitek_dtv_abort_pipes(struct auvitek_softc *);
static int auvitek_dtv_close_pipes(struct auvitek_softc *);
static int auvitek_dtv_bulk_start(struct auvitek_softc *);
@@ -180,13 +181,15 @@
struct auvitek_softc *sc = priv;
auvitek_dtv_stop_transfer(sc);
- auvitek_dtv_close_pipes(sc);
+ auvitek_dtv_abort_pipes(sc);
for (size_t i = 0; i < AUVITEK_NBULK_XFERS; i++) {
if (sc->sc_ab.ab_bx[i].bx_xfer)
usbd_destroy_xfer(sc->sc_ab.ab_bx[i].bx_xfer);
}
+ auvitek_dtv_close_pipes(sc);
+
sc->sc_dtvsubmitcb = NULL;
sc->sc_dtvsubmitarg = NULL;
}
@@ -295,11 +298,22 @@
}
static int
+auvitek_dtv_abort_pipes(struct auvitek_softc *sc)
+{
+ if (sc->sc_ab.ab_pipe != NULL) {
+ KERNEL_LOCK(1, curlwp);
+ usbd_abort_pipe(sc->sc_ab.ab_pipe);
+ KERNEL_UNLOCK_ONE(curlwp);
+ }
+
+ return 0;
+}
+
+static int
auvitek_dtv_close_pipes(struct auvitek_softc *sc)
{
if (sc->sc_ab.ab_pipe != NULL) {
KERNEL_LOCK(1, curlwp);
- usbd_abort_pipe(sc->sc_ab.ab_pipe);
usbd_close_pipe(sc->sc_ab.ab_pipe);
KERNEL_UNLOCK_ONE(curlwp);
sc->sc_ab.ab_pipe = NULL;
diff -r 031f4176c64c -r 95d8e04351ef sys/dev/usb/auvitek_video.c
--- a/sys/dev/usb/auvitek_video.c Mon Dec 28 09:20:24 2015 +0000
+++ b/sys/dev/usb/auvitek_video.c Mon Dec 28 09:26:33 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek_video.c,v 1.6.32.4 2015/10/06 21:32:15 skrll Exp $ */
+/* $NetBSD: auvitek_video.c,v 1.6.32.5 2015/12/28 09:26:33 skrll Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek_video.c,v 1.6.32.4 2015/10/06 21:32:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek_video.c,v 1.6.32.5 2015/12/28 09:26:33 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -607,10 +607,7 @@
if (ax->ax_pipe != NULL) {
usbd_abort_pipe(ax->ax_pipe);
- usbd_close_pipe(ax->ax_pipe);
- ax->ax_pipe = NULL;
}
-
for (i = 0; i < AUVITEK_NISOC_XFERS; i++) {
struct auvitek_isoc *isoc = &ax->ax_i[i];
if (isoc->i_xfer != NULL) {
@@ -623,6 +620,10 @@
isoc->i_frlengths = NULL;
}
}
+ if (ax->ax_pipe != NULL) {
+ usbd_close_pipe(ax->ax_pipe);
+ ax->ax_pipe = NULL;
+ }
usbd_delay_ms(sc->sc_udev, 1000);
err = usbd_set_interface(sc->sc_isoc_iface, 0);
diff -r 031f4176c64c -r 95d8e04351ef sys/dev/usb/emdtv_dtv.c
--- a/sys/dev/usb/emdtv_dtv.c Mon Dec 28 09:20:24 2015 +0000
+++ b/sys/dev/usb/emdtv_dtv.c Mon Dec 28 09:26:33 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emdtv_dtv.c,v 1.10.14.4 2015/10/06 21:32:15 skrll Exp $ */
+/* $NetBSD: emdtv_dtv.c,v 1.10.14.5 2015/12/28 09:26:33 skrll Exp $ */
/*-
* Copyright (c) 2008, 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emdtv_dtv.c,v 1.10.14.4 2015/10/06 21:32:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emdtv_dtv.c,v 1.10.14.5 2015/12/28 09:26:33 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -125,6 +125,20 @@
emdtv_dtv_rescan(sc, NULL, NULL);
}
+static void
+emdtv_dtv_free_xfers(struct emdtv_softc *sc)
+{
+
+ for (size_t i = 0; i < EMDTV_NXFERS; i++)
+ if (sc->sc_ix[i].ix_xfer) {
+ usbd_destroy_xfer(sc->sc_ix[i].ix_xfer);
+ sc->sc_ix[i].ix_xfer = NULL;
+ sc->sc_ix[i].ix_buf = NULL;
+ }
+
+ return;
+}
+
void
emdtv_dtv_detach(struct emdtv_softc *sc, int flags)
{
@@ -142,6 +156,7 @@
if (sc->sc_isoc_pipe) {
usbd_abort_pipe(sc->sc_isoc_pipe);
+ emdtv_dtv_free_xfers(sc);
usbd_close_pipe(sc->sc_isoc_pipe);
sc->sc_isoc_pipe = NULL;
}
@@ -250,14 +265,7 @@
{
struct emdtv_softc *sc = priv;
- for (size_t i = 0; i < EMDTV_NXFERS; i++)
- if (sc->sc_ix[i].ix_xfer) {
- usbd_destroy_xfer(sc->sc_ix[i].ix_xfer);
- sc->sc_ix[i].ix_xfer = NULL;
- sc->sc_ix[i].ix_buf = NULL;
- }
-
- return;
+ emdtv_dtv_free_xfers(sc);
}
static int
diff -r 031f4176c64c -r 95d8e04351ef sys/dev/usb/if_athn_usb.c
--- a/sys/dev/usb/if_athn_usb.c Mon Dec 28 09:20:24 2015 +0000
+++ b/sys/dev/usb/if_athn_usb.c Mon Dec 28 09:26:33 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_athn_usb.c,v 1.6.8.7 2015/10/17 10:24:59 skrll Exp $ */
+/* $NetBSD: if_athn_usb.c,v 1.6.8.8 2015/12/28 09:26:33 skrll Exp $ */
/* $OpenBSD: if_athn_usb.c,v 1.12 2013/01/14 09:50:31 jsing Exp $ */
/*-
@@ -22,7 +22,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.8.7 2015/10/17 10:24:59 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.8.8 2015/12/28 09:26:33 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -98,6 +98,7 @@
Static void athn_usb_attachhook(device_t);
Static void athn_usb_bcneof(struct usbd_xfer *, void *,
usbd_status);
+Static void athn_usb_abort_pipes(struct athn_usb_softc *);
Static void athn_usb_close_pipes(struct athn_usb_softc *);
Static int athn_usb_create_hw_node(struct athn_usb_softc *,
struct ar_htc_target_sta *);
@@ -309,6 +310,7 @@
fail:
/* Free Tx/Rx buffers. */
+ athn_usb_abort_pipes(usc);
athn_usb_free_tx_list(usc);
athn_usb_free_rx_list(usc);
athn_usb_free_tx_cmd(usc);
@@ -456,8 +458,8 @@
usc->usc_athn_attached = 0;
athn_detach(sc);
}
- /* Abort and close Tx/Rx pipes. */
- athn_usb_close_pipes(usc);
+ /* Abort Tx/Rx pipes. */
+ athn_usb_abort_pipes(usc);
splx(s);
/* Free Tx/Rx buffers. */
@@ -465,6 +467,9 @@
athn_usb_free_tx_list(usc);
athn_usb_free_tx_cmd(usc);
+ /* Close Tx/Rx pipes. */
+ athn_usb_close_pipes(usc);
+
mutex_destroy(&usc->usc_tx_mtx);
mutex_destroy(&usc->usc_task_mtx);
cv_destroy(&usc->usc_task_cv);
@@ -551,6 +556,7 @@
}
return 0;
fail:
+ athn_usb_abort_pipes(usc);
athn_usb_close_pipes(usc);
return error;
}
@@ -563,12 +569,26 @@
CTASSERT(sizeof(pipe) == sizeof(void *));
pipe = atomic_swap_ptr(pipeptr, NULL);
if (pipe != NULL) {
- usbd_abort_pipe(pipe);
usbd_close_pipe(pipe);
}
}
Static void
+athn_usb_abort_pipes(struct athn_usb_softc *usc)
+{
+ DPRINTFN(DBG_FN, usc, "\n");
+
+ if (usc->usc_tx_data_pipe != NULL)
+ usbd_abort_pipe(usc->usc_tx_data_pipe);
+ if (usc->usc_rx_data_pipe != NULL)
+ usbd_abort_pipe(usc->usc_rx_data_pipe);
+ if (usc->usc_tx_intr_pipe != NULL)
+ usbd_abort_pipe(usc->usc_tx_intr_pipe);
+ if (usc->usc_rx_intr_pipe != NULL)
+ usbd_abort_pipe(usc->usc_rx_intr_pipe);
+}
+
+Static void
athn_usb_close_pipes(struct athn_usb_softc *usc)
{
uint8_t *ibuf;
diff -r 031f4176c64c -r 95d8e04351ef sys/dev/usb/if_atu.c
--- a/sys/dev/usb/if_atu.c Mon Dec 28 09:20:24 2015 +0000
+++ b/sys/dev/usb/if_atu.c Mon Dec 28 09:26:33 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_atu.c,v 1.50.2.10 2015/12/19 10:11:13 skrll Exp $ */
+/* $NetBSD: if_atu.c,v 1.50.2.11 2015/12/28 09:26:33 skrll Exp $ */
/* $OpenBSD: if_atu.c,v 1.48 2004/12/30 01:53:21 dlg Exp $ */
/*
* Copyright (c) 2003, 2004
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_atu.c,v 1.50.2.10 2015/12/19 10:11:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_atu.c,v 1.50.2.11 2015/12/28 09:26:33 skrll Exp $");
#include <sys/param.h>
#include <sys/sockio.h>
@@ -2247,6 +2247,23 @@
DPRINTF(("%s: abort rx pipe failed: %s\n",
device_xname(sc->atu_dev), usbd_errstr(err)));
}
+ }
+
+ if (sc->atu_ep[ATU_ENDPT_TX] != NULL) {
+ err = usbd_abort_pipe(sc->atu_ep[ATU_ENDPT_TX]);
+ if (err) {
+ DPRINTF(("%s: abort tx pipe failed: %s\n",
+ device_xname(sc->atu_dev), usbd_errstr(err)));
+ }
+ }
+
+ /* Free RX/TX/MGMT list resources. */
+ cd = &sc->atu_cdata;
+ atu_xfer_list_free(sc, cd->atu_rx_chain, ATU_RX_LIST_CNT);
+ atu_xfer_list_free(sc, cd->atu_tx_chain, ATU_TX_LIST_CNT);
+
+ /* Close pipes */
+ if (sc->atu_ep[ATU_ENDPT_RX] != NULL) {
Home |
Main Index |
Thread Index |
Old Index