Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Convert to pool_cache and add some (disabled by ...
details: https://anonhg.NetBSD.org/src/rev/b734ef3ebf3b
branches: trunk
changeset: 783881:b734ef3ebf3b
user: skrll <skrll%NetBSD.org@localhost>
date: Fri Jan 11 13:48:46 2013 +0000
description:
Convert to pool_cache and add some (disabled by default) counters.
diffstat:
sys/dev/usb/dwc_otg.c | 50 ++++++++++++++++++++++++++++++++++++++---------
sys/dev/usb/dwc_otgvar.h | 17 ++++++++++++---
2 files changed, 53 insertions(+), 14 deletions(-)
diffs (167 lines):
diff -r bec5cbc0b8e0 -r b734ef3ebf3b sys/dev/usb/dwc_otg.c
--- a/sys/dev/usb/dwc_otg.c Fri Jan 11 13:01:44 2013 +0000
+++ b/sys/dev/usb/dwc_otg.c Fri Jan 11 13:48:46 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_otg.c,v 1.8 2013/01/11 13:01:44 skrll Exp $ */
+/* $NetBSD: dwc_otg.c,v 1.9 2013/01/11 13:48:46 skrll 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.8 2013/01/11 13:01:44 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc_otg.c,v 1.9 2013/01/11 13:48:46 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -87,6 +87,13 @@
#include <arm/broadcom/bcm2835reg.h>
#include <arm/broadcom/bcm2835_mbox.h>
+#ifdef DOTG_COUNTERS
+#define DOTG_EVCNT_ADD(a,b) ((void)((a).ev_count += (b)))
+#else
+#define DOTG_EVCNT_ADD(a,b) do { } while (/*CONSTCOND*/0)
+#endif
+#define DOTG_EVCNT_INCR(a) DOTG_EVCNT_ADD((a), 1)
+
#ifdef DWC_OTG_DEBUG
#define DPRINTFN(n,fmt,...) do { \
if (dwc_otgdebug >= (n)) { \
@@ -423,6 +430,8 @@
KASSERT(sc->sc_bus.use_polling || mutex_owned(&sc->sc_lock));
+ DOTG_EVCNT_INCR(sc->sc_ev_soft_intr);
+
DPRINTF("\n");
TAILQ_FOREACH_SAFE(dxfer, &sc->sc_complete, xnext, tmp) {
TAILQ_REMOVE(&sc->sc_complete, dxfer, xnext);
@@ -1680,6 +1689,8 @@
usbd_xfer_handle xfer = dwork->xfer;
struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
+ DOTG_EVCNT_INCR(sc->sc_ev_work);
+
mutex_enter(&sc->sc_lock);
dwc_otg_start_standard_chain(xfer);
mutex_exit(&sc->sc_lock);
@@ -3415,6 +3426,8 @@
{
uint32_t status;
+ DOTG_EVCNT_INCR(sc->sc_ev_intr);
+
/* read and clear interrupt status */
status = DWC_OTG_READ_4(sc, DOTG_GINTSTS);
DWC_OTG_WRITE_4(sc, DOTG_GINTSTS, status);
@@ -4162,6 +4175,7 @@
usbd_status
dwc_otg_init(struct dwc_otg_softc *sc)
{
+ const char * const xname = device_xname(sc->sc_dev);
uint32_t temp;
sc->sc_bus.hci_private = sc;
@@ -4179,21 +4193,33 @@
TAILQ_INIT(&sc->sc_active);
TAILQ_INIT(&sc->sc_complete);
- pool_init(&sc->sc_tdpool,
- sizeof(struct dwc_otg_td), 0, 0, 0,
- "dwctdpool", NULL, IPL_USB);
- pool_prime(&sc->sc_tdpool, DWC_OTG_POOL_SIZE);
+ sc->sc_tdpool = pool_cache_init(sizeof(struct dwc_otg_td), 0, 0, 0,
+ "dotgtd", NULL, IPL_USB, NULL, NULL, NULL);
sc->sc_rhc_si = softint_establish(SOFTINT_NET | SOFTINT_MPSAFE,
dwc_otg_rhc, sc);
sc->sc_timer_si = softint_establish(SOFTINT_NET | SOFTINT_MPSAFE,
dwc_otg_timer, sc);
- workqueue_create(&sc->sc_wq, device_xname(sc->sc_dev),
- dwc_otg_intr_worker, sc, PRI_NONE, IPL_USB, WQ_MPSAFE);
+ workqueue_create(&sc->sc_wq, xname, dwc_otg_intr_worker, sc, PRI_NONE,
+ IPL_USB, WQ_MPSAFE);
usb_setup_reserve(sc->sc_dev, &sc->sc_dma_reserve, sc->sc_bus.dmatag,
USB_MEM_RESERVE);
+
+#ifdef DOTG_COUNTERS
+ evcnt_attach_dynamic(&sc->sc_ev_intr, EVCNT_TYPE_INTR,
+ NULL, xname, "intr");
+ evcnt_attach_dynamic(&sc->sc_ev_soft_intr, EVCNT_TYPE_INTR,
+ NULL, xname, "soft intr");
+ evcnt_attach_dynamic(&sc->sc_ev_work, EVCNT_TYPE_MISC,
+ NULL, xname, "work items");
+
+ evcnt_attach_dynamic(&sc->sc_ev_tdpoolget, EVCNT_TYPE_MISC,
+ NULL, xname, "pool get");
+ evcnt_attach_dynamic(&sc->sc_ev_tdpoolput, EVCNT_TYPE_MISC,
+ NULL, xname, "pool put");
+#endif
temp = DWC_OTG_READ_4(sc, DOTG_GUSBCFG);
temp |= GUSBCFG_FORCEHOSTMODE;
@@ -4426,7 +4452,9 @@
for (n = 0; n != ntd; n++) {
struct dwc_otg_td *td;
- td = pool_get(&sc->sc_tdpool, PR_NOWAIT);
+ DOTG_EVCNT_INCR(sc->sc_ev_tdpoolget);
+
+ td = pool_cache_get(sc->sc_tdpool, PR_NOWAIT);
if (td == NULL) {
printf("%s: pool empty\n", __func__);
goto done;
@@ -4458,7 +4486,9 @@
for (td = dxfer->td_start[0]; td; ) {
td_next = td->obj_next;
- pool_put(&sc->sc_tdpool, td);
+ DOTG_EVCNT_INCR(sc->sc_ev_tdpoolput);
+
+ pool_cache_put(sc->sc_tdpool, td);
td = td_next;
}
}
diff -r bec5cbc0b8e0 -r b734ef3ebf3b sys/dev/usb/dwc_otgvar.h
--- a/sys/dev/usb/dwc_otgvar.h Fri Jan 11 13:01:44 2013 +0000
+++ b/sys/dev/usb/dwc_otgvar.h Fri Jan 11 13:48:46 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_otgvar.h,v 1.1 2013/01/09 22:23:44 skrll Exp $ */
+/* $NetBSD: dwc_otgvar.h,v 1.2 2013/01/11 13:48:46 skrll Exp $ */
/* $FreeBSD: src/sys/dev/usb/controller/dwc_otg.h,v 1.12 2012/09/27 15:23:38 hselasky Exp $ */
/*-
@@ -40,8 +40,6 @@
#define DWC_OTG_MAX_ENDPOINTS 16
#define DWC_OTG_HOST_TIMER_RATE 10 /* ms */
-#define DWC_OTG_POOL_SIZE 4096 /* XXXNH measure */
-
struct dwc_otg_td;
typedef uint8_t (dwc_otg_cmd_t)(struct dwc_otg_td *td);
@@ -201,7 +199,18 @@
SIMPLEQ_HEAD(, usbd_xfer) sc_free_xfers; /* free xfers */
- struct pool sc_tdpool;
+ pool_cache_t sc_tdpool;
+
+#ifdef DOTG_COUNTERS
+
+ struct evcnt sc_ev_intr;
+ struct evcnt sc_ev_soft_intr;
+ struct evcnt sc_ev_work;
+
+ struct evcnt sc_ev_tdpoolget;
+ struct evcnt sc_ev_tdpoolput;
+
+#endif
/* From FreeBSD softc */
struct callout sc_timer;
Home |
Main Index |
Thread Index |
Old Index