From owner-p4-projects@FreeBSD.ORG Mon Jul 29 22:15:50 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5537E888; Mon, 29 Jul 2013 22:15:50 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 1910A886 for ; Mon, 29 Jul 2013 22:15:50 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 04E6A23F8 for ; Mon, 29 Jul 2013 22:15:50 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6TMFn0H022881 for ; Mon, 29 Jul 2013 22:15:49 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6TMFn91022878 for perforce@freebsd.org; Mon, 29 Jul 2013 22:15:49 GMT (envelope-from brooks@freebsd.org) Date: Mon, 29 Jul 2013 22:15:49 GMT Message-Id: <201307292215.r6TMFn91022878@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 231565 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jul 2013 22:15:50 -0000 http://p4web.freebsd.org/@@231565?ac=10 Change 231565 by brooks@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 #include +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;