From owner-svn-src-stable-8@FreeBSD.ORG Sun Sep 29 07:42:26 2013 Return-Path: Delivered-To: svn-src-stable-8@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 1C7FE8CE; Sun, 29 Sep 2013 07:42:26 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (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 0A3052A65; Sun, 29 Sep 2013 07:42:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8T7gPer099894; Sun, 29 Sep 2013 07:42:25 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r8T7gPJG099893; Sun, 29 Sep 2013 07:42:25 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201309290742.r8T7gPJG099893@svn.freebsd.org> From: Xin LI Date: Sun, 29 Sep 2013 07:42:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r255934 - in stable: 8/lib/libedit 9/lib/libedit X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Sep 2013 07:42:26 -0000 Author: delphij Date: Sun Sep 29 07:42:25 2013 New Revision: 255934 URL: http://svnweb.freebsd.org/changeset/base/255934 Log: MFC r255891: Import NetBSD readline.c,v 1.104: do not crash with add_history(NULL). Modified: stable/8/lib/libedit/readline.c Directory Properties: stable/8/lib/libedit/ (props changed) Changes in other areas also in this revision: Modified: stable/9/lib/libedit/readline.c Directory Properties: stable/9/lib/libedit/ (props changed) Modified: stable/8/lib/libedit/readline.c ============================================================================== --- stable/8/lib/libedit/readline.c Sun Sep 29 01:05:00 2013 (r255933) +++ stable/8/lib/libedit/readline.c Sun Sep 29 07:42:25 2013 (r255934) @@ -1363,6 +1363,9 @@ add_history(const char *line) TYPE(HistEvent) ev; const Char *wline; + if (line == NULL) + return 0; + if (h == NULL || e == NULL) rl_initialize(); From owner-svn-src-stable-8@FreeBSD.ORG Mon Sep 30 17:35:48 2013 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org 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 ESMTP id D3E53CBF; Mon, 30 Sep 2013 17:35:48 +0000 (UTC) (envelope-from jmg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (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 A5FC3275C; Mon, 30 Sep 2013 17:35:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8UHZmHi014698; Mon, 30 Sep 2013 17:35:48 GMT (envelope-from jmg@svn.freebsd.org) Received: (from jmg@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r8UHZmp5014697; Mon, 30 Sep 2013 17:35:48 GMT (envelope-from jmg@svn.freebsd.org) Message-Id: <201309301735.r8UHZmp5014697@svn.freebsd.org> From: John-Mark Gurney Date: Mon, 30 Sep 2013 17:35:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r255950 - stable/8/sys/fs/cd9660 X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Sep 2013 17:35:48 -0000 Author: jmg Date: Mon Sep 30 17:35:48 2013 New Revision: 255950 URL: http://svnweb.freebsd.org/changeset/base/255950 Log: MFC: r255866, r255867 fix a bug where we access a bread buffer after we have brelse'd it... The kernel normally didn't unmap/context switch away before we accessed the buffer most of the time, but under heavy I/O pressure and lots of mount/unmounting this would cause a fault on nofault panic... NULL stale pointers (should be a no-op as they should no longer be used)... Modified: stable/8/sys/fs/cd9660/cd9660_vfsops.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/fs/ (props changed) Modified: stable/8/sys/fs/cd9660/cd9660_vfsops.c ============================================================================== --- stable/8/sys/fs/cd9660/cd9660_vfsops.c Mon Sep 30 17:23:45 2013 (r255949) +++ stable/8/sys/fs/cd9660/cd9660_vfsops.c Mon Sep 30 17:35:48 2013 (r255950) @@ -369,6 +369,9 @@ iso_mountfs(devvp, mp) pribp->b_flags |= B_AGE; brelse(pribp); pribp = NULL; + rootp = NULL; + pri = NULL; + pri_sierra = NULL; mp->mnt_data = isomp; mp->mnt_stat.f_fsid.val[0] = dev2udev(dev); @@ -391,11 +394,11 @@ iso_mountfs(devvp, mp) /* Check the Rock Ridge Extension support */ if (!(isomp->im_flags & ISOFSMNT_NORRIP)) { - if ((error = bread(isomp->im_devvp, - (isomp->root_extent + isonum_711(rootp->ext_attr_length)) << - (isomp->im_bshift - DEV_BSHIFT), - isomp->logical_block_size, NOCRED, &bp)) != 0) - goto out; + if ((error = bread(isomp->im_devvp, (isomp->root_extent + + isonum_711(((struct iso_directory_record *)isomp->root)-> + ext_attr_length)) << (isomp->im_bshift - DEV_BSHIFT), + isomp->logical_block_size, NOCRED, &bp)) != 0) + goto out; rootp = (struct iso_directory_record *)bp->b_data; @@ -412,6 +415,7 @@ iso_mountfs(devvp, mp) bp->b_flags |= B_AGE; brelse(bp); bp = NULL; + rootp = NULL; } if (isomp->im_flags & ISOFSMNT_KICONV && cd9660_iconv) { @@ -466,6 +470,7 @@ iso_mountfs(devvp, mp) if (supbp) { brelse(supbp); supbp = NULL; + sup = NULL; } return 0; From owner-svn-src-stable-8@FreeBSD.ORG Tue Oct 1 00:49:58 2013 Return-Path: Delivered-To: svn-src-stable-8@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 C222960D; Tue, 1 Oct 2013 00:49:58 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (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 AF7652088; Tue, 1 Oct 2013 00:49:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r910nw7E056532; Tue, 1 Oct 2013 00:49:58 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r910nwgg056531; Tue, 1 Oct 2013 00:49:58 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201310010049.r910nwgg056531@svn.freebsd.org> From: Xin LI Date: Tue, 1 Oct 2013 00:49:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r255959 - in stable: 8/sys/dev/nfe 9/sys/dev/nfe X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Oct 2013 00:49:58 -0000 Author: delphij Date: Tue Oct 1 00:49:57 2013 New Revision: 255959 URL: http://svnweb.freebsd.org/changeset/base/255959 Log: MFC r255648: Fix a typo when accounting for tx_broadcast statistics. Submitted by: Paul A. Patience Modified: stable/8/sys/dev/nfe/if_nfe.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/dev/ (props changed) stable/8/sys/dev/nfe/ (props changed) Changes in other areas also in this revision: Modified: stable/9/sys/dev/nfe/if_nfe.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/8/sys/dev/nfe/if_nfe.c ============================================================================== --- stable/8/sys/dev/nfe/if_nfe.c Mon Sep 30 21:26:03 2013 (r255958) +++ stable/8/sys/dev/nfe/if_nfe.c Tue Oct 1 00:49:57 2013 (r255959) @@ -3261,7 +3261,7 @@ nfe_stats_update(struct nfe_softc *sc) if ((sc->nfe_flags & NFE_MIB_V3) != 0) { stats->tx_unicast += NFE_READ(sc, NFE_TX_UNICAST); stats->tx_multicast += NFE_READ(sc, NFE_TX_MULTICAST); - stats->rx_broadcast += NFE_READ(sc, NFE_TX_BROADCAST); + stats->tx_broadcast += NFE_READ(sc, NFE_TX_BROADCAST); } } From owner-svn-src-stable-8@FreeBSD.ORG Tue Oct 1 08:41:29 2013 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org 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 ESMTP id C704EBAE; Tue, 1 Oct 2013 08:41:29 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (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 B363727FF; Tue, 1 Oct 2013 08:41:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r918fTjQ010083; Tue, 1 Oct 2013 08:41:29 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r918fTa0010077; Tue, 1 Oct 2013 08:41:29 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201310010841.r918fTa0010077@svn.freebsd.org> From: Hans Petter Selasky Date: Tue, 1 Oct 2013 08:41:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r255966 - stable/8/sys/dev/usb/controller X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Oct 2013 08:41:29 -0000 Author: hselasky Date: Tue Oct 1 08:41:28 2013 New Revision: 255966 URL: http://svnweb.freebsd.org/changeset/base/255966 Log: MFC r255768: Stability fixes for Intel LynxPoint XHCI controllers. Disable XHCI port routing if we get certain errors. Poll for command completion upon command timeouts. The XHCI error events might not generate interrupts. PR: usb/181159 Modified: stable/8/sys/dev/usb/controller/xhci.c stable/8/sys/dev/usb/controller/xhci.h stable/8/sys/dev/usb/controller/xhci_pci.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/dev/ (props changed) stable/8/sys/dev/usb/ (props changed) Modified: stable/8/sys/dev/usb/controller/xhci.c ============================================================================== --- stable/8/sys/dev/usb/controller/xhci.c Tue Oct 1 08:38:47 2013 (r255965) +++ stable/8/sys/dev/usb/controller/xhci.c Tue Oct 1 08:41:28 2013 (r255966) @@ -94,6 +94,8 @@ TUNABLE_INT("hw.usb.xhci.debug", &xhcide SYSCTL_INT(_hw_usb_xhci, OID_AUTO, xhci_port_route, CTLFLAG_RW | CTLFLAG_TUN, &xhciroute, 0, "Routing bitmap for switching EHCI ports to XHCI controller"); TUNABLE_INT("hw.usb.xhci.xhci_port_route", &xhciroute); +#else +#define xhciroute 0 #endif #define XHCI_INTR_ENDPT 1 @@ -179,16 +181,6 @@ xhci_dump_device(struct xhci_softc *sc, } #endif -uint32_t -xhci_get_port_route(void) -{ -#ifdef USB_DEBUG - return (0xFFFFFFFFU ^ ((uint32_t)xhciroute)); -#else - return (0xFFFFFFFFU); -#endif -} - static void xhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb) { @@ -480,6 +472,11 @@ xhci_start_controller(struct xhci_softc /* catch any lost interrupts */ xhci_do_poll(&sc->sc_bus); + if (sc->sc_port_route != NULL) { + /* Route all ports to the XHCI by default */ + sc->sc_port_route(sc->sc_bus.parent, + ~xhciroute, xhciroute); + } return (0); } @@ -917,7 +914,7 @@ xhci_check_transfer(struct xhci_softc *s } } -static void +static int xhci_check_command(struct xhci_softc *sc, struct xhci_trb *trb) { if (sc->sc_cmd_addr == trb->qwTrb0) { @@ -925,16 +922,19 @@ xhci_check_command(struct xhci_softc *sc sc->sc_cmd_result[0] = trb->dwTrb2; sc->sc_cmd_result[1] = trb->dwTrb3; cv_signal(&sc->sc_cmd_cv); + return (1); /* command match */ } + return (0); } -static void +static int xhci_interrupt_poll(struct xhci_softc *sc) { struct usb_page_search buf_res; struct xhci_hw_root *phwr; uint64_t addr; uint32_t temp; + int retval = 0; uint16_t i; uint8_t event; uint8_t j; @@ -974,7 +974,7 @@ xhci_interrupt_poll(struct xhci_softc *s xhci_check_transfer(sc, &phwr->hwr_events[i]); break; case XHCI_TRB_EVENT_CMD_COMPLETE: - xhci_check_command(sc, &phwr->hwr_events[i]); + retval |= xhci_check_command(sc, &phwr->hwr_events[i]); break; default: DPRINTF("Unhandled event = %u\n", event); @@ -1011,6 +1011,8 @@ xhci_interrupt_poll(struct xhci_softc *s XWRITE4(sc, runt, XHCI_ERDP_LO(0), (uint32_t)addr); XWRITE4(sc, runt, XHCI_ERDP_HI(0), (uint32_t)(addr >> 32)); + + return (retval); } static usb_error_t @@ -1098,7 +1100,15 @@ xhci_do_command(struct xhci_softc *sc, s err = cv_timedwait(&sc->sc_cmd_cv, &sc->sc_bus.bus_mtx, USB_MS_TO_TICKS(timeout_ms)); - if (err) { + /* + * In some error cases event interrupts are not generated. + * Poll one time to see if the command has completed. + */ + if (err != 0 && xhci_interrupt_poll(sc) != 0) { + DPRINTF("Command was completed when polling\n"); + err = 0; + } + if (err != 0) { DPRINTFN(0, "Command timeout!\n"); err = USB_ERR_TIMEOUT; trb->dwTrb2 = 0; @@ -1277,6 +1287,14 @@ xhci_set_address(struct usb_device *udev (address == 0), index); if (err != 0) { + temp = le32toh(sc->sc_cmd_result[0]); + if (address == 0 && sc->sc_port_route != NULL && + XHCI_TRB_2_ERROR_GET(temp) == + XHCI_TRB_ERROR_PARAMETER) { + /* LynxPoint XHCI - ports are not switchable */ + /* Un-route all ports from the XHCI */ + sc->sc_port_route(sc->sc_bus.parent, 0, ~0); + } DPRINTF("Could not set address " "for slot %u.\n", index); if (address != 0) Modified: stable/8/sys/dev/usb/controller/xhci.h ============================================================================== --- stable/8/sys/dev/usb/controller/xhci.h Tue Oct 1 08:38:47 2013 (r255965) +++ stable/8/sys/dev/usb/controller/xhci.h Tue Oct 1 08:41:28 2013 (r255966) @@ -421,6 +421,8 @@ union xhci_hub_desc { uint8_t temp[128]; }; +typedef int (xhci_port_route_t)(device_t, uint32_t, uint32_t); + struct xhci_softc { struct xhci_hw_softc sc_hw; /* base device */ @@ -429,6 +431,8 @@ struct xhci_softc { struct usb_process sc_config_proc; struct usb_bus_msg sc_config_msg[2]; + xhci_port_route_t *sc_port_route; + union xhci_hub_desc sc_hub_desc; struct cv sc_cmd_cv; @@ -490,7 +494,6 @@ struct xhci_softc { /* prototypes */ -uint32_t xhci_get_port_route(void); usb_error_t xhci_halt_controller(struct xhci_softc *); usb_error_t xhci_init(struct xhci_softc *, device_t); usb_error_t xhci_start_controller(struct xhci_softc *); Modified: stable/8/sys/dev/usb/controller/xhci_pci.c ============================================================================== --- stable/8/sys/dev/usb/controller/xhci_pci.c Tue Oct 1 08:38:47 2013 (r255965) +++ stable/8/sys/dev/usb/controller/xhci_pci.c Tue Oct 1 08:41:28 2013 (r255966) @@ -130,6 +130,25 @@ xhci_pci_probe(device_t self) } static int +xhci_pci_port_route(device_t self, uint32_t set, uint32_t clear) +{ + uint32_t temp; + + temp = pci_read_config(self, PCI_XHCI_INTEL_USB3_PSSEN, 4) | + pci_read_config(self, PCI_XHCI_INTEL_XUSB2PR, 4); + + temp |= set; + temp &= ~clear; + + pci_write_config(self, PCI_XHCI_INTEL_USB3_PSSEN, temp, 4); + pci_write_config(self, PCI_XHCI_INTEL_XUSB2PR, temp, 4); + + device_printf(self, "Port routing mask set to 0x%08x\n", temp); + + return (0); +} + +static int xhci_pci_attach(device_t self) { struct xhci_softc *sc = device_get_softc(self); @@ -184,6 +203,16 @@ xhci_pci_attach(device_t self) sc->sc_intr_hdl = NULL; goto error; } + /* On Intel chipsets reroute ports from EHCI to XHCI controller. */ + switch (pci_get_devid(self)) { + case 0x1e318086: /* Panther Point */ + case 0x8c318086: /* Lynx Point */ + sc->sc_port_route = &xhci_pci_port_route; + break; + default: + break; + } + xhci_pci_take_controller(self); err = xhci_halt_controller(sc); @@ -247,7 +276,6 @@ static int xhci_pci_take_controller(device_t self) { struct xhci_softc *sc = device_get_softc(self); - uint32_t device_id = pci_get_devid(self); uint32_t cparams; uint32_t eecp; uint32_t eec; @@ -288,13 +316,5 @@ xhci_pci_take_controller(device_t self) usb_pause_mtx(NULL, hz / 100); /* wait 10ms */ } } - - /* On Intel chipsets reroute ports from EHCI to XHCI controller. */ - if (device_id == 0x1e318086 /* Panther Point */ || - device_id == 0x8c318086 /* Lynx Point */) { - uint32_t temp = xhci_get_port_route(); - pci_write_config(self, PCI_XHCI_INTEL_USB3_PSSEN, temp, 4); - pci_write_config(self, PCI_XHCI_INTEL_XUSB2PR, temp, 4); - } return (0); } From owner-svn-src-stable-8@FreeBSD.ORG Thu Oct 3 18:50:10 2013 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org 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 ESMTP id 5C916B6F; Thu, 3 Oct 2013 18:50:10 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (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 3B9672839; Thu, 3 Oct 2013 18:50:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r93IoASk054110; Thu, 3 Oct 2013 18:50:10 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r93Io9XE053792; Thu, 3 Oct 2013 18:50:09 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201310031850.r93Io9XE053792@svn.freebsd.org> From: Mikolaj Golub Date: Thu, 3 Oct 2013 18:50:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r256026 - stable/8/usr.sbin/daemon X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Oct 2013 18:50:10 -0000 Author: trociny Date: Thu Oct 3 18:50:09 2013 New Revision: 256026 URL: http://svnweb.freebsd.org/changeset/base/256026 Log: MFC r255521, r255526, r255707: r255521 (jmg): add support for writing the pid of the daemon program to a pid file so that daemon can be used w/ rc.subr and ports can use the additional functionality, such as keeping the ldap daemon up and running, and have the proper program to signal to exit. PR: bin/181341 Submitted by: feld r255526 (joel): mdoc: remove EOL whitespace. r255707: 1. Properly clean pid files in the case of the error. 2. Write the supervisor pid before the restart loop, so we don't uselessly rewrite it after every child restart. 3. Remove duplicate ppfh and pfh initialization. Modified: stable/8/usr.sbin/daemon/daemon.8 stable/8/usr.sbin/daemon/daemon.c Directory Properties: stable/8/usr.sbin/daemon/ (props changed) Modified: stable/8/usr.sbin/daemon/daemon.8 ============================================================================== --- stable/8/usr.sbin/daemon/daemon.8 Thu Oct 3 18:48:43 2013 (r256025) +++ stable/8/usr.sbin/daemon/daemon.8 Thu Oct 3 18:50:09 2013 (r256026) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 4, 2012 +.Dd September 13, 2013 .Dt DAEMON 8 .Os .Sh NAME @@ -35,7 +35,8 @@ .Sh SYNOPSIS .Nm .Op Fl cfr -.Op Fl p Ar pidfile +.Op Fl p Ar child_pidfile +.Op Fl P Ar supervisor_pidfile .Op Fl u Ar user .Ar command arguments ... .Sh DESCRIPTION @@ -53,19 +54,39 @@ Change the current working directory to .It Fl f Redirect standard input, standard output and standard error to .Pa /dev/null . -.It Fl p Ar file +.It Fl p Ar child_pidfile Write the ID of the created process into the -.Ar file +.Ar child_pidfile using the .Xr pidfile 3 functionality. The program is executed in a spawned child process while the .Nm waits until it terminates to keep the -.Ar file +.Ar child_pidfile locked and removes it after the process exits. The -.Ar file +.Ar child_pidfile +owner is the user who runs the +.Nm +regardless of whether the +.Fl u +option is used or not. +.It Fl P Ar supervisor_pidfile +Write the ID of the +.Nm +process into the +.Ar supervisor_pidfile +using the +.Xr pidfile 3 +functionality. +The program is executed in a spawned child process while the +.Nm +waits until it terminates to keep the +.Ar supervisor_pidfile +locked and removes it after the process exits. +The +.Ar supervisor_pidfile owner is the user who runs the .Nm regardless of whether the @@ -79,27 +100,46 @@ Requires adequate superuser privileges. .El .Pp If the -.Fl p +.Fl p , +.Fl P or .Fl r option is specified the program is executed in a spawned child process. The .Nm -waits until it terminates to keep the pid file locked and removes it +waits until it terminates to keep the pid file(s) locked and removes them after the process exits or restarts the program. In this case if the monitoring .Nm receives software termination signal (SIGTERM) it forwards it to the spawned process. -Normally it will cause the child to exit followed by the termination -of the supervising process after removing the pidfile. +Normally it will cause the child to exit, remove the pidfile(s) +and then terminate. +.Pp +The +.Fl P +option is useful combined with the +.Fl r +option as +.Ar supervisor_pidfile +contains the ID of the supervisor +not the child. This is especially important if you use +.Fl r +in an rc script as the +.Fl p +option will give you the child's ID to signal when you attempt to +stop the service, causing +.Nm +to restart the child. .Sh EXIT STATUS The .Nm utility exits 1 if an error is returned by the .Xr daemon 3 -library routine, 2 if the -.Ar pidfile +library routine, 2 if +.Ar child_pidfile +or +.Ar supervisor_pidfile is requested, but cannot be opened, 3 if process is already running (pidfile exists and is locked), otherwise 0. Modified: stable/8/usr.sbin/daemon/daemon.c ============================================================================== --- stable/8/usr.sbin/daemon/daemon.c Thu Oct 3 18:48:43 2013 (r256025) +++ stable/8/usr.sbin/daemon/daemon.c Thu Oct 3 18:50:09 2013 (r256026) @@ -53,16 +53,16 @@ static void usage(void); int main(int argc, char *argv[]) { - struct pidfh *pfh = NULL; + struct pidfh *ppfh, *pfh; sigset_t mask, oldmask; - int ch, nochdir, noclose, restart; - const char *pidfile, *user; + int ch, nochdir, noclose, restart, serrno; + const char *pidfile, *ppidfile, *user; pid_t otherpid, pid; nochdir = noclose = 1; restart = 0; - pidfile = user = NULL; - while ((ch = getopt(argc, argv, "cfp:ru:")) != -1) { + ppidfile = pidfile = user = NULL; + while ((ch = getopt(argc, argv, "cfp:P:ru:")) != -1) { switch (ch) { case 'c': nochdir = 0; @@ -73,6 +73,9 @@ main(int argc, char *argv[]) case 'p': pidfile = optarg; break; + case 'P': + ppidfile = optarg; + break; case 'r': restart = 1; break; @@ -89,7 +92,7 @@ main(int argc, char *argv[]) if (argc == 0) usage(); - pfh = NULL; + ppfh = pfh = NULL; /* * Try to open the pidfile before calling daemon(3), * to be able to report the error intelligently @@ -104,9 +107,27 @@ main(int argc, char *argv[]) err(2, "pidfile ``%s''", pidfile); } } + /* Do the same for actual daemon process. */ + if (ppidfile != NULL) { + ppfh = pidfile_open(ppidfile, 0600, &otherpid); + if (ppfh == NULL) { + serrno = errno; + pidfile_remove(pfh); + errno = serrno; + if (errno == EEXIST) { + errx(3, "process already running, pid: %d", + otherpid); + } + err(2, "ppidfile ``%s''", ppidfile); + } + } - if (daemon(nochdir, noclose) == -1) - err(1, NULL); + if (daemon(nochdir, noclose) == -1) { + warn("daemon"); + goto exit; + } + /* Write out parent pidfile if needed. */ + pidfile_write(ppfh); /* * If the pidfile or restart option is specified the daemon @@ -123,22 +144,28 @@ main(int argc, char *argv[]) * Restore default action for SIGTERM in case the * parent process decided to ignore it. */ - if (signal(SIGTERM, SIG_DFL) == SIG_ERR) - err(1, "signal"); + if (signal(SIGTERM, SIG_DFL) == SIG_ERR) { + warn("signal"); + goto exit; + } /* * Because SIGCHLD is ignored by default, setup dummy handler * for it, so we can mask it. */ - if (signal(SIGCHLD, dummy_sighandler) == SIG_ERR) - err(1, "signal"); + if (signal(SIGCHLD, dummy_sighandler) == SIG_ERR) { + warn("signal"); + goto exit; + } /* * Block interesting signals. */ sigemptyset(&mask); sigaddset(&mask, SIGTERM); sigaddset(&mask, SIGCHLD); - if (sigprocmask(SIG_SETMASK, &mask, &oldmask) == -1) - err(1, "sigprocmask"); + if (sigprocmask(SIG_SETMASK, &mask, &oldmask) == -1) { + warn("sigprocmask"); + goto exit; + } /* * Try to protect against pageout kill. Ignore the * error, madvise(2) will fail only if a process does @@ -152,8 +179,8 @@ restart: */ pid = fork(); if (pid == -1) { - pidfile_remove(pfh); - err(1, "fork"); + warn("fork"); + goto exit; } } if (pid <= 0) { @@ -176,13 +203,16 @@ restart: */ err(1, "%s", argv[0]); } + setproctitle("%s[%d]", argv[0], pid); if (wait_child(pid, &mask) == 0 && restart) { sleep(1); goto restart; } +exit: pidfile_remove(pfh); - exit(0); /* Exit status does not matter. */ + pidfile_remove(ppfh); + exit(1); /* If daemon(3) succeeded exit status does not matter. */ } static void @@ -240,7 +270,7 @@ static void usage(void) { (void)fprintf(stderr, - "usage: daemon [-cfr] [-p pidfile] [-u user] command " - "arguments ...\n"); + "usage: daemon [-cfr] [-p child_pidfile] [-P supervisor_pidfile] " + "[-u user]\n command arguments ...\n"); exit(1); } From owner-svn-src-stable-8@FreeBSD.ORG Thu Oct 3 18:53:14 2013 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org 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 ESMTP id 4B799DF5; Thu, 3 Oct 2013 18:53:14 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (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 2B86D2881; Thu, 3 Oct 2013 18:53:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r93IrEp0055695; Thu, 3 Oct 2013 18:53:14 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r93IrD2l055692; Thu, 3 Oct 2013 18:53:13 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201310031853.r93IrD2l055692@svn.freebsd.org> From: Mikolaj Golub Date: Thu, 3 Oct 2013 18:53:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r256028 - stable/8/sbin/hastd X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Oct 2013 18:53:14 -0000 Author: trociny Date: Thu Oct 3 18:53:13 2013 New Revision: 256028 URL: http://svnweb.freebsd.org/changeset/base/256028 Log: MFC r255714, r255716, r255717: r255714: Use cv_broadcast() instead of cv_signal() when waking up threads waiting on an empty queue as the queue may have several consumers. Before the fix the following scenario was possible: 2 threads are waiting on empty queue, 2 threads are inserting simultaneously. The first inserting thread detects that the queue is empty and is going to send the signal, but before it sends the second thread inserts too. When the first sends the signal only one of the waiting threads receive it while the other one may wait forever. The scenario above is is believed to be the cause of the observed cases, when ggate_recv_thread() was getting stuck on taking free request, while the free queue was not empty. Reviewed by: pjd Tested by: Yamagi Burmeister yamagi.org r255716: When updating the map of dirty extents, most recently used extents are kept dirty to reduce the number of on-disk metadata updates. The sequence of operations is: 1) acquire the activemap lock; 2) update in-memory map; 3) if the list of keepdirty extents is changed, update on-disk metadata; 4) release the lock. On-disk updates are not frequent in comparison with in-memory updates, while require much more time. So situations are possible when one thread is updating on-disk metadata and another one is waiting for the activemap lock just to update the in-memory map. Improve this by introducing additional, on-disk map lock: when in-memory map is updated and it is detected that the on-disk map needs update too, the on-disk map lock is acquired and the on-memory lock is released before flushing the map. Reported by: Yamagi Burmeister yamagi.org Tested by: Yamagi Burmeister yamagi.org Reviewed by: pjd r255717: Fix comments. Modified: stable/8/sbin/hastd/hast.h stable/8/sbin/hastd/primary.c stable/8/sbin/hastd/secondary.c Directory Properties: stable/8/sbin/hastd/ (props changed) Modified: stable/8/sbin/hastd/hast.h ============================================================================== --- stable/8/sbin/hastd/hast.h Thu Oct 3 18:52:04 2013 (r256027) +++ stable/8/sbin/hastd/hast.h Thu Oct 3 18:53:13 2013 (r256028) @@ -226,8 +226,10 @@ struct hast_resource { /* Activemap structure. */ struct activemap *hr_amp; - /* Locked used to synchronize access to hr_amp. */ + /* Lock used to synchronize access to hr_amp. */ pthread_mutex_t hr_amp_lock; + /* Lock used to synchronize access to hr_amp diskmap. */ + pthread_mutex_t hr_amp_diskmap_lock; /* Number of BIO_READ requests. */ uint64_t hr_stat_read; Modified: stable/8/sbin/hastd/primary.c ============================================================================== --- stable/8/sbin/hastd/primary.c Thu Oct 3 18:52:04 2013 (r256027) +++ stable/8/sbin/hastd/primary.c Thu Oct 3 18:53:13 2013 (r256028) @@ -172,7 +172,7 @@ static pthread_mutex_t metadata_lock; hio_next[(ncomp)]); \ mtx_unlock(&hio_##name##_list_lock[ncomp]); \ if (_wakeup) \ - cv_signal(&hio_##name##_list_cond[(ncomp)]); \ + cv_broadcast(&hio_##name##_list_cond[(ncomp)]); \ } while (0) #define QUEUE_INSERT2(hio, name) do { \ bool _wakeup; \ @@ -182,7 +182,7 @@ static pthread_mutex_t metadata_lock; TAILQ_INSERT_TAIL(&hio_##name##_list, (hio), hio_##name##_next);\ mtx_unlock(&hio_##name##_list_lock); \ if (_wakeup) \ - cv_signal(&hio_##name##_list_cond); \ + cv_broadcast(&hio_##name##_list_cond); \ } while (0) #define QUEUE_TAKE1(hio, name, ncomp, timeout) do { \ bool _last; \ @@ -291,22 +291,28 @@ primary_exitx(int exitcode, const char * exit(exitcode); } +/* Expects res->hr_amp locked, returns unlocked. */ static int hast_activemap_flush(struct hast_resource *res) { const unsigned char *buf; size_t size; + int ret; + mtx_lock(&res->hr_amp_diskmap_lock); buf = activemap_bitmap(res->hr_amp, &size); + mtx_unlock(&res->hr_amp_lock); PJDLOG_ASSERT(buf != NULL); PJDLOG_ASSERT((size % res->hr_local_sectorsize) == 0); + ret = 0; if (pwrite(res->hr_localfd, buf, size, METADATA_SIZE) != (ssize_t)size) { pjdlog_errno(LOG_ERR, "Unable to flush activemap to disk"); res->hr_stat_activemap_write_error++; - return (-1); + ret = -1; } - if (res->hr_metaflush == 1 && g_flush(res->hr_localfd) == -1) { + if (ret == 0 && res->hr_metaflush == 1 && + g_flush(res->hr_localfd) == -1) { if (errno == EOPNOTSUPP) { pjdlog_warning("The %s provider doesn't support flushing write cache. Disabling it.", res->hr_localpath); @@ -315,10 +321,11 @@ hast_activemap_flush(struct hast_resourc pjdlog_errno(LOG_ERR, "Unable to flush disk cache on activemap update"); res->hr_stat_activemap_flush_error++; - return (-1); + ret = -1; } } - return (0); + mtx_unlock(&res->hr_amp_diskmap_lock); + return (ret); } static bool @@ -783,6 +790,7 @@ init_remote(struct hast_resource *res, s * Now that we merged bitmaps from both nodes, flush it to the * disk before we start to synchronize. */ + mtx_lock(&res->hr_amp_lock); (void)hast_activemap_flush(res); } nv_free(nvin); @@ -1288,8 +1296,9 @@ ggate_recv_thread(void *arg) ggio->gctl_offset, ggio->gctl_length)) { res->hr_stat_activemap_update++; (void)hast_activemap_flush(res); + } else { + mtx_unlock(&res->hr_amp_lock); } - mtx_unlock(&res->hr_amp_lock); break; case BIO_DELETE: res->hr_stat_delete++; @@ -1649,8 +1658,9 @@ done_queue: if (activemap_need_sync(res->hr_amp, ggio->gctl_offset, ggio->gctl_length)) { (void)hast_activemap_flush(res); + } else { + mtx_unlock(&res->hr_amp_lock); } - mtx_unlock(&res->hr_amp_lock); if (hio->hio_replication == HAST_REPLICATION_MEMSYNC) (void)refcnt_release(&hio->hio_countdown); } @@ -1917,8 +1927,9 @@ ggate_send_thread(void *arg) ggio->gctl_offset, ggio->gctl_length)) { res->hr_stat_activemap_update++; (void)hast_activemap_flush(res); + } else { + mtx_unlock(&res->hr_amp_lock); } - mtx_unlock(&res->hr_amp_lock); } if (ggio->gctl_cmd == BIO_WRITE) { /* @@ -2014,8 +2025,11 @@ sync_thread(void *arg __unused) */ if (activemap_extent_complete(res->hr_amp, syncext)) (void)hast_activemap_flush(res); + else + mtx_unlock(&res->hr_amp_lock); + } else { + mtx_unlock(&res->hr_amp_lock); } - mtx_unlock(&res->hr_amp_lock); if (dorewind) { dorewind = false; if (offset == -1) Modified: stable/8/sbin/hastd/secondary.c ============================================================================== --- stable/8/sbin/hastd/secondary.c Thu Oct 3 18:52:04 2013 (r256027) +++ stable/8/sbin/hastd/secondary.c Thu Oct 3 18:53:13 2013 (r256028) @@ -85,14 +85,13 @@ static TAILQ_HEAD(, hio) hio_free_list; static pthread_mutex_t hio_free_list_lock; static pthread_cond_t hio_free_list_cond; /* - * Disk thread (the one that do I/O requests) takes requests from this list. + * Disk thread (the one that does I/O requests) takes requests from this list. */ static TAILQ_HEAD(, hio) hio_disk_list; static pthread_mutex_t hio_disk_list_lock; static pthread_cond_t hio_disk_list_cond; /* - * There is one recv list for every component, although local components don't - * use recv lists as local requests are done synchronously. + * Thread that sends requests back to primary takes requests from this list. */ static TAILQ_HEAD(, hio) hio_send_list; static pthread_mutex_t hio_send_list_lock; @@ -115,7 +114,7 @@ static void *send_thread(void *arg); TAILQ_INSERT_TAIL(&hio_##name##_list, (hio), hio_next); \ mtx_unlock(&hio_##name##_list_lock); \ if (_wakeup) \ - cv_signal(&hio_##name##_list_cond); \ + cv_broadcast(&hio_##name##_list_cond); \ } while (0) #define QUEUE_TAKE(name, hio) do { \ mtx_lock(&hio_##name##_list_lock); \ From owner-svn-src-stable-8@FreeBSD.ORG Thu Oct 3 23:56:39 2013 Return-Path: Delivered-To: svn-src-stable-8@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 A8B5D23D; Thu, 3 Oct 2013 23:56:39 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (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 8551728F8; Thu, 3 Oct 2013 23:56:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r93NudAK016375; Thu, 3 Oct 2013 23:56:39 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r93NudwB016365; Thu, 3 Oct 2013 23:56:39 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201310032356.r93NudwB016365@svn.freebsd.org> From: Xin LI Date: Thu, 3 Oct 2013 23:56:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r256034 - stable/8/sys/dev/arcmsr X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Oct 2013 23:56:39 -0000 Author: delphij Date: Thu Oct 3 23:56:38 2013 New Revision: 256034 URL: http://svnweb.freebsd.org/changeset/base/256034 Log: MFC r252857,255718: Refresh vendor driver version which fixes command queue full issue with ARC-1214 and ARC-1224. Update arcmsr(4) driver to 1.20.00.28 which fixes mutex recursion in CCB abort codepath. Many thanks to Areca for continuing to support FreeBSD. Submitted by: 黃清隆 Modified: stable/8/sys/dev/arcmsr/arcmsr.c stable/8/sys/dev/arcmsr/arcmsr.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/dev/ (props changed) stable/8/sys/dev/arcmsr/ (props changed) Modified: stable/8/sys/dev/arcmsr/arcmsr.c ============================================================================== --- stable/8/sys/dev/arcmsr/arcmsr.c Thu Oct 3 23:52:02 2013 (r256033) +++ stable/8/sys/dev/arcmsr/arcmsr.c Thu Oct 3 23:56:38 2013 (r256034) @@ -35,44 +35,46 @@ ******************************************************************************** ** History ** -** REV# DATE NAME DESCRIPTION -** 1.00.00.00 03/31/2004 Erich Chen First release -** 1.20.00.02 11/29/2004 Erich Chen bug fix with arcmsr_bus_reset when PHY error -** 1.20.00.03 04/19/2005 Erich Chen add SATA 24 Ports adapter type support -** clean unused function -** 1.20.00.12 09/12/2005 Erich Chen bug fix with abort command handling, -** firmware version check -** and firmware update notify for hardware bug fix -** handling if none zero high part physical address -** of srb resource -** 1.20.00.13 08/18/2006 Erich Chen remove pending srb and report busy -** add iop message xfer -** with scsi pass-through command -** add new device id of sas raid adapters -** code fit for SPARC64 & PPC -** 1.20.00.14 02/05/2007 Erich Chen bug fix for incorrect ccb_h.status report -** and cause g_vfs_done() read write error -** 1.20.00.15 10/10/2007 Erich Chen support new RAID adapter type ARC120x -** 1.20.00.16 10/10/2009 Erich Chen Bug fix for RAID adapter type ARC120x -** bus_dmamem_alloc() with BUS_DMA_ZERO -** 1.20.00.17 07/15/2010 Ching Huang Added support ARC1880 -** report CAM_DEV_NOT_THERE instead of CAM_SEL_TIMEOUT when device failed, -** prevent cam_periph_error removing all LUN devices of one Target id -** for any one LUN device failed -** 1.20.00.18 10/14/2010 Ching Huang Fixed "inquiry data fails comparion at DV1 step" -** 10/25/2010 Ching Huang Fixed bad range input in bus_alloc_resource for ADAPTER_TYPE_B -** 1.20.00.19 11/11/2010 Ching Huang Fixed arcmsr driver prevent arcsas support for Areca SAS HBA ARC13x0 -** 1.20.00.20 12/08/2010 Ching Huang Avoid calling atomic_set_int function -** 1.20.00.21 02/08/2011 Ching Huang Implement I/O request timeout -** 02/14/2011 Ching Huang Modified pktRequestCount -** 1.20.00.21 03/03/2011 Ching Huang if a command timeout, then wait its ccb back before free it -** 1.20.00.22 07/04/2011 Ching Huang Fixed multiple MTX panic -** 1.20.00.23 10/28/2011 Ching Huang Added TIMEOUT_DELAY in case of too many HDDs need to start -** 1.20.00.23 11/08/2011 Ching Huang Added report device transfer speed -** 1.20.00.23 01/30/2012 Ching Huang Fixed Request requeued and Retrying command -** 1.20.00.24 06/11/2012 Ching Huang Fixed return sense data condition -** 1.20.00.25 08/17/2012 Ching Huang Fixed hotplug device no function on type A adapter -** 1.20.00.26 12/14/2012 Ching Huang Added support ARC1214,1224 +** REV# DATE NAME DESCRIPTION +** 1.00.00.00 03/31/2004 Erich Chen First release +** 1.20.00.02 11/29/2004 Erich Chen bug fix with arcmsr_bus_reset when PHY error +** 1.20.00.03 04/19/2005 Erich Chen add SATA 24 Ports adapter type support +** clean unused function +** 1.20.00.12 09/12/2005 Erich Chen bug fix with abort command handling, +** firmware version check +** and firmware update notify for hardware bug fix +** handling if none zero high part physical address +** of srb resource +** 1.20.00.13 08/18/2006 Erich Chen remove pending srb and report busy +** add iop message xfer +** with scsi pass-through command +** add new device id of sas raid adapters +** code fit for SPARC64 & PPC +** 1.20.00.14 02/05/2007 Erich Chen bug fix for incorrect ccb_h.status report +** and cause g_vfs_done() read write error +** 1.20.00.15 10/10/2007 Erich Chen support new RAID adapter type ARC120x +** 1.20.00.16 10/10/2009 Erich Chen Bug fix for RAID adapter type ARC120x +** bus_dmamem_alloc() with BUS_DMA_ZERO +** 1.20.00.17 07/15/2010 Ching Huang Added support ARC1880 +** report CAM_DEV_NOT_THERE instead of CAM_SEL_TIMEOUT when device failed, +** prevent cam_periph_error removing all LUN devices of one Target id +** for any one LUN device failed +** 1.20.00.18 10/14/2010 Ching Huang Fixed "inquiry data fails comparion at DV1 step" +** 10/25/2010 Ching Huang Fixed bad range input in bus_alloc_resource for ADAPTER_TYPE_B +** 1.20.00.19 11/11/2010 Ching Huang Fixed arcmsr driver prevent arcsas support for Areca SAS HBA ARC13x0 +** 1.20.00.20 12/08/2010 Ching Huang Avoid calling atomic_set_int function +** 1.20.00.21 02/08/2011 Ching Huang Implement I/O request timeout +** 02/14/2011 Ching Huang Modified pktRequestCount +** 1.20.00.21 03/03/2011 Ching Huang if a command timeout, then wait its ccb back before free it +** 1.20.00.22 07/04/2011 Ching Huang Fixed multiple MTX panic +** 1.20.00.23 10/28/2011 Ching Huang Added TIMEOUT_DELAY in case of too many HDDs need to start +** 1.20.00.23 11/08/2011 Ching Huang Added report device transfer speed +** 1.20.00.23 01/30/2012 Ching Huang Fixed Request requeued and Retrying command +** 1.20.00.24 06/11/2012 Ching Huang Fixed return sense data condition +** 1.20.00.25 08/17/2012 Ching Huang Fixed hotplug device no function on type A adapter +** 1.20.00.26 12/14/2012 Ching Huang Added support ARC1214,1224,1264,1284 +** 1.20.00.27 05/06/2013 Ching Huang Fixed out standing cmd full on ARC-12x4 +** 1.20.00.28 09/13/2013 Ching Huang Removed recursive mutex in arcmsr_abort_dr_ccbs ****************************************************************************************** */ @@ -144,7 +146,7 @@ __FBSDID("$FreeBSD$"); #define arcmsr_callout_init(a) callout_init(a); #endif -#define ARCMSR_DRIVER_VERSION "Driver Version 1.20.00.26 2013-01-08" +#define ARCMSR_DRIVER_VERSION "arcmsr version 1.20.00.28 2013-09-13" #include /* ************************************************************************** @@ -753,7 +755,7 @@ static void arcmsr_srb_complete(struct C if(stand_flag == 1) { atomic_subtract_int(&acb->srboutstandingcount, 1); if((acb->acb_flags & ACB_F_CAM_DEV_QFRZN) && ( - acb->srboutstandingcount < (acb->firm_numbers_queue -10))) { + acb->srboutstandingcount < (acb->maxOutstanding -10))) { acb->acb_flags &= ~ACB_F_CAM_DEV_QFRZN; pccb->ccb_h.status |= CAM_RELEASE_SIMQ; } @@ -1599,7 +1601,7 @@ static void arcmsr_rescan_lun(struct Ada if ((ccb = (union ccb *)xpt_alloc_ccb_nowait()) == NULL) return; - if (xpt_create_path(&path, xpt_periph, cam_sim_path(acb->psim), target, lun) != CAM_REQ_CMP) + if (xpt_create_path(&path, NULL, cam_sim_path(acb->psim), target, lun) != CAM_REQ_CMP) { xpt_free_ccb(ccb); return; @@ -1620,7 +1622,6 @@ static void arcmsr_abort_dr_ccbs(struct u_int32_t intmask_org; int i; - ARCMSR_LOCK_ACQUIRE(&acb->isr_lock); /* disable all outbound interrupts */ intmask_org = arcmsr_disable_allintr(acb); for (i = 0; i < ARCMSR_MAX_FREESRB_NUM; i++) @@ -1639,7 +1640,6 @@ static void arcmsr_abort_dr_ccbs(struct } /* enable outbound Post Queue, outbound doorbell Interrupt */ arcmsr_enable_allintr(acb, intmask_org); - ARCMSR_LOCK_RELEASE(&acb->isr_lock); } /* ************************************************************************** @@ -1939,11 +1939,11 @@ static void arcmsr_hbc_postqueue_isr(str /* check if command done with no error*/ error = (flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE1)?TRUE:FALSE; arcmsr_drain_donequeue(acb, flag_srb, error); + throttling++; if(throttling == ARCMSR_HBC_ISR_THROTTLING_LEVEL) { CHIP_REG_WRITE32(HBC_MessageUnit, 0, inbound_doorbell,ARCMSR_HBCMU_DRV2IOP_POSTQUEUE_THROTTLING); - break; + throttling = 0; } - throttling++; } /*drain reply FIFO*/ } /* @@ -2686,7 +2686,7 @@ static void arcmsr_execute_srb(void *arg arcmsr_srb_complete(srb, 0); return; } - if(acb->srboutstandingcount >= acb->firm_numbers_queue) { + if(acb->srboutstandingcount >= acb->maxOutstanding) { if((acb->acb_flags & ACB_F_CAM_DEV_QFRZN) == 0) { xpt_freeze_simq(acb->psim, 1); @@ -3461,13 +3461,16 @@ static void arcmsr_get_hba_config(struct acb_device_map++; i++; } - printf("ARECA RAID ADAPTER%d: %s \n", acb->pci_unit, ARCMSR_DRIVER_VERSION); - printf("ARECA RAID ADAPTER%d: FIRMWARE VERSION %s \n", acb->pci_unit, acb->firm_version); + printf("Areca RAID adapter%d: %s F/W version %s \n", acb->pci_unit, acb->firm_model, acb->firm_version); acb->firm_request_len = CHIP_REG_READ32(HBA_MessageUnit, 0, msgcode_rwbuffer[1]); /*firm_request_len, 1, 04-07*/ acb->firm_numbers_queue = CHIP_REG_READ32(HBA_MessageUnit, 0, msgcode_rwbuffer[2]); /*firm_numbers_queue, 2, 08-11*/ acb->firm_sdram_size = CHIP_REG_READ32(HBA_MessageUnit, 0, msgcode_rwbuffer[3]); /*firm_sdram_size, 3, 12-15*/ acb->firm_ide_channels = CHIP_REG_READ32(HBA_MessageUnit, 0, msgcode_rwbuffer[4]); /*firm_ide_channels, 4, 16-19*/ acb->firm_cfg_version = CHIP_REG_READ32(HBA_MessageUnit, 0, msgcode_rwbuffer[ARCMSR_FW_CFGVER_OFFSET]); /*firm_cfg_version, 25, */ + if(acb->firm_numbers_queue > ARCMSR_MAX_OUTSTANDING_CMD) + acb->maxOutstanding = ARCMSR_MAX_OUTSTANDING_CMD - 1; + else + acb->maxOutstanding = acb->firm_numbers_queue - 1; } /* ********************************************************************** @@ -3507,13 +3510,16 @@ static void arcmsr_get_hbb_config(struct acb_device_map++; i++; } - printf("ARECA RAID ADAPTER%d: %s \n", acb->pci_unit, ARCMSR_DRIVER_VERSION); - printf("ARECA RAID ADAPTER%d: FIRMWARE VERSION %s \n", acb->pci_unit, acb->firm_version); + printf("Areca RAID adapter%d: %s F/W version %s \n", acb->pci_unit, acb->firm_model, acb->firm_version); acb->firm_request_len = CHIP_REG_READ32(HBB_RWBUFFER, 1, msgcode_rwbuffer[1]); /*firm_request_len, 1, 04-07*/ acb->firm_numbers_queue = CHIP_REG_READ32(HBB_RWBUFFER, 1, msgcode_rwbuffer[2]); /*firm_numbers_queue, 2, 08-11*/ acb->firm_sdram_size = CHIP_REG_READ32(HBB_RWBUFFER, 1, msgcode_rwbuffer[3]); /*firm_sdram_size, 3, 12-15*/ acb->firm_ide_channels = CHIP_REG_READ32(HBB_RWBUFFER, 1, msgcode_rwbuffer[4]); /*firm_ide_channels, 4, 16-19*/ acb->firm_cfg_version = CHIP_REG_READ32(HBB_RWBUFFER, 1, msgcode_rwbuffer[ARCMSR_FW_CFGVER_OFFSET]); /*firm_cfg_version, 25, */ + if(acb->firm_numbers_queue > ARCMSR_MAX_HBB_POSTQUEUE) + acb->maxOutstanding = ARCMSR_MAX_HBB_POSTQUEUE - 1; + else + acb->maxOutstanding = acb->firm_numbers_queue - 1; } /* ********************************************************************** @@ -3554,13 +3560,16 @@ static void arcmsr_get_hbc_config(struct acb_device_map++; i++; } - printf("ARECA RAID ADAPTER%d: %s \n", acb->pci_unit, ARCMSR_DRIVER_VERSION); - printf("ARECA RAID ADAPTER%d: FIRMWARE VERSION %s \n", acb->pci_unit, acb->firm_version); + printf("Areca RAID adapter%d: %s F/W version %s \n", acb->pci_unit, acb->firm_model, acb->firm_version); acb->firm_request_len = CHIP_REG_READ32(HBC_MessageUnit, 0, msgcode_rwbuffer[1]); /*firm_request_len, 1, 04-07*/ acb->firm_numbers_queue = CHIP_REG_READ32(HBC_MessageUnit, 0, msgcode_rwbuffer[2]); /*firm_numbers_queue, 2, 08-11*/ acb->firm_sdram_size = CHIP_REG_READ32(HBC_MessageUnit, 0, msgcode_rwbuffer[3]); /*firm_sdram_size, 3, 12-15*/ acb->firm_ide_channels = CHIP_REG_READ32(HBC_MessageUnit, 0, msgcode_rwbuffer[4]); /*firm_ide_channels, 4, 16-19*/ acb->firm_cfg_version = CHIP_REG_READ32(HBC_MessageUnit, 0, msgcode_rwbuffer[ARCMSR_FW_CFGVER_OFFSET]); /*firm_cfg_version, 25, */ + if(acb->firm_numbers_queue > ARCMSR_MAX_OUTSTANDING_CMD) + acb->maxOutstanding = ARCMSR_MAX_OUTSTANDING_CMD - 1; + else + acb->maxOutstanding = acb->firm_numbers_queue - 1; } /* ********************************************************************** @@ -3602,13 +3611,16 @@ static void arcmsr_get_hbd_config(struct acb_device_map++; i++; } - printf("ARECA RAID ADAPTER%d: %s \n", acb->pci_unit, ARCMSR_DRIVER_VERSION); - printf("ARECA RAID ADAPTER%d: FIRMWARE VERSION %s \n", acb->pci_unit, acb->firm_version); + printf("Areca RAID adapter%d: %s F/W version %s \n", acb->pci_unit, acb->firm_model, acb->firm_version); acb->firm_request_len = CHIP_REG_READ32(HBD_MessageUnit, 0, msgcode_rwbuffer[2]); /*firm_request_len, 1, 04-07*/ acb->firm_numbers_queue = CHIP_REG_READ32(HBD_MessageUnit, 0, msgcode_rwbuffer[3]); /*firm_numbers_queue, 2, 08-11*/ acb->firm_sdram_size = CHIP_REG_READ32(HBD_MessageUnit, 0, msgcode_rwbuffer[4]); /*firm_sdram_size, 3, 12-15*/ acb->firm_ide_channels = CHIP_REG_READ32(HBD_MessageUnit, 0, msgcode_rwbuffer[5]); /*firm_ide_channels, 4, 16-19*/ acb->firm_cfg_version = CHIP_REG_READ32(HBD_MessageUnit, 0, msgcode_rwbuffer[ARCMSR_FW_CFGVER_OFFSET]); /*firm_cfg_version, 25, */ + if(acb->firm_numbers_queue > ARCMSR_MAX_HBD_POSTQUEUE) + acb->maxOutstanding = ARCMSR_MAX_HBD_POSTQUEUE - 1; + else + acb->maxOutstanding = acb->firm_numbers_queue - 1; } /* ********************************************************************** @@ -4285,6 +4297,8 @@ static int arcmsr_attach(device_t dev) return (ENOMEM); } arcmsr_mutex_init(acb); + acb->pci_dev = dev; + acb->pci_unit = unit; if(arcmsr_initialize(dev)) { printf("arcmsr%d: initialize failure!\n", unit); arcmsr_mutex_destroy(acb); @@ -4305,8 +4319,6 @@ static int arcmsr_attach(device_t dev) return ENXIO; } acb->irqres = irqres; - acb->pci_dev = dev; - acb->pci_unit = unit; /* * Now let the CAM generic SCSI layer find the SCSI devices on * the bus * start queue to reset to the idle loop. * @@ -4388,7 +4400,7 @@ static int arcmsr_probe(device_t dev) { u_int32_t id; static char buf[256]; - char x_type[]={"X-TYPE"}; + char x_type[]={"unknown"}; char *type; int raid6 = 1; @@ -4434,11 +4446,13 @@ static int arcmsr_probe(device_t dev) break; default: type = x_type; + raid6 = 0; break; } if(type == x_type) return(ENXIO); - sprintf(buf, "Areca %s Host Adapter RAID Controller %s\n", type, raid6 ? "(RAID6 capable)" : ""); + sprintf(buf, "Areca %s Host Adapter RAID Controller %s\n%s\n", + type, raid6 ? "(RAID6 capable)" : "", ARCMSR_DRIVER_VERSION); device_set_desc_copy(dev, buf); return 0; } Modified: stable/8/sys/dev/arcmsr/arcmsr.h ============================================================================== --- stable/8/sys/dev/arcmsr/arcmsr.h Thu Oct 3 23:52:02 2013 (r256033) +++ stable/8/sys/dev/arcmsr/arcmsr.h Thu Oct 3 23:56:38 2013 (r256034) @@ -1182,6 +1182,7 @@ struct AdapterControlBlock { u_int32_t pktReturnCount; u_int32_t vendor_device_id; u_int32_t adapter_bus_speed; + u_int32_t maxOutstanding; };/* HW_DEVICE_EXTENSION */ /* acb_flags */ #define ACB_F_SCSISTOPADAPTER 0x0001