PERFORCE change 231565 for review
Brooks Davis
brooks at FreeBSD.org
Mon Jul 29 22:15:50 UTC 2013
http://p4web.freebsd.org/@@231565?ac=10
Change 231565 by brooks at brooks_zenith on 2013/07/29 22:15:11
Add counters for each type of timeout and report them via sysctl.
Tidy the timeout code a bit and ensure that the last status
register check is performed after the last timeout expires.
Based on feedback from: imp
Affected files ...
.. //depot/projects/ctsrd/beribsd/src/sys/dev/cfi/cfi_core.c#18 edit
.. //depot/projects/ctsrd/beribsd/src/sys/dev/cfi/cfi_var.h#9 edit
Differences ...
==== //depot/projects/ctsrd/beribsd/src/sys/dev/cfi/cfi_core.c#18 (text+ko) ====
@@ -55,6 +55,8 @@
#include <dev/cfi/cfi_reg.h>
#include <dev/cfi/cfi_var.h>
+static void cfi_add_sysctls(struct cfi_softc *);
+
extern struct cdevsw cfi_cdevsw;
char cfi_driver_name[] = "cfi";
@@ -343,6 +345,8 @@
"%s%u", cfi_driver_name, u);
sc->sc_nod->si_drv1 = sc;
+ cfi_add_sysctls(sc);
+
#ifdef CFI_SUPPORT_STRATAFLASH
/*
* Store the Intel factory PPR in the environment. In some
@@ -363,6 +367,45 @@
return (0);
}
+static void
+cfi_add_sysctls(struct cfi_softc *sc)
+{
+ struct sysctl_ctx_list *ctx;
+ struct sysctl_oid_list *children;
+
+ ctx = device_get_sysctl_ctx(sc->sc_dev);
+ children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->sc_dev));
+
+ SYSCTL_ADD_UINT(ctx, children, OID_AUTO,
+ "typical_erase_timout_count",
+ CTLFLAG_RD, &sc->sc_tto_counts[CFI_TIMEOUT_ERASE],
+ 0, "Number of times the typical erase timeout was exceeded");
+ SYSCTL_ADD_UINT(ctx, children, OID_AUTO,
+ "max_erase_timout_count",
+ CTLFLAG_RD, &sc->sc_mto_counts[CFI_TIMEOUT_ERASE], 0,
+ "Number of times the maximum erase timeout was exceeded");
+ SYSCTL_ADD_UINT(ctx, children, OID_AUTO,
+ "typical_write_timout_count",
+ CTLFLAG_RD, &sc->sc_tto_counts[CFI_TIMEOUT_WRITE], 0,
+ "Number of times the typical write timeout was exceeded");
+ SYSCTL_ADD_UINT(ctx, children, OID_AUTO,
+ "max_write_timout_count",
+ CTLFLAG_RD, &sc->sc_mto_counts[CFI_TIMEOUT_WRITE], 0,
+ "Number of times the maximum write timeout was exceeded");
+ if (sc->sc_maxbuf > 0) {
+ SYSCTL_ADD_UINT(ctx, children, OID_AUTO,
+ "typical_bufwrite_timout_count",
+ CTLFLAG_RD, &sc->sc_tto_counts[CFI_TIMEOUT_BUFWRITE], 0,
+ "Number of times the typical buffered write timeout was "
+ "exceeded");
+ SYSCTL_ADD_UINT(ctx, children, OID_AUTO,
+ "max_bufwrite_timout_count",
+ CTLFLAG_RD, &sc->sc_mto_counts[CFI_TIMEOUT_BUFWRITE], 0,
+ "Number of times the maximum buffered write timeout was "
+ "exceeded");
+ }
+}
+
int
cfi_detach(device_t dev)
{
@@ -382,15 +425,18 @@
{
int done, error, tto_exceeded;
uint32_t st0 = 0, st = 0;
- sbintime_t mend, now, tend;
-
- tend = start + sc->sc_typical_timeouts[cmd];
- mend = start + sc->sc_max_timeouts[cmd];
+ sbintime_t now;
done = 0;
error = 0;
tto_exceeded = 0;
while (!done && !error) {
+ /*
+ * Save time before we start so we always do one check
+ * after the timeout has expired.
+ */
+ now = sbinuptime();
+
switch (sc->sc_cmdset) {
case CFI_VEND_INTEL_ECS:
case CFI_VEND_INTEL_SCS:
@@ -419,24 +465,25 @@
break;
}
- now = sbinuptime();
- if (tto_exceeded || now > tend) {
- if (!tto_exceeded)
+ if (tto_exceeded ||
+ now > start + sc->sc_typical_timeouts[cmd]) {
+ if (!tto_exceeded) {
tto_exceeded = 1;
- if (now > mend) {
+ sc->sc_tto_counts[cmd]++;
+#ifdef CFI_DEBUG_TIMEOUT
+ device_printf(sc->sc_dev,
+ "typical timeout exceeded (cmd %d)", cmd);
+#endif
+ }
+ if (now > start + sc->sc_max_timeouts[cmd]) {
+ sc->sc_mto_counts[cmd]++;
#ifdef CFI_DEBUG_TIMEOUT
device_printf(sc->sc_dev,
"max timeout exceeded (cmd %d)", cmd);
#endif
- break;
}
}
}
-#ifdef CFI_DEBUG_TIMEOUT
- if (tto_exceeded)
- device_printf(sc->sc_dev,
- "typical timeout exceeded (cmd %d)", cmd);
-#endif
if (!done && !error)
error = ETIMEDOUT;
if (error)
==== //depot/projects/ctsrd/beribsd/src/sys/dev/cfi/cfi_var.h#9 (text+ko) ====
@@ -65,6 +65,8 @@
u_int sc_cmdset;
sbintime_t sc_typical_timeouts[3];
sbintime_t sc_max_timeouts[3];
+ u_int sc_tto_counts[3];
+ u_int sc_mto_counts[3];
u_int sc_maxbuf;
More information about the p4-projects
mailing list