From owner-svn-src-projects@FreeBSD.ORG Tue May 17 22:27:36 2011 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6E647106566C; Tue, 17 May 2011 22:27:36 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 50C258FC16; Tue, 17 May 2011 22:27:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p4HMRar7049662; Tue, 17 May 2011 22:27:36 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p4HMRajw049658; Tue, 17 May 2011 22:27:36 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201105172227.p4HMRajw049658@svn.freebsd.org> From: Attilio Rao Date: Tue, 17 May 2011 22:27:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222042 - in projects/largeSMP: contrib/top share/man/man4 share/mk sys/dev/ahci X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 May 2011 22:27:36 -0000 Author: attilio Date: Tue May 17 22:27:35 2011 New Revision: 222042 URL: http://svn.freebsd.org/changeset/base/222042 Log: MFC Modified: projects/largeSMP/share/man/man4/ahci.4 projects/largeSMP/sys/dev/ahci/ahci.c projects/largeSMP/sys/dev/ahci/ahci.h Directory Properties: projects/largeSMP/ (props changed) projects/largeSMP/cddl/contrib/opensolaris/ (props changed) projects/largeSMP/contrib/bind9/ (props changed) projects/largeSMP/contrib/binutils/ (props changed) projects/largeSMP/contrib/bzip2/ (props changed) projects/largeSMP/contrib/dialog/ (props changed) projects/largeSMP/contrib/ee/ (props changed) projects/largeSMP/contrib/expat/ (props changed) projects/largeSMP/contrib/file/ (props changed) projects/largeSMP/contrib/gcc/ (props changed) projects/largeSMP/contrib/gdb/ (props changed) projects/largeSMP/contrib/gdtoa/ (props changed) projects/largeSMP/contrib/gnu-sort/ (props changed) projects/largeSMP/contrib/groff/ (props changed) projects/largeSMP/contrib/less/ (props changed) projects/largeSMP/contrib/libpcap/ (props changed) projects/largeSMP/contrib/libstdc++/ (props changed) projects/largeSMP/contrib/llvm/ (props changed) projects/largeSMP/contrib/llvm/tools/clang/ (props changed) projects/largeSMP/contrib/ncurses/ (props changed) projects/largeSMP/contrib/netcat/ (props changed) projects/largeSMP/contrib/ntp/ (props changed) projects/largeSMP/contrib/one-true-awk/ (props changed) projects/largeSMP/contrib/openbsm/ (props changed) projects/largeSMP/contrib/openpam/ (props changed) projects/largeSMP/contrib/pf/ (props changed) projects/largeSMP/contrib/sendmail/ (props changed) projects/largeSMP/contrib/tcpdump/ (props changed) projects/largeSMP/contrib/tcsh/ (props changed) projects/largeSMP/contrib/top/ (props changed) projects/largeSMP/contrib/top/install-sh (props changed) projects/largeSMP/contrib/tzcode/stdtime/ (props changed) projects/largeSMP/contrib/tzcode/zic/ (props changed) projects/largeSMP/contrib/tzdata/ (props changed) projects/largeSMP/contrib/wpa/ (props changed) projects/largeSMP/contrib/xz/ (props changed) projects/largeSMP/crypto/openssh/ (props changed) projects/largeSMP/crypto/openssl/ (props changed) projects/largeSMP/gnu/lib/ (props changed) projects/largeSMP/gnu/usr.bin/binutils/ (props changed) projects/largeSMP/gnu/usr.bin/cc/cc_tools/ (props changed) projects/largeSMP/gnu/usr.bin/gdb/ (props changed) projects/largeSMP/lib/libc/ (props changed) projects/largeSMP/lib/libc/stdtime/ (props changed) projects/largeSMP/lib/libutil/ (props changed) projects/largeSMP/lib/libz/ (props changed) projects/largeSMP/sbin/ (props changed) projects/largeSMP/sbin/ipfw/ (props changed) projects/largeSMP/share/mk/bsd.arch.inc.mk (props changed) projects/largeSMP/share/zoneinfo/ (props changed) projects/largeSMP/sys/ (props changed) projects/largeSMP/sys/amd64/include/xen/ (props changed) projects/largeSMP/sys/boot/ (props changed) projects/largeSMP/sys/boot/i386/efi/ (props changed) projects/largeSMP/sys/boot/ia64/efi/ (props changed) projects/largeSMP/sys/boot/ia64/ski/ (props changed) projects/largeSMP/sys/boot/powerpc/boot1.chrp/ (props changed) projects/largeSMP/sys/boot/powerpc/ofw/ (props changed) projects/largeSMP/sys/cddl/contrib/opensolaris/ (props changed) projects/largeSMP/sys/conf/ (props changed) projects/largeSMP/sys/contrib/dev/acpica/ (props changed) projects/largeSMP/sys/contrib/octeon-sdk/ (props changed) projects/largeSMP/sys/contrib/pf/ (props changed) projects/largeSMP/sys/contrib/x86emu/ (props changed) projects/largeSMP/usr.bin/calendar/ (props changed) projects/largeSMP/usr.bin/csup/ (props changed) projects/largeSMP/usr.bin/procstat/ (props changed) projects/largeSMP/usr.sbin/ndiscvt/ (props changed) projects/largeSMP/usr.sbin/zic/ (props changed) Modified: projects/largeSMP/share/man/man4/ahci.4 ============================================================================== --- projects/largeSMP/share/man/man4/ahci.4 Tue May 17 22:15:53 2011 (r222041) +++ projects/largeSMP/share/man/man4/ahci.4 Tue May 17 22:27:35 2011 (r222042) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 28, 2010 +.Dd May 17, 2011 .Dt AHCI 4 .Os .Sh NAME @@ -121,6 +121,15 @@ hardware command queues (up to 32 comman Native Command Queuing, SATA interface Power Management, device hot-plug and Message Signaled Interrupts. .Pp +Driver supports "LED" enclosure management messages, defined by the AHCI. +When supported by hardware, it allows to control per-port activity, locate +and fault LEDs via the +.Xr led 4 +API for localization and status reporting purposes. +Supporting AHCI controllers may transmit that information to the backplane +controllers via SGPIO interface. Backplane controllers interpret received +statuses in some way (IBPI standard) to report them using present indicators. +.Pp AHCI hardware is also supported by ataahci driver from .Xr ata 4 subsystem. @@ -135,6 +144,15 @@ subclass 6 (SATA) and programming interf Also, in cooperation with atamarvell and atajmicron drivers of ata(4), it supports AHCI part of legacy-PATA + AHCI-SATA combined controllers, such as JMicron JMB36x and Marvell 88SX61xx. +.Sh FILES +.Bl -tag -width /dev/led/ahcich*.locate +.It Pa /dev/led/ahcich*.act +activity LED device nodes +.It Pa /dev/led/ahcich*.fault +fault LED device nodes +.It Pa /dev/led/ahcich*.locate +locate LED device nodes +.El .Sh SEE ALSO .Xr ada 4 , .Xr ata 4 , Modified: projects/largeSMP/sys/dev/ahci/ahci.c ============================================================================== --- projects/largeSMP/sys/dev/ahci/ahci.c Tue May 17 22:15:53 2011 (r222041) +++ projects/largeSMP/sys/dev/ahci/ahci.c Tue May 17 22:27:35 2011 (r222042) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include "ahci.h" @@ -68,6 +69,7 @@ static int ahci_ch_resume(device_t dev); static void ahci_ch_pm(void *arg); static void ahci_ch_intr_locked(void *data); static void ahci_ch_intr(void *data); +static void ahci_ch_led(void *priv, int onoff); static int ahci_ctlr_reset(device_t dev); static int ahci_ctlr_setup(device_t dev); static void ahci_begin_transaction(device_t dev, union ccb *ccb); @@ -418,6 +420,8 @@ ahci_attach(device_t dev) ctlr->caps &= ~AHCI_CAP_SNCQ; if ((ctlr->caps & AHCI_CAP_CCCS) == 0) ctlr->ccc = 0; + mtx_init(&ctlr->em_mtx, "AHCI EM lock", NULL, MTX_DEF); + ctlr->emloc = ATA_INL(ctlr->r_mem, AHCI_EM_LOC); ahci_ctlr_setup(dev); /* Setup interrupts. */ if (ahci_setup_interrupt(dev)) { @@ -521,6 +525,7 @@ ahci_detach(device_t dev) rman_fini(&ctlr->sc_iomem); if (ctlr->r_mem) bus_release_resource(dev, SYS_RES_MEMORY, ctlr->r_rid, ctlr->r_mem); + mtx_destroy(&ctlr->em_mtx); return (0); } @@ -887,6 +892,7 @@ ahci_ch_attach(device_t dev) struct cam_devq *devq; int rid, error, i, sata_rev = 0; u_int32_t version; + char buf[32]; ch->dev = dev; ch->unit = (intptr_t)device_get_ivars(dev); @@ -995,6 +1001,25 @@ ahci_ch_attach(device_t dev) ahci_ch_pm, dev); } mtx_unlock(&ch->mtx); + if ((ch->caps & AHCI_CAP_EMS) && + (ctlr->capsem & AHCI_EM_LED)) { + for (i = 0; i < AHCI_NUM_LEDS; i++) { + ch->leds[i].dev = dev; + ch->leds[i].num = i; + } + if ((ctlr->capsem & AHCI_EM_ALHD) == 0) { + snprintf(buf, sizeof(buf), "%s.act", + device_get_nameunit(dev)); + ch->leds[0].led = led_create(ahci_ch_led, + &ch->leds[0], buf); + } + snprintf(buf, sizeof(buf), "%s.locate", + device_get_nameunit(dev)); + ch->leds[1].led = led_create(ahci_ch_led, &ch->leds[1], buf); + snprintf(buf, sizeof(buf), "%s.fault", + device_get_nameunit(dev)); + ch->leds[2].led = led_create(ahci_ch_led, &ch->leds[2], buf); + } return (0); err3: @@ -1014,7 +1039,12 @@ static int ahci_ch_detach(device_t dev) { struct ahci_channel *ch = device_get_softc(dev); + int i; + for (i = 0; i < AHCI_NUM_LEDS; i++) { + if (ch->leds[i].led) + led_destroy(ch->leds[i].led); + } mtx_lock(&ch->mtx); xpt_async(AC_LOST_DEVICE, ch->path, NULL); /* Forget about reset. */ @@ -1137,6 +1167,47 @@ static driver_t ahcich_driver = { }; DRIVER_MODULE(ahcich, ahci, ahcich_driver, ahcich_devclass, 0, 0); +static void +ahci_ch_setleds(device_t dev) +{ + struct ahci_channel *ch; + struct ahci_controller *ctlr; + size_t buf; + int i, timeout; + int16_t val; + + ctlr = device_get_softc(device_get_parent(dev)); + ch = device_get_softc(dev); + + val = 0; + for (i = 0; i < AHCI_NUM_LEDS; i++) + val |= ch->leds[i].state << (i * 3); + + buf = (ctlr->emloc & 0xffff0000) >> 14; + mtx_lock(&ctlr->em_mtx); + timeout = 1000; + while (ATA_INL(ctlr->r_mem, AHCI_EM_CTL) & (AHCI_EM_TM | AHCI_EM_RST) && + --timeout > 0) + DELAY(1000); + if (timeout == 0) + device_printf(dev, "EM timeout\n"); + ATA_OUTL(ctlr->r_mem, buf, (1 << 8) | (0 << 16) | (0 << 24)); + ATA_OUTL(ctlr->r_mem, buf + 4, ch->unit | (val << 16)); + ATA_OUTL(ctlr->r_mem, AHCI_EM_CTL, AHCI_EM_TM); + mtx_unlock(&ctlr->em_mtx); +} + +static void +ahci_ch_led(void *priv, int onoff) +{ + struct ahci_led *led; + + led = (struct ahci_led *)priv; + + led->state = onoff; + ahci_ch_setleds(led->dev); +} + struct ahci_dc_cb_args { bus_addr_t maddr; int error; Modified: projects/largeSMP/sys/dev/ahci/ahci.h ============================================================================== --- projects/largeSMP/sys/dev/ahci/ahci.h Tue May 17 22:15:53 2011 (r222041) +++ projects/largeSMP/sys/dev/ahci/ahci.h Tue May 17 22:27:35 2011 (r222042) @@ -376,6 +376,15 @@ struct ahci_device { u_int caps; }; +struct ahci_led { + device_t dev; /* Device handle */ + struct cdev *led; + uint8_t num; /* Number of this led */ + uint8_t state; /* State of this led */ +}; + +#define AHCI_NUM_LEDS 3 + /* structure describing an ATA channel */ struct ahci_channel { device_t dev; /* Device handle */ @@ -386,6 +395,7 @@ struct ahci_channel { struct ata_dma dma; /* DMA data */ struct cam_sim *sim; struct cam_path *path; + struct ahci_led leds[3]; uint32_t caps; /* Controller capabilities */ uint32_t caps2; /* Controller capabilities */ uint32_t chcaps; /* Channel capabilities */ @@ -443,6 +453,7 @@ struct ahci_controller { uint32_t caps; /* Controller capabilities */ uint32_t caps2; /* Controller capabilities */ uint32_t capsem; /* Controller capabilities */ + uint32_t emloc; /* EM buffer location */ int quirks; int numirqs; int channels; @@ -453,6 +464,7 @@ struct ahci_controller { void (*function)(void *); void *argument; } interrupt[AHCI_MAX_PORTS]; + struct mtx em_mtx; /* EM access lock */ }; enum ahci_err_type {