Module Name:    src
Committed By:   jmcneill
Date:           Sat Jan 12 23:26:06 UTC 2013

Modified Files:
        src/sys/dev/usb: dwc_otg.c dwc_otgvar.h

Log Message:
use a pool to allocate xfer handles


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/usb/dwc_otg.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/usb/dwc_otgvar.h

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/dwc_otg.c
diff -u src/sys/dev/usb/dwc_otg.c:1.19 src/sys/dev/usb/dwc_otg.c:1.20
--- src/sys/dev/usb/dwc_otg.c:1.19	Sat Jan 12 22:57:26 2013
+++ src/sys/dev/usb/dwc_otg.c	Sat Jan 12 23:26:06 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: dwc_otg.c,v 1.19 2013/01/12 22:57:26 skrll Exp $	*/
+/*	$NetBSD: dwc_otg.c,v 1.20 2013/01/12 23:26:06 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2012 Hans Petter Selasky. All rights reserved.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc_otg.c,v 1.19 2013/01/12 22:57:26 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc_otg.c,v 1.20 2013/01/12 23:26:06 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -376,24 +376,14 @@ dwc_otg_allocx(struct usbd_bus *bus)
 
 	DPRINTF("\n");
 
-	xfer = SIMPLEQ_FIRST(&sc->sc_free_xfers);
+	DOTG_EVCNT_INCR(sc->sc_ev_xferpoolget);
+	xfer = pool_cache_get(sc->sc_xferpool, PR_WAITOK);
 	if (xfer != NULL) {
-		SIMPLEQ_REMOVE_HEAD(&sc->sc_free_xfers, next);
-#ifdef DIAGNOSTIC
-		if (xfer->busy_free != XFER_FREE) {
-			DPRINTF("xfer=%p not free, 0x%08x\n", xfer,
-			    xfer->busy_free);
-		}
-#endif
 		memset(xfer, 0, sizeof(struct dwc_otg_xfer));
-	} else {
-		xfer = kmem_zalloc(sizeof(struct dwc_otg_xfer), KM_SLEEP);
-	}
 #ifdef DIAGNOSTIC
-	if (xfer != NULL) {
 		xfer->busy_free = XFER_BUSY;
-	}
 #endif
+	}
 	return xfer;
 }
 
@@ -410,7 +400,8 @@ dwc_otg_freex(struct usbd_bus *bus, usbd
 	}
 	xfer->busy_free = XFER_FREE;
 #endif
-	SIMPLEQ_INSERT_HEAD(&sc->sc_free_xfers, xfer, next);
+	DOTG_EVCNT_INCR(sc->sc_ev_xferpoolput);
+	pool_cache_put(sc->sc_xferpool, xfer);
 }
 
 
@@ -4141,6 +4132,8 @@ dwc_otg_init(struct dwc_otg_softc *sc)
 
 	sc->sc_tdpool = pool_cache_init(sizeof(struct dwc_otg_td), 0, 0, 0,
 	    "dotgtd", NULL, IPL_USB, NULL, NULL, NULL);
+	sc->sc_xferpool = pool_cache_init(sizeof(struct dwc_otg_xfer), 0, 0, 0,
+	    "dotgxfer", NULL, IPL_USB, NULL, NULL, NULL);
 
 	sc->sc_rhc_si = softint_establish(SOFTINT_NET | SOFTINT_MPSAFE,
 	    dwc_otg_rhc, sc);

Index: src/sys/dev/usb/dwc_otgvar.h
diff -u src/sys/dev/usb/dwc_otgvar.h:1.3 src/sys/dev/usb/dwc_otgvar.h:1.4
--- src/sys/dev/usb/dwc_otgvar.h:1.3	Fri Jan 11 20:35:51 2013
+++ src/sys/dev/usb/dwc_otgvar.h	Sat Jan 12 23:26:06 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: dwc_otgvar.h,v 1.3 2013/01/11 20:35:51 jmcneill Exp $ */
+/*	$NetBSD: dwc_otgvar.h,v 1.4 2013/01/12 23:26:06 jmcneill Exp $ */
 
 /* $FreeBSD: src/sys/dev/usb/controller/dwc_otg.h,v 1.12 2012/09/27 15:23:38 hselasky Exp $ */
 /*-
@@ -199,9 +199,8 @@ typedef struct dwc_otg_softc {
 	TAILQ_HEAD(, dwc_otg_xfer) sc_active;	/* active transfers */
 	TAILQ_HEAD(, dwc_otg_xfer) sc_complete;	/* complete transfers */
 
-	SIMPLEQ_HEAD(, usbd_xfer) sc_free_xfers; /* free xfers */
-
 	pool_cache_t sc_tdpool;
+	pool_cache_t sc_xferpool;
 
 #ifdef DOTG_COUNTERS
 	
@@ -211,6 +210,8 @@ typedef struct dwc_otg_softc {
 	
 	struct evcnt sc_ev_tdpoolget;
 	struct evcnt sc_ev_tdpoolput;
+	struct evcnt sc_ev_xferpoolget;
+	struct evcnt sc_ev_xferpoolput;
 	
 #endif	
 

Reply via email to