Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/sdmmc Add some event counters to track transfer sizes.
details: https://anonhg.NetBSD.org/src/rev/110410a0097e
branches: trunk
changeset: 341934:110410a0097e
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sun Nov 29 23:38:47 2015 +0000
description:
Add some event counters to track transfer sizes.
diffstat:
sys/dev/sdmmc/sdmmc.c | 35 ++++++++++++++++++++++++++++++++---
sys/dev/sdmmc/sdmmc_mem.c | 32 ++++++++++++++++++++++++++++----
sys/dev/sdmmc/sdmmcvar.h | 9 ++++++++-
3 files changed, 68 insertions(+), 8 deletions(-)
diffs (171 lines):
diff -r b10a70919a10 -r 110410a0097e sys/dev/sdmmc/sdmmc.c
--- a/sys/dev/sdmmc/sdmmc.c Sun Nov 29 21:38:10 2015 +0000
+++ b/sys/dev/sdmmc/sdmmc.c Sun Nov 29 23:38:47 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sdmmc.c,v 1.31 2015/08/09 13:18:46 mlelstv Exp $ */
+/* $NetBSD: sdmmc.c,v 1.32 2015/11/29 23:38:47 jmcneill Exp $ */
/* $OpenBSD: sdmmc.c,v 1.18 2009/01/09 10:58:38 jsg Exp $ */
/*
@@ -49,7 +49,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.31 2015/08/09 13:18:46 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.32 2015/11/29 23:38:47 jmcneill Exp $");
#ifdef _KERNEL_OPT
#include "opt_sdmmc.h"
@@ -154,6 +154,29 @@
mutex_init(&sc->sc_intr_task_mtx, MUTEX_DEFAULT, IPL_SDMMC);
cv_init(&sc->sc_tskq_cv, "mmctaskq");
+ evcnt_attach_dynamic(&sc->sc_ev_xfer, EVCNT_TYPE_MISC, NULL,
+ device_xname(self), "xfer");
+ evcnt_attach_dynamic(&sc->sc_ev_xfer_aligned[0], EVCNT_TYPE_MISC,
+ &sc->sc_ev_xfer, device_xname(self), "xfer 512");
+ evcnt_attach_dynamic(&sc->sc_ev_xfer_aligned[1], EVCNT_TYPE_MISC,
+ &sc->sc_ev_xfer, device_xname(self), "xfer 1024");
+ evcnt_attach_dynamic(&sc->sc_ev_xfer_aligned[2], EVCNT_TYPE_MISC,
+ &sc->sc_ev_xfer, device_xname(self), "xfer 2048");
+ evcnt_attach_dynamic(&sc->sc_ev_xfer_aligned[3], EVCNT_TYPE_MISC,
+ &sc->sc_ev_xfer, device_xname(self), "xfer 4096");
+ evcnt_attach_dynamic(&sc->sc_ev_xfer_aligned[4], EVCNT_TYPE_MISC,
+ &sc->sc_ev_xfer, device_xname(self), "xfer 8192");
+ evcnt_attach_dynamic(&sc->sc_ev_xfer_aligned[5], EVCNT_TYPE_MISC,
+ &sc->sc_ev_xfer, device_xname(self), "xfer 16384");
+ evcnt_attach_dynamic(&sc->sc_ev_xfer_aligned[6], EVCNT_TYPE_MISC,
+ &sc->sc_ev_xfer, device_xname(self), "xfer 32768");
+ evcnt_attach_dynamic(&sc->sc_ev_xfer_aligned[7], EVCNT_TYPE_MISC,
+ &sc->sc_ev_xfer, device_xname(self), "xfer 65536");
+ evcnt_attach_dynamic(&sc->sc_ev_xfer_unaligned, EVCNT_TYPE_MISC,
+ &sc->sc_ev_xfer, device_xname(self), "xfer unaligned");
+ evcnt_attach_dynamic(&sc->sc_ev_xfer_error, EVCNT_TYPE_MISC,
+ &sc->sc_ev_xfer, device_xname(self), "xfer error");
+
if (ISSET(sc->sc_caps, SMC_CAPS_POLL_CARD_DET)) {
callout_init(&sc->sc_card_detect_ch, 0);
callout_reset(&sc->sc_card_detect_ch, hz,
@@ -178,7 +201,7 @@
sdmmc_detach(device_t self, int flags)
{
struct sdmmc_softc *sc = device_private(self);
- int error;
+ int error, i;
mutex_enter(&sc->sc_tskq_mtx);
sc->sc_dying = 1;
@@ -209,6 +232,12 @@
mutex_destroy(&sc->sc_tskq_mtx);
mutex_destroy(&sc->sc_mtx);
+ evcnt_detach(&sc->sc_ev_xfer_error);
+ evcnt_detach(&sc->sc_ev_xfer_unaligned);
+ for (i = 0; i < __arraycount(sc->sc_ev_xfer_aligned); i++)
+ evcnt_detach(&sc->sc_ev_xfer_aligned[i]);
+ evcnt_detach(&sc->sc_ev_xfer);
+
return 0;
}
diff -r b10a70919a10 -r 110410a0097e sys/dev/sdmmc/sdmmc_mem.c
--- a/sys/dev/sdmmc/sdmmc_mem.c Sun Nov 29 21:38:10 2015 +0000
+++ b/sys/dev/sdmmc/sdmmc_mem.c Sun Nov 29 23:38:47 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sdmmc_mem.c,v 1.48 2015/10/29 22:37:15 jmcneill Exp $ */
+/* $NetBSD: sdmmc_mem.c,v 1.49 2015/11/29 23:38:47 jmcneill Exp $ */
/* $OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $ */
/*
@@ -45,7 +45,7 @@
/* Routines for SD/MMC memory cards. */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.48 2015/10/29 22:37:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.49 2015/11/29 23:38:47 jmcneill Exp $");
#ifdef _KERNEL_OPT
#include "opt_sdmmc.h"
@@ -56,6 +56,8 @@
#include <sys/malloc.h>
#include <sys/systm.h>
#include <sys/device.h>
+#include <sys/bitops.h>
+#include <sys/evcnt.h>
#include <dev/sdmmc/sdmmcchip.h>
#include <dev/sdmmc/sdmmcreg.h>
@@ -1595,9 +1597,20 @@
if (ISSET(sc->sc_caps, SMC_CAPS_DMA))
cmd.c_dmamap = dmap;
+ sc->sc_ev_xfer.ev_count++;
+
error = sdmmc_mmc_command(sc, &cmd);
- if (error)
+ if (error) {
+ sc->sc_ev_xfer_error.ev_count++;
goto out;
+ }
+
+ const u_int counter = __builtin_ctz(cmd.c_datalen);
+ if (counter >= 9 && counter <= 16) {
+ sc->sc_ev_xfer_aligned[counter - 9].ev_count++;
+ } else {
+ sc->sc_ev_xfer_unaligned.ev_count++;
+ }
if (!ISSET(sc->sc_caps, SMC_CAPS_AUTO_STOP)) {
if (cmd.c_opcode == MMC_READ_BLOCK_MULTIPLE) {
@@ -1809,9 +1822,20 @@
if (ISSET(sc->sc_caps, SMC_CAPS_DMA))
cmd.c_dmamap = dmap;
+ sc->sc_ev_xfer.ev_count++;
+
error = sdmmc_mmc_command(sc, &cmd);
- if (error)
+ if (error) {
+ sc->sc_ev_xfer_error.ev_count++;
goto out;
+ }
+
+ const u_int counter = __builtin_ctz(cmd.c_datalen);
+ if (counter >= 9 && counter <= 16) {
+ sc->sc_ev_xfer_aligned[counter - 9].ev_count++;
+ } else {
+ sc->sc_ev_xfer_unaligned.ev_count++;
+ }
if (!ISSET(sc->sc_caps, SMC_CAPS_AUTO_STOP)) {
if (cmd.c_opcode == MMC_WRITE_BLOCK_MULTIPLE) {
diff -r b10a70919a10 -r 110410a0097e sys/dev/sdmmc/sdmmcvar.h
--- a/sys/dev/sdmmc/sdmmcvar.h Sun Nov 29 21:38:10 2015 +0000
+++ b/sys/dev/sdmmc/sdmmcvar.h Sun Nov 29 23:38:47 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sdmmcvar.h,v 1.20 2015/10/06 14:32:51 mlelstv Exp $ */
+/* $NetBSD: sdmmcvar.h,v 1.21 2015/11/29 23:38:47 jmcneill Exp $ */
/* $OpenBSD: sdmmcvar.h,v 1.13 2009/01/09 10:55:22 jsg Exp $ */
/*
@@ -27,6 +27,7 @@
#include <sys/queue.h>
#include <sys/mutex.h>
#include <sys/callout.h>
+#include <sys/evcnt.h>
#include <sys/bus.h>
@@ -266,6 +267,12 @@
const char *sc_transfer_mode; /* current transfer mode */
callout_t sc_card_detect_ch; /* polling card insert/remove */
+
+ /* event counters */
+ struct evcnt sc_ev_xfer; /* xfer count */
+ struct evcnt sc_ev_xfer_aligned[8]; /* aligned xfer counts */
+ struct evcnt sc_ev_xfer_unaligned; /* unaligned xfer count */
+ struct evcnt sc_ev_xfer_error; /* error xfer count */
};
/*
Home |
Main Index |
Thread Index |
Old Index