Date: Tue, 13 May 2014 23:53:04 GMT From: Keith White <kwhite@uottawa.ca> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/189788: [patch] add kern.geom.disk.%s.activity_led to attach a LED to display disk activity Message-ID: <201405132353.s4DNr4Bb094110@cgiserv.freebsd.org> Resent-Message-ID: <201405140000.s4E000Pm029814@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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 <geom/geom_int.h> #include <dev/led/led.h> +#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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405132353.s4DNr4Bb094110>