Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb use a pool to allocate xfer handles



details:   https://anonhg.NetBSD.org/src/rev/46afa110af76
branches:  trunk
changeset: 783939:46afa110af76
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Jan 12 23:26:06 2013 +0000

description:
use a pool to allocate xfer handles

diffstat:

 sys/dev/usb/dwc_otg.c    |  27 ++++++++++-----------------
 sys/dev/usb/dwc_otgvar.h |   7 ++++---
 2 files changed, 14 insertions(+), 20 deletions(-)

diffs (95 lines):

diff -r 15f504e0ddc6 -r 46afa110af76 sys/dev/usb/dwc_otg.c
--- a/sys/dev/usb/dwc_otg.c     Sat Jan 12 22:57:26 2013 +0000
+++ b/sys/dev/usb/dwc_otg.c     Sat Jan 12 23:26:06 2013 +0000
@@ -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 @@
 
        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);
+               memset(xfer, 0, sizeof(struct dwc_otg_xfer));
 #ifdef DIAGNOSTIC
-               if (xfer->busy_free != XFER_FREE) {
-                       DPRINTF("xfer=%p not free, 0x%08x\n", xfer,
-                           xfer->busy_free);
-               }
+               xfer->busy_free = XFER_BUSY;
 #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 @@
        }
        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 @@
 
        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);
diff -r 15f504e0ddc6 -r 46afa110af76 sys/dev/usb/dwc_otgvar.h
--- a/sys/dev/usb/dwc_otgvar.h  Sat Jan 12 22:57:26 2013 +0000
+++ b/sys/dev/usb/dwc_otgvar.h  Sat Jan 12 23:26:06 2013 +0000
@@ -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 @@
        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 @@
        
        struct evcnt sc_ev_tdpoolget;
        struct evcnt sc_ev_tdpoolput;
+       struct evcnt sc_ev_xferpoolget;
+       struct evcnt sc_ev_xferpoolput;
        
 #endif 
 



Home | Main Index | Thread Index | Old Index