From owner-freebsd-bugs@FreeBSD.ORG Wed May 14 00:00:01 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.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 ESMTPS id 189FD24C for ; Wed, 14 May 2014 00:00:01 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E91452C6A for ; Wed, 14 May 2014 00:00:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s4E000hV029826 for ; Wed, 14 May 2014 00:00:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s4E000Pm029814; Wed, 14 May 2014 00:00:00 GMT (envelope-from gnats) Resent-Date: Wed, 14 May 2014 00:00:00 GMT Resent-Message-Id: <201405140000.s4E000Pm029814@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Keith White Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A9409FDA for ; Tue, 13 May 2014 23:53:04 +0000 (UTC) Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 962BE2C35 for ; Tue, 13 May 2014 23:53:04 +0000 (UTC) Received: from cgiserv.freebsd.org ([127.0.1.6]) by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s4DNr42L094114 for ; Tue, 13 May 2014 23:53:04 GMT (envelope-from nobody@cgiserv.freebsd.org) Received: (from nobody@localhost) by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s4DNr4Bb094110; Tue, 13 May 2014 23:53:04 GMT (envelope-from nobody) Message-Id: <201405132353.s4DNr4Bb094110@cgiserv.freebsd.org> Date: Tue, 13 May 2014 23:53:04 GMT From: Keith White To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: kern/189788: [patch] add kern.geom.disk.%s.activity_led to attach a LED to display disk activity X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 May 2014 00:00:01 -0000 >Number: 189788 >Category: kern >Synopsis: [patch] add kern.geom.disk.%s.activity_led to attach a LED to display disk activity >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed May 14 00:00:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Keith White >Release: FreeBSD 11 >Organization: Faculty of Engineering, University of Ottawa >Environment: FreeBSD beaglebone 11.0-CURRENT FreeBSD 11.0-CURRENT #12 r265947M: Tue May 13 07:50:40 EDT 2014 root@beaglebone:/usr/obj/usr/src/sys/BEAGLEBONE-LOCAL arm >Description: In embedded platforms (Beaglebone Black in particular) there are uncommitted LEDs that might be useful to have display "disk" activity. The attached patch adds a kern.geom.disk.%s.activity_led SYSCTL that could be used for this purpose. Apply the attached patch. Add the following to your KERNCONF: options GEOM_DISK_ACTIVITY_LED # blinky lights for GEOM disk access Add the following to /boot/loader.conf on that platform to have blinky lights for SD/MMC access: kern.geom.disk.mmcsd0.activity_led="led2" kern.geom.disk.mmcsd1.activity_led="led1" To have the LEDs default on, and go off for any activity, prefix the LED name with bang: kern.geom.disk.mmcsd0.activity_led="!led2" kern.geom.disk.mmcsd1.activity_led="!led1" >How-To-Repeat: NA >Fix: See above. Patch attached with submission follows: Index: sys/conf/options =================================================================== --- sys/conf/options (revision 265947) +++ sys/conf/options (working copy) @@ -97,6 +97,7 @@ GEOM_BSD opt_geom.h GEOM_CACHE opt_geom.h GEOM_CONCAT opt_geom.h +GEOM_DISK_ACTIVITY_LED opt_geom.h GEOM_ELI opt_geom.h GEOM_FOX opt_geom.h GEOM_GATE opt_geom.h Index: sys/geom/geom_disk.c =================================================================== --- sys/geom/geom_disk.c (revision 265947) +++ sys/geom/geom_disk.c (working copy) @@ -57,6 +57,21 @@ #include #include +#ifdef GEOM_DISK_ACTIVITY_LED +#define ACTIVITY_LED_SET(set, negset) do { \ + if (sc->activity_led[0] != 0) { \ + if (sc->activity_led[0] != '!') \ + led_set(sc->activity_led, (set)); \ + else \ + led_set(sc->activity_led+1, (negset)); \ + } \ +} while (0) +#define ACTIVITY_LED_ON ACTIVITY_LED_SET("1", "0") +#define ACTIVITY_LED_OFF ACTIVITY_LED_SET("0", "1") +#else +#define ACTIVITY_LED_ON +#define ACTIVITY_LED_OFF +#endif struct g_disk_softc { struct mtx done_mtx; @@ -66,6 +81,9 @@ char led[64]; uint32_t state; struct mtx start_mtx; +#ifdef GEOM_DISK_ACTIVITY_LED + char activity_led[64]; +#endif }; static g_access_t g_disk_access; @@ -233,6 +251,7 @@ } else mtx_unlock(&sc->done_mtx); g_destroy_bio(bp); + ACTIVITY_LED_OFF; } static void @@ -250,6 +269,7 @@ mtx_lock(&sc->done_mtx); devstat_end_transaction_bio_bt(sc->dp->d_devstat, bp, &now); mtx_unlock(&sc->done_mtx); + ACTIVITY_LED_OFF; } g_io_deliver(bp, bp->bio_error); } @@ -306,6 +326,7 @@ devstat_start_transaction_bio(dp->d_devstat, bp); mtx_unlock(&sc->start_mtx); dp->d_strategy(bp); + ACTIVITY_LED_ON; break; } off = 0; @@ -315,6 +336,7 @@ error = ENOMEM; break; } + ACTIVITY_LED_ON; do { bp2->bio_offset += off; bp2->bio_length -= off; @@ -565,6 +587,15 @@ SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "led", CTLFLAG_RW | CTLFLAG_TUN, sc->led, sizeof(sc->led), "LED name"); +#ifdef GEOM_DISK_ACTIVITY_LED + snprintf(tmpstr, sizeof(tmpstr), + "kern.geom.disk.%s.activity_led", gp->name); + TUNABLE_STR_FETCH(tmpstr, sc->activity_led, sizeof(sc->activity_led)); + SYSCTL_ADD_STRING(&sc->sysctl_ctx, + SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "activity_led", + CTLFLAG_RW | CTLFLAG_TUN, sc->activity_led, sizeof(sc->activity_led), + "(!)Activity LED name"); +#endif } pp->private = sc; dp->d_geom = gp; >Release-Note: >Audit-Trail: >Unformatted: