From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 02:46:28 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 77D36106564A; Sun, 17 Jun 2012 02:46:28 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 614858FC0A; Sun, 17 Jun 2012 02:46:28 +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 q5H2kS4D079984; Sun, 17 Jun 2012 02:46:28 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5H2kSMT079981; Sun, 17 Jun 2012 02:46:28 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206170246.q5H2kSMT079981@svn.freebsd.org> From: Eitan Adler Date: Sun, 17 Jun 2012 02:46:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237178 - in head: share/man/man4 sys/dev/hptrr X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 02:46:28 -0000 Author: eadler Date: Sun Jun 17 02:46:27 2012 New Revision: 237178 URL: http://svn.freebsd.org/changeset/base/237178 Log: attach_generic causes missing devices in /dev when the driver interacts with some non-highpoint controollers. Change attach_generic to be off by default. PR: kern/168910 Submitted by: Richard Yao Approved by: cperciva No objections by: -hackers Obtained from: Gentoo FreeBSD MFC after: 2 weeks Modified: head/share/man/man4/hptrr.4 head/sys/dev/hptrr/hptrr_osm_bsd.c Modified: head/share/man/man4/hptrr.4 ============================================================================== --- head/share/man/man4/hptrr.4 Sun Jun 17 00:28:57 2012 (r237177) +++ head/share/man/man4/hptrr.4 Sun Jun 17 02:46:27 2012 (r237178) @@ -50,8 +50,8 @@ hptrr_load="YES" The following tunables are settable from the loader: .Bl -ohang .It Va hw.hptrr.attach_generic -set to 0 to deny driver attach to chips with generic Marvell (non-HighPoint) -PCI identification. These chips are also supported by ata(4). +set to 1 to permit driver attach to chips with generic Marvell (non-HighPoint) +PCI identification. These chips are also supported by ata(4) and mvs(4). Some vendors are using same chips, but without providing RAID BIOS. .El .Sh DESCRIPTION @@ -112,7 +112,8 @@ This driver supersedes the older rr232x .Xr ata 4 , .Xr cam 4 , .Xr hptmv 4 , -.Xr loader 8 +.Xr loader 8 , +.Xr mvs 4 .Sh HISTORY The .Nm Modified: head/sys/dev/hptrr/hptrr_osm_bsd.c ============================================================================== --- head/sys/dev/hptrr/hptrr_osm_bsd.c Sun Jun 17 00:28:57 2012 (r237177) +++ head/sys/dev/hptrr/hptrr_osm_bsd.c Sun Jun 17 02:46:27 2012 (r237178) @@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include -static int attach_generic = 1; +static int attach_generic = 0; TUNABLE_INT("hw.hptrr.attach_generic", &attach_generic); static int hpt_probe(device_t dev) From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 03:08:34 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DAE61106566B; Sun, 17 Jun 2012 03:08:34 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AD2168FC08; Sun, 17 Jun 2012 03:08:34 +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 q5H38Y1j081014; Sun, 17 Jun 2012 03:08:34 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5H38Ynh081012; Sun, 17 Jun 2012 03:08:34 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201206170308.q5H38Ynh081012@svn.freebsd.org> From: Adrian Chadd Date: Sun, 17 Jun 2012 03:08:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237179 - head/sys/dev/ath X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 03:08:34 -0000 Author: adrian Date: Sun Jun 17 03:08:33 2012 New Revision: 237179 URL: http://svn.freebsd.org/changeset/base/237179 Log: After some discussion with bschmidt@, it's likely better to just go through ieee80211_suspend_all() and ieee80211_resume_all(). All the other wireless drivers are doing that particular dance. PR: kern/169084 Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Sun Jun 17 02:46:27 2012 (r237178) +++ head/sys/dev/ath/if_ath.c Sun Jun 17 03:08:33 2012 (r237179) @@ -1309,15 +1309,8 @@ ath_suspend(struct ath_softc *sc) __func__, ifp->if_flags); sc->sc_resume_up = (ifp->if_flags & IFF_UP) != 0; - if (ic->ic_opmode == IEEE80211_M_STA) - /* - * This has been disabled - see PR kern/169084. - */ -#if 0 - ath_stop(ifp); - else -#endif - ieee80211_suspend_all(ic); + + ieee80211_suspend_all(ic); /* * NB: don't worry about putting the chip in low power * mode; pci will power off our socket on suspend and @@ -1383,34 +1376,8 @@ ath_resume(struct ath_softc *sc) ath_led_config(sc); ath_hal_setledstate(ah, HAL_LED_INIT); - if (sc->sc_resume_up) { - /* - * This particular feature doesn't work at the present, - * at least on the 802.11n chips. It's quite possible - * that the STA Beacon timers aren't being configured - * properly. - * - * See PR kern/169084. - */ -#if 0 - if (ic->ic_opmode == IEEE80211_M_STA) { - ath_init(sc); - ath_hal_setledstate(ah, HAL_LED_RUN); - /* - * Program the beacon registers using the last rx'd - * beacon frame and enable sync on the next beacon - * we see. This should handle the case where we - * wakeup and find the same AP and also the case where - * we wakeup and need to roam. For the latter we - * should get bmiss events that trigger a roam. - */ - ath_beacon_config(sc, NULL); - sc->sc_syncbeacon = 1; - ieee80211_resume_all(ic); - } else -#endif - ieee80211_resume_all(ic); - } + if (sc->sc_resume_up) + ieee80211_resume_all(ic); /* XXX beacons ? */ } From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 03:54:11 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7D7871065673; Sun, 17 Jun 2012 03:54:11 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 68EEF8FC0A; Sun, 17 Jun 2012 03:54:11 +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 q5H3sBBL083059; Sun, 17 Jun 2012 03:54:11 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5H3sBBr083057; Sun, 17 Jun 2012 03:54:11 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206170354.q5H3sBBr083057@svn.freebsd.org> From: Eitan Adler Date: Sun, 17 Jun 2012 03:54:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237180 - head/share/man/man4 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 03:54:11 -0000 Author: eadler Date: Sun Jun 17 03:54:10 2012 New Revision: 237180 URL: http://svn.freebsd.org/changeset/base/237180 Log: Fix mdoc style nits PR: kern/168910 Submitted by: gjb Approved by: gjb MFC after: 3 days X-MFC-With: r237178 Modified: head/share/man/man4/hptrr.4 Modified: head/share/man/man4/hptrr.4 ============================================================================== --- head/share/man/man4/hptrr.4 Sun Jun 17 03:08:33 2012 (r237179) +++ head/share/man/man4/hptrr.4 Sun Jun 17 03:54:10 2012 (r237180) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 8, 2009 +.Dd June 6, 2012 .Dt HPTRR 4 .Os .Sh NAME @@ -51,7 +51,10 @@ The following tunables are settable from .Bl -ohang .It Va hw.hptrr.attach_generic set to 1 to permit driver attach to chips with generic Marvell (non-HighPoint) -PCI identification. These chips are also supported by ata(4) and mvs(4). +PCI identification. These chips are also supported by +.Xr ata 4 +and +.Xr mvs 4 . Some vendors are using same chips, but without providing RAID BIOS. .El .Sh DESCRIPTION @@ -112,8 +115,8 @@ This driver supersedes the older rr232x .Xr ata 4 , .Xr cam 4 , .Xr hptmv 4 , -.Xr loader 8 , -.Xr mvs 4 +.Xr mvs 4 , +.Xr loader 8 .Sh HISTORY The .Nm From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 04:48:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4DF25106566B; Sun, 17 Jun 2012 04:48:48 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1FDE98FC0C; Sun, 17 Jun 2012 04:48:48 +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 q5H4mlIa085415; Sun, 17 Jun 2012 04:48:47 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5H4mlof085413; Sun, 17 Jun 2012 04:48:47 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201206170448.q5H4mlof085413@svn.freebsd.org> From: Adrian Chadd Date: Sun, 17 Jun 2012 04:48:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237182 - head/sys/dev/ath/ath_hal/ar9002 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 04:48:48 -0000 Author: adrian Date: Sun Jun 17 04:48:47 2012 New Revision: 237182 URL: http://svn.freebsd.org/changeset/base/237182 Log: Bring over the AR9285 specific PCIe suspend/resume/ASPM workarounds. Obtained from: Qualcomm Atheros, Linux ath9k Modified: head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c Modified: head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c Sun Jun 17 03:59:17 2012 (r237181) +++ head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c Sun Jun 17 04:48:47 2012 (r237182) @@ -367,18 +367,71 @@ bad: static void ar9285ConfigPCIE(struct ath_hal *ah, HAL_BOOL restore, HAL_BOOL power_off) { + uint32_t val; + if (AH_PRIVATE(ah)->ah_ispcie && !restore) { ath_hal_ini_write(ah, &AH5416(ah)->ah_ini_pcieserdes, 1, 0); OS_DELAY(1000); + } + + /* + * Set PCIe workaround bits + * + * NOTE: + * + * In Merlin and Kite, bit 14 in WA register (disable L1) should only + * be set when device enters D3 and be cleared when device comes back + * to D0. + */ + if (power_off) { /* Power-off */ + OS_REG_CLR_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA); + + val = OS_REG_READ(ah, AR_WA); + + /* + * Disable bit 6 and 7 before entering D3 to prevent + * system hang. + */ + val &= ~(AR_WA_BIT6 | AR_WA_BIT7); + + /* + * See above: set AR_WA_D3_L1_DISABLE when entering D3 state. + * + * XXX The reference HAL does it this way - it only sets + * AR_WA_D3_L1_DISABLE if it's set in AR9280_WA_DEFAULT, + * which it (currently) isn't. So the following statement + * is currently a NOP. + */ + if (AR9285_WA_DEFAULT & AR_WA_D3_L1_DISABLE) + val |= AR_WA_D3_L1_DISABLE; + + if (AR_SREV_9285E_20(ah)) + val |= AR_WA_BIT23; + + OS_REG_WRITE(ah, AR_WA, val); + } else { /* Power-on */ + val = AR9285_WA_DEFAULT; + /* + * See note above: make sure L1_DISABLE is not set. + */ + val &= (~AR_WA_D3_L1_DISABLE); + + /* Software workaroud for ASPM system hang. */ + val |= (AR_WA_BIT6 | AR_WA_BIT7); + + if (AR_SREV_9285E_20(ah)) + val |= AR_WA_BIT23; + + OS_REG_WRITE(ah, AR_WA, val); + + /* set bit 19 to allow forcing of pcie core into L1 state */ OS_REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA); - OS_REG_WRITE(ah, AR_WA, AR9285_WA_DEFAULT); } } static void ar9285DisablePCIE(struct ath_hal *ah) { - /* XXX TODO */ } static void From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 05:34:42 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 67AE11065774; Sun, 17 Jun 2012 05:34:42 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 568E28FC08; Sun, 17 Jun 2012 05:34:42 +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 q5H5Ygcq087317; Sun, 17 Jun 2012 05:34:42 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5H5Ygi9087315; Sun, 17 Jun 2012 05:34:42 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201206170534.q5H5Ygi9087315@svn.freebsd.org> From: Adrian Chadd Date: Sun, 17 Jun 2012 05:34:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237183 - head/sys/dev/ath/ath_hal/ar9002 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 05:34:42 -0000 Author: adrian Date: Sun Jun 17 05:34:41 2012 New Revision: 237183 URL: http://svn.freebsd.org/changeset/base/237183 Log: Add an disabled workaround for the AR9285SE. This just requires a little HAL change (add a new config parameter) and some glue in if_ath_pci.c, however I'm leaving this up for someone else to do. Obtained from: Qualcomm Atheros Modified: head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c Modified: head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c Sun Jun 17 04:48:47 2012 (r237182) +++ head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c Sun Jun 17 05:34:41 2012 (r237183) @@ -369,6 +369,25 @@ ar9285ConfigPCIE(struct ath_hal *ah, HAL { uint32_t val; + /* + * This workaround needs some integration work with the HAL + * config parameters and the if_ath_pci.c glue. + * Specifically, read the value of the PCI register 0x70c + * (4 byte PCI config space register) and store it in ath_hal_war70c. + * Then if it's non-zero, the below WAR would override register + * 0x570c upon suspend/resume. + */ +#if 0 + if (AR_SREV_9285E_20(ah)) { + val = AH_PRIVATE(ah)->ah_config.ath_hal_war70c; + if (val) { + val &= 0xffff00ff; + val |= 0x6f00; + OS_REG_WRITE(ah, 0x570c, val); + } + } +#endif + if (AH_PRIVATE(ah)->ah_ispcie && !restore) { ath_hal_ini_write(ah, &AH5416(ah)->ah_ini_pcieserdes, 1, 0); OS_DELAY(1000); From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 05:56:28 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 85065106564A; Sun, 17 Jun 2012 05:56:28 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6F8C18FC17; Sun, 17 Jun 2012 05:56:28 +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 q5H5uSpo088220; Sun, 17 Jun 2012 05:56:28 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5H5uRjN088217; Sun, 17 Jun 2012 05:56:27 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201206170556.q5H5uRjN088217@svn.freebsd.org> From: Adrian Chadd Date: Sun, 17 Jun 2012 05:56:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237184 - in head/sys/dev/ath/ath_hal: . ar9002 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 05:56:28 -0000 Author: adrian Date: Sun Jun 17 05:56:27 2012 New Revision: 237184 URL: http://svn.freebsd.org/changeset/base/237184 Log: AR9287 tidyups: * Add an OS_A_REG_WRITE() routine - analog writes require a 100usec delay on AR9280 and later, so create a method to do it. * Use it for the AR9287 analog writes. * Re-indent and style(9) the code. Modified: head/sys/dev/ath/ath_hal/ah_internal.h head/sys/dev/ath/ath_hal/ar9002/ar9287_reset.c Modified: head/sys/dev/ath/ath_hal/ah_internal.h ============================================================================== --- head/sys/dev/ath/ath_hal/ah_internal.h Sun Jun 17 05:34:41 2012 (r237183) +++ head/sys/dev/ath/ath_hal/ah_internal.h Sun Jun 17 05:56:27 2012 (r237184) @@ -484,6 +484,8 @@ isBigEndian(void) /* Analog register writes may require a delay between each one (eg Merlin?) */ #define OS_A_REG_RMW_FIELD(_a, _r, _f, _v) \ do { OS_REG_WRITE(_a, _r, (OS_REG_READ(_a, _r) &~ (_f)) | (((_v) << _f##_S) & (_f))) ; OS_DELAY(100); } while (0) +#define OS_A_REG_WRITE(_a, _r, _v) \ + do { OS_REG_WRITE(_a, _r, _v); OS_DELAY(100); } while (0) /* wait for the register contents to have the specified value */ extern HAL_BOOL ath_hal_wait(struct ath_hal *, u_int reg, Modified: head/sys/dev/ath/ath_hal/ar9002/ar9287_reset.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar9002/ar9287_reset.c Sun Jun 17 05:34:41 2012 (r237183) +++ head/sys/dev/ath/ath_hal/ar9002/ar9287_reset.c Sun Jun 17 05:56:27 2012 (r237184) @@ -45,70 +45,70 @@ static void ar9287SetPowerCalTable(struct ath_hal *ah, const struct ieee80211_channel *chan, int16_t *pTxPowerIndexOffset) { - struct cal_data_op_loop_ar9287 *pRawDatasetOpenLoop; - uint8_t *pCalBChans = NULL; - uint16_t pdGainOverlap_t2; - uint16_t numPiers = 0, i; - uint16_t numXpdGain, xpdMask; - uint16_t xpdGainValues[AR5416_NUM_PD_GAINS] = {0, 0, 0, 0}; - uint32_t regChainOffset; + struct cal_data_op_loop_ar9287 *pRawDatasetOpenLoop; + uint8_t *pCalBChans = NULL; + uint16_t pdGainOverlap_t2; + uint16_t numPiers = 0, i; + uint16_t numXpdGain, xpdMask; + uint16_t xpdGainValues[AR5416_NUM_PD_GAINS] = {0, 0, 0, 0}; + uint32_t regChainOffset; HAL_EEPROM_9287 *ee = AH_PRIVATE(ah)->ah_eeprom; - struct ar9287_eeprom *pEepData = &ee->ee_base; + struct ar9287_eeprom *pEepData = &ee->ee_base; - xpdMask = pEepData->modalHeader.xpdGain; + xpdMask = pEepData->modalHeader.xpdGain; - if ((pEepData->baseEepHeader.version & AR9287_EEP_VER_MINOR_MASK) >= - AR9287_EEP_MINOR_VER_2) - pdGainOverlap_t2 = pEepData->modalHeader.pdGainOverlap; - else - pdGainOverlap_t2 = (uint16_t)(MS(OS_REG_READ(ah, AR_PHY_TPCRG5), - AR_PHY_TPCRG5_PD_GAIN_OVERLAP)); + if ((pEepData->baseEepHeader.version & AR9287_EEP_VER_MINOR_MASK) >= + AR9287_EEP_MINOR_VER_2) + pdGainOverlap_t2 = pEepData->modalHeader.pdGainOverlap; + else + pdGainOverlap_t2 = (uint16_t)(MS(OS_REG_READ(ah, AR_PHY_TPCRG5), + AR_PHY_TPCRG5_PD_GAIN_OVERLAP)); /* Note: Kiwi should only be 2ghz.. */ - if (IEEE80211_IS_CHAN_2GHZ(chan)) { - pCalBChans = pEepData->calFreqPier2G; - numPiers = AR9287_NUM_2G_CAL_PIERS; - pRawDatasetOpenLoop = (struct cal_data_op_loop_ar9287 *)pEepData->calPierData2G[0]; - AH5416(ah)->initPDADC = pRawDatasetOpenLoop->vpdPdg[0][0]; - } - numXpdGain = 0; - - /* Calculate the value of xpdgains from the xpdGain Mask */ - for (i = 1; i <= AR5416_PD_GAINS_IN_MASK; i++) { - if ((xpdMask >> (AR5416_PD_GAINS_IN_MASK - i)) & 1) { - if (numXpdGain >= AR5416_NUM_PD_GAINS) - break; - xpdGainValues[numXpdGain] = - (uint16_t)(AR5416_PD_GAINS_IN_MASK-i); - numXpdGain++; - } - } - - OS_REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_NUM_PD_GAIN, - (numXpdGain - 1) & 0x3); - OS_REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_1, - xpdGainValues[0]); - OS_REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_2, - xpdGainValues[1]); - OS_REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_3, - xpdGainValues[2]); - - for (i = 0; i < AR9287_MAX_CHAINS; i++) { - regChainOffset = i * 0x1000; - - if (pEepData->baseEepHeader.txMask & (1 << i)) { - int8_t txPower; - pRawDatasetOpenLoop = - (struct cal_data_op_loop_ar9287 *)pEepData->calPierData2G[i]; - ar9287olcGetTxGainIndex(ah, chan, - pRawDatasetOpenLoop, - pCalBChans, numPiers, - &txPower); - ar9287olcSetPDADCs(ah, txPower, i); - } - } + if (IEEE80211_IS_CHAN_2GHZ(chan)) { + pCalBChans = pEepData->calFreqPier2G; + numPiers = AR9287_NUM_2G_CAL_PIERS; + pRawDatasetOpenLoop = (struct cal_data_op_loop_ar9287 *)pEepData->calPierData2G[0]; + AH5416(ah)->initPDADC = pRawDatasetOpenLoop->vpdPdg[0][0]; + } + numXpdGain = 0; + + /* Calculate the value of xpdgains from the xpdGain Mask */ + for (i = 1; i <= AR5416_PD_GAINS_IN_MASK; i++) { + if ((xpdMask >> (AR5416_PD_GAINS_IN_MASK - i)) & 1) { + if (numXpdGain >= AR5416_NUM_PD_GAINS) + break; + xpdGainValues[numXpdGain] = + (uint16_t)(AR5416_PD_GAINS_IN_MASK-i); + numXpdGain++; + } + } + + OS_REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_NUM_PD_GAIN, + (numXpdGain - 1) & 0x3); + OS_REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_1, + xpdGainValues[0]); + OS_REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_2, + xpdGainValues[1]); + OS_REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_3, + xpdGainValues[2]); - *pTxPowerIndexOffset = 0; + for (i = 0; i < AR9287_MAX_CHAINS; i++) { + regChainOffset = i * 0x1000; + + if (pEepData->baseEepHeader.txMask & (1 << i)) { + int8_t txPower; + pRawDatasetOpenLoop = + (struct cal_data_op_loop_ar9287 *)pEepData->calPierData2G[i]; + ar9287olcGetTxGainIndex(ah, chan, + pRawDatasetOpenLoop, + pCalBChans, numPiers, + &txPower); + ar9287olcSetPDADCs(ah, txPower, i); + } + } + + *pTxPowerIndexOffset = 0; } @@ -329,20 +329,20 @@ ar9287SetTransmitPower(struct ath_hal *a const struct ieee80211_channel *chan, uint16_t *rfXpdGain) { #define POW_SM(_r, _s) (((_r) & 0x3f) << (_s)) -#define N(a) (sizeof (a) / sizeof (a[0])) +#define N(a) (sizeof (a) / sizeof (a[0])) const struct modal_eep_ar9287_header *pModal; struct ath_hal_5212 *ahp = AH5212(ah); - int16_t ratesArray[Ar5416RateSize]; - int16_t txPowerIndexOffset = 0; - uint8_t ht40PowerIncForPdadc = 2; - int i; - - uint16_t cfgCtl; - uint16_t powerLimit; - uint16_t twiceAntennaReduction; - uint16_t twiceMaxRegulatoryPower; - int16_t maxPower; + int16_t ratesArray[Ar5416RateSize]; + int16_t txPowerIndexOffset = 0; + uint8_t ht40PowerIncForPdadc = 2; + int i; + + uint16_t cfgCtl; + uint16_t powerLimit; + uint16_t twiceAntennaReduction; + uint16_t twiceMaxRegulatoryPower; + int16_t maxPower; HAL_EEPROM_9287 *ee = AH_PRIVATE(ah)->ah_eeprom; struct ar9287_eeprom *pEepData = &ee->ee_base; @@ -351,7 +351,8 @@ ar9287SetTransmitPower(struct ath_hal *a cfgCtl = ath_hal_getctl(ah, chan); powerLimit = chan->ic_maxregpower * 2; twiceAntennaReduction = chan->ic_maxantgain; - twiceMaxRegulatoryPower = AH_MIN(MAX_RATE_POWER, AH_PRIVATE(ah)->ah_powerLimit); + twiceMaxRegulatoryPower = AH_MIN(MAX_RATE_POWER, + AH_PRIVATE(ah)->ah_powerLimit); pModal = &pEepData->modalHeader; HALDEBUG(ah, HAL_DEBUG_RESET, "%s Channel=%u CfgCtl=%u\n", __func__,chan->ic_freq, cfgCtl ); @@ -361,9 +362,9 @@ ar9287SetTransmitPower(struct ath_hal *a /* Fetch per-rate power table for the given channel */ if (! ar9287SetPowerPerRateTable(ah, pEepData, chan, - &ratesArray[0],cfgCtl, - twiceAntennaReduction, - twiceMaxRegulatoryPower, powerLimit)) { + &ratesArray[0],cfgCtl, + twiceAntennaReduction, + twiceMaxRegulatoryPower, powerLimit)) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: unable to set tx power per rate table\n", __func__); return AH_FALSE; @@ -476,7 +477,8 @@ ar9287SetBoardValues(struct ath_hal *ah, pModal->antCtrlChain[i]); OS_REG_WRITE(ah, AR_PHY_TIMING_CTRL4_CHAIN(0) + regChainOffset, - (OS_REG_READ(ah, AR_PHY_TIMING_CTRL4_CHAIN(0) + regChainOffset) + (OS_REG_READ(ah, AR_PHY_TIMING_CTRL4_CHAIN(0) + + regChainOffset) & ~(AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF | AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF)) | SM(pModal->iqCalICh[i], @@ -500,7 +502,6 @@ ar9287SetBoardValues(struct ath_hal *ah, pModal->rxTxMarginCh[i]); } - if (IEEE80211_IS_CHAN_HT40(chan)) OS_REG_RMW_FIELD(ah, AR_PHY_SETTLING, AR_PHY_SETTLING_SWITCH, pModal->swSettleHt40); @@ -539,8 +540,8 @@ ar9287SetBoardValues(struct ath_hal *ah, SM(pModal->ob_qam, AR9287_AN_RF2G3_OB_QAM) | SM(pModal->ob_pal_off, AR9287_AN_RF2G3_OB_PAL_OFF)); - OS_REG_WRITE(ah, AR9287_AN_RF2G3_CH0, regval); - OS_DELAY(100); /* analog write */ + /* Analog write - requires a 100usec delay */ + OS_A_REG_WRITE(ah, AR9287_AN_RF2G3_CH0, regval); regval = OS_REG_READ(ah, AR9287_AN_RF2G3_CH1); regval &= ~(AR9287_AN_RF2G3_DB1 | @@ -556,8 +557,7 @@ ar9287SetBoardValues(struct ath_hal *ah, SM(pModal->ob_qam, AR9287_AN_RF2G3_OB_QAM) | SM(pModal->ob_pal_off, AR9287_AN_RF2G3_OB_PAL_OFF)); - OS_REG_WRITE(ah, AR9287_AN_RF2G3_CH1, regval); - OS_DELAY(100); /* analog write */ + OS_A_REG_WRITE(ah, AR9287_AN_RF2G3_CH1, regval); OS_REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_FRAME_TO_DATA_START, pModal->txFrameToDataStart); From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 11:04:39 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 86F5D1065672; Sun, 17 Jun 2012 11:04:39 +0000 (UTC) (envelope-from joel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 71A118FC0A; Sun, 17 Jun 2012 11:04:39 +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 q5HB4dbL004160; Sun, 17 Jun 2012 11:04:39 GMT (envelope-from joel@svn.freebsd.org) Received: (from joel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5HB4dLU004158; Sun, 17 Jun 2012 11:04:39 GMT (envelope-from joel@svn.freebsd.org) Message-Id: <201206171104.q5HB4dLU004158@svn.freebsd.org> From: Joel Dahl Date: Sun, 17 Jun 2012 11:04:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237190 - head/contrib/telnet/telnet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 11:04:39 -0000 Author: joel (doc committer) Date: Sun Jun 17 11:04:38 2012 New Revision: 237190 URL: http://svn.freebsd.org/changeset/base/237190 Log: Remove superfluous paragraph macro. Modified: head/contrib/telnet/telnet/telnet.1 Modified: head/contrib/telnet/telnet/telnet.1 ============================================================================== --- head/contrib/telnet/telnet/telnet.1 Sun Jun 17 09:50:59 2012 (r237189) +++ head/contrib/telnet/telnet/telnet.1 Sun Jun 17 11:04:38 2012 (r237190) @@ -344,7 +344,6 @@ Only enough of each command to uniquely and .Ic display commands). -.Pp .Bl -tag -width "mode type" .It Ic auth Ar argument ... The auth command manipulates the information sent through the @@ -664,7 +663,6 @@ An end of file (in command mode) will al Sends one or more special character sequences to the remote host. The following are the arguments which may be specified (more than one argument may be specified at a time): -.Pp .Bl -tag -width escape .It Ic abort Sends the From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 11:33:56 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6EFFC106564A; Sun, 17 Jun 2012 11:33:56 +0000 (UTC) (envelope-from joel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 598D08FC08; Sun, 17 Jun 2012 11:33:56 +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 q5HBXuqu005504; Sun, 17 Jun 2012 11:33:56 GMT (envelope-from joel@svn.freebsd.org) Received: (from joel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5HBXuha005498; Sun, 17 Jun 2012 11:33:56 GMT (envelope-from joel@svn.freebsd.org) Message-Id: <201206171133.q5HBXuha005498@svn.freebsd.org> From: Joel Dahl Date: Sun, 17 Jun 2012 11:33:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237193 - in head/contrib/bsnmp: lib snmp_target snmp_usm snmp_vacm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 11:33:56 -0000 Author: joel (doc committer) Date: Sun Jun 17 11:33:55 2012 New Revision: 237193 URL: http://svn.freebsd.org/changeset/base/237193 Log: Minor mdoc fixes. Modified: head/contrib/bsnmp/lib/bsnmpclient.3 head/contrib/bsnmp/lib/bsnmplib.3 head/contrib/bsnmp/snmp_target/snmp_target.3 head/contrib/bsnmp/snmp_usm/snmp_usm.3 head/contrib/bsnmp/snmp_vacm/snmp_vacm.3 Modified: head/contrib/bsnmp/lib/bsnmpclient.3 ============================================================================== --- head/contrib/bsnmp/lib/bsnmpclient.3 Sun Jun 17 11:16:17 2012 (r237192) +++ head/contrib/bsnmp/lib/bsnmpclient.3 Sun Jun 17 11:33:55 2012 (r237193) @@ -368,7 +368,7 @@ This format expects an argument of type and appends the length of the string (as computed by .Xr strlen 3 ) and each of the characters in the string to the OID. -.It Li ( Va N Ns Li ) +.It ( Va N Ns ) This format expects no argument. .Va N must be a decimal number and is stored into an internal variable Modified: head/contrib/bsnmp/lib/bsnmplib.3 ============================================================================== --- head/contrib/bsnmp/lib/bsnmplib.3 Sun Jun 17 11:16:17 2012 (r237192) +++ head/contrib/bsnmp/lib/bsnmplib.3 Sun Jun 17 11:33:55 2012 (r237193) @@ -161,7 +161,6 @@ is not zero, .Fa v.octetstring.octets points to a string allocated by .Xr malloc 3 . -.Pp .Bd -literal -offset indent #define SNMP_ENGINE_ID_SIZ 32 @@ -176,7 +175,6 @@ struct snmp_engine { .Pp This structure represents an SNMP engine as specified by the SNMP Management Architecture described in RFC 3411. -.Pp .Bd -literal -offset indent #define SNMP_ADM_STR32_SIZ (32 + 1) #define SNMP_AUTH_KEY_SIZ 40 @@ -225,7 +223,6 @@ enum snmp_privacy { and .Fa priv_key contain the authentication and privacy keys for the user. -.Pp .Bd -literal -offset indent #define SNMP_COMMUNITY_MAXLEN 128 #define SNMP_MAX_BINDINGS 100 Modified: head/contrib/bsnmp/snmp_target/snmp_target.3 ============================================================================== --- head/contrib/bsnmp/snmp_target/snmp_target.3 Sun Jun 17 11:16:17 2012 (r237192) +++ head/contrib/bsnmp/snmp_target/snmp_target.3 Sun Jun 17 11:33:55 2012 (r237193) @@ -33,7 +33,7 @@ .Os .Sh NAME .Nm snmp_target -.Nd "Target addresses and notifications module for +.Nd "Target addresses and notifications module for" .Xr bsnmpd 1 .Sh LIBRARY .Pq begemotSnmpdModulePath."target" = "/usr/lib/snmp_target.so" Modified: head/contrib/bsnmp/snmp_usm/snmp_usm.3 ============================================================================== --- head/contrib/bsnmp/snmp_usm/snmp_usm.3 Sun Jun 17 11:16:17 2012 (r237192) +++ head/contrib/bsnmp/snmp_usm/snmp_usm.3 Sun Jun 17 11:33:55 2012 (r237193) @@ -33,7 +33,7 @@ .Os .Sh NAME .Nm snmp_usm -.Nd "user-based security module for +.Nd "user-based security module for" .Xr bsnmpd 1 .Sh LIBRARY .Pq begemotSnmpdModulePath."usm" = "/usr/lib/snmp_usm.so" Modified: head/contrib/bsnmp/snmp_vacm/snmp_vacm.3 ============================================================================== --- head/contrib/bsnmp/snmp_vacm/snmp_vacm.3 Sun Jun 17 11:16:17 2012 (r237192) +++ head/contrib/bsnmp/snmp_vacm/snmp_vacm.3 Sun Jun 17 11:33:55 2012 (r237193) @@ -33,7 +33,7 @@ .Os .Sh NAME .Nm snmp_vacm -.Nd "View-based Access Control module for +.Nd "View-based Access Control module for" .Xr bsnmpd 1 .Sh LIBRARY .Pq begemotSnmpdModulePath."vacm" = "/usr/lib/snmp_vacm.so" From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 11:36:29 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 570BD106564A; Sun, 17 Jun 2012 11:36:29 +0000 (UTC) (envelope-from joel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 282368FC08; Sun, 17 Jun 2012 11:36:29 +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 q5HBaTQ1005648; Sun, 17 Jun 2012 11:36:29 GMT (envelope-from joel@svn.freebsd.org) Received: (from joel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5HBaSUV005645; Sun, 17 Jun 2012 11:36:28 GMT (envelope-from joel@svn.freebsd.org) Message-Id: <201206171136.q5HBaSUV005645@svn.freebsd.org> From: Joel Dahl Date: Sun, 17 Jun 2012 11:36:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237194 - in head/contrib/bsnmp: lib snmp_usm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 11:36:29 -0000 Author: joel (doc committer) Date: Sun Jun 17 11:36:28 2012 New Revision: 237194 URL: http://svn.freebsd.org/changeset/base/237194 Log: Remove end of line whitespace. Modified: head/contrib/bsnmp/lib/bsnmplib.3 head/contrib/bsnmp/snmp_usm/snmp_usm.3 Modified: head/contrib/bsnmp/lib/bsnmplib.3 ============================================================================== --- head/contrib/bsnmp/lib/bsnmplib.3 Sun Jun 17 11:33:55 2012 (r237193) +++ head/contrib/bsnmp/lib/bsnmplib.3 Sun Jun 17 11:36:28 2012 (r237194) @@ -386,7 +386,7 @@ If successfull, a plain text scoped PDU The function .Fn snmp_pdu_init_secparams calculates the initialization vector for the privacy protocol in use before -the PDU pointed to by +the PDU pointed to by .Fa pdu may be encrypted or decrypted. .Pp @@ -501,7 +501,7 @@ the cryptographic functions from The library may optionally be built without references to the .Xr crypto 3 library. In such case only plain text SNMPv3 PDUs without message digests -may be proccessed correctly. +may be proccessed correctly. .Sh STANDARDS This implementation conforms to the applicable IETF RFCs and ITU-T recommendations. Modified: head/contrib/bsnmp/snmp_usm/snmp_usm.3 ============================================================================== --- head/contrib/bsnmp/snmp_usm/snmp_usm.3 Sun Jun 17 11:33:55 2012 (r237193) +++ head/contrib/bsnmp/snmp_usm/snmp_usm.3 Sun Jun 17 11:36:28 2012 (r237194) @@ -79,7 +79,7 @@ supported. .It Va usmUserAuthProtocol The value of this column contains the OID corresponding to the authentication protocol used by the USM user. The following protocols and their OIDs are known to -.Nm +.Nm module .Bl -tag -width ".It Va NoAuthProtocol" .It NoAuthProtocol 1.3.6.1.6.3.10.1.1.1 @@ -91,7 +91,7 @@ These columns may be used to change the .It Va usmUserPrivProtocol The value of this column contains the OID corresponding to the privacy protocol used by the USM user. The following protocols and their OIDs are known to -.Nm +.Nm module .Bl -tag -width ".It Va NoPrivProtocol" .It NoPrivProtocol 1.3.6.1.6.3.10.1.2.1 From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 13:03:51 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6D1F1106566B; Sun, 17 Jun 2012 13:03:51 +0000 (UTC) (envelope-from davide@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5878A8FC0A; Sun, 17 Jun 2012 13:03:51 +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 q5HD3pHT009187; Sun, 17 Jun 2012 13:03:51 GMT (envelope-from davide@svn.freebsd.org) Received: (from davide@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5HD3pl9009185; Sun, 17 Jun 2012 13:03:51 GMT (envelope-from davide@svn.freebsd.org) Message-Id: <201206171303.q5HD3pl9009185@svn.freebsd.org> From: Davide Italiano Date: Sun, 17 Jun 2012 13:03:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237195 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 13:03:51 -0000 Author: davide Date: Sun Jun 17 13:03:50 2012 New Revision: 237195 URL: http://svn.freebsd.org/changeset/base/237195 Log: The variable 'error' in sys_poll() is initialized in declaration to value zero but in any case is overwritten by successive copyin(), making the previous initialization useless. Remove this. As an added bonus this fixes a style(9) bug. Discussed with: kib Approved by: gnn (mentor) MFC after: 3 days Modified: head/sys/kern/sys_generic.c Modified: head/sys/kern/sys_generic.c ============================================================================== --- head/sys/kern/sys_generic.c Sun Jun 17 11:36:28 2012 (r237194) +++ head/sys/kern/sys_generic.c Sun Jun 17 13:03:50 2012 (r237195) @@ -1255,7 +1255,7 @@ sys_poll(td, uap) struct pollfd *bits; struct pollfd smallbits[32]; struct timeval atv, rtv, ttv; - int error = 0, timo; + int error, timo; u_int nfds; size_t ni; From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 13:48:40 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3BE6A1065670; Sun, 17 Jun 2012 13:48:40 +0000 (UTC) (envelope-from davide@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 27F908FC0C; Sun, 17 Jun 2012 13:48:40 +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 q5HDmep7011039; Sun, 17 Jun 2012 13:48:40 GMT (envelope-from davide@svn.freebsd.org) Received: (from davide@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5HDmdW3011037; Sun, 17 Jun 2012 13:48:39 GMT (envelope-from davide@svn.freebsd.org) Message-Id: <201206171348.q5HDmdW3011037@svn.freebsd.org> From: Davide Italiano Date: Sun, 17 Jun 2012 13:48:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237196 - head/sys/dev/hwpmc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 13:48:40 -0000 Author: davide Date: Sun Jun 17 13:48:39 2012 New Revision: 237196 URL: http://svn.freebsd.org/changeset/base/237196 Log: Disable hwpmc(4) support for Intel Xeon Sandy Bridge (Model 0x2D). Due to some differences in MSRs between Xeon Sandy Bridge and Core Sandy Bridge (Model 0x2A), wrmsr() may generate in a GP# fault exception and so a panic of the machine. Approved by: gnn (mentor) MFC after: 3 days Modified: head/sys/dev/hwpmc/hwpmc_intel.c Modified: head/sys/dev/hwpmc/hwpmc_intel.c ============================================================================== --- head/sys/dev/hwpmc/hwpmc_intel.c Sun Jun 17 13:03:50 2012 (r237195) +++ head/sys/dev/hwpmc/hwpmc_intel.c Sun Jun 17 13:48:39 2012 (r237196) @@ -143,7 +143,6 @@ pmc_intel_initialize(void) nclasses = 5; break; case 0x2A: /* Per Intel document 253669-039US 05/2011. */ - case 0x2D: /* Per Intel document 253669-041US 12/2011. */ cputype = PMC_CPU_INTEL_SANDYBRIDGE; nclasses = 5; break; From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 16:19:10 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2B576106566B; Sun, 17 Jun 2012 16:19:10 +0000 (UTC) (envelope-from iwasaki@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F11608FC15; Sun, 17 Jun 2012 16:19:09 +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 q5HGJ9Qf017232; Sun, 17 Jun 2012 16:19:09 GMT (envelope-from iwasaki@svn.freebsd.org) Received: (from iwasaki@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5HGJ94j017230; Sun, 17 Jun 2012 16:19:09 GMT (envelope-from iwasaki@svn.freebsd.org) Message-Id: <201206171619.q5HGJ94j017230@svn.freebsd.org> From: Mitsuru IWASAKI Date: Sun, 17 Jun 2012 16:19:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237197 - head/sys/dev/acpica X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 16:19:10 -0000 Author: iwasaki Date: Sun Jun 17 16:19:09 2012 New Revision: 237197 URL: http://svn.freebsd.org/changeset/base/237197 Log: Resotre LCD brightness level on resuming. MFC after: 3 days Modified: head/sys/dev/acpica/acpi_video.c Modified: head/sys/dev/acpica/acpi_video.c ============================================================================== --- head/sys/dev/acpica/acpi_video.c Sun Jun 17 13:48:39 2012 (r237196) +++ head/sys/dev/acpica/acpi_video.c Sun Jun 17 16:19:09 2012 (r237197) @@ -75,6 +75,7 @@ static void acpi_video_identify(driver_t static int acpi_video_probe(device_t); static int acpi_video_attach(device_t); static int acpi_video_detach(device_t); +static int acpi_video_resume(device_t); static int acpi_video_shutdown(device_t); static void acpi_video_notify_handler(ACPI_HANDLE, UINT32, void *); static void acpi_video_power_profile(void *); @@ -155,6 +156,7 @@ static device_method_t acpi_video_method DEVMETHOD(device_probe, acpi_video_probe), DEVMETHOD(device_attach, acpi_video_attach), DEVMETHOD(device_detach, acpi_video_detach), + DEVMETHOD(device_resume, acpi_video_resume), DEVMETHOD(device_shutdown, acpi_video_shutdown), { 0, 0 } }; @@ -305,6 +307,36 @@ acpi_video_detach(device_t dev) } static int +acpi_video_resume(device_t dev) +{ + struct acpi_video_softc *sc; + struct acpi_video_output *vo, *vn; + int level; + + sc = device_get_softc(dev); + + /* Restore brightness level */ + ACPI_SERIAL_BEGIN(video); + ACPI_SERIAL_BEGIN(video_output); + STAILQ_FOREACH_SAFE(vo, &sc->vid_outputs, vo_next, vn) { + if ((vo->adr & DOD_DEVID_MASK_FULL) != DOD_DEVID_LCD && + (vo->adr & DOD_DEVID_MASK) != DOD_DEVID_INTDFP) + continue; + + if ((vo_get_device_status(vo->handle) & DCS_ACTIVE) == 0) + continue; + + level = vo_get_brightness(vo->handle); + if (level != -1) + vo_set_brightness(vo->handle, level); + } + ACPI_SERIAL_END(video_output); + ACPI_SERIAL_END(video); + + return (0); +} + +static int acpi_video_shutdown(device_t dev) { struct acpi_video_softc *sc; From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 16:32:33 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9F2B41065799; Sun, 17 Jun 2012 16:32:33 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8ACFA8FC0C; Sun, 17 Jun 2012 16:32:33 +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 q5HGWXBY017786; Sun, 17 Jun 2012 16:32:33 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5HGWXKq017784; Sun, 17 Jun 2012 16:32:33 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201206171632.q5HGWXKq017784@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sun, 17 Jun 2012 16:32:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237198 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 16:32:33 -0000 Author: pjd Date: Sun Jun 17 16:32:32 2012 New Revision: 237198 URL: http://svn.freebsd.org/changeset/base/237198 Log: If VOP_ADVLOCK() call or earlier checks failed don't check for a race with close, because even if we had a race there is nothing to unlock. Discussed with: kib MFC after: 1 month Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Sun Jun 17 16:19:09 2012 (r237197) +++ head/sys/kern/kern_descrip.c Sun Jun 17 16:32:32 2012 (r237198) @@ -668,6 +668,10 @@ kern_fcntl(struct thread *td, int fd, in } VFS_UNLOCK_GIANT(vfslocked); vfslocked = 0; + if (error != 0) { + fdrop(fp, td); + break; + } /* Check for race with close */ FILEDESC_SLOCK(fdp); if (fget_locked(fdp, fd) != fp) { From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 16:59:37 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BE1F01065672; Sun, 17 Jun 2012 16:59:37 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AA5228FC12; Sun, 17 Jun 2012 16:59:37 +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 q5HGxbWq018934; Sun, 17 Jun 2012 16:59:37 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5HGxbAZ018932; Sun, 17 Jun 2012 16:59:37 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201206171659.q5HGxbAZ018932@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sun, 17 Jun 2012 16:59:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237199 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 16:59:37 -0000 Author: pjd Date: Sun Jun 17 16:59:37 2012 New Revision: 237199 URL: http://svn.freebsd.org/changeset/base/237199 Log: Extend the comment about checking for a race with close to explain why it is done and why we don't return an error in such case. Discussed with: kib MFC after: 1 month Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Sun Jun 17 16:32:32 2012 (r237198) +++ head/sys/kern/kern_descrip.c Sun Jun 17 16:59:37 2012 (r237199) @@ -672,7 +672,23 @@ kern_fcntl(struct thread *td, int fd, in fdrop(fp, td); break; } - /* Check for race with close */ + + /* + * Check for a race with close. + * + * The vnode is now advisory locked (or unlocked, but this case + * is not really important) as the caller requested. + * We had to drop the filedesc lock, so we need to recheck if + * the descriptor is still valid, because if it was closed + * in the meantime we need to remove advisory lock from the + * vnode - close on any descriptor leading to an advisory + * locked vnode, removes that lock. + * We will return 0 on purpose in that case, as the result of + * successful advisory lock might have been externally visible + * already. This is fine - effectively we pretend to the caller + * that the closing thread was a bit slower and that the + * advisory lock succeeded before the close. + */ FILEDESC_SLOCK(fdp); if (fget_locked(fdp, fd) != fp) { FILEDESC_SUNLOCK(fdp); From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 18:34:04 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C567A106566B; Sun, 17 Jun 2012 18:34:04 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B15CC8FC14; Sun, 17 Jun 2012 18:34:04 +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 q5HIY4Gk023646; Sun, 17 Jun 2012 18:34:04 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5HIY42F023644; Sun, 17 Jun 2012 18:34:04 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201206171834.q5HIY42F023644@svn.freebsd.org> From: Rick Macklem Date: Sun, 17 Jun 2012 18:34:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237200 - head/sys/fs/nfsclient X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 18:34:04 -0000 Author: rmacklem Date: Sun Jun 17 18:34:04 2012 New Revision: 237200 URL: http://svn.freebsd.org/changeset/base/237200 Log: Move the nfsrpc_close() call in ncl_reclaim() for the NFSv4 client to below the vnode_destroy_vobject() call, since that is where writes are flushed. Suggested by: kib MFC after: 1 week Modified: head/sys/fs/nfsclient/nfs_clnode.c Modified: head/sys/fs/nfsclient/nfs_clnode.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clnode.c Sun Jun 17 16:59:37 2012 (r237199) +++ head/sys/fs/nfsclient/nfs_clnode.c Sun Jun 17 18:34:04 2012 (r237200) @@ -257,15 +257,6 @@ ncl_reclaim(struct vop_reclaim_args *ap) struct nfsnode *np = VTONFS(vp); struct nfsdmap *dp, *dp2; - if (NFS_ISV4(vp) && vp->v_type == VREG) - /* - * Since mmap()'d files do I/O after VOP_CLOSE(), the NFSv4 - * Close operations are delayed until ncl_inactive(). - * However, since VOP_INACTIVE() is not guaranteed to be - * called, we need to do it again here. - */ - (void) nfsrpc_close(vp, 1, ap->a_td); - /* * If the NLM is running, give it a chance to abort pending * locks. @@ -278,6 +269,15 @@ ncl_reclaim(struct vop_reclaim_args *ap) */ vnode_destroy_vobject(vp); + if (NFS_ISV4(vp) && vp->v_type == VREG) + /* + * We can now safely close any remaining NFSv4 Opens for + * this file. Most opens will have already been closed by + * ncl_inactive(), but there are cases where it is not + * called, so we need to do it again here. + */ + (void) nfsrpc_close(vp, 1, ap->a_td); + vfs_hash_remove(vp); /* From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 21:02:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DBBF9106564A; Sun, 17 Jun 2012 21:02:48 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C708E8FC0A; Sun, 17 Jun 2012 21:02:48 +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 q5HL2mAW032401; Sun, 17 Jun 2012 21:02:48 GMT (envelope-from phk@svn.freebsd.org) Received: (from phk@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5HL2mG9032399; Sun, 17 Jun 2012 21:02:48 GMT (envelope-from phk@svn.freebsd.org) Message-Id: <201206172102.q5HL2mG9032399@svn.freebsd.org> From: Poul-Henning Kamp Date: Sun, 17 Jun 2012 21:02:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237203 - head/sys/dev/fb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 21:02:49 -0000 Author: phk Date: Sun Jun 17 21:02:48 2012 New Revision: 237203 URL: http://svn.freebsd.org/changeset/base/237203 Log: On certain newer Intel Atom based motherboards, for instance the D2500CC which I have, syscons in text-mode fails to show the expected contents due to write errors into video-memory. At least one of the causes is that we copy from syscons internal buffer to the video memory with optimized bcopy(9) which uses >16bit operations. Until now, 32bit and wider operations have always worked on the video memory, but since I cannot find a single source which says that this SHALL work, and since these chipsets/bugs are now out there, this commit changes syscons to always use 16bit copies on i386 & amd64. This may be relevevant for PR's: 166262 166639 and various other bug reports floating elsewhere on the net, but I lack hardware to test those. Modified: head/sys/dev/fb/fbreg.h Modified: head/sys/dev/fb/fbreg.h ============================================================================== --- head/sys/dev/fb/fbreg.h Sun Jun 17 20:45:45 2012 (r237202) +++ head/sys/dev/fb/fbreg.h Sun Jun 17 21:02:48 2012 (r237203) @@ -35,9 +35,16 @@ /* some macros */ #if defined(__amd64__) || defined(__i386__) -#define bcopy_io(s, d, c) bcopy((void *)(s), (void *)(d), (c)) -#define bcopy_toio(s, d, c) bcopy((void *)(s), (void *)(d), (c)) -#define bcopy_fromio(s, d, c) bcopy((void *)(s), (void *)(d), (c)) + +static __inline void +copyw(uint16_t *src, uint16_t *dst, size_t size) +{ + while (size--) + *dst++ = *src++; +} +#define bcopy_io(s, d, c) copyw((void*)(s), (void*)(d), (c)) +#define bcopy_toio(s, d, c) copyw((void*)(s), (void*)(d), (c)) +#define bcopy_fromio(s, d, c) copyw((void*)(s), (void*)(d), (c)) #define bzero_io(d, c) bzero((void *)(d), (c)) #define fill_io(p, d, c) fill((p), (void *)(d), (c)) #define fillw_io(p, d, c) fillw((p), (void *)(d), (c)) From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 21:04:23 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2F0CD106566C; Sun, 17 Jun 2012 21:04:23 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1A6AB8FC08; Sun, 17 Jun 2012 21:04:23 +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 q5HL4MuD032501; Sun, 17 Jun 2012 21:04:22 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5HL4M0t032499; Sun, 17 Jun 2012 21:04:22 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201206172104.q5HL4M0t032499@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sun, 17 Jun 2012 21:04:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237204 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 21:04:23 -0000 Author: pjd Date: Sun Jun 17 21:04:22 2012 New Revision: 237204 URL: http://svn.freebsd.org/changeset/base/237204 Log: Don't check for race with close on advisory unlock (there is nothing smart we can do when such a race occurs). This saves lock/unlock cycle for the filedesc lock for every advisory unlock operation. MFC after: 1 month Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Sun Jun 17 21:02:48 2012 (r237203) +++ head/sys/kern/kern_descrip.c Sun Jun 17 21:04:22 2012 (r237204) @@ -668,7 +668,8 @@ kern_fcntl(struct thread *td, int fd, in } VFS_UNLOCK_GIANT(vfslocked); vfslocked = 0; - if (error != 0) { + if (error != 0 || flp->l_type == F_UNLCK || + flp->l_type == F_UNLCKSYS) { fdrop(fp, td); break; } From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 21:29:16 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EDB0E1065670; Sun, 17 Jun 2012 21:29:15 +0000 (UTC) (envelope-from taku@tackymt.homeip.net) Received: from basalt.tackymt.homeip.net (unknown [IPv6:2001:3e0:577:0:20d:61ff:fecc:2253]) by mx1.freebsd.org (Postfix) with ESMTP id 908B28FC12; Sun, 17 Jun 2012 21:29:15 +0000 (UTC) Received: from basalt.tackymt.homeip.net (localhost [127.0.0.1]) by basalt.tackymt.homeip.net (Postfix) with ESMTP id AEDC583B8; Mon, 18 Jun 2012 06:29:14 +0900 (JST) X-Virus-Scanned: amavisd-new at tackymt.homeip.net Received: from localhost by basalt.tackymt.homeip.net (amavisd-new, unix socket) with ESMTP id X6jkgJBcX10K; Mon, 18 Jun 2012 06:29:12 +0900 (JST) Received: from basalt.tackymt.homeip.net (basalt.tackymt.homeip.net [IPv6:2001:3e0:577:0:20d:61ff:fecc:2253]) by basalt.tackymt.homeip.net (Postfix) with ESMTPSA; Mon, 18 Jun 2012 06:29:12 +0900 (JST) Date: Mon, 18 Jun 2012 06:29:12 +0900 From: Taku YAMAMOTO To: Poul-Henning Kamp Message-Id: <20120618062912.61088c11.taku@tackymt.homeip.net> In-Reply-To: <201206172102.q5HL2mG9032399@svn.freebsd.org> References: <201206172102.q5HL2mG9032399@svn.freebsd.org> X-Mailer: Sylpheed 3.0.3 (GTK+ 2.24.6; i386-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237203 - head/sys/dev/fb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 21:29:16 -0000 On Sun, 17 Jun 2012 21:02:48 +0000 (UTC) Poul-Henning Kamp wrote: > Author: phk > Date: Sun Jun 17 21:02:48 2012 > New Revision: 237203 > URL: http://svn.freebsd.org/changeset/base/237203 (snip) > Modified: > head/sys/dev/fb/fbreg.h > > Modified: head/sys/dev/fb/fbreg.h > ============================================================================== > --- head/sys/dev/fb/fbreg.h Sun Jun 17 20:45:45 2012 (r237202) > +++ head/sys/dev/fb/fbreg.h Sun Jun 17 21:02:48 2012 (r237203) > @@ -35,9 +35,16 @@ > > /* some macros */ > #if defined(__amd64__) || defined(__i386__) > -#define bcopy_io(s, d, c) bcopy((void *)(s), (void *)(d), (c)) > -#define bcopy_toio(s, d, c) bcopy((void *)(s), (void *)(d), (c)) > -#define bcopy_fromio(s, d, c) bcopy((void *)(s), (void *)(d), (c)) > + > +static __inline void > +copyw(uint16_t *src, uint16_t *dst, size_t size) > +{ > + while (size--) > + *dst++ = *src++; > +} > +#define bcopy_io(s, d, c) copyw((void*)(s), (void*)(d), (c)) > +#define bcopy_toio(s, d, c) copyw((void*)(s), (void*)(d), (c)) > +#define bcopy_fromio(s, d, c) copyw((void*)(s), (void*)(d), (c)) > #define bzero_io(d, c) bzero((void *)(d), (c)) > #define fill_io(p, d, c) fill((p), (void *)(d), (c)) > #define fillw_io(p, d, c) fillw((p), (void *)(d), (c)) > Does this end up with copying 2*size bytes instead of size bytes? -- -|-__ YAMAMOTO, Taku | __ < - A chicken is an egg's way of producing more eggs. - From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 21:39:40 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D9400106564A; Sun, 17 Jun 2012 21:39:40 +0000 (UTC) (envelope-from mjacob@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C2D9D8FC0C; Sun, 17 Jun 2012 21:39:40 +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 q5HLde8l034312; Sun, 17 Jun 2012 21:39:40 GMT (envelope-from mjacob@svn.freebsd.org) Received: (from mjacob@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5HLdeCQ034308; Sun, 17 Jun 2012 21:39:40 GMT (envelope-from mjacob@svn.freebsd.org) Message-Id: <201206172139.q5HLdeCQ034308@svn.freebsd.org> From: Matt Jacob Date: Sun, 17 Jun 2012 21:39:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237210 - head/sys/dev/isp X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 21:39:41 -0000 Author: mjacob Date: Sun Jun 17 21:39:40 2012 New Revision: 237210 URL: http://svn.freebsd.org/changeset/base/237210 Log: Prepare for FC-Tape support. This involved doing a lot of little cleanups and crosschecks against firmware documentation. We now check and report FC firmware attributes and at least are now prepared for the upper 48 bits of f/w attributes (which are probably for the 8100 or later cards). This involed changing how inbits and outbits are calculated for varios commands, hopefully clearer and cleaner. This also caused me to clean up the actual mailbox register usage. Finally, we are now unconditionally using a CRN for initiator mode. A longstanding issue with the 2400/2500 is that they do *not* support a "Prefer PTP followed by loop", which explains why enabling that caused the f/w to crash. A slightly more invasive change is to let the firmware load entirely drive whether multi_id support is enabled or not. Sponsored by: Spectralogic MFC after: 1 week Modified: head/sys/dev/isp/isp.c head/sys/dev/isp/isp_freebsd.h head/sys/dev/isp/isp_pci.c head/sys/dev/isp/ispmbox.h head/sys/dev/isp/ispreg.h head/sys/dev/isp/ispvar.h Modified: head/sys/dev/isp/isp.c ============================================================================== --- head/sys/dev/isp/isp.c Sun Jun 17 21:30:24 2012 (r237209) +++ head/sys/dev/isp/isp.c Sun Jun 17 21:39:40 2012 (r237210) @@ -159,6 +159,8 @@ void isp_reset(ispsoftc_t *isp, int do_load_defaults) { mbreg_t mbs; + char *buf; + uint64_t fwt; uint32_t code_org, val; int loops, i, dodnld = 1; const char *btype = "????"; @@ -685,9 +687,7 @@ isp_reset(ispsoftc_t *isp, int do_load_d * Do some sanity checking by running a NOP command. * If it succeeds, the ROM firmware is now running. */ - ISP_MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_NO_OP; - mbs.logval = MBLOGALL; + MBSINIT(&mbs, MBOX_NO_OP, MBLOGALL, 0); isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { isp_prt(isp, ISP_LOGERR, "NOP command failed (%x)", mbs.param[0]); @@ -700,29 +700,32 @@ isp_reset(ispsoftc_t *isp, int do_load_d */ if (IS_SCSI(isp) || IS_24XX(isp)) { - ISP_MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_MAILBOX_REG_TEST; - mbs.param[1] = 0xdead; - mbs.param[2] = 0xbeef; - mbs.param[3] = 0xffff; - mbs.param[4] = 0x1111; - mbs.param[5] = 0xa5a5; - mbs.param[6] = 0x0000; - mbs.param[7] = 0x0000; - mbs.logval = MBLOGALL; + static const uint16_t patterns[MAX_MAILBOX] = { + 0x0000, 0xdead, 0xbeef, 0xffff, + 0xa5a5, 0x5a5a, 0x7f7f, 0x7ff7, + 0x3421, 0xabcd, 0xdcba, 0xfeef, + 0xbead, 0xdebe, 0x2222, 0x3333, + 0x5555, 0x6666, 0x7777, 0xaaaa, + 0xffff, 0xdddd, 0x9999, 0x1fbc, + 0x6666, 0x6677, 0x1122, 0x33ff, + 0x0000, 0x0001, 0x1000, 0x1010, + }; + MBSINIT(&mbs, MBOX_MAILBOX_REG_TEST, MBLOGALL, 0); + for (i = 1; i < ISP_NMBOX(isp); i++) { + mbs.param[i] = patterns[i]; + } isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { ISP_RESET0(isp); return; } - if (mbs.param[1] != 0xdead || mbs.param[2] != 0xbeef || - mbs.param[3] != 0xffff || mbs.param[4] != 0x1111 || - mbs.param[5] != 0xa5a5) { - ISP_RESET0(isp); - isp_prt(isp, ISP_LOGERR, "Register Test Failed (0x%x 0x%x 0x%x 0x%x 0x%x)", mbs.param[1], mbs.param[2], mbs.param[3], mbs.param[4], mbs.param[5]); - return; + for (i = 1; i < ISP_NMBOX(isp); i++) { + if (mbs.param[i] != patterns[i]) { + ISP_RESET0(isp); + isp_prt(isp, ISP_LOGERR, "Register Test Failed at Register %d: should have 0x%04x but got 0x%04x", i, patterns[i], mbs.param[i]); + return; + } } - } /* @@ -780,7 +783,7 @@ isp_reset(ispsoftc_t *isp, int do_load_d } MEMORYBARRIER(isp, SYNC_REQUEST, 0, ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)), -1); again: - ISP_MEMZERO(&mbs, sizeof (mbs)); + MBSINIT(&mbs, 0, MBLOGALL, 0); if (la < 0x10000 && nw < 0x10000) { mbs.param[0] = MBOX_LOAD_RISC_RAM_2100; mbs.param[1] = la; @@ -818,7 +821,6 @@ isp_reset(ispsoftc_t *isp, int do_load_d mbs.param[8] = la >> 16; isp_prt(isp, ISP_LOGDEBUG0, "LOAD RISC RAM %u words at load address 0x%x", nw, la); } - mbs.logval = MBLOGALL; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { if (mbs.param[0] == MBOX_HOST_INTERFACE_ERROR) { @@ -872,7 +874,7 @@ isp_reset(ispsoftc_t *isp, int do_load_d wl--; } MEMORYBARRIER(isp, SYNC_REQUEST, 0, ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)), -1); - ISP_MEMZERO(&mbs, sizeof (mbs)); + MBSINIT(&mbs, 0, MBLOGALL, 0); if (la < 0x10000) { mbs.param[0] = MBOX_LOAD_RISC_RAM_2100; mbs.param[1] = la; @@ -893,7 +895,6 @@ isp_reset(ispsoftc_t *isp, int do_load_d mbs.param[8] = la >> 16; isp_prt(isp, ISP_LOGDEBUG1, "LOAD RISC RAM %u words at load address 0x%x\n", nw, la); } - mbs.logval = MBLOGALL; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { isp_prt(isp, ISP_LOGERR, "F/W Risc Ram Load Failed"); @@ -933,11 +934,9 @@ isp_reset(ispsoftc_t *isp, int do_load_d isp->isp_mbxworkp = &ucd.np[1]; isp->isp_mbxwrk0 = ucd.np[3] - 1; isp->isp_mbxwrk1 = code_org + 1; - ISP_MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_WRITE_RAM_WORD; + MBSINIT(&mbs, MBOX_WRITE_RAM_WORD, MBLOGNONE, 0); mbs.param[1] = code_org; mbs.param[2] = ucd.np[0]; - mbs.logval = MBLOGNONE; isp_prt(isp, ISP_LOGDEBUG1, "WRITE RAM %u words at load address 0x%x\n", ucd.np[3], code_org); isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { @@ -954,7 +953,7 @@ isp_reset(ispsoftc_t *isp, int do_load_d * If we loaded firmware, verify its checksum */ if (isp->isp_loaded_fw) { - ISP_MEMZERO(&mbs, sizeof (mbs)); + MBSINIT(&mbs, MBOX_VERIFY_CHECKSUM, MBLOGNONE, 0); mbs.param[0] = MBOX_VERIFY_CHECKSUM; if (IS_24XX(isp)) { mbs.param[1] = code_org >> 16; @@ -978,7 +977,7 @@ isp_reset(ispsoftc_t *isp, int do_load_d */ - MBSINIT(&mbs, MBOX_EXEC_FIRMWARE, MBLOGALL, 1000000); + MBSINIT(&mbs, MBOX_EXEC_FIRMWARE, MBLOGALL, 5000000); if (IS_24XX(isp)) { mbs.param[1] = code_org >> 16; mbs.param[2] = code_org; @@ -1071,9 +1070,6 @@ isp_reset(ispsoftc_t *isp, int do_load_d isp->isp_fwrev[2] = mbs.param[3]; } - isp_prt(isp, ISP_LOGCONFIG, "Board Type %s, Chip Revision 0x%x, %s F/W Revision %d.%d.%d", - btype, isp->isp_revision, dodnld? "loaded" : "resident", isp->isp_fwrev[0], isp->isp_fwrev[1], isp->isp_fwrev[2]); - if (IS_FC(isp)) { /* * We do not believe firmware attributes for 2100 code less @@ -1090,9 +1086,12 @@ isp_reset(ispsoftc_t *isp, int do_load_d #endif } else { isp->isp_fwattr = mbs.param[6]; - isp_prt(isp, ISP_LOGDEBUG0, "Firmware Attributes = 0x%x", mbs.param[6]); } - } else { + if (IS_24XX(isp) && (isp->isp_fwattr & ISP2400_FW_ATTR_EXTNDED)) { + isp->isp_fwattr ^= ISP2400_FW_ATTR_EXTNDED; + isp->isp_fwattr |= (((uint64_t) mbs.param[15]) << 16) | (((uint64_t) mbs.param[16]) << 32) | (((uint64_t) mbs.param[17]) << 48); + } + } else if (IS_SCSI(isp)) { #ifndef ISP_TARGET_MODE isp->isp_fwattr = ISP_FW_ATTR_TMODE; #else @@ -1100,6 +1099,95 @@ isp_reset(ispsoftc_t *isp, int do_load_d #endif } + isp_prt(isp, ISP_LOGCONFIG, "Board Type %s, Chip Revision 0x%x, %s F/W Revision %d.%d.%d", + btype, isp->isp_revision, dodnld? "loaded" : "resident", isp->isp_fwrev[0], isp->isp_fwrev[1], isp->isp_fwrev[2]); + + fwt = isp->isp_fwattr; + if (IS_24XX(isp)) { + buf = FCPARAM(isp, 0)->isp_scratch; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN, "Attributes:"); + if (fwt & ISP2400_FW_ATTR_CLASS2) { + fwt ^=ISP2400_FW_ATTR_CLASS2; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s Class2", buf); + } + if (fwt & ISP2400_FW_ATTR_IP) { + fwt ^=ISP2400_FW_ATTR_IP; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s IP", buf); + } + if (fwt & ISP2400_FW_ATTR_MULTIID) { + fwt ^=ISP2400_FW_ATTR_MULTIID; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s MultiID", buf); + } + if (fwt & ISP2400_FW_ATTR_SB2) { + fwt ^=ISP2400_FW_ATTR_SB2; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s SB2", buf); + } + if (fwt & ISP2400_FW_ATTR_T10CRC) { + fwt ^=ISP2400_FW_ATTR_T10CRC; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s T10CRC", buf); + } + if (fwt & ISP2400_FW_ATTR_VI) { + fwt ^=ISP2400_FW_ATTR_VI; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s VI", buf); + } + if (fwt & ISP2400_FW_ATTR_VP0) { + fwt ^= ISP2400_FW_ATTR_VP0; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s VP0_Decoupling", buf); + } + if (fwt & ISP2400_FW_ATTR_EXPFW) { + fwt ^= ISP2400_FW_ATTR_EXPFW; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s (Experimental)", buf); + } + fwt &= ~ISP2400_FW_ATTR_EXTNDED; + if (fwt) { + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s (unknown 0x%jx)", buf, (uintmax_t)fwt); + } + isp_prt(isp, ISP_LOGCONFIG, "%s", buf); + } else if (IS_FC(isp)) { + buf = FCPARAM(isp, 0)->isp_scratch; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN, "Attributes:"); + if (fwt & ISP_FW_ATTR_TMODE) { + fwt ^=ISP_FW_ATTR_TMODE; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s TargetMode", buf); + } + if (fwt & ISP_FW_ATTR_SCCLUN) { + fwt ^=ISP_FW_ATTR_SCCLUN; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s SCC-Lun", buf); + } + if (fwt & ISP_FW_ATTR_FABRIC) { + fwt ^=ISP_FW_ATTR_FABRIC; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s Fabric", buf); + } + if (fwt & ISP_FW_ATTR_CLASS2) { + fwt ^=ISP_FW_ATTR_CLASS2; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s Class2", buf); + } + if (fwt & ISP_FW_ATTR_FCTAPE) { + fwt ^=ISP_FW_ATTR_FCTAPE; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s FC-Tape", buf); + } + if (fwt & ISP_FW_ATTR_IP) { + fwt ^=ISP_FW_ATTR_IP; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s IP", buf); + } + if (fwt & ISP_FW_ATTR_VI) { + fwt ^=ISP_FW_ATTR_VI; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s VI", buf); + } + if (fwt & ISP_FW_ATTR_VI_SOLARIS) { + fwt ^=ISP_FW_ATTR_VI_SOLARIS; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s VI_SOLARIS", buf); + } + if (fwt & ISP_FW_ATTR_2KLOGINS) { + fwt ^=ISP_FW_ATTR_2KLOGINS; + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s 2K-Login", buf); + } + if (fwt != 0) { + ISP_SNPRINTF(buf, ISP_FC_SCRLEN - strlen(buf), "%s (unknown 0x%jx)", buf, (uintmax_t)fwt); + } + isp_prt(isp, ISP_LOGCONFIG, "%s", buf); + } + if (!IS_24XX(isp)) { MBSINIT(&mbs, MBOX_GET_FIRMWARE_STATUS, MBLOGALL, 0); isp_mboxcmd(isp, &mbs); @@ -1768,6 +1856,7 @@ isp_fibre_init_2400(ispsoftc_t *isp) isp_icb_2400_t local, *icbp = &local; mbreg_t mbs; int chan; + int ownloopid = 0; /* * Check to see whether all channels have *some* kind of role @@ -1831,7 +1920,6 @@ isp_fibre_init_2400(ispsoftc_t *isp) * Get current resource count */ MBSINIT(&mbs, MBOX_GET_RESOURCE_COUNT, MBLOGALL, 0); - mbs.obits = 0x4cf; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { return; @@ -1840,27 +1928,18 @@ isp_fibre_init_2400(ispsoftc_t *isp) } + ownloopid = (isp->isp_confopts & ISP_CFG_OWNLOOPID) != 0; icbp->icb_hardaddr = fcp->isp_loopid; if (icbp->icb_hardaddr >= LOCAL_LOOP_LIM) { icbp->icb_hardaddr = 0; + ownloopid = 0; } - /* - * Force this on. - */ - icbp->icb_fwoptions1 |= ICB2400_OPT1_HARD_ADDRESS; + if (ownloopid) + icbp->icb_fwoptions1 |= ICB2400_OPT1_HARD_ADDRESS; icbp->icb_fwoptions2 = fcp->isp_xfwoptions; switch (isp->isp_confopts & ISP_CFG_PORT_PREF) { -#if 0 - case ISP_CFG_NPORT: - /* - * XXX: This causes the f/w to crash. - */ - icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK; - icbp->icb_fwoptions2 |= ICB2400_OPT2_PTP_2_LOOP; - break; -#endif case ISP_CFG_NPORT_ONLY: icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK; icbp->icb_fwoptions2 |= ICB2400_OPT2_PTP_ONLY; @@ -1870,14 +1949,12 @@ isp_fibre_init_2400(ispsoftc_t *isp) icbp->icb_fwoptions2 |= ICB2400_OPT2_LOOP_ONLY; break; default: + /* ISP_CFG_PTP_2_LOOP not available in 24XX/25XX */ icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK; icbp->icb_fwoptions2 |= ICB2400_OPT2_LOOP_2_PTP; break; } - /* force this on for now */ - icbp->icb_fwoptions2 |= ICB2400_OPT2_ZIO; - switch (icbp->icb_fwoptions2 & ICB2400_OPT2_TIMER_MASK) { case ICB2400_OPT2_ZIO: case ICB2400_OPT2_ZIO1: @@ -1891,12 +1968,10 @@ isp_fibre_init_2400(ispsoftc_t *isp) break; } - /* - * We don't support FCTAPE, so clear it. - */ - icbp->icb_fwoptions2 &= ~ICB2400_OPT2_FCTAPE; - icbp->icb_fwoptions3 = fcp->isp_zfwoptions; + if ((icbp->icb_fwoptions3 & ICB2400_OPT3_RSPSZ_MASK) == 0) { + icbp->icb_fwoptions3 |= ICB2400_OPT3_RSPSZ_24; + } icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_AUTO; if (isp->isp_confopts & ISP_CFG_ONEGB) { icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_ONEGB; @@ -1904,11 +1979,12 @@ isp_fibre_init_2400(ispsoftc_t *isp) icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_TWOGB; } else if (isp->isp_confopts & ISP_CFG_FOURGB) { icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_FOURGB; + } else if (IS_25XX(isp) && (isp->isp_confopts & ISP_CFG_EIGHTGB)) { + icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_EIGHTGB; } else { icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_AUTO; } - - if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) { + if (ownloopid == 0) { icbp->icb_fwoptions3 |= ICB2400_OPT3_SOFTID; } icbp->icb_logintime = ICB_LOGIN_TOV; @@ -2569,11 +2645,7 @@ isp_fclink_test(ispsoftc_t *isp, int cha * Get our Loop ID and Port ID. */ MBSINIT(&mbs, MBOX_GET_LOOP_ID, MBLOGALL, 0); - if (ISP_CAP_MULTI_ID(isp)) { - mbs.param[9] = chan; - mbs.ibits = (1 << 9); - mbs.obits = (1 << 7); - } + mbs.param[9] = chan; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { return (-1); @@ -2676,12 +2748,14 @@ isp_fclink_test(ispsoftc_t *isp, int cha lp->new_portid = lp->portid; lp->new_roles = lp->roles; if (IS_24XX(isp)) { - fcp->inorder = (mbs.param[7] & ISP24XX_INORDER) != 0; - if (ISP_FW_NEWER_THAN(isp, 4, 0, 27)) { - fcp->npiv_fabric = (mbs.param[7] & ISP24XX_NPIV_SAN) != 0; - if (fcp->npiv_fabric) { - isp_prt(isp, ISP_LOGCONFIG, "fabric supports NP-IV"); - } + if (check_for_fabric) { + /* + * The mbs is still hanging out from the MBOX_GET_LOOP_ID above. + */ + fcp->isp_fabric_params = mbs.param[7]; + isp_prt(isp, ISP_LOGCONFIG, "fabric params 0x%x", mbs.param[7]); + } else { + fcp->isp_fabric_params = 0; } if (chan) { fcp->isp_sns_hdl = NPH_SNS_HDLBASE + chan; @@ -4427,6 +4501,7 @@ isp_start(XS_T *xs) t7->req_lun[0] |= 0x40; } t7->req_lun[1] = XS_LUN(xs); + FCP_NEXT_CRN(isp, xs, t7->req_crn, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); tptr = &t7->req_time; cdbp = t7->req_cdb; cdblen = ISP_MIN(cdblen, sizeof (t7->req_cdb)); @@ -4907,7 +4982,7 @@ again: if (isp->isp_mboxbsy) { int obits = isp->isp_obits; isp->isp_mboxtmp[0] = mbox; - for (i = 1; i < MAX_MAILBOX(isp); i++) { + for (i = 1; i < ISP_NMBOX(isp); i++) { if ((obits & (1 << i)) == 0) { continue; } @@ -6667,105 +6742,106 @@ isp_mbox_continue(ispsoftc_t *isp) return (0); } -#define HIWRD(x) ((x) >> 16) -#define LOWRD(x) ((x) & 0xffff) -#define ISPOPMAP(a, b) (((a) << 16) | (b)) -static const uint32_t mbpscsi[] = { - ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */ - ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */ - ISPOPMAP(0x03, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */ - ISPOPMAP(0x1f, 0x01), /* 0x03: MBOX_DUMP_RAM */ - ISPOPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */ - ISPOPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */ - ISPOPMAP(0x3f, 0x3f), /* 0x06: MBOX_MAILBOX_REG_TEST */ - ISPOPMAP(0x07, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */ - ISPOPMAP(0x01, 0x0f), /* 0x08: MBOX_ABOUT_FIRMWARE */ - ISPOPMAP(0x00, 0x00), /* 0x09: */ - ISPOPMAP(0x00, 0x00), /* 0x0a: */ - ISPOPMAP(0x00, 0x00), /* 0x0b: */ - ISPOPMAP(0x00, 0x00), /* 0x0c: */ - ISPOPMAP(0x00, 0x00), /* 0x0d: */ - ISPOPMAP(0x01, 0x05), /* 0x0e: MBOX_CHECK_FIRMWARE */ - ISPOPMAP(0x00, 0x00), /* 0x0f: */ - ISPOPMAP(0x1f, 0x1f), /* 0x10: MBOX_INIT_REQ_QUEUE */ - ISPOPMAP(0x3f, 0x3f), /* 0x11: MBOX_INIT_RES_QUEUE */ - ISPOPMAP(0x0f, 0x0f), /* 0x12: MBOX_EXECUTE_IOCB */ - ISPOPMAP(0x03, 0x03), /* 0x13: MBOX_WAKE_UP */ - ISPOPMAP(0x01, 0x3f), /* 0x14: MBOX_STOP_FIRMWARE */ - ISPOPMAP(0x0f, 0x0f), /* 0x15: MBOX_ABORT */ - ISPOPMAP(0x03, 0x03), /* 0x16: MBOX_ABORT_DEVICE */ - ISPOPMAP(0x07, 0x07), /* 0x17: MBOX_ABORT_TARGET */ - ISPOPMAP(0x07, 0x07), /* 0x18: MBOX_BUS_RESET */ - ISPOPMAP(0x03, 0x07), /* 0x19: MBOX_STOP_QUEUE */ - ISPOPMAP(0x03, 0x07), /* 0x1a: MBOX_START_QUEUE */ - ISPOPMAP(0x03, 0x07), /* 0x1b: MBOX_SINGLE_STEP_QUEUE */ - ISPOPMAP(0x03, 0x07), /* 0x1c: MBOX_ABORT_QUEUE */ - ISPOPMAP(0x03, 0x4f), /* 0x1d: MBOX_GET_DEV_QUEUE_STATUS */ - ISPOPMAP(0x00, 0x00), /* 0x1e: */ - ISPOPMAP(0x01, 0x07), /* 0x1f: MBOX_GET_FIRMWARE_STATUS */ - ISPOPMAP(0x01, 0x07), /* 0x20: MBOX_GET_INIT_SCSI_ID */ - ISPOPMAP(0x01, 0x07), /* 0x21: MBOX_GET_SELECT_TIMEOUT */ - ISPOPMAP(0x01, 0xc7), /* 0x22: MBOX_GET_RETRY_COUNT */ - ISPOPMAP(0x01, 0x07), /* 0x23: MBOX_GET_TAG_AGE_LIMIT */ - ISPOPMAP(0x01, 0x03), /* 0x24: MBOX_GET_CLOCK_RATE */ - ISPOPMAP(0x01, 0x07), /* 0x25: MBOX_GET_ACT_NEG_STATE */ - ISPOPMAP(0x01, 0x07), /* 0x26: MBOX_GET_ASYNC_DATA_SETUP_TIME */ - ISPOPMAP(0x01, 0x07), /* 0x27: MBOX_GET_PCI_PARAMS */ - ISPOPMAP(0x03, 0x4f), /* 0x28: MBOX_GET_TARGET_PARAMS */ - ISPOPMAP(0x03, 0x0f), /* 0x29: MBOX_GET_DEV_QUEUE_PARAMS */ - ISPOPMAP(0x01, 0x07), /* 0x2a: MBOX_GET_RESET_DELAY_PARAMS */ - ISPOPMAP(0x00, 0x00), /* 0x2b: */ - ISPOPMAP(0x00, 0x00), /* 0x2c: */ - ISPOPMAP(0x00, 0x00), /* 0x2d: */ - ISPOPMAP(0x00, 0x00), /* 0x2e: */ - ISPOPMAP(0x00, 0x00), /* 0x2f: */ - ISPOPMAP(0x03, 0x03), /* 0x30: MBOX_SET_INIT_SCSI_ID */ - ISPOPMAP(0x07, 0x07), /* 0x31: MBOX_SET_SELECT_TIMEOUT */ - ISPOPMAP(0xc7, 0xc7), /* 0x32: MBOX_SET_RETRY_COUNT */ - ISPOPMAP(0x07, 0x07), /* 0x33: MBOX_SET_TAG_AGE_LIMIT */ - ISPOPMAP(0x03, 0x03), /* 0x34: MBOX_SET_CLOCK_RATE */ - ISPOPMAP(0x07, 0x07), /* 0x35: MBOX_SET_ACT_NEG_STATE */ - ISPOPMAP(0x07, 0x07), /* 0x36: MBOX_SET_ASYNC_DATA_SETUP_TIME */ - ISPOPMAP(0x07, 0x07), /* 0x37: MBOX_SET_PCI_CONTROL_PARAMS */ - ISPOPMAP(0x4f, 0x4f), /* 0x38: MBOX_SET_TARGET_PARAMS */ - ISPOPMAP(0x0f, 0x0f), /* 0x39: MBOX_SET_DEV_QUEUE_PARAMS */ - ISPOPMAP(0x07, 0x07), /* 0x3a: MBOX_SET_RESET_DELAY_PARAMS */ - ISPOPMAP(0x00, 0x00), /* 0x3b: */ - ISPOPMAP(0x00, 0x00), /* 0x3c: */ - ISPOPMAP(0x00, 0x00), /* 0x3d: */ - ISPOPMAP(0x00, 0x00), /* 0x3e: */ - ISPOPMAP(0x00, 0x00), /* 0x3f: */ - ISPOPMAP(0x01, 0x03), /* 0x40: MBOX_RETURN_BIOS_BLOCK_ADDR */ - ISPOPMAP(0x3f, 0x01), /* 0x41: MBOX_WRITE_FOUR_RAM_WORDS */ - ISPOPMAP(0x03, 0x07), /* 0x42: MBOX_EXEC_BIOS_IOCB */ - ISPOPMAP(0x00, 0x00), /* 0x43: */ - ISPOPMAP(0x00, 0x00), /* 0x44: */ - ISPOPMAP(0x03, 0x03), /* 0x45: SET SYSTEM PARAMETER */ - ISPOPMAP(0x01, 0x03), /* 0x46: GET SYSTEM PARAMETER */ - ISPOPMAP(0x00, 0x00), /* 0x47: */ - ISPOPMAP(0x01, 0xcf), /* 0x48: GET SCAM CONFIGURATION */ - ISPOPMAP(0xcf, 0xcf), /* 0x49: SET SCAM CONFIGURATION */ - ISPOPMAP(0x03, 0x03), /* 0x4a: MBOX_SET_FIRMWARE_FEATURES */ - ISPOPMAP(0x01, 0x03), /* 0x4b: MBOX_GET_FIRMWARE_FEATURES */ - ISPOPMAP(0x00, 0x00), /* 0x4c: */ - ISPOPMAP(0x00, 0x00), /* 0x4d: */ - ISPOPMAP(0x00, 0x00), /* 0x4e: */ - ISPOPMAP(0x00, 0x00), /* 0x4f: */ - ISPOPMAP(0xdf, 0xdf), /* 0x50: LOAD RAM A64 */ - ISPOPMAP(0xdf, 0xdf), /* 0x51: DUMP RAM A64 */ - ISPOPMAP(0xdf, 0xff), /* 0x52: INITIALIZE REQUEST QUEUE A64 */ - ISPOPMAP(0xef, 0xff), /* 0x53: INITIALIZE RESPONSE QUEUE A64 */ - ISPOPMAP(0xcf, 0x01), /* 0x54: EXECUCUTE COMMAND IOCB A64 */ - ISPOPMAP(0x07, 0x01), /* 0x55: ENABLE TARGET MODE */ - ISPOPMAP(0x03, 0x0f), /* 0x56: GET TARGET STATUS */ - ISPOPMAP(0x00, 0x00), /* 0x57: */ - ISPOPMAP(0x00, 0x00), /* 0x58: */ - ISPOPMAP(0x00, 0x00), /* 0x59: */ - ISPOPMAP(0x03, 0x03), /* 0x5a: SET DATA OVERRUN RECOVERY MODE */ - ISPOPMAP(0x01, 0x03), /* 0x5b: GET DATA OVERRUN RECOVERY MODE */ - ISPOPMAP(0x0f, 0x0f), /* 0x5c: SET HOST DATA */ - ISPOPMAP(0x01, 0x01) /* 0x5d: GET NOST DATA */ +#define ISP_SCSI_IBITS(op) (mbpscsi[((op)<<1)]) +#define ISP_SCSI_OBITS(op) (mbpscsi[((op)<<1) + 1]) +#define ISP_SCSI_OPMAP(in, out) in, out +static const uint8_t mbpscsi[] = { + ISP_SCSI_OPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */ + ISP_SCSI_OPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */ + ISP_SCSI_OPMAP(0x03, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */ + ISP_SCSI_OPMAP(0x1f, 0x01), /* 0x03: MBOX_DUMP_RAM */ + ISP_SCSI_OPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */ + ISP_SCSI_OPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */ + ISP_SCSI_OPMAP(0x3f, 0x3f), /* 0x06: MBOX_MAILBOX_REG_TEST */ + ISP_SCSI_OPMAP(0x07, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */ + ISP_SCSI_OPMAP(0x01, 0x0f), /* 0x08: MBOX_ABOUT_FIRMWARE */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x09: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x0a: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x0b: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x0c: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x0d: */ + ISP_SCSI_OPMAP(0x01, 0x05), /* 0x0e: MBOX_CHECK_FIRMWARE */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x0f: */ + ISP_SCSI_OPMAP(0x1f, 0x1f), /* 0x10: MBOX_INIT_REQ_QUEUE */ + ISP_SCSI_OPMAP(0x3f, 0x3f), /* 0x11: MBOX_INIT_RES_QUEUE */ + ISP_SCSI_OPMAP(0x0f, 0x0f), /* 0x12: MBOX_EXECUTE_IOCB */ + ISP_SCSI_OPMAP(0x03, 0x03), /* 0x13: MBOX_WAKE_UP */ + ISP_SCSI_OPMAP(0x01, 0x3f), /* 0x14: MBOX_STOP_FIRMWARE */ + ISP_SCSI_OPMAP(0x0f, 0x0f), /* 0x15: MBOX_ABORT */ + ISP_SCSI_OPMAP(0x03, 0x03), /* 0x16: MBOX_ABORT_DEVICE */ + ISP_SCSI_OPMAP(0x07, 0x07), /* 0x17: MBOX_ABORT_TARGET */ + ISP_SCSI_OPMAP(0x07, 0x07), /* 0x18: MBOX_BUS_RESET */ + ISP_SCSI_OPMAP(0x03, 0x07), /* 0x19: MBOX_STOP_QUEUE */ + ISP_SCSI_OPMAP(0x03, 0x07), /* 0x1a: MBOX_START_QUEUE */ + ISP_SCSI_OPMAP(0x03, 0x07), /* 0x1b: MBOX_SINGLE_STEP_QUEUE */ + ISP_SCSI_OPMAP(0x03, 0x07), /* 0x1c: MBOX_ABORT_QUEUE */ + ISP_SCSI_OPMAP(0x03, 0x4f), /* 0x1d: MBOX_GET_DEV_QUEUE_STATUS */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x1e: */ + ISP_SCSI_OPMAP(0x01, 0x07), /* 0x1f: MBOX_GET_FIRMWARE_STATUS */ + ISP_SCSI_OPMAP(0x01, 0x07), /* 0x20: MBOX_GET_INIT_SCSI_ID */ + ISP_SCSI_OPMAP(0x01, 0x07), /* 0x21: MBOX_GET_SELECT_TIMEOUT */ + ISP_SCSI_OPMAP(0x01, 0xc7), /* 0x22: MBOX_GET_RETRY_COUNT */ + ISP_SCSI_OPMAP(0x01, 0x07), /* 0x23: MBOX_GET_TAG_AGE_LIMIT */ + ISP_SCSI_OPMAP(0x01, 0x03), /* 0x24: MBOX_GET_CLOCK_RATE */ + ISP_SCSI_OPMAP(0x01, 0x07), /* 0x25: MBOX_GET_ACT_NEG_STATE */ + ISP_SCSI_OPMAP(0x01, 0x07), /* 0x26: MBOX_GET_ASYNC_DATA_SETUP_TIME */ + ISP_SCSI_OPMAP(0x01, 0x07), /* 0x27: MBOX_GET_PCI_PARAMS */ + ISP_SCSI_OPMAP(0x03, 0x4f), /* 0x28: MBOX_GET_TARGET_PARAMS */ + ISP_SCSI_OPMAP(0x03, 0x0f), /* 0x29: MBOX_GET_DEV_QUEUE_PARAMS */ + ISP_SCSI_OPMAP(0x01, 0x07), /* 0x2a: MBOX_GET_RESET_DELAY_PARAMS */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x2b: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x2c: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x2d: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x2e: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x2f: */ + ISP_SCSI_OPMAP(0x03, 0x03), /* 0x30: MBOX_SET_INIT_SCSI_ID */ + ISP_SCSI_OPMAP(0x07, 0x07), /* 0x31: MBOX_SET_SELECT_TIMEOUT */ + ISP_SCSI_OPMAP(0xc7, 0xc7), /* 0x32: MBOX_SET_RETRY_COUNT */ + ISP_SCSI_OPMAP(0x07, 0x07), /* 0x33: MBOX_SET_TAG_AGE_LIMIT */ + ISP_SCSI_OPMAP(0x03, 0x03), /* 0x34: MBOX_SET_CLOCK_RATE */ + ISP_SCSI_OPMAP(0x07, 0x07), /* 0x35: MBOX_SET_ACT_NEG_STATE */ + ISP_SCSI_OPMAP(0x07, 0x07), /* 0x36: MBOX_SET_ASYNC_DATA_SETUP_TIME */ + ISP_SCSI_OPMAP(0x07, 0x07), /* 0x37: MBOX_SET_PCI_CONTROL_PARAMS */ + ISP_SCSI_OPMAP(0x4f, 0x4f), /* 0x38: MBOX_SET_TARGET_PARAMS */ + ISP_SCSI_OPMAP(0x0f, 0x0f), /* 0x39: MBOX_SET_DEV_QUEUE_PARAMS */ + ISP_SCSI_OPMAP(0x07, 0x07), /* 0x3a: MBOX_SET_RESET_DELAY_PARAMS */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x3b: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x3c: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x3d: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x3e: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x3f: */ + ISP_SCSI_OPMAP(0x01, 0x03), /* 0x40: MBOX_RETURN_BIOS_BLOCK_ADDR */ + ISP_SCSI_OPMAP(0x3f, 0x01), /* 0x41: MBOX_WRITE_FOUR_RAM_WORDS */ + ISP_SCSI_OPMAP(0x03, 0x07), /* 0x42: MBOX_EXEC_BIOS_IOCB */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x43: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x44: */ + ISP_SCSI_OPMAP(0x03, 0x03), /* 0x45: SET SYSTEM PARAMETER */ + ISP_SCSI_OPMAP(0x01, 0x03), /* 0x46: GET SYSTEM PARAMETER */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x47: */ + ISP_SCSI_OPMAP(0x01, 0xcf), /* 0x48: GET SCAM CONFIGURATION */ + ISP_SCSI_OPMAP(0xcf, 0xcf), /* 0x49: SET SCAM CONFIGURATION */ + ISP_SCSI_OPMAP(0x03, 0x03), /* 0x4a: MBOX_SET_FIRMWARE_FEATURES */ + ISP_SCSI_OPMAP(0x01, 0x03), /* 0x4b: MBOX_GET_FIRMWARE_FEATURES */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x4c: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x4d: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x4e: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x4f: */ + ISP_SCSI_OPMAP(0xdf, 0xdf), /* 0x50: LOAD RAM A64 */ + ISP_SCSI_OPMAP(0xdf, 0xdf), /* 0x51: DUMP RAM A64 */ + ISP_SCSI_OPMAP(0xdf, 0xff), /* 0x52: INITIALIZE REQUEST QUEUE A64 */ + ISP_SCSI_OPMAP(0xef, 0xff), /* 0x53: INITIALIZE RESPONSE QUEUE A64 */ + ISP_SCSI_OPMAP(0xcf, 0x01), /* 0x54: EXECUCUTE COMMAND IOCB A64 */ + ISP_SCSI_OPMAP(0x07, 0x01), /* 0x55: ENABLE TARGET MODE */ + ISP_SCSI_OPMAP(0x03, 0x0f), /* 0x56: GET TARGET STATUS */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x57: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x58: */ + ISP_SCSI_OPMAP(0x00, 0x00), /* 0x59: */ + ISP_SCSI_OPMAP(0x03, 0x03), /* 0x5a: SET DATA OVERRUN RECOVERY MODE */ + ISP_SCSI_OPMAP(0x01, 0x03), /* 0x5b: GET DATA OVERRUN RECOVERY MODE */ + ISP_SCSI_OPMAP(0x0f, 0x0f), /* 0x5c: SET HOST DATA */ + ISP_SCSI_OPMAP(0x01, 0x01) /* 0x5d: GET NOST DATA */ }; +#define MAX_SCSI_OPCODE 0x5d static const char *scsi_mbcmd_names[] = { "NO-OP", @@ -6864,135 +6940,142 @@ static const char *scsi_mbcmd_names[] = "GET NOST DATA", }; +#define ISP_FC_IBITS(op) ((mbpfc[((op)<<3) + 0] << 24) | (mbpfc[((op)<<3) + 1] << 16) | (mbpfc[((op)<<3) + 2] << 8) | (mbpfc[((op)<<3) + 3])) +#define ISP_FC_OBITS(op) ((mbpfc[((op)<<3) + 4] << 24) | (mbpfc[((op)<<3) + 5] << 16) | (mbpfc[((op)<<3) + 6] << 8) | (mbpfc[((op)<<3) + 7])) + +#define ISP_FC_OPMAP(in0, out0) 0, 0, 0, in0, 0, 0, 0, out0 +#define ISP_FC_OPMAP_HALF(in1, in0, out1, out0) 0, 0, in1, in0, 0, 0, out1, out0 +#define ISP_FC_OPMAP_FULL(in3, in2, in1, in0, out3, out2, out1, out0) in3, in2, in1, in0, out3, out2, out1, out0 static const uint32_t mbpfc[] = { - ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */ - ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */ - ISPOPMAP(0x0f, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */ - ISPOPMAP(0xdf, 0x01), /* 0x03: MBOX_DUMP_RAM */ - ISPOPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */ - ISPOPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */ - ISPOPMAP(0xff, 0xff), /* 0x06: MBOX_MAILBOX_REG_TEST */ - ISPOPMAP(0x07, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */ - ISPOPMAP(0x01, 0x4f), /* 0x08: MBOX_ABOUT_FIRMWARE */ - ISPOPMAP(0xdf, 0x01), /* 0x09: MBOX_LOAD_RISC_RAM_2100 */ - ISPOPMAP(0xdf, 0x01), /* 0x0a: DUMP RAM */ - ISPOPMAP(0x1ff, 0x01), /* 0x0b: MBOX_LOAD_RISC_RAM */ - ISPOPMAP(0x00, 0x00), /* 0x0c: */ - ISPOPMAP(0x10f, 0x01), /* 0x0d: MBOX_WRITE_RAM_WORD_EXTENDED */ - ISPOPMAP(0x01, 0x05), /* 0x0e: MBOX_CHECK_FIRMWARE */ - ISPOPMAP(0x103, 0x0d), /* 0x0f: MBOX_READ_RAM_WORD_EXTENDED */ - ISPOPMAP(0x1f, 0x11), /* 0x10: MBOX_INIT_REQ_QUEUE */ - ISPOPMAP(0x2f, 0x21), /* 0x11: MBOX_INIT_RES_QUEUE */ - ISPOPMAP(0x0f, 0x01), /* 0x12: MBOX_EXECUTE_IOCB */ - ISPOPMAP(0x03, 0x03), /* 0x13: MBOX_WAKE_UP */ - ISPOPMAP(0x01, 0xff), /* 0x14: MBOX_STOP_FIRMWARE */ - ISPOPMAP(0x4f, 0x01), /* 0x15: MBOX_ABORT */ - ISPOPMAP(0x07, 0x01), /* 0x16: MBOX_ABORT_DEVICE */ - ISPOPMAP(0x07, 0x01), /* 0x17: MBOX_ABORT_TARGET */ - ISPOPMAP(0x03, 0x03), /* 0x18: MBOX_BUS_RESET */ - ISPOPMAP(0x07, 0x05), /* 0x19: MBOX_STOP_QUEUE */ - ISPOPMAP(0x07, 0x05), /* 0x1a: MBOX_START_QUEUE */ - ISPOPMAP(0x07, 0x05), /* 0x1b: MBOX_SINGLE_STEP_QUEUE */ - ISPOPMAP(0x07, 0x05), /* 0x1c: MBOX_ABORT_QUEUE */ - ISPOPMAP(0x07, 0x03), /* 0x1d: MBOX_GET_DEV_QUEUE_STATUS */ - ISPOPMAP(0x00, 0x00), /* 0x1e: */ - ISPOPMAP(0x01, 0x07), /* 0x1f: MBOX_GET_FIRMWARE_STATUS */ - ISPOPMAP(0x01, 0x4f), /* 0x20: MBOX_GET_LOOP_ID */ - ISPOPMAP(0x00, 0x00), /* 0x21: */ - ISPOPMAP(0x01, 0x07), /* 0x22: MBOX_GET_RETRY_COUNT */ - ISPOPMAP(0x00, 0x00), /* 0x23: */ - ISPOPMAP(0x00, 0x00), /* 0x24: */ - ISPOPMAP(0x00, 0x00), /* 0x25: */ - ISPOPMAP(0x00, 0x00), /* 0x26: */ - ISPOPMAP(0x00, 0x00), /* 0x27: */ - ISPOPMAP(0x01, 0x03), /* 0x28: MBOX_GET_FIRMWARE_OPTIONS */ - ISPOPMAP(0x03, 0x07), /* 0x29: MBOX_GET_PORT_QUEUE_PARAMS */ - ISPOPMAP(0x00, 0x00), /* 0x2a: */ - ISPOPMAP(0x00, 0x00), /* 0x2b: */ - ISPOPMAP(0x00, 0x00), /* 0x2c: */ - ISPOPMAP(0x00, 0x00), /* 0x2d: */ - ISPOPMAP(0x00, 0x00), /* 0x2e: */ - ISPOPMAP(0x00, 0x00), /* 0x2f: */ - ISPOPMAP(0x00, 0x00), /* 0x30: */ - ISPOPMAP(0x00, 0x00), /* 0x31: */ - ISPOPMAP(0x07, 0x07), /* 0x32: MBOX_SET_RETRY_COUNT */ - ISPOPMAP(0x00, 0x00), /* 0x33: */ - ISPOPMAP(0x00, 0x00), /* 0x34: */ - ISPOPMAP(0x00, 0x00), /* 0x35: */ - ISPOPMAP(0x00, 0x00), /* 0x36: */ - ISPOPMAP(0x00, 0x00), /* 0x37: */ - ISPOPMAP(0x0f, 0x01), /* 0x38: MBOX_SET_FIRMWARE_OPTIONS */ - ISPOPMAP(0x0f, 0x07), /* 0x39: MBOX_SET_PORT_QUEUE_PARAMS */ - ISPOPMAP(0x00, 0x00), /* 0x3a: */ - ISPOPMAP(0x00, 0x00), /* 0x3b: */ - ISPOPMAP(0x00, 0x00), /* 0x3c: */ - ISPOPMAP(0x00, 0x00), /* 0x3d: */ - ISPOPMAP(0x00, 0x00), /* 0x3e: */ - ISPOPMAP(0x00, 0x00), /* 0x3f: */ - ISPOPMAP(0x03, 0x01), /* 0x40: MBOX_LOOP_PORT_BYPASS */ - ISPOPMAP(0x03, 0x01), /* 0x41: MBOX_LOOP_PORT_ENABLE */ - ISPOPMAP(0x03, 0x07), /* 0x42: MBOX_GET_RESOURCE_COUNT */ - ISPOPMAP(0x01, 0x01), /* 0x43: MBOX_REQUEST_OFFLINE_MODE */ - ISPOPMAP(0x00, 0x00), /* 0x44: */ - ISPOPMAP(0x00, 0x00), /* 0x45: */ - ISPOPMAP(0x00, 0x00), /* 0x46: */ - ISPOPMAP(0xcf, 0x03), /* 0x47: GET PORT_DATABASE ENHANCED */ - ISPOPMAP(0xcd, 0x01), /* 0x48: MBOX_INIT_FIRMWARE_MULTI_ID */ - ISPOPMAP(0xcd, 0x01), /* 0x49: MBOX_GET_VP_DATABASE */ - ISPOPMAP(0x2cd, 0x01), /* 0x4a: MBOX_GET_VP_DATABASE_ENTRY */ - ISPOPMAP(0x00, 0x00), /* 0x4b: */ - ISPOPMAP(0x00, 0x00), /* 0x4c: */ - ISPOPMAP(0x00, 0x00), /* 0x4d: */ - ISPOPMAP(0x00, 0x00), /* 0x4e: */ - ISPOPMAP(0x00, 0x00), /* 0x4f: */ - ISPOPMAP(0x00, 0x00), /* 0x50: */ - ISPOPMAP(0x00, 0x00), /* 0x51: */ - ISPOPMAP(0x00, 0x00), /* 0x52: */ - ISPOPMAP(0x00, 0x00), /* 0x53: */ - ISPOPMAP(0xcf, 0x01), /* 0x54: EXECUTE IOCB A64 */ - ISPOPMAP(0x00, 0x00), /* 0x55: */ - ISPOPMAP(0x00, 0x00), /* 0x56: */ - ISPOPMAP(0x00, 0x00), /* 0x57: */ - ISPOPMAP(0x00, 0x00), /* 0x58: */ - ISPOPMAP(0x00, 0x00), /* 0x59: */ - ISPOPMAP(0x00, 0x00), /* 0x5a: */ - ISPOPMAP(0x03, 0x01), /* 0x5b: MBOX_DRIVER_HEARTBEAT */ - ISPOPMAP(0xcf, 0x01), /* 0x5c: MBOX_FW_HEARTBEAT */ - ISPOPMAP(0x07, 0x03), /* 0x5d: MBOX_GET_SET_DATA_RATE */ - ISPOPMAP(0x00, 0x00), /* 0x5e: */ - ISPOPMAP(0x00, 0x00), /* 0x5f: */ - ISPOPMAP(0xcd, 0x01), /* 0x60: MBOX_INIT_FIRMWARE */ - ISPOPMAP(0x00, 0x00), /* 0x61: */ - ISPOPMAP(0x01, 0x01), /* 0x62: MBOX_INIT_LIP */ - ISPOPMAP(0xcd, 0x03), /* 0x63: MBOX_GET_FC_AL_POSITION_MAP */ - ISPOPMAP(0xcf, 0x01), /* 0x64: MBOX_GET_PORT_DB */ - ISPOPMAP(0x07, 0x01), /* 0x65: MBOX_CLEAR_ACA */ - ISPOPMAP(0x07, 0x01), /* 0x66: MBOX_TARGET_RESET */ - ISPOPMAP(0x07, 0x01), /* 0x67: MBOX_CLEAR_TASK_SET */ - ISPOPMAP(0x07, 0x01), /* 0x68: MBOX_ABORT_TASK_SET */ - ISPOPMAP(0x01, 0x07), /* 0x69: MBOX_GET_FW_STATE */ - ISPOPMAP(0x03, 0xcf), /* 0x6a: MBOX_GET_PORT_NAME */ - ISPOPMAP(0xcf, 0x01), /* 0x6b: MBOX_GET_LINK_STATUS */ - ISPOPMAP(0x0f, 0x01), /* 0x6c: MBOX_INIT_LIP_RESET */ - ISPOPMAP(0x00, 0x00), /* 0x6d: */ - ISPOPMAP(0xcf, 0x03), /* 0x6e: MBOX_SEND_SNS */ - ISPOPMAP(0x0f, 0x07), /* 0x6f: MBOX_FABRIC_LOGIN */ - ISPOPMAP(0x03, 0x01), /* 0x70: MBOX_SEND_CHANGE_REQUEST */ - ISPOPMAP(0x03, 0x03), /* 0x71: MBOX_FABRIC_LOGOUT */ - ISPOPMAP(0x0f, 0x0f), /* 0x72: MBOX_INIT_LIP_LOGIN */ - ISPOPMAP(0x00, 0x00), /* 0x73: */ - ISPOPMAP(0x07, 0x01), /* 0x74: LOGIN LOOP PORT */ - ISPOPMAP(0xcf, 0x03), /* 0x75: GET PORT/NODE NAME LIST */ - ISPOPMAP(0x4f, 0x01), /* 0x76: SET VENDOR ID */ - ISPOPMAP(0xcd, 0x01), /* 0x77: INITIALIZE IP MAILBOX */ - ISPOPMAP(0x00, 0x00), /* 0x78: */ - ISPOPMAP(0x00, 0x00), /* 0x79: */ - ISPOPMAP(0x00, 0x00), /* 0x7a: */ - ISPOPMAP(0x00, 0x00), /* 0x7b: */ - ISPOPMAP(0x4f, 0x03), /* 0x7c: Get ID List */ - ISPOPMAP(0xcf, 0x01), /* 0x7d: SEND LFA */ - ISPOPMAP(0x0f, 0x01) /* 0x7e: LUN RESET */ + ISP_FC_OPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */ + ISP_FC_OPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */ + ISP_FC_OPMAP(0x0f, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */ + ISP_FC_OPMAP(0xdf, 0x01), /* 0x03: MBOX_DUMP_RAM */ + ISP_FC_OPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */ + ISP_FC_OPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */ + ISP_FC_OPMAP_FULL(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff), /* 0x06: MBOX_MAILBOX_REG_TEST */ + ISP_FC_OPMAP(0x07, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */ + ISP_FC_OPMAP_FULL(0x0, 0x0, 0x0, 0x01, 0x0, 0x3, 0x80, 0x4f), /* 0x08: MBOX_ABOUT_FIRMWARE */ + ISP_FC_OPMAP(0xdf, 0x01), /* 0x09: MBOX_LOAD_RISC_RAM_2100 */ + ISP_FC_OPMAP(0xdf, 0x01), /* 0x0a: DUMP RAM */ + ISP_FC_OPMAP_HALF(0x1, 0xff, 0x0, 0x01), /* 0x0b: MBOX_LOAD_RISC_RAM */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x0c: */ + ISP_FC_OPMAP_HALF(0x1, 0x0f, 0x0, 0x01), /* 0x0d: MBOX_WRITE_RAM_WORD_EXTENDED */ + ISP_FC_OPMAP(0x01, 0x05), /* 0x0e: MBOX_CHECK_FIRMWARE */ + ISP_FC_OPMAP_HALF(0x1, 0x03, 0x0, 0x0d), /* 0x0f: MBOX_READ_RAM_WORD_EXTENDED */ + ISP_FC_OPMAP(0x1f, 0x11), /* 0x10: MBOX_INIT_REQ_QUEUE */ + ISP_FC_OPMAP(0x2f, 0x21), /* 0x11: MBOX_INIT_RES_QUEUE */ + ISP_FC_OPMAP(0x0f, 0x01), /* 0x12: MBOX_EXECUTE_IOCB */ + ISP_FC_OPMAP(0x03, 0x03), /* 0x13: MBOX_WAKE_UP */ + ISP_FC_OPMAP(0x01, 0xff), /* 0x14: MBOX_STOP_FIRMWARE */ + ISP_FC_OPMAP(0x4f, 0x01), /* 0x15: MBOX_ABORT */ + ISP_FC_OPMAP(0x07, 0x01), /* 0x16: MBOX_ABORT_DEVICE */ + ISP_FC_OPMAP(0x07, 0x01), /* 0x17: MBOX_ABORT_TARGET */ + ISP_FC_OPMAP(0x03, 0x03), /* 0x18: MBOX_BUS_RESET */ + ISP_FC_OPMAP(0x07, 0x05), /* 0x19: MBOX_STOP_QUEUE */ + ISP_FC_OPMAP(0x07, 0x05), /* 0x1a: MBOX_START_QUEUE */ + ISP_FC_OPMAP(0x07, 0x05), /* 0x1b: MBOX_SINGLE_STEP_QUEUE */ + ISP_FC_OPMAP(0x07, 0x05), /* 0x1c: MBOX_ABORT_QUEUE */ + ISP_FC_OPMAP(0x07, 0x03), /* 0x1d: MBOX_GET_DEV_QUEUE_STATUS */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x1e: */ + ISP_FC_OPMAP(0x01, 0x07), /* 0x1f: MBOX_GET_FIRMWARE_STATUS */ + ISP_FC_OPMAP_HALF(0x2, 0x01, 0x0, 0xcf), /* 0x20: MBOX_GET_LOOP_ID */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x21: */ + ISP_FC_OPMAP(0x01, 0x07), /* 0x22: MBOX_GET_RETRY_COUNT */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x23: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x24: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x25: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x26: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x27: */ + ISP_FC_OPMAP(0x01, 0x03), /* 0x28: MBOX_GET_FIRMWARE_OPTIONS */ + ISP_FC_OPMAP(0x03, 0x07), /* 0x29: MBOX_GET_PORT_QUEUE_PARAMS */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x2a: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x2b: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x2c: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x2d: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x2e: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x2f: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x30: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x31: */ + ISP_FC_OPMAP(0x07, 0x07), /* 0x32: MBOX_SET_RETRY_COUNT */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x33: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x34: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x35: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x36: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x37: */ + ISP_FC_OPMAP(0x0f, 0x01), /* 0x38: MBOX_SET_FIRMWARE_OPTIONS */ + ISP_FC_OPMAP(0x0f, 0x07), /* 0x39: MBOX_SET_PORT_QUEUE_PARAMS */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x3a: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x3b: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x3c: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x3d: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x3e: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x3f: */ + ISP_FC_OPMAP(0x03, 0x01), /* 0x40: MBOX_LOOP_PORT_BYPASS */ + ISP_FC_OPMAP(0x03, 0x01), /* 0x41: MBOX_LOOP_PORT_ENABLE */ + ISP_FC_OPMAP_HALF(0x3, 0xcf, 0x0, 0x07), /* 0x42: MBOX_GET_RESOURCE_COUNT */ + ISP_FC_OPMAP(0x01, 0x01), /* 0x43: MBOX_REQUEST_OFFLINE_MODE */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x44: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x45: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x46: */ + ISP_FC_OPMAP(0xcf, 0x03), /* 0x47: GET PORT_DATABASE ENHANCED */ + ISP_FC_OPMAP(0xcd, 0x01), /* 0x48: MBOX_INIT_FIRMWARE_MULTI_ID */ + ISP_FC_OPMAP(0xcd, 0x01), /* 0x49: MBOX_GET_VP_DATABASE */ + ISP_FC_OPMAP_HALF(0x2, 0xcd, 0x0, 0x01), /* 0x4a: MBOX_GET_VP_DATABASE_ENTRY */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x4b: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x4c: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x4d: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x4e: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x4f: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x50: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x51: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x52: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x53: */ + ISP_FC_OPMAP(0xcf, 0x01), /* 0x54: EXECUTE IOCB A64 */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x55: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x56: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x57: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x58: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x59: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x5a: */ + ISP_FC_OPMAP(0x03, 0x01), /* 0x5b: MBOX_DRIVER_HEARTBEAT */ + ISP_FC_OPMAP(0xcf, 0x01), /* 0x5c: MBOX_FW_HEARTBEAT */ + ISP_FC_OPMAP(0x07, 0x03), /* 0x5d: MBOX_GET_SET_DATA_RATE */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x5e: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x5f: */ + ISP_FC_OPMAP(0xcd, 0x01), /* 0x60: MBOX_INIT_FIRMWARE */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x61: */ + ISP_FC_OPMAP(0x01, 0x01), /* 0x62: MBOX_INIT_LIP */ + ISP_FC_OPMAP(0xcd, 0x03), /* 0x63: MBOX_GET_FC_AL_POSITION_MAP */ + ISP_FC_OPMAP(0xcf, 0x01), /* 0x64: MBOX_GET_PORT_DB */ + ISP_FC_OPMAP(0x07, 0x01), /* 0x65: MBOX_CLEAR_ACA */ + ISP_FC_OPMAP(0x07, 0x01), /* 0x66: MBOX_TARGET_RESET */ + ISP_FC_OPMAP(0x07, 0x01), /* 0x67: MBOX_CLEAR_TASK_SET */ + ISP_FC_OPMAP(0x07, 0x01), /* 0x68: MBOX_ABORT_TASK_SET */ + ISP_FC_OPMAP(0x01, 0x07), /* 0x69: MBOX_GET_FW_STATE */ + ISP_FC_OPMAP(0x03, 0xcf), /* 0x6a: MBOX_GET_PORT_NAME */ + ISP_FC_OPMAP(0xcf, 0x01), /* 0x6b: MBOX_GET_LINK_STATUS */ + ISP_FC_OPMAP(0x0f, 0x01), /* 0x6c: MBOX_INIT_LIP_RESET */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x6d: */ + ISP_FC_OPMAP(0xcf, 0x03), /* 0x6e: MBOX_SEND_SNS */ + ISP_FC_OPMAP(0x0f, 0x07), /* 0x6f: MBOX_FABRIC_LOGIN */ + ISP_FC_OPMAP(0x03, 0x01), /* 0x70: MBOX_SEND_CHANGE_REQUEST */ + ISP_FC_OPMAP(0x03, 0x03), /* 0x71: MBOX_FABRIC_LOGOUT */ + ISP_FC_OPMAP(0x0f, 0x0f), /* 0x72: MBOX_INIT_LIP_LOGIN */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x73: */ + ISP_FC_OPMAP(0x07, 0x01), /* 0x74: LOGIN LOOP PORT */ + ISP_FC_OPMAP(0xcf, 0x03), /* 0x75: GET PORT/NODE NAME LIST */ + ISP_FC_OPMAP(0x4f, 0x01), /* 0x76: SET VENDOR ID */ + ISP_FC_OPMAP(0xcd, 0x01), /* 0x77: INITIALIZE IP MAILBOX */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x78: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x79: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x7a: */ + ISP_FC_OPMAP(0x00, 0x00), /* 0x7b: */ + ISP_FC_OPMAP(0x4f, 0x03), /* 0x7c: Get ID List */ + ISP_FC_OPMAP(0xcf, 0x01), /* 0x7d: SEND LFA */ + ISP_FC_OPMAP(0x0f, 0x01) /* 0x7e: LUN RESET */ }; +#define MAX_FC_OPCODE 0x7e /* * Footnotes * @@ -7136,19 +7219,18 @@ static void isp_mboxcmd_qnw(ispsoftc_t *isp, mbreg_t *mbp, int nodelay) { unsigned int ibits, obits, box, opcode; - const uint32_t *mcp; + opcode = mbp->param[0]; if (IS_FC(isp)) { - mcp = mbpfc; + ibits = ISP_FC_IBITS(opcode); + obits = ISP_FC_OBITS(opcode); } else { - mcp = mbpscsi; + ibits = ISP_SCSI_IBITS(opcode); + obits = ISP_SCSI_OBITS(opcode); } - opcode = mbp->param[0]; - ibits = HIWRD(mcp[opcode]) & NMBOX_BMASK(isp); - obits = LOWRD(mcp[opcode]) & NMBOX_BMASK(isp); ibits |= mbp->ibits; obits |= mbp->obits; - for (box = 0; box < MAX_MAILBOX(isp); box++) { + for (box = 0; box < ISP_NMBOX(isp); box++) { if (ibits & (1 << box)) { ISP_WRITE(isp, MBOX_OFF(box), mbp->param[box]); } @@ -7181,26 +7263,27 @@ isp_mboxcmd(ispsoftc_t *isp, mbreg_t *mb { const char *cname, *xname; char tname[16], mname[16]; - unsigned int lim, ibits, obits, box, opcode; - const uint32_t *mcp; + unsigned int ibits, obits, box, opcode; + opcode = mbp->param[0]; if (IS_FC(isp)) { - mcp = mbpfc; - lim = (sizeof (mbpfc) / sizeof (mbpfc[0])); + if (opcode > MAX_FC_OPCODE) { + mbp->param[0] = MBOX_INVALID_COMMAND; + isp_prt(isp, ISP_LOGERR, "Unknown Command 0x%x", opcode); + return; + } + ibits = ISP_FC_IBITS(opcode); + obits = ISP_FC_OBITS(opcode); } else { - mcp = mbpscsi; - lim = (sizeof (mbpscsi) / sizeof (mbpscsi[0])); - } - - if ((opcode = mbp->param[0]) >= lim) { - mbp->param[0] = MBOX_INVALID_COMMAND; - isp_prt(isp, ISP_LOGERR, "Unknown Command 0x%x", opcode); - return; + if (opcode > MAX_SCSI_OPCODE) { + mbp->param[0] = MBOX_INVALID_COMMAND; + isp_prt(isp, ISP_LOGERR, "Unknown Command 0x%x", opcode); + return; + } + ibits = ISP_SCSI_IBITS(opcode); + obits = ISP_SCSI_OBITS(opcode); } - ibits = HIWRD(mcp[opcode]) & NMBOX_BMASK(isp); - obits = LOWRD(mcp[opcode]) & NMBOX_BMASK(isp); - /* * Pick up any additional bits that the caller might have set. */ @@ -7221,7 +7304,7 @@ isp_mboxcmd(ispsoftc_t *isp, mbreg_t *mb goto out; } - for (box = 0; box < MAX_MAILBOX(isp); box++) { + for (box = 0; box < ISP_NMBOX(isp); box++) { if (ibits & (1 << box)) { isp_prt(isp, ISP_LOGDEBUG3, "IN mbox %d = 0x%04x", box, mbp->param[box]); @@ -7264,7 +7347,7 @@ isp_mboxcmd(ispsoftc_t *isp, mbreg_t *mb /* * Copy back output registers. */ - for (box = 0; box < MAX_MAILBOX(isp); box++) { + for (box = 0; box < ISP_NMBOX(isp); box++) { if (obits & (1 << box)) { mbp->param[box] = isp->isp_mboxtmp[box]; isp_prt(isp, ISP_LOGDEBUG3, "OUT mbox %d = 0x%04x", box, @@ -7964,8 +8047,7 @@ isp_parse_nvram_1020(ispsoftc_t *isp, ui (ISP_NVRAM_FIFO_THRESHOLD_128(nvram_data) << 2); if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) - sdp->isp_initiator_id = - ISP_NVRAM_INITIATOR_ID(nvram_data); + sdp->isp_initiator_id = ISP_NVRAM_INITIATOR_ID(nvram_data); sdp->isp_bus_reset_delay = ISP_NVRAM_BUS_RESET_DELAY(nvram_data); @@ -8076,8 +8158,7 @@ isp_parse_nvram_1080(ispsoftc_t *isp, in ISP1080_NVRAM_FIFO_THRESHOLD(nvram_data); if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) - sdp->isp_initiator_id = - ISP1080_NVRAM_INITIATOR_ID(nvram_data, bus); + sdp->isp_initiator_id = ISP1080_NVRAM_INITIATOR_ID(nvram_data, bus); sdp->isp_bus_reset_delay = ISP1080_NVRAM_BUS_RESET_DELAY(nvram_data, bus); @@ -8152,8 +8233,7 @@ isp_parse_nvram_12160(ispsoftc_t *isp, i ISP12160_NVRAM_FIFO_THRESHOLD(nvram_data); if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) - sdp->isp_initiator_id = - ISP12160_NVRAM_INITIATOR_ID(nvram_data, bus); + sdp->isp_initiator_id = ISP12160_NVRAM_INITIATOR_ID(nvram_data, bus); sdp->isp_bus_reset_delay = ISP12160_NVRAM_BUS_RESET_DELAY(nvram_data, bus); Modified: head/sys/dev/isp/isp_freebsd.h ============================================================================== --- head/sys/dev/isp/isp_freebsd.h Sun Jun 17 21:30:24 2012 (r237209) +++ head/sys/dev/isp/isp_freebsd.h Sun Jun 17 21:39:40 2012 (r237210) @@ -153,6 +153,7 @@ struct isp_pcmd { bus_dmamap_t dmap; /* dma map for this command */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 21:40:13 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B1969106566C; Sun, 17 Jun 2012 21:40:13 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9D9E08FC12; Sun, 17 Jun 2012 21:40:13 +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 q5HLeDIm034378; Sun, 17 Jun 2012 21:40:13 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5HLeDHo034376; Sun, 17 Jun 2012 21:40:13 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201206172140.q5HLeDHo034376@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 17 Jun 2012 21:40:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237211 - head/lib/libc/stdtime X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 21:40:13 -0000 Author: jilles Date: Sun Jun 17 21:40:13 2012 New Revision: 237211 URL: http://svn.freebsd.org/changeset/base/237211 Log: libc: Reduce relative relocations in strftime(). Modified: head/lib/libc/stdtime/strftime.c Modified: head/lib/libc/stdtime/strftime.c ============================================================================== --- head/lib/libc/stdtime/strftime.c Sun Jun 17 21:39:40 2012 (r237210) +++ head/lib/libc/stdtime/strftime.c Sun Jun 17 21:40:13 2012 (r237211) @@ -67,7 +67,7 @@ extern char * tzname[]; #define PAD_SPACE 2 #define PAD_ZERO 3 -static const char* fmt_padding[][4] = { +static const char fmt_padding[][4][5] = { /* DEFAULT, LESS, SPACE, ZERO */ #define PAD_FMT_MONTHDAY 0 #define PAD_FMT_HMS 0 From owner-svn-src-head@FreeBSD.ORG Sun Jun 17 21:47:25 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 82769106566C; Sun, 17 Jun 2012 21:47:25 +0000 (UTC) (envelope-from mjacob@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 68E0F8FC0C; Sun, 17 Jun 2012 21:47:25 +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 q5HLlPV2034720; Sun, 17 Jun 2012 21:47:25 GMT (envelope-from mjacob@svn.freebsd.org) Received: (from mjacob@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5HLlOQL034717; Sun, 17 Jun 2012 21:47:25 GMT (envelope-from mjacob@svn.freebsd.org) Message-Id: <201206172147.q5HLlOQL034717@svn.freebsd.org> From: Matt Jacob Date: Sun, 17 Jun 2012 21:47:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237212 - head/sys/dev/ispfw X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2012 21:47:25 -0000 Author: mjacob Date: Sun Jun 17 21:47:24 2012 New Revision: 237212 URL: http://svn.freebsd.org/changeset/base/237212 Log: Roll to the latest 2400/2500 firmware available from the public QLogic website. Sponsored by: Spectralogic MFC after: 1 week Modified: head/sys/dev/ispfw/asm_2400.h head/sys/dev/ispfw/asm_2500.h Modified: head/sys/dev/ispfw/asm_2400.h ============================================================================== --- head/sys/dev/ispfw/asm_2400.h Sun Jun 17 21:40:13 2012 (r237211) +++ head/sys/dev/ispfw/asm_2400.h Sun Jun 17 21:47:24 2012 (r237212) @@ -24,29 +24,24 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/************************************************************************ - * * - * ISP2400 Firmware * - * * - ************************************************************************/ -#ifdef ISP_2400 /* - * Firmware Version 5.04.00 (12:18 Jul 02, 2010) + * Firmware Version 5.05.00 (15:31 Dec 14, 2010) */ +#ifdef ISP_2400 static const uint32_t isp_2400_risc_code[] = { - 0x0401f195, 0x00110000, 0x00100000, 0x0000aebb, - 0x00000005, 0x00000004, 0x00000000, 0x00000482, + 0x0401f195, 0x00110000, 0x00100000, 0x0000afb1, + 0x00000005, 0x00000005, 0x00000000, 0x00008482, 0x00000003, 0x00000000, 0x20434f50, 0x59524947, 0x48542032, 0x30303720, 0x514c4f47, 0x49432043, 0x4f52504f, 0x52415449, 0x4f4e2020, 0x20495350, 0x32347878, 0x20466972, 0x6d776172, 0x65202020, - 0x56657273, 0x696f6e20, 0x2020352e, 0x30342e30, + 0x56657273, 0x696f6e20, 0x2020352e, 0x30352e30, 0x30202024, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x42001800, 0x0010014c, 0x42002000, 0x0010bcc7, + 0x42001800, 0x0010014c, 0x42002000, 0x0010bdc7, 0x500c0800, 0x800c1800, 0x500c1000, 0x800c1800, 0x54042000, 0x80102000, 0x80040800, 0x80081040, 0x040207fc, 0x500c0800, 0x800409c0, 0x040207f6, @@ -129,11 +124,11 @@ static const uint32_t isp_2400_risc_code 0x00006150, 0x00000010, 0x00006170, 0x00000010, 0x00006190, 0x00000010, 0x000061b0, 0x00000010, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00100000, 0x00100000, 0x0000aebb, + 0x00000000, 0x00100000, 0x00100000, 0x0000afb1, 0xffffffff, 0x00110004, 0x00020000, 0x00000b53, - 0xffffffff, 0x00110b57, 0x0010d600, 0x00001ab8, - 0xffffffff, 0x0011260f, 0x0000c000, 0x000007e8, - 0x00ffffff, 0x00112df7, 0x00008000, 0x000005de, + 0xffffffff, 0x00110b57, 0x0010d700, 0x00001ac0, + 0xffffffff, 0x00112617, 0x0000c000, 0x000007e8, + 0x00ffffff, 0x00112dff, 0x00008000, 0x000005e5, 0x00ffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4203f000, 0x00021fff, 0x40000000, 0x4203e000, 0x90000100, 0x40000000, 0x42000800, @@ -141,11 +136,11 @@ static const uint32_t isp_2400_risc_code 0x00007023, 0x50000000, 0x8c000500, 0x04020003, 0x42000800, 0x00020000, 0x45780800, 0x80040800, 0x82040580, 0x00022000, 0x040207fc, 0x4178a000, - 0x4200a800, 0x0010aebb, 0x42000800, 0x0010d600, - 0x40540000, 0x8004b480, 0x0201f800, 0x0010adf8, + 0x4200a800, 0x0010afb1, 0x42000800, 0x0010d700, + 0x40540000, 0x8004b480, 0x0201f800, 0x0010aeeb, 0x0401fac9, 0x0401fa00, 0x4803c856, 0x42000000, 0x00001000, 0x50000000, 0x82000480, 0x24320002, - 0x0402000d, 0x0201f800, 0x0010ae33, 0x04000008, + 0x0402000d, 0x0201f800, 0x0010af26, 0x04000008, 0x42000800, 0x00007a17, 0x50040000, 0x8c00050e, 0x04020003, 0x8400054e, 0x44000800, 0x4a030000, 0x00000000, 0x4a03c020, 0x00000004, 0x4203e000, @@ -159,7 +154,7 @@ static const uint32_t isp_2400_risc_code 0x4817c857, 0x4853c857, 0x8050a1c0, 0x0400000f, 0x4c140000, 0x5814a801, 0x4857c857, 0x40500000, 0x80540480, 0x04000005, 0x5814b002, 0x485bc857, - 0x0201f800, 0x0010adef, 0x5c002800, 0x82142c00, + 0x0201f800, 0x0010aee2, 0x5c002800, 0x82142c00, 0x00000004, 0x0401f7ee, 0x42002800, 0x0010017d, 0x58140801, 0x4817c857, 0x4807c857, 0x800409c0, 0x04000018, 0x58142002, 0x4813c857, 0x58141003, @@ -168,9 +163,9 @@ static const uint32_t isp_2400_risc_code 0x4a03c020, 0x00004010, 0x4a03c011, 0x40100011, 0x04006000, 0x4203e000, 0x40000000, 0x4a03c017, 0x00000000, 0x4203e000, 0x30000001, 0x0401f000, - 0x4803c856, 0x0201f800, 0x0010d604, 0x0401faf6, - 0x4a03c014, 0x001c001c, 0x42002000, 0x0010f0b8, - 0x0201f800, 0x0010ae00, 0x42000000, 0x00001000, + 0x4803c856, 0x0201f800, 0x0010d704, 0x0401faf6, + 0x4a03c014, 0x001c001c, 0x42002000, 0x0010f1c0, + 0x0201f800, 0x0010aef3, 0x42000000, 0x00001000, 0x50000000, 0x82000480, 0x24220001, 0x04000906, 0x42000000, 0x00001000, 0x50000000, 0x82000480, 0x24320001, 0x04000900, 0x59c40000, 0x82000500, @@ -179,28 +174,28 @@ static const uint32_t isp_2400_risc_code 0x0401f00a, 0x59e00003, 0x82000500, 0x00030000, 0x82000580, 0x00010000, 0x04020004, 0x59a8006d, 0x84000542, 0x4803506d, 0x4c140000, 0x0201f800, - 0x0010a5ad, 0x5c002800, 0x42000800, 0x00001100, + 0x0010a6a0, 0x5c002800, 0x42000800, 0x00001100, 0x42001800, 0x00000100, 0x82141480, 0x0017ffff, 0x0402100d, 0x42000800, 0x00000900, 0x82141480, 0x0013ffff, 0x04021008, 0x42000800, 0x00000480, 0x42001800, 0x00000080, 0x82141480, 0x0011ffff, 0x040018d5, 0x4807500d, 0x480f5251, 0x42001000, - 0x00000024, 0x0201f800, 0x00105f4a, 0x82040c00, - 0x0010f584, 0x4807500b, 0x4a03c810, 0x00100000, - 0x4a03c811, 0x0010aebb, 0x4a03c812, 0x0010d600, - 0x4a03c813, 0x0010f0b7, 0x4a03c829, 0x00000004, + 0x00000024, 0x0201f800, 0x00105fef, 0x82040c00, + 0x0010f694, 0x4807500b, 0x4a03c810, 0x00100000, + 0x4a03c811, 0x0010afb1, 0x4a03c812, 0x0010d700, + 0x4a03c813, 0x0010f1bf, 0x4a03c829, 0x00000004, 0x59e40001, 0x82000540, 0x0003403f, 0x4803c801, 0x42001000, 0x0000001c, 0x0401f9f0, 0x4202c000, - 0x0010f584, 0x59aab00b, 0x59aaa00b, 0x59aaa80b, + 0x0010f694, 0x59aab00b, 0x59aaa00b, 0x59aaa80b, 0x59aac80d, 0x49675050, 0x59a8000b, 0x4803500c, - 0x0201f800, 0x001070a4, 0x0401fac4, 0x0401fb14, - 0x0201f800, 0x001017f8, 0x0201f800, 0x001010e9, - 0x0401fbdb, 0x0201f800, 0x00100ca4, 0x0201f800, - 0x00105f8a, 0x0401f85c, 0x0201f800, 0x00101c0a, - 0x0201f800, 0x00104b8f, 0x0201f800, 0x001044a6, - 0x0201f800, 0x00105a28, 0x0201f800, 0x00105729, - 0x0201f800, 0x0010118e, 0x0201f800, 0x00100ff1, - 0x4203e000, 0xf0000001, 0x0201f800, 0x0010ae4f, + 0x0201f800, 0x00107133, 0x0401fac4, 0x0401fb14, + 0x0201f800, 0x001017f9, 0x0201f800, 0x001010ea, + 0x0401fbdb, 0x0201f800, 0x00100ca5, 0x0201f800, + 0x0010602f, 0x0401f85c, 0x0201f800, 0x00101c0f, + 0x0201f800, 0x00104bce, 0x0201f800, 0x001044e5, + 0x0201f800, 0x00105acd, 0x0201f800, 0x001057ce, + 0x0201f800, 0x0010118f, 0x0201f800, 0x00100ff2, + 0x4203e000, 0xf0000001, 0x0201f800, 0x0010af45, 0x4a03c018, 0x00000000, 0x4203e000, 0x20000511, 0x4203e000, 0x50010000, 0x4a03c020, 0x00000000, 0x04027010, 0x59e00020, 0x82000580, 0x00000002, @@ -212,25 +207,25 @@ static const uint32_t isp_2400_risc_code 0x4df00000, 0x4203e000, 0x50000000, 0x416c0000, 0x82000c80, 0x00000008, 0x0402186b, 0x0c01f804, 0x5c03e000, 0x0201f000, 0x00020008, 0x001002d0, - 0x0010eeff, 0x0010ee47, 0x001002cf, 0x0010ee13, + 0x0010f007, 0x0010ef4c, 0x001002cf, 0x0010ef18, 0x001002cf, 0x001002cf, 0x001002e2, 0x0401f85e, - 0x42000800, 0x0010b7fa, 0x5804001e, 0x8c000500, + 0x42000800, 0x0010b8fa, 0x5804001e, 0x8c000500, 0x0400000d, 0x84000500, 0x4800081e, 0x4202d800, 0x00000004, 0x0401f97b, 0x49f3c857, 0x5c000800, 0x5c000000, 0x82000540, 0x00003e00, 0x4c000000, 0x4c040000, 0x1c01f000, 0x4a038805, 0x000000f0, 0x1c01f000, 0x4a035048, 0x00000005, 0x4a035049, - 0x00000004, 0x4a03504a, 0x00000000, 0x4a03504b, - 0x00000482, 0x0201f800, 0x00104b59, 0x4a03541b, + 0x00000005, 0x4a03504a, 0x00000000, 0x4a03504b, + 0x00008482, 0x0201f800, 0x00104b98, 0x4a03541b, 0x0000ffff, 0x4a03500f, 0x00ffffff, 0x0201f800, - 0x00108bc4, 0x4a03501f, 0x20200000, 0x4a035020, + 0x00108c7d, 0x4a03501f, 0x20200000, 0x4a035020, 0x88000200, 0x4a035021, 0x00ff001f, 0x4a035022, 0x000007d0, 0x4a035023, 0x80000000, 0x4a035024, 0x00000200, 0x4a035025, 0x00ff0000, 0x4a035026, 0x00010000, 0x4a03502d, 0x514c4f47, 0x4a03502e, 0x49432020, 0x1c01f000, 0x4d440000, 0x417a8800, 0x4c5c0000, 0x4178b800, 0x0201f800, 0x00020319, - 0x04020005, 0x0201f800, 0x00104165, 0x04020002, + 0x04020005, 0x0201f800, 0x00104181, 0x04020002, 0x805cb800, 0x81468800, 0x83440580, 0x000007f0, 0x040207f6, 0x405c0800, 0x5c00b800, 0x5c028800, 0x1c01f000, 0x4803c857, 0x5c000000, 0x4c000000, @@ -241,7 +236,7 @@ static const uint32_t isp_2400_risc_code 0x4200b800, 0x00008002, 0x04006000, 0x4c000000, 0x4c040000, 0x59bc00ea, 0x4803c857, 0x82000500, 0x00000007, 0x82000580, 0x00000001, 0x04020005, - 0x42000800, 0x00000000, 0x0201f800, 0x00106126, + 0x42000800, 0x00000000, 0x0201f800, 0x001061cb, 0x59b800ea, 0x4803c857, 0x4a0370e8, 0x00000004, 0x5c000800, 0x4807c025, 0x80040920, 0x4807c026, 0x5c000000, 0x4803c023, 0x80000120, 0x4803c024, @@ -249,8 +244,8 @@ static const uint32_t isp_2400_risc_code 0x4803c022, 0x41f80000, 0x4803c029, 0x80000120, 0x4803c02a, 0x42000000, 0x00001000, 0x50000000, 0x82000480, 0x24320001, 0x4803c857, 0x0400104b, - 0x0201f800, 0x0010ae33, 0x04000046, 0x42000800, - 0x0010c526, 0x46000800, 0xfaceface, 0x80040800, + 0x0201f800, 0x0010af26, 0x04000046, 0x42000800, + 0x0010c626, 0x46000800, 0xfaceface, 0x80040800, 0x4c080000, 0x4c0c0000, 0x42001000, 0x00007a00, 0x58080013, 0x44000800, 0x80040800, 0x58080019, 0x44000800, 0x80040800, 0x5808001a, 0x44000800, @@ -273,29 +268,29 @@ static const uint32_t isp_2400_risc_code 0x00000000, 0x4203e000, 0x30000001, 0x0401f847, 0x0401f7ff, 0x42000000, 0x00000004, 0x0401f80c, 0x4a03c855, 0x0001eb5a, 0x59e40001, 0x82000540, - 0x00000700, 0x4803c801, 0x42000000, 0x0010bcb1, + 0x00000700, 0x4803c801, 0x42000000, 0x0010bdb1, 0x49780003, 0x49780004, 0x1c01f000, 0x42000800, - 0x0010bcb3, 0x44000800, 0x59e40801, 0x82041500, + 0x0010bdb3, 0x44000800, 0x59e40801, 0x82041500, 0xfff3c0ff, 0x480bc801, 0x8c040d24, 0x0400000c, 0x4c000000, 0x59e41052, 0x59e40054, 0x800000d4, - 0x82000400, 0x0010c542, 0x80081480, 0x480bc853, + 0x82000400, 0x0010c642, 0x80081480, 0x480bc853, 0x4a03c800, 0x00000040, 0x5c000000, 0x4a03c850, - 0x0010c542, 0x800000d4, 0x82002400, 0x0010c541, + 0x0010c642, 0x800000d4, 0x82002400, 0x0010c641, 0x4813c851, 0x4a03c853, 0x00000400, 0x42000000, - 0x0010c542, 0x82001400, 0x00001000, 0x45780000, + 0x0010c642, 0x82001400, 0x00001000, 0x45780000, 0x80000000, 0x80081d80, 0x040207fd, 0x4807c801, - 0x1c01f000, 0x42002000, 0x0010bcb1, 0x59e41801, + 0x1c01f000, 0x42002000, 0x0010bdb1, 0x59e41801, 0x58100c01, 0x82040500, 0x00003800, 0x820c1d00, 0xffffc7ff, 0x800c1d40, 0x480fc801, 0x1c01f000, 0x5c036000, 0x4db00000, 0x49b3c857, 0x4803c857, 0x1c01f000, 0x1c01f000, 0x59a80059, 0x8c000530, 0x040207fe, 0x4c080000, 0x42001000, 0x00000004, 0x0401f862, 0x5c001000, 0x4201d000, 0x00028b0a, - 0x0201f800, 0x0010592d, 0x4c080000, 0x42001000, + 0x0201f800, 0x001059d2, 0x4c080000, 0x42001000, 0x00000008, 0x0401f859, 0x5c001000, 0x4201d000, - 0x00028b0a, 0x0201f800, 0x0010592d, 0x4c080000, + 0x00028b0a, 0x0201f800, 0x001059d2, 0x4c080000, 0x42001000, 0x00000010, 0x0401f850, 0x5c001000, - 0x4201d000, 0x00028b0a, 0x0201f800, 0x0010592d, + 0x4201d000, 0x00028b0a, 0x0201f800, 0x001059d2, 0x0401f7e2, 0x8c00050c, 0x59a80859, 0x04020003, 0x84040d30, 0x0401f006, 0x84040d70, 0x48075059, 0x42001000, 0x00000000, 0x0401f040, 0x48075059, @@ -334,8 +329,8 @@ static const uint32_t isp_2400_risc_code 0x41792800, 0x41793000, 0x41793800, 0x41794000, 0x41794800, 0x41795000, 0x41795800, 0x41796000, 0x41796800, 0x41797000, 0x41797800, 0x41798000, - 0x41798800, 0x42019000, 0x0010b889, 0x42019800, - 0x0010b860, 0x4179a000, 0x4179a800, 0x4179b000, + 0x41798800, 0x42019000, 0x0010b989, 0x42019800, + 0x0010b960, 0x4179a000, 0x4179a800, 0x4179b000, 0x4179b800, 0x4179c800, 0x4179c000, 0x4179d000, 0x4179d800, 0x4179e000, 0x4179e800, 0x4179f000, 0x4179f800, 0x417a0000, 0x417a0800, 0x417a1000, @@ -344,17 +339,17 @@ static const uint32_t isp_2400_risc_code 0x417a5000, 0x417a5800, 0x417a6000, 0x417a6800, 0x417a7000, 0x417a7800, 0x417a8000, 0x417a8800, 0x417a9000, 0x417a9800, 0x417ae800, 0x417af800, - 0x42030000, 0x00007c00, 0x42031000, 0x0010bb5a, + 0x42030000, 0x00007c00, 0x42031000, 0x0010bc5a, 0x42031800, 0x0000bf1d, 0x42032000, 0x0000bf32, - 0x42032800, 0x0010bb22, 0x42033000, 0x00020b5d, - 0x42034000, 0x0010b7fa, 0x42033800, 0x0010b819, - 0x42034800, 0x0010b898, 0x42035000, 0x0010b780, - 0x42035800, 0x0010af80, 0x42030800, 0x0010b85b, + 0x42032800, 0x0010bc22, 0x42033000, 0x00020b5d, + 0x42034000, 0x0010b8fa, 0x42033800, 0x0010b919, + 0x42034800, 0x0010b998, 0x42035000, 0x0010b880, + 0x42035800, 0x0010b080, 0x42030800, 0x0010b95b, 0x417b6000, 0x42036800, 0x00006f00, 0x4203c800, 0x00003000, 0x42037000, 0x0000ff00, 0x42037800, 0x0000bf00, 0x42038000, 0x00007700, 0x42038800, 0x00004000, 0x42039000, 0x00006000, 0x42039800, - 0x0010c25e, 0x4203a000, 0x00007600, 0x4203a800, + 0x0010c35e, 0x4203a000, 0x00007600, 0x4203a800, 0x00007400, 0x4203b000, 0x00007200, 0x4203b800, 0x00007100, 0x4203c000, 0x00007000, 0x4203d000, 0x00000000, 0x4203e800, 0x0002018e, 0x417bd800, @@ -379,13 +374,13 @@ static const uint32_t isp_2400_risc_code 0x412d8800, 0x1c01f000, 0x835c0480, 0x00000020, 0x0400100a, 0x496bc857, 0x815eb840, 0x416a5800, 0x592ed000, 0x497a5800, 0x497a5801, 0x497a5805, - 0x812e59c0, 0x1c01f000, 0x42000000, 0x0010bc0f, - 0x0201f800, 0x0010ad1d, 0x417a5800, 0x0401f7f9, + 0x812e59c0, 0x1c01f000, 0x42000000, 0x0010bd0f, + 0x0201f800, 0x0010ae10, 0x417a5800, 0x0401f7f9, 0x0401f803, 0x412d8800, 0x1c01f000, 0x815eb840, 0x04001009, 0x416a5800, 0x492fc857, 0x592ed000, 0x497a5800, 0x497a5801, 0x497a5805, 0x812e59c0, - 0x1c01f000, 0x42000000, 0x0010bc0f, 0x0201f800, - 0x0010ad1d, 0x417ab800, 0x417a5800, 0x0401f7f8, + 0x1c01f000, 0x42000000, 0x0010bd0f, 0x0201f800, + 0x0010ae10, 0x417ab800, 0x417a5800, 0x0401f7f8, 0x492fc857, 0x496a5800, 0x412ed000, 0x815eb800, 0x59c80000, 0x82000540, 0x00001200, 0x48039000, 0x1c01f000, 0x492fc857, 0x812e59c0, 0x04000007, @@ -403,26 +398,26 @@ static const uint32_t isp_2400_risc_code 0x00000020, 0x497bb807, 0x8058b040, 0x040207fe, 0x4a03b805, 0x30000000, 0x59dc0006, 0x4a03b805, 0x60000001, 0x4803c856, 0x0401ff98, 0x04000d6a, - 0x42001000, 0x0010bb55, 0x452c1000, 0x4a025801, + 0x42001000, 0x0010bc55, 0x452c1000, 0x4a025801, 0x00000001, 0x4a025802, 0x00000100, 0x4a025808, - 0x00106784, 0x497a5809, 0x497a580a, 0x497a580b, - 0x0401ff8a, 0x04000d5c, 0x42001000, 0x0010bb56, + 0x00106826, 0x497a5809, 0x497a580a, 0x497a580b, + 0x0401ff8a, 0x04000d5c, 0x42001000, 0x0010bc56, 0x452c1000, 0x4a025801, 0x00000000, 0x4a025802, - 0x00000100, 0x4a025808, 0x00100f2e, 0x497a5803, + 0x00000100, 0x4a025808, 0x00100f2f, 0x497a5803, 0x497a5806, 0x497a5807, 0x497a5809, 0x59a8006d, 0x8c000500, 0x04000006, 0x4a03b805, 0xe0000001, 0x59dc0006, 0x8c000522, 0x040007fc, 0x1c01f000, 0x40681000, 0x0201f800, 0x00020016, 0x1c01f000, - 0x42001000, 0x00020026, 0x0201f800, 0x001057d8, - 0x0201f800, 0x00108cab, 0x0201f800, 0x0010a24b, + 0x42001000, 0x00020026, 0x0201f800, 0x0010587d, + 0x0201f800, 0x00108d64, 0x0201f800, 0x0010a32a, 0x04000014, 0x4a03b805, 0x30000002, 0x59dc0006, 0x4807b800, 0x480bb801, 0x42007000, 0x00020b54, 0x4a007002, 0x00000040, 0x480c7008, 0x58380007, 0x82000400, 0x00000005, 0x48007003, 0x4a007000, 0x00000003, 0x4803b803, 0x0201f000, 0x00020050, - 0x42000000, 0x0010bb77, 0x0201f800, 0x0010ad1d, - 0x0201f800, 0x00108cc3, 0x42000800, 0x00000001, - 0x42001000, 0x00020026, 0x0201f800, 0x001057b1, + 0x42000000, 0x0010bc77, 0x0201f800, 0x0010ae10, + 0x0201f800, 0x00108d7c, 0x42000800, 0x00000001, + 0x42001000, 0x00020026, 0x0201f800, 0x00105856, 0x42007000, 0x00020b54, 0x0201f000, 0x00020030, 0x58380802, 0x42001000, 0x0000ff00, 0x82040480, 0x0000ff00, 0x04021003, 0x40041000, 0x80000580, @@ -442,7 +437,7 @@ static const uint32_t isp_2400_risc_code 0x04000003, 0x48107005, 0x0401f008, 0x49787005, 0x49787004, 0x0401f005, 0x48101800, 0x801021c0, 0x04020002, 0x480c7004, 0x1c01f000, 0x4803c856, - 0x4dc00000, 0x42007000, 0x0010bb58, 0x4a007400, + 0x4dc00000, 0x42007000, 0x0010bc58, 0x4a007400, 0x00000000, 0x49787001, 0x42038000, 0x00007720, 0x4a038006, 0x60000001, 0x4a038009, 0xf4f60000, 0x42038000, 0x00007700, 0x4a038006, 0x60000001, @@ -458,7 +453,7 @@ static const uint32_t isp_2400_risc_code 0x4a038807, 0x00000004, 0x4a0370e5, 0x00080000, 0x59b800ea, 0x8c000510, 0x04000004, 0x59b800e0, 0x0401f879, 0x0401f7fb, 0x42038000, 0x00007720, - 0x0201f800, 0x00100c06, 0x59c00007, 0x4a038006, + 0x0201f800, 0x00100c07, 0x59c00007, 0x4a038006, 0x20000000, 0x59c00007, 0x4a038006, 0x8000000a, 0x59c00007, 0x4a038006, 0x8000000b, 0x59c00007, 0x4a038006, 0x40000001, 0x83c00580, 0x00007700, @@ -469,16 +464,16 @@ static const uint32_t isp_2400_risc_code 0x83c00580, 0x00007700, 0x04000004, 0x42038000, 0x00007700, 0x0401f7f1, 0x4178a000, 0x805cb9c0, 0x0402001d, 0x4200b000, 0x00000020, 0x83b8ac00, - 0x00000020, 0x0201f800, 0x0010adf8, 0x4a0370fb, - 0x00000001, 0x4a037020, 0x00100e39, 0x59a8002c, + 0x00000020, 0x0201f800, 0x0010aeeb, 0x4a0370fb, + 0x00000001, 0x4a037020, 0x00100e3a, 0x59a8002c, 0x82000500, 0x0000ffff, 0x48037021, 0x4a037035, - 0x0010c1a4, 0x4a037030, 0x0010b78f, 0x4a037031, - 0x0010af80, 0x4a037032, 0x0010b86b, 0x4a037036, - 0x0010b876, 0x59840002, 0x48037034, 0x4a037038, - 0x00100e30, 0x4a0370fb, 0x00000001, 0x4200b000, + 0x0010c2a4, 0x4a037030, 0x0010b88f, 0x4a037031, + 0x0010b080, 0x4a037032, 0x0010b96b, 0x4a037036, + 0x0010b976, 0x59840002, 0x48037034, 0x4a037038, + 0x00100e31, 0x4a0370fb, 0x00000001, 0x4200b000, 0x00000020, 0x83b8ac00, 0x00000000, 0x0201f800, - 0x0010adf8, 0x4200b000, 0x00000040, 0x83b8ac00, - 0x00000040, 0x0201f800, 0x0010adf8, 0x805cb9c0, + 0x0010aeeb, 0x4200b000, 0x00000040, 0x83b8ac00, + 0x00000040, 0x0201f800, 0x0010aeeb, 0x805cb9c0, 0x04020004, 0x4a0370e4, 0xaaaaaaaa, 0x0401f003, 0x4a0370e4, 0xa2aa2a82, 0x4a0370e5, 0xaaaaaaaa, 0x4a0370e6, 0xaaaaaaaa, 0x4a0370fb, 0x00000000, @@ -490,7 +485,7 @@ static const uint32_t isp_2400_risc_code 0x1c01f000, 0x4d300000, 0x4d380000, 0x40026000, 0x82000500, 0x7f000000, 0x82000580, 0x60000000, 0x04020012, 0x83326500, 0x00ffffff, 0x0201f800, - 0x001091d9, 0x0402000d, 0x59300203, 0x82000580, + 0x00109291, 0x0402000d, 0x59300203, 0x82000580, 0x00000004, 0x04020009, 0x59300c07, 0x82040580, 0x00000009, 0x04020005, 0x42027000, 0x00000047, 0x0201f800, 0x00020a34, 0x5c027000, 0x5c026000, @@ -498,16518 +493,1663 @@ static const uint32_t isp_2400_risc_code 0x4d400000, 0x4cfc0000, 0x4d380000, 0x4d3c0000, 0x4d440000, 0x4d4c0000, 0x4d480000, 0x4c5c0000, 0x4c600000, 0x4c640000, 0x4d040000, 0x4cc80000, - 0x4ccc0000, 0x4cf40000, 0x4cf80000, 0x4cfc0000, - 0x0201f800, 0x00020095, 0x5c01f800, 0x5c01f000, - 0x5c01e800, 0x5c019800, 0x5c019000, 0x5c020800, - 0x5c00c800, 0x5c00c000, 0x5c00b800, 0x5c029000, - 0x5c029800, 0x5c028800, 0x5c027800, 0x5c027000, - 0x5c01f800, 0x5c028000, 0x5c026800, 0x5c025800, - 0x5c026000, 0x1c01f000, 0x493bc857, 0x0201f000, - 0x000200bc, 0x83300500, 0x000000ff, 0x82000c80, - 0x00000007, 0x02021800, 0x0010032d, 0x0c01f025, - 0x1c01f000, 0x82000d00, 0xc0000038, 0x02020800, - 0x00100322, 0x0201f800, 0x0010032d, 0x00000000, - 0x00000048, 0x00000054, 0x00000053, 0x00100786, - 0x001007aa, 0x001007a5, 0x001007c9, 0x00100791, - 0x0010079d, 0x00100786, 0x001007c4, 0x00100810, - 0x00100786, 0x00100813, 0x00100786, 0x00100786, - 0x00100816, 0x0010081c, 0x00100839, 0x0010084e, - 0x00100786, 0x00100857, 0x00100863, 0x00100786, - 0x00100786, 0x00100786, 0x0201f800, 0x0010032d, - 0x0010078f, 0x001008fa, 0x001007d6, 0x001007ff, - 0x0010078f, 0x0010078f, 0x0010078f, 0x0201f800, - 0x0010032d, 0x4803c856, 0x59300004, 0x8c00053e, - 0x04020005, 0x42027000, 0x00000055, 0x0201f000, - 0x00020a34, 0x0201f800, 0x0010644d, 0x040007fa, - 0x1c01f000, 0x4803c856, 0x0401f8c7, 0x40002800, - 0x41782000, 0x42027000, 0x00000056, 0x0201f000, - 0x00020a34, 0x4803c856, 0x42027000, 0x00000057, - 0x0201f000, 0x00020a34, 0x4803c856, 0x59325809, - 0x812e59c0, 0x04000016, 0x59300008, 0x8c00051a, - 0x0402000d, 0x592c0409, 0x8c00051c, 0x04020003, - 0x4a026012, 0xffffffff, 0x59300004, 0x8c00053e, - 0x04020008, 0x42027000, 0x00000048, 0x0201f000, - 0x00020a34, 0x4a025a07, 0x00000007, 0x0401f7f5, - 0x0201f800, 0x0010644d, 0x040007f7, 0x1c01f000, - 0x4803c856, 0x83300500, 0x00ffffff, 0x0201f000, - 0x00105d72, 0x1c01f000, 0x4c040000, 0x59b808ea, - 0x82040d00, 0x00000007, 0x82040580, 0x00000003, - 0x04000004, 0x42000000, 0x60000000, 0x0401f8c6, - 0x5c000800, 0x1c01f000, 0x0401f914, 0x0400001b, - 0x59325809, 0x812e59c0, 0x04000018, 0x592c0205, - 0x82000500, 0x000000ff, 0x82000d80, 0x00000029, - 0x04020012, 0x59300203, 0x82000580, 0x00000003, - 0x0400000b, 0x59300808, 0x84040d26, 0x48066008, - 0x0201f800, 0x00020111, 0x4a03900d, 0x00000040, - 0x4a0370e5, 0x00000008, 0x1c01f000, 0x0201f800, - 0x0010644d, 0x040007f4, 0x42000000, 0x0010bc15, - 0x0201f800, 0x0010ad1d, 0x5988014a, 0x80000000, - 0x4803114a, 0x4a03900d, 0x00000040, 0x42000000, - 0xc0000000, 0x0201f000, 0x00020105, 0x4c5c0000, - 0x4c600000, 0x4c640000, 0x4200c800, 0x0010c1ab, - 0x4200b800, 0x00003000, 0x4200c000, 0x00000105, - 0x0201f800, 0x001055e9, 0x4a0370e4, 0x02000000, - 0x5c00c800, 0x5c00c000, 0x5c00b800, 0x1c01f000, - 0x4933c857, 0x0201f000, 0x00020a10, 0x4933c857, - 0x0401fbfa, 0x1c01f000, 0x41300800, 0x800409c0, - 0x02020800, 0x0010032d, 0x0201f800, 0x00100322, - 0x42000000, 0x0010bc15, 0x0201f800, 0x0010ad1d, - 0x4933c857, 0x813261c0, 0x02000800, 0x0010032d, - 0x0401f841, 0x40002800, 0x0201f800, 0x0010ac86, - 0x4c140000, 0x59a8006a, 0x80000540, 0x04000004, - 0x8c142d2a, 0x04000002, 0x0401fbe0, 0x5c002800, - 0x0401f8ae, 0x04000007, 0x5932680a, 0x59340200, - 0x8c00050e, 0x59300415, 0x02020800, 0x00108b7a, - 0x1c01f000, 0x42000000, 0x0010bc15, 0x0201f800, - 0x0010ad1d, 0x4933c857, 0x813261c0, 0x02000800, - 0x0010032d, 0x0401f89d, 0x0400000b, 0x0201f800, - 0x0010889a, 0x04000008, 0x59325809, 0x592c0209, - 0x8400054e, 0x48025a09, 0x417a7800, 0x0201f800, - 0x00108487, 0x1c01f000, 0x485fc857, 0x5c000000, - 0x4d780000, 0x4203e000, 0x50000000, 0x4200b800, - 0x00008005, 0x0201f000, 0x00100332, 0x4933c857, - 0x83300480, 0x00000020, 0x02021800, 0x0010032d, - 0x83300c00, 0x0010bc88, 0x50040000, 0x80000000, - 0x04001002, 0x44000800, 0x1c01f000, 0x4933c857, - 0x0401f7f4, 0x4807c856, 0x59b800ea, 0x8c000510, - 0x040007fd, 0x59b800e0, 0x4803c857, 0x1c01f000, - 0x4803c856, 0x42000000, 0x10000000, 0x41300800, - 0x0401f029, 0x8c000510, 0x02000000, 0x0002010b, - 0x4c040000, 0x0401f80b, 0x5c000800, 0x82100480, - 0x00000008, 0x02001000, 0x0002010b, 0x4c040000, - 0x0401feb5, 0x5c000800, 0x0201f000, 0x0002010b, - 0x59b800e2, 0x59b820e2, 0x80100580, 0x040207fd, - 0x80102114, 0x0401f001, 0x40101800, 0x800c190a, - 0x82100500, 0x0000001f, 0x820c1d00, 0x0000001f, - 0x800c2480, 0x82102500, 0x0000001f, 0x1c01f000, - 0x40680000, 0x406c0800, 0x0401f807, 0x42018800, - 0x00000001, 0x04020003, 0x42018800, 0x00000000, - 0x1c01f000, 0x82000500, 0xf0000000, 0x82040d00, - 0x0fffffff, 0x80040d40, 0x4807c857, 0x42001000, - 0x0010bb59, 0x50080000, 0x80000540, 0x04020005, - 0x4a0370e5, 0x00000003, 0x4a0370e4, 0x00000300, - 0x80000000, 0x44001000, 0x42001000, 0x00000400, - 0x59b800ea, 0x8c000510, 0x0400000c, 0x0401ffd1, - 0x82100480, 0x00000008, 0x04001007, 0x4c040000, - 0x4c080000, 0x0401fe7c, 0x5c001000, 0x5c000800, - 0x0401f020, 0x59b800ea, 0x8c000516, 0x0402001d, - 0x4a0370e4, 0x00300000, 0x480770e1, 0x42001000, - 0x0000ff00, 0x80081040, 0x04000012, 0x59b808e4, - 0x8c040d28, 0x040207fc, 0x42001000, 0x0010bb59, - 0x50080000, 0x80000040, 0x04020005, 0x4a0370e5, - 0x00000002, 0x4a0370e4, 0x00000200, 0x02001800, - 0x0010032d, 0x44001000, 0x8c040d2c, 0x1c01f000, + 0x4ccc0000, 0x4cf40000, 0x4cf80000, 0x0201f800, + 0x00020095, 0x5c01f000, 0x5c01e800, 0x5c019800, + 0x5c019000, 0x5c020800, 0x5c00c800, 0x5c00c000, + 0x5c00b800, 0x5c029000, 0x5c029800, 0x5c028800, + 0x5c027800, 0x5c027000, 0x5c01f800, 0x5c028000, + 0x5c026800, 0x5c025800, 0x5c026000, 0x1c01f000, + 0x493bc857, 0x0201f000, 0x000200bc, 0x83300500, + 0x000000ff, 0x82000c80, 0x00000007, 0x02021800, + 0x0010032d, 0x0c01f025, 0x1c01f000, 0x82000d00, + 0xc0000038, 0x02020800, 0x00100322, 0x0201f800, + 0x0010032d, 0x00000000, 0x00000048, 0x00000054, + 0x00000053, 0x00100784, 0x001007a8, 0x001007a3, + 0x001007c7, 0x0010078f, 0x0010079b, 0x00100784, + 0x001007c2, 0x0010080e, 0x00100784, 0x00100811, + 0x00100784, 0x00100784, 0x00100814, 0x0010081a, + 0x00100837, 0x0010084c, 0x00100784, 0x00100855, + 0x00100861, 0x00100784, 0x00100784, 0x00100784, + 0x0201f800, 0x0010032d, 0x0010078d, 0x001008f8, + 0x001007d4, 0x001007fd, 0x0010078d, 0x0010078d, + 0x0010078d, 0x0201f800, 0x0010032d, 0x4803c856, + 0x59300004, 0x8c00053e, 0x04020005, 0x42027000, + 0x00000055, 0x0201f000, 0x00020a34, 0x0201f800, + 0x001064f2, 0x040007fa, 0x1c01f000, 0x4803c856, + 0x0401f8c7, 0x40002800, 0x41782000, 0x42027000, + 0x00000056, 0x0201f000, 0x00020a34, 0x4803c856, + 0x42027000, 0x00000057, 0x0201f000, 0x00020a34, + 0x4803c856, 0x59325809, 0x812e59c0, 0x04000016, + 0x59300008, 0x8c00051a, 0x0402000d, 0x592c0409, + 0x8c00051c, 0x04020003, 0x4a026012, 0xffffffff, + 0x59300004, 0x8c00053e, 0x04020008, 0x42027000, + 0x00000048, 0x0201f000, 0x00020a34, 0x4a025a07, + 0x00000007, 0x0401f7f5, 0x0201f800, 0x001064f2, + 0x040007f7, 0x1c01f000, 0x4803c856, 0x83300500, + 0x00ffffff, 0x0201f000, 0x00105e17, 0x1c01f000, + 0x4c040000, 0x59b808ea, 0x82040d00, 0x00000007, + 0x82040580, 0x00000003, 0x04000004, 0x42000000, + 0x60000000, 0x0401f8c6, 0x5c000800, 0x1c01f000, + 0x0401f914, 0x0400001b, 0x59325809, 0x812e59c0, + 0x04000018, 0x592c0205, 0x82000500, 0x000000ff, + 0x82000d80, 0x00000029, 0x04020012, 0x59300203, + 0x82000580, 0x00000003, 0x0400000b, 0x59300808, + 0x84040d26, 0x48066008, 0x0201f800, 0x00020111, + 0x4a03900d, 0x00000040, 0x4a0370e5, 0x00000008, + 0x1c01f000, 0x0201f800, 0x001064f2, 0x040007f4, + 0x42000000, 0x0010bd15, 0x0201f800, 0x0010ae10, + 0x5988014a, 0x80000000, 0x4803114a, 0x4a03900d, + 0x00000040, 0x42000000, 0xc0000000, 0x0201f000, + 0x00020105, 0x4c5c0000, 0x4c600000, 0x4c640000, + 0x4200c800, 0x0010c2ab, 0x4200b800, 0x00003000, + 0x4200c000, 0x00000105, 0x0201f800, 0x00105655, + 0x4a0370e4, 0x02000000, 0x5c00c800, 0x5c00c000, + 0x5c00b800, 0x1c01f000, 0x4933c857, 0x0201f000, + 0x00020a10, 0x4933c857, 0x0401fbfd, 0x1c01f000, + 0x41300800, 0x800409c0, 0x02020800, 0x0010032d, + 0x0201f800, 0x00100322, 0x42000000, 0x0010bd15, + 0x0201f800, 0x0010ae10, 0x4933c857, 0x813261c0, + 0x02000800, 0x0010032d, 0x0401f841, 0x40002800, + 0x0201f800, 0x0010ad79, 0x4c140000, 0x59a8006a, + 0x80000540, 0x04000004, 0x8c142d2a, 0x04000002, + 0x0401fbe3, 0x5c002800, 0x0401f8ae, 0x04000007, + 0x5932680a, 0x59340200, 0x8c00050e, 0x59300415, + 0x02020800, 0x00108c33, 0x1c01f000, 0x42000000, + 0x0010bd15, 0x0201f800, 0x0010ae10, 0x4933c857, + 0x813261c0, 0x02000800, 0x0010032d, 0x0401f89d, + 0x0400000b, 0x0201f800, 0x00108953, 0x04000008, + 0x59325809, 0x592c0209, 0x8400054e, 0x48025a09, + 0x417a7800, 0x0201f800, 0x0010853c, 0x1c01f000, + 0x485fc857, 0x5c000000, 0x4d780000, 0x4203e000, + 0x50000000, 0x4200b800, 0x00008005, 0x0201f000, + 0x00100332, 0x4933c857, 0x83300480, 0x00000020, + 0x02021800, 0x0010032d, 0x83300c00, 0x0010bd88, + 0x50040000, 0x80000000, 0x04001002, 0x44000800, + 0x1c01f000, 0x4933c857, 0x0401f7f4, 0x4807c856, + 0x59b800ea, 0x8c000510, 0x040007fd, 0x59b800e0, + 0x4803c857, 0x1c01f000, 0x4803c856, 0x42000000, + 0x10000000, 0x41300800, 0x0401f029, 0x8c000510, + 0x02000000, 0x0002010b, 0x4c040000, 0x0401f80b, + 0x5c000800, 0x82100480, 0x00000008, 0x02001000, + 0x0002010b, 0x4c040000, 0x0401feb7, 0x5c000800, + 0x0201f000, 0x0002010b, 0x59b800e2, 0x59b820e2, + 0x80100580, 0x040207fd, 0x80102114, 0x0401f001, + 0x40101800, 0x800c190a, 0x82100500, 0x0000001f, + 0x820c1d00, 0x0000001f, 0x800c2480, 0x82102500, + 0x0000001f, 0x1c01f000, 0x40680000, 0x406c0800, + 0x0401f807, 0x42018800, 0x00000001, 0x04020003, + 0x42018800, 0x00000000, 0x1c01f000, 0x82000500, + 0xf0000000, 0x82040d00, 0x0fffffff, 0x80040d40, + 0x4807c857, 0x42001000, 0x0010bc59, 0x50080000, + 0x80000540, 0x04020005, 0x4a0370e5, 0x00000003, + 0x4a0370e4, 0x00000300, 0x80000000, 0x44001000, + 0x42001000, 0x00000400, 0x59b800ea, 0x8c000510, + 0x0400000c, 0x0401ffd1, 0x82100480, 0x00000008, + 0x04001007, 0x4c040000, 0x4c080000, 0x0401fe7e, + 0x5c001000, 0x5c000800, 0x0401f020, 0x59b800ea, + 0x8c000516, 0x0402001d, 0x4a0370e4, 0x00300000, + 0x480770e1, 0x42001000, 0x0000ff00, 0x80081040, + 0x04000012, 0x59b808e4, 0x8c040d28, 0x040207fc, + 0x42001000, 0x0010bc59, 0x50080000, 0x80000040, + 0x04020005, 0x4a0370e5, 0x00000002, 0x4a0370e4, + 0x00000200, 0x02001800, 0x0010032d, 0x44001000, + 0x8c040d2c, 0x1c01f000, 0x41f80000, 0x50000000, + 0x0201f800, 0x0010032d, 0x80081040, 0x040207d3, 0x41f80000, 0x50000000, 0x0201f800, 0x0010032d, - 0x80081040, 0x040207d3, 0x41f80000, 0x50000000, - 0x0201f800, 0x0010032d, 0x4d380000, 0x59300c07, - 0x82040580, 0x00000009, 0x04020006, 0x42027000, - 0x00000047, 0x0201f800, 0x00020a34, 0x80000580, - 0x5c027000, 0x1c01f000, 0x4c500000, 0x4a03900d, - 0x00000001, 0x59c8a020, 0x4a03900d, 0x00000002, - 0x59c80820, 0x8c50a52e, 0x04000002, 0x900409c0, - 0x82040d00, 0x0000ffff, 0x0201f800, 0x001055ab, - 0x5c00a000, 0x1c01f000, 0x42000000, 0x0010bc0c, - 0x0201f800, 0x0010ad1d, 0x0401ffec, 0x0400004b, - 0x4933c857, 0x59300407, 0x82000580, 0x00000000, - 0x04000046, 0x59c82021, 0x4a03900d, 0x00000001, - 0x59c82821, 0x82142d00, 0x0000ffff, 0x59325809, - 0x812e59c0, 0x0400003d, 0x5932680a, 0x0201f800, - 0x001040aa, 0x02020800, 0x00108b62, 0x599c0019, - 0x8c00050c, 0x04020018, 0x0201f800, 0x001040aa, - 0x04020015, 0x59300812, 0x4807c857, 0x592c0409, - 0x8c00051c, 0x0402000e, 0x8400055c, 0x48025c09, - 0x592c0a05, 0x82040d00, 0x000000ff, 0x82040580, - 0x00000048, 0x04000004, 0x82040580, 0x00000018, - 0x04020003, 0x59300812, 0x48065803, 0x4a026012, - 0x7fffffff, 0x48166014, 0x599c0019, 0x8c00050c, - 0x04020004, 0x59a80007, 0x8c00051e, 0x04020017, - 0x0201f800, 0x00100e59, 0x04020014, 0x0401fa2f, - 0x40280000, 0x4802600e, 0x04000005, 0x4832600c, - 0x50200000, 0x4802600b, 0x4822600d, 0x59300415, - 0x8c00051c, 0x04020004, 0x599c0019, 0x8c00050c, - 0x04020885, 0x4a03900d, 0x00000040, 0x4a0370e5, - 0x00000008, 0x1c01f000, 0x42000000, 0x0010bc15, - 0x0201f800, 0x0010ad1d, 0x5988014c, 0x80000000, - 0x4803114c, 0x4a03900d, 0x00000040, 0x42000000, - 0xc0000000, 0x0201f000, 0x00020105, 0x4cf80000, - 0x58f40000, 0x8001f540, 0x0401f820, 0x41781800, - 0x0401f8f9, 0x04020014, 0x44140800, 0x0401f82a, - 0x04000011, 0x40043800, 0x42001800, 0x00000001, - 0x40142000, 0x0401f8f0, 0x0402000b, 0x801c3800, - 0x501c0000, 0x44000800, 0x0401f810, 0x801c0580, - 0x04000004, 0x44103800, 0x801c3840, 0x44143800, - 0x0401f819, 0x5c01f000, 0x1c01f000, 0x80f9f1c0, - 0x04020003, 0x58f41202, 0x0401f003, 0x42001000, - 0x00000007, 0x1c01f000, 0x80f9f1c0, 0x04020006, - 0x58f40401, 0x82000480, 0x00000002, 0x80f40400, - 0x0401f005, 0x58f80401, 0x82000480, 0x00000002, - 0x80f80400, 0x50002800, 0x80000000, 0x50002000, - 0x1c01f000, 0x80f9f1c0, 0x04020008, 0x58f40401, + 0x4d380000, 0x59300c07, 0x82040580, 0x00000009, + 0x04020006, 0x42027000, 0x00000047, 0x0201f800, + 0x00020a34, 0x80000580, 0x5c027000, 0x1c01f000, + 0x4c500000, 0x4a03900d, 0x00000001, 0x59c8a020, + 0x4a03900d, 0x00000002, 0x59c80820, 0x8c50a52e, + 0x04000002, 0x900409c0, 0x82040d00, 0x0000ffff, + 0x0201f800, 0x00105617, 0x5c00a000, 0x1c01f000, + 0x42000000, 0x0010bd0c, 0x0201f800, 0x0010ae10, + 0x0401ffec, 0x0400004e, 0x4933c857, 0x59300407, + 0x82000580, 0x00000000, 0x04000049, 0x59c82021, + 0x4a03900d, 0x00000001, 0x59c82821, 0x82142d00, + 0x0000ffff, 0x59325809, 0x812e59c0, 0x04000040, + 0x5932680a, 0x0201f800, 0x001040c4, 0x02020800, + 0x00108c1b, 0x599c0019, 0x8c00050c, 0x04020018, + 0x0201f800, 0x001040c4, 0x04020015, 0x59300812, + 0x4807c857, 0x592c0409, 0x8c00051c, 0x0402000e, + 0x8400055c, 0x48025c09, 0x592c0a05, 0x82040d00, + 0x000000ff, 0x82040580, 0x00000048, 0x04000004, + 0x82040580, 0x00000018, 0x04020003, 0x59300812, + 0x48065803, 0x4a026012, 0x7fffffff, 0x48166014, + 0x0201f800, 0x001040c4, 0x04000004, 0x59300415, + 0x8c00051c, 0x04000004, 0x599c0019, 0x8c00050c, + 0x04000017, 0x0201f800, 0x00100e5a, 0x04020014, + 0x0401fa2f, 0x40280000, 0x4802600e, 0x04000005, + 0x4832600c, 0x50200000, 0x4802600b, 0x4822600d, + 0x59300415, 0x8c00051c, 0x04020004, 0x599c0019, + 0x8c00050c, 0x04020885, 0x4a03900d, 0x00000040, + 0x4a0370e5, 0x00000008, 0x1c01f000, 0x42000000, + 0x0010bd15, 0x0201f800, 0x0010ae10, 0x5988014c, + 0x80000000, 0x4803114c, 0x4a03900d, 0x00000040, + 0x42000000, 0xc0000000, 0x0201f000, 0x00020105, + 0x4cf80000, 0x58f40000, 0x8001f540, 0x0401f820, + 0x41781800, 0x0401f8f9, 0x04020014, 0x44140800, + 0x0401f82a, 0x04000011, 0x40043800, 0x42001800, + 0x00000001, 0x40142000, 0x0401f8f0, 0x0402000b, + 0x801c3800, 0x501c0000, 0x44000800, 0x0401f810, + 0x801c0580, 0x04000004, 0x44103800, 0x801c3840, + 0x44143800, 0x0401f819, 0x5c01f000, 0x1c01f000, + 0x80f9f1c0, 0x04020003, 0x58f41202, 0x0401f003, + 0x42001000, 0x00000007, 0x1c01f000, 0x80f9f1c0, + 0x04020006, 0x58f40401, 0x82000480, 0x00000002, + 0x80f40400, 0x0401f005, 0x58f80401, 0x82000480, + 0x00000002, 0x80f80400, 0x50002800, 0x80000000, + 0x50002000, 0x1c01f000, 0x80f9f1c0, 0x04020008, + 0x58f40401, 0x82000480, 0x00000002, 0x02001800, + 0x0010032d, 0x4801ec01, 0x0401f00b, 0x58f80401, 0x82000480, 0x00000002, 0x02001800, 0x0010032d, - 0x4801ec01, 0x0401f00b, 0x58f80401, 0x82000480, - 0x00000002, 0x02001800, 0x0010032d, 0x4801f401, - 0x82000580, 0x00000002, 0x04020002, 0x0401f81b, - 0x58f40202, 0x80000040, 0x4801ea02, 0x02000800, - 0x0010032d, 0x82000580, 0x00000001, 0x1c01f000, - 0x82f40580, 0xffffffff, 0x0400000f, 0x58f40201, + 0x4801f401, 0x82000580, 0x00000002, 0x04020002, + 0x0401f81b, 0x58f40202, 0x80000040, 0x4801ea02, + 0x02000800, 0x0010032d, 0x82000580, 0x00000001, + 0x1c01f000, 0x82f40580, 0xffffffff, 0x0400000f, + 0x58f40201, 0x82000580, 0x0000dcb3, 0x02020800, + 0x0010032d, 0x58f40000, 0x8001f540, 0x04000006, + 0x58f80201, 0x82000580, 0x0000ddb9, 0x02020800, + 0x0010032d, 0x0401f80a, 0x1c01f000, 0x4d2c0000, + 0x40fa5800, 0x0201f800, 0x00100580, 0x4979e800, + 0x4179f000, 0x5c025800, 0x1c01f000, 0x80f5e9c0, + 0x04000009, 0x80f9f1c0, 0x04020ff5, 0x4d2c0000, + 0x40f65800, 0x0201f800, 0x00100580, 0x4179e800, + 0x5c025800, 0x1c01f000, 0x4cf40000, 0x0201f800, + 0x001040c4, 0x04020036, 0x59300808, 0x82040500, + 0x00013100, 0x04020032, 0x8c040d22, 0x04000032, + 0x59300020, 0x8001ed40, 0x02000800, 0x0010032d, + 0x82000580, 0xffffffff, 0x04000029, 0x58f40201, 0x82000580, 0x0000dcb3, 0x02020800, 0x0010032d, - 0x58f40000, 0x8001f540, 0x04000006, 0x58f80201, - 0x82000580, 0x0000ddb9, 0x02020800, 0x0010032d, - 0x0401f80a, 0x1c01f000, 0x4d2c0000, 0x40fa5800, - 0x0201f800, 0x00100580, 0x4979e800, 0x4179f000, - 0x5c025800, 0x1c01f000, 0x80f5e9c0, 0x04000009, - 0x80f9f1c0, 0x04020ff5, 0x4d2c0000, 0x40f65800, - 0x0201f800, 0x00100580, 0x4179e800, 0x5c025800, - 0x1c01f000, 0x4cf40000, 0x0201f800, 0x001040aa, - 0x04020036, 0x59300808, 0x82040500, 0x00013100, - 0x04020032, 0x8c040d22, 0x04000032, 0x59300020, - 0x8001ed40, 0x02000800, 0x0010032d, 0x82000580, - 0xffffffff, 0x04000029, 0x58f40201, 0x82000580, - 0x0000dcb3, 0x02020800, 0x0010032d, 0x58f40a02, - 0x82040500, 0x0000fffe, 0x04000003, 0x0401ff74, - 0x58f40a02, 0x82040480, 0x0000000f, 0x04021059, - 0x80040800, 0x4805ea02, 0x82040580, 0x00000008, - 0x0400005d, 0x82040480, 0x00000008, 0x0400100a, - 0x58f40000, 0x8001ed40, 0x02000800, 0x0010032d, - 0x58f40201, 0x82000580, 0x0000ddb9, 0x02020800, - 0x0010032d, 0x58f40401, 0x82000c00, 0x00000002, - 0x4805ec01, 0x80f40400, 0x59300813, 0x44040000, - 0x80000000, 0x45780000, 0x5c01e800, 0x1c01f000, - 0x42001000, 0x00000400, 0x59b800e4, 0x8c000524, - 0x04020023, 0x4a0370e4, 0x00030000, 0x40000000, - 0x59b800e4, 0x8c000524, 0x0402001b, 0x59300808, - 0x84040d62, 0x48066008, 0x4a0370e4, 0x00020000, - 0x4d2c0000, 0x0201f800, 0x0010055a, 0x04000025, - 0x492e6020, 0x4a025a01, 0x0000dcb3, 0x59300009, - 0x80001d40, 0x02000800, 0x0010032d, 0x580c0810, - 0x48065803, 0x59301812, 0x40040000, 0x800c0580, - 0x0402000d, 0x497a5a02, 0x4a025c01, 0x00000004, - 0x0401f011, 0x4a0370e4, 0x00020000, 0x40000000, - 0x40000000, 0x80081040, 0x02000800, 0x0010032d, - 0x0401f7d6, 0x4a025a02, 0x00000001, 0x4a025c01, - 0x00000006, 0x497a5804, 0x400c0000, 0x80040480, - 0x48025805, 0x412de800, 0x5c025800, 0x0401f7a9, - 0x5c025800, 0x4a026020, 0xffffffff, 0x0401f7c3, - 0x4d2c0000, 0x58f65800, 0x0201f800, 0x00100580, - 0x40f65800, 0x0201f800, 0x00100580, 0x5c025800, - 0x0401f7f5, 0x4d2c0000, 0x0201f800, 0x0010055a, - 0x040007f8, 0x4a025a01, 0x0000ddb9, 0x4a025c01, - 0x00000002, 0x492de800, 0x412de800, 0x5c025800, - 0x0401f7a5, 0x0401ff1e, 0x82f40400, 0x00000004, - 0x800c0400, 0x40000800, 0x50040000, 0x80100580, - 0x04000016, 0x82040c00, 0x00000002, 0x80081040, - 0x040207fa, 0x80f9f1c0, 0x04000011, 0x58f41202, - 0x82081480, 0x00000007, 0x82f80400, 0x00000002, - 0x800c0400, 0x40000800, 0x50040000, 0x80100580, - 0x04000006, 0x82040c00, 0x00000002, 0x80081040, - 0x040207fa, 0x0401f002, 0x1c01f000, 0x82000540, - 0x00000001, 0x0401f7fd, 0x4cf40000, 0x4cf80000, - 0x4001e800, 0x812e59c0, 0x04000024, 0x592c0a07, - 0x800409c0, 0x04020021, 0x82f40580, 0xffffffff, - 0x0400001b, 0x58f40201, 0x82000580, 0x0000dcb3, - 0x02020800, 0x0010032d, 0x58f40000, 0x8001f540, - 0x04000006, 0x58f80201, 0x82000580, 0x0000ddb9, - 0x02020800, 0x0010032d, 0x41783800, 0x58f44003, - 0x0401f839, 0x04020009, 0x0401ff2c, 0x497a6020, - 0x59300808, 0x84040d22, 0x48066008, 0x5c01f000, - 0x5c01e800, 0x1c01f000, 0x0401ff24, 0x4a025a07, - 0x00000011, 0x0401f7f6, 0x0401ff06, 0x0401f7f4, - 0x4cf40000, 0x4cf80000, 0x4001e800, 0x82040580, - 0x00000001, 0x04020020, 0x82f40580, 0xffffffff, - 0x0400001a, 0x58f40201, 0x82000580, 0x0000dcb3, - 0x02020800, 0x0010032d, 0x58f40000, 0x8001f540, - 0x04000006, 0x58f80201, 0x82000580, 0x0000ddb9, - 0x02020800, 0x0010032d, 0x41783800, 0x58f44003, - 0x0401f811, 0x04020008, 0x0401ff04, 0x42000800, - 0x00000001, 0x497a6020, 0x5c01f000, 0x5c01e800, - 0x1c01f000, 0x0401fefd, 0x42000800, 0x00000011, - 0x0401f7f9, 0x4c040000, 0x0401fede, 0x5c000800, - 0x0401f7f5, 0x4803c856, 0x401c2000, 0x41781800, - 0x4c200000, 0x0401ff88, 0x5c004000, 0x0402002a, - 0x40202000, 0x42001800, 0x00000001, 0x0401ff82, - 0x04020025, 0x0401fe9e, 0x40082800, 0x82f43400, - 0x00000004, 0x50182000, 0x40100000, 0x801c0580, - 0x04000005, 0x42001800, 0x00000001, 0x0401ff76, - 0x04020019, 0x82183400, 0x00000002, 0x80142840, - 0x040207f5, 0x80f9f1c0, 0x04000012, 0x58f42a02, - 0x82142c80, 0x00000007, 0x82f83400, 0x00000002, - 0x50182000, 0x40100000, 0x801c0580, 0x04000005, - 0x42001800, 0x00000001, 0x0401ff63, 0x04020006, - 0x82183400, 0x00000002, 0x80142840, 0x040207f5, - 0x1c01f000, 0x82000540, 0x00000001, 0x0401f7fd, - 0x0201f800, 0x0010032d, 0x58380a05, 0x82040d00, - 0x000000ff, 0x82040580, 0x0000001b, 0x04000004, - 0x82040580, 0x0000002b, 0x040207f6, 0x50200000, - 0x80387c00, 0x583c2800, 0x583c2001, 0x583c1002, - 0x592c0a08, 0x58383010, 0x59303808, 0x497a6013, - 0x497a6014, 0x0201f000, 0x00020149, 0x58380208, - 0x8c000502, 0x040007e7, 0x50200000, 0x80387c00, - 0x583c2800, 0x583c2001, 0x58380405, 0x80001540, - 0x04020002, 0x58381408, 0x58c83401, 0x58380c09, - 0x59303808, 0x497a6013, 0x497a6014, 0x0201f000, - 0x00020149, 0x592c0409, 0x8c000502, 0x040007d5, - 0x592c040a, 0x80000540, 0x040007d2, 0x82000c80, - 0x00000002, 0x04001011, 0x58380001, 0x80007540, - 0x02000800, 0x0010032d, 0x58380205, 0x82000500, - 0x0000000f, 0x82000400, 0x00100e39, 0x50004000, - 0x40040000, 0x800409c0, 0x04000005, 0x82040c80, - 0x00000005, 0x040217f1, 0x80204400, 0x50200000, - 0x80387c00, 0x583c2800, 0x583c2001, 0x583c1002, - 0x592c0a08, 0x592c4c09, 0x592c300e, 0x59303808, - 0x497a6013, 0x497a6014, 0x4816600f, 0x48126010, - 0x480a6011, 0x481a6012, 0x80040840, 0x4806600e, - 0x02000000, 0x00020151, 0x80204000, 0x50201800, - 0x800c19c0, 0x0402000c, 0x58380001, 0x80007540, - 0x02000800, 0x0010032d, 0x58380205, 0x82000500, - 0x0000000f, 0x82000400, 0x00100e39, 0x50004000, - 0x50201800, 0x483a600c, 0x480e600b, 0x4822600d, - 0x0201f000, 0x00020151, 0x4803c856, 0x592c0209, - 0x8c00051e, 0x04020017, 0x50200000, 0x80306c00, - 0x40240000, 0x0c01f001, 0x00100b7e, 0x00100b7e, - 0x00100b87, 0x00100b7e, 0x00100b7e, 0x00100b7e, - 0x00100b7e, 0x00100b7e, 0x00100b87, 0x00100b7e, - 0x00100b87, 0x00100b7e, 0x00100b7e, 0x00100b87, - 0x00100b7e, 0x00100b7e, 0x0201f800, 0x0010032d, - 0x8400051e, 0x48025a09, 0x50200000, 0x80306c00, - 0x58343801, 0x481e6010, 0x0401f007, 0x58341802, - 0x58342800, 0x58343801, 0x480e6011, 0x4816600f, - 0x481e6010, 0x0401f28a, 0x4933c857, 0x5931f809, - 0x59301006, 0x800811c0, 0x0400000b, 0x41780800, - 0x42000000, 0x0000000a, 0x0201f800, 0x00105f69, - 0x80080102, 0x04020002, 0x84001542, 0x80081040, - 0x4809fc07, 0x4a026006, 0x00000002, 0x592c040a, - 0x82000500, 0x00000008, 0x0400000b, 0x0401f831, - 0x59300203, 0x82000580, 0x00000004, 0x04020005, - 0x42027000, 0x00000048, 0x0201f800, 0x00020a34, - 0x1c01f000, 0x4cfc0000, 0x58fc0205, 0x82000500, - 0x000000ff, 0x82000580, 0x00000048, 0x04020009, - 0x58fc0409, 0x8c000500, 0x04000006, 0x58fc080c, - 0x8c040d16, 0x04000017, 0x58fc0008, 0x0401f00a, - 0x58fc0409, 0x8c000512, 0x04020014, 0x58fc0c0a, - 0x8c040d16, 0x04020003, 0x5c01f800, 0x1c01f000, - 0x58fc000b, 0x59300812, 0x80040580, 0x04020009, - 0x59300008, 0x84000500, 0x48026008, 0x42027000, - 0x00000048, 0x5c01f800, 0x0201f000, 0x00020a34, - 0x5c01f800, 0x1c01f000, 0x58fdf80a, 0x0401f7ec, - 0x5c000000, 0x4c000000, 0x4803c857, 0x4933c857, - 0x59b808ea, 0x82040d00, 0x00000007, 0x82040580, - 0x00000000, 0x04000025, 0x82040580, 0x00000003, - 0x04000022, 0x59300407, 0x4c000000, 0x4a026407, - 0x00000000, 0x42003000, 0x00000041, 0x4a0370e5, - 0x00003000, 0x42000000, 0x50000000, 0x41300800, - 0x4c180000, 0x0401fcac, 0x5c003000, 0x0400000e, - 0x42000000, 0x0000001e, 0x80000040, 0x040207ff, - 0x80183040, 0x040207f4, 0x42000000, 0x40000000, - 0x41300800, 0x0401fca0, 0x59880146, 0x80000000, - 0x48031146, 0x4a0370e5, 0x00002000, 0x5c000000, - 0x48026407, 0x1c01f000, 0x59300008, 0x84000500, - 0x48026008, 0x0401f7fc, 0x59c00007, 0x4a038006, - 0x30000000, 0x40000000, 0x59c00007, 0x8c00050a, - 0x040207fe, 0x1c01f000, 0x5c000000, 0x4c000000, - 0x4803c857, 0x42000800, 0x00000001, 0x0201f800, - 0x00101993, 0x4dc00000, 0x4a0370e8, 0x00000000, - 0x42038000, 0x00007720, 0x0401ffec, 0x42038000, - 0x00007700, 0x0401ffe9, 0x0201f800, 0x00104716, - 0x04020017, 0x4a038891, 0x0000ffff, 0x497b8880, - 0x4ce80000, 0x4201d000, 0x00000016, 0x0201f800, - 0x0010592d, 0x497b8892, 0x4201d000, 0x00000016, - 0x0201f800, 0x0010592d, 0x5c01d000, 0x42000000, - 0x0010bc60, 0x0201f800, 0x0010ad1d, 0x0401f812, - 0x5c038000, 0x0201f000, 0x0010483a, 0x0401f830, - 0x4c080000, 0x4c140000, 0x42000000, 0x0010bc61, - 0x0201f800, 0x0010ad1d, 0x0401f807, 0x5c002800, - 0x5c001000, 0x48178892, 0x480b8880, 0x5c038000, - 0x1c01f000, 0x496fc857, 0x836c0580, 0x00000003, - 0x0402000b, 0x4c080000, 0x4c0c0000, 0x42001000, - 0x00008048, 0x42001800, 0x0000ffff, 0x0201f800, - 0x001031eb, 0x5c001800, 0x5c001000, 0x42000800, - 0x0000003c, 0x0201f800, 0x001010da, 0x59a8006a, - 0x80000540, 0x04000005, 0x59a8106b, 0x800811c0, - 0x02020800, 0x001018fe, 0x4a038891, 0x0000ffff, - 0x4a03900d, 0x00000040, 0x0201f800, 0x00100684, - 0x4a0370e8, 0x00000001, 0x1c01f000, 0x5c000000, - 0x4c000000, 0x4803c857, 0x59c41080, 0x497b8880, - 0x4ce80000, 0x4201d000, 0x00000016, 0x4c080000, - 0x0201f800, 0x0010592d, 0x5c001000, 0x5c01d000, - 0x59c42892, 0x497b8892, 0x0201f800, 0x00104716, - 0x04020002, 0x1c01f000, 0x42002000, 0x00000260, - 0x59c418a4, 0x820c1d00, 0x0000000f, 0x820c0580, - 0x00000000, 0x04000010, 0x59c41805, 0x820c1d00, - 0x00000001, 0x0402000e, 0x59c418a4, 0x820c1d00, - 0x0000000f, 0x820c0480, 0x00000007, 0x04001004, - 0x820c0480, 0x0000000c, 0x04001003, 0x80102040, - 0x040207ec, 0x497b8891, 0x1c01f000, 0x4c100000, - 0x42002000, 0x00000019, 0x4a038805, 0x00000001, - 0x0201f800, 0x00101730, 0x59c41805, 0x820c1d00, - 0x00000001, 0x04000005, 0x80102040, 0x040207f7, - 0x5c002000, 0x0401f7f0, 0x5c002000, 0x0401f7ec, - 0x4803c856, 0x1c01f000, 0x00100cb6, 0x00100cb6, - 0x00100cb6, 0x00100cda, 0x00100cb6, 0x00100cb6, - 0x00100cb6, 0x00100cb6, 0x00100cb6, 0x00100cda, - 0x00100cb6, 0x00100cb8, 0x00100cb6, 0x00100cb6, - 0x00100cb6, 0x00100cb6, 0x0201f800, 0x0010032d, - 0x82040580, 0x0000001b, 0x0400001a, 0x82040580, - 0x0000002b, 0x04000017, 0x82040580, 0x0000003b, - 0x02020800, 0x0010032d, 0x592c020b, 0x8c000500, - 0x04000073, 0x592c1a08, 0x82040500, 0x0000000f, - 0x82000400, 0x00100e39, 0x50001000, 0x50080000, - 0x59302014, 0x4802600b, 0x492e600c, 0x480a600d, - 0x480e600e, 0x48126013, 0x5c025800, 0x1c01f000, - 0x592c0010, 0x48026012, 0x592c0011, 0x48026014, - 0x592c1a08, 0x0401f7ed, 0x82040500, 0x0000000f, - 0x82000400, 0x00100e39, 0x50001000, 0x50080000, - 0x592c1a08, 0x4802600b, 0x492e600c, 0x480a600d, - 0x480e600e, 0x497a6013, 0x0401f7ec, 0x8c040d00, - 0x0402004f, 0x82040d00, 0x00000080, 0x0400004c, - 0x0201f000, 0x00020164, 0x59300014, 0x59301013, - 0x80080580, 0x0402000c, 0x42007800, 0x80000005, - 0x592c1209, 0x82080500, 0xffff7fff, 0x48025a09, - 0x8c08151e, 0x0402003b, 0x823c7d40, 0x00000020, - 0x0401f038, 0x480bc857, 0x42000000, 0x0010bc0d, - 0x0201f800, 0x0010ad1d, 0x59302014, 0x59300415, - 0x4803c857, 0x8c000514, 0x04020011, 0x599c1819, - 0x8c0c1d12, 0x0400000b, 0x592c0810, 0x59300016, - 0x80040c80, 0x04000005, 0x04001004, 0x80040000, - 0x80140480, 0x0400100a, 0x0201f800, 0x00107134, - 0x820c1d40, 0x00000001, 0x0401f020, 0x84000514, - 0x48026415, 0x48126016, 0x4813c857, 0x0401f93e, - 0x0402001a, 0x42007800, 0x80000005, 0x5930500e, - 0x592c0209, 0x4803c857, 0x8c00051e, 0x04020005, - 0x823c7d40, 0x00000020, 0x5930400d, 0x0401f004, - 0x8400051e, 0x48025a09, 0x0401f8ed, 0x50201800, - 0x480e600b, 0x4832600c, 0x4822600d, 0x482a600e, - 0x480fc857, 0x4833c857, 0x4823c857, 0x482bc857, - 0x80000580, 0x483e6004, 0x1c01f000, 0x0201f800, - 0x0010032d, 0x4933c857, 0x4d2c0000, 0x59900004, + 0x58f40a02, 0x82040500, 0x0000fffe, 0x04000003, + 0x0401ff74, 0x58f40a02, 0x82040480, 0x0000000f, + 0x04021059, 0x80040800, 0x4805ea02, 0x82040580, + 0x00000008, 0x0400005d, 0x82040480, 0x00000008, + 0x0400100a, 0x58f40000, 0x8001ed40, 0x02000800, + 0x0010032d, 0x58f40201, 0x82000580, 0x0000ddb9, + 0x02020800, 0x0010032d, 0x58f40401, 0x82000c00, + 0x00000002, 0x4805ec01, 0x80f40400, 0x59300813, + 0x44040000, 0x80000000, 0x45780000, 0x5c01e800, + 0x1c01f000, 0x42001000, 0x00000400, 0x59b800e4, + 0x8c000524, 0x04020023, 0x4a0370e4, 0x00030000, + 0x40000000, 0x59b800e4, 0x8c000524, 0x0402001b, + 0x59300808, 0x84040d62, 0x48066008, 0x4a0370e4, + 0x00020000, 0x4d2c0000, 0x0201f800, 0x0010055a, + 0x04000025, 0x492e6020, 0x4a025a01, 0x0000dcb3, + 0x59300009, 0x80001d40, 0x02000800, 0x0010032d, + 0x580c0810, 0x48065803, 0x59301812, 0x40040000, + 0x800c0580, 0x0402000d, 0x497a5a02, 0x4a025c01, + 0x00000004, 0x0401f011, 0x4a0370e4, 0x00020000, + 0x40000000, 0x40000000, 0x80081040, 0x02000800, + 0x0010032d, 0x0401f7d6, 0x4a025a02, 0x00000001, + 0x4a025c01, 0x00000006, 0x497a5804, 0x400c0000, + 0x80040480, 0x48025805, 0x412de800, 0x5c025800, + 0x0401f7a9, 0x5c025800, 0x4a026020, 0xffffffff, + 0x0401f7c3, 0x4d2c0000, 0x58f65800, 0x0201f800, + 0x00100580, 0x40f65800, 0x0201f800, 0x00100580, + 0x5c025800, 0x0401f7f5, 0x4d2c0000, 0x0201f800, + 0x0010055a, 0x040007f8, 0x4a025a01, 0x0000ddb9, + 0x4a025c01, 0x00000002, 0x492de800, 0x412de800, + 0x5c025800, 0x0401f7a5, 0x0401ff1e, 0x82f40400, + 0x00000004, 0x800c0400, 0x40000800, 0x50040000, + 0x80100580, 0x04000016, 0x82040c00, 0x00000002, + 0x80081040, 0x040207fa, 0x80f9f1c0, 0x04000011, + 0x58f41202, 0x82081480, 0x00000007, 0x82f80400, + 0x00000002, 0x800c0400, 0x40000800, 0x50040000, + 0x80100580, 0x04000006, 0x82040c00, 0x00000002, + 0x80081040, 0x040207fa, 0x0401f002, 0x1c01f000, + 0x82000540, 0x00000001, 0x0401f7fd, 0x4cf40000, + 0x4cf80000, 0x4001e800, 0x812e59c0, 0x04000024, + 0x592c0a07, 0x800409c0, 0x04020021, 0x82f40580, + 0xffffffff, 0x0400001b, 0x58f40201, 0x82000580, + 0x0000dcb3, 0x02020800, 0x0010032d, 0x58f40000, + 0x8001f540, 0x04000006, 0x58f80201, 0x82000580, + 0x0000ddb9, 0x02020800, 0x0010032d, 0x41783800, + 0x58f44003, 0x0401f839, 0x04020009, 0x0401ff2c, + 0x497a6020, 0x59300808, 0x84040d22, 0x48066008, + 0x5c01f000, 0x5c01e800, 0x1c01f000, 0x0401ff24, + 0x4a025a07, 0x00000011, 0x0401f7f6, 0x0401ff06, + 0x0401f7f4, 0x4cf40000, 0x4cf80000, 0x4001e800, + 0x82040580, 0x00000001, 0x04020020, 0x82f40580, + 0xffffffff, 0x0400001a, 0x58f40201, 0x82000580, + 0x0000dcb3, 0x02020800, 0x0010032d, 0x58f40000, + 0x8001f540, 0x04000006, 0x58f80201, 0x82000580, + 0x0000ddb9, 0x02020800, 0x0010032d, 0x41783800, + 0x58f44003, 0x0401f811, 0x04020008, 0x0401ff04, + 0x42000800, 0x00000001, 0x497a6020, 0x5c01f000, + 0x5c01e800, 0x1c01f000, 0x0401fefd, 0x42000800, + 0x00000011, 0x0401f7f9, 0x4c040000, 0x0401fede, + 0x5c000800, 0x0401f7f5, 0x4803c856, 0x401c2000, + 0x41781800, 0x4c200000, 0x0401ff88, 0x5c004000, + 0x0402002a, 0x40202000, 0x42001800, 0x00000001, + 0x0401ff82, 0x04020025, 0x0401fe9e, 0x40082800, + 0x82f43400, 0x00000004, 0x50182000, 0x40100000, + 0x801c0580, 0x04000005, 0x42001800, 0x00000001, + 0x0401ff76, 0x04020019, 0x82183400, 0x00000002, + 0x80142840, 0x040207f5, 0x80f9f1c0, 0x04000012, + 0x58f42a02, 0x82142c80, 0x00000007, 0x82f83400, + 0x00000002, 0x50182000, 0x40100000, 0x801c0580, + 0x04000005, 0x42001800, 0x00000001, 0x0401ff63, + 0x04020006, 0x82183400, 0x00000002, 0x80142840, + 0x040207f5, 0x1c01f000, 0x82000540, 0x00000001, + 0x0401f7fd, 0x0201f800, 0x0010032d, 0x58380a05, + 0x82040d00, 0x000000ff, 0x82040580, 0x0000001b, + 0x04000004, 0x82040580, 0x0000002b, 0x040207f6, + 0x50200000, 0x80387c00, 0x583c2800, 0x583c2001, + 0x583c1002, 0x592c0a08, 0x58383010, 0x59303808, + 0x497a6013, 0x497a6014, 0x0201f000, 0x00020149, + 0x58380208, 0x8c000502, 0x040007e7, 0x50200000, + 0x80387c00, 0x583c2800, 0x583c2001, 0x58380405, + 0x80001540, 0x04020002, 0x58381408, 0x58c83401, + 0x58380c09, 0x59303808, 0x497a6013, 0x497a6014, + 0x0201f000, 0x00020149, 0x592c0409, 0x8c000502, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 02:08:04 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C8D0A106566B; Mon, 18 Jun 2012 02:08:04 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A96E28FC0A; Mon, 18 Jun 2012 02:08:04 +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 q5I284bM047331; Mon, 18 Jun 2012 02:08:04 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5I284Gq047328; Mon, 18 Jun 2012 02:08:04 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201206180208.q5I284Gq047328@svn.freebsd.org> From: Adrian Chadd Date: Mon, 18 Jun 2012 02:08:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237214 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 02:08:04 -0000 Author: adrian Date: Mon Jun 18 02:08:04 2012 New Revision: 237214 URL: http://svn.freebsd.org/changeset/base/237214 Log: Extend the radiotap code to be aware of the size of any extra vendor bitmaps that may occur. The way this works is: * the beginning of the radiotap frame has a 32 bit "radiotap" namespace bitmap; * if the vendor bitmap bit is set, then the next bitmap will be interpreted as a vendor bitmap; * this can keep going on and on (ie, more vendor and radiotap namespace bitmaps can be added) until the last bitmap with no "more bitmaps" set. Now, the radiotap code gets its grubby fingers into the supplied radiotap rx/tx buffer and replaces the channel configuration for each frame. I don't know why it's not up to the drivers themselves to do this, but I digress. So, if a vendor bitmap (or two, etc) exists, the offset calculations will be all completely wrong. This particular patch introduces ieee80211_radiotap_attachv(), which includes the number of vendor bitmaps (well, any other bitmaps, vendor or otherwise) between the end of the bitmap/header and the start of the actual radiotap field entries. This makes the radiotap calculations "right", so it correctly calculates where to overwrite the channel configuration. The long term fix is to go through and make each driver update the channel configuration, as some of the fields are already being updated. That, however, is a longer term fix that will need each driver fixed. I leave that as an exercise to someone in the future. Modified: head/sys/net80211/ieee80211_radiotap.c head/sys/net80211/ieee80211_var.h Modified: head/sys/net80211/ieee80211_radiotap.c ============================================================================== --- head/sys/net80211/ieee80211_radiotap.c Sun Jun 17 21:48:40 2012 (r237213) +++ head/sys/net80211/ieee80211_radiotap.c Mon Jun 18 02:08:04 2012 (r237214) @@ -47,13 +47,24 @@ __FBSDID("$FreeBSD$"); #include -static int radiotap_offset(struct ieee80211_radiotap_header *, int); +static int radiotap_offset(struct ieee80211_radiotap_header *, int, int); void ieee80211_radiotap_attach(struct ieee80211com *ic, struct ieee80211_radiotap_header *th, int tlen, uint32_t tx_radiotap, struct ieee80211_radiotap_header *rh, int rlen, uint32_t rx_radiotap) { + ieee80211_radiotap_attachv(ic, th, tlen, 0, tx_radiotap, + rh, rlen, 0, rx_radiotap); +} + +void +ieee80211_radiotap_attachv(struct ieee80211com *ic, + struct ieee80211_radiotap_header *th, + int tlen, int n_tx_v, uint32_t tx_radiotap, + struct ieee80211_radiotap_header *rh, + int rlen, int n_rx_v, uint32_t rx_radiotap) +{ #define B(_v) (1<<(_v)) int off; @@ -63,9 +74,9 @@ ieee80211_radiotap_attach(struct ieee802 /* calculate offset to channel data */ off = -1; if (tx_radiotap & B(IEEE80211_RADIOTAP_CHANNEL)) - off = radiotap_offset(th, IEEE80211_RADIOTAP_CHANNEL); + off = radiotap_offset(th, n_tx_v, IEEE80211_RADIOTAP_CHANNEL); else if (tx_radiotap & B(IEEE80211_RADIOTAP_XCHANNEL)) - off = radiotap_offset(th, IEEE80211_RADIOTAP_XCHANNEL); + off = radiotap_offset(th, n_tx_v, IEEE80211_RADIOTAP_XCHANNEL); if (off == -1) { if_printf(ic->ic_ifp, "%s: no tx channel, radiotap 0x%x\n", __func__, tx_radiotap); @@ -79,9 +90,9 @@ ieee80211_radiotap_attach(struct ieee802 /* calculate offset to channel data */ off = -1; if (rx_radiotap & B(IEEE80211_RADIOTAP_CHANNEL)) - off = radiotap_offset(rh, IEEE80211_RADIOTAP_CHANNEL); + off = radiotap_offset(rh, n_rx_v, IEEE80211_RADIOTAP_CHANNEL); else if (rx_radiotap & B(IEEE80211_RADIOTAP_XCHANNEL)) - off = radiotap_offset(rh, IEEE80211_RADIOTAP_XCHANNEL); + off = radiotap_offset(rh, n_rx_v, IEEE80211_RADIOTAP_XCHANNEL); if (off == -1) { if_printf(ic->ic_ifp, "%s: no rx channel, radiotap 0x%x\n", __func__, rx_radiotap); @@ -260,7 +271,8 @@ ieee80211_radiotap_rx_all(struct ieee802 * known -1 is returned. */ static int -radiotap_offset(struct ieee80211_radiotap_header *rh, int item) +radiotap_offset(struct ieee80211_radiotap_header *rh, + int n_vendor_attributes, int item) { static const struct { size_t align, width; @@ -334,6 +346,8 @@ radiotap_offset(struct ieee80211_radiota int off, i; off = sizeof(struct ieee80211_radiotap_header); + off += n_vendor_attributes * (sizeof(uint32_t)); + for (i = 0; i < IEEE80211_RADIOTAP_EXT; i++) { if ((present & (1< Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7957D1065673; Mon, 18 Jun 2012 04:07:12 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail35.syd.optusnet.com.au (mail35.syd.optusnet.com.au [211.29.133.51]) by mx1.freebsd.org (Postfix) with ESMTP id CA6398FC0C; Mon, 18 Jun 2012 04:07:11 +0000 (UTC) Received: from c122-106-171-232.carlnfd1.nsw.optusnet.com.au (c122-106-171-232.carlnfd1.nsw.optusnet.com.au [122.106.171.232]) by mail35.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q5I470ib018093 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 18 Jun 2012 14:07:02 +1000 Date: Mon, 18 Jun 2012 14:07:00 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Poul-Henning Kamp In-Reply-To: <201206172102.q5HL2mG9032399@svn.freebsd.org> Message-ID: <20120618130626.M952@besplex.bde.org> References: <201206172102.q5HL2mG9032399@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r237203 - head/sys/dev/fb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 04:07:12 -0000 On Sun, 17 Jun 2012, Poul-Henning Kamp wrote: > Log: > On certain newer Intel Atom based motherboards, for instance the > D2500CC which I have, syscons in text-mode fails to show the expected > contents due to write errors into video-memory. > > At least one of the causes is that we copy from syscons internal buffer > to the video memory with optimized bcopy(9) which uses >16bit operations. > > Until now, 32bit and wider operations have always worked on the video > memory, but since I cannot find a single source which says that this > SHALL work, and since these chipsets/bugs are now out there, this > commit changes syscons to always use 16bit copies on i386 & amd64. > > This may be relevevant for PR's: > 166262 > 166639 > and various other bug reports floating elsewhere on the net, but > I lack hardware to test those. There is no reason 16-bit copies should work either. IIRC, CRTC registers were once written 16 bits at a time, but some (rare) hardware doesn't like this. One would expect frame buffers to look more like memory than device ragisters, but it is apparently possible for this to be broken too. > > Modified: > head/sys/dev/fb/fbreg.h > > Modified: head/sys/dev/fb/fbreg.h > ============================================================================== > --- head/sys/dev/fb/fbreg.h Sun Jun 17 20:45:45 2012 (r237202) > +++ head/sys/dev/fb/fbreg.h Sun Jun 17 21:02:48 2012 (r237203) > @@ -35,9 +35,16 @@ > > /* some macros */ > #if defined(__amd64__) || defined(__i386__) > -#define bcopy_io(s, d, c) bcopy((void *)(s), (void *)(d), (c)) > -#define bcopy_toio(s, d, c) bcopy((void *)(s), (void *)(d), (c)) > -#define bcopy_fromio(s, d, c) bcopy((void *)(s), (void *)(d), (c)) Syscons used to use the bogus bcopyb() function to avoid this bug. This has been turned into nonsense -- bcopyb() still exists on i386, but is never used (it wasn't copied to amd64). The above was used instead. (bcopyb() is bogus because the interface is logically a bus-io one and has nothing to do with bcopy().) Syscons (fb) still uses the bogus fillw() function. fillw() is implemented bogusly. First, the corresponding API used by the main part of fb is named fillw_io(). That is not as bogus as bcopy*_io() since fillw() isn't a standard memory API like bcopy() is. But fillw() is bogus since it should have been named something like fillw_io() to begin with. Then: - on amd64 and i386, fillw() is a function "optimized" in support.[sS]. fillw_io() is #defined to this. - on other arches, fillw() is implemented using messy ifdefs: - on ia64, the ifdefs are used to obfuscate the logically correct function bus_space_set_region(2) as fillw_io() - on sparc64, a fillw() function is implemented in C, under a messy ifdef that seems to be completely broken -- fillw() is never used directly, and seems to be unattached to fillw_io() on sparc64 - on powerpc(), both fillw_io() and fillw() are #defined in terms of ofwfb_fillw(). Now fillw_io() exists, but fillw() seems to be unused garbage. - the #else clause if the messy ifdef is commented as being for !__i386__ && !__amd64__ && !__ia64__ && !__sparc64__ && !__powerpc__ (in that unsorted order. __amd64__ and __i386__ were not unsorted in the corresponding #if). I think this reduces to __arm__. So for arm, in this #else clause fillw_io() is #defined in terms of memset_io() (another bogus interface). The unused fillw() is defined in terms of memsetw(). This can be considered a non-bogus interface -- it can be like memset() and thus unsuitable for i/o, but take a "word" pattern instead of a u_char pattern. The full (?) set of bogus interfaces is easiest to see in this #else clause. It is bcopy_{io,toio,fromio}, bzero_io (another nonsense), and fill{_io,w,w_io}. > Modified: head/sys/dev/fb/fbreg.h > ============================================================================== > --- head/sys/dev/fb/fbreg.h Sun Jun 17 20:45:45 2012 (r237202) > +++ head/sys/dev/fb/fbreg.h Sun Jun 17 21:02:48 2012 (r237203) > @@ -35,9 +35,16 @@ > > /* some macros */ > #if defined(__amd64__) || defined(__i386__) > -#define bcopy_io(s, d, c) bcopy((void *)(s), (void *)(d), (c)) > -#define bcopy_toio(s, d, c) bcopy((void *)(s), (void *)(d), (c)) > -#define bcopy_fromio(s, d, c) bcopy((void *)(s), (void *)(d), (c)) > + > +static __inline void > +copyw(uint16_t *src, uint16_t *dst, size_t size) > +{ > + while (size--) > + *dst++ = *src++; > +} > +#define bcopy_io(s, d, c) copyw((void*)(s), (void*)(d), (c)) > +#define bcopy_toio(s, d, c) copyw((void*)(s), (void*)(d), (c)) > +#define bcopy_fromio(s, d, c) copyw((void*)(s), (void*)(d), (c)) This patch doesn't improve the above mess: - it is only for amd64 and i386 - it introduces yet another function and naming scheme that doesn't use bus space and doesn't have "io" in the basic function - it makes other old bugs more obvious: - space instead of tab after all #define's - bogus casts to (void *) for bcopy()'s args. These probably don't even hide bugs, since bcopy()'s prototype says to do the same conversions and the compiler probably doesn't warn about implicit conversions to void *. - bogus casts to (void *) for copyw()'s args. These may now hide bugs, since they are different from the ones that the prototype says to do, and the compiler would probably complain about implicit conversions fro a non-uint16_t * pointer to a uint16_t * one. > #define bzero_io(d, c) bzero((void *)(d), (c)) bzero() still does 32 or even 64 bit accesses. Hmm, I wonder if your hardware works with 32-bit accesses on i386 but not with 64-bit ones on amd64. > #define fill_io(p, d, c) fill((p), (void *)(d), (c)) > #define fillw_io(p, d, c) fillw((p), (void *)(d), (c)) I tried to get the powers that be to clean up this mess, but there was no interest. From old mail (the version that seems to have the most complete patch; perhaps not my best version of the patch): % On Wed, 17 Jun 2009, Bruce Evans wrote: % % ... % % Here are patches for RELENG_7 to remove the frame buffer grot from % i386 and partially clean it up in frame buffer code. This compiles % in a least 1 i386 kernel and is fast enough (22 MB/S for % % dd % % +#endif % % +/* XXX fix gratuitous MD spelling: */ % % +#ifdef __amd64__ % % +#define BUS_SPACE_MEM AMD64_BUS_SPACE_MEM % % +#endif % % +#ifdef __i386__ % % +#define BUS_SPACE_MEM I386_BUS_SPACE_MEM % % +#endif % % +#ifdef __ia64__ % % +#define BUS_SPACE_MEM IA64_BUS_SPACE_MEM % % +#endif % % +#if defined(__amd64__) || defined(__i386__) || defined(__ia64__) % % #define bcopy_fromio(s, d, c) \ % % - bus_space_read_region_1(IA64_BUS_SPACE_MEM, s, 0, (void*)(d), c) % % + bus_space_read_region_1(BUS_SPACE_MEM, s, 0, (void*)(d), c) % % #define bcopy_io(s, d, c) \ % % - bus_space_copy_region_1(IA64_BUS_SPACE_MEM, s, 0, d, 0, c) % % + bus_space_copy_region_1(BUS_SPACE_MEM, s, 0, d, 0, c) % % #define bcopy_toio(s, d, c) \ % % - bus_space_write_region_1(IA64_BUS_SPACE_MEM, d, 0, (void*)(s), c) % % + bus_space_write_region_1(BUS_SPACE_MEM, d, 0, (void*)(s), c) % % #define bzero_io(d, c) \ % % - bus_space_set_region_1(IA64_BUS_SPACE_MEM, (intptr_t)(d), 0, 0, c) % % + bus_space_set_region_1(BUS_SPACE_MEM, (intptr_t)(d), 0, 0, c) % % #define fill_io(p, d, c) \ % % - bus_space_set_region_1(IA64_BUS_SPACE_MEM, (intptr_t)(d), 0, p, c) % % + bus_space_set_region_1(BUS_SPACE_MEM, (intptr_t)(d), 0, p, c) % % #define fillw_io(p, d, c) \ % % - bus_space_set_region_2(IA64_BUS_SPACE_MEM, (intptr_t)(d), 0, p, c) % % -#define readb(a) bus_space_read_1(IA64_BUS_SPACE_MEM, a, 0) % % -#define readw(a) bus_space_read_2(IA64_BUS_SPACE_MEM, a, 0) % % -#define writeb(a, v) bus_space_write_1(IA64_BUS_SPACE_MEM, a, 0, v) % % -#define writew(a, v) bus_space_write_2(IA64_BUS_SPACE_MEM, a, 0, v) % % -#define writel(a, v) bus_space_write_4(IA64_BUS_SPACE_MEM, a, 0, v) % % -#endif /* __ia64__ */ % % + bus_space_set_region_2(BUS_SPACE_MEM, (intptr_t)(d), 0, p, c) % % +#define readb(a) bus_space_read_1(BUS_SPACE_MEM, a, 0) % % +#define readw(a) bus_space_read_2(BUS_SPACE_MEM, a, 0) % % +#define writeb(a, v) bus_space_write_1(BUS_SPACE_MEM, a, 0, v) % % +#define writew(a, v) bus_space_write_2(BUS_SPACE_MEM, a, 0, v) % % +#define writel(a, v) bus_space_write_4(BUS_SPACE_MEM, a, 0, v) % % +#endif /* __amd64__ || __i386__ || __ia64__ */ % % +/* fillw for __amd64__ || __i386__ || __ia64__ and || __sparc64__ too, ugh. */ % % static __inline void % % fillw(int val, uint16_t *buf, size_t size) % % @@ -102,5 +101,5 @@ % % #define fillw(p, d, c) memsetw((d), (p), (c)) % % #define fillw_io(p, d, c) memsetw_io((d), (p), (c)) % % -#endif /* !__i386__ */ % % +#endif % % % % /* video function table */ % % Index: dev/fb/vga.c % % =================================================================== % % RCS file: /home/ncvs/src/sys/dev/fb/vga.c,v % % retrieving revision 1.36 % % diff -u -2 -r1.36 vga.c % % --- dev/fb/vga.c 4 Dec 2005 02:12:41 -0000 1.36 % % +++ dev/fb/vga.c 17 Jun 2009 02:19:22 -0000 % % @@ -1331,15 +1331,4 @@ % % % % #ifndef VGA_NO_MODE_CHANGE % % -#if defined(__i386__) || defined(__amd64__) /* XXX */ % % -static void % % -fill(int val, void *d, size_t size) % % -{ % % - u_char *p = d; % % - % % - while (size-- > 0) % % - *p++ = val; % % -} % % -#endif /* __i386__ */ % % - % % static void % % filll_io(int val, vm_offset_t d, size_t size) Gak, yet another fill function to actually force 32-bit accesses. What does your hardware do with this and the bzero()s? The i586 optimized copying routines used 64-bit accesses even on i386, and of course for sp33d, bcopy should use SSE for 128-bit accesses. I wonder if there is only a problem with misaligned cases on your hardware. x86 bcopy() is intentionally sloppy with alignment since it expects callers to align if this is best for speed. But frame buffer accesses could naturally cause lots of cases with only 16-bit alignment. % % Index: i386/i386/support.s % % =================================================================== % % RCS file: /home/ncvs/src/sys/i386/i386/support.s,v % % retrieving revision 1.119.2.1 % % diff -u -2 -r1.119.2.1 support.s % % --- i386/i386/support.s 12 Jan 2009 15:48:22 -0000 1.119.2.1 % % +++ i386/i386/support.s 17 Jun 2009 01:43:27 -0000 % % @@ -429,49 +429,4 @@ % % END(i686_pagezero) % % % % -/* fillw(pat, base, cnt) */ % % -ENTRY(fillw) % % - pushl %edi % % - movl 8(%esp),%eax % % - movl 12(%esp),%edi % % - movl 16(%esp),%ecx % % - cld % % - rep % % - stosw % % - popl %edi % % - ret % % -END(fillw) % % - % % -ENTRY(bcopyb) % % - pushl %esi % % - pushl %edi % % - movl 12(%esp),%esi % % - movl 16(%esp),%edi % % - movl 20(%esp),%ecx % % - movl %edi,%eax % % - subl %esi,%eax % % - cmpl %ecx,%eax /* overlapping && src < dst? */ % % - jb 1f % % - cld /* nope, copy forwards */ % % - rep % % - movsb % % - popl %edi % % - popl %esi % % - ret % % - % % - ALIGN_TEXT % % -1: % % - addl %ecx,%edi /* copy backwards. */ % % - addl %ecx,%esi % % - decl %edi % % - decl %esi % % - std % % - rep % % - movsb % % - popl %edi % % - popl %esi % % - cld % % - ret % % -END(bcopyb) % % - % % ENTRY(bcopy) % % MEXITCOUNT % % Index: i386/include/cpufunc.h % % =================================================================== % % RCS file: /home/ncvs/src/sys/i386/include/cpufunc.h,v % % retrieving revision 1.145.2.1 % % diff -u -2 -r1.145.2.1 cpufunc.h % % --- i386/include/cpufunc.h 12 Jan 2009 15:48:22 -0000 1.145.2.1 % % +++ i386/include/cpufunc.h 17 Jun 2009 01:44:24 -0000 % % @@ -45,12 +45,4 @@ % % struct region_descriptor; % % % % -#define readb(va) (*(volatile u_int8_t *) (va)) % % -#define readw(va) (*(volatile u_int16_t *) (va)) % % -#define readl(va) (*(volatile u_int32_t *) (va)) % % - % % -#define writeb(va, d) (*(volatile u_int8_t *) (va) = (d)) % % -#define writew(va, d) (*(volatile u_int16_t *) (va) = (d)) % % -#define writel(va, d) (*(volatile u_int32_t *) (va) = (d)) % % - % % #if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE) % % % % Index: i386/include/md_var.h % % =================================================================== % % RCS file: /home/ncvs/src/sys/i386/include/md_var.h,v % % retrieving revision 1.76.2.1 % % diff -u -2 -r1.76.2.1 md_var.h % % --- i386/include/md_var.h 21 Jan 2009 20:16:11 -0000 1.76.2.1 % % +++ i386/include/md_var.h 17 Jun 2009 01:44:01 -0000 % % @@ -80,5 +80,4 @@ % % struct dumperinfo; % % % % -void bcopyb(const void *from, void *to, size_t len); % % void busdma_swi(void); % % void cpu_setregs(void); % % @@ -95,5 +94,4 @@ % % void dump_drop_page(vm_paddr_t); % % void enable_sse(void); % % -void fillw(int /*u_short*/ pat, void *base, size_t cnt); % % void i486_bzero(void *buf, size_t len); % % void i586_bcopy(const void *from, void *to, size_t len); % % In fbreg.h, this just uses the ia64 macros for i386 (and for amd64, % untested) after s/IA64_//g. There are still messes for sparc64, % powerpc and default (arm only?), and new messes to get an MI name % for BUS_SPACE_MEM (the very idea of a frame buffer depends on having % a memory bus-space, so BUS_SPACE_MEM should be MI). fillw() doesn't % use bus space since it is for ordinary memory. It should probably % be implemented in vga.c. between fill() (removed above) and filll(). % fill() looks like it is for ordinary memory, but was only used for % bus space memory, only on amd64 and i386; thus it became unused. % It is also better spelled as memset(). fillw() and filll() would % probably be better spelled memset[wl]() like fillw() already is in % MD code for the default case. % % Bruce Bruce From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 06:41:47 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 93C00106564A; Mon, 18 Jun 2012 06:41:47 +0000 (UTC) (envelope-from phk@phk.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.freebsd.org (Postfix) with ESMTP id 4CBB18FC14; Mon, 18 Jun 2012 06:41:47 +0000 (UTC) Received: from critter.freebsd.dk (critter.freebsd.dk [192.168.61.3]) by phk.freebsd.dk (Postfix) with ESMTP id B2EC113E71; Mon, 18 Jun 2012 06:41:39 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.14.5/8.14.5) with ESMTP id q5I6fciZ080209; Mon, 18 Jun 2012 06:41:39 GMT (envelope-from phk@phk.freebsd.dk) To: Bruce Evans From: "Poul-Henning Kamp" In-Reply-To: Your message of "Mon, 18 Jun 2012 14:07:00 +1000." <20120618130626.M952@besplex.bde.org> Content-Type: text/plain; charset=ISO-8859-1 Date: Mon, 18 Jun 2012 06:41:38 +0000 Message-ID: <80208.1340001698@critter.freebsd.dk> Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r237203 - head/sys/dev/fb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 06:41:47 -0000 In message <20120618130626.M952@besplex.bde.org>, Bruce Evans writes: >There is no reason 16-bit copies should work either. Indeed not, but they do. As for the rest of your observations: Yes, the syscons code is a mess. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 07:34:39 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E0183106566C; Mon, 18 Jun 2012 07:34:38 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C140A8FC19; Mon, 18 Jun 2012 07:34:38 +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 q5I7YciA062476; Mon, 18 Jun 2012 07:34:38 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5I7YcRv062474; Mon, 18 Jun 2012 07:34:38 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201206180734.q5I7YcRv062474@svn.freebsd.org> From: Peter Holm Date: Mon, 18 Jun 2012 07:34:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237219 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 07:34:39 -0000 Author: pho Date: Mon Jun 18 07:34:38 2012 New Revision: 237219 URL: http://svn.freebsd.org/changeset/base/237219 Log: In tty_makedev() the following construction: dev = make_dev_cred(); dev->si_drv1 = tp; leaves a small window where the newly created device may be opened and si_drv1 is NULL. As this is a vary rare situation, using a lock to close the window seems overkill. Instead just wait for the assignment of si_drv1. Suggested by: kib MFC after: 1 week Modified: head/sys/kern/tty.c Modified: head/sys/kern/tty.c ============================================================================== --- head/sys/kern/tty.c Mon Jun 18 05:02:21 2012 (r237218) +++ head/sys/kern/tty.c Mon Jun 18 07:34:38 2012 (r237219) @@ -219,9 +219,15 @@ ttydev_leave(struct tty *tp) static int ttydev_open(struct cdev *dev, int oflags, int devtype, struct thread *td) { - struct tty *tp = dev->si_drv1; + struct tty *tp; int error = 0; + while ((tp = dev->si_drv1) == NULL) { + error = tsleep(&dev->si_drv1, PCATCH, "ttdrv1", 1); + if (error != EWOULDBLOCK) + return (error); + } + tty_lock(tp); if (tty_gone(tp)) { /* Device is already gone. */ @@ -738,9 +744,14 @@ static struct cdevsw ttydev_cdevsw = { static int ttyil_open(struct cdev *dev, int oflags, int devtype, struct thread *td) { - struct tty *tp = dev->si_drv1; + struct tty *tp; int error = 0; + while ((tp = dev->si_drv1) == NULL) { + error = tsleep(&dev->si_drv1, PCATCH, "ttdrv1", 1); + if (error != EWOULDBLOCK) + return (error); + } tty_lock(tp); if (tty_gone(tp)) error = ENODEV; @@ -1203,6 +1214,7 @@ tty_makedev(struct tty *tp, struct ucred dev = make_dev_cred(&ttydev_cdevsw, 0, cred, uid, gid, mode, "%s%s", prefix, name); dev->si_drv1 = tp; + wakeup(&dev->si_drv1); tp->t_dev = dev; /* Slave call-in devices. */ @@ -1211,12 +1223,14 @@ tty_makedev(struct tty *tp, struct ucred uid, gid, mode, "%s%s.init", prefix, name); dev_depends(tp->t_dev, dev); dev->si_drv1 = tp; + wakeup(&dev->si_drv1); dev->si_drv2 = &tp->t_termios_init_in; dev = make_dev_cred(&ttyil_cdevsw, TTYUNIT_LOCK, cred, uid, gid, mode, "%s%s.lock", prefix, name); dev_depends(tp->t_dev, dev); dev->si_drv1 = tp; + wakeup(&dev->si_drv1); dev->si_drv2 = &tp->t_termios_lock_in; } @@ -1226,6 +1240,7 @@ tty_makedev(struct tty *tp, struct ucred UID_UUCP, GID_DIALER, 0660, "cua%s", name); dev_depends(tp->t_dev, dev); dev->si_drv1 = tp; + wakeup(&dev->si_drv1); /* Slave call-out devices. */ if (tp->t_flags & TF_INITLOCK) { @@ -1234,6 +1249,7 @@ tty_makedev(struct tty *tp, struct ucred UID_UUCP, GID_DIALER, 0660, "cua%s.init", name); dev_depends(tp->t_dev, dev); dev->si_drv1 = tp; + wakeup(&dev->si_drv1); dev->si_drv2 = &tp->t_termios_init_out; dev = make_dev_cred(&ttyil_cdevsw, @@ -1241,6 +1257,7 @@ tty_makedev(struct tty *tp, struct ucred UID_UUCP, GID_DIALER, 0660, "cua%s.lock", name); dev_depends(tp->t_dev, dev); dev->si_drv1 = tp; + wakeup(&dev->si_drv1); dev->si_drv2 = &tp->t_termios_lock_out; } } From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 07:54:11 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8D17310658C4; Mon, 18 Jun 2012 07:54:11 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 78AAC8FC08; Mon, 18 Jun 2012 07:54:11 +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 q5I7sBrT063450; Mon, 18 Jun 2012 07:54:11 GMT (envelope-from phk@svn.freebsd.org) Received: (from phk@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5I7sBoQ063448; Mon, 18 Jun 2012 07:54:11 GMT (envelope-from phk@svn.freebsd.org) Message-Id: <201206180754.q5I7sBoQ063448@svn.freebsd.org> From: Poul-Henning Kamp Date: Mon, 18 Jun 2012 07:54:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237223 - head/sys/dev/fb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 07:54:11 -0000 Author: phk Date: Mon Jun 18 07:54:10 2012 New Revision: 237223 URL: http://svn.freebsd.org/changeset/base/237223 Log: Fix the previous commit to only copy the data we were asked to and not twice as much. Spotted by: Taku YAMAMOTO Modified: head/sys/dev/fb/fbreg.h Modified: head/sys/dev/fb/fbreg.h ============================================================================== --- head/sys/dev/fb/fbreg.h Mon Jun 18 07:43:23 2012 (r237222) +++ head/sys/dev/fb/fbreg.h Mon Jun 18 07:54:10 2012 (r237223) @@ -39,6 +39,7 @@ static __inline void copyw(uint16_t *src, uint16_t *dst, size_t size) { + size >>= 1; while (size--) *dst++ = *src++; } From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 07:54:46 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D597F1065672; Mon, 18 Jun 2012 07:54:46 +0000 (UTC) (envelope-from phk@phk.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.freebsd.org (Postfix) with ESMTP id 8FD428FC1F; Mon, 18 Jun 2012 07:54:46 +0000 (UTC) Received: from critter.freebsd.dk (critter.freebsd.dk [192.168.61.3]) by phk.freebsd.dk (Postfix) with ESMTP id 2F2DC13FB0; Mon, 18 Jun 2012 07:54:45 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.14.5/8.14.5) with ESMTP id q5I7shl3024167; Mon, 18 Jun 2012 07:54:44 GMT (envelope-from phk@phk.freebsd.dk) To: Taku YAMAMOTO From: "Poul-Henning Kamp" In-Reply-To: Your message of "Mon, 18 Jun 2012 06:29:12 +0900." <20120618062912.61088c11.taku@tackymt.homeip.net> Content-Type: text/plain; charset=ISO-8859-1 Date: Mon, 18 Jun 2012 07:54:43 +0000 Message-ID: <24166.1340006083@critter.freebsd.dk> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237203 - head/sys/dev/fb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 07:54:46 -0000 In message <20120618062912.61088c11.taku@tackymt.homeip.net>, Taku YAMAMOTO wri tes: >On Sun, 17 Jun 2012 21:02:48 +0000 (UTC) >Poul-Henning Kamp wrote: > >> Author: phk >> Date: Sun Jun 17 21:02:48 2012 >> New Revision: 237203 >> URL: http://svn.freebsd.org/changeset/base/237203 >> + >> +static __inline void >> +copyw(uint16_t *src, uint16_t *dst, size_t size) >> +{ >> + while (size--) >> + *dst++ = *src++; >> +} > >Does this end up with copying 2*size bytes instead of size bytes? Indeed it did. Thanks for spotting my mistake. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 09:36:52 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 675FB1065670; Mon, 18 Jun 2012 09:36:52 +0000 (UTC) (envelope-from gprspb@mail.ru) Received: from fallback3.mail.ru (fallback3.mail.ru [94.100.176.58]) by mx1.freebsd.org (Postfix) with ESMTP id 098098FC14; Mon, 18 Jun 2012 09:36:52 +0000 (UTC) Received: from smtp17.mail.ru (smtp17.mail.ru [94.100.176.154]) by fallback3.mail.ru (mPOP.Fallback_MX) with ESMTP id 9EA41B317B1E; Mon, 18 Jun 2012 13:35:33 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=rYvQt8vuDfCiziI29s7P13gtpLdzPu4OeHJ2jWwVAUU=; b=DIaqfur5ORvJrmYTIqG8wcgvbfmJ1fU39zcIzDb+HX1b2btDH+QAJcI4u3h1rLqG2X1msSkjH850MAj5tXfzu644lVDlV6mXytQCoyIiY8/1GkF4eD1GRONiAQGK9Ezp; Received: from [93.185.182.46] (port=27508 helo=gpr.nnz-home.ru) by smtp17.mail.ru with esmtpa (envelope-from ) id 1SgYMo-000068-5k; Mon, 18 Jun 2012 13:35:26 +0400 Received: from gpr by gpr.nnz-home.ru with local (Exim 4.77 (FreeBSD)) (envelope-from ) id 1SgYLz-0000I6-Ad; Mon, 18 Jun 2012 13:34:35 +0400 Date: Mon, 18 Jun 2012 13:34:35 +0400 From: Gennady Proskurin To: Poul-Henning Kamp Message-ID: <20120618093435.GA1017@gpr.nnz-home.ru> References: <201206180754.q5I7sBoQ063448@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201206180754.q5I7sBoQ063448@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam: Not detected X-Mras: Ok Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237223 - head/sys/dev/fb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 09:36:52 -0000 On Mon, Jun 18, 2012 at 07:54:11AM +0000, Poul-Henning Kamp wrote: > Author: phk > Date: Mon Jun 18 07:54:10 2012 > New Revision: 237223 > URL: http://svn.freebsd.org/changeset/base/237223 > > Log: > Fix the previous commit to only copy the data we were asked to and not > twice as much. > > Spotted by: Taku YAMAMOTO > > Modified: > head/sys/dev/fb/fbreg.h > > Modified: head/sys/dev/fb/fbreg.h > ============================================================================== > --- head/sys/dev/fb/fbreg.h Mon Jun 18 07:43:23 2012 (r237222) > +++ head/sys/dev/fb/fbreg.h Mon Jun 18 07:54:10 2012 (r237223) > @@ -39,6 +39,7 @@ > static __inline void > copyw(uint16_t *src, uint16_t *dst, size_t size) > { > + size >>= 1; > while (size--) > *dst++ = *src++; > } If size is odd, this does not copy the last byte. Not sure, whether this is intended. From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 12:45:36 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2E8E8106564A; Mon, 18 Jun 2012 12:45:36 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 198C08FC08; Mon, 18 Jun 2012 12:45: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 q5ICjZ5N079605; Mon, 18 Jun 2012 12:45:35 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5ICjZDt079602; Mon, 18 Jun 2012 12:45:35 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206181245.q5ICjZDt079602@svn.freebsd.org> From: Alexander Motin Date: Mon, 18 Jun 2012 12:45:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237225 - head/sys/cam/scsi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 12:45:36 -0000 Author: mav Date: Mon Jun 18 12:45:35 2012 New Revision: 237225 URL: http://svn.freebsd.org/changeset/base/237225 Log: Remove never used CD/DA_FLAG_TAGGED_QUEUING flags. MFC after: 1 week Modified: head/sys/cam/scsi/scsi_cd.c head/sys/cam/scsi/scsi_da.c Modified: head/sys/cam/scsi/scsi_cd.c ============================================================================== --- head/sys/cam/scsi/scsi_cd.c Mon Jun 18 10:56:29 2012 (r237224) +++ head/sys/cam/scsi/scsi_cd.c Mon Jun 18 12:45:35 2012 (r237225) @@ -97,7 +97,6 @@ typedef enum { CD_FLAG_NEW_DISC = 0x0002, CD_FLAG_DISC_LOCKED = 0x0004, CD_FLAG_DISC_REMOVABLE = 0x0008, - CD_FLAG_TAGGED_QUEUING = 0x0010, CD_FLAG_CHANGER = 0x0040, CD_FLAG_ACTIVE = 0x0080, CD_FLAG_SCHED_ON_COMP = 0x0100, @@ -653,8 +652,6 @@ cdregister(struct cam_periph *periph, vo bioq_init(&softc->bio_queue); if (SID_IS_REMOVABLE(&cgd->inq_data)) softc->flags |= CD_FLAG_DISC_REMOVABLE; - if ((cgd->inq_data.flags & SID_CmdQue) != 0) - softc->flags |= CD_FLAG_TAGGED_QUEUING; periph->softc = softc; softc->periph = periph; Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Mon Jun 18 10:56:29 2012 (r237224) +++ head/sys/cam/scsi/scsi_da.c Mon Jun 18 12:45:35 2012 (r237225) @@ -77,7 +77,6 @@ typedef enum { DA_FLAG_NEW_PACK = 0x002, DA_FLAG_PACK_LOCKED = 0x004, DA_FLAG_PACK_REMOVABLE = 0x008, - DA_FLAG_TAGGED_QUEUING = 0x010, DA_FLAG_NEED_OTAG = 0x020, DA_FLAG_WENT_IDLE = 0x040, DA_FLAG_RETRY_UA = 0x080, @@ -1540,8 +1539,6 @@ daregister(struct cam_periph *periph, vo bioq_init(&softc->delete_run_queue); if (SID_IS_REMOVABLE(&cgd->inq_data)) softc->flags |= DA_FLAG_PACK_REMOVABLE; - if ((cgd->inq_data.flags & SID_CmdQue) != 0) - softc->flags |= DA_FLAG_TAGGED_QUEUING; softc->unmap_max_ranges = UNMAP_MAX_RANGES; softc->unmap_max_lba = 1024*1024*2; From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 13:50:41 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E4D201065672; Mon, 18 Jun 2012 13:50:41 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CEC208FC08; Mon, 18 Jun 2012 13:50:41 +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 q5IDofEU082369; Mon, 18 Jun 2012 13:50:41 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5IDoflP082367; Mon, 18 Jun 2012 13:50:41 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201206181350.q5IDoflP082367@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Mon, 18 Jun 2012 13:50:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237226 - head/sys/netgraph/netflow X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 13:50:42 -0000 Author: melifaro Date: Mon Jun 18 13:50:41 2012 New Revision: 237226 URL: http://svn.freebsd.org/changeset/base/237226 Log: Simplify IP pointer recovery in case of mbuf reallocation. Reviewed by: glebius (previous version) Approved by: ae(mentor) MFC after: 2 weeks Modified: head/sys/netgraph/netflow/ng_netflow.c Modified: head/sys/netgraph/netflow/ng_netflow.c ============================================================================== --- head/sys/netgraph/netflow/ng_netflow.c Mon Jun 18 12:45:35 2012 (r237225) +++ head/sys/netgraph/netflow/ng_netflow.c Mon Jun 18 13:50:41 2012 (r237226) @@ -560,8 +560,8 @@ ng_netflow_rcvdata (hook_p hook, item_p struct ip6_hdr *ip6 = NULL; struct m_tag *mtag; int pullup_len = 0, off; - uint8_t upper_proto = 0, is_frag = 0; - int error = 0, bypass = 0, acct = 0; + uint8_t acct = 0, bypass = 0, is_frag = 0, upper_proto = 0; + int error = 0, l3_off = 0; unsigned int src_if_index; caddr_t upper_ptr = NULL; fib_export_p fe; @@ -666,6 +666,7 @@ ng_netflow_rcvdata (hook_p hook, item_p M_CHECK(sizeof(struct ip)); eh = mtod(m, struct ether_header *); ip = (struct ip *)(eh + 1); + l3_off = sizeof(struct ether_header); break; #ifdef INET6 case ETHERTYPE_IPV6: @@ -676,6 +677,7 @@ ng_netflow_rcvdata (hook_p hook, item_p M_CHECK(sizeof(struct ip6_hdr)); eh = mtod(m, struct ether_header *); ip6 = (struct ip6_hdr *)(eh + 1); + l3_off = sizeof(struct ether_header); break; #endif case ETHERTYPE_VLAN: @@ -686,6 +688,7 @@ ng_netflow_rcvdata (hook_p hook, item_p sizeof(struct ether_header)); evh = mtod(m, struct ether_vlan_header *); etype = ntohs(evh->evl_proto); + l3_off = sizeof(struct ether_vlan_header); if (etype == ETHERTYPE_IP) { M_CHECK(sizeof(struct ip)); @@ -707,6 +710,7 @@ ng_netflow_rcvdata (hook_p hook, item_p case DLT_RAW: /* IP packets */ M_CHECK(sizeof(struct ip)); ip = mtod(m, struct ip *); + /* l3_off is already zero */ #ifdef INET6 /* If INET6 is not defined IPv6 packets will be discarded in ng_netflow_flow_add() */ if (ip->ip_v == IP6VERSION) { @@ -824,7 +828,10 @@ ng_netflow_rcvdata (hook_p hook, item_p case IPPROTO_NONE: goto loopend; #endif - /* Any unknow header (new extension or IPv6/IPv4 header for tunnels) */ + /* + * Any unknow header (new extension or IPv6/IPv4 + * header for tunnels) ends loop. + */ default: goto loopend; } @@ -842,56 +849,11 @@ loopend: /* Just in case of real reallocation in M_CHECK() / m_pullup() */ if (m != m_old) { atomic_fetchadd_32(&priv->info.nfinfo_realloc_mbuf, 1); - ip = NULL; - ip6 = NULL; - switch (iface->info.ifinfo_dlt) { - case DLT_EN10MB: /* Ethernet */ - { - struct ether_header *eh; - - eh = mtod(m, struct ether_header *); - switch (ntohs(eh->ether_type)) { - case ETHERTYPE_IP: - ip = (struct ip *)(eh + 1); - break; -#ifdef INET6 - case ETHERTYPE_IPV6: - ip6 = (struct ip6_hdr *)(eh + 1); - break; -#endif - case ETHERTYPE_VLAN: - { - struct ether_vlan_header *evh; - - evh = mtod(m, struct ether_vlan_header *); - if (ntohs(evh->evl_proto) == ETHERTYPE_IP) { - ip = (struct ip *)(evh + 1); - break; -#ifdef INET6 - } else if (ntohs(evh->evl_proto) == ETHERTYPE_IPV6) { - ip6 = (struct ip6_hdr *)(evh + 1); - break; -#endif - } - } - default: - panic("ng_netflow entered deadcode"); - } - break; - } - case DLT_RAW: /* IP packets */ - ip = mtod(m, struct ip *); -#ifdef INET6 - if (ip->ip_v == IP6VERSION) { - /* IPv6 packet */ - ip = NULL; - ip6 = mtod(m, struct ip6_hdr *); - } -#endif - break; - default: - panic("ng_netflow entered deadcode"); - } + /* Restore ip/ipv6 pointer */ + if (ip != NULL) + ip = (struct ip *)(mtod(m, caddr_t) + l3_off); + else if (ip6 != NULL) + ip6 = (struct ip6_hdr *)(mtod(m, caddr_t) + l3_off); } upper_ptr = (caddr_t)(mtod(m, caddr_t) + off); From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 13:56:36 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B2DBC1065673; Mon, 18 Jun 2012 13:56:36 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9C6B78FC16; Mon, 18 Jun 2012 13:56: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 q5IDua2h082646; Mon, 18 Jun 2012 13:56:36 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5IDuaIf082641; Mon, 18 Jun 2012 13:56:36 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201206181356.q5IDuaIf082641@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Mon, 18 Jun 2012 13:56:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237227 - in head: share/man/man4 sys/netgraph/netflow X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 13:56:36 -0000 Author: melifaro Date: Mon Jun 18 13:56:36 2012 New Revision: 237227 URL: http://svn.freebsd.org/changeset/base/237227 Log: Make radix lookup on src and dst flow addresses optional and configurable on per-interface basis. Remove __inline__ for several functions being called once per flow (e.g once per 10-20 packets on common traffic flows). Update manual page to simplify search for BPF data link types. Sponsored by Yandex LLC Reviewed by: glebius Approved by: ae(mentor) MFC after: 2 weeks Modified: head/share/man/man4/ng_netflow.4 head/sys/netgraph/netflow/netflow.c head/sys/netgraph/netflow/ng_netflow.c head/sys/netgraph/netflow/ng_netflow.h Modified: head/share/man/man4/ng_netflow.4 ============================================================================== --- head/share/man/man4/ng_netflow.4 Mon Jun 18 13:50:41 2012 (r237226) +++ head/share/man/man4/ng_netflow.4 Mon Jun 18 13:56:36 2012 (r237227) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 2, 2011 +.Dd June 16, 2012 .Dt NG_NETFLOW 4 .Os .Sh NAME @@ -112,7 +112,18 @@ The hook number is passed as an argument Sets data link type on the .Va iface Ns Ar N hook. -Currently, supported types are raw IP datagrams and Ethernet. +Currently, supported types are +.Cm DLT_RAW +(raw IP datagrams) and +.Cm DLT_EN10MB +(Ethernet). +DLT_ definitions can be found in +.In net/bpf.h +header. +Currently used values are 1 for +.Cm DLT_EN10MB +and 12 for +.Cm DLT_RAW . This message type uses .Vt "struct ng_netflow_setdlt" as an argument: @@ -180,18 +191,36 @@ struct ng_netflow_setconfig { #define NG_NETFLOW_CONF_EGRESS 2 #define NG_NETFLOW_CONF_ONCE 4 #define NG_NETFLOW_CONF_THISONCE 8 +#define NG_NETFLOW_CONF_NOSRCLOOKUP 16 +#define NG_NETFLOW_CONF_NODSTLOOKUP 32 }; .Ed .Pp Configuration is a bitmask of several options. Option NG_NETFLOW_CONF_INGRESS enabled by default enables ingress NetFlow generation (for data coming from -ifaceX hook). Option NG_NETFLOW_CONF_EGRESS enables egress NetFlow (for data -coming from outX hook). Option NG_NETFLOW_CONF_ONCE defines that packet should -be accounted only once if it several times passes via netflow node. Option -NG_NETFLOW_CONF_THISONCE defines that packet should be accounted only once -if it several times passes via exactly this netflow node. Last two options are -important to avoid duplicate accounting when both ingress and egress NetFlow -are enabled. +ifaceX hook). +Option +.Va NG_NETFLOW_CONF_EGRESS +enables egress NetFlow (for data coming from outX hook). +Option +.Va NG_NETFLOW_CONF_ONCE +defines that packet should be accounted only once if it several times passes +via netflow node. +Option +.Va NG_NETFLOW_CONF_THISONCE +defines that packet should be accounted only once if it several times passes +via exactly this netflow node. +These two options are important to avoid duplicate accounting when both ingress +and egress NetFlow are enabled. +Option +.Va NG_NETFLOW_CONF_NOSRCLOOKUP +skips radix lookup on flow source address used to fill in network mask. +Option +.Va NG_NETFLOW_CONF_NODSTLOOKUP +skips radix lookup on destination (which fills egress interface id, destination +mask and gateway). +If one doesn't need data provided by lookups, he/she can disable them, to reduce +load on routers. .It Dv NGM_NETFLOW_SETTEMPLATE Sets various timeouts to announce data flow templates (NetFlow v9-specific). This message requires Modified: head/sys/netgraph/netflow/netflow.c ============================================================================== --- head/sys/netgraph/netflow/netflow.c Mon Jun 18 13:50:41 2012 (r237226) +++ head/sys/netgraph/netflow/netflow.c Mon Jun 18 13:56:36 2012 (r237227) @@ -98,9 +98,9 @@ MALLOC_DEFINE(M_NETFLOW_HASH, "netflow_h static int export_add(item_p, struct flow_entry *); static int export_send(priv_p, fib_export_p, item_p, int); -static int hash_insert(priv_p, struct flow_hash_entry *, struct flow_rec *, int, uint8_t); +static int hash_insert(priv_p, struct flow_hash_entry *, struct flow_rec *, int, uint8_t, uint8_t); #ifdef INET6 -static int hash6_insert(priv_p, struct flow_hash_entry *, struct flow6_rec *, int, uint8_t); +static int hash6_insert(priv_p, struct flow_hash_entry *, struct flow6_rec *, int, uint8_t, uint8_t); #endif static __inline void expire_flow(priv_p, fib_export_p, struct flow_entry *, int); @@ -325,9 +325,9 @@ ng_netflow_copyinfo(priv_p priv, struct * as this was done in previous version. Need to test & profile * to be sure. */ -static __inline int +static int hash_insert(priv_p priv, struct flow_hash_entry *hsh, struct flow_rec *r, - int plen, uint8_t tcp_flags) + int plen, uint8_t flags, uint8_t tcp_flags) { struct flow_entry *fle; struct sockaddr_in sin; @@ -358,44 +358,48 @@ hash_insert(priv_p priv, struct flow_has * First we do route table lookup on destination address. So we can * fill in out_ifx, dst_mask, nexthop, and dst_as in future releases. */ - bzero(&sin, sizeof(sin)); - sin.sin_len = sizeof(struct sockaddr_in); - sin.sin_family = AF_INET; - sin.sin_addr = fle->f.r.r_dst; - rt = rtalloc1_fib((struct sockaddr *)&sin, 0, 0, r->fib); - if (rt != NULL) { - fle->f.fle_o_ifx = rt->rt_ifp->if_index; - - if (rt->rt_flags & RTF_GATEWAY && - rt->rt_gateway->sa_family == AF_INET) - fle->f.next_hop = - ((struct sockaddr_in *)(rt->rt_gateway))->sin_addr; - - if (rt_mask(rt)) - fle->f.dst_mask = bitcount32(((struct sockaddr_in *) - rt_mask(rt))->sin_addr.s_addr); - else if (rt->rt_flags & RTF_HOST) - /* Give up. We can't determine mask :( */ - fle->f.dst_mask = 32; + if ((flags & NG_NETFLOW_CONF_NODSTLOOKUP) == 0) { + bzero(&sin, sizeof(sin)); + sin.sin_len = sizeof(struct sockaddr_in); + sin.sin_family = AF_INET; + sin.sin_addr = fle->f.r.r_dst; + rt = rtalloc1_fib((struct sockaddr *)&sin, 0, 0, r->fib); + if (rt != NULL) { + fle->f.fle_o_ifx = rt->rt_ifp->if_index; + + if (rt->rt_flags & RTF_GATEWAY && + rt->rt_gateway->sa_family == AF_INET) + fle->f.next_hop = + ((struct sockaddr_in *)(rt->rt_gateway))->sin_addr; + + if (rt_mask(rt)) + fle->f.dst_mask = bitcount32(((struct sockaddr_in *) + rt_mask(rt))->sin_addr.s_addr); + else if (rt->rt_flags & RTF_HOST) + /* Give up. We can't determine mask :( */ + fle->f.dst_mask = 32; - RTFREE_LOCKED(rt); + RTFREE_LOCKED(rt); + } } /* Do route lookup on source address, to fill in src_mask. */ - bzero(&sin, sizeof(sin)); - sin.sin_len = sizeof(struct sockaddr_in); - sin.sin_family = AF_INET; - sin.sin_addr = fle->f.r.r_src; - rt = rtalloc1_fib((struct sockaddr *)&sin, 0, 0, r->fib); - if (rt != NULL) { - if (rt_mask(rt)) - fle->f.src_mask = bitcount32(((struct sockaddr_in *) - rt_mask(rt))->sin_addr.s_addr); - else if (rt->rt_flags & RTF_HOST) - /* Give up. We can't determine mask :( */ - fle->f.src_mask = 32; + if ((flags & NG_NETFLOW_CONF_NOSRCLOOKUP) == 0) { + bzero(&sin, sizeof(sin)); + sin.sin_len = sizeof(struct sockaddr_in); + sin.sin_family = AF_INET; + sin.sin_addr = fle->f.r.r_src; + rt = rtalloc1_fib((struct sockaddr *)&sin, 0, 0, r->fib); + if (rt != NULL) { + if (rt_mask(rt)) + fle->f.src_mask = bitcount32(((struct sockaddr_in *) + rt_mask(rt))->sin_addr.s_addr); + else if (rt->rt_flags & RTF_HOST) + /* Give up. We can't determine mask :( */ + fle->f.src_mask = 32; - RTFREE_LOCKED(rt); + RTFREE_LOCKED(rt); + } } /* Push new flow at the and of hash. */ @@ -410,10 +414,10 @@ hash_insert(priv_p priv, struct flow_has bitcount32((x).__u6_addr.__u6_addr32[1]) + \ bitcount32((x).__u6_addr.__u6_addr32[2]) + \ bitcount32((x).__u6_addr.__u6_addr32[3]) -/* XXX: Do we need inline here ? */ -static __inline int +#define RT_MASK6(x) (ipv6_masklen(((struct sockaddr_in6 *)rt_mask(x))->sin6_addr)) +static int hash6_insert(priv_p priv, struct flow_hash_entry *hsh6, struct flow6_rec *r, - int plen, uint8_t tcp_flags) + int plen, uint8_t flags, uint8_t tcp_flags) { struct flow6_entry *fle6; struct sockaddr_in6 *src, *dst; @@ -445,49 +449,55 @@ hash6_insert(priv_p priv, struct flow_ha * First we do route table lookup on destination address. So we can * fill in out_ifx, dst_mask, nexthop, and dst_as in future releases. */ - bzero(&rin6, sizeof(struct route_in6)); - dst = (struct sockaddr_in6 *)&rin6.ro_dst; - dst->sin6_len = sizeof(struct sockaddr_in6); - dst->sin6_family = AF_INET6; - dst->sin6_addr = r->dst.r_dst6; - - rin6.ro_rt = rtalloc1_fib((struct sockaddr *)dst, 0, 0, r->fib); - - if (rin6.ro_rt != NULL) { - rt = rin6.ro_rt; - fle6->f.fle_o_ifx = rt->rt_ifp->if_index; - - if (rt->rt_flags & RTF_GATEWAY && - rt->rt_gateway->sa_family == AF_INET6) - fle6->f.n.next_hop6 = - ((struct sockaddr_in6 *)(rt->rt_gateway))->sin6_addr; - - if (rt_mask(rt)) - fle6->f.dst_mask = ipv6_masklen(((struct sockaddr_in6 *)rt_mask(rt))->sin6_addr); - else - fle6->f.dst_mask = 128; + if ((flags & NG_NETFLOW_CONF_NODSTLOOKUP) == 0) + { + bzero(&rin6, sizeof(struct route_in6)); + dst = (struct sockaddr_in6 *)&rin6.ro_dst; + dst->sin6_len = sizeof(struct sockaddr_in6); + dst->sin6_family = AF_INET6; + dst->sin6_addr = r->dst.r_dst6; + + rin6.ro_rt = rtalloc1_fib((struct sockaddr *)dst, 0, 0, r->fib); + + if (rin6.ro_rt != NULL) { + rt = rin6.ro_rt; + fle6->f.fle_o_ifx = rt->rt_ifp->if_index; + + if (rt->rt_flags & RTF_GATEWAY && + rt->rt_gateway->sa_family == AF_INET6) + fle6->f.n.next_hop6 = + ((struct sockaddr_in6 *)(rt->rt_gateway))->sin6_addr; - RTFREE_LOCKED(rt); + if (rt_mask(rt)) + fle6->f.dst_mask = RT_MASK6(rt); + else + fle6->f.dst_mask = 128; + + RTFREE_LOCKED(rt); + } } - /* Do route lookup on source address, to fill in src_mask. */ - bzero(&rin6, sizeof(struct route_in6)); - src = (struct sockaddr_in6 *)&rin6.ro_dst; - src->sin6_len = sizeof(struct sockaddr_in6); - src->sin6_family = AF_INET6; - src->sin6_addr = r->src.r_src6; - - rin6.ro_rt = rtalloc1_fib((struct sockaddr *)src, 0, 0, r->fib); - - if (rin6.ro_rt != NULL) { - rt = rin6.ro_rt; - - if (rt_mask(rt)) - fle6->f.src_mask = ipv6_masklen(((struct sockaddr_in6 *)rt_mask(rt))->sin6_addr); - else - fle6->f.src_mask = 128; + if ((flags & NG_NETFLOW_CONF_NODSTLOOKUP) == 0) + { + /* Do route lookup on source address, to fill in src_mask. */ + bzero(&rin6, sizeof(struct route_in6)); + src = (struct sockaddr_in6 *)&rin6.ro_dst; + src->sin6_len = sizeof(struct sockaddr_in6); + src->sin6_family = AF_INET6; + src->sin6_addr = r->src.r_src6; + + rin6.ro_rt = rtalloc1_fib((struct sockaddr *)src, 0, 0, r->fib); + + if (rin6.ro_rt != NULL) { + rt = rin6.ro_rt; - RTFREE_LOCKED(rt); + if (rt_mask(rt)) + fle6->f.src_mask = RT_MASK6(rt); + else + fle6->f.src_mask = 128; + + RTFREE_LOCKED(rt); + } } /* Push new flow at the and of hash. */ @@ -495,6 +505,8 @@ hash6_insert(priv_p priv, struct flow_ha return (0); } +#undef ipv6_masklen +#undef RT_MASK6 #endif @@ -651,7 +663,7 @@ ng_netflow_cache_flush(priv_p priv) /* Insert packet from into flow cache. */ int ng_netflow_flow_add(priv_p priv, fib_export_p fe, struct ip *ip, caddr_t upper_ptr, uint8_t upper_proto, - uint8_t is_frag, unsigned int src_if_index) + uint8_t flags, unsigned int src_if_index) { register struct flow_entry *fle, *fle1; struct flow_hash_entry *hsh; @@ -770,7 +782,7 @@ ng_netflow_flow_add(priv_p priv, fib_exp } } } else /* A new flow entry. */ - error = hash_insert(priv, hsh, &r, plen, tcp_flags); + error = hash_insert(priv, hsh, &r, plen, flags, tcp_flags); mtx_unlock(&hsh->mtx); @@ -781,7 +793,7 @@ ng_netflow_flow_add(priv_p priv, fib_exp /* Insert IPv6 packet from into flow cache. */ int ng_netflow_flow6_add(priv_p priv, fib_export_p fe, struct ip6_hdr *ip6, caddr_t upper_ptr, uint8_t upper_proto, - uint8_t is_frag, unsigned int src_if_index) + uint8_t flags, unsigned int src_if_index) { register struct flow_entry *fle = NULL, *fle1; register struct flow6_entry *fle6; @@ -811,7 +823,7 @@ ng_netflow_flow6_add(priv_p priv, fib_ex #if 0 r.r_tos = ip->ip_tos; #endif - if (is_frag == 0) { + if ((flags & NG_NETFLOW_IS_FRAG) == 0) { switch(upper_proto) { case IPPROTO_TCP: { @@ -896,7 +908,7 @@ ng_netflow_flow6_add(priv_p priv, fib_ex } } } else /* A new flow entry. */ - error = hash6_insert(priv, hsh, &r, plen, tcp_flags); + error = hash6_insert(priv, hsh, &r, plen, flags, tcp_flags); mtx_unlock(&hsh->mtx); Modified: head/sys/netgraph/netflow/ng_netflow.c ============================================================================== --- head/sys/netgraph/netflow/ng_netflow.c Mon Jun 18 13:50:41 2012 (r237226) +++ head/sys/netgraph/netflow/ng_netflow.c Mon Jun 18 13:56:36 2012 (r237227) @@ -560,7 +560,7 @@ ng_netflow_rcvdata (hook_p hook, item_p struct ip6_hdr *ip6 = NULL; struct m_tag *mtag; int pullup_len = 0, off; - uint8_t acct = 0, bypass = 0, is_frag = 0, upper_proto = 0; + uint8_t acct = 0, bypass = 0, flags = 0, upper_proto = 0; int error = 0, l3_off = 0; unsigned int src_if_index; caddr_t upper_ptr = NULL; @@ -619,6 +619,9 @@ ng_netflow_rcvdata (hook_p hook, item_p } } + /* Import configuration flags related to flow creation */ + flags = iface->info.conf & NG_NETFLOW_FLOW_FLAGS; + NGI_GET_M(item, m); m_old = m; @@ -759,7 +762,7 @@ ng_netflow_rcvdata (hook_p hook, item_p } } else if (ip != NULL) { /* Nothing to save except upper layer proto, since this is packet fragment */ - is_frag = 1; + flags |= NG_NETFLOW_IS_FRAG; upper_proto = ip->ip_p; if ((ip->ip_v != IPVERSION) || ((ip->ip_hl << 2) < sizeof(struct ip))) @@ -821,7 +824,7 @@ ng_netflow_rcvdata (hook_p hook, item_p upper_proto = ip6f->ip6f_nxt; hdr_off = sizeof(struct ip6_frag); off += hdr_off; - is_frag = 1; + flags |= NG_NETFLOW_IS_FRAG; goto loopend; #if 0 @@ -886,10 +889,10 @@ loopend: } if (ip != NULL) - error = ng_netflow_flow_add(priv, fe, ip, upper_ptr, upper_proto, is_frag, src_if_index); + error = ng_netflow_flow_add(priv, fe, ip, upper_ptr, upper_proto, flags, src_if_index); #ifdef INET6 else if (ip6 != NULL) - error = ng_netflow_flow6_add(priv, fe, ip6, upper_ptr, upper_proto, is_frag, src_if_index); + error = ng_netflow_flow6_add(priv, fe, ip6, upper_ptr, upper_proto, flags, src_if_index); #endif else goto bypass; Modified: head/sys/netgraph/netflow/ng_netflow.h ============================================================================== --- head/sys/netgraph/netflow/ng_netflow.h Mon Jun 18 13:50:41 2012 (r237226) +++ head/sys/netgraph/netflow/ng_netflow.h Mon Jun 18 13:56:36 2012 (r237227) @@ -111,10 +111,16 @@ struct ng_netflow_settimeouts { uint32_t active_timeout; /* flow active timeout */ }; -#define NG_NETFLOW_CONF_INGRESS 1 -#define NG_NETFLOW_CONF_EGRESS 2 -#define NG_NETFLOW_CONF_ONCE 4 -#define NG_NETFLOW_CONF_THISONCE 8 +#define NG_NETFLOW_CONF_INGRESS 0x01 /* Account on ingress */ +#define NG_NETFLOW_CONF_EGRESS 0x02 /* Account on egress */ +#define NG_NETFLOW_CONF_ONCE 0x04 /* Add tag to account only once */ +#define NG_NETFLOW_CONF_THISONCE 0x08 /* Account once in current node */ +#define NG_NETFLOW_CONF_NOSRCLOOKUP 0x10 /* No radix lookup on src */ +#define NG_NETFLOW_CONF_NODSTLOOKUP 0x20 /* No radix lookup on dst */ + +#define NG_NETFLOW_IS_FRAG 0x01 +#define NG_NETFLOW_FLOW_FLAGS (NG_NETFLOW_CONF_NOSRCLOOKUP|\ + NG_NETFLOW_CONF_NODSTLOOKUP) /* This structure is passed to NGM_NETFLOW_SETCONFIG */ struct ng_netflow_setconfig { From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 16:22:00 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B1ECD106564A; Mon, 18 Jun 2012 16:22:00 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8FAD68FC08; Mon, 18 Jun 2012 16:22:00 +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 q5IGM0lS088515; Mon, 18 Jun 2012 16:22:00 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5IGM0TP088511; Mon, 18 Jun 2012 16:22:00 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201206181622.q5IGM0TP088511@svn.freebsd.org> From: Alan Cox Date: Mon, 18 Jun 2012 16:22:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237228 - head/sys/amd64/amd64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 16:22:00 -0000 Author: alc Date: Mon Jun 18 16:21:59 2012 New Revision: 237228 URL: http://svn.freebsd.org/changeset/base/237228 Log: Add PV chunk and list locking to pmap_page_exists_quick(), pmap_page_is_mapped(), and pmap_remove_pages(). These functions are no longer serialized by the pvh global lock. Modified: head/sys/amd64/amd64/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Mon Jun 18 13:56:36 2012 (r237227) +++ head/sys/amd64/amd64/pmap.c Mon Jun 18 16:21:59 2012 (r237228) @@ -168,6 +168,14 @@ __FBSDID("$FreeBSD$"); #define pa_index(pa) ((pa) >> PDRSHIFT) #define pa_to_pvh(pa) (&pv_table[pa_index(pa)]) +#define NPV_LIST_LOCKS MAXCPU + +#define PHYS_TO_PV_LIST_LOCK(pa) \ + (&pv_list_locks[pa_index(pa) % NPV_LIST_LOCKS]) + +#define VM_PAGE_TO_PV_LIST_LOCK(m) \ + PHYS_TO_PV_LIST_LOCK(VM_PAGE_TO_PHYS(m)) + struct pmap kernel_pmap_store; vm_offset_t virtual_avail; /* VA of first avail page (after kernel bss) */ @@ -214,7 +222,8 @@ static struct { * Data for the pv entry allocation mechanism */ static TAILQ_HEAD(pch, pv_chunk) pv_chunks = TAILQ_HEAD_INITIALIZER(pv_chunks); -static long pv_entry_count; +static struct mtx pv_chunks_mutex; +static struct rwlock pv_list_locks[NPV_LIST_LOCKS]; static struct md_page *pv_table; /* @@ -763,6 +772,17 @@ pmap_init(void) } /* + * Initialize the pv chunk list mutex. + */ + mtx_init(&pv_chunks_mutex, "pv chunk list", NULL, MTX_DEF); + + /* + * Initialize the pool of pv list locks. + */ + for (i = 0; i < NPV_LIST_LOCKS; i++) + rw_init(&pv_list_locks[i], "pv list"); + + /* * Calculate the size of the pv head table for superpages. */ for (i = 0; phys_avail[i + 1]; i += 2); @@ -2023,6 +2043,7 @@ pv_to_chunk(pv_entry_t pv) static const uint64_t pc_freemask[_NPCM] = { PC_FREE0, PC_FREE1, PC_FREE2 }; +static long pv_entry_count; SYSCTL_LONG(_vm_pmap, OID_AUTO, pv_entry_count, CTLFLAG_RD, &pv_entry_count, 0, "Current number of pv entries"); @@ -2215,10 +2236,12 @@ free_pv_chunk(struct pv_chunk *pc) { vm_page_t m; + mtx_lock(&pv_chunks_mutex); TAILQ_REMOVE(&pv_chunks, pc, pc_lru); - PV_STAT(pv_entry_spare -= _NPCPV); - PV_STAT(pc_chunk_count--); - PV_STAT(pc_chunk_frees++); + mtx_unlock(&pv_chunks_mutex); + PV_STAT(atomic_subtract_int(&pv_entry_spare, _NPCPV)); + PV_STAT(atomic_subtract_int(&pc_chunk_count, 1)); + PV_STAT(atomic_add_int(&pc_chunk_frees, 1)); /* entire chunk is free, return it */ m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pc)); dump_drop_page(m->phys_addr); @@ -4000,6 +4023,7 @@ boolean_t pmap_page_exists_quick(pmap_t pmap, vm_page_t m) { struct md_page *pvh; + struct rwlock *lock; pv_entry_t pv; int loops = 0; boolean_t rv; @@ -4007,7 +4031,9 @@ pmap_page_exists_quick(pmap_t pmap, vm_p KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("pmap_page_exists_quick: page %p is not managed", m)); rv = FALSE; - rw_wlock(&pvh_global_lock); + rw_rlock(&pvh_global_lock); + lock = VM_PAGE_TO_PV_LIST_LOCK(m); + rw_rlock(lock); TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) { if (PV_PMAP(pv) == pmap) { rv = TRUE; @@ -4029,7 +4055,8 @@ pmap_page_exists_quick(pmap_t pmap, vm_p break; } } - rw_wunlock(&pvh_global_lock); + rw_runlock(lock); + rw_runlock(&pvh_global_lock); return (rv); } @@ -4088,15 +4115,19 @@ pmap_pvh_wired_mappings(struct md_page * boolean_t pmap_page_is_mapped(vm_page_t m) { + struct rwlock *lock; boolean_t rv; if ((m->oflags & VPO_UNMANAGED) != 0) return (FALSE); - rw_wlock(&pvh_global_lock); + rw_rlock(&pvh_global_lock); + lock = VM_PAGE_TO_PV_LIST_LOCK(m); + rw_rlock(lock); rv = !TAILQ_EMPTY(&m->md.pv_list) || ((m->flags & PG_FICTITIOUS) == 0 && !TAILQ_EMPTY(&pa_to_pvh(VM_PAGE_TO_PHYS(m))->pv_list)); - rw_wunlock(&pvh_global_lock); + rw_runlock(lock); + rw_runlock(&pvh_global_lock); return (rv); } @@ -4118,19 +4149,21 @@ pmap_remove_pages(pmap_t pmap) pv_entry_t pv; struct md_page *pvh; struct pv_chunk *pc, *npc; - int field, idx; + struct rwlock *lock, *new_lock; int64_t bit; uint64_t inuse, bitmask; - int allfree; + int allfree, field, freed, idx; if (pmap != PCPU_GET(curpmap)) { printf("warning: pmap_remove_pages called with non-current pmap\n"); return; } - rw_wlock(&pvh_global_lock); + rw_rlock(&pvh_global_lock); PMAP_LOCK(pmap); + lock = NULL; TAILQ_FOREACH_SAFE(pc, &pmap->pm_pvchunk, pc_list, npc) { allfree = 1; + freed = 0; for (field = 0; field < _NPCM; field++) { inuse = ~pc->pc_map[field] & pc_freemask[field]; while (inuse != 0) { @@ -4186,10 +4219,15 @@ pmap_remove_pages(pmap_t pmap) vm_page_dirty(m); } + new_lock = VM_PAGE_TO_PV_LIST_LOCK(m); + if (new_lock != lock) { + if (lock != NULL) + rw_wunlock(lock); + lock = new_lock; + rw_wlock(lock); + } + /* Mark free */ - PV_STAT(pv_entry_frees++); - PV_STAT(pv_entry_spare++); - pv_entry_count--; pc->pc_map[field] |= bitmask; if ((tpte & PG_PS) != 0) { pmap_resident_count_dec(pmap, NBPDR / PAGE_SIZE); @@ -4223,15 +4261,25 @@ pmap_remove_pages(pmap_t pmap) } } pmap_unuse_pt(pmap, pv->pv_va, ptepde, &free); + freed++; } } + PV_STAT(atomic_add_long(&pv_entry_frees, freed)); + PV_STAT(atomic_add_int(&pv_entry_spare, freed)); + atomic_subtract_long(&pv_entry_count, freed); if (allfree) { + if (lock != NULL) { + rw_wunlock(lock); + lock = NULL; + } TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); free_pv_chunk(pc); } } + if (lock != NULL) + rw_wunlock(lock); pmap_invalidate_all(pmap); - rw_wunlock(&pvh_global_lock); + rw_runlock(&pvh_global_lock); PMAP_UNLOCK(pmap); pmap_free_zero_pages(free); } From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 17:09:40 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 46EF8106566B; Mon, 18 Jun 2012 17:09:40 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 18CF28FC12; Mon, 18 Jun 2012 17:09:40 +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 q5IH9dff090603; Mon, 18 Jun 2012 17:09:39 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5IH9dxd090601; Mon, 18 Jun 2012 17:09:39 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201206181709.q5IH9dxd090601@svn.freebsd.org> From: Michael Tuexen Date: Mon, 18 Jun 2012 17:09:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237229 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 17:09:40 -0000 Author: tuexen Date: Mon Jun 18 17:09:39 2012 New Revision: 237229 URL: http://svn.freebsd.org/changeset/base/237229 Log: Cleanup the UDP decapsulation code. MFC after: 3 days Modified: head/sys/netinet/sctputil.c Modified: head/sys/netinet/sctputil.c ============================================================================== --- head/sys/netinet/sctputil.c Mon Jun 18 16:21:59 2012 (r237228) +++ head/sys/netinet/sctputil.c Mon Jun 18 17:09:39 2012 (r237229) @@ -6837,83 +6837,61 @@ sctp_recv_udp_tunneled_packet(struct mbu struct ip *iph; struct mbuf *sp, *last; struct udphdr *uhdr; - uint16_t port = 0; - int header_size = sizeof(struct udphdr) + sizeof(struct sctphdr); + uint16_t port; - /* - * Split out the mbuf chain. Leave the IP header in m, place the - * rest in the sp. - */ if ((m->m_flags & M_PKTHDR) == 0) { /* Can't handle one that is not a pkt hdr */ goto out; } - /* pull the src port */ + /* Pull the src port */ iph = mtod(m, struct ip *); uhdr = (struct udphdr *)((caddr_t)iph + off); - port = uhdr->uh_sport; + /* + * Split out the mbuf chain. Leave the IP header in m, place the + * rest in the sp. + */ sp = m_split(m, off, M_DONTWAIT); if (sp == NULL) { /* Gak, drop packet, we can't do a split */ goto out; } - if (sp->m_pkthdr.len < header_size) { - /* Gak, packet can't have an SCTP header in it - to small */ + if (sp->m_pkthdr.len < sizeof(struct udphdr) + sizeof(struct sctphdr)) { + /* Gak, packet can't have an SCTP header in it - too small */ m_freem(sp); goto out; } - /* ok now pull up the UDP header and SCTP header together */ - sp = m_pullup(sp, header_size); + /* Now pull up the UDP header and SCTP header together */ + sp = m_pullup(sp, sizeof(struct udphdr) + sizeof(struct sctphdr)); if (sp == NULL) { /* Gak pullup failed */ goto out; } - /* trim out the UDP header */ + /* Trim out the UDP header */ m_adj(sp, sizeof(struct udphdr)); /* Now reconstruct the mbuf chain */ - /* 1) find last one */ - last = m; - while (last->m_next != NULL) { - last = last->m_next; - } + for (last = m; last->m_next; last = last->m_next); last->m_next = sp; m->m_pkthdr.len += sp->m_pkthdr.len; - last = m; - while (last != NULL) { - last = last->m_next; - } - /* Now its ready for sctp_input or sctp6_input */ iph = mtod(m, struct ip *); switch (iph->ip_v) { #ifdef INET case IPVERSION: - { - uint16_t len; - - /* its IPv4 */ - len = SCTP_GET_IPV4_LENGTH(iph); - len -= sizeof(struct udphdr); - SCTP_GET_IPV4_LENGTH(iph) = len; - sctp_input_with_port(m, off, port); - break; - } + iph->ip_len -= sizeof(struct udphdr); + sctp_input_with_port(m, off, port); + break; #endif #ifdef INET6 case IPV6_VERSION >> 4: - { - /* its IPv6 - NOT supported */ - goto out; - break; + /* Not yet supported. */ + goto out; + break; - } #endif default: - { - m_freem(m); - break; - } + goto out; + break; } return; out: From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 17:11:24 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D0ED4106564A; Mon, 18 Jun 2012 17:11:24 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A379A8FC12; Mon, 18 Jun 2012 17:11:24 +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 q5IHBONq090721; Mon, 18 Jun 2012 17:11:24 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5IHBO9i090717; Mon, 18 Jun 2012 17:11:24 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201206181711.q5IHBO9i090717@svn.freebsd.org> From: Michael Tuexen Date: Mon, 18 Jun 2012 17:11:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237230 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 17:11:24 -0000 Author: tuexen Date: Mon Jun 18 17:11:24 2012 New Revision: 237230 URL: http://svn.freebsd.org/changeset/base/237230 Log: Add rate limitation for SCTP OOTB responses. MFC after: 3 days Modified: head/sys/netinet/icmp_var.h head/sys/netinet/ip_icmp.c head/sys/netinet/sctp_input.c Modified: head/sys/netinet/icmp_var.h ============================================================================== --- head/sys/netinet/icmp_var.h Mon Jun 18 17:09:39 2012 (r237229) +++ head/sys/netinet/icmp_var.h Mon Jun 18 17:11:24 2012 (r237230) @@ -102,7 +102,8 @@ extern int badport_bandlim(int); #define BANDLIM_RST_CLOSEDPORT 3 /* No connection, and no listeners */ #define BANDLIM_RST_OPENPORT 4 /* No connection, listener */ #define BANDLIM_ICMP6_UNREACH 5 -#define BANDLIM_MAX 5 +#define BANDLIM_SCTP_OOTB 6 +#define BANDLIM_MAX 6 #endif #endif Modified: head/sys/netinet/ip_icmp.c ============================================================================== --- head/sys/netinet/ip_icmp.c Mon Jun 18 17:09:39 2012 (r237229) +++ head/sys/netinet/ip_icmp.c Mon Jun 18 17:11:24 2012 (r237230) @@ -965,7 +965,8 @@ badport_bandlim(int which) { "icmp tstamp response" }, { "closed port RST response" }, { "open port RST response" }, - { "icmp6 unreach response" } + { "icmp6 unreach response" }, + { "sctp ootb response" } }; /* Modified: head/sys/netinet/sctp_input.c ============================================================================== --- head/sys/netinet/sctp_input.c Mon Jun 18 17:09:39 2012 (r237229) +++ head/sys/netinet/sctp_input.c Mon Jun 18 17:11:24 2012 (r237230) @@ -6060,15 +6060,8 @@ sctp_skip_csum_4: struct sctp_init_chunk *init_chk, chunk_buf; SCTP_STAT_INCR(sctps_noport); -#ifdef ICMP_BANDLIM - /* - * we use the bandwidth limiting to protect against sending - * too many ABORTS all at once. In this case these count the - * same as an ICMP message. - */ - if (badport_bandlim(0) < 0) + if (badport_bandlim(BANDLIM_SCTP_OOTB) < 0) goto bad; -#endif /* ICMP_BANDLIM */ SCTPDBG(SCTP_DEBUG_INPUT1, "Sending a ABORT from packet entry!\n"); if (ch->chunk_type == SCTP_INITIATION) { From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 19:11:07 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CDCC41065670; Mon, 18 Jun 2012 19:11:07 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BA2828FC08; Mon, 18 Jun 2012 19:11:07 +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 q5IJB7SL095736; Mon, 18 Jun 2012 19:11:07 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5IJB7NL095734; Mon, 18 Jun 2012 19:11:07 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201206181911.q5IJB7NL095734@svn.freebsd.org> From: Marius Strobl Date: Mon, 18 Jun 2012 19:11:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237234 - head/share/man/man4 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 19:11:07 -0000 Author: marius Date: Mon Jun 18 19:11:07 2012 New Revision: 237234 URL: http://svn.freebsd.org/changeset/base/237234 Log: Avoid hard sentence break. MFC after: 3 days Modified: head/share/man/man4/ahci.4 Modified: head/share/man/man4/ahci.4 ============================================================================== --- head/share/man/man4/ahci.4 Mon Jun 18 18:25:57 2012 (r237233) +++ head/share/man/man4/ahci.4 Mon Jun 18 19:11:07 2012 (r237234) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 6, 2011 +.Dd June 18, 2012 .Dt AHCI 4 .Os .Sh NAME @@ -101,7 +101,8 @@ setting to nonzero value limits maximum Values 1, 2 and 3 are respectively 1.5, 3 and 6Gbps. .It Va hw.ahci.force setting to nonzero value forces driver attach to some known AHCI-capable -chips even if they are configured for legacy IDE emulation. Default is 1. +chips even if they are configured for legacy IDE emulation. +Default is 1. .El .Sh DESCRIPTION This driver provides the From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 19:14:07 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4F585106566B; Mon, 18 Jun 2012 19:14:07 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3B0138FC17; Mon, 18 Jun 2012 19:14:07 +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 q5IJE7p0095885; Mon, 18 Jun 2012 19:14:07 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5IJE7xR095883; Mon, 18 Jun 2012 19:14:07 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201206181914.q5IJE7xR095883@svn.freebsd.org> From: Marius Strobl Date: Mon, 18 Jun 2012 19:14:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237235 - head/share/man/man4 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 19:14:07 -0000 Author: marius Date: Mon Jun 18 19:14:06 2012 New Revision: 237235 URL: http://svn.freebsd.org/changeset/base/237235 Log: Document the hw.ahci.force tunable here, too, as it's also used by ataahci(4) and atanvidia(4). MFC after: 3 days Modified: head/share/man/man4/ata.4 Modified: head/share/man/man4/ata.4 ============================================================================== --- head/share/man/man4/ata.4 Mon Jun 18 19:11:07 2012 (r237234) +++ head/share/man/man4/ata.4 Mon Jun 18 19:14:06 2012 (r237235) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 17, 2011 +.Dd June 18, 2012 .Dt ATA 4 .Os .Sh NAME @@ -89,8 +89,12 @@ subsystem module. The following tunables are settable from the .Xr loader 8 : .Bl -ohang +.It Va hw.ahci.force +set to nonzero value for forcing drivers to attach to some known AHCI-capable +chips even if they are configured for legacy IDE emulation (the default is 1, +force the attach). .It Va hw.ata.ata_dma_check_80pin -set to 0 to disable the 80pin cable check (the default is 1, check the cable) +set to 0 to disable the 80pin cable check (the default is 1, check the cable). .It Va hint.atapci.X.msi set to 1 to allow Message Signalled Interrupts (MSI) to be used by the specified PCI ATA controller, if supported. From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 19:18:31 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DDCCD106566C; Mon, 18 Jun 2012 19:18:31 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BE7BA8FC20; Mon, 18 Jun 2012 19:18:31 +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 q5IJIVLc096104; Mon, 18 Jun 2012 19:18:31 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5IJIVjp096101; Mon, 18 Jun 2012 19:18:31 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201206181918.q5IJIVjp096101@svn.freebsd.org> From: Marius Strobl Date: Mon, 18 Jun 2012 19:18:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237236 - head/sys/dev/usb/serial X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 19:18:32 -0000 Author: marius Date: Mon Jun 18 19:18:31 2012 New Revision: 237236 URL: http://svn.freebsd.org/changeset/base/237236 Log: Refine r237102 a bit: - Anounce JTAG interfaces deliberately skipped. - Bring back empty lines too eagerly removed. MFC after: 3 days Modified: head/sys/dev/usb/serial/uftdi.c head/sys/dev/usb/serial/uftdi_reg.h Modified: head/sys/dev/usb/serial/uftdi.c ============================================================================== --- head/sys/dev/usb/serial/uftdi.c Mon Jun 18 19:14:06 2012 (r237235) +++ head/sys/dev/usb/serial/uftdi.c Mon Jun 18 19:18:31 2012 (r237236) @@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$"); */ /* - * FTDI FT8U100AX serial adapter driver + * FTDI FT2232x, FT8U100AX and FT8U232AM serial adapter driver */ #include @@ -278,9 +278,15 @@ uftdi_probe(device_t dev) */ id = usbd_lookup_id_by_info(uftdi_devs, sizeof(uftdi_devs), &uaa->info); - if (id == NULL || ((id->driver_info & UFTDI_FLAG_JTAG) != 0 && - uaa->info.bIfaceIndex == UFTDI_IFACE_INDEX_JTAG)) + if (id == NULL) return (ENXIO); + if ((id->driver_info & UFTDI_FLAG_JTAG) != 0 && + uaa->info.bIfaceIndex == UFTDI_IFACE_INDEX_JTAG) { + printf("%s: skipping JTAG interface at %u.%u\n", + device_get_name(dev), usbd_get_bus_index(uaa->device), + usbd_get_device_index(uaa->device)); + return (ENXIO); + } uaa->driver_info = id->driver_info; return (BUS_PROBE_SPECIFIC); } Modified: head/sys/dev/usb/serial/uftdi_reg.h ============================================================================== --- head/sys/dev/usb/serial/uftdi_reg.h Mon Jun 18 19:14:06 2012 (r237235) +++ head/sys/dev/usb/serial/uftdi_reg.h Mon Jun 18 19:18:31 2012 (r237236) @@ -70,6 +70,7 @@ #define FTDI_SIO_RESET_SIO 0 #define FTDI_SIO_RESET_PURGE_RX 1 #define FTDI_SIO_RESET_PURGE_TX 2 + /* * BmRequestType: 0100 0000B * bRequest: FTDI_SIO_SET_BAUDRATE @@ -133,6 +134,7 @@ enum { #define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11) #define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11) #define FTDI_SIO_SET_BREAK (0x1 << 14) + /* * BmRequestType: 0100 0000B * bRequest: FTDI_SIO_MODEM_CTRL @@ -168,6 +170,7 @@ enum { #define FTDI_SIO_SET_RTS_MASK 0x2 #define FTDI_SIO_SET_RTS_HIGH (2 | ( FTDI_SIO_SET_RTS_MASK << 8)) #define FTDI_SIO_SET_RTS_LOW (0 | ( FTDI_SIO_SET_RTS_MASK << 8)) + /* * BmRequestType: 0100 0000b * bRequest: FTDI_SIO_SET_FLOW_CTRL @@ -197,6 +200,7 @@ enum { #define FTDI_SIO_RTS_CTS_HS 0x1 #define FTDI_SIO_DTR_DSR_HS 0x2 #define FTDI_SIO_XON_XOFF_HS 0x4 + /* * BmRequestType: 0100 0000b * bRequest: FTDI_SIO_SET_EVENT_CHAR @@ -219,6 +223,7 @@ enum { * data read so far - rather than wait 40ms or until 62 bytes are read * which is what normally happens. */ + /* * BmRequestType: 0100 0000b * bRequest: FTDI_SIO_SET_ERROR_CHAR @@ -237,6 +242,7 @@ enum { * Set the parity error replacement character for the specified communications * port. */ + /* * BmRequestType: 1100 0000b * bRequest: FTDI_SIO_GET_MODEM_STATUS @@ -267,8 +273,8 @@ enum { #define FTDI_SIO_DSR_MASK 0x20 #define FTDI_SIO_RI_MASK 0x40 #define FTDI_SIO_RLSD_MASK 0x80 + /* - * * DATA FORMAT * * IN Endpoint From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 19:22:11 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 11E1D1065672; Mon, 18 Jun 2012 19:22:11 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F1C968FC16; Mon, 18 Jun 2012 19:22:10 +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 q5IJMA5h096301; Mon, 18 Jun 2012 19:22:10 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5IJMA2o096299; Mon, 18 Jun 2012 19:22:10 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201206181922.q5IJMA2o096299@svn.freebsd.org> From: Marius Strobl Date: Mon, 18 Jun 2012 19:22:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237237 - head/sys/arm/at91 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 19:22:11 -0000 Author: marius Date: Mon Jun 18 19:22:10 2012 New Revision: 237237 URL: http://svn.freebsd.org/changeset/base/237237 Log: Unbreak after r236658 by comparing the right things. Modified: head/sys/arm/at91/at91sam9260.c Modified: head/sys/arm/at91/at91sam9260.c ============================================================================== --- head/sys/arm/at91/at91sam9260.c Mon Jun 18 19:18:31 2012 (r237236) +++ head/sys/arm/at91/at91sam9260.c Mon Jun 18 19:22:10 2012 (r237237) @@ -197,7 +197,7 @@ static void at91_identify(driver_t *drv, device_t parent) { - if (soc_data.type == AT91_CPU_SAM9260) { + if (soc_data.type == AT91_T_SAM9260) { at91_add_child(parent, 0, "at91sam9260", 0, 0, 0, -1, 0, 0); at91_cpu_add_builtin_children(parent); } @@ -266,7 +266,7 @@ at91_attach(device_t dev) &sc->sc_matrix_sh) != 0) panic("Enable to map matrix registers"); - /* activate NAND*/ + /* activate NAND */ i = bus_space_read_4(sc->sc_st, sc->sc_matrix_sh, AT91SAM9260_EBICSA); bus_space_write_4(sc->sc_st, sc->sc_matrix_sh, From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 19:33:27 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4D61F106564A; Mon, 18 Jun 2012 19:33:27 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id D47148FC19; Mon, 18 Jun 2012 19:33:26 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.4/8.14.4/ALCHEMY.FRANKEN.DE) with ESMTP id q5IJXK5g099905; Mon, 18 Jun 2012 21:33:20 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.4/8.14.4/Submit) id q5IJXKos099904; Mon, 18 Jun 2012 21:33:20 +0200 (CEST) (envelope-from marius) Date: Mon, 18 Jun 2012 21:33:19 +0200 From: Marius Strobl To: Warner Losh Message-ID: <20120618193319.GD69382@alchemy.franken.de> References: <201206150837.q5F8boYj055844@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201206150837.q5F8boYj055844@svn.freebsd.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237130 - head/sys/arm/at91 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 19:33:27 -0000 On Fri, Jun 15, 2012 at 08:37:50AM +0000, Warner Losh wrote: > Author: imp > Date: Fri Jun 15 08:37:50 2012 > New Revision: 237130 > URL: http://svn.freebsd.org/changeset/base/237130 > > Log: > Make it possible to link together a sam and an rm kernel. The results > aren't very pretty yet, but this takes DELAY and cpu_reset and makes > them pointers. > > # I worry that these are set too late in the boot, especially cpu_reset. > Indeed, if we now panic before at91_rst(4) attaches, automatic reboot no longer works (seen with the bug in r236658 keeping at91sam9260(4) from probing) ... Marius From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 19:47:25 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C4E301065674; Mon, 18 Jun 2012 19:47:25 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AFA958FC17; Mon, 18 Jun 2012 19:47:25 +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 q5IJlPYR097337; Mon, 18 Jun 2012 19:47:25 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5IJlPKQ097335; Mon, 18 Jun 2012 19:47:25 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201206181947.q5IJlPKQ097335@svn.freebsd.org> From: Marius Strobl Date: Mon, 18 Jun 2012 19:47:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237238 - head/sys/arm/at91 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 19:47:25 -0000 Author: marius Date: Mon Jun 18 19:47:25 2012 New Revision: 237238 URL: http://svn.freebsd.org/changeset/base/237238 Log: Try to bring this file closer to style(9). Modified: head/sys/arm/at91/at91_machdep.c Modified: head/sys/arm/at91/at91_machdep.c ============================================================================== --- head/sys/arm/at91/at91_machdep.c Mon Jun 18 19:22:10 2012 (r237237) +++ head/sys/arm/at91/at91_machdep.c Mon Jun 18 19:47:25 2012 (r237238) @@ -92,10 +92,12 @@ __FBSDID("$FreeBSD$"); #include #include -#define KERNEL_PT_SYS 0 /* Page table for mapping proc0 zero page */ +/* Page table for mapping proc0 zero page */ +#define KERNEL_PT_SYS 0 #define KERNEL_PT_KERN 1 #define KERNEL_PT_KERN_NUM 22 -#define KERNEL_PT_AFKERNEL KERNEL_PT_KERN + KERNEL_PT_KERN_NUM /* L2 table for mapping after kernel */ +/* L2 table for mapping after kernel */ +#define KERNEL_PT_AFKERNEL KERNEL_PT_KERN + KERNEL_PT_KERN_NUM #define KERNEL_PT_AFKERNEL_NUM 5 /* this should be evenly divisable by PAGE_SIZE / L2_TABLE_SIZE_REAL (or 4) */ @@ -150,7 +152,8 @@ const struct pmap_devmap at91_devmap[] = VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, }, - /* We can't just map the OHCI registers VA == PA, because + /* + * We can't just map the OHCI registers VA == PA, because * AT91xx_xxx_BASE belongs to the userland address space. * We could just choose a different virtual address, but a better * solution would probably be to just use pmap_mapdev() to allocate @@ -180,8 +183,10 @@ const struct pmap_devmap at91_devmap[] = VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, }, - /* The next two should be good for the 9260, 9261 and 9G20 since - * addresses mapping is the same. */ + /* + * The next two should be good for the 9260, 9261 and 9G20 since + * addresses mapping is the same. + */ { /* Internal Memory 1MB */ AT91SAM9G20_OHCI_BASE, @@ -210,16 +215,18 @@ extern int memsize[]; long at91_ramsize(void) { - uint32_t cr, mr; + uint32_t cr, mr, *SDRAMC; int banks, rows, cols, bw; #ifdef LINUX_BOOT_ABI - // If we found any ATAGs that were for memory, return the first bank. + /* + * If we found any ATAGs that were for memory, return the first bank. + */ if (membanks > 0) - return memsize[0]; + return (memsize[0]); #endif if (at91_is_rm92()) { - uint32_t *SDRAMC = (uint32_t *)(AT91_BASE + AT91RM92_SDRAMC_BASE); + SDRAMC = (uint32_t *)(AT91_BASE + AT91RM92_SDRAMC_BASE); cr = SDRAMC[AT91RM92_SDRAMC_CR / 4]; mr = SDRAMC[AT91RM92_SDRAMC_MR / 4]; banks = (cr & AT91RM92_SDRAMC_CR_NB_4) ? 2 : 1; @@ -227,9 +234,11 @@ at91_ramsize(void) cols = (cr & AT91RM92_SDRAMC_CR_NC_MASK) + 8; bw = (mr & AT91RM92_SDRAMC_MR_DBW_16) ? 1 : 2; } else { - /* This should be good for the 9260, 9261, 9G20, 9G35 and 9X25 as addresses - * and registers are the same */ - uint32_t *SDRAMC = (uint32_t *)(AT91_BASE + AT91SAM9G20_SDRAMC_BASE); + /* + * This should be good for the 9260, 9261, 9G20, 9G35 and 9X25 + * as addresses and registers are the same. + */ + SDRAMC = (uint32_t *)(AT91_BASE + AT91SAM9G20_SDRAMC_BASE); cr = SDRAMC[AT91SAM9G20_SDRAMC_CR / 4]; mr = SDRAMC[AT91SAM9G20_SDRAMC_MR / 4]; banks = (cr & AT91SAM9G20_SDRAMC_CR_NB_4) ? 2 : 1; @@ -241,7 +250,7 @@ at91_ramsize(void) return (1 << (cols + rows + banks + bw)); } -const char *soc_type_name[] = { +static const char *soc_type_name[] = { [AT91_T_CAP9] = "at91cap9", [AT91_T_RM9200] = "at91rm9200", [AT91_T_SAM9260] = "at91sam9260", @@ -255,8 +264,8 @@ const char *soc_type_name[] = { [AT91_T_SAM9X5] = "at91sam9x5", [AT91_T_NONE] = "UNKNOWN" }; - -const char *soc_subtype_name[] = { + +static const char *soc_subtype_name[] = { [AT91_ST_NONE] = "UNKNOWN", [AT91_ST_RM9200_BGA] = "at91rm9200_bga", [AT91_ST_RM9200_PQFP] = "at91rm9200_pqfp", @@ -288,13 +297,15 @@ at91_try_id(uint32_t dbgu_base) { uint32_t socid; - soc_data.cidr = *(volatile uint32_t *)(AT91_BASE + dbgu_base + DBGU_C1R); + soc_data.cidr = *(volatile uint32_t *)(AT91_BASE + dbgu_base + + DBGU_C1R); socid = soc_data.cidr & ~AT91_CPU_VERSION_MASK; soc_data.type = AT91_T_NONE; soc_data.subtype = AT91_ST_NONE; soc_data.family = (soc_data.cidr & AT91_CPU_FAMILY_MASK) >> 20; - soc_data.exid = *(volatile uint32_t *)(AT91_BASE + dbgu_base + DBGU_C2R); + soc_data.exid = *(volatile uint32_t *)(AT91_BASE + dbgu_base + + DBGU_C2R); switch (socid) { case AT91_CPU_CAP9: @@ -336,7 +347,7 @@ at91_try_id(uint32_t dbgu_base) soc_data.type = AT91_T_SAM9X5; break; default: - return 0; + return (0); } switch (soc_data.type) { @@ -378,15 +389,18 @@ at91_try_id(uint32_t dbgu_base) default: break; } - snprintf(soc_data.name, sizeof(soc_data.name), "%s%s%s", soc_type_name[soc_data.type], + snprintf(soc_data.name, sizeof(soc_data.name), "%s%s%s", + soc_type_name[soc_data.type], soc_data.subtype == AT91_ST_NONE ? "" : " subtype ", - soc_data.subtype == AT91_ST_NONE ? "" : soc_subtype_name[soc_data.subtype]); - return 1; + soc_data.subtype == AT91_ST_NONE ? "" : + soc_subtype_name[soc_data.subtype]); + return (1); } static void at91_soc_id(void) { + if (!at91_try_id(AT91_DBGU0)) at91_try_id(AT91_DBGU1); } @@ -413,13 +427,13 @@ initarm(struct arm_boot_params *abp) freemempos = (lastaddr + PAGE_MASK) & ~PAGE_MASK; /* Define a macro to simplify memory allocation */ -#define valloc_pages(var, np) \ - alloc_pages((var).pv_va, (np)); \ +#define valloc_pages(var, np) \ + alloc_pages((var).pv_va, (np)); \ (var).pv_pa = (var).pv_va + (KERNPHYSADDR - KERNVIRTADDR); -#define alloc_pages(var, np) \ - (var) = freemempos; \ - freemempos += (np * PAGE_SIZE); \ +#define alloc_pages(var, np) \ + (var) = freemempos; \ + freemempos += (np * PAGE_SIZE); \ memset((char *)(var), 0, ((np) * PAGE_SIZE)); while (((freemempos - L1_TABLE_SIZE) & (L1_TABLE_SIZE - 1)) != 0) @@ -608,6 +622,7 @@ cpu_initclocks(void) void DELAY(int n) { + if (soc_data.delay) soc_data.delay(n); } @@ -615,6 +630,7 @@ DELAY(int n) void cpu_reset(void) { + if (soc_data.reset) soc_data.reset(); while (1) From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 20:14:43 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 30D6F106567A; Mon, 18 Jun 2012 20:14:43 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1292C8FC1D; Mon, 18 Jun 2012 20:14:43 +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 q5IKEgI2098517; Mon, 18 Jun 2012 20:14:42 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5IKEgpt098515; Mon, 18 Jun 2012 20:14:42 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201206182014.q5IKEgpt098515@svn.freebsd.org> From: Marius Strobl Date: Mon, 18 Jun 2012 20:14:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237239 - head/sys/arm/at91 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 20:14:43 -0000 Author: marius Date: Mon Jun 18 20:14:42 2012 New Revision: 237239 URL: http://svn.freebsd.org/changeset/base/237239 Log: Revert the part of r236495 that introduced checking of SPI_SR_TXEMPTY for TX transfer completion as for reasons unknown this occasionally causes SPI_SR_RXBUFF and SPI_SR_ENDRX to not rise. In any case, once the RX part of the transfer is done it's obvious that the preceding TX part had finished and checking of SPI_SR_TXEMPTY was introduced to rule out a possible cause for the data corruption mentioned in r236495 but which didn't turn out to be the problem anyway. MFC after: 3 days Modified: head/sys/arm/at91/at91_spi.c Modified: head/sys/arm/at91/at91_spi.c ============================================================================== --- head/sys/arm/at91/at91_spi.c Mon Jun 18 19:47:25 2012 (r237238) +++ head/sys/arm/at91/at91_spi.c Mon Jun 18 20:14:42 2012 (r237239) @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include @@ -59,7 +58,6 @@ struct at91_spi_softc bus_dma_tag_t dmatag; /* bus dma tag for transfers */ bus_dmamap_t map[4]; /* Maps for the transaction */ struct sx xfer_mtx; /* Enforce one transfer at a time */ - uint32_t xfer_mask; /* Bits to wait on for completion */ uint32_t xfer_done; /* interrupt<->mainthread signaling */ }; @@ -124,7 +122,6 @@ at91_spi_attach(device_t dev) * Set up the hardware. */ - sc->xfer_mask = SPI_SR_RXBUFF | (at91_is_rm92() ? 0 : SPI_SR_TXEMPTY); WR4(sc, SPI_CR, SPI_CR_SWRST); /* "Software Reset must be Written Twice" erratum */ WR4(sc, SPI_CR, SPI_CR_SWRST); @@ -272,7 +269,6 @@ at91_spi_transfer(device_t dev, device_t struct at91_spi_softc *sc; bus_addr_t addr; int err, i, j, mode[4]; - uint32_t mask; KASSERT(cmd->tx_cmd_sz == cmd->rx_cmd_sz, ("%s: TX/RX command sizes should be equal", __func__)); @@ -356,12 +352,11 @@ at91_spi_transfer(device_t dev, device_t * Start the transfer, wait for it to complete. */ sc->xfer_done = 0; - mask = sc->xfer_mask; - WR4(sc, SPI_IER, mask); + WR4(sc, SPI_IER, SPI_SR_RXBUFF); WR4(sc, PDC_PTCR, PDC_PTCR_TXTEN | PDC_PTCR_RXTEN); do err = tsleep(&sc->xfer_done, PCATCH | PZERO, "at91_spi", hz); - while (sc->xfer_done != mask && err != EINTR); + while (sc->xfer_done == 0 && err != EINTR); /* * Stop the transfer and clean things up. @@ -383,20 +378,19 @@ static void at91_spi_intr(void *arg) { struct at91_spi_softc *sc; - uint32_t mask, sr; + uint32_t sr; sc = (struct at91_spi_softc*)arg; - mask = sc->xfer_mask; sr = RD4(sc, SPI_SR) & RD4(sc, SPI_IMR); - if ((sr & mask) != 0) { - sc->xfer_done |= sr & mask; - WR4(sc, SPI_IDR, mask); + if ((sr & SPI_SR_RXBUFF) != 0) { + sc->xfer_done = 1; + WR4(sc, SPI_IDR, SPI_SR_RXBUFF); wakeup(&sc->xfer_done); } - if ((sr & ~mask) != 0) { + if ((sr & ~SPI_SR_RXBUFF) != 0) { device_printf(sc->dev, "Unexpected ISR %#x\n", sr); - WR4(sc, SPI_IDR, sr & ~mask); + WR4(sc, SPI_IDR, sr & ~SPI_SR_RXBUFF); } } From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 20:19:08 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 04440106564A; Mon, 18 Jun 2012 20:19:08 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E3FE18FC17; Mon, 18 Jun 2012 20:19:07 +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 q5IKJ7qB098729; Mon, 18 Jun 2012 20:19:07 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5IKJ7LL098727; Mon, 18 Jun 2012 20:19:07 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201206182019.q5IKJ7LL098727@svn.freebsd.org> From: Marius Strobl Date: Mon, 18 Jun 2012 20:19:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237240 - head/sys/dev/flash X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 20:19:08 -0000 Author: marius Date: Mon Jun 18 20:19:07 2012 New Revision: 237240 URL: http://svn.freebsd.org/changeset/base/237240 Log: Revert r236529, re-enabling verification of the flashed content as the underlying problem was dealt with in r237239 (in fact, disabling verification also actually only made the problem less likely to occur). Modified: head/sys/dev/flash/at45d.c Modified: head/sys/dev/flash/at45d.c ============================================================================== --- head/sys/dev/flash/at45d.c Mon Jun 18 20:14:42 2012 (r237239) +++ head/sys/dev/flash/at45d.c Mon Jun 18 20:19:07 2012 (r237240) @@ -390,7 +390,6 @@ at45d_task(void *arg) berr = EIO; goto out; } -#ifdef notyet /* May cause physwr to hang for reasons unknown. */ if (bp->bio_cmd == BIO_WRITE) { addr = page << sc->pageoffset; txBuf[0] = BUFFER_COMPARE; @@ -409,7 +408,6 @@ at45d_task(void *arg) goto out; } } -#endif page++; buf += len; offset = 0; From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 20:29:42 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BF33F1065673; Mon, 18 Jun 2012 20:29:42 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 780128FC15; Mon, 18 Jun 2012 20:29:42 +0000 (UTC) Received: from [10.0.0.63] (63.imp.bsdimp.com [10.0.0.63]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id q5IKRBtS030445 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Mon, 18 Jun 2012 14:27:13 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <20120618193319.GD69382@alchemy.franken.de> Date: Mon, 18 Jun 2012 14:27:11 -0600 Content-Transfer-Encoding: 7bit Message-Id: <579203DE-5FA1-4235-BE71-EBB4BC0CCD3C@bsdimp.com> References: <201206150837.q5F8boYj055844@svn.freebsd.org> <20120618193319.GD69382@alchemy.franken.de> To: Marius Strobl X-Mailer: Apple Mail (2.1084) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Mon, 18 Jun 2012 14:27:13 -0600 (MDT) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Warner Losh Subject: Re: svn commit: r237130 - head/sys/arm/at91 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 20:29:42 -0000 On Jun 18, 2012, at 1:33 PM, Marius Strobl wrote: > On Fri, Jun 15, 2012 at 08:37:50AM +0000, Warner Losh wrote: >> Author: imp >> Date: Fri Jun 15 08:37:50 2012 >> New Revision: 237130 >> URL: http://svn.freebsd.org/changeset/base/237130 >> >> Log: >> Make it possible to link together a sam and an rm kernel. The results >> aren't very pretty yet, but this takes DELAY and cpu_reset and makes >> them pointers. >> >> # I worry that these are set too late in the boot, especially cpu_reset. >> > > Indeed, if we now panic before at91_rst(4) attaches, automatic reboot no > longer works (seen with the bug in r236658 keeping at91sam9260(4) from > probing) ... makes sense. I plan to fix the reboot issue. Whats' the bug in r234458? warner From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 21:08:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A15C61065670; Mon, 18 Jun 2012 21:08:48 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 89DE08FC20; Mon, 18 Jun 2012 21:08:48 +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 q5IL8mVa001011; Mon, 18 Jun 2012 21:08:48 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5IL8mWK001009; Mon, 18 Jun 2012 21:08:48 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206182108.q5IL8mWK001009@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 18 Jun 2012 21:08:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237243 - head/sys/amd64/amd64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 21:08:48 -0000 Author: kib Date: Mon Jun 18 21:08:48 2012 New Revision: 237243 URL: http://svn.freebsd.org/changeset/base/237243 Log: Adjust the fix in r236953, by not generating the signal manually, but performing the return to usermode using full return path. This consolidates the handling of exceptional situations in less number of places, and is less code as well. Reviewed by: jhb MFC after: 1 week Modified: head/sys/amd64/amd64/trap.c Modified: head/sys/amd64/amd64/trap.c ============================================================================== --- head/sys/amd64/amd64/trap.c Mon Jun 18 21:00:54 2012 (r237242) +++ head/sys/amd64/amd64/trap.c Mon Jun 18 21:08:48 2012 (r237243) @@ -977,16 +977,10 @@ amd64_syscall(struct thread *td, int tra * If the user-supplied value of %rip is not a canonical * address, then some CPUs will trigger a ring 0 #GP during * the sysret instruction. However, the fault handler would - * execute with the user's %gs and %rsp in ring 0 which would - * not be safe. Instead, preemptively kill the thread with a - * SIGBUS. + * execute in ring 0 with the user's %gs and %rsp which would + * not be safe. Instead, use the full return path which + * catches the problem safely. */ - if (td->td_frame->tf_rip >= VM_MAXUSER_ADDRESS) { - ksiginfo_init_trap(&ksi); - ksi.ksi_signo = SIGBUS; - ksi.ksi_code = BUS_OBJERR; - ksi.ksi_trapno = T_PROTFLT; - ksi.ksi_addr = (void *)td->td_frame->tf_rip; - trapsignal(td, &ksi); - } + if (td->td_frame->tf_rip >= VM_MAXUSER_ADDRESS) + set_pcb_flags(td->td_pcb, PCB_FULL_IRET); } From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 21:10:12 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BF357106566B; Mon, 18 Jun 2012 21:10:12 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 436D98FC12; Mon, 18 Jun 2012 21:10:12 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.4/8.14.4/ALCHEMY.FRANKEN.DE) with ESMTP id q5ILA7fa000309; Mon, 18 Jun 2012 23:10:07 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.4/8.14.4/Submit) id q5ILA7oS000308; Mon, 18 Jun 2012 23:10:07 +0200 (CEST) (envelope-from marius) Date: Mon, 18 Jun 2012 23:10:07 +0200 From: Marius Strobl To: Warner Losh Message-ID: <20120618211007.GV46065@alchemy.franken.de> References: <201206150837.q5F8boYj055844@svn.freebsd.org> <20120618193319.GD69382@alchemy.franken.de> <579203DE-5FA1-4235-BE71-EBB4BC0CCD3C@bsdimp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <579203DE-5FA1-4235-BE71-EBB4BC0CCD3C@bsdimp.com> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Warner Losh Subject: Re: svn commit: r237130 - head/sys/arm/at91 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 21:10:13 -0000 On Mon, Jun 18, 2012 at 02:27:11PM -0600, Warner Losh wrote: > > On Jun 18, 2012, at 1:33 PM, Marius Strobl wrote: > > > On Fri, Jun 15, 2012 at 08:37:50AM +0000, Warner Losh wrote: > >> Author: imp > >> Date: Fri Jun 15 08:37:50 2012 > >> New Revision: 237130 > >> URL: http://svn.freebsd.org/changeset/base/237130 > >> > >> Log: > >> Make it possible to link together a sam and an rm kernel. The results > >> aren't very pretty yet, but this takes DELAY and cpu_reset and makes > >> them pointers. > >> > >> # I worry that these are set too late in the boot, especially cpu_reset. > >> > > > > Indeed, if we now panic before at91_rst(4) attaches, automatic reboot no > > longer works (seen with the bug in r236658 keeping at91sam9260(4) from > > probing) ... > > > makes sense. I plan to fix the reboot issue. > > Whats' the bug in r234458? > See r237237 Marius From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 22:17:29 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BBB7C1065675; Mon, 18 Jun 2012 22:17:29 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8DE038FC0A; Mon, 18 Jun 2012 22:17:29 +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 q5IMHTaj003930; Mon, 18 Jun 2012 22:17:29 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5IMHTJE003928; Mon, 18 Jun 2012 22:17:29 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201206182217.q5IMHTJE003928@svn.freebsd.org> From: Rick Macklem Date: Mon, 18 Jun 2012 22:17:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237244 - head/sys/fs/nfsclient X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 22:17:29 -0000 Author: rmacklem Date: Mon Jun 18 22:17:28 2012 New Revision: 237244 URL: http://svn.freebsd.org/changeset/base/237244 Log: Fix the NFSv4 client for the case where mmap'd files are written, but not msync'd by a process. A VOP_PUTPAGES() called when VOP_RECLAIM() happens will usually fail, since the NFSv4 Open has already been closed by VOP_INACTIVE(). Add a vm_object_page_clean() call to the NFSv4 client's VOP_INACTIVE(), so that the write happens before the NFSv4 Open is closed. kib@ suggested using vgone() instead and I will explore this, but this patch fixes things in the meantime. For some reason, the VOP_PUTPAGES() is still attaempted in VOP_RECLAIM(), but having this fail doesn't cause any problems except a "stateid0 in write" being logged. Reviewed by: kib MFC after: 1 week Modified: head/sys/fs/nfsclient/nfs_clnode.c Modified: head/sys/fs/nfsclient/nfs_clnode.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clnode.c Mon Jun 18 21:08:48 2012 (r237243) +++ head/sys/fs/nfsclient/nfs_clnode.c Mon Jun 18 22:17:28 2012 (r237244) @@ -210,18 +210,28 @@ ncl_inactive(struct vop_inactive_args *a struct nfsnode *np; struct sillyrename *sp; struct vnode *vp = ap->a_vp; + boolean_t retv; np = VTONFS(vp); if (NFS_ISV4(vp) && vp->v_type == VREG) { /* * Since mmap()'d files do I/O after VOP_CLOSE(), the NFSv4 - * Close operations are delayed until now. Any dirty buffers - * must be flushed before the close, so that the stateid is - * available for the writes. + * Close operations are delayed until now. Any dirty + * buffers/pages must be flushed before the close, so that the + * stateid is available for the writes. */ - (void) ncl_flush(vp, MNT_WAIT, NULL, ap->a_td, 1, 0); - (void) nfsrpc_close(vp, 1, ap->a_td); + if (vp->v_object != NULL) { + VM_OBJECT_LOCK(vp->v_object); + retv = vm_object_page_clean(vp->v_object, 0, 0, + OBJPC_SYNC); + VM_OBJECT_UNLOCK(vp->v_object); + } else + retv = TRUE; + if (retv == TRUE) { + (void)ncl_flush(vp, MNT_WAIT, NULL, ap->a_td, 1, 0); + (void)nfsrpc_close(vp, 1, ap->a_td); + } } mtx_lock(&np->n_mtx); From owner-svn-src-head@FreeBSD.ORG Mon Jun 18 23:18:50 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2AFC5106566B; Mon, 18 Jun 2012 23:18:50 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 159998FC12; Mon, 18 Jun 2012 23:18:50 +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 q5INInmc007442; Mon, 18 Jun 2012 23:18:49 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5INInJg007439; Mon, 18 Jun 2012 23:18:49 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201206182318.q5INInJg007439@svn.freebsd.org> From: Sean Bruno Date: Mon, 18 Jun 2012 23:18:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237245 - head/share/man/man4 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 23:18:50 -0000 Author: sbruno Date: Mon Jun 18 23:18:49 2012 New Revision: 237245 URL: http://svn.freebsd.org/changeset/base/237245 Log: Document support for Intel Enhanced Speedstep Tech interface of cpufreq(4) via a new man page est(4) Document the two exposed tuneables of est(4). I'd appreciate more reviews of content if possible. I gleaned the information contained herein from sys/x86/cpufreq/est.c and the Intel reference documentation Reviewed by: wblock hrs gjb MFC after: 2 weeks Added: head/share/man/man4/est.4 (contents, props changed) Modified: head/share/man/man4/Makefile Modified: head/share/man/man4/Makefile ============================================================================== --- head/share/man/man4/Makefile Mon Jun 18 22:17:28 2012 (r237244) +++ head/share/man/man4/Makefile Mon Jun 18 23:18:49 2012 (r237245) @@ -116,6 +116,7 @@ MAN= aac.4 \ enc.4 \ epair.4 \ esp.4 \ + est.4 \ et.4 \ eventtimers.4 \ exca.4 \ Added: head/share/man/man4/est.4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man4/est.4 Mon Jun 18 23:18:49 2012 (r237245) @@ -0,0 +1,100 @@ +.\" +.\" Copyright (c) 2012 Sean Bruno +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd June 12, 2012 +.Dt EST 4 +.Os +.Sh NAME +.Nm est +.Nd Enhanced Speedstep Technology +.Sh SYNOPSIS +To compile this capability into your kernel +place the following line in your kernel +configuration file: +.Bd -ragged -offset indent +.Cd "device cpufreq" +.Ed +.Sh DESCRIPTION +The +.Nm +interface provides support for the Intel Enhanced Speedstep Technology. +.Pp +Note that +.Nm +capabilities are automatically loaded by the +.Xr cpufreq 4 +driver. +.Sh LOADER TUNABLES +The +.Nm +interface is intended to allow +.Xr cpufreq 4 +to access and implement Intel Enhanced SpeedStep Technology via +.Xr acpi 4 +and the acpi_perf interface accessors. +If the default settings are not optimal, the following sysctls can be +used to modify or monitor +.Nm +behavior. +.Bl -tag -width indent +.It hw.est.msr_info +Attempt to infer information from direct probing of the msr. +Should only be used in diagnostic cases +.Pq default 0 +.It hw.est.strict +Do not allow different cpus to be set to different frequencies. +It appears that this will only work on i386 systems +.Pq default 0 +.El +.Sh DIAGNOSTICS +.Bl -diag +.It "est%d: on cpu%d" +.Pp +Indicates normal startup of this interface. +.It "est: CPU supports Enhanced Speedstep, but is not recognized." +.It "est: cpu_vendor GenuineIntel, msr 471c471c0600471c" +.It "device_attach: est%d attach returned 6" +.Pp +Indicates all attempts to attach to this interface have failed. +This usually indicates an improper BIOS setting restricting O/S +control of the CPU speeds. +Consult your BIOS documentation for more details. +.El +.Sh COMPATIBILITY +.Nm +is only found on supported Intel CPUs. +.Sh SEE ALSO +.Xr cpufreq 4 +.Sh SUPPORT +For general information and support, +go to the Intel 64 and IA-32 Architectures Software Developer +Manuals site. +.Pa http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html +.Sh AUTHORS +.Pp +This manual page was written by +.An Sean Bruno Aq sbruno@FreeBSD.org . From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 02:17:50 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 46C8A106564A; Tue, 19 Jun 2012 02:17:50 +0000 (UTC) (envelope-from doconnor@gsoft.com.au) Received: from cain.gsoft.com.au (cain.gsoft.com.au [203.31.81.10]) by mx1.freebsd.org (Postfix) with ESMTP id A52E28FC15; Tue, 19 Jun 2012 02:17:48 +0000 (UTC) Received: from ur.gsoft.com.au (Ur.gsoft.com.au [203.31.81.55]) (authenticated bits=0) by cain.gsoft.com.au (8.14.4/8.14.3) with ESMTP id q5J1sRUg000878 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Tue, 19 Jun 2012 11:24:33 +0930 (CST) (envelope-from doconnor@gsoft.com.au) Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=us-ascii From: "Daniel O'Connor" In-Reply-To: <20120618093435.GA1017@gpr.nnz-home.ru> Date: Tue, 19 Jun 2012 11:24:27 +0930 Content-Transfer-Encoding: quoted-printable Message-Id: <68FBE843-7337-4C90-B01F-E0CAABB62BCD@gsoft.com.au> References: <201206180754.q5I7sBoQ063448@svn.freebsd.org> <20120618093435.GA1017@gpr.nnz-home.ru> To: Gennady Proskurin X-Mailer: Apple Mail (2.1278) X-Spam-Score: -2.51 () ALL_TRUSTED,BAYES_00,T_RP_MATCHES_RCVD X-Scanned-By: MIMEDefang 2.67 on 203.31.81.10 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Poul-Henning Kamp Subject: Re: svn commit: r237223 - head/sys/dev/fb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 02:17:50 -0000 On 18/06/2012, at 19:04, Gennady Proskurin wrote: >> Modified: head/sys/dev/fb/fbreg.h >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- head/sys/dev/fb/fbreg.h Mon Jun 18 07:43:23 2012 = (r237222) >> +++ head/sys/dev/fb/fbreg.h Mon Jun 18 07:54:10 2012 = (r237223) >> @@ -39,6 +39,7 @@ >> static __inline void >> copyw(uint16_t *src, uint16_t *dst, size_t size) >> { >> + size >>=3D 1; >> while (size--) >> *dst++ =3D *src++; >> } >=20 > If size is odd, this does not copy the last byte. Not sure, whether = this is intended. Add KASSERT(size & 0x1 =3D=3D 0, ("odd size copy")); before size >>=3D 1; :) -- Daniel O'Connor software and network engineer for Genesis Software - http://www.gsoft.com.au "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 03:06:09 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6F6F61065670; Tue, 19 Jun 2012 03:06:09 +0000 (UTC) (envelope-from bjk@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 54DD58FC0A; Tue, 19 Jun 2012 03:06:09 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q5J369jR029323; Tue, 19 Jun 2012 03:06:09 GMT (envelope-from bjk@freebsd.org) Received: from localhost (bjk@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) with ESMTP id q5J369hk029320; Tue, 19 Jun 2012 03:06:09 GMT (envelope-from bjk@freebsd.org) X-Authentication-Warning: freefall.freebsd.org: bjk owned process doing -bs Date: Tue, 19 Jun 2012 03:06:09 +0000 (UTC) From: Benjamin Kaduk To: Rick Macklem In-Reply-To: <201206182217.q5IMHTJE003928@svn.freebsd.org> Message-ID: References: <201206182217.q5IMHTJE003928@svn.freebsd.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237244 - head/sys/fs/nfsclient X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 03:06:09 -0000 On Mon, 18 Jun 2012, Rick Macklem wrote: > Author: rmacklem > Date: Mon Jun 18 22:17:28 2012 > New Revision: 237244 > URL: http://svn.freebsd.org/changeset/base/237244 > > Log: > Fix the NFSv4 client for the case where mmap'd files are > written, but not msync'd by a process. A VOP_PUTPAGES() > called when VOP_RECLAIM() happens will usually fail, since > the NFSv4 Open has already been closed by VOP_INACTIVE(). > Add a vm_object_page_clean() call to the NFSv4 client's > VOP_INACTIVE(), so that the write happens before the NFSv4 > Open is closed. kib@ suggested using vgone() instead and > I will explore this, but this patch fixes things in the Hi Rick, OpenAFS is currently using vgone() in the vnode cleanup path (though it is actually in RECLAIM not INACTIVE because of how AFS has traditionally separated the two). However, it seems that the other *BSD implementations do not call vgone() in the same place, instead the corresponding flush functions call cache_purge() and sometimes other things. My colleague is trying to get our FreeBSD implementation to match, so I would be interested in your test case to confirm that we do not rely on the full vgone() there. Thanks, Ben > meantime. For some reason, the VOP_PUTPAGES() is still > attaempted in VOP_RECLAIM(), but having this fail doesn't > cause any problems except a "stateid0 in write" being logged. From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 05:17:08 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 737F41065674; Tue, 19 Jun 2012 05:17:08 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-pz0-f54.google.com (mail-pz0-f54.google.com [209.85.210.54]) by mx1.freebsd.org (Postfix) with ESMTP id 2F4828FC1E; Tue, 19 Jun 2012 05:17:08 +0000 (UTC) Received: by dadv36 with SMTP id v36so8438973dad.13 for ; Mon, 18 Jun 2012 22:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=6TNvfhXys01OZGS66dxq/a10XBrKneXxIYaJaUxGa8g=; b=htthRhOYnBzW4Abij3orOrrUaf3IC7Sh9lRzEAyZfmw5dMgEkHiBeMrhWwZUEPlR02 RY7AqYBV1cm7wN58FNSS4oI8kQ1CnqexQ4nXH8aGz7Nb8hr5H06LECp18/m/NHkWjdzp tpHvcYP/b50Y6KGwEjdr3SpLrs2bUgm+IAPhDdNWCWx6QjicIdiLwH+/zoXOdt5IBWez ud4CFgMTe+83sFHTo08echiqwqEyHBHwBfbFphcVtVNrjB7Q2ahg148fUVnr4Xvbche7 MVtaH5VJyqNkv9zCPRO5FhOtQbI6tLG3mCzNS1i3+DquW3ohQ7oBb9bcNx2dDmYqDj7g xzwg== MIME-Version: 1.0 Received: by 10.68.226.226 with SMTP id rv2mr59883707pbc.101.1340083027606; Mon, 18 Jun 2012 22:17:07 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.143.91.18 with HTTP; Mon, 18 Jun 2012 22:17:07 -0700 (PDT) In-Reply-To: <68FBE843-7337-4C90-B01F-E0CAABB62BCD@gsoft.com.au> References: <201206180754.q5I7sBoQ063448@svn.freebsd.org> <20120618093435.GA1017@gpr.nnz-home.ru> <68FBE843-7337-4C90-B01F-E0CAABB62BCD@gsoft.com.au> Date: Mon, 18 Jun 2012 22:17:07 -0700 X-Google-Sender-Auth: N8VEusY1NUNrfqP_-thSr-8xP0Q Message-ID: From: Adrian Chadd To: "Daniel O'Connor" Content-Type: text/plain; charset=ISO-8859-1 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, Gennady Proskurin , src-committers@freebsd.org, Poul-Henning Kamp Subject: Re: svn commit: r237223 - head/sys/dev/fb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 05:17:08 -0000 .. what, a kassert without handling the actual errorneous condition when INVARIANTS aren't compiled in? :) Adrian From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 05:27:15 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 39B62106564A; Tue, 19 Jun 2012 05:27:15 +0000 (UTC) (envelope-from phk@phk.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.freebsd.org (Postfix) with ESMTP id E7DA48FC08; Tue, 19 Jun 2012 05:27:14 +0000 (UTC) Received: from critter.freebsd.dk (critter.freebsd.dk [192.168.61.3]) by phk.freebsd.dk (Postfix) with ESMTP id BE94F13F3A; Tue, 19 Jun 2012 05:27:13 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.14.5/8.14.5) with ESMTP id q5J5RBpI031751; Tue, 19 Jun 2012 05:27:12 GMT (envelope-from phk@phk.freebsd.dk) To: "Daniel O'Connor" From: "Poul-Henning Kamp" In-Reply-To: Your message of "Tue, 19 Jun 2012 11:24:27 +0930." <68FBE843-7337-4C90-B01F-E0CAABB62BCD@gsoft.com.au> Content-Type: text/plain; charset=ISO-8859-1 Date: Tue, 19 Jun 2012 05:27:11 +0000 Message-ID: <31750.1340083631@critter.freebsd.dk> Cc: svn-src-head@freebsd.org, Gennady Proskurin , src-committers@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r237223 - head/sys/dev/fb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 05:27:15 -0000 In message <68FBE843-7337-4C90-B01F-E0CAABB62BCD@gsoft.com.au>, "Daniel O'Conno r" writes: >> If size is odd, this does not copy the last byte. Not sure, whether = >this is intended. Feel free to improve... -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 05:53:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 455CD106567A; Tue, 19 Jun 2012 05:53:48 +0000 (UTC) (envelope-from joel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 30E548FC0A; Tue, 19 Jun 2012 05:53:48 +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 q5J5rmdZ023924; Tue, 19 Jun 2012 05:53:48 GMT (envelope-from joel@svn.freebsd.org) Received: (from joel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5J5rmxP023922; Tue, 19 Jun 2012 05:53:48 GMT (envelope-from joel@svn.freebsd.org) Message-Id: <201206190553.q5J5rmxP023922@svn.freebsd.org> From: Joel Dahl Date: Tue, 19 Jun 2012 05:53:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237250 - head/share/man/man4 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 05:53:48 -0000 Author: joel (doc committer) Date: Tue Jun 19 05:53:47 2012 New Revision: 237250 URL: http://svn.freebsd.org/changeset/base/237250 Log: Minor mdoc fixes. Modified: head/share/man/man4/est.4 Modified: head/share/man/man4/est.4 ============================================================================== --- head/share/man/man4/est.4 Tue Jun 19 05:49:53 2012 (r237249) +++ head/share/man/man4/est.4 Tue Jun 19 05:53:47 2012 (r237250) @@ -89,12 +89,10 @@ Consult your BIOS documentation for more is only found on supported Intel CPUs. .Sh SEE ALSO .Xr cpufreq 4 -.Sh SUPPORT -For general information and support, -go to the Intel 64 and IA-32 Architectures Software Developer -Manuals site. -.Pa http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html +.Rs +.%T "Intel 64 and IA-32 Architectures Software Developer Manuals" +.%U "http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html" +.Re .Sh AUTHORS -.Pp This manual page was written by .An Sean Bruno Aq sbruno@FreeBSD.org . From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 05:55:15 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B40EB1065686; Tue, 19 Jun 2012 05:55:15 +0000 (UTC) (envelope-from joel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 988328FC12; Tue, 19 Jun 2012 05:55:15 +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 q5J5tFBr024026; Tue, 19 Jun 2012 05:55:15 GMT (envelope-from joel@svn.freebsd.org) Received: (from joel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5J5tFNA024025; Tue, 19 Jun 2012 05:55:15 GMT (envelope-from joel@svn.freebsd.org) Message-Id: <201206190555.q5J5tFNA024025@svn.freebsd.org> From: Joel Dahl Date: Tue, 19 Jun 2012 05:55:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237251 - head/share/man/man4 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 05:55:15 -0000 Author: joel (doc committer) Date: Tue Jun 19 05:55:14 2012 New Revision: 237251 URL: http://svn.freebsd.org/changeset/base/237251 Log: Remove end of line whitespace. Modified: head/share/man/man4/est.4 Modified: head/share/man/man4/est.4 ============================================================================== --- head/share/man/man4/est.4 Tue Jun 19 05:53:47 2012 (r237250) +++ head/share/man/man4/est.4 Tue Jun 19 05:55:14 2012 (r237251) @@ -63,11 +63,11 @@ behavior. .Bl -tag -width indent .It hw.est.msr_info Attempt to infer information from direct probing of the msr. -Should only be used in diagnostic cases +Should only be used in diagnostic cases .Pq default 0 .It hw.est.strict Do not allow different cpus to be set to different frequencies. -It appears that this will only work on i386 systems +It appears that this will only work on i386 systems .Pq default 0 .El .Sh DIAGNOSTICS From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 06:09:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 746CC1065670; Tue, 19 Jun 2012 06:09:48 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0A5FF8FC0C; Tue, 19 Jun 2012 06:09:48 +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 q5J69lUo024778; Tue, 19 Jun 2012 06:09:47 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5J69lCj024775; Tue, 19 Jun 2012 06:09:47 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206190609.q5J69lCj024775@svn.freebsd.org> From: Eitan Adler Date: Tue, 19 Jun 2012 06:09:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237253 - head/usr.sbin/bsdinstall/partedit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 06:09:48 -0000 Author: eadler Date: Tue Jun 19 06:09:47 2012 New Revision: 237253 URL: http://svn.freebsd.org/changeset/base/237253 Log: Remove variables which are initialized but never used thereafter reported by gcc46 warning Approved by: cperciva MFC After: 3 days Modified: head/usr.sbin/bsdinstall/partedit/diskeditor.c head/usr.sbin/bsdinstall/partedit/part_wizard.c Modified: head/usr.sbin/bsdinstall/partedit/diskeditor.c ============================================================================== --- head/usr.sbin/bsdinstall/partedit/diskeditor.c Tue Jun 19 05:55:56 2012 (r237252) +++ head/usr.sbin/bsdinstall/partedit/diskeditor.c Tue Jun 19 06:09:47 2012 (r237253) @@ -74,7 +74,7 @@ diskeditor_show(const char *title, const int x, y; int i; int height, width, min_width; - int partlist_height, partlist_width, min_partlist_width; + int partlist_height, partlist_width; int cur_scroll = 0; int key, fkey; int cur_button = 0, cur_part = 0; @@ -102,7 +102,6 @@ diskeditor_show(const char *title, const min_width = 50; height = width = 0; partlist_height = 10; - min_partlist_width = 0; dlg_tab_correct_str(prompt); dlg_button_layout(buttons, &min_width); dlg_auto_size(title, prompt, &height, &width, 2, min_width); Modified: head/usr.sbin/bsdinstall/partedit/part_wizard.c ============================================================================== --- head/usr.sbin/bsdinstall/partedit/part_wizard.c Tue Jun 19 05:55:56 2012 (r237252) +++ head/usr.sbin/bsdinstall/partedit/part_wizard.c Tue Jun 19 06:09:47 2012 (r237253) @@ -294,8 +294,6 @@ wizard_makeparts(struct gmesh *mesh, con struct gmesh submesh; struct gclass *classp; struct ggeom *gp; - struct gconfig *gc; - const char *scheme; struct gprovider *pp; intmax_t swapsize, available; char swapsizestr[10], rootsizestr[10]; @@ -309,10 +307,6 @@ wizard_makeparts(struct gmesh *mesh, con if (strcmp(gp->lg_name, disk) == 0) break; - LIST_FOREACH(gc, &gp->lg_config, lg_config) - if (strcmp(gc->lg_name, "scheme") == 0) - scheme = gc->lg_val; - pp = provider_for_name(mesh, disk); available = gpart_max_free(gp, NULL)*pp->lg_sectorsize; From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 06:09:59 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 78F6210657A6; Tue, 19 Jun 2012 06:09:59 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 647778FC12; Tue, 19 Jun 2012 06:09:59 +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 q5J69xQN024823; Tue, 19 Jun 2012 06:09:59 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5J69xR9024821; Tue, 19 Jun 2012 06:09:59 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206190609.q5J69xR9024821@svn.freebsd.org> From: Eitan Adler Date: Tue, 19 Jun 2012 06:09:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237254 - head/usr.sbin/crunch/crunchide X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 06:09:59 -0000 Author: eadler Date: Tue Jun 19 06:09:58 2012 New Revision: 237254 URL: http://svn.freebsd.org/changeset/base/237254 Log: Remove variables which are initialized but never used thereafter reported by gcc46 warning Approved by: cperciva MFC After: 3 days Modified: head/usr.sbin/crunch/crunchide/exec_elf32.c Modified: head/usr.sbin/crunch/crunchide/exec_elf32.c ============================================================================== --- head/usr.sbin/crunch/crunchide/exec_elf32.c Tue Jun 19 06:09:47 2012 (r237253) +++ head/usr.sbin/crunch/crunchide/exec_elf32.c Tue Jun 19 06:09:58 2012 (r237254) @@ -238,7 +238,7 @@ ELFNAMEEND(hide)(int fd, const char *fn) Elf_Shdr *shdrp = NULL, *symtabshdr, *strtabshdr; Elf_Sym *symtabp = NULL; char *strtabp = NULL; - Elf_Size nsyms, nlocalsyms, ewi; + Elf_Size nsyms, ewi; ssize_t shdrsize; int rv, i, weird; size_t nstrtab_size, nstrtab_nextoff, fn_size; @@ -327,7 +327,6 @@ ELFNAMEEND(hide)(int fd, const char *fn) /* Prepare data structures for symbol movement. */ nsyms = xewtoh(symtabshdr->sh_size) / xewtoh(symtabshdr->sh_entsize); - nlocalsyms = xe32toh(symtabshdr->sh_info); /* move symbols, making them local */ for (ewi = 0; ewi < nsyms; ewi++) { From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 06:10:25 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2FC3B1065866; Tue, 19 Jun 2012 06:10:25 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1AA358FC08; Tue, 19 Jun 2012 06:10:25 +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 q5J6AOkD024881; Tue, 19 Jun 2012 06:10:24 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5J6AOGf024879; Tue, 19 Jun 2012 06:10:24 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206190610.q5J6AOGf024879@svn.freebsd.org> From: Eitan Adler Date: Tue, 19 Jun 2012 06:10:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237255 - head/usr.sbin/ctladm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 06:10:25 -0000 Author: eadler Date: Tue Jun 19 06:10:24 2012 New Revision: 237255 URL: http://svn.freebsd.org/changeset/base/237255 Log: Remove variables which are initialized but never used thereafter reported by gcc46 warning Approved by: cperciva MFC After: 3 days Modified: head/usr.sbin/ctladm/ctladm.c Modified: head/usr.sbin/ctladm/ctladm.c ============================================================================== --- head/usr.sbin/ctladm/ctladm.c Tue Jun 19 06:09:58 2012 (r237254) +++ head/usr.sbin/ctladm/ctladm.c Tue Jun 19 06:10:24 2012 (r237255) @@ -772,7 +772,6 @@ static int cctl_delay(int fd, int target, int lun, int argc, char **argv, char *combinedopt) { - int datamove_delay; struct ctl_io_delay_info delay_info; char *delayloc = NULL; char *delaytype = NULL; @@ -781,7 +780,6 @@ cctl_delay(int fd, int target, int lun, int c; retval = 0; - datamove_delay = 0; memset(&delay_info, 0, sizeof(delay_info)); @@ -3803,7 +3801,7 @@ CTL_DEFAULT_DEV); int main(int argc, char **argv) { - int option_index, c; + int c; ctladm_cmdfunction command; ctladm_cmdargs cmdargs; ctladm_optret optreturn; @@ -3814,10 +3812,9 @@ main(int argc, char **argv) int target, lun; int optstart = 2; int retval, fd; - int retries, timeout; + int retries; int initid; - option_index = 0; retval = 0; cmdargs = CTLADM_ARG_NONE; command = CTLADM_CMD_HELP; @@ -3826,7 +3823,6 @@ main(int argc, char **argv) retries = 0; target = 0; lun = 0; - timeout = 0; initid = 7; if (argc < 2) { From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 06:10:28 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7CD7D106585B; Tue, 19 Jun 2012 06:10:28 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6821B8FC0A; Tue, 19 Jun 2012 06:10:28 +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 q5J6ASII024922; Tue, 19 Jun 2012 06:10:28 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5J6ASoq024920; Tue, 19 Jun 2012 06:10:28 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206190610.q5J6ASoq024920@svn.freebsd.org> From: Eitan Adler Date: Tue, 19 Jun 2012 06:10:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237256 - head/usr.sbin/ifmcstat X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 06:10:28 -0000 Author: eadler Date: Tue Jun 19 06:10:27 2012 New Revision: 237256 URL: http://svn.freebsd.org/changeset/base/237256 Log: Remove variables which are initialized but never used thereafter reported by gcc46 warning Approved by: cperciva MFC After: 3 days Modified: head/usr.sbin/ifmcstat/ifmcstat.c Modified: head/usr.sbin/ifmcstat/ifmcstat.c ============================================================================== --- head/usr.sbin/ifmcstat/ifmcstat.c Tue Jun 19 06:10:24 2012 (r237255) +++ head/usr.sbin/ifmcstat/ifmcstat.c Tue Jun 19 06:10:27 2012 (r237256) @@ -387,7 +387,6 @@ ll_addrlist(struct ifaddr *ifap) struct sockaddr sa; struct sockaddr_dl sdl; struct ifaddr *ifap0; - int error; if (af && af != AF_LINK) return; @@ -404,7 +403,7 @@ ll_addrlist(struct ifaddr *ifap) if (sdl.sdl_alen == 0) goto nextifap; addrbuf[0] = '\0'; - error = getnameinfo((struct sockaddr *)&sdl, sdl.sdl_len, + getnameinfo((struct sockaddr *)&sdl, sdl.sdl_len, addrbuf, sizeof(addrbuf), NULL, 0, NI_NUMERICHOST); printf("\tlink %s\n", addrbuf); nextifap: @@ -427,7 +426,7 @@ ll_addrlist(struct ifaddr *ifap) goto nextmulti; KREAD(ifm.ifma_addr, &sdl, struct sockaddr_dl); addrbuf[0] = '\0'; - error = getnameinfo((struct sockaddr *)&sdl, + getnameinfo((struct sockaddr *)&sdl, sdl.sdl_len, addrbuf, sizeof(addrbuf), NULL, 0, NI_NUMERICHOST); printf("\t\tgroup %s refcnt %d\n", From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 06:10:33 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5EEC910656D9; Tue, 19 Jun 2012 06:10:31 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 960CA8FC15; Tue, 19 Jun 2012 06:10:31 +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 q5J6AVru024966; Tue, 19 Jun 2012 06:10:31 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5J6AV3k024964; Tue, 19 Jun 2012 06:10:31 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206190610.q5J6AV3k024964@svn.freebsd.org> From: Eitan Adler Date: Tue, 19 Jun 2012 06:10:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237257 - head/usr.sbin/kbdmap X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 06:10:33 -0000 Author: eadler Date: Tue Jun 19 06:10:31 2012 New Revision: 237257 URL: http://svn.freebsd.org/changeset/base/237257 Log: Remove variables which are initialized but never used thereafter reported by gcc46 warning Approved by: cperciva MFC After: 3 days Modified: head/usr.sbin/kbdmap/kbdmap.c Modified: head/usr.sbin/kbdmap/kbdmap.c ============================================================================== --- head/usr.sbin/kbdmap/kbdmap.c Tue Jun 19 06:10:27 2012 (r237256) +++ head/usr.sbin/kbdmap/kbdmap.c Tue Jun 19 06:10:31 2012 (r237257) @@ -327,7 +327,6 @@ show_dialog(struct keymap **km_sorted, i FILE *fp; char *cmd, *dialog; char tmp_name[] = "/tmp/_kbd_lang.XXXX"; - const char *ext; int fd, i, size; fd = mkstemp(tmp_name); @@ -339,8 +338,6 @@ show_dialog(struct keymap **km_sorted, i asprintf(&dialog, "/usr/bin/dialog --clear --title \"Keyboard Menu\" " "--menu \"%s\" 0 0 0", menu); - ext = extract_name(dir); - /* start right font, assume that current font is equal * to default font in /etc/rc.conf * From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 06:10:35 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D719E1065784; Tue, 19 Jun 2012 06:10:34 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BD88F8FC18; Tue, 19 Jun 2012 06:10:34 +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 q5J6AYA6025005; Tue, 19 Jun 2012 06:10:34 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5J6AYMu025003; Tue, 19 Jun 2012 06:10:34 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206190610.q5J6AYMu025003@svn.freebsd.org> From: Eitan Adler Date: Tue, 19 Jun 2012 06:10:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237258 - head/usr.sbin/kldxref X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 06:10:35 -0000 Author: eadler Date: Tue Jun 19 06:10:34 2012 New Revision: 237258 URL: http://svn.freebsd.org/changeset/base/237258 Log: Remove variables which are initialized but never used thereafter reported by gcc46 warning Approved by: cperciva MFC After: 3 days Modified: head/usr.sbin/kldxref/ef.c Modified: head/usr.sbin/kldxref/ef.c ============================================================================== --- head/usr.sbin/kldxref/ef.c Tue Jun 19 06:10:31 2012 (r237257) +++ head/usr.sbin/kldxref/ef.c Tue Jun 19 06:10:34 2012 (r237258) @@ -532,7 +532,7 @@ ef_open(const char *filename, struct elf int error; int phlen, res; int nsegs; - Elf_Phdr *phdr, *phdyn, *phphdr, *phlimit; + Elf_Phdr *phdr, *phdyn, *phlimit; if (filename == NULL) return EFTYPE; @@ -576,7 +576,6 @@ ef_open(const char *filename, struct elf phlimit = phdr + hdr->e_phnum; nsegs = 0; phdyn = NULL; - phphdr = NULL; while (phdr < phlimit) { if (verbose > 1) ef_print_phdr(phdr); @@ -590,7 +589,6 @@ ef_open(const char *filename, struct elf ef->ef_segs[nsegs++] = phdr; break; case PT_PHDR: - phphdr = phdr; break; case PT_DYNAMIC: phdyn = phdr; From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 06:18:38 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 142D01065670; Tue, 19 Jun 2012 06:18:38 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F1B2E8FC1D; Tue, 19 Jun 2012 06:18:37 +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 q5J6IbPX025386; Tue, 19 Jun 2012 06:18:37 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5J6IbCe025374; Tue, 19 Jun 2012 06:18:37 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206190618.q5J6IbCe025374@svn.freebsd.org> From: Eitan Adler Date: Tue, 19 Jun 2012 06:18:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237259 - head/usr.sbin/mfiutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 06:18:38 -0000 Author: eadler Date: Tue Jun 19 06:18:37 2012 New Revision: 237259 URL: http://svn.freebsd.org/changeset/base/237259 Log: Allow users with RO privilege to the device to read the RO attributes. PR: bin/167302 Submitted by: markham breitbach Discussed with: pjd (briefly) Approved by: cperciva MFC after: 1 week Modified: head/usr.sbin/mfiutil/mfi_cmd.c head/usr.sbin/mfiutil/mfi_config.c head/usr.sbin/mfiutil/mfi_drive.c head/usr.sbin/mfiutil/mfi_evt.c head/usr.sbin/mfiutil/mfi_flash.c head/usr.sbin/mfiutil/mfi_patrol.c head/usr.sbin/mfiutil/mfi_show.c head/usr.sbin/mfiutil/mfi_volume.c head/usr.sbin/mfiutil/mfiutil.c head/usr.sbin/mfiutil/mfiutil.h Modified: head/usr.sbin/mfiutil/mfi_cmd.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_cmd.c Tue Jun 19 06:10:34 2012 (r237258) +++ head/usr.sbin/mfiutil/mfi_cmd.c Tue Jun 19 06:18:37 2012 (r237259) @@ -301,12 +301,12 @@ mfi_ctrl_get_info(int fd, struct mfi_ctr } int -mfi_open(int unit) +mfi_open(int unit, int acs) { char path[MAXPATHLEN]; snprintf(path, sizeof(path), "/dev/mfi%d", unit); - return (open(path, O_RDWR)); + return (open(path, acs)); } void Modified: head/usr.sbin/mfiutil/mfi_config.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_config.c Tue Jun 19 06:10:34 2012 (r237258) +++ head/usr.sbin/mfiutil/mfi_config.c Tue Jun 19 06:18:37 2012 (r237259) @@ -35,6 +35,7 @@ #endif #include #include +#include #include #ifdef DEBUG #include @@ -157,7 +158,7 @@ clear_config(int ac, char **av) int ch, error, fd; u_int i; - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -575,7 +576,7 @@ create_volume(int ac, char **av) narrays = 0; error = 0; - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -857,7 +858,7 @@ delete_volume(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -925,7 +926,7 @@ add_spare(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -1050,7 +1051,7 @@ remove_spare(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -1196,7 +1197,7 @@ debug_config(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -1233,7 +1234,7 @@ dump(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); Modified: head/usr.sbin/mfiutil/mfi_drive.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_drive.c Tue Jun 19 06:10:34 2012 (r237258) +++ head/usr.sbin/mfiutil/mfi_drive.c Tue Jun 19 06:18:37 2012 (r237259) @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -71,7 +72,7 @@ mfi_drive_name(struct mfi_pd_info *pinfo else snprintf(buf, sizeof(buf), "%2u", device_id); - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { warn("mfi_open"); return (buf); @@ -383,7 +384,7 @@ drive_set_state(char *drive, uint16_t ne uint8_t mbox[6]; int error, fd; - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -484,7 +485,7 @@ start_rebuild(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -541,7 +542,7 @@ abort_rebuild(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -597,7 +598,7 @@ drive_progress(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -663,7 +664,7 @@ drive_clear(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -723,7 +724,7 @@ drive_locate(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); Modified: head/usr.sbin/mfiutil/mfi_evt.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_evt.c Tue Jun 19 06:10:34 2012 (r237258) +++ head/usr.sbin/mfiutil/mfi_evt.c Tue Jun 19 06:18:37 2012 (r237259) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -73,7 +74,7 @@ show_logstate(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -541,7 +542,7 @@ show_events(int ac, char **av) int ch, error, fd, num_events, verbose; u_int i; - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); Modified: head/usr.sbin/mfiutil/mfi_flash.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_flash.c Tue Jun 19 06:10:34 2012 (r237258) +++ head/usr.sbin/mfiutil/mfi_flash.c Tue Jun 19 06:18:37 2012 (r237259) @@ -150,7 +150,7 @@ flash_adapter(int ac, char **av) goto error; } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); Modified: head/usr.sbin/mfiutil/mfi_patrol.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_patrol.c Tue Jun 19 06:10:34 2012 (r237258) +++ head/usr.sbin/mfiutil/mfi_patrol.c Tue Jun 19 06:18:37 2012 (r237259) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -86,7 +87,7 @@ show_patrol(int ac, char **av) int error, fd; u_int i; - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -196,7 +197,7 @@ start_patrol(int ac, char **av) { int error, fd; - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -222,7 +223,7 @@ stop_patrol(int ac, char **av) { int error, fd; - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -292,7 +293,7 @@ patrol_config(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); Modified: head/usr.sbin/mfiutil/mfi_show.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_show.c Tue Jun 19 06:10:34 2012 (r237258) +++ head/usr.sbin/mfiutil/mfi_show.c Tue Jun 19 06:18:37 2012 (r237259) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -61,7 +62,7 @@ show_adapter(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -148,7 +149,7 @@ show_battery(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -320,7 +321,7 @@ show_config(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -421,7 +422,7 @@ show_volumes(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -504,7 +505,7 @@ show_drives(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -612,7 +613,7 @@ show_firmware(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -672,7 +673,7 @@ show_progress(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); Modified: head/usr.sbin/mfiutil/mfi_volume.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_volume.c Tue Jun 19 06:10:34 2012 (r237258) +++ head/usr.sbin/mfiutil/mfi_volume.c Tue Jun 19 06:18:37 2012 (r237259) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -294,7 +295,7 @@ volume_cache(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -402,7 +403,7 @@ volume_name(int ac, char **av) return (ENOSPC); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -453,7 +454,7 @@ volume_progress(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); Modified: head/usr.sbin/mfiutil/mfiutil.c ============================================================================== --- head/usr.sbin/mfiutil/mfiutil.c Tue Jun 19 06:10:34 2012 (r237258) +++ head/usr.sbin/mfiutil/mfiutil.c Tue Jun 19 06:18:37 2012 (r237259) @@ -95,7 +95,7 @@ static int version(int ac, char **av) { - printf("mfiutil version 1.0.13"); + printf("mfiutil version 1.0.14"); #ifdef DEBUG printf(" (DEBUG)"); #endif Modified: head/usr.sbin/mfiutil/mfiutil.h ============================================================================== --- head/usr.sbin/mfiutil/mfiutil.h Tue Jun 19 06:10:34 2012 (r237258) +++ head/usr.sbin/mfiutil/mfiutil.h Tue Jun 19 06:18:37 2012 (r237259) @@ -139,7 +139,7 @@ int mfi_lookup_drive(int fd, char *drive int mfi_lookup_volume(int fd, const char *name, uint8_t *target_id); int mfi_dcmd_command(int fd, uint32_t opcode, void *buf, size_t bufsize, uint8_t *mbox, size_t mboxlen, uint8_t *statusp); -int mfi_open(int unit); +int mfi_open(int unit, int acs); int mfi_ctrl_get_info(int fd, struct mfi_ctrl_info *info, uint8_t *statusp); int mfi_ld_get_info(int fd, uint8_t target_id, struct mfi_ld_info *info, uint8_t *statusp); From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 06:18:43 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2327C106564A; Tue, 19 Jun 2012 06:18:43 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 043D48FC1B; Tue, 19 Jun 2012 06:18:43 +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 q5J6IgHb025430; Tue, 19 Jun 2012 06:18:42 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5J6Ig7W025423; Tue, 19 Jun 2012 06:18:42 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206190618.q5J6Ig7W025423@svn.freebsd.org> From: Eitan Adler Date: Tue, 19 Jun 2012 06:18:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237260 - head/usr.sbin/mfiutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 06:18:43 -0000 Author: eadler Date: Tue Jun 19 06:18:42 2012 New Revision: 237260 URL: http://svn.freebsd.org/changeset/base/237260 Log: Add __unused macros to appropriate places in order to allow building with WARNS=6 on base gcc, gcc46, and clang Approved by: cperciva MFC after: 1 week Modified: head/usr.sbin/mfiutil/Makefile head/usr.sbin/mfiutil/mfi_config.c head/usr.sbin/mfiutil/mfi_evt.c head/usr.sbin/mfiutil/mfi_patrol.c head/usr.sbin/mfiutil/mfi_show.c head/usr.sbin/mfiutil/mfiutil.c Modified: head/usr.sbin/mfiutil/Makefile ============================================================================== --- head/usr.sbin/mfiutil/Makefile Tue Jun 19 06:18:37 2012 (r237259) +++ head/usr.sbin/mfiutil/Makefile Tue Jun 19 06:18:42 2012 (r237260) @@ -6,7 +6,6 @@ SRCS= mfiutil.c mfi_cmd.c mfi_config.c m MAN8= mfiutil.8 CFLAGS+= -fno-builtin-strftime -WARNS?=3 DPADD= ${LIBUTIL} LDADD= -lutil Modified: head/usr.sbin/mfiutil/mfi_config.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_config.c Tue Jun 19 06:18:37 2012 (r237259) +++ head/usr.sbin/mfiutil/mfi_config.c Tue Jun 19 06:18:42 2012 (r237260) @@ -152,7 +152,7 @@ mfi_config_lookup_volume(struct mfi_conf } static int -clear_config(int ac, char **av) +clear_config(int ac __unused, char **av __unused) { struct mfi_ld_list list; int ch, error, fd; @@ -411,7 +411,7 @@ find_next_volume(struct config_id_state /* Populate an array with drives. */ static void -build_array(int fd, char *arrayp, struct array_info *array_info, +build_array(int fd __unused, char *arrayp, struct array_info *array_info, struct config_id_state *state, int verbose) { struct mfi_array *ar = (struct mfi_array *)arrayp; Modified: head/usr.sbin/mfiutil/mfi_evt.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_evt.c Tue Jun 19 06:18:37 2012 (r237259) +++ head/usr.sbin/mfiutil/mfi_evt.c Tue Jun 19 06:18:42 2012 (r237260) @@ -64,7 +64,7 @@ mfi_get_events(int fd, struct mfi_evt_li } static int -show_logstate(int ac, char **av) +show_logstate(int ac, char **av __unused) { struct mfi_evt_log_state info; int error, fd; Modified: head/usr.sbin/mfiutil/mfi_patrol.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_patrol.c Tue Jun 19 06:18:37 2012 (r237259) +++ head/usr.sbin/mfiutil/mfi_patrol.c Tue Jun 19 06:18:42 2012 (r237260) @@ -75,7 +75,7 @@ patrol_get_props(int fd, struct mfi_pr_p } static int -show_patrol(int ac, char **av) +show_patrol(int ac __unused, char **av __unused) { struct mfi_pr_properties prop; struct mfi_pr_status status; @@ -193,7 +193,7 @@ show_patrol(int ac, char **av) MFI_COMMAND(show, patrol, show_patrol); static int -start_patrol(int ac, char **av) +start_patrol(int ac __unused, char **av __unused) { int error, fd; @@ -219,7 +219,7 @@ start_patrol(int ac, char **av) MFI_COMMAND(start, patrol, start_patrol); static int -stop_patrol(int ac, char **av) +stop_patrol(int ac __unused, char **av __unused) { int error, fd; Modified: head/usr.sbin/mfiutil/mfi_show.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_show.c Tue Jun 19 06:18:37 2012 (r237259) +++ head/usr.sbin/mfiutil/mfi_show.c Tue Jun 19 06:18:42 2012 (r237260) @@ -51,7 +51,7 @@ format_stripe(char *buf, size_t buflen, } static int -show_adapter(int ac, char **av) +show_adapter(int ac, char **av __unused) { struct mfi_ctrl_info info; char stripe[5]; @@ -136,7 +136,7 @@ show_adapter(int ac, char **av) MFI_COMMAND(show, adapter, show_adapter); static int -show_battery(int ac, char **av) +show_battery(int ac, char **av __unused) { struct mfi_bbu_capacity_info cap; struct mfi_bbu_design_info design; @@ -304,7 +304,7 @@ print_pd(struct mfi_pd_info *info, int s } static int -show_config(int ac, char **av) +show_config(int ac, char **av __unused) { struct mfi_config_data *config; struct mfi_array *ar; @@ -410,7 +410,7 @@ show_config(int ac, char **av) MFI_COMMAND(show, config, show_config); static int -show_volumes(int ac, char **av) +show_volumes(int ac, char **av __unused) { struct mfi_ld_list list; struct mfi_ld_info info; @@ -493,7 +493,7 @@ show_volumes(int ac, char **av) MFI_COMMAND(show, volumes, show_volumes); static int -show_drives(int ac, char **av) +show_drives(int ac, char **av __unused) { struct mfi_pd_list *list; struct mfi_pd_info info; @@ -601,7 +601,7 @@ display_firmware(struct mfi_info_compone } static int -show_firmware(int ac, char **av) +show_firmware(int ac, char **av __unused) { struct mfi_ctrl_info info; struct mfi_info_component header; @@ -657,7 +657,7 @@ show_firmware(int ac, char **av) MFI_COMMAND(show, firmware, show_firmware); static int -show_progress(int ac, char **av) +show_progress(int ac, char **av __unused) { struct mfi_ld_list llist; struct mfi_pd_list *plist; Modified: head/usr.sbin/mfiutil/mfiutil.c ============================================================================== --- head/usr.sbin/mfiutil/mfiutil.c Tue Jun 19 06:18:37 2012 (r237259) +++ head/usr.sbin/mfiutil/mfiutil.c Tue Jun 19 06:18:42 2012 (r237260) @@ -92,7 +92,7 @@ usage(void) } static int -version(int ac, char **av) +version(int ac __unused, char **av __unused) { printf("mfiutil version 1.0.14"); From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 07:34:15 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id ECC69106564A; Tue, 19 Jun 2012 07:34:14 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D2DA78FC08; Tue, 19 Jun 2012 07:34:14 +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 q5J7YEjw028629; Tue, 19 Jun 2012 07:34:14 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5J7YErt028615; Tue, 19 Jun 2012 07:34:14 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201206190734.q5J7YErt028615@svn.freebsd.org> From: Navdeep Parhar Date: Tue, 19 Jun 2012 07:34:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237263 - in head: sbin/ifconfig sys/amd64/conf sys/conf sys/contrib/rdma sys/contrib/rdma/krping sys/dev/cxgb sys/dev/cxgb/common sys/dev/cxgb/sys sys/dev/cxgb/ulp/iw_cxgb sys/dev/cxgb... X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 07:34:15 -0000 Author: np Date: Tue Jun 19 07:34:13 2012 New Revision: 237263 URL: http://svn.freebsd.org/changeset/base/237263 Log: - Updated TOE support in the kernel. - Stateful TCP offload drivers for Terminator 3 and 4 (T3 and T4) ASICs. These are available as t3_tom and t4_tom modules that augment cxgb(4) and cxgbe(4) respectively. The cxgb/cxgbe drivers continue to work as usual with or without these extra features. - iWARP driver for Terminator 3 ASIC (kernel verbs). T4 iWARP in the works and will follow soon. Build-tested with make universe. 30s overview ============ What interfaces support TCP offload? Look for TOE4 and/or TOE6 in the capabilities of an interface: # ifconfig -m | grep TOE Enable/disable TCP offload on an interface (just like any other ifnet capability): # ifconfig cxgbe0 toe # ifconfig cxgbe0 -toe Which connections are offloaded? Look for toe4 and/or toe6 in the output of netstat and sockstat: # netstat -np tcp | grep toe # sockstat -46c | grep toe Reviewed by: bz, gnn Sponsored by: Chelsio communications. MFC after: ~3 months (after 9.1, and after ensuring MFC is feasible) Added: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_ib_intfc.h (contents, props changed) head/sys/dev/cxgbe/tom/ head/sys/dev/cxgbe/tom/t4_connect.c (contents, props changed) head/sys/dev/cxgbe/tom/t4_cpl_io.c (contents, props changed) head/sys/dev/cxgbe/tom/t4_listen.c (contents, props changed) head/sys/dev/cxgbe/tom/t4_tom.c (contents, props changed) head/sys/dev/cxgbe/tom/t4_tom.h (contents, props changed) head/sys/dev/cxgbe/tom/t4_tom_l2t.c (contents, props changed) head/sys/dev/cxgbe/tom/t4_tom_l2t.h (contents, props changed) head/sys/modules/cxgbe/tom/ head/sys/modules/cxgbe/tom/Makefile (contents, props changed) head/sys/modules/toecore/ head/sys/modules/toecore/Makefile (contents, props changed) head/sys/netinet/toecore.c (contents, props changed) head/sys/netinet/toecore.h (contents, props changed) Deleted: head/sys/dev/cxgb/cxgb_offload.c head/sys/dev/cxgb/t3cdev.h head/sys/dev/cxgb/ulp/toecore/ head/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c head/sys/dev/cxgb/ulp/tom/cxgb_ddp.c head/sys/dev/cxgb/ulp/tom/cxgb_defs.h head/sys/dev/cxgb/ulp/tom/cxgb_t3_ddp.h head/sys/dev/cxgb/ulp/tom/cxgb_tcp.h head/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.c head/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.h head/sys/dev/cxgb/ulp/tom/cxgb_tom_sysctl.c head/sys/modules/cxgb/toecore/ head/sys/netinet/toedev.h Modified: head/sbin/ifconfig/ifconfig.c head/sys/amd64/conf/GENERIC head/sys/conf/NOTES head/sys/conf/files head/sys/conf/options head/sys/contrib/rdma/krping/krping.c head/sys/contrib/rdma/krping/krping.h head/sys/contrib/rdma/krping/krping_dev.c head/sys/contrib/rdma/rdma_addr.c head/sys/contrib/rdma/rdma_cache.c head/sys/dev/cxgb/common/cxgb_ctl_defs.h head/sys/dev/cxgb/cxgb_adapter.h head/sys/dev/cxgb/cxgb_main.c head/sys/dev/cxgb/cxgb_offload.h head/sys/dev/cxgb/cxgb_osdep.h head/sys/dev/cxgb/cxgb_sge.c head/sys/dev/cxgb/sys/mvec.h head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.h head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.h head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cq.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_dbg.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_ev.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_hal.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_hal.h head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_mem.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.h head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_qp.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_resource.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_user.h head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_wr.h head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c head/sys/dev/cxgb/ulp/tom/cxgb_l2t.c head/sys/dev/cxgb/ulp/tom/cxgb_l2t.h head/sys/dev/cxgb/ulp/tom/cxgb_listen.c head/sys/dev/cxgb/ulp/tom/cxgb_toepcb.h head/sys/dev/cxgb/ulp/tom/cxgb_tom.c head/sys/dev/cxgb/ulp/tom/cxgb_tom.h head/sys/dev/cxgbe/adapter.h head/sys/dev/cxgbe/common/t4_hw.c head/sys/dev/cxgbe/offload.h head/sys/dev/cxgbe/t4_l2t.c head/sys/dev/cxgbe/t4_l2t.h head/sys/dev/cxgbe/t4_main.c head/sys/dev/cxgbe/t4_sge.c head/sys/i386/conf/GENERIC head/sys/i386/conf/XEN head/sys/modules/Makefile head/sys/modules/cxgb/Makefile head/sys/modules/cxgb/cxgb/Makefile head/sys/modules/cxgb/iw_cxgb/Makefile head/sys/modules/cxgb/tom/Makefile head/sys/modules/cxgbe/Makefile head/sys/modules/rdma/krping/Makefile head/sys/net/if_var.h head/sys/net/if_vlan.c head/sys/netinet/if_ether.c head/sys/netinet/if_ether.h head/sys/netinet/in.c head/sys/netinet/tcp_input.c head/sys/netinet/tcp_offload.c head/sys/netinet/tcp_offload.h head/sys/netinet/tcp_output.c head/sys/netinet/tcp_subr.c head/sys/netinet/tcp_syncache.c head/sys/netinet/tcp_syncache.h head/sys/netinet/tcp_timer.c head/sys/netinet/tcp_usrreq.c head/sys/netinet/tcp_var.h head/sys/ofed/drivers/infiniband/core/cma.c head/sys/ofed/drivers/infiniband/core/iwcm.c head/sys/ofed/include/linux/net.h head/sys/ofed/include/net/netevent.h head/sys/ofed/include/rdma/iw_cm.h head/usr.bin/netstat/inet.c head/usr.bin/sockstat/sockstat.c Modified: head/sbin/ifconfig/ifconfig.c ============================================================================== --- head/sbin/ifconfig/ifconfig.c Tue Jun 19 06:52:21 2012 (r237262) +++ head/sbin/ifconfig/ifconfig.c Tue Jun 19 07:34:13 2012 (r237263) @@ -916,7 +916,7 @@ unsetifdescr(const char *val, int value, #define IFCAPBITS \ "\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING" \ "\10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC" \ -"\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE\25NETMAP" \ +"\17TOE4\20TOE6\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE\25NETMAP" \ "\26RXCSUM_IPV6\27TXCSUM_IPV6" /* @@ -1212,6 +1212,8 @@ static struct cmd basic_cmds[] = { DEF_CMD("-tso4", -IFCAP_TSO4, setifcap), DEF_CMD("tso", IFCAP_TSO, setifcap), DEF_CMD("-tso", -IFCAP_TSO, setifcap), + DEF_CMD("toe", IFCAP_TOE, setifcap), + DEF_CMD("-toe", -IFCAP_TOE, setifcap), DEF_CMD("lro", IFCAP_LRO, setifcap), DEF_CMD("-lro", -IFCAP_LRO, setifcap), DEF_CMD("wol", IFCAP_WOL, setifcap), Modified: head/sys/amd64/conf/GENERIC ============================================================================== --- head/sys/amd64/conf/GENERIC Tue Jun 19 06:52:21 2012 (r237262) +++ head/sys/amd64/conf/GENERIC Tue Jun 19 07:34:13 2012 (r237263) @@ -28,6 +28,7 @@ options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_OFFLOAD # TCP offload options SCTP # Stream Control Transmission Protocol options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Tue Jun 19 06:52:21 2012 (r237262) +++ head/sys/conf/NOTES Tue Jun 19 07:34:13 2012 (r237263) @@ -545,6 +545,8 @@ options INET6 #IPv6 communications pr options ROUTETABLES=2 # max 16. 1 is back compatible. +options TCP_OFFLOAD # TCP offload support. + # In order to enable IPSEC you MUST also add device crypto to # your kernel configuration options IPSEC #IP security (requires device crypto) Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Tue Jun 19 06:52:21 2012 (r237262) +++ head/sys/conf/files Tue Jun 19 07:34:13 2012 (r237263) @@ -1038,8 +1038,6 @@ dev/cs/if_cs_isa.c optional cs isa dev/cs/if_cs_pccard.c optional cs pccard dev/cxgb/cxgb_main.c optional cxgb pci \ compile-with "${NORMAL_C} -I$S/dev/cxgb" -dev/cxgb/cxgb_offload.c optional cxgb pci \ - compile-with "${NORMAL_C} -I$S/dev/cxgb" dev/cxgb/cxgb_sge.c optional cxgb pci \ compile-with "${NORMAL_C} -I$S/dev/cxgb" dev/cxgb/common/cxgb_mc5.c optional cxgb pci \ @@ -3037,7 +3035,7 @@ netinet/tcp_hostcache.c optional inet | netinet/tcp_input.c optional inet | inet6 netinet/tcp_lro.c optional inet | inet6 netinet/tcp_output.c optional inet | inet6 -netinet/tcp_offload.c optional inet | inet6 +netinet/tcp_offload.c optional tcp_offload inet | tcp_offload inet6 netinet/tcp_reass.c optional inet | inet6 netinet/tcp_sack.c optional inet | inet6 netinet/tcp_subr.c optional inet | inet6 Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Tue Jun 19 06:52:21 2012 (r237262) +++ head/sys/conf/options Tue Jun 19 07:34:13 2012 (r237263) @@ -434,7 +434,7 @@ RADIX_MPATH opt_mpath.h ROUTETABLES opt_route.h SLIP_IFF_OPTS opt_slip.h TCPDEBUG -TCP_OFFLOAD_DISABLE opt_inet.h #Disable code to dispatch tcp offloading +TCP_OFFLOAD opt_inet.h # Enable code to dispatch TCP offloading TCP_SIGNATURE opt_inet.h VLAN_ARRAY opt_vlan.h XBONEHACK Modified: head/sys/contrib/rdma/krping/krping.c ============================================================================== --- head/sys/contrib/rdma/krping/krping.c Tue Jun 19 06:52:21 2012 (r237262) +++ head/sys/contrib/rdma/krping/krping.c Tue Jun 19 07:34:13 2012 (r237263) @@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -53,11 +52,13 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include -#include +#include +#include #include "getopt.h" #include "krping.h" @@ -83,6 +84,7 @@ static const struct krping_option krping {"bw", OPT_NOPARAM, 'B'}, {"tx-depth", OPT_INT, 't'}, {"poll", OPT_NOPARAM, 'P'}, + {"memlimit", OPT_INT, 'm'}, {NULL, 0, 0} }; @@ -254,10 +256,14 @@ static void krping_cq_event_handler(stru ib_req_notify_cq(cb->cq, IB_CQ_NEXT_COMP); while ((ret = ib_poll_cq(cb->cq, 1, &wc)) == 1) { if (wc.status) { - if (wc.status != IB_WC_WR_FLUSH_ERR) - log(LOG_ERR, "cq completion failed status %d\n", + if (wc.status == IB_WC_WR_FLUSH_ERR) { + DEBUG_LOG("cq flushed\n"); + continue; + } else { + log(LOG_CRIT, "cq completion failed status %d\n", wc.status); - goto error; + goto error; + } } switch (wc.opcode) { @@ -432,8 +438,17 @@ static int krping_setup_buffers(struct k } } - cb->rdma_buf = contigmalloc(cb->size, M_DEVBUF, M_WAITOK, 0, -1UL, - PAGE_SIZE, 0); + /* RNIC adapters have a limit upto which it can register physical memory + * If DMA-MR memory mode is set then normally driver registers maximum + * supported memory. After that if contigmalloc allocates memory beyond the + * specified RNIC limit then Krping may not work. + */ + if (cb->use_dmamr && cb->memlimit) + cb->rdma_buf = contigmalloc(cb->size, M_DEVBUF, M_WAITOK, 0, cb->memlimit, + PAGE_SIZE, 0); + else + cb->rdma_buf = contigmalloc(cb->size, M_DEVBUF, M_WAITOK, 0, -1UL, + PAGE_SIZE, 0); if (!cb->rdma_buf) { log(LOG_ERR, "rdma_buf malloc failed\n"); @@ -458,8 +473,12 @@ static int krping_setup_buffers(struct k } if (!cb->server || cb->wlat || cb->rlat || cb->bw) { - cb->start_buf = contigmalloc(cb->size, M_DEVBUF, M_WAITOK, - 0, -1UL, PAGE_SIZE, 0); + if (cb->use_dmamr && cb->memlimit) + cb->start_buf = contigmalloc(cb->size, M_DEVBUF, M_WAITOK, + 0, cb->memlimit, PAGE_SIZE, 0); + else + cb->start_buf = contigmalloc(cb->size, M_DEVBUF, M_WAITOK, + 0, -1UL, PAGE_SIZE, 0); if (!cb->start_buf) { log(LOG_ERR, "start_buf malloc failed\n"); ret = ENOMEM; @@ -1636,6 +1655,8 @@ int krping_doit(char *cmd) cb->state = IDLE; cb->size = 64; cb->txdepth = RPING_SQ_DEPTH; + cb->use_dmamr = 1; + cb->memlimit = 0; mtx_init(&cb->lock, "krping mtx", NULL, MTX_DUPOK|MTX_DEF); while ((op = krping_getopt("krping", &cmd, krping_opts, NULL, &optarg, @@ -1713,6 +1734,15 @@ int krping_doit(char *cmd) case 'd': debug++; break; + case 'm': + cb->memlimit = optint; + if (cb->memlimit < 1) { + log(LOG_ERR, "Invalid memory limit %ju\n", + cb->memlimit); + ret = EINVAL; + } else + DEBUG_LOG(PFX "memory limit %d\n", (int)optint); + break; default: log(LOG_ERR, "unknown opt %s\n", optarg); ret = EINVAL; Modified: head/sys/contrib/rdma/krping/krping.h ============================================================================== --- head/sys/contrib/rdma/krping/krping.h Tue Jun 19 06:52:21 2012 (r237262) +++ head/sys/contrib/rdma/krping/krping.h Tue Jun 19 07:34:13 2012 (r237263) @@ -1,7 +1,7 @@ /* * $FreeBSD$ */ -#include +#include #include /* @@ -92,6 +92,8 @@ struct krping_cb { int count; /* ping count */ int size; /* ping data size */ int validate; /* validate ping data */ + uint64_t memlimit; /* limit of the physical memory that + can be registered with dma_mr mode */ /* CM stuff */ struct rdma_cm_id *cm_id; /* connection on client side,*/ Modified: head/sys/contrib/rdma/krping/krping_dev.c ============================================================================== --- head/sys/contrib/rdma/krping/krping_dev.c Tue Jun 19 06:52:21 2012 (r237262) +++ head/sys/contrib/rdma/krping/krping_dev.c Tue Jun 19 07:34:13 2012 (r237263) @@ -14,7 +14,6 @@ __FBSDID("$FreeBSD$"); #include -#include #include /* uprintf */ #include #include /* defines used in kernel.h */ @@ -51,6 +50,9 @@ typedef struct s_krping { /* vars */ static struct cdev *krping_dev; +#undef MODULE_VERSION +#include + static int krping_loader(struct module *m, int what, void *arg) { @@ -175,6 +177,4 @@ krping_write(struct cdev *dev, struct ui return(err); } -MODULE_DEPEND(krping, rdma_core, 1, 1, 1); -MODULE_DEPEND(krping, rdma_cma, 1, 1, 1); DEV_MODULE(krping,krping_loader,NULL); Modified: head/sys/contrib/rdma/rdma_addr.c ============================================================================== --- head/sys/contrib/rdma/rdma_addr.c Tue Jun 19 06:52:21 2012 (r237262) +++ head/sys/contrib/rdma/rdma_addr.c Tue Jun 19 07:34:13 2012 (r237263) @@ -117,7 +117,8 @@ int rdma_copy_addr(struct rdma_dev_addr const unsigned char *dst_dev_addr) { dev_addr->dev_type = RDMA_NODE_RNIC; - memcpy(dev_addr->src_dev_addr, IF_LLADDR(dev), MAX_ADDR_LEN); + memset(dev_addr->src_dev_addr, 0, MAX_ADDR_LEN); + memcpy(dev_addr->src_dev_addr, IF_LLADDR(dev), dev->if_addrlen); memcpy(dev_addr->broadcast, dev->if_broadcastaddr, MAX_ADDR_LEN); if (dst_dev_addr) memcpy(dev_addr->dst_dev_addr, dst_dev_addr, MAX_ADDR_LEN); @@ -207,7 +208,7 @@ static int addr_resolve_remote(struct so goto put; } ret = arpresolve(iproute.ro_rt->rt_ifp, iproute.ro_rt, NULL, - rt_key(iproute.ro_rt), dmac, &lle); + (struct sockaddr *)dst_in, dmac, &lle); if (ret) { goto put; } Modified: head/sys/contrib/rdma/rdma_cache.c ============================================================================== --- head/sys/contrib/rdma/rdma_cache.c Tue Jun 19 06:52:21 2012 (r237262) +++ head/sys/contrib/rdma/rdma_cache.c Tue Jun 19 07:34:13 2012 (r237263) @@ -132,7 +132,7 @@ int ib_find_cached_gid(struct ib_device for (p = 0; p <= end_port(device) - start_port(device); ++p) { cache = device->cache.gid_cache[p]; for (i = 0; i < cache->table_len; ++i) { - if (!memcmp(gid, &cache->table[i], 6)) { /* XXX */ + if (!memcmp(gid, &cache->table[i], sizeof *gid)) { *port_num = p + start_port(device); if (index) *index = i; Modified: head/sys/dev/cxgb/common/cxgb_ctl_defs.h ============================================================================== --- head/sys/dev/cxgb/common/cxgb_ctl_defs.h Tue Jun 19 06:52:21 2012 (r237262) +++ head/sys/dev/cxgb/common/cxgb_ctl_defs.h Tue Jun 19 07:34:13 2012 (r237263) @@ -60,14 +60,12 @@ struct mtutab { const unsigned short *mtus; /* the MTU table values */ }; -struct net_device; - /* - * Structure used to request the adapter net_device owning a given MAC address. + * Structure used to request the ifnet that owns a given MAC address. */ struct iff_mac { - struct net_device *dev; /* the net_device */ - const unsigned char *mac_addr; /* MAC address to lookup */ + struct ifnet *dev; + const unsigned char *mac_addr; u16 vlan_tag; }; @@ -85,7 +83,7 @@ struct ddp_params { struct adap_ports { unsigned int nports; /* number of ports on this adapter */ - struct net_device *lldevs[MAX_NPORTS]; + struct ifnet *lldevs[MAX_NPORTS]; }; /* Modified: head/sys/dev/cxgb/cxgb_adapter.h ============================================================================== --- head/sys/dev/cxgb/cxgb_adapter.h Tue Jun 19 06:52:21 2012 (r237262) +++ head/sys/dev/cxgb/cxgb_adapter.h Tue Jun 19 07:34:13 2012 (r237263) @@ -57,7 +57,6 @@ $FreeBSD$ #include #include -#include #include struct adapter; @@ -130,6 +129,7 @@ enum { CXGB_OFLD_INIT = (1 << 7), TP_PARITY_INIT = (1 << 8), CXGB_BUSY = (1 << 9), + TOM_INIT_DONE = (1 << 10), /* port flags */ DOOMED = (1 << 0), @@ -179,7 +179,6 @@ struct sge_rspq { uint32_t async_notif; uint32_t cntxt_id; uint32_t offload_pkts; - uint32_t offload_bundles; uint32_t pure_rsps; uint32_t unhandled_irqs; uint32_t starved; @@ -291,6 +290,7 @@ struct sge_qset { uint32_t txq_stopped; /* which Tx queues are stopped */ uint64_t port_stats[SGE_PSTAT_MAX]; struct port_info *port; + struct adapter *adap; int idx; /* qset # */ int qs_flags; int coalescing; @@ -307,10 +307,13 @@ struct sge { struct filter_info; +typedef int (*cpl_handler_t)(struct sge_qset *, struct rsp_desc *, + struct mbuf *); + struct adapter { + SLIST_ENTRY(adapter) link; device_t dev; int flags; - TAILQ_ENTRY(adapter) adapter_entry; /* PCI register resources */ int regs_rid; @@ -376,11 +379,16 @@ struct adapter { struct port_info port[MAX_NPORTS]; device_t portdev[MAX_NPORTS]; - struct t3cdev tdev; +#ifdef TCP_OFFLOAD + void *tom_softc; + void *iwarp_softc; +#endif char fw_version[64]; char port_types[MAX_NPORTS + 1]; uint32_t open_device_map; - uint32_t registered_device_map; +#ifdef TCP_OFFLOAD + int offload_map; +#endif struct mtx lock; driver_intr_t *cxgb_intr; int msi_count; @@ -392,6 +400,11 @@ struct adapter { char elmerlockbuf[ADAPTER_LOCK_NAME_LEN]; int timestamp; + +#ifdef TCP_OFFLOAD +#define NUM_CPL_HANDLERS 0xa7 + cpl_handler_t cpl_handler[NUM_CPL_HANDLERS] __aligned(CACHE_LINE_SIZE); +#endif }; struct t3_rx_mode { @@ -502,10 +515,12 @@ void t3_os_link_changed(adapter_t *adapt int speed, int duplex, int fc, int mac_was_reset); void t3_os_phymod_changed(struct adapter *adap, int port_id); void t3_sge_err_intr_handler(adapter_t *adapter); -int t3_offload_tx(struct t3cdev *, struct mbuf *); +#ifdef TCP_OFFLOAD +int t3_offload_tx(struct adapter *, struct mbuf *); +#endif void t3_os_set_hw_addr(adapter_t *adapter, int port_idx, u8 hw_addr[]); int t3_mgmt_tx(adapter_t *adap, struct mbuf *m); - +int t3_register_cpl_handler(struct adapter *, int, cpl_handler_t); int t3_sge_alloc(struct adapter *); int t3_sge_free(struct adapter *); @@ -556,15 +571,9 @@ txq_to_qset(struct sge_txq *q, int qidx) return container_of(q, struct sge_qset, txq[qidx]); } -static __inline struct adapter * -tdev2adap(struct t3cdev *d) -{ - return container_of(d, struct adapter, tdev); -} - #undef container_of -#define OFFLOAD_DEVMAP_BIT 15 +#define OFFLOAD_DEVMAP_BIT (1 << MAX_NPORTS) static inline int offload_running(adapter_t *adapter) { return isset(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT); @@ -573,4 +582,5 @@ static inline int offload_running(adapte void cxgb_tx_watchdog(void *arg); int cxgb_transmit(struct ifnet *ifp, struct mbuf *m); void cxgb_qflush(struct ifnet *ifp); +void t3_iterate(void (*)(struct adapter *, void *), void *); #endif Modified: head/sys/dev/cxgb/cxgb_main.c ============================================================================== --- head/sys/dev/cxgb/cxgb_main.c Tue Jun 19 06:52:21 2012 (r237262) +++ head/sys/dev/cxgb/cxgb_main.c Tue Jun 19 07:34:13 2012 (r237263) @@ -30,6 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. #include __FBSDID("$FreeBSD$"); +#include "opt_inet.h" + #include #include #include @@ -107,6 +109,9 @@ static inline void mk_set_tcb_field(stru unsigned int, u64, u64); static inline void set_tcb_field_ulp(struct cpl_set_tcb_field *, unsigned int, unsigned int, u64, u64); +#ifdef TCP_OFFLOAD +static int cpl_not_handled(struct sge_qset *, struct rsp_desc *, struct mbuf *); +#endif /* Attachment glue for the PCI controller end of the device. Each port of * the device is attached separately, as defined later. @@ -119,10 +124,11 @@ static __inline void reg_block_dump(stru unsigned int end); static void cxgb_get_regs(adapter_t *sc, struct ch_ifconf_regs *regs, uint8_t *buf); static int cxgb_get_regs_len(void); -static int offload_open(struct port_info *pi); static void touch_bars(device_t dev); -static int offload_close(struct t3cdev *tdev); static void cxgb_update_mac_settings(struct port_info *p); +#ifdef TCP_OFFLOAD +static int toe_capability(struct port_info *, int); +#endif static device_method_t cxgb_controller_methods[] = { DEVMETHOD(device_probe, cxgb_controller_probe), @@ -138,8 +144,11 @@ static driver_t cxgb_controller_driver = sizeof(struct adapter) }; +static int cxgbc_mod_event(module_t, int, void *); static devclass_t cxgb_controller_devclass; -DRIVER_MODULE(cxgbc, pci, cxgb_controller_driver, cxgb_controller_devclass, 0, 0); +DRIVER_MODULE(cxgbc, pci, cxgb_controller_driver, cxgb_controller_devclass, + cxgbc_mod_event, 0); +MODULE_VERSION(cxgbc, 1); /* * Attachment glue for the ports. Attachment is done directly to the @@ -177,6 +186,14 @@ static struct cdevsw cxgb_cdevsw = { static devclass_t cxgb_port_devclass; DRIVER_MODULE(cxgb, cxgbc, cxgb_port_driver, cxgb_port_devclass, 0, 0); +MODULE_VERSION(cxgb, 1); + +static struct mtx t3_list_lock; +static SLIST_HEAD(, adapter) t3_list; +#ifdef TCP_OFFLOAD +static struct mtx t3_uld_list_lock; +static SLIST_HEAD(, uld_info) t3_uld_list; +#endif /* * The driver uses the best interrupt scheme available on a platform in the @@ -195,15 +212,6 @@ SYSCTL_INT(_hw_cxgb, OID_AUTO, msi_allow "MSI-X, MSI, INTx selector"); /* - * The driver enables offload as a default. - * To disable it, use ofld_disable = 1. - */ -static int ofld_disable = 0; -TUNABLE_INT("hw.cxgb.ofld_disable", &ofld_disable); -SYSCTL_INT(_hw_cxgb, OID_AUTO, ofld_disable, CTLFLAG_RDTUN, &ofld_disable, 0, - "disable ULP offload"); - -/* * The driver uses an auto-queue algorithm by default. * To disable it and force a single queue-set per port, use multiq = 0 */ @@ -445,6 +453,25 @@ cxgb_controller_attach(device_t dev) sc->msi_count = 0; ai = cxgb_get_adapter_info(dev); + snprintf(sc->lockbuf, ADAPTER_LOCK_NAME_LEN, "cxgb controller lock %d", + device_get_unit(dev)); + ADAPTER_LOCK_INIT(sc, sc->lockbuf); + + snprintf(sc->reglockbuf, ADAPTER_LOCK_NAME_LEN, "SGE reg lock %d", + device_get_unit(dev)); + snprintf(sc->mdiolockbuf, ADAPTER_LOCK_NAME_LEN, "cxgb mdio lock %d", + device_get_unit(dev)); + snprintf(sc->elmerlockbuf, ADAPTER_LOCK_NAME_LEN, "cxgb elmer lock %d", + device_get_unit(dev)); + + MTX_INIT(&sc->sge.reg_lock, sc->reglockbuf, NULL, MTX_SPIN); + MTX_INIT(&sc->mdio_lock, sc->mdiolockbuf, NULL, MTX_DEF); + MTX_INIT(&sc->elmer_lock, sc->elmerlockbuf, NULL, MTX_DEF); + + mtx_lock(&t3_list_lock); + SLIST_INSERT_HEAD(&t3_list, sc, link); + mtx_unlock(&t3_list_lock); + /* find the PCIe link width and set max read request to 4KB*/ if (pci_find_cap(dev, PCIY_EXPRESS, ®) == 0) { uint16_t lnk; @@ -471,24 +498,10 @@ cxgb_controller_attach(device_t dev) if ((sc->regs_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->regs_rid, RF_ACTIVE)) == NULL) { device_printf(dev, "Cannot allocate BAR region 0\n"); - return (ENXIO); + error = ENXIO; + goto out; } - snprintf(sc->lockbuf, ADAPTER_LOCK_NAME_LEN, "cxgb controller lock %d", - device_get_unit(dev)); - ADAPTER_LOCK_INIT(sc, sc->lockbuf); - - snprintf(sc->reglockbuf, ADAPTER_LOCK_NAME_LEN, "SGE reg lock %d", - device_get_unit(dev)); - snprintf(sc->mdiolockbuf, ADAPTER_LOCK_NAME_LEN, "cxgb mdio lock %d", - device_get_unit(dev)); - snprintf(sc->elmerlockbuf, ADAPTER_LOCK_NAME_LEN, "cxgb elmer lock %d", - device_get_unit(dev)); - - MTX_INIT(&sc->sge.reg_lock, sc->reglockbuf, NULL, MTX_SPIN); - MTX_INIT(&sc->mdio_lock, sc->mdiolockbuf, NULL, MTX_DEF); - MTX_INIT(&sc->elmer_lock, sc->elmerlockbuf, NULL, MTX_DEF); - sc->bt = rman_get_bustag(sc->regs_res); sc->bh = rman_get_bushandle(sc->regs_res); sc->mmio_len = rman_get_size(sc->regs_res); @@ -604,7 +617,7 @@ cxgb_controller_attach(device_t dev) } else { sc->flags |= TPS_UPTODATE; } - + /* * Create a child device for each MAC. The ethernet attachment * will be done in these children. @@ -636,12 +649,7 @@ cxgb_controller_attach(device_t dev) t3_sge_init_adapter(sc); t3_led_ready(sc); - - cxgb_offload_init(); - if (is_offload(sc)) { - setbit(&sc->registered_device_map, OFFLOAD_DEVMAP_BIT); - cxgb_adapter_ofld(sc); - } + error = t3_get_fw_version(sc, &vers); if (error) goto out; @@ -662,6 +670,11 @@ cxgb_controller_attach(device_t dev) device_printf(sc->dev, "Firmware Version %s\n", &sc->fw_version[0]); callout_reset(&sc->cxgb_tick_ch, hz, cxgb_tick, sc); t3_add_attach_sysctls(sc); + +#ifdef TCP_OFFLOAD + for (i = 0; i < NUM_CPL_HANDLERS; i++) + sc->cpl_handler[i] = cpl_not_handled; +#endif out: if (error) cxgb_free(sc); @@ -775,20 +788,9 @@ cxgb_free(struct adapter *sc) sc->tq = NULL; } - if (is_offload(sc)) { - clrbit(&sc->registered_device_map, OFFLOAD_DEVMAP_BIT); - cxgb_adapter_unofld(sc); - } - -#ifdef notyet - if (sc->flags & CXGB_OFLD_INIT) - cxgb_offload_deactivate(sc); -#endif free(sc->filters, M_DEVBUF); t3_sge_free(sc); - cxgb_offload_exit(); - if (sc->udbs_res != NULL) bus_release_resource(sc->dev, SYS_RES_MEMORY, sc->udbs_rid, sc->udbs_res); @@ -800,6 +802,9 @@ cxgb_free(struct adapter *sc) MTX_DESTROY(&sc->mdio_lock); MTX_DESTROY(&sc->sge.reg_lock); MTX_DESTROY(&sc->elmer_lock); + mtx_lock(&t3_list_lock); + SLIST_REMOVE(&t3_list, sc, adapter, link); + mtx_unlock(&t3_list_lock); ADAPTER_LOCK_DEINIT(sc); } @@ -1017,6 +1022,10 @@ cxgb_port_attach(device_t dev) ifp->if_qflush = cxgb_qflush; ifp->if_capabilities = CXGB_CAP; +#ifdef TCP_OFFLOAD + if (is_offload(sc)) + ifp->if_capabilities |= IFCAP_TOE4; +#endif ifp->if_capenable = CXGB_CAP_ENABLE; ifp->if_hwassist = CSUM_TCP | CSUM_UDP | CSUM_IP | CSUM_TSO; @@ -1420,65 +1429,6 @@ setup_rss(adapter_t *adap) cpus, rspq_map); } - -/* - * Sends an mbuf to an offload queue driver - * after dealing with any active network taps. - */ -static inline int -offload_tx(struct t3cdev *tdev, struct mbuf *m) -{ - int ret; - - ret = t3_offload_tx(tdev, m); - return (ret); -} - -static int -write_smt_entry(struct adapter *adapter, int idx) -{ - struct port_info *pi = &adapter->port[idx]; - struct cpl_smt_write_req *req; - struct mbuf *m; - - if ((m = m_gethdr(M_NOWAIT, MT_DATA)) == NULL) - return (ENOMEM); - - req = mtod(m, struct cpl_smt_write_req *); - m->m_pkthdr.len = m->m_len = sizeof(struct cpl_smt_write_req); - - req->wr.wrh_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); - OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SMT_WRITE_REQ, idx)); - req->mtu_idx = NMTUS - 1; /* should be 0 but there's a T3 bug */ - req->iff = idx; - memset(req->src_mac1, 0, sizeof(req->src_mac1)); - memcpy(req->src_mac0, pi->hw_addr, ETHER_ADDR_LEN); - - m_set_priority(m, 1); - - offload_tx(&adapter->tdev, m); - - return (0); -} - -static int -init_smt(struct adapter *adapter) -{ - int i; - - for_each_port(adapter, i) - write_smt_entry(adapter, i); - return 0; -} - -static void -init_port_mtus(adapter_t *adapter) -{ - unsigned int mtus = ETHERMTU | (ETHERMTU << 16); - - t3_write_reg(adapter, A_TP_MTU_PORT_TABLE, mtus); -} - static void send_pktsched_cmd(struct adapter *adap, int sched, int qidx, int lo, int hi, int port) @@ -1705,45 +1655,6 @@ cxgb_down(struct adapter *sc) t3_intr_disable(sc); } -static int -offload_open(struct port_info *pi) -{ - struct adapter *sc = pi->adapter; - struct t3cdev *tdev = &sc->tdev; - - setbit(&sc->open_device_map, OFFLOAD_DEVMAP_BIT); - - t3_tp_set_offload_mode(sc, 1); - tdev->lldev = pi->ifp; - init_port_mtus(sc); - t3_load_mtus(sc, sc->params.mtus, sc->params.a_wnd, sc->params.b_wnd, - sc->params.rev == 0 ? sc->port[0].ifp->if_mtu : 0xffff); - init_smt(sc); - cxgb_add_clients(tdev); - - return (0); -} - -static int -offload_close(struct t3cdev *tdev) -{ - struct adapter *adapter = tdev2adap(tdev); - - if (!isset(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT)) - return (0); - - /* Call back all registered clients */ - cxgb_remove_clients(tdev); - - tdev->lldev = NULL; - cxgb_set_dummy_ops(tdev); - t3_tp_set_offload_mode(adapter, 0); - - clrbit(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT); - - return (0); -} - /* * if_init for cxgb ports. */ @@ -1793,15 +1704,9 @@ cxgb_init_locked(struct port_info *p) ADAPTER_UNLOCK(sc); } - if (sc->open_device_map == 0) { - if ((rc = cxgb_up(sc)) != 0) + if (sc->open_device_map == 0 && ((rc = cxgb_up(sc)) != 0)) goto done; - if (is_offload(sc) && !ofld_disable && offload_open(p)) - log(LOG_WARNING, - "Could not initialize offload capabilities\n"); - } - PORT_LOCK(p); if (isset(&sc->open_device_map, p->port_id) && (ifp->if_drv_flags & IFF_DRV_RUNNING)) { @@ -1929,7 +1834,6 @@ cxgb_uninit_synchronized(struct port_inf DELAY(100 * 1000); t3_mac_disable(&pi->mac, MAC_DIRECTION_RX); - pi->phy.ops->power_down(&pi->phy, 1); PORT_UNLOCK(pi); @@ -1937,9 +1841,6 @@ cxgb_uninit_synchronized(struct port_inf pi->link_config.link_ok = 0; t3_os_link_changed(sc, pi->port_id, 0, 0, 0, 0, 0); - if ((sc->open_device_map & PORT_MASK) == 0) - offload_close(&sc->tdev); - if (sc->open_device_map == 0) cxgb_down(pi->adapter); @@ -2081,6 +1982,15 @@ fail: /* Safe to do this even if cxgb_up not called yet */ cxgb_set_lro(p, ifp->if_capenable & IFCAP_LRO); } +#ifdef TCP_OFFLOAD + if (mask & IFCAP_TOE4) { + int enable = (ifp->if_capenable ^ mask) & IFCAP_TOE4; + + error = toe_capability(p, enable); + if (error == 0) + ifp->if_capenable ^= mask; + } +#endif if (mask & IFCAP_VLAN_HWTAGGING) { ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING; if (ifp->if_drv_flags & IFF_DRV_RUNNING) { @@ -3362,3 +3272,235 @@ set_tcb_field_ulp(struct cpl_set_tcb_fie txpkt->len = htonl(V_ULPTX_NFLITS(sizeof(*req) / 8)); mk_set_tcb_field(req, tid, word, mask, val); } + +void +t3_iterate(void (*func)(struct adapter *, void *), void *arg) +{ + struct adapter *sc; + + mtx_lock(&t3_list_lock); + SLIST_FOREACH(sc, &t3_list, link) { + /* + * func should not make any assumptions about what state sc is + * in - the only guarantee is that sc->sc_lock is a valid lock. + */ + func(sc, arg); + } + mtx_unlock(&t3_list_lock); +} + +#ifdef TCP_OFFLOAD +static int +toe_capability(struct port_info *pi, int enable) +{ + int rc; + struct adapter *sc = pi->adapter; + + ADAPTER_LOCK_ASSERT_OWNED(sc); + + if (!is_offload(sc)) + return (ENODEV); + + if (enable) { + if (!(sc->flags & FULL_INIT_DONE)) { + log(LOG_WARNING, + "You must enable a cxgb interface first\n"); + return (EAGAIN); + } + + if (isset(&sc->offload_map, pi->port_id)) + return (0); + + if (!(sc->flags & TOM_INIT_DONE)) { + rc = t3_activate_uld(sc, ULD_TOM); + if (rc == EAGAIN) { + log(LOG_WARNING, + "You must kldload t3_tom.ko before trying " + "to enable TOE on a cxgb interface.\n"); + } + if (rc != 0) + return (rc); + KASSERT(sc->tom_softc != NULL, + ("%s: TOM activated but softc NULL", __func__)); + KASSERT(sc->flags & TOM_INIT_DONE, + ("%s: TOM activated but flag not set", __func__)); + } + + setbit(&sc->offload_map, pi->port_id); + + /* + * XXX: Temporary code to allow iWARP to be enabled when TOE is + * enabled on any port. Need to figure out how to enable, + * disable, load, and unload iWARP cleanly. + */ + if (!isset(&sc->offload_map, MAX_NPORTS) && + t3_activate_uld(sc, ULD_IWARP) == 0) + setbit(&sc->offload_map, MAX_NPORTS); + } else { + if (!isset(&sc->offload_map, pi->port_id)) + return (0); + + KASSERT(sc->flags & TOM_INIT_DONE, + ("%s: TOM never initialized?", __func__)); + clrbit(&sc->offload_map, pi->port_id); + } + + return (0); +} + +/* + * Add an upper layer driver to the global list. + */ +int +t3_register_uld(struct uld_info *ui) +{ + int rc = 0; + struct uld_info *u; + + mtx_lock(&t3_uld_list_lock); + SLIST_FOREACH(u, &t3_uld_list, link) { + if (u->uld_id == ui->uld_id) { + rc = EEXIST; + goto done; + } + } + + SLIST_INSERT_HEAD(&t3_uld_list, ui, link); + ui->refcount = 0; +done: + mtx_unlock(&t3_uld_list_lock); + return (rc); +} + +int +t3_unregister_uld(struct uld_info *ui) +{ + int rc = EINVAL; + struct uld_info *u; + + mtx_lock(&t3_uld_list_lock); + + SLIST_FOREACH(u, &t3_uld_list, link) { + if (u == ui) { + if (ui->refcount > 0) { + rc = EBUSY; + goto done; + } + + SLIST_REMOVE(&t3_uld_list, ui, uld_info, link); + rc = 0; + goto done; + } + } +done: + mtx_unlock(&t3_uld_list_lock); + return (rc); +} + +int +t3_activate_uld(struct adapter *sc, int id) +{ + int rc = EAGAIN; + struct uld_info *ui; + + mtx_lock(&t3_uld_list_lock); + + SLIST_FOREACH(ui, &t3_uld_list, link) { + if (ui->uld_id == id) { + rc = ui->activate(sc); + if (rc == 0) + ui->refcount++; + goto done; + } + } +done: + mtx_unlock(&t3_uld_list_lock); + + return (rc); +} + +int +t3_deactivate_uld(struct adapter *sc, int id) +{ + int rc = EINVAL; + struct uld_info *ui; + + mtx_lock(&t3_uld_list_lock); + + SLIST_FOREACH(ui, &t3_uld_list, link) { + if (ui->uld_id == id) { + rc = ui->deactivate(sc); + if (rc == 0) + ui->refcount--; + goto done; + } + } +done: + mtx_unlock(&t3_uld_list_lock); + + return (rc); +} + +static int +cpl_not_handled(struct sge_qset *qs __unused, struct rsp_desc *r __unused, + struct mbuf *m) +{ + m_freem(m); + return (EDOOFUS); +} + +int +t3_register_cpl_handler(struct adapter *sc, int opcode, cpl_handler_t h) +{ + uintptr_t *loc, new; + + if (opcode >= NUM_CPL_HANDLERS) + return (EINVAL); + + new = h ? (uintptr_t)h : (uintptr_t)cpl_not_handled; + loc = (uintptr_t *) &sc->cpl_handler[opcode]; + atomic_store_rel_ptr(loc, new); + + return (0); +} +#endif + +static int +cxgbc_mod_event(module_t mod, int cmd, void *arg) +{ + int rc = 0; + + switch (cmd) { + case MOD_LOAD: + mtx_init(&t3_list_lock, "T3 adapters", 0, MTX_DEF); + SLIST_INIT(&t3_list); +#ifdef TCP_OFFLOAD + mtx_init(&t3_uld_list_lock, "T3 ULDs", 0, MTX_DEF); + SLIST_INIT(&t3_uld_list); +#endif + break; + + case MOD_UNLOAD: +#ifdef TCP_OFFLOAD + mtx_lock(&t3_uld_list_lock); + if (!SLIST_EMPTY(&t3_uld_list)) { + rc = EBUSY; + mtx_unlock(&t3_uld_list_lock); + break; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 07:59:36 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 85BF8106564A; Tue, 19 Jun 2012 07:59:36 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id F1EFD8FC14; Tue, 19 Jun 2012 07:59:34 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q5J7xSA2057662; Tue, 19 Jun 2012 10:59:28 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q5J7xRd4086124; Tue, 19 Jun 2012 10:59:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q5J7xRnF086123; Tue, 19 Jun 2012 10:59:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 19 Jun 2012 10:59:27 +0300 From: Konstantin Belousov To: Benjamin Kaduk Message-ID: <20120619075927.GO2337@deviant.kiev.zoral.com.ua> References: <201206182217.q5IMHTJE003928@svn.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="JLgb/x5pnTX2rSUi" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, Rick Macklem , svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237244 - head/sys/fs/nfsclient X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 07:59:36 -0000 --JLgb/x5pnTX2rSUi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 19, 2012 at 03:06:09AM +0000, Benjamin Kaduk wrote: > On Mon, 18 Jun 2012, Rick Macklem wrote: >=20 > >Author: rmacklem > >Date: Mon Jun 18 22:17:28 2012 > >New Revision: 237244 > >URL: http://svn.freebsd.org/changeset/base/237244 > > > >Log: > > Fix the NFSv4 client for the case where mmap'd files are > > written, but not msync'd by a process. A VOP_PUTPAGES() > > called when VOP_RECLAIM() happens will usually fail, since > > the NFSv4 Open has already been closed by VOP_INACTIVE(). > > Add a vm_object_page_clean() call to the NFSv4 client's > > VOP_INACTIVE(), so that the write happens before the NFSv4 > > Open is closed. kib@ suggested using vgone() instead and > > I will explore this, but this patch fixes things in the >=20 > Hi Rick, >=20 > OpenAFS is currently using vgone() in the vnode cleanup path (though it i= s=20 > actually in RECLAIM not INACTIVE because of how AFS has traditionally=20 > separated the two). Calling vgone() from VOP_RECLAIM is exactly NOP. > However, it seems that the other *BSD implementations do not call vgone()= =20 > in the same place, instead the corresponding flush functions call=20 > cache_purge() and sometimes other things. My colleague is trying to get= =20 > our FreeBSD implementation to match, so I would be interested in your tes= t=20 > case to confirm that we do not rely on the full vgone() there. >=20 > Thanks, >=20 > Ben >=20 > > meantime. For some reason, the VOP_PUTPAGES() is still > > attaempted in VOP_RECLAIM(), but having this fail doesn't > > cause any problems except a "stateid0 in write" being logged. --JLgb/x5pnTX2rSUi Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/gMV8ACgkQC3+MBN1Mb4h74wCdGoaluRfwe75F83VID8Go5NfN KcgAn1Tsa1z7ipDa49FSUex0k8wjSKZ1 =RcIY -----END PGP SIGNATURE----- --JLgb/x5pnTX2rSUi-- From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 08:12:45 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 242E0106566C; Tue, 19 Jun 2012 08:12:45 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0F45E8FC15; Tue, 19 Jun 2012 08:12:45 +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 q5J8CiL4030296; Tue, 19 Jun 2012 08:12:44 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5J8CiqH030294; Tue, 19 Jun 2012 08:12:44 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201206190812.q5J8CiqH030294@svn.freebsd.org> From: Alan Cox Date: Tue, 19 Jun 2012 08:12:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237264 - head/sys/amd64/amd64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 08:12:45 -0000 Author: alc Date: Tue Jun 19 08:12:44 2012 New Revision: 237264 URL: http://svn.freebsd.org/changeset/base/237264 Log: Condition the implementation of pv_entry_count on PV_STATS. On amd64, pv_entry_count is purely informational. It does not serve any functional purpose. Add PV chunk locking to get_pv_entry(). Modified: head/sys/amd64/amd64/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Tue Jun 19 07:34:13 2012 (r237263) +++ head/sys/amd64/amd64/pmap.c Tue Jun 19 08:12:44 2012 (r237264) @@ -2043,10 +2043,6 @@ pv_to_chunk(pv_entry_t pv) static const uint64_t pc_freemask[_NPCM] = { PC_FREE0, PC_FREE1, PC_FREE2 }; -static long pv_entry_count; -SYSCTL_LONG(_vm_pmap, OID_AUTO, pv_entry_count, CTLFLAG_RD, &pv_entry_count, 0, - "Current number of pv entries"); - #ifdef PV_STATS static int pc_chunk_count, pc_chunk_allocs, pc_chunk_frees, pc_chunk_tryfail; @@ -2059,13 +2055,15 @@ SYSCTL_INT(_vm_pmap, OID_AUTO, pc_chunk_ SYSCTL_INT(_vm_pmap, OID_AUTO, pc_chunk_tryfail, CTLFLAG_RD, &pc_chunk_tryfail, 0, "Number of times tried to get a chunk page but failed."); -static long pv_entry_frees, pv_entry_allocs; +static long pv_entry_frees, pv_entry_allocs, pv_entry_count; static int pv_entry_spare; SYSCTL_LONG(_vm_pmap, OID_AUTO, pv_entry_frees, CTLFLAG_RD, &pv_entry_frees, 0, "Current number of pv entry frees"); SYSCTL_LONG(_vm_pmap, OID_AUTO, pv_entry_allocs, CTLFLAG_RD, &pv_entry_allocs, 0, "Current number of pv entry allocs"); +SYSCTL_LONG(_vm_pmap, OID_AUTO, pv_entry_count, CTLFLAG_RD, &pv_entry_count, 0, + "Current number of pv entries"); SYSCTL_INT(_vm_pmap, OID_AUTO, pv_entry_spare, CTLFLAG_RD, &pv_entry_spare, 0, "Current number of spare pv entries"); #endif @@ -2164,7 +2162,7 @@ pmap_pv_reclaim(pmap_t locked_pmap) pmap_resident_count_dec(pmap, freed); PV_STAT(pv_entry_frees += freed); PV_STAT(pv_entry_spare += freed); - pv_entry_count -= freed; + PV_STAT(atomic_subtract_long(&pv_entry_count, freed)); TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); if (pc->pc_map[0] == PC_FREE0 && pc->pc_map[1] == PC_FREE1 && pc->pc_map[2] == PC_FREE2) { @@ -2212,7 +2210,7 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv PMAP_LOCK_ASSERT(pmap, MA_OWNED); PV_STAT(pv_entry_frees++); PV_STAT(pv_entry_spare++); - pv_entry_count--; + PV_STAT(atomic_subtract_long(&pv_entry_count, 1)); pc = pv_to_chunk(pv); idx = pv - &pc->pc_pventry[0]; field = idx / 64; @@ -2261,9 +2259,9 @@ get_pv_entry(pmap_t pmap, boolean_t try) struct pv_chunk *pc; vm_page_t m; - rw_assert(&pvh_global_lock, RA_WLOCKED); + rw_assert(&pvh_global_lock, RA_LOCKED); PMAP_LOCK_ASSERT(pmap, MA_OWNED); - PV_STAT(pv_entry_allocs++); + PV_STAT(atomic_add_long(&pv_entry_allocs, 1)); retry: pc = TAILQ_FIRST(&pmap->pm_pvchunk); if (pc != NULL) { @@ -2283,8 +2281,8 @@ retry: TAILQ_INSERT_TAIL(&pmap->pm_pvchunk, pc, pc_list); } - pv_entry_count++; - PV_STAT(pv_entry_spare--); + PV_STAT(atomic_add_long(&pv_entry_count, 1)); + PV_STAT(atomic_subtract_int(&pv_entry_spare, 1)); return (pv); } } @@ -2300,19 +2298,21 @@ retry: if (m == NULL) goto retry; } - PV_STAT(pc_chunk_count++); - PV_STAT(pc_chunk_allocs++); + PV_STAT(atomic_add_int(&pc_chunk_count, 1)); + PV_STAT(atomic_add_int(&pc_chunk_allocs, 1)); dump_add_page(m->phys_addr); pc = (void *)PHYS_TO_DMAP(m->phys_addr); pc->pc_pmap = pmap; pc->pc_map[0] = PC_FREE0 & ~1ul; /* preallocated bit 0 */ pc->pc_map[1] = PC_FREE1; pc->pc_map[2] = PC_FREE2; + mtx_lock(&pv_chunks_mutex); TAILQ_INSERT_TAIL(&pv_chunks, pc, pc_lru); + mtx_unlock(&pv_chunks_mutex); pv = &pc->pc_pventry[0]; TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list); - pv_entry_count++; - PV_STAT(pv_entry_spare += _NPCPV - 1); + PV_STAT(atomic_add_long(&pv_entry_count, 1)); + PV_STAT(atomic_add_int(&pv_entry_spare, _NPCPV - 1)); return (pv); } @@ -4266,7 +4266,7 @@ pmap_remove_pages(pmap_t pmap) } PV_STAT(atomic_add_long(&pv_entry_frees, freed)); PV_STAT(atomic_add_int(&pv_entry_spare, freed)); - atomic_subtract_long(&pv_entry_count, freed); + PV_STAT(atomic_subtract_long(&pv_entry_count, freed)); if (allfree) { if (lock != NULL) { rw_wunlock(lock); From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 09:09:58 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AC024106564A; Tue, 19 Jun 2012 09:09:58 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 788D68FC17; Tue, 19 Jun 2012 09:09:57 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id MAA05790; Tue, 19 Jun 2012 12:09:35 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1SguRK-000ARC-LZ; Tue, 19 Jun 2012 12:09:34 +0300 Message-ID: <4FE041CB.5080506@FreeBSD.org> Date: Tue, 19 Jun 2012 12:09:31 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:13.0) Gecko/20120613 Thunderbird/13.0 MIME-Version: 1.0 To: Poul-Henning Kamp References: <31750.1340083631@critter.freebsd.dk> In-Reply-To: <31750.1340083631@critter.freebsd.dk> X-Enigmail-Version: 1.4.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, Daniel O'Connor , svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r237223 - head/sys/dev/fb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 09:09:58 -0000 on 19/06/2012 08:27 Poul-Henning Kamp said the following: > In message <68FBE843-7337-4C90-B01F-E0CAABB62BCD@gsoft.com.au>, "Daniel O'Conno > r" writes: > >>> If size is odd, this does not copy the last byte. Not sure, whether = >> this is intended. > > Feel free to improve... Interesting reaction to a bug reported in one's freshly committed code... -- Andriy Gapon From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 11:39:56 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E7E77106564A; Tue, 19 Jun 2012 11:39:56 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D395E8FC08; Tue, 19 Jun 2012 11:39:56 +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 q5JBduXw041788; Tue, 19 Jun 2012 11:39:56 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5JBdugJ041786; Tue, 19 Jun 2012 11:39:56 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201206191139.q5JBdugJ041786@svn.freebsd.org> From: Baptiste Daroussin Date: Tue, 19 Jun 2012 11:39:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237268 - head/lib/libutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 11:39:57 -0000 Author: bapt Date: Tue Jun 19 11:39:56 2012 New Revision: 237268 URL: http://svn.freebsd.org/changeset/base/237268 Log: Revert user comparison back to user names as some user can share uids (root/toor for example) get the username information from old_pw structures to still allow renaming of a user. Reported by: Claude Buisson Approved by: des (mentor) MFC after: 3 weeks Modified: head/lib/libutil/pw_util.c Modified: head/lib/libutil/pw_util.c ============================================================================== --- head/lib/libutil/pw_util.c Tue Jun 19 10:07:50 2012 (r237267) +++ head/lib/libutil/pw_util.c Tue Jun 19 11:39:56 2012 (r237268) @@ -437,14 +437,21 @@ pw_copy(int ffd, int tfd, const struct p size_t len; int eof, readlen; - spw = pw; + if (old_pw == NULL && pw == NULL) + return (-1); + + spw = old_pw; + /* deleting a user */ if (pw == NULL) { line = NULL; - if (old_pw == NULL) + } else { + if ((line = pw_make(pw)) == NULL) return (-1); - spw = old_pw; - } else if ((line = pw_make(pw)) == NULL) - return (-1); + } + + /* adding a user */ + if (spw == NULL) + spw = pw; eof = 0; len = 0; @@ -511,7 +518,7 @@ pw_copy(int ffd, int tfd, const struct p */ *q = t; - if (fpw == NULL || fpw->pw_uid != spw->pw_uid) { + if (fpw == NULL || strcmp(fpw->pw_name, spw->pw_name) != 0) { /* nope */ if (fpw != NULL) free(fpw); From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 14:46:19 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ADE5F1065677; Tue, 19 Jun 2012 14:46:19 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 982AA8FC1D; Tue, 19 Jun 2012 14:46:19 +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 q5JEkJ1L050839; Tue, 19 Jun 2012 14:46:19 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5JEkJTY050836; Tue, 19 Jun 2012 14:46:19 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201206191446.q5JEkJTY050836@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Tue, 19 Jun 2012 14:46:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237269 - in head: etc lib/libutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 14:46:19 -0000 Author: des Date: Tue Jun 19 14:46:18 2012 New Revision: 237269 URL: http://svn.freebsd.org/changeset/base/237269 Log: Switch the default password hash from md5 to sha512. MFC after: 1 week Modified: head/etc/login.conf head/lib/libutil/login.conf.5 Modified: head/etc/login.conf ============================================================================== --- head/etc/login.conf Tue Jun 19 11:39:56 2012 (r237268) +++ head/etc/login.conf Tue Jun 19 14:46:18 2012 (r237269) @@ -23,7 +23,7 @@ # AND SEMANTICS'' section of getcap(3) for more escape sequences). default:\ - :passwd_format=md5:\ + :passwd_format=sha512:\ :copyright=/etc/COPYRIGHT:\ :welcome=/etc/motd:\ :setenv=MAIL=/var/mail/$,BLOCKSIZE=K,FTP_PASSIVE_MODE=YES:\ Modified: head/lib/libutil/login.conf.5 ============================================================================== --- head/lib/libutil/login.conf.5 Tue Jun 19 11:39:56 2012 (r237268) +++ head/lib/libutil/login.conf.5 Tue Jun 19 14:46:18 2012 (r237269) @@ -267,7 +267,7 @@ The backoff delay is the number of tries multiplied by 5 seconds. .It "login-retries number 10 The number of login attempts" allowed before the login fails. -.It "passwd_format string md5 The encryption format that new or" +.It "passwd_format string sha512 The encryption format that new or" changed passwords will use. Valid values include "des", "md5", "blf", "sha256" and "sha512"; see .Xr crypt 3 From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 14:47:08 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 30FE01065670; Tue, 19 Jun 2012 14:47:08 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1B93D8FC22; Tue, 19 Jun 2012 14:47:08 +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 q5JEl7ua050910; Tue, 19 Jun 2012 14:47:07 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5JEl7DO050908; Tue, 19 Jun 2012 14:47:07 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201206191447.q5JEl7DO050908@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Tue, 19 Jun 2012 14:47:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237270 - head/etc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 14:47:08 -0000 Author: des Date: Tue Jun 19 14:47:07 2012 New Revision: 237270 URL: http://svn.freebsd.org/changeset/base/237270 Log: Passive mode is the default, and has been for a while. MFC after: 1 week Modified: head/etc/login.conf Modified: head/etc/login.conf ============================================================================== --- head/etc/login.conf Tue Jun 19 14:46:18 2012 (r237269) +++ head/etc/login.conf Tue Jun 19 14:47:07 2012 (r237270) @@ -26,7 +26,7 @@ default:\ :passwd_format=sha512:\ :copyright=/etc/COPYRIGHT:\ :welcome=/etc/motd:\ - :setenv=MAIL=/var/mail/$,BLOCKSIZE=K,FTP_PASSIVE_MODE=YES:\ + :setenv=MAIL=/var/mail/$,BLOCKSIZE=K:\ :path=/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin ~/bin:\ :nologin=/var/run/nologin:\ :cputime=unlimited:\ From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 15:15:35 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E7E661065674; Tue, 19 Jun 2012 15:15:35 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D3D368FC23; Tue, 19 Jun 2012 15:15:35 +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 q5JFFZ6E052405; Tue, 19 Jun 2012 15:15:35 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5JFFZDk052403; Tue, 19 Jun 2012 15:15:35 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206191515.q5JFFZDk052403@svn.freebsd.org> From: John Baldwin Date: Tue, 19 Jun 2012 15:15:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237271 - head/sys/dev/pci X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 15:15:36 -0000 Author: jhb Date: Tue Jun 19 15:15:35 2012 New Revision: 237271 URL: http://svn.freebsd.org/changeset/base/237271 Log: Fix another off-by-one error in the previous fix so that the new start address is properly aligned. While here, use a simpler expression to align the new end address that we use elsewhere for aligning the end. Modified: head/sys/dev/pci/pci_pci.c Modified: head/sys/dev/pci/pci_pci.c ============================================================================== --- head/sys/dev/pci/pci_pci.c Tue Jun 19 14:47:07 2012 (r237270) +++ head/sys/dev/pci/pci_pci.c Tue Jun 19 15:15:35 2012 (r237271) @@ -913,7 +913,7 @@ pcib_grow_window(struct pcib_softc *sc, if (bootverbose) printf("\tfront candidate range: %#lx-%#lx\n", front, end_free); - front &= ~(1ul << w->step) - 1; + front &= ~((1ul << w->step) - 1); front = rman_get_start(w->res) - front; } else front = 0; @@ -941,7 +941,7 @@ pcib_grow_window(struct pcib_softc *sc, if (bootverbose) printf("\tback candidate range: %#lx-%#lx\n", start_free, back); - back = roundup2(back + 1, 1ul << w->step) - 1; + back |= (1ul << w->step) - 1; back -= rman_get_end(w->res); } else back = 0; From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 16:06:28 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B0F7106564A; Tue, 19 Jun 2012 16:06:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2B35A8FC14; Tue, 19 Jun 2012 16:06:28 +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 q5JG6SZD060043; Tue, 19 Jun 2012 16:06:28 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5JG6Ron060041; Tue, 19 Jun 2012 16:06:27 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206191606.q5JG6Ron060041@svn.freebsd.org> From: John Baldwin Date: Tue, 19 Jun 2012 16:06:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237272 - head/sys/dev/pci X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 16:06:28 -0000 Author: jhb Date: Tue Jun 19 16:06:27 2012 New Revision: 237272 URL: http://svn.freebsd.org/changeset/base/237272 Log: Add a 'wmask' variable to hold the expression '(1ul << w->step) - 1' in pcib_grow_window(). This makes the code slightly easier to read and prevents the type of bug fixed in r237271. MFC after: 3 days Modified: head/sys/dev/pci/pci_pci.c Modified: head/sys/dev/pci/pci_pci.c ============================================================================== --- head/sys/dev/pci/pci_pci.c Tue Jun 19 15:15:35 2012 (r237271) +++ head/sys/dev/pci/pci_pci.c Tue Jun 19 16:06:27 2012 (r237272) @@ -815,7 +815,7 @@ static int pcib_grow_window(struct pcib_softc *sc, struct pcib_window *w, int type, u_long start, u_long end, u_long count, u_int flags) { - u_long align, start_free, end_free, front, back; + u_long align, start_free, end_free, front, back, wmask; int error, rid; /* @@ -828,6 +828,7 @@ pcib_grow_window(struct pcib_softc *sc, end = w->rman.rm_end; if (start + count - 1 > end || start + count < start) return (EINVAL); + wmask = (1ul << w->step) - 1; /* * If there is no resource at all, just try to allocate enough @@ -838,8 +839,8 @@ pcib_grow_window(struct pcib_softc *sc, flags &= ~RF_ALIGNMENT_MASK; flags |= RF_ALIGNMENT_LOG2(w->step); } - start &= ~((1ul << w->step) - 1); - end |= ((1ul << w->step) - 1); + start &= ~wmask; + end |= wmask; count = roundup2(count, 1ul << w->step); rid = w->reg; w->res = bus_alloc_resource(sc->dev, type, &rid, start, end, @@ -913,7 +914,7 @@ pcib_grow_window(struct pcib_softc *sc, if (bootverbose) printf("\tfront candidate range: %#lx-%#lx\n", front, end_free); - front &= ~((1ul << w->step) - 1); + front &= ~wmask; front = rman_get_start(w->res) - front; } else front = 0; @@ -941,7 +942,7 @@ pcib_grow_window(struct pcib_softc *sc, if (bootverbose) printf("\tback candidate range: %#lx-%#lx\n", start_free, back); - back |= (1ul << w->step) - 1; + back |= wmask; back -= rman_get_end(w->res); } else back = 0; @@ -1000,10 +1001,8 @@ updatewin: /* Save the new window. */ w->base = rman_get_start(w->res); w->limit = rman_get_end(w->res); - KASSERT((w->base & ((1ul << w->step) - 1)) == 0, - ("start address is not aligned")); - KASSERT((w->limit & ((1ul << w->step) - 1)) == (1ul << w->step) - 1, - ("end address is not aligned")); + KASSERT((w->base & wmask) == 0, ("start address is not aligned")); + KASSERT((w->limit & wmask) == wmask, ("end address is not aligned")); pcib_write_windows(sc, w->mask); return (0); } From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 16:13:20 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1033) id 47A0F106566C; Tue, 19 Jun 2012 16:13:20 +0000 (UTC) Date: Tue, 19 Jun 2012 16:13:20 +0000 From: Alexey Dokuchaev To: Dag-Erling Smorgrav Message-ID: <20120619161320.GA54109@FreeBSD.org> References: <201206191446.q5JEkJTY050836@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <201206191446.q5JEkJTY050836@svn.freebsd.org> User-Agent: Mutt/1.4.2.1i Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237269 - in head: etc lib/libutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 16:13:20 -0000 On Tue, Jun 19, 2012 at 02:46:19PM +0000, Dag-Erling Smorgrav wrote: > Author: des > Date: Tue Jun 19 14:46:18 2012 > New Revision: 237269 > URL: http://svn.freebsd.org/changeset/base/237269 > > Log: > Switch the default password hash from md5 to sha512. Pardon my possible unawareness, but was this change discussed anywhere? I understand the rationale to move away from MD5, but reasons for SHA512 seem moot. I've personally had been using Blowfish for password hashes since OpenBSD switched to it, for example, as fast and apparently reliable hash. Is there anything wrong with it? Why SHA512 is clear winner here? FWIW, ports use SHA256 for now. Could it be that switch to SHA512 will impose perfomance problems? ./danfe From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 16:21:16 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 55C97106564A; Tue, 19 Jun 2012 16:21:16 +0000 (UTC) (envelope-from utisoft@gmail.com) Received: from mail-bk0-f54.google.com (mail-bk0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 1E3528FC08; Tue, 19 Jun 2012 16:21:14 +0000 (UTC) Received: by bkvi18 with SMTP id i18so6610821bkv.13 for ; Tue, 19 Jun 2012 09:21:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=AHOOm6WRNMaGmwpHbpgLcK1f5MEV6lxX7+yzhirkTbw=; b=pnSCNfJ6MUbI1gZexsVGaaqA/5LOlLOdRzA+NsoEAVFbuQAVoF0JsztQQQVgnAOZv5 aAuJhxLl4mMOtSLmtzJphULC6Z8UjJIjFS7ozPP1SgAXqYaHyvSypT7WJWzeZuI1Aavj l6+iHxiACOpJ2taffyCLUWFouYP4llZHYhuNpsuIMX0pJ48FxE0jSzKdt8l0ie5rHJtw AvMltMfI+sPBufAplAhNSOYSHAkioDV5QRTaF9rU39i9bR4CmmAWkW2SkV6PuYKMMGdP kxg/YKUVguu6YJ60v7kAGo0K2YOStJwViMN4CV1ghLHpt+wBF1KTcInT88tMNUFc3T9v tY7w== MIME-Version: 1.0 Received: by 10.204.153.15 with SMTP id i15mr52711bkw.74.1340122874110; Tue, 19 Jun 2012 09:21:14 -0700 (PDT) Received: by 10.204.171.138 with HTTP; Tue, 19 Jun 2012 09:21:13 -0700 (PDT) Received: by 10.204.171.138 with HTTP; Tue, 19 Jun 2012 09:21:13 -0700 (PDT) In-Reply-To: <20120619161320.GA54109@FreeBSD.org> References: <201206191446.q5JEkJTY050836@svn.freebsd.org> <20120619161320.GA54109@FreeBSD.org> Date: Tue, 19 Jun 2012 17:21:13 +0100 Message-ID: From: Chris Rees To: Alexey Dokuchaev Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Dag-Erling Smorgrav Subject: Re: svn commit: r237269 - in head: etc lib/libutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 16:21:16 -0000 On Jun 19, 2012 5:15 PM, "Alexey Dokuchaev" wrote: > > On Tue, Jun 19, 2012 at 02:46:19PM +0000, Dag-Erling Smorgrav wrote: > > Author: des > > Date: Tue Jun 19 14:46:18 2012 > > New Revision: 237269 > > URL: http://svn.freebsd.org/changeset/base/237269 > > > > Log: > > Switch the default password hash from md5 to sha512. > > Pardon my possible unawareness, but was this change discussed anywhere? http://lists.freebsd.org/pipermail/freebsd-security/2012-June/006271.html > I understand the rationale to move away from MD5, but reasons for SHA512 > seem moot. I've personally had been using Blowfish for password hashes > since OpenBSD switched to it, for example, as fast and apparently reliable > hash. Is there anything wrong with it? Why SHA512 is clear winner here? > FWIW, ports use SHA256 for now. Could it be that switch to SHA512 will > impose perfomance problems? Why would you want password matching to be fast? That makes brute-forcing easier. Chris From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 17:13:14 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AA887106566B; Tue, 19 Jun 2012 17:13:14 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 963698FC15; Tue, 19 Jun 2012 17:13:14 +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 q5JHDEff071288; Tue, 19 Jun 2012 17:13:14 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5JHDEbk071286; Tue, 19 Jun 2012 17:13:14 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201206191713.q5JHDEbk071286@svn.freebsd.org> From: Sean Bruno Date: Tue, 19 Jun 2012 17:13:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237273 - head/share/man/man4 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 17:13:14 -0000 Author: sbruno Date: Tue Jun 19 17:13:14 2012 New Revision: 237273 URL: http://svn.freebsd.org/changeset/base/237273 Log: Correct misunderstanding of hw.est.strict Setting strict causes a validation of the requested value vs the value currently running after a frequency change is requested. Change applicability to be single core not i386. Thanks to mav@ for reviewing and commenting on my lack of understanding. MFC after: 2 weeks Modified: head/share/man/man4/est.4 Modified: head/share/man/man4/est.4 ============================================================================== --- head/share/man/man4/est.4 Tue Jun 19 16:06:27 2012 (r237272) +++ head/share/man/man4/est.4 Tue Jun 19 17:13:14 2012 (r237273) @@ -66,8 +66,8 @@ Attempt to infer information from direct Should only be used in diagnostic cases .Pq default 0 .It hw.est.strict -Do not allow different cpus to be set to different frequencies. -It appears that this will only work on i386 systems +Validate frequency requested is accepted by the cpu when set. +It appears that this will only work on single core cpus. .Pq default 0 .El .Sh DIAGNOSTICS From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 17:17:26 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1033) id 1E004106566B; Tue, 19 Jun 2012 17:17:26 +0000 (UTC) Date: Tue, 19 Jun 2012 17:17:26 +0000 From: Alexey Dokuchaev To: Chris Rees Message-ID: <20120619171726.GA72257@FreeBSD.org> References: <201206191446.q5JEkJTY050836@svn.freebsd.org> <20120619161320.GA54109@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Dag-Erling Smorgrav Subject: Re: svn commit: r237269 - in head: etc lib/libutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 17:17:26 -0000 On Tue, Jun 19, 2012 at 05:21:13PM +0100, Chris Rees wrote: > On Jun 19, 2012 5:15 PM, "Alexey Dokuchaev" wrote: > > Pardon my possible unawareness, but was this change discussed anywhere? > > http://lists.freebsd.org/pipermail/freebsd-security/2012-June/006271.html Thanks for the link, I didn't check -security@ for some reason. > > I understand the rationale to move away from MD5, but reasons for SHA512 > > seem moot. I've personally had been using Blowfish for password hashes > > since OpenBSD switched to it, for example, as fast and apparently reliable > > hash. Is there anything wrong with it? Why SHA512 is clear winner here? > > FWIW, ports use SHA256 for now. Could it be that switch to SHA512 will > > impose performance problems? > > Why would you want password matching to be fast? That makes brute-forcing > easier. Maybe I don't. I just want to know if I should switch from Blowfish to SHA512. It seems that the former is quite popular judging from discussion link given above. It also seems that des@' rationale for the switch boils down to "I vastly prefer sha512 to blf, as that is what the rest of the world uses." If there's nothing wrong with Blowfish, I guess I'll stick to it as I prefer compatibility among *BSD to some weird Unix clones. :-) ./danfe From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 18:27:54 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3046110656A6; Tue, 19 Jun 2012 18:27:54 +0000 (UTC) (envelope-from des@des.no) Received: from smtp.des.no (smtp.des.no [194.63.250.102]) by mx1.freebsd.org (Postfix) with ESMTP id C9FF08FC19; Tue, 19 Jun 2012 18:27:53 +0000 (UTC) Received: from ds4.des.no (smtp.des.no [194.63.250.102]) by smtp.des.no (Postfix) with ESMTP id D24D86641; Tue, 19 Jun 2012 18:27:52 +0000 (UTC) Received: by ds4.des.no (Postfix, from userid 1001) id 6EFF38479; Tue, 19 Jun 2012 20:27:52 +0200 (CEST) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Alexey Dokuchaev References: <201206191446.q5JEkJTY050836@svn.freebsd.org> <20120619161320.GA54109@FreeBSD.org> <20120619171726.GA72257@FreeBSD.org> Date: Tue, 19 Jun 2012 20:27:52 +0200 In-Reply-To: <20120619171726.GA72257@FreeBSD.org> (Alexey Dokuchaev's message of "Tue, 19 Jun 2012 17:17:26 +0000") Message-ID: <86d34v40nr.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Chris Rees Subject: Re: svn commit: r237269 - in head: etc lib/libutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 18:27:54 -0000 Alexey Dokuchaev writes: > Maybe I don't. I just want to know if I should switch from Blowfish to > SHA512. It seems that the former is quite popular judging from discussion > link given above. It also seems that des@' rationale for the switch boils > down to "I vastly prefer sha512 to blf, as that is what the rest of the > world uses." If there's nothing wrong with Blowfish, I guess I'll stick = to > it as I prefer compatibility among *BSD to some weird Unix clones. :-) My understanding is that blf and sha512 are approximately equally hard (or equally easy, if you like) to brute-force with a CPU, but sha512 is supposedly less GPU-friendly. That plus compatibility - but mostly compatibility, to be honest - tipped the scales in favor of sha512. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 18:40:20 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1033) id 01DDE106566C; Tue, 19 Jun 2012 18:40:20 +0000 (UTC) Date: Tue, 19 Jun 2012 18:40:19 +0000 From: Alexey Dokuchaev To: Dag-Erling Sm??rgrav Message-ID: <20120619184019.GA4692@FreeBSD.org> References: <201206191446.q5JEkJTY050836@svn.freebsd.org> <20120619161320.GA54109@FreeBSD.org> <20120619171726.GA72257@FreeBSD.org> <86d34v40nr.fsf@ds4.des.no> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <86d34v40nr.fsf@ds4.des.no> User-Agent: Mutt/1.4.2.1i Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Chris Rees Subject: Re: svn commit: r237269 - in head: etc lib/libutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 18:40:20 -0000 On Tue, Jun 19, 2012 at 08:27:52PM +0200, Dag-Erling Sm??rgrav wrote: > Alexey Dokuchaev writes: > > Maybe I don't. I just want to know if I should switch from Blowfish to > > SHA512. It seems that the former is quite popular judging from discussion > > link given above. It also seems that des@' rationale for the switch boils > > down to "I vastly prefer sha512 to blf, as that is what the rest of the > > world uses." If there's nothing wrong with Blowfish, I guess I'll stick to > > it as I prefer compatibility among *BSD to some weird Unix clones. :-) > > My understanding is that blf and sha512 are approximately equally hard > (or equally easy, if you like) to brute-force with a CPU, but sha512 is > supposedly less GPU-friendly. That plus compatibility - but mostly > compatibility, to be honest - tipped the scales in favor of sha512. This CPU vs. GPU particularity is something I wanted to know about, actually. Thanks for this piece of knowledge Dag-Erling, and sorry for the noise. ./danfe From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 18:42:25 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A9F2210656D8; Tue, 19 Jun 2012 18:42:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 939818FC1F; Tue, 19 Jun 2012 18:42:25 +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 q5JIgP2Y085923; Tue, 19 Jun 2012 18:42:25 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5JIgPBw085918; Tue, 19 Jun 2012 18:42:25 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206191842.q5JIgPBw085918@svn.freebsd.org> From: John Baldwin Date: Tue, 19 Jun 2012 18:42:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237274 - in head: lib/libc/sys sys/kern sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 18:42:25 -0000 Author: jhb Date: Tue Jun 19 18:42:24 2012 New Revision: 237274 URL: http://svn.freebsd.org/changeset/base/237274 Log: Further refine the implementation of POSIX_FADV_NOREUSE. First, extend the changes in r230782 to better handle the common case of using NOREUSE with sequential reads. A NOREUSE file descriptor will now track the last implicit DONTNEED request it made as a result of a NOREUSE read. If a subsequent NOREUSE read is adjacent to the previous range, it will apply the DONTNEED request to the entire range of both the previous read and the current read. The effect is that each read of a file accessed sequentially will apply the DONTNEED request to the entire range that has been read. This allows NOREUSE to properly handle misaligned reads by flushing each buffer to cache once it has been completely read. Second, apply the same changes made to read(2) by r230782 and this change to writes. This provides much better performance in the sequential write case as it allows writes to still be clustered. It also provides much better performance for misaligned writes. It does mean that NOREUSE will be generally ineffective for non-sequential writes as the current implementation relies on a future NOREUSE write's implicit DONTNEED request to flush the dirty buffer from the current write. MFC after: 2 weeks Modified: head/lib/libc/sys/posix_fadvise.2 head/sys/kern/vfs_syscalls.c head/sys/kern/vfs_vnops.c head/sys/sys/file.h Modified: head/lib/libc/sys/posix_fadvise.2 ============================================================================== --- head/lib/libc/sys/posix_fadvise.2 Tue Jun 19 17:13:14 2012 (r237273) +++ head/lib/libc/sys/posix_fadvise.2 Tue Jun 19 18:42:24 2012 (r237274) @@ -28,7 +28,7 @@ .\" @(#)madvise.2 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd February 25, 2012 +.Dd June 19, 2012 .Dt POSIX_FADVISE 2 .Os .Sh NAME @@ -84,10 +84,9 @@ specified range and future access to thi .It Dv POSIX_FADV_NOREUSE Tells the system that the specified data will only be accessed once and then not reused. -Accesses to data within the specified range are treated as if the file -descriptor has the -.Dv O_DIRECT -flag enabled. +The system may decrease the in-memory priority of data once it has been +read or written. +Future access to this data may require a read operation. .El .Sh RETURN VALUES .Rv -std posix_fadvise Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Tue Jun 19 17:13:14 2012 (r237273) +++ head/sys/kern/vfs_syscalls.c Tue Jun 19 18:42:24 2012 (r237274) @@ -4872,6 +4872,8 @@ kern_posix_fadvise(struct thread *td, in new->fa_advice = advice; new->fa_start = offset; new->fa_end = end; + new->fa_prevstart = 0; + new->fa_prevend = 0; fp->f_advice = new; new = fa; } Modified: head/sys/kern/vfs_vnops.c ============================================================================== --- head/sys/kern/vfs_vnops.c Tue Jun 19 17:13:14 2012 (r237273) +++ head/sys/kern/vfs_vnops.c Tue Jun 19 18:42:24 2012 (r237274) @@ -542,7 +542,7 @@ vn_read(fp, uio, active_cred, flags, td) int error, ioflag; struct mtx *mtxp; int advice, vfslocked; - off_t offset; + off_t offset, start, end; KASSERT(uio->uio_td == td, ("uio_td %p is not td %p", uio->uio_td, td)); @@ -607,9 +607,38 @@ vn_read(fp, uio, active_cred, flags, td) fp->f_nextoff = uio->uio_offset; VOP_UNLOCK(vp, 0); if (error == 0 && advice == POSIX_FADV_NOREUSE && - offset != uio->uio_offset) - error = VOP_ADVISE(vp, offset, uio->uio_offset - 1, - POSIX_FADV_DONTNEED); + offset != uio->uio_offset) { + /* + * Use POSIX_FADV_DONTNEED to flush clean pages and + * buffers for the backing file after a + * POSIX_FADV_NOREUSE read(2). To optimize the common + * case of using POSIX_FADV_NOREUSE with sequential + * access, track the previous implicit DONTNEED + * request and grow this request to include the + * current read(2) in addition to the previous + * DONTNEED. With purely sequential access this will + * cause the DONTNEED requests to continously grow to + * cover all of the previously read regions of the + * file. This allows filesystem blocks that are + * accessed by multiple calls to read(2) to be flushed + * once the last read(2) finishes. + */ + start = offset; + end = uio->uio_offset - 1; + mtx_lock(mtxp); + if (fp->f_advice != NULL && + fp->f_advice->fa_advice == POSIX_FADV_NOREUSE) { + if (start != 0 && fp->f_advice->fa_prevend + 1 == start) + start = fp->f_advice->fa_prevstart; + else if (fp->f_advice->fa_prevstart != 0 && + fp->f_advice->fa_prevstart == end + 1) + end = fp->f_advice->fa_prevend; + fp->f_advice->fa_prevstart = start; + fp->f_advice->fa_prevend = end; + } + mtx_unlock(mtxp); + error = VOP_ADVISE(vp, start, end, POSIX_FADV_DONTNEED); + } VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -630,6 +659,7 @@ vn_write(fp, uio, active_cred, flags, td int error, ioflag, lock_flags; struct mtx *mtxp; int advice, vfslocked; + off_t offset, start, end; KASSERT(uio->uio_td == td, ("uio_td %p is not td %p", uio->uio_td, td)); @@ -664,6 +694,7 @@ vn_write(fp, uio, active_cred, flags, td if ((flags & FOF_OFFSET) == 0) uio->uio_offset = fp->f_offset; advice = POSIX_FADV_NORMAL; + mtxp = NULL; if (fp->f_advice != NULL) { mtxp = mtx_pool_find(mtxpool_sleep, fp); mtx_lock(mtxp); @@ -676,19 +707,14 @@ vn_write(fp, uio, active_cred, flags, td switch (advice) { case POSIX_FADV_NORMAL: case POSIX_FADV_SEQUENTIAL: + case POSIX_FADV_NOREUSE: ioflag |= sequential_heuristic(uio, fp); break; case POSIX_FADV_RANDOM: /* XXX: Is this correct? */ break; - case POSIX_FADV_NOREUSE: - /* - * Request the underlying FS to discard the buffers - * and pages after the I/O is complete. - */ - ioflag |= IO_DIRECT; - break; } + offset = uio->uio_offset; #ifdef MAC error = mac_vnode_check_write(active_cred, fp->f_cred, vp); @@ -701,6 +727,55 @@ vn_write(fp, uio, active_cred, flags, td VOP_UNLOCK(vp, 0); if (vp->v_type != VCHR) vn_finished_write(mp); + if (error == 0 && advice == POSIX_FADV_NOREUSE && + offset != uio->uio_offset) { + /* + * Use POSIX_FADV_DONTNEED to flush clean pages and + * buffers for the backing file after a + * POSIX_FADV_NOREUSE write(2). To optimize the + * common case of using POSIX_FADV_NOREUSE with + * sequential access, track the previous implicit + * DONTNEED request and grow this request to include + * the current write(2) in addition to the previous + * DONTNEED. With purely sequential access this will + * cause the DONTNEED requests to continously grow to + * cover all of the previously written regions of the + * file. + * + * Note that the blocks just written are almost + * certainly still dirty, so this only works when + * VOP_ADVISE() calls from subsequent writes push out + * the data written by this write(2) once the backing + * buffers are clean. However, as compared to forcing + * IO_DIRECT, this gives much saner behavior. Write + * clustering is still allowed, and clean pages are + * merely moved to the cache page queue rather than + * outright thrown away. This means a subsequent + * read(2) can still avoid hitting the disk if the + * pages have not been reclaimed. + * + * This does make POSIX_FADV_NOREUSE largely useless + * with non-sequential access. However, sequential + * access is the more common use case and the flag is + * merely advisory. + */ + start = offset; + end = uio->uio_offset - 1; + mtx_lock(mtxp); + if (fp->f_advice != NULL && + fp->f_advice->fa_advice == POSIX_FADV_NOREUSE) { + if (start != 0 && fp->f_advice->fa_prevend + 1 == start) + start = fp->f_advice->fa_prevstart; + else if (fp->f_advice->fa_prevstart != 0 && + fp->f_advice->fa_prevstart == end + 1) + end = fp->f_advice->fa_prevend; + fp->f_advice->fa_prevstart = start; + fp->f_advice->fa_prevend = end; + } + mtx_unlock(mtxp); + error = VOP_ADVISE(vp, start, end, POSIX_FADV_DONTNEED); + } + unlock: VFS_UNLOCK_GIANT(vfslocked); return (error); Modified: head/sys/sys/file.h ============================================================================== --- head/sys/sys/file.h Tue Jun 19 17:13:14 2012 (r237273) +++ head/sys/sys/file.h Tue Jun 19 18:42:24 2012 (r237274) @@ -126,6 +126,8 @@ struct fadvise_info { int fa_advice; /* (f) FADV_* type. */ off_t fa_start; /* (f) Region start. */ off_t fa_end; /* (f) Region end. */ + off_t fa_prevstart; /* (f) Previous NOREUSE start. */ + off_t fa_prevend; /* (f) Previous NOREUSE end. */ }; struct file { From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 22:22:00 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 49D111065672; Tue, 19 Jun 2012 22:22:00 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 34ABE8FC0A; Tue, 19 Jun 2012 22:22:00 +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 q5JMM0S1000745; Tue, 19 Jun 2012 22:22:00 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5JMLxVj000743; Tue, 19 Jun 2012 22:22:00 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201206192222.q5JMLxVj000743@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Tue, 19 Jun 2012 22:21:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237276 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 22:22:00 -0000 Author: pjd Date: Tue Jun 19 22:21:59 2012 New Revision: 237276 URL: http://svn.freebsd.org/changeset/base/237276 Log: The falloc() function obtains two references to newly created 'fp'. On success we have to drop one after procdesc_finit() and on failure we have to close allocated slot with fdclose(), which also drops one reference for us and drop the remaining reference with fdrop(). Without this change closing process descriptor didn't result in killing pdfork(2)ed child. Reviewed by: rwatson MFC after: 1 month Modified: head/sys/kern/kern_fork.c Modified: head/sys/kern/kern_fork.c ============================================================================== --- head/sys/kern/kern_fork.c Tue Jun 19 19:40:54 2012 (r237275) +++ head/sys/kern/kern_fork.c Tue Jun 19 22:21:59 2012 (r237276) @@ -921,8 +921,10 @@ fork1(struct thread *td, int flags, int */ *procp = newproc; #ifdef PROCDESC - if (flags & RFPROCDESC) + if (flags & RFPROCDESC) { procdesc_finit(newproc->p_procdesc, fp_procdesc); + fdrop(fp_procdesc, td); + } #endif racct_proc_fork_done(newproc); return (0); @@ -944,8 +946,10 @@ fail1: vmspace_free(vm2); uma_zfree(proc_zone, newproc); #ifdef PROCDESC - if (((flags & RFPROCDESC) != 0) && (fp_procdesc != NULL)) + if (((flags & RFPROCDESC) != 0) && (fp_procdesc != NULL)) { + fdclose(td->td_proc->p_fd, fp_procdesc, *procdescp, td); fdrop(fp_procdesc, td); + } #endif pause("fork", hz / 2); return (error); From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 22:24:00 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3066D106566B; Tue, 19 Jun 2012 22:24:00 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1B5888FC0C; Tue, 19 Jun 2012 22:24:00 +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 q5JMNxDf000865; Tue, 19 Jun 2012 22:23:59 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5JMNxs3000863; Tue, 19 Jun 2012 22:23:59 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201206192223.q5JMNxs3000863@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Tue, 19 Jun 2012 22:23:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237277 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 22:24:00 -0000 Author: pjd Date: Tue Jun 19 22:23:59 2012 New Revision: 237277 URL: http://svn.freebsd.org/changeset/base/237277 Log: Check proper flag (PDF_DAEMON, not PD_DAEMON) when deciding if the process should be killed or not. This fixes killing pdfork(2)ed process on last close of the corresponding process descriptor. Reviewed by: rwatson MFC after: 1 month Modified: head/sys/kern/sys_procdesc.c Modified: head/sys/kern/sys_procdesc.c ============================================================================== --- head/sys/kern/sys_procdesc.c Tue Jun 19 22:21:59 2012 (r237276) +++ head/sys/kern/sys_procdesc.c Tue Jun 19 22:23:59 2012 (r237277) @@ -338,7 +338,7 @@ procdesc_reap(struct proc *p) /* * procdesc_close() - last close on a process descriptor. If the process is - * still running, terminate with SIGKILL (unless PD_DAEMON is set) and let + * still running, terminate with SIGKILL (unless PDF_DAEMON is set) and let * init(8) clean up the mess; if not, we have to clean up the zombie ourselves. */ static int @@ -386,7 +386,7 @@ procdesc_close(struct file *fp, struct t */ p->p_sigparent = SIGCHLD; proc_reparent(p, initproc); - if ((pd->pd_flags & PD_DAEMON) == 0) + if ((pd->pd_flags & PDF_DAEMON) == 0) kern_psignal(p, SIGKILL); PROC_UNLOCK(p); sx_xunlock(&proctree_lock); From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 00:09:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 694C5106568D; Wed, 20 Jun 2012 00:09:48 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 54A6B8FC17; Wed, 20 Jun 2012 00:09:48 +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 q5K09mwp005360; Wed, 20 Jun 2012 00:09:48 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5K09mVQ005357; Wed, 20 Jun 2012 00:09:48 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201206200009.q5K09mVQ005357@svn.freebsd.org> From: "David E. O'Brien" Date: Wed, 20 Jun 2012 00:09:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237279 - in head: etc/mtree include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 00:09:48 -0000 Author: obrien Date: Wed Jun 20 00:09:47 2012 New Revision: 237279 URL: http://svn.freebsd.org/changeset/base/237279 Log: Install filemon.h into /usr/include for userland consumption. Modified: head/etc/mtree/BSD.include.dist head/include/Makefile Modified: head/etc/mtree/BSD.include.dist ============================================================================== --- head/etc/mtree/BSD.include.dist Tue Jun 19 23:45:17 2012 (r237278) +++ head/etc/mtree/BSD.include.dist Wed Jun 20 00:09:47 2012 (r237279) @@ -102,6 +102,8 @@ .. ciss .. + filemon + .. firewire .. hwpmc Modified: head/include/Makefile ============================================================================== --- head/include/Makefile Tue Jun 19 23:45:17 2012 (r237278) +++ head/include/Makefile Wed Jun 20 00:09:47 2012 (r237279) @@ -39,7 +39,7 @@ LDIRS= bsm cam geom net net80211 netatal sys vm LSUBDIRS= cam/ata cam/scsi \ - dev/acpica dev/an dev/bktr dev/ciss dev/firewire dev/hwpmc \ + dev/acpica dev/an dev/bktr dev/ciss dev/filemon dev/firewire dev/hwpmc \ dev/ic dev/iicbus ${_dev_ieee488} dev/io dev/lmc dev/mfi dev/ofw \ dev/pbio ${_dev_powermac_nvram} dev/ppbus dev/smbus \ dev/speaker dev/usb dev/utopia dev/vkbd dev/wi \ From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 00:17:29 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CDBB41065676; Wed, 20 Jun 2012 00:17:29 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AEF338FC18; Wed, 20 Jun 2012 00:17:29 +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 q5K0HTvK005818; Wed, 20 Jun 2012 00:17:29 GMT (envelope-from scottl@svn.freebsd.org) Received: (from scottl@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5K0HTvx005813; Wed, 20 Jun 2012 00:17:29 GMT (envelope-from scottl@svn.freebsd.org) Message-Id: <201206200017.q5K0HTvx005813@svn.freebsd.org> From: Scott Long Date: Wed, 20 Jun 2012 00:17:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237281 - head/sbin/camcontrol X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 00:17:30 -0000 Author: scottl Date: Wed Jun 20 00:17:29 2012 New Revision: 237281 URL: http://svn.freebsd.org/changeset/base/237281 Log: Update the 'fwdownload' command to also flash disks connected over an ATA/SATA transport. The detection logic is automatic, so it should Just Work. While here, also improve the progress meter that is displayed during firmware download. Submitted by: Alistair Crooks Obtained from: Netflix, Inc. MFC after: 3 days Modified: head/sbin/camcontrol/Makefile head/sbin/camcontrol/camcontrol.c head/sbin/camcontrol/camcontrol.h head/sbin/camcontrol/fwdownload.c Modified: head/sbin/camcontrol/Makefile ============================================================================== --- head/sbin/camcontrol/Makefile Wed Jun 20 00:13:44 2012 (r237280) +++ head/sbin/camcontrol/Makefile Wed Jun 20 00:17:29 2012 (r237281) @@ -3,7 +3,7 @@ PROG= camcontrol SRCS= camcontrol.c util.c .if !defined(RELEASE_CRUNCH) -SRCS+= fwdownload.c modeedit.c +SRCS+= fwdownload.c modeedit.c progress.c .else CFLAGS+= -DMINIMALISTIC .endif Modified: head/sbin/camcontrol/camcontrol.c ============================================================================== --- head/sbin/camcontrol/camcontrol.c Wed Jun 20 00:13:44 2012 (r237280) +++ head/sbin/camcontrol/camcontrol.c Wed Jun 20 00:17:29 2012 (r237281) @@ -3071,6 +3071,26 @@ get_cgd_bailout: return(retval); } +/* return the type of disk (really the command type) */ +static const char * +get_disk_type(struct cam_device *device) +{ + struct ccb_getdev cgd; + + (void) memset(&cgd, 0x0, sizeof(cgd)); + get_cgd(device, &cgd); + switch(cgd.protocol) { + case PROTO_SCSI: + return "scsi"; + case PROTO_ATA: + case PROTO_ATAPI: + case PROTO_SATAPM: + return "ata"; + default: + return "unknown"; + } +} + static void cpi_print(struct ccb_pathinq *cpi) { @@ -6197,7 +6217,8 @@ main(int argc, char **argv) break; case CAM_CMD_DOWNLOAD_FW: error = fwdownload(cam_dev, argc, argv, combinedopt, - arglist & CAM_ARG_VERBOSE, retry_count, timeout); + arglist & CAM_ARG_VERBOSE, retry_count, timeout, + get_disk_type(cam_dev)); break; #endif /* MINIMALISTIC */ case CAM_CMD_USAGE: Modified: head/sbin/camcontrol/camcontrol.h ============================================================================== --- head/sbin/camcontrol/camcontrol.h Wed Jun 20 00:13:44 2012 (r237280) +++ head/sbin/camcontrol/camcontrol.h Wed Jun 20 00:17:29 2012 (r237281) @@ -41,7 +41,8 @@ struct get_hook }; int fwdownload(struct cam_device *device, int argc, char **argv, - char *combinedopt, int verbose, int retry_count, int timeout); + char *combinedopt, int verbose, int retry_count, int timeout, + const char */*type*/); void mode_sense(struct cam_device *device, int mode_page, int page_control, int dbd, int retry_count, int timeout, u_int8_t *data, int datalen); Modified: head/sbin/camcontrol/fwdownload.c ============================================================================== --- head/sbin/camcontrol/fwdownload.c Wed Jun 20 00:13:44 2012 (r237280) +++ head/sbin/camcontrol/fwdownload.c Wed Jun 20 00:17:29 2012 (r237281) @@ -64,6 +64,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include "progress.h" + #include "camcontrol.h" #define CMD_TIMEOUT 50000 /* 50 seconds */ @@ -73,6 +75,7 @@ typedef enum { VENDOR_HP, VENDOR_IBM, VENDOR_PLEXTOR, + VENDOR_QUALSTAR, VENDOR_QUANTUM, VENDOR_SEAGATE, VENDOR_UNKNOWN @@ -93,17 +96,43 @@ static const struct fw_vendor vendors_li {VENDOR_HP, "HP", 0x8000, 0x07, 0x07, 0, 1}, {VENDOR_IBM, "IBM", 0x8000, 0x05, 0x05, 1, 0}, {VENDOR_PLEXTOR, "PLEXTOR", 0x2000, 0x04, 0x05, 0, 1}, + {VENDOR_QUALSTAR, "QUALSTAR", 0x2030, 0x05, 0x05, 0, 0}, {VENDOR_QUANTUM, "QUANTUM", 0x2000, 0x04, 0x05, 0, 1}, {VENDOR_SEAGATE, "SEAGATE", 0x8000, 0x07, 0x07, 0, 1}, + /* the next 2 are SATA disks going through SAS HBA */ + {VENDOR_SEAGATE, "ATA ST", 0x8000, 0x07, 0x07, 0, 1}, + {VENDOR_HITACHI, "ATA HDS", 0x8000, 0x05, 0x05, 1, 0}, {VENDOR_UNKNOWN, NULL, 0x0000, 0x00, 0x00, 0, 0} }; +#ifndef ATA_DOWNLOAD_MICROCODE +#define ATA_DOWNLOAD_MICROCODE 0x92 +#endif + +#define USE_OFFSETS_FEATURE 0x3 + +#ifndef LOW_SECTOR_SIZE +#define LOW_SECTOR_SIZE 512 +#endif + +#define ATA_MAKE_LBA(o, p) \ + ((((((o) / LOW_SECTOR_SIZE) >> 8) & 0xff) << 16) | \ + ((((o) / LOW_SECTOR_SIZE) & 0xff) << 8) | \ + ((((p) / LOW_SECTOR_SIZE) >> 8) & 0xff)) + +#define ATA_MAKE_SECTORS(p) (((p) / 512) & 0xff) + +#ifndef UNKNOWN_MAX_PKT_SIZE +#define UNKNOWN_MAX_PKT_SIZE 0x8000 +#endif + static const struct fw_vendor *fw_get_vendor(struct cam_device *cam_dev); static char *fw_read_img(const char *fw_img_path, const struct fw_vendor *vp, int *num_bytes); static int fw_download_img(struct cam_device *cam_dev, const struct fw_vendor *vp, char *buf, int img_size, - int sim_mode, int verbose, int retry_count, int timeout); + int sim_mode, int verbose, int retry_count, int timeout, + const char */*name*/, const char */*type*/); /* * Find entry in vendors list that belongs to @@ -173,6 +202,9 @@ fw_read_img(const char *fw_img_path, con (img_size % 512 == 80)) skip_bytes = 80; break; + case VENDOR_QUALSTAR: + skip_bytes = img_size % 1030; + break; default: break; } @@ -207,26 +239,57 @@ bailout1: static int fw_download_img(struct cam_device *cam_dev, const struct fw_vendor *vp, char *buf, int img_size, int sim_mode, int verbose, int retry_count, - int timeout) + int timeout, const char *imgname, const char *type) { struct scsi_write_buffer cdb; + progress_t progress; + int size; union ccb *ccb; int pkt_count = 0; + int max_pkt_size; u_int32_t pkt_size = 0; char *pkt_ptr = buf; u_int32_t offset; int last_pkt = 0; + int16_t *ptr; if ((ccb = cam_getccb(cam_dev)) == NULL) { warnx("Could not allocate CCB"); return (1); } - scsi_test_unit_ready(&ccb->csio, 0, NULL, MSG_SIMPLE_Q_TAG, - SSD_FULL_SIZE, 5000); + if (strcmp(type, "scsi") == 0) { + scsi_test_unit_ready(&ccb->csio, 0, NULL, MSG_SIMPLE_Q_TAG, + SSD_FULL_SIZE, 5000); + } else if (strcmp(type, "ata") == 0) { + /* cam_getccb cleans up the header, caller has to zero the payload */ + bzero(&(&ccb->ccb_h)[1], + sizeof(struct ccb_ataio) - sizeof(struct ccb_hdr)); + + ptr = (uint16_t *)malloc(sizeof(struct ata_params)); + + if (ptr == NULL) { + cam_freeccb(ccb); + warnx("can't malloc memory for identify\n"); + return(1); + } + bzero(ptr, sizeof(struct ata_params)); + cam_fill_ataio(&ccb->ataio, + 1, + NULL, + /*flags*/CAM_DIR_IN, + MSG_SIMPLE_Q_TAG, + /*data_ptr*/(uint8_t *)ptr, + /*dxfer_len*/sizeof(struct ata_params), + timeout ? timeout : 30 * 1000); + ata_28bit_cmd(&ccb->ataio, ATA_ATA_IDENTIFY, 0, 0, 0); + } else { + warnx("weird disk type '%s'", type); + return 1; + } /* Disable freezing the device queue. */ ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; if (cam_send_ccb(cam_dev, ccb) < 0) { - warnx("Error sending test unit ready"); + warnx("Error sending identify/test unit ready"); if (verbose) cam_error_print(cam_dev, ccb, CAM_ESF_ALL, CAM_EPF_ALL, stderr); @@ -241,83 +304,102 @@ fw_download_img(struct cam_device *cam_d cam_freeccb(ccb); return (1); } - pkt_size = vp->max_pkt_size; - if (verbose || sim_mode) { - fprintf(stdout, - "--------------------------------------------------\n"); - fprintf(stdout, - "PktNo. PktSize BytesRemaining LastPkt\n"); - fprintf(stdout, - "--------------------------------------------------\n"); + max_pkt_size = vp->max_pkt_size; + if (vp->max_pkt_size == 0 && strcmp(type, "ata") == 0) { + max_pkt_size = UNKNOWN_MAX_PKT_SIZE; } + pkt_size = vp->max_pkt_size; + progress_init(&progress, imgname, size = img_size); /* Download single fw packets. */ do { - if (img_size <= vp->max_pkt_size) { + if (img_size <= max_pkt_size) { last_pkt = 1; pkt_size = img_size; } - if (verbose || sim_mode) - fprintf(stdout, "%3u %5u (0x%05X) %7u (0x%06X) " - "%d\n", pkt_count, pkt_size, pkt_size, - img_size - pkt_size, img_size - pkt_size, - last_pkt); + progress_update(&progress, size - img_size); + progress_draw(&progress); bzero(&cdb, sizeof(cdb)); - cdb.opcode = WRITE_BUFFER; - cdb.control = 0; - /* Parameter list length. */ - scsi_ulto3b(pkt_size, &cdb.length[0]); - offset = vp->inc_cdb_offset ? (pkt_ptr - buf) : 0; - scsi_ulto3b(offset, &cdb.offset[0]); - cdb.byte2 = last_pkt ? vp->cdb_byte2_last : vp->cdb_byte2; - cdb.buffer_id = vp->inc_cdb_buffer_id ? pkt_count : 0; - /* Zero out payload of ccb union after ccb header. */ - bzero((u_char *)ccb + sizeof(struct ccb_hdr), - sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr)); - /* Copy previously constructed cdb into ccb_scsiio struct. */ - bcopy(&cdb, &ccb->csio.cdb_io.cdb_bytes[0], - sizeof(struct scsi_write_buffer)); - /* Fill rest of ccb_scsiio struct. */ + if (strcmp(type, "scsi") == 0) { + cdb.opcode = WRITE_BUFFER; + cdb.control = 0; + /* Parameter list length. */ + scsi_ulto3b(pkt_size, &cdb.length[0]); + offset = vp->inc_cdb_offset ? (pkt_ptr - buf) : 0; + scsi_ulto3b(offset, &cdb.offset[0]); + cdb.byte2 = last_pkt ? vp->cdb_byte2_last : vp->cdb_byte2; + cdb.buffer_id = vp->inc_cdb_buffer_id ? pkt_count : 0; + /* Zero out payload of ccb union after ccb header. */ + bzero((u_char *)ccb + sizeof(struct ccb_hdr), + sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr)); + /* Copy previously constructed cdb into ccb_scsiio struct. */ + bcopy(&cdb, &ccb->csio.cdb_io.cdb_bytes[0], + sizeof(struct scsi_write_buffer)); + /* Fill rest of ccb_scsiio struct. */ + if (!sim_mode) { + cam_fill_csio(&ccb->csio, /* ccb_scsiio */ + retry_count, /* retries */ + NULL, /* cbfcnp */ + CAM_DIR_OUT | CAM_DEV_QFRZDIS, /* flags */ + CAM_TAG_ACTION_NONE, /* tag_action */ + (u_char *)pkt_ptr, /* data_ptr */ + pkt_size, /* dxfer_len */ + SSD_FULL_SIZE, /* sense_len */ + sizeof(struct scsi_write_buffer), /* cdb_len */ + timeout ? timeout : CMD_TIMEOUT); /* timeout */ + } + } else if (strcmp(type, "ata") == 0) { + bzero(&(&ccb->ccb_h)[1], + sizeof(struct ccb_ataio) - sizeof(struct ccb_hdr)); + if (!sim_mode) { + uint32_t off; + + cam_fill_ataio(&ccb->ataio, + (last_pkt) ? 256 : retry_count, + NULL, + /*flags*/CAM_DIR_OUT | CAM_DEV_QFRZDIS, + CAM_TAG_ACTION_NONE, + /*data_ptr*/(uint8_t *)pkt_ptr, + /*dxfer_len*/pkt_size, + timeout ? timeout : 30 * 1000); + off = (uint32_t)(pkt_ptr - buf); + ata_28bit_cmd(&ccb->ataio, ATA_DOWNLOAD_MICROCODE, + USE_OFFSETS_FEATURE, + ATA_MAKE_LBA(off, pkt_size), + ATA_MAKE_SECTORS(pkt_size)); + } + } if (!sim_mode) { - cam_fill_csio(&ccb->csio, /* ccb_scsiio */ - retry_count, /* retries */ - NULL, /* cbfcnp */ - CAM_DIR_OUT | CAM_DEV_QFRZDIS, /* flags */ - CAM_TAG_ACTION_NONE, /* tag_action */ - (u_char *)pkt_ptr, /* data_ptr */ - pkt_size, /* dxfer_len */ - SSD_FULL_SIZE, /* sense_len */ - sizeof(struct scsi_write_buffer), /* cdb_len */ - timeout ? timeout : CMD_TIMEOUT); /* timeout */ /* Execute the command. */ if (cam_send_ccb(cam_dev, ccb) < 0) { warnx("Error writing image to device"); if (verbose) cam_error_print(cam_dev, ccb, CAM_ESF_ALL, - CAM_EPF_ALL, stderr); + CAM_EPF_ALL, stderr); goto bailout; } + if (ccb->ataio.res.status != 0 /*&& !last_pkt*/) { + cam_error_print(cam_dev, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + } } /* Prepare next round. */ pkt_count++; pkt_ptr += pkt_size; img_size -= pkt_size; } while(!last_pkt); - if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { - if (verbose) - cam_error_print(cam_dev, ccb, CAM_ESF_ALL, - CAM_EPF_ALL, stderr); - goto bailout; - } + progress_complete(&progress, size - img_size); cam_freeccb(ccb); return (0); bailout: + progress_complete(&progress, size - img_size); cam_freeccb(ccb); return (1); } int fwdownload(struct cam_device *device, int argc, char **argv, - char *combinedopt, int verbose, int retry_count, int timeout) + char *combinedopt, int verbose, int retry_count, int timeout, + const char *type) { const struct fw_vendor *vp; char *fw_img_path = NULL; @@ -345,12 +427,13 @@ fwdownload(struct cam_device *device, in } if (fw_img_path == NULL) - errx(1, - "you must specify a firmware image file using -f option"); + errx(1, "you must specify a firmware image file using -f option"); vp = fw_get_vendor(device); - if (vp == NULL || vp->type == VENDOR_UNKNOWN) - errx(1, "Unsupported device"); + if (vp == NULL) + errx(1, "NULL vendor"); + if (vp->type == VENDOR_UNKNOWN) + warnx("Unsupported device - flashing through an HBA?"); buf = fw_read_img(fw_img_path, vp, &img_size); if (buf == NULL) @@ -360,11 +443,6 @@ fwdownload(struct cam_device *device, in fprintf(stdout, "You are about to download firmware image (%s)" " into the following device:\n", fw_img_path); - if (scsidoinquiry(device, argc, argv, combinedopt, 0, - 5000) != 0) { - warnx("Error sending inquiry"); - goto fail; - } fprintf(stdout, "\nIt may damage your drive. "); if (!get_confirmation()) goto fail; @@ -373,10 +451,11 @@ fwdownload(struct cam_device *device, in fprintf(stdout, "Running in simulation mode\n"); if (fw_download_img(device, vp, buf, img_size, sim_mode, verbose, - retry_count, timeout) != 0) { + retry_count, timeout, fw_img_path, type) != 0) { fprintf(stderr, "Firmware download failed\n"); goto fail; - } else + } + else fprintf(stdout, "Firmware download successful\n"); free(buf); From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 00:37:01 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0F650106566C; Wed, 20 Jun 2012 00:37:01 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EFA008FC0A; Wed, 20 Jun 2012 00:37:00 +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 q5K0b0H9006700; Wed, 20 Jun 2012 00:37:00 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5K0b0rr006698; Wed, 20 Jun 2012 00:37:00 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201206200037.q5K0b0rr006698@svn.freebsd.org> From: "David E. O'Brien" Date: Wed, 20 Jun 2012 00:37:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237282 - head/usr.bin/make X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 00:37:01 -0000 Author: obrien Date: Wed Jun 20 00:37:00 2012 New Revision: 237282 URL: http://svn.freebsd.org/changeset/base/237282 Log: Correct typo in version. Modified: head/usr.bin/make/Makefile Modified: head/usr.bin/make/Makefile ============================================================================== --- head/usr.bin/make/Makefile Wed Jun 20 00:17:29 2012 (r237281) +++ head/usr.bin/make/Makefile Wed Jun 20 00:37:00 2012 (r237282) @@ -15,7 +15,7 @@ NO_SHARED?= YES .endif # Version has the RYYYYMMDDX format, where R is from RELENG_ -CFLAGS+=-DMAKE_VERSION=\"10201120530\" +CFLAGS+=-DMAKE_VERSION=\"10201205300\" # There is no obvious performance improvement currently. # CFLAGS+=-DUSE_KQUEUE From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 02:21:53 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D0CE21065674; Wed, 20 Jun 2012 02:21:53 +0000 (UTC) (envelope-from kevlo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BC4478FC0C; Wed, 20 Jun 2012 02:21:53 +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 q5K2LrrI012795; Wed, 20 Jun 2012 02:21:53 GMT (envelope-from kevlo@svn.freebsd.org) Received: (from kevlo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5K2LrXM012793; Wed, 20 Jun 2012 02:21:53 GMT (envelope-from kevlo@svn.freebsd.org) Message-Id: <201206200221.q5K2LrXM012793@svn.freebsd.org> From: Kevin Lo Date: Wed, 20 Jun 2012 02:21:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237284 - head/bin/rm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 02:21:53 -0000 Author: kevlo Date: Wed Jun 20 02:21:53 2012 New Revision: 237284 URL: http://svn.freebsd.org/changeset/base/237284 Log: Fix potential symlink race condition in "rm -P" by adding a check that the file we have opened is the one we expected. Also open in non-blocking mode to avoid a potential hang with FIFOs. Obtained from: NetBSD via OpenBSD Modified: head/bin/rm/rm.c Modified: head/bin/rm/rm.c ============================================================================== --- head/bin/rm/rm.c Wed Jun 20 00:41:31 2012 (r237283) +++ head/bin/rm/rm.c Wed Jun 20 02:21:53 2012 (r237284) @@ -408,7 +408,7 @@ rm_file(char **argv) int rm_overwrite(char *file, struct stat *sbp) { - struct stat sb; + struct stat sb, sb2; struct statfs fsb; off_t len; int bsize, fd, wlen; @@ -427,8 +427,15 @@ rm_overwrite(char *file, struct stat *sb file, sbp->st_ino); return (0); } - if ((fd = open(file, O_WRONLY, 0)) == -1) + if ((fd = open(file, O_WRONLY|O_NONBLOCK|O_NOFOLLOW, 0)) == -1) goto err; + if (fstat(fd, &sb2)) + goto err; + if (sb2.st_dev != sbp->st_dev || sb2.st_ino != sbp->st_ino || + !S_ISREG(sb2.st_mode)) { + errno = EPERM; + goto err; + } if (fstatfs(fd, &fsb) == -1) goto err; bsize = MAX(fsb.f_iosize, 1024); From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 04:11:34 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E51371065670; Wed, 20 Jun 2012 04:11:34 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CDFF58FC0C; Wed, 20 Jun 2012 04:11:34 +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 q5K4BYOI017746; Wed, 20 Jun 2012 04:11:34 GMT (envelope-from scottl@svn.freebsd.org) Received: (from scottl@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5K4BYTw017744; Wed, 20 Jun 2012 04:11:34 GMT (envelope-from scottl@svn.freebsd.org) Message-Id: <201206200411.q5K4BYTw017744@svn.freebsd.org> From: Scott Long Date: Wed, 20 Jun 2012 04:11:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237285 - head/sbin/camcontrol X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 04:11:35 -0000 Author: scottl Date: Wed Jun 20 04:11:34 2012 New Revision: 237285 URL: http://svn.freebsd.org/changeset/base/237285 Log: Add progress.c and progress.h, missed in the previous commit to camcontrol. Submitted by: Garrett Cooper Obtained from: Netflix, Inc. Added: head/sbin/camcontrol/progress.c (contents, props changed) head/sbin/camcontrol/progress.h (contents, props changed) Added: head/sbin/camcontrol/progress.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sbin/camcontrol/progress.c Wed Jun 20 04:11:34 2012 (r237285) @@ -0,0 +1,186 @@ +/* $NetBSD: progressbar.c,v 1.21 2009/04/12 10:18:52 lukem Exp $ */ + +/*- + * Copyright (c) 1997-2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Luke Mewburn. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +__FBSDID("$FreeBSD$"); + +#include "progress.h" + +static const char * const suffixes[] = { + "", /* 2^0 (byte) */ + "KiB", /* 2^10 Kibibyte */ + "MiB", /* 2^20 Mebibyte */ + "GiB", /* 2^30 Gibibyte */ + "TiB", /* 2^40 Tebibyte */ + "PiB", /* 2^50 Pebibyte */ + "EiB", /* 2^60 Exbibyte */ +}; + +#define NSUFFIXES (sizeof(suffixes) / sizeof(suffixes[0])) +#define SECSPERHOUR (60 * 60) +#define DEFAULT_TTYWIDTH 80 + +/* initialise progress meter structure */ +int +progress_init(progress_t *prog, const char *prefix, uint64_t total) +{ + struct winsize winsize; + int oerrno = errno; + + (void) memset(prog, 0x0, sizeof(*prog)); + prog->size = total; + prog->prefix = strdup(prefix); + prog->start = time(NULL); + if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize) != -1 && + winsize.ws_col != 0) { + prog->ttywidth = winsize.ws_col; + } else { + prog->ttywidth = DEFAULT_TTYWIDTH; + } + errno = oerrno; + return 1; +} + +/* update the values in the progress meter */ +int +progress_update(progress_t *prog, uint64_t done) +{ + prog->done = done; + prog->percent = (prog->done * 100) / prog->size; + prog->now = time(NULL); + prog->elapsed = prog->now - prog->start; + if (done == 0 || prog->elapsed == 0 || prog->done / prog->elapsed == 0) { + prog->eta = 0; + } else { + prog->eta = prog->size / (prog->done / prog->elapsed) - prog->elapsed; + } + return 1; +} + +/* update the values in the progress meter */ +int +progress_reset_size(progress_t *prog, uint64_t size) +{ + prog->size = size; + return 1; +} + +/* make it look pretty at the end - display done bytes (usually total) */ +int +progress_complete(progress_t *prog, uint64_t done) +{ + progress_update(prog, done); + progress_draw(prog); + printf("\n"); + return 1; +} + +/* draw the progress meter */ +int +progress_draw(progress_t *prog) +{ +#define BAROVERHEAD 45 /* non `*' portion of progress bar */ + /* + * stars should contain at least + * sizeof(buf) - BAROVERHEAD entries + */ + static const char stars[] = +"*****************************************************************************" +"*****************************************************************************" +"*****************************************************************************"; + unsigned bytesabbrev; + unsigned bpsabbrev; + int64_t secs; + uint64_t bytespersec; + uint64_t abbrevsize; + int64_t secsleft; + size_t barlength; + size_t starc; + char hours[12]; + char buf[256]; + int len; + + barlength = MIN(sizeof(buf) - 1, (unsigned)prog->ttywidth) - BAROVERHEAD - strlen(prog->prefix); + starc = (barlength * prog->percent) / 100; + abbrevsize = prog->done; + for (bytesabbrev = 0; abbrevsize >= 100000 && bytesabbrev < NSUFFIXES; bytesabbrev++) { + abbrevsize >>= 10; + } + if (bytesabbrev == NSUFFIXES) { + bytesabbrev--; + } + bytespersec = 0; + if (prog->done > 0) { + bytespersec = prog->done; + if (prog->elapsed > 0) { + bytespersec /= prog->elapsed; + } + } + for (bpsabbrev = 1; bytespersec >= 1024000 && bpsabbrev < NSUFFIXES; bpsabbrev++) { + bytespersec >>= 10; + } + if (prog->done == 0 || prog->elapsed <= 0 || prog->done > prog->size) { + secsleft = 0; + } else { + secsleft = prog->eta; + } + if ((secs = secsleft / SECSPERHOUR) > 0) { + (void) snprintf(hours, sizeof(hours), "%2lld:", (long long)secs); + } else { + (void) snprintf(hours, sizeof(hours), " "); + } + secs = secsleft % SECSPERHOUR; + len = snprintf(buf, sizeof(buf), + "\r%s %3lld%% |%.*s%*s| %5lld %-3s %3lld.%02d %.2sB/s %s%02d:%02d ETA", + (prog->prefix) ? prog->prefix : "", + (long long)prog->percent, + (int)starc, stars, (int)(barlength - starc), "", + (long long)abbrevsize, + suffixes[bytesabbrev], + (long long)(bytespersec / 1024), + (int)((bytespersec % 1024) * 100 / 1024), + suffixes[bpsabbrev], + hours, + (int)secs / 60, (int)secs % 60); + return (int)write(STDOUT_FILENO, buf, len); +} Added: head/sbin/camcontrol/progress.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sbin/camcontrol/progress.h Wed Jun 20 04:11:34 2012 (r237285) @@ -0,0 +1,60 @@ +/* $NetBSD: progressbar.c,v 1.21 2009/04/12 10:18:52 lukem Exp $ */ + +/*- + * Copyright (c) 1997-2012 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Luke Mewburn. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef PROGRESS_H_ +#define PROGRESS_H_ 20100228 + +#include + +#include + +/* structure used to display a progress meter */ +typedef struct progress_t { + char *prefix; /* any prefix explanation */ + uint64_t size; /* total of bytes/units to be counted */ + uint64_t done; /* number of units counted to date */ + uint64_t percent; /* cache the percentage complete */ + time_t start; /* time we started this */ + time_t now; /* time now */ + time_t eta; /* estimated # of secs until completion */ + int64_t elapsed; /* cached # of elapsed seconds */ + int32_t ttywidth; /* width of tty in columns */ +} progress_t; + +int progress_init(progress_t */*meter*/, const char */*prefix*/, uint64_t /*size*/); +int progress_update(progress_t */*meter*/, uint64_t /*done*/); +int progress_draw(progress_t */*meter*/); +int progress_reset_size(progress_t */*meter*/, uint64_t /*size*/); +int progress_complete(progress_t */*meter*/, uint64_t /*done*/); + +#endif From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 06:38:42 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6203A1065673; Wed, 20 Jun 2012 06:38:42 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4D1988FC08; Wed, 20 Jun 2012 06:38:42 +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 q5K6cgUI024026; Wed, 20 Jun 2012 06:38:42 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5K6cg7u024024; Wed, 20 Jun 2012 06:38:42 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206200638.q5K6cg7u024024@svn.freebsd.org> From: Eitan Adler Date: Wed, 20 Jun 2012 06:38:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237286 - head/lib/libc/gen X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 06:38:42 -0000 Author: eadler Date: Wed Jun 20 06:38:41 2012 New Revision: 237286 URL: http://svn.freebsd.org/changeset/base/237286 Log: Don't close an uninitialized descriptor. [1] Add a sanity check for the validity of the passed fd. PR: kern/139080 [1] Submitted by: Andrey Simonenko [1] Reviewed by: pjd (briefly) Approved by: cperciva MFC after: 1 week Modified: head/lib/libc/gen/syslog.c Modified: head/lib/libc/gen/syslog.c ============================================================================== --- head/lib/libc/gen/syslog.c Wed Jun 20 04:11:34 2012 (r237285) +++ head/lib/libc/gen/syslog.c Wed Jun 20 06:38:41 2012 (r237286) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -413,8 +414,11 @@ void closelog(void) { THREAD_LOCK(); - (void)_close(LogFile); - LogFile = -1; + assert(LogFile >= -1); + if (LogFile != -1) { + (void)_close(LogFile); + LogFile = -1; + } LogTag = NULL; status = NOCONN; THREAD_UNLOCK(); From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 07:25:20 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E80501065672; Wed, 20 Jun 2012 07:25:20 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D34088FC14; Wed, 20 Jun 2012 07:25:20 +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 q5K7PKKX026136; Wed, 20 Jun 2012 07:25:20 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5K7PKAm026134; Wed, 20 Jun 2012 07:25:20 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201206200725.q5K7PKAm026134@svn.freebsd.org> From: Alan Cox Date: Wed, 20 Jun 2012 07:25:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237290 - head/sys/amd64/amd64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 07:25:21 -0000 Author: alc Date: Wed Jun 20 07:25:20 2012 New Revision: 237290 URL: http://svn.freebsd.org/changeset/base/237290 Log: Add PV list locking to pmap_copy(), pmap_enter_object(), and pmap_enter_quick(). These functions are no longer serialized by the pvh global lock. There is no need to release the PV list lock before calling free_pv_chunk() in pmap_remove_pages(). Modified: head/sys/amd64/amd64/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Wed Jun 20 06:58:56 2012 (r237289) +++ head/sys/amd64/amd64/pmap.c Wed Jun 20 07:25:20 2012 (r237290) @@ -241,7 +241,8 @@ static void free_pv_chunk(struct pv_chun static void free_pv_entry(pmap_t pmap, pv_entry_t pv); static pv_entry_t get_pv_entry(pmap_t pmap, boolean_t try); static void pmap_pv_demote_pde(pmap_t pmap, vm_offset_t va, vm_paddr_t pa); -static boolean_t pmap_pv_insert_pde(pmap_t pmap, vm_offset_t va, vm_paddr_t pa); +static boolean_t pmap_pv_insert_pde(pmap_t pmap, vm_offset_t va, vm_paddr_t pa, + struct rwlock **lockp); static void pmap_pv_promote_pde(pmap_t pmap, vm_offset_t va, vm_paddr_t pa); static void pmap_pvh_free(struct md_page *pvh, pmap_t pmap, vm_offset_t va); static pv_entry_t pmap_pvh_remove(struct md_page *pvh, pmap_t pmap, @@ -253,9 +254,9 @@ static boolean_t pmap_demote_pde(pmap_t static boolean_t pmap_demote_pdpe(pmap_t pmap, pdp_entry_t *pdpe, vm_offset_t va); static boolean_t pmap_enter_pde(pmap_t pmap, vm_offset_t va, vm_page_t m, - vm_prot_t prot); + vm_prot_t prot, struct rwlock **lockp); static vm_page_t pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, - vm_page_t m, vm_prot_t prot, vm_page_t mpte); + vm_page_t m, vm_prot_t prot, vm_page_t mpte, struct rwlock **lockp); static void pmap_fill_ptp(pt_entry_t *firstpte, pt_entry_t newpte); static void pmap_insert_pt_page(pmap_t pmap, vm_page_t mpte); static boolean_t pmap_is_modified_pvh(struct md_page *pvh); @@ -278,7 +279,7 @@ static void pmap_remove_entry(struct pma vm_offset_t va); static void pmap_insert_entry(pmap_t pmap, vm_offset_t va, vm_page_t m); static boolean_t pmap_try_insert_pv_entry(pmap_t pmap, vm_offset_t va, - vm_page_t m); + vm_page_t m, struct rwlock **lockp); static void pmap_update_pde(pmap_t pmap, vm_offset_t va, pd_entry_t *pde, pd_entry_t newpde); static void pmap_update_pde_invalidate(vm_offset_t va, pd_entry_t newpde); @@ -2463,14 +2464,23 @@ pmap_insert_entry(pmap_t pmap, vm_offset * Conditionally create a pv entry. */ static boolean_t -pmap_try_insert_pv_entry(pmap_t pmap, vm_offset_t va, vm_page_t m) +pmap_try_insert_pv_entry(pmap_t pmap, vm_offset_t va, vm_page_t m, + struct rwlock **lockp) { + struct rwlock *new_lock; pv_entry_t pv; - rw_assert(&pvh_global_lock, RA_WLOCKED); + rw_assert(&pvh_global_lock, RA_LOCKED); PMAP_LOCK_ASSERT(pmap, MA_OWNED); if ((pv = get_pv_entry(pmap, TRUE)) != NULL) { pv->pv_va = va; + new_lock = VM_PAGE_TO_PV_LIST_LOCK(m); + if (new_lock != *lockp) { + if (*lockp != NULL) + rw_wunlock(*lockp); + *lockp = new_lock; + rw_wlock(*lockp); + } TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_list); return (TRUE); } else @@ -2481,14 +2491,23 @@ pmap_try_insert_pv_entry(pmap_t pmap, vm * Create the pv entry for a 2MB page mapping. */ static boolean_t -pmap_pv_insert_pde(pmap_t pmap, vm_offset_t va, vm_paddr_t pa) +pmap_pv_insert_pde(pmap_t pmap, vm_offset_t va, vm_paddr_t pa, + struct rwlock **lockp) { struct md_page *pvh; + struct rwlock *new_lock; pv_entry_t pv; - rw_assert(&pvh_global_lock, RA_WLOCKED); + rw_assert(&pvh_global_lock, RA_LOCKED); if ((pv = get_pv_entry(pmap, TRUE)) != NULL) { pv->pv_va = va; + new_lock = PHYS_TO_PV_LIST_LOCK(pa); + if (new_lock != *lockp) { + if (*lockp != NULL) + rw_wunlock(*lockp); + *lockp = new_lock; + rw_wlock(*lockp); + } pvh = pa_to_pvh(pa); TAILQ_INSERT_TAIL(&pvh->pv_list, pv, pv_list); return (TRUE); @@ -3434,12 +3453,13 @@ validate: * (3) a pv entry cannot be allocated without reclaiming another pv entry. */ static boolean_t -pmap_enter_pde(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot) +pmap_enter_pde(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot, + struct rwlock **lockp) { pd_entry_t *pde, newpde; vm_page_t free, mpde; - rw_assert(&pvh_global_lock, RA_WLOCKED); + rw_assert(&pvh_global_lock, RA_LOCKED); PMAP_LOCK_ASSERT(pmap, MA_OWNED); if ((mpde = pmap_allocpde(pmap, va, M_NOWAIT)) == NULL) { CTR2(KTR_PMAP, "pmap_enter_pde: failure for va %#lx" @@ -3464,7 +3484,8 @@ pmap_enter_pde(pmap_t pmap, vm_offset_t /* * Abort this mapping if its PV entry could not be created. */ - if (!pmap_pv_insert_pde(pmap, va, VM_PAGE_TO_PHYS(m))) { + if (!pmap_pv_insert_pde(pmap, va, VM_PAGE_TO_PHYS(m), + lockp)) { free = NULL; if (pmap_unwire_pte_hold(pmap, va, mpde, &free)) { pmap_invalidate_page(pmap, va); @@ -3490,7 +3511,7 @@ pmap_enter_pde(pmap_t pmap, vm_offset_t */ pde_store(pde, newpde); - pmap_pde_mappings++; + atomic_add_long(&pmap_pde_mappings, 1); CTR2(KTR_PMAP, "pmap_enter_pde: success for va %#lx" " in pmap %p", va, pmap); return (TRUE); @@ -3512,6 +3533,7 @@ void pmap_enter_object(pmap_t pmap, vm_offset_t start, vm_offset_t end, vm_page_t m_start, vm_prot_t prot) { + struct rwlock *lock; vm_offset_t va; vm_page_t m, mpte; vm_pindex_t diff, psize; @@ -3520,21 +3542,24 @@ pmap_enter_object(pmap_t pmap, vm_offset psize = atop(end - start); mpte = NULL; m = m_start; - rw_wlock(&pvh_global_lock); + lock = NULL; + rw_rlock(&pvh_global_lock); PMAP_LOCK(pmap); while (m != NULL && (diff = m->pindex - m_start->pindex) < psize) { va = start + ptoa(diff); if ((va & PDRMASK) == 0 && va + NBPDR <= end && (VM_PAGE_TO_PHYS(m) & PDRMASK) == 0 && pg_ps_enabled && vm_reserv_level_iffullpop(m) == 0 && - pmap_enter_pde(pmap, va, m, prot)) + pmap_enter_pde(pmap, va, m, prot, &lock)) m = &m[NBPDR / PAGE_SIZE - 1]; else mpte = pmap_enter_quick_locked(pmap, va, m, prot, - mpte); + mpte, &lock); m = TAILQ_NEXT(m, listq); } - rw_wunlock(&pvh_global_lock); + if (lock != NULL) + rw_wunlock(lock); + rw_runlock(&pvh_global_lock); PMAP_UNLOCK(pmap); } @@ -3550,17 +3575,21 @@ pmap_enter_object(pmap_t pmap, vm_offset void pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot) { + struct rwlock *lock; - rw_wlock(&pvh_global_lock); + lock = NULL; + rw_rlock(&pvh_global_lock); PMAP_LOCK(pmap); - (void)pmap_enter_quick_locked(pmap, va, m, prot, NULL); - rw_wunlock(&pvh_global_lock); + (void)pmap_enter_quick_locked(pmap, va, m, prot, NULL, &lock); + if (lock != NULL) + rw_wunlock(lock); + rw_runlock(&pvh_global_lock); PMAP_UNLOCK(pmap); } static vm_page_t pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, - vm_prot_t prot, vm_page_t mpte) + vm_prot_t prot, vm_page_t mpte, struct rwlock **lockp) { vm_page_t free; pt_entry_t *pte; @@ -3569,7 +3598,7 @@ pmap_enter_quick_locked(pmap_t pmap, vm_ KASSERT(va < kmi.clean_sva || va >= kmi.clean_eva || (m->oflags & VPO_UNMANAGED) != 0, ("pmap_enter_quick_locked: managed mapping within the clean submap")); - rw_assert(&pvh_global_lock, RA_WLOCKED); + rw_assert(&pvh_global_lock, RA_LOCKED); PMAP_LOCK_ASSERT(pmap, MA_OWNED); /* @@ -3626,7 +3655,7 @@ pmap_enter_quick_locked(pmap_t pmap, vm_ * Enter on the PV list if part of our managed memory. */ if ((m->oflags & VPO_UNMANAGED) == 0 && - !pmap_try_insert_pv_entry(pmap, va, m)) { + !pmap_try_insert_pv_entry(pmap, va, m, lockp)) { if (mpte != NULL) { free = NULL; if (pmap_unwire_pte_hold(pmap, va, mpte, &free)) { @@ -3825,6 +3854,7 @@ void pmap_copy(pmap_t dst_pmap, pmap_t src_pmap, vm_offset_t dst_addr, vm_size_t len, vm_offset_t src_addr) { + struct rwlock *lock; vm_page_t free; vm_offset_t addr; vm_offset_t end_addr = src_addr + len; @@ -3833,7 +3863,8 @@ pmap_copy(pmap_t dst_pmap, pmap_t src_pm if (dst_addr != src_addr) return; - rw_wlock(&pvh_global_lock); + lock = NULL; + rw_rlock(&pvh_global_lock); if (dst_pmap < src_pmap) { PMAP_LOCK(dst_pmap); PMAP_LOCK(src_pmap); @@ -3885,7 +3916,7 @@ pmap_copy(pmap_t dst_pmap, pmap_t src_pm pde = &pde[pmap_pde_index(addr)]; if (*pde == 0 && ((srcptepaddr & PG_MANAGED) == 0 || pmap_pv_insert_pde(dst_pmap, addr, srcptepaddr & - PG_PS_FRAME))) { + PG_PS_FRAME, &lock))) { *pde = srcptepaddr & ~PG_W; pmap_resident_count_inc(dst_pmap, NBPDR / PAGE_SIZE); } else @@ -3922,7 +3953,8 @@ pmap_copy(pmap_t dst_pmap, pmap_t src_pm dst_pte = &dst_pte[pmap_pte_index(addr)]; if (*dst_pte == 0 && pmap_try_insert_pv_entry(dst_pmap, addr, - PHYS_TO_VM_PAGE(ptetemp & PG_FRAME))) { + PHYS_TO_VM_PAGE(ptetemp & PG_FRAME), + &lock)) { /* * Clear the wired, modified, and * accessed (referenced) bits @@ -3949,7 +3981,9 @@ pmap_copy(pmap_t dst_pmap, pmap_t src_pm } } out: - rw_wunlock(&pvh_global_lock); + if (lock != NULL) + rw_wunlock(lock); + rw_runlock(&pvh_global_lock); PMAP_UNLOCK(src_pmap); PMAP_UNLOCK(dst_pmap); } @@ -4158,9 +4192,9 @@ pmap_remove_pages(pmap_t pmap) printf("warning: pmap_remove_pages called with non-current pmap\n"); return; } + lock = NULL; rw_rlock(&pvh_global_lock); PMAP_LOCK(pmap); - lock = NULL; TAILQ_FOREACH_SAFE(pc, &pmap->pm_pvchunk, pc_list, npc) { allfree = 1; freed = 0; @@ -4268,10 +4302,6 @@ pmap_remove_pages(pmap_t pmap) PV_STAT(atomic_add_int(&pv_entry_spare, freed)); PV_STAT(atomic_subtract_long(&pv_entry_count, freed)); if (allfree) { - if (lock != NULL) { - rw_wunlock(lock); - lock = NULL; - } TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); free_pv_chunk(pc); } From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 07:47:00 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E9D911065670; Wed, 20 Jun 2012 07:47:00 +0000 (UTC) (envelope-from gprspb@mail.ru) Received: from smtp16.mail.ru (smtp16.mail.ru [94.100.176.153]) by mx1.freebsd.org (Postfix) with ESMTP id 4C9258FC12; Wed, 20 Jun 2012 07:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=UzfZG8fbocgBxWUD86fqTDgnNhRzkRnYNcBIHuzWe5Q=; b=dzdK8e0jc0L2Neei46FeWij4ntQWKiMcB446At0piyQrUYCxgZ26yv+oZGGrzx5HoZd5UvcXRikeTqQkijflXvgaFJJau1Ic6IGEgcdbubUFKm5dFFT/0a7vjn7bb0jb; Received: from [93.185.182.46] (port=26323 helo=gpr.nnz-home.ru) by smtp16.mail.ru with esmtpa (envelope-from ) id 1ShFco-00020G-7N; Wed, 20 Jun 2012 11:46:50 +0400 Received: from gpr by gpr.nnz-home.ru with local (Exim 4.77 (FreeBSD)) (envelope-from ) id 1ShFXC-000BpC-17; Wed, 20 Jun 2012 11:41:02 +0400 Date: Wed, 20 Jun 2012 11:41:01 +0400 From: Gennady Proskurin To: Poul-Henning Kamp Message-ID: <20120620074101.GA832@gpr.nnz-home.ru> References: <68FBE843-7337-4C90-B01F-E0CAABB62BCD@gsoft.com.au> <31750.1340083631@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="45Z9DzgjV8m4Oswq" Content-Disposition: inline In-Reply-To: <31750.1340083631@critter.freebsd.dk> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam: Not detected X-Mras: Ok Cc: svn-src-head@freebsd.org, Daniel O'Connor , Gennady Proskurin , src-committers@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r237223 - head/sys/dev/fb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 07:47:01 -0000 --45Z9DzgjV8m4Oswq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jun 19, 2012 at 05:27:11AM +0000, Poul-Henning Kamp wrote: > In message <68FBE843-7337-4C90-B01F-E0CAABB62BCD@gsoft.com.au>, "Daniel O'Conno > r" writes: > > >> If size is odd, this does not copy the last byte. Not sure, whether = > >this is intended. > > Feel free to improve... --45Z9DzgjV8m4Oswq Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="fb.patch" Index: fbreg.h =================================================================== --- fbreg.h (revision 237289) +++ fbreg.h (working copy) @@ -39,9 +39,12 @@ static __inline void copyw(uint16_t *src, uint16_t *dst, size_t size) { + const int is_odd = (size & 0x1); size >>= 1; while (size--) *dst++ = *src++; + if (is_odd) + *(char*)dst = *(char*)src; // copy last byte } #define bcopy_io(s, d, c) copyw((void*)(s), (void*)(d), (c)) #define bcopy_toio(s, d, c) copyw((void*)(s), (void*)(d), (c)) --45Z9DzgjV8m4Oswq-- From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 08:29:22 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C5537106566B; Wed, 20 Jun 2012 08:29:22 +0000 (UTC) (envelope-from doconnor@gsoft.com.au) Received: from cain.gsoft.com.au (cain.gsoft.com.au [203.31.81.10]) by mx1.freebsd.org (Postfix) with ESMTP id 3BD6B8FC1E; Wed, 20 Jun 2012 08:29:22 +0000 (UTC) Received: from ur.gsoft.com.au (Ur.gsoft.com.au [203.31.81.55]) (authenticated bits=0) by cain.gsoft.com.au (8.14.4/8.14.3) with ESMTP id q5K8T7HX007585 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Wed, 20 Jun 2012 17:59:13 +0930 (CST) (envelope-from doconnor@gsoft.com.au) Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=us-ascii From: "Daniel O'Connor" In-Reply-To: <20120620074101.GA832@gpr.nnz-home.ru> Date: Wed, 20 Jun 2012 17:59:07 +0930 Content-Transfer-Encoding: quoted-printable Message-Id: References: <68FBE843-7337-4C90-B01F-E0CAABB62BCD@gsoft.com.au> <31750.1340083631@critter.freebsd.dk> <20120620074101.GA832@gpr.nnz-home.ru> To: Gennady Proskurin X-Mailer: Apple Mail (2.1278) X-Spam-Score: -2.51 () ALL_TRUSTED,BAYES_00,T_RP_MATCHES_RCVD X-Scanned-By: MIMEDefang 2.67 on 203.31.81.10 Cc: svn-src-head@freebsd.org, Poul-Henning Kamp , src-committers@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r237223 - head/sys/dev/fb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 08:29:22 -0000 On 20/06/2012, at 17:11, Gennady Proskurin wrote: > On Tue, Jun 19, 2012 at 05:27:11AM +0000, Poul-Henning Kamp wrote: >> In message <68FBE843-7337-4C90-B01F-E0CAABB62BCD@gsoft.com.au>, = "Daniel O'Conno >> r" writes: >>=20 >>>> If size is odd, this does not copy the last byte. Not sure, whether = =3D >>> this is intended. >>=20 >> Feel free to improve... >=20 > Surely if you pass it an odd size you made a mistake - either the wrong = function was used or you computed the size incorrectly. -- Daniel O'Connor software and network engineer for Genesis Software - http://www.gsoft.com.au "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 09:01:45 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 441421065670; Wed, 20 Jun 2012 09:01:45 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2F2078FC0C; Wed, 20 Jun 2012 09:01:45 +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 q5K91jS8030340; Wed, 20 Jun 2012 09:01:45 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5K91i5Z030338; Wed, 20 Jun 2012 09:01:44 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201206200901.q5K91i5Z030338@svn.freebsd.org> From: Fabien Thomas Date: Wed, 20 Jun 2012 09:01:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237295 - head/sys/dev/viawd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 09:01:45 -0000 Author: fabient Date: Wed Jun 20 09:01:44 2012 New Revision: 237295 URL: http://svn.freebsd.org/changeset/base/237295 Log: Fix viawd(4) that was only working as a module. Obtained from: jhb MFC after: 3 days Modified: head/sys/dev/viawd/viawd.c Modified: head/sys/dev/viawd/viawd.c ============================================================================== --- head/sys/dev/viawd/viawd.c Wed Jun 20 08:29:24 2012 (r237294) +++ head/sys/dev/viawd/viawd.c Wed Jun 20 09:01:44 2012 (r237295) @@ -168,14 +168,18 @@ viawd_attach(device_t dev) } /* Allocate I/O register space. */ - sc->wd_rid = 0; - sc->wd_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->wd_rid, - pmbase, pmbase + VIAWD_MEM_LEN - 1, VIAWD_MEM_LEN, + sc->wd_rid = VIAWD_CONFIG_BASE; + sc->wd_res = bus_alloc_resource_any(sb_dev, SYS_RES_MEMORY, &sc->wd_rid, RF_ACTIVE | RF_SHAREABLE); if (sc->wd_res == NULL) { device_printf(dev, "Unable to map watchdog memory\n"); goto fail; } + if (rman_get_size(sc->wd_res) < VIAWD_MEM_LEN) { + device_printf(dev, "Bad size for watchdog memory: %#x\n", + (unsigned)rman_get_size(sc->wd_res)); + goto fail; + } /* Check if watchdog fired last boot. */ reg = viawd_read_4(sc, VIAWD_MEM_CTRL); @@ -192,7 +196,7 @@ viawd_attach(device_t dev) return (0); fail: if (sc->wd_res != NULL) - bus_release_resource(dev, SYS_RES_MEMORY, + bus_release_resource(sb_dev, SYS_RES_MEMORY, sc->wd_rid, sc->wd_res); return (ENXIO); } @@ -224,7 +228,7 @@ viawd_detach(device_t dev) } if (sc->wd_res != NULL) - bus_release_resource(sc->dev, SYS_RES_MEMORY, + bus_release_resource(sc->sb_dev, SYS_RES_MEMORY, sc->wd_rid, sc->wd_res); return (0); From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 09:19:15 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E93BF106566C; Wed, 20 Jun 2012 09:19:15 +0000 (UTC) (envelope-from gprspb@mail.ru) Received: from fallback4.mail.ru (fallback4.mail.ru [94.100.176.42]) by mx1.freebsd.org (Postfix) with ESMTP id 8A0EA8FC12; Wed, 20 Jun 2012 09:19:15 +0000 (UTC) Received: from smtp23.mail.ru (smtp23.mail.ru [94.100.176.176]) by fallback4.mail.ru (mPOP.Fallback_MX) with ESMTP id DB2768B3C44B; Wed, 20 Jun 2012 13:19:13 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=IT88HzSX9N5abpczEMZTXZ7hc6KCFjATl5zRNSBDzGg=; b=rOfceUKruvrai9f4OzX9koZg5ORzRk+/pV+3gKqlAcBlX+A+5A3BgEE7L1COuyuaE1yM6Pp1Ad06A0KcXReFY3r0TbxkqFIbCcd5xFUqSkOS8MXLbOLPS6H6g2ATjwQF; Received: from [93.185.182.46] (port=20381 helo=gpr.nnz-home.ru) by smtp23.mail.ru with esmtpa (envelope-from ) id 1ShH40-0000uC-H6; Wed, 20 Jun 2012 13:19:00 +0400 Received: from gpr by gpr.nnz-home.ru with local (Exim 4.77 (FreeBSD)) (envelope-from ) id 1ShH3j-000BrY-8T; Wed, 20 Jun 2012 13:18:43 +0400 Date: Wed, 20 Jun 2012 13:18:43 +0400 From: Gennady Proskurin To: Daniel O'Connor Message-ID: <20120620091843.GB832@gpr.nnz-home.ru> References: <68FBE843-7337-4C90-B01F-E0CAABB62BCD@gsoft.com.au> <31750.1340083631@critter.freebsd.dk> <20120620074101.GA832@gpr.nnz-home.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam: Not detected X-Mras: Ok Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, Gennady Proskurin , src-committers@freebsd.org, Poul-Henning Kamp Subject: Re: svn commit: r237223 - head/sys/dev/fb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 09:19:16 -0000 On Wed, Jun 20, 2012 at 05:59:07PM +0930, Daniel O'Connor wrote: > > On 20/06/2012, at 17:11, Gennady Proskurin wrote: > > On Tue, Jun 19, 2012 at 05:27:11AM +0000, Poul-Henning Kamp wrote: > >> In message <68FBE843-7337-4C90-B01F-E0CAABB62BCD@gsoft.com.au>, "Daniel O'Conno > >> r" writes: > >> > >>>> If size is odd, this does not copy the last byte. Not sure, whether = > >>> this is intended. > >> > >> Feel free to improve... > > > > > > > Surely if you pass it an odd size you made a mistake - either the wrong function was used or you computed the size incorrectly. Functions are called "bcopy_io" and so, such names tell nothing about data size they work with ("copyw" tells something). If it is not supposed to work with odd size, I agree, my patch is overkill, something like KASSERT (or just one-line comment) is better. I just wanted to be sure, that potential bug in this code is known to developpers. From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 09:28:33 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DDA421065686; Wed, 20 Jun 2012 09:28:33 +0000 (UTC) (envelope-from phk@phk.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.freebsd.org (Postfix) with ESMTP id 9705D8FC08; Wed, 20 Jun 2012 09:28:33 +0000 (UTC) Received: from critter.freebsd.dk (unknown [192.168.61.3]) by phk.freebsd.dk (Postfix) with ESMTP id 6CC2D3B763; Wed, 20 Jun 2012 09:28:27 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.14.5/8.14.5) with ESMTP id q5K9SPrL070850; Wed, 20 Jun 2012 09:28:25 GMT (envelope-from phk@phk.freebsd.dk) To: Gennady Proskurin From: "Poul-Henning Kamp" In-Reply-To: Your message of "Wed, 20 Jun 2012 11:41:01 +0400." <20120620074101.GA832@gpr.nnz-home.ru> Content-Type: text/plain; charset=ISO-8859-1 Date: Wed, 20 Jun 2012 09:28:25 +0000 Message-ID: <70849.1340184505@critter.freebsd.dk> Cc: svn-src-head@freebsd.org, Daniel O'Connor , svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237223 - head/sys/dev/fb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 09:28:34 -0000 In message <20120620074101.GA832@gpr.nnz-home.ru>, Gennady Proskurin writes: >> >> If size is odd, this does not copy the last byte. Not sure, whether = >> >this is intended. >> >> Feel free to improve... It is not my impression that an odd byte count can happen at all... And yes, I fully agree with Bruce that it is a mess, so with "improve" I didn't mean "bandaid for non-existent issues" I meant: Rewrite with extreme prejudice. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 15:45:51 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3845C106566B; Wed, 20 Jun 2012 15:45:51 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 196DF8FC0A; Wed, 20 Jun 2012 15:45:51 +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 q5KFjoYB051503; Wed, 20 Jun 2012 15:45:50 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5KFjoxb051501; Wed, 20 Jun 2012 15:45:50 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201206201545.q5KFjoxb051501@svn.freebsd.org> From: Fabien Thomas Date: Wed, 20 Jun 2012 15:45:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237322 - head/sys/dev/xen/balloon X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 15:45:51 -0000 Author: fabient Date: Wed Jun 20 15:45:50 2012 New Revision: 237322 URL: http://svn.freebsd.org/changeset/base/237322 Log: Allow booting XENHVM kernel without Xen hypervisor. MFC after: 3 days Modified: head/sys/dev/xen/balloon/balloon.c Modified: head/sys/dev/xen/balloon/balloon.c ============================================================================== --- head/sys/dev/xen/balloon/balloon.c Wed Jun 20 15:12:31 2012 (r237321) +++ head/sys/dev/xen/balloon/balloon.c Wed Jun 20 15:45:50 2012 (r237322) @@ -436,6 +436,9 @@ balloon_init_watcher(void *arg) { int err; + if (!is_running_on_xen()) + return; + err = xs_register_watch(&target_watch); if (err) printf("Failed to set balloon watcher\n"); From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 16:27:28 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A8D61065672; Wed, 20 Jun 2012 16:27:28 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail04.syd.optusnet.com.au (mail04.syd.optusnet.com.au [211.29.132.185]) by mx1.freebsd.org (Postfix) with ESMTP id E2ECC8FC15; Wed, 20 Jun 2012 16:27:27 +0000 (UTC) Received: from c122-106-171-232.carlnfd1.nsw.optusnet.com.au (c122-106-171-232.carlnfd1.nsw.optusnet.com.au [122.106.171.232]) by mail04.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q5KGRNTt028595 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 21 Jun 2012 02:27:25 +1000 Date: Thu, 21 Jun 2012 02:27:23 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Eitan Adler In-Reply-To: <201206200638.q5K6cg7u024024@svn.freebsd.org> Message-ID: <20120621015220.J2636@besplex.bde.org> References: <201206200638.q5K6cg7u024024@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237286 - head/lib/libc/gen X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 16:27:28 -0000 On Wed, 20 Jun 2012, Eitan Adler wrote: > Log: > Don't close an uninitialized descriptor. [1] > Add a sanity check for the validity of the passed fd. Library functions shouldn't use assert() or abort(). The fd is not passed, but is a static variable under syslog()'s control. In libc, only the following use assert.h: - stdio/xprintf*.c. Very nonstd. - rpc/*.c (perhaps not everything) - db/*.c (but partly under DEBUG. Not the standard use where assert() is controlled by NDEBUG) - nameser/ns_print.c - ia64/gen/unwind.c (but under SANITY. The standard NDEBUG is too hard to use here too) - gen/getgrent.c. - regex/grot/main.c (test program. Not part of libc) - regex/regex/utils.h (but ifdefed, and I think turned off in production. Spencer knows how to use NDEBUG) - regex/regcomp.c (ifdefed) - include/isc/list.h - net/*.c (just 2 files) - posix1e/acl*.c (perhaps not everything) - inet/inet_net_pton.c - iconv/*.c (perhaps not everything). The list was only short enough to be described by "only" in not very old versions of FreeBSD. posix1e and iconv doubled the number of files. > Modified: head/lib/libc/gen/syslog.c > ============================================================================== > --- head/lib/libc/gen/syslog.c Wed Jun 20 04:11:34 2012 (r237285) > +++ head/lib/libc/gen/syslog.c Wed Jun 20 06:38:41 2012 (r237286) > @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > > +#include > #include > #include > #include > @@ -413,8 +414,11 @@ void > closelog(void) > { > THREAD_LOCK(); > - (void)_close(LogFile); > - LogFile = -1; > + assert(LogFile >= -1); Since this assert() can't fail (unless the CPU has a parity error or or the memory behind Logfile has a parity error or another memory error or was clobbered by a buffer overrun), this assert() doesn't break the library but just wastes space. > + if (LogFile != -1) { > + (void)_close(LogFile); > + LogFile = -1; > + } > LogTag = NULL; > status = NOCONN; > THREAD_UNLOCK(); Bruce From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 16:37:37 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 453CA106564A for ; Wed, 20 Jun 2012 16:37:37 +0000 (UTC) (envelope-from bounces+73574-9504-svn-src-head=freebsd.org@sendgrid.me) Received: from o3.shared.sendgrid.net (o3.shared.sendgrid.net [208.117.48.85]) by mx1.freebsd.org (Postfix) with SMTP id DC0C88FC1A for ; Wed, 20 Jun 2012 16:37:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.info; h= message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type:content-transfer-encoding; s=smtpapi; bh=TftGBz3F3lVqpXVib75fwLxiFi4=; b=fO0aiA6Vas2DTqjyy5MypgybGrzr Cx15fN/qVffYztON2VZSiq4yaV+rAG8YqvZa7cdNuYcXS+h0xT1W5y8NHBFymIKC Y/3W3s+QLEUO028rYaApiU6Ni+QL2rl4ArjyHUMCMGUrc9prG1ISyIylAzjh6Vl8 kThAubkP75ZdsSg= Received: by 10.8.49.116 with SMTP id mf43.11766.4FE1FC4E5 Wed, 20 Jun 2012 11:37:34 -0500 (CDT) Received: from mail.tarsnap.com (unknown [10.8.49.124]) by mi3 (SG) with ESMTP id 4fe1fc4e.132d.1f0ab5c for ; Wed, 20 Jun 2012 11:37:34 -0500 (CST) Received: (qmail 84857 invoked from network); 20 Jun 2012 16:37:10 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by ec2-107-20-205-189.compute-1.amazonaws.com with ESMTP; 20 Jun 2012 16:37:10 -0000 Received: (qmail 90108 invoked from network); 20 Jun 2012 16:36:52 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by clamshell.daemonology.net with SMTP; 20 Jun 2012 16:36:52 -0000 Message-ID: <4FE1FC23.9000904@freebsd.org> Date: Wed, 20 Jun 2012 09:36:51 -0700 From: Colin Percival User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20120509 Thunderbird/12.0.1 MIME-Version: 1.0 To: Bruce Evans References: <201206200638.q5K6cg7u024024@svn.freebsd.org> <20120621015220.J2636@besplex.bde.org> In-Reply-To: <20120621015220.J2636@besplex.bde.org> X-Enigmail-Version: 1.5pre Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Sendgrid-EID: EvYvoie/qnEezyq2t4eRKjDm9X7ZKbCMt75WvXA+XNFYUHn+qEl0gxkE0kp+uUnx6pSnINpsyUKctmM98ewuVGomul+0ygDaqMOVVsTn/V87ehZ0ARF6AiC8a6bXNtmkUlW00Spo9XolM8WxnnpTOXMuxNCmiKZ5FKFgh3wF7FA= Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Eitan Adler Subject: Re: svn commit: r237286 - head/lib/libc/gen X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 16:37:37 -0000 On 06/20/12 09:27, Bruce Evans wrote: > On Wed, 20 Jun 2012, Eitan Adler wrote: >> Log: >> Don't close an uninitialized descriptor. [1] >> Add a sanity check for the validity of the passed fd. > > Library functions shouldn't use assert() or abort(). Why not? > The fd is not passed, but is a static variable under syslog()'s control. I understood "passed fd" to mean "fd we're passing to _close". >> closelog(void) >> { >> THREAD_LOCK(); >> - (void)_close(LogFile); >> - LogFile = -1; >> + assert(LogFile >= -1); > > Since this assert() can't fail (unless the CPU has a parity error or > or the memory behind Logfile has a parity error or another memory error > or was clobbered by a buffer overrun), this assert() doesn't break the > library but just wastes space. I asked eadler to include that on the basis that it made the code easier to understand. -- Colin Percival Security Officer Emeritus, FreeBSD | The power to serve Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 17:08:01 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CCD921065670; Wed, 20 Jun 2012 17:08:01 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 71A2E8FC15; Wed, 20 Jun 2012 17:08:01 +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 q5KH81K2056371; Wed, 20 Jun 2012 17:08:01 GMT (envelope-from ken@svn.freebsd.org) Received: (from ken@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5KH81EI056365; Wed, 20 Jun 2012 17:08:01 GMT (envelope-from ken@svn.freebsd.org) Message-Id: <201206201708.q5KH81EI056365@svn.freebsd.org> From: "Kenneth D. Merry" Date: Wed, 20 Jun 2012 17:08:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237328 - in head/sys/cam: . scsi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 17:08:01 -0000 Author: ken Date: Wed Jun 20 17:08:00 2012 New Revision: 237328 URL: http://svn.freebsd.org/changeset/base/237328 Log: Fix several reference counting and object lifetime issues between the pass(4) and enc(4) drivers and devfs. The pass(4) driver uses the destroy_dev_sched() routine to schedule its device node for destruction in a separate thread context. It does this because the passcleanup() routine can get called indirectly from the passclose() routine, and that would cause a deadlock if the close routine tried to destroy its own device node. In any case, once a particular passthrough driver number, e.g. pass3, is destroyed, CAM considers that unit number (3 in this case) available for reuse. The problem is that devfs may not be done cleaning up the previous instance of pass3, and will panic if isn't done cleaning up the previous instance. The solution is to get a callback from devfs when the device node is removed, and make sure we hold a reference to the peripheral until that happens. Testing exposed some other cases where we have reference counting issues, and those were also fixed in the pass(4) driver. cam_periph.c: In camperiphfree(), reorder some of the operations. The peripheral destructor needs to be called before the peripheral is removed from the peripheral is removed from the list. This is because once we remove the peripheral from the list, and drop the topology lock, the peripheral number may be reused. But if the destructor hasn't been called yet, there may still be resources hanging around (like devfs nodes) that haven't been fully cleaned up. cam_xpt.c: Add an argument to xpt_remove_periph() to indicate whether the topology lock is already held. scsi_enc.c: Acquire an extra reference to the peripheral during registration, and release it once we get a callback from devfs indicating that the device node is gone. Call destroy_dev_sched_cb() in enc_oninvalidate() instead of calling destroy_dev() in the cleanup routine. scsi_pass.c: Add reference counting to handle peripheral and devfs object lifetime issues. Add a reference to the peripheral and the devfs node in the peripheral registration. Don't attempt to add a physical path alias if the peripheral has been marked invalid. Release the devfs reference once the initial physical path alias taskqueue run has completed. Schedule devfs node destruction in the passoninvalidate(), and release our peripheral reference in a new routine, passdevgonecb() once the devfs node is gone. This allows the peripheral to fully go away, and the peripheral destructor, passcleanup(), will get called. MFC after: 3 days Sponsored by: Spectra Logic Modified: head/sys/cam/cam_periph.c head/sys/cam/cam_xpt.c head/sys/cam/cam_xpt_periph.h head/sys/cam/scsi/scsi_enc.c head/sys/cam/scsi/scsi_pass.c Modified: head/sys/cam/cam_periph.c ============================================================================== --- head/sys/cam/cam_periph.c Wed Jun 20 16:51:14 2012 (r237327) +++ head/sys/cam/cam_periph.c Wed Jun 20 17:08:00 2012 (r237328) @@ -258,7 +258,7 @@ failure: break; case 3: CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph destroyed\n")); - xpt_remove_periph(periph); + xpt_remove_periph(periph, /*topology_lock_held*/ 0); /* FALLTHROUGH */ case 2: xpt_lock_buses(); @@ -610,13 +610,38 @@ camperiphfree(struct cam_periph *periph) return; } - TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links); - (*p_drv)->generation++; + /* + * The peripheral destructor semantics dictate calling with only the + * SIM mutex held. Since it might sleep, it should not be called + * with the topology lock held. + */ xpt_unlock_buses(); + /* + * We need to call the peripheral destructor prior to removing the + * peripheral from the list. Otherwise, we risk running into a + * scenario where the peripheral unit number may get reused + * (because it has been removed from the list), but some resources + * used by the peripheral are still hanging around. In particular, + * the devfs nodes used by some peripherals like the pass(4) driver + * aren't fully cleaned up until the destructor is run. If the + * unit number is reused before the devfs instance is fully gone, + * devfs will panic. + */ if (periph->periph_dtor != NULL) periph->periph_dtor(periph); - xpt_remove_periph(periph); + + /* + * The peripheral list is protected by the topology lock. + */ + xpt_lock_buses(); + + TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links); + (*p_drv)->generation++; + + xpt_remove_periph(periph, /*topology_lock_held*/ 1); + + xpt_unlock_buses(); CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph destroyed\n")); if (periph->flags & CAM_PERIPH_NEW_DEV_FOUND) { Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Wed Jun 20 16:51:14 2012 (r237327) +++ head/sys/cam/cam_xpt.c Wed Jun 20 17:08:00 2012 (r237328) @@ -1026,7 +1026,7 @@ xpt_add_periph(struct cam_periph *periph } void -xpt_remove_periph(struct cam_periph *periph) +xpt_remove_periph(struct cam_periph *periph, int topology_lock_held) { struct cam_ed *device; @@ -1047,9 +1047,13 @@ xpt_remove_periph(struct cam_periph *per SLIST_REMOVE(periph_head, periph, cam_periph, periph_links); } - mtx_lock(&xsoftc.xpt_topo_lock); + if (topology_lock_held == 0) + mtx_lock(&xsoftc.xpt_topo_lock); + xsoftc.xpt_generation++; - mtx_unlock(&xsoftc.xpt_topo_lock); + + if (topology_lock_held == 0) + mtx_unlock(&xsoftc.xpt_topo_lock); } Modified: head/sys/cam/cam_xpt_periph.h ============================================================================== --- head/sys/cam/cam_xpt_periph.h Wed Jun 20 16:51:14 2012 (r237327) +++ head/sys/cam/cam_xpt_periph.h Wed Jun 20 17:08:00 2012 (r237328) @@ -42,7 +42,8 @@ void xpt_polled_action(union ccb *ccb); void xpt_release_ccb(union ccb *released_ccb); void xpt_schedule(struct cam_periph *perph, u_int32_t new_priority); int32_t xpt_add_periph(struct cam_periph *periph); -void xpt_remove_periph(struct cam_periph *periph); +void xpt_remove_periph(struct cam_periph *periph, + int topology_lock_held); void xpt_announce_periph(struct cam_periph *periph, char *announce_string); #endif Modified: head/sys/cam/scsi/scsi_enc.c ============================================================================== --- head/sys/cam/scsi/scsi_enc.c Wed Jun 20 16:51:14 2012 (r237327) +++ head/sys/cam/scsi/scsi_enc.c Wed Jun 20 17:08:00 2012 (r237328) @@ -114,6 +114,16 @@ enc_init(void) } static void +enc_devgonecb(void *arg) +{ + struct cam_periph *periph; + + periph = (struct cam_periph *)arg; + + cam_periph_release(periph); +} + +static void enc_oninvalidate(struct cam_periph *periph) { struct enc_softc *enc; @@ -141,6 +151,8 @@ enc_oninvalidate(struct cam_periph *peri } callout_drain(&enc->status_updater); + destroy_dev_sched_cb(enc->enc_dev, enc_devgonecb, periph); + xpt_print(periph->path, "lost device\n"); } @@ -152,9 +164,7 @@ enc_dtor(struct cam_periph *periph) enc = periph->softc; xpt_print(periph->path, "removing device entry\n"); - cam_periph_unlock(periph); - destroy_dev(enc->enc_dev); - cam_periph_lock(periph); + /* If the sub-driver has a cleanup routine, call it */ if (enc->enc_vec.softc_cleanup != NULL) @@ -951,9 +961,19 @@ enc_ctor(struct cam_periph *periph, void goto out; } } + + if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + xpt_print(periph->path, "%s: lost periph during " + "registration!\n", __func__); + cam_periph_lock(periph); + + return (CAM_REQ_CMP_ERR); + } + enc->enc_dev = make_dev(&enc_cdevsw, periph->unit_number, UID_ROOT, GID_OPERATOR, 0600, "%s%d", periph->periph_name, periph->unit_number); + cam_periph_lock(periph); enc->enc_dev->si_drv1 = periph; Modified: head/sys/cam/scsi/scsi_pass.c ============================================================================== --- head/sys/cam/scsi/scsi_pass.c Wed Jun 20 16:51:14 2012 (r237327) +++ head/sys/cam/scsi/scsi_pass.c Wed Jun 20 17:08:00 2012 (r237328) @@ -55,7 +55,8 @@ __FBSDID("$FreeBSD$"); typedef enum { PASS_FLAG_OPEN = 0x01, PASS_FLAG_LOCKED = 0x02, - PASS_FLAG_INVALID = 0x04 + PASS_FLAG_INVALID = 0x04, + PASS_FLAG_INITIAL_PHYSPATH = 0x08 } pass_flags; typedef enum { @@ -133,7 +134,18 @@ passinit(void) printf("pass: Failed to attach master async callback " "due to status 0x%x!\n", status); } - + +} + +static void +passdevgonecb(void *arg) +{ + struct cam_periph *periph; + + periph = (struct cam_periph *)arg; + + xpt_print(periph->path, "%s: devfs entry is gone\n", __func__); + cam_periph_release(periph); } static void @@ -151,6 +163,12 @@ passoninvalidate(struct cam_periph *peri softc->flags |= PASS_FLAG_INVALID; /* + * Tell devfs this device has gone away, and ask for a callback + * when it has cleaned up its state. + */ + destroy_dev_sched_cb(softc->dev, passdevgonecb, periph); + + /* * XXX Return all queued I/O with ENXIO. * XXX Handle any transactions queued to the card * with XPT_ABORT_CCB. @@ -176,11 +194,6 @@ passcleanup(struct cam_periph *periph) cam_periph_unlock(periph); taskqueue_drain(taskqueue_thread, &softc->add_physpath_task); - /* - * passcleanup() is indirectly a d_close method via passclose, - * so using destroy_dev(9) directly can result in deadlock. - */ - destroy_dev_sched(softc->dev); cam_periph_lock(periph); free(softc, M_DEVBUF); @@ -199,6 +212,12 @@ pass_add_physpath(void *context, int pen */ periph = context; softc = periph->softc; + cam_periph_lock(periph); + if (periph->flags & CAM_PERIPH_INVALID) { + cam_periph_unlock(periph); + return; + } + cam_periph_unlock(periph); physpath = malloc(MAXPATHLEN, M_DEVBUF, M_WAITOK); if (xpt_getattr(physpath, MAXPATHLEN, "GEOM::physpath", periph->path) == 0 @@ -208,6 +227,19 @@ pass_add_physpath(void *context, int pen softc->dev, softc->alias_dev, physpath); } free(physpath, M_DEVBUF); + + /* + * Now that we've made our alias, we no longer have to have a + * reference to the device. + */ + cam_periph_lock(periph); + if ((softc->flags & PASS_FLAG_INITIAL_PHYSPATH) == 0) { + softc->flags |= PASS_FLAG_INITIAL_PHYSPATH; + cam_periph_unlock(periph); + dev_rel(softc->dev); + } + else + cam_periph_unlock(periph); } static void @@ -281,12 +313,12 @@ passregister(struct cam_periph *periph, cgd = (struct ccb_getdev *)arg; if (periph == NULL) { - printf("passregister: periph was NULL!!\n"); + printf("%s: periph was NULL!!\n", __func__); return(CAM_REQ_CMP_ERR); } if (cgd == NULL) { - printf("passregister: no getdev CCB, can't register device\n"); + printf("%s: no getdev CCB, can't register device\n", __func__); return(CAM_REQ_CMP_ERR); } @@ -294,8 +326,8 @@ passregister(struct cam_periph *periph, M_DEVBUF, M_NOWAIT); if (softc == NULL) { - printf("passregister: Unable to probe new device. " - "Unable to allocate softc\n"); + printf("%s: Unable to probe new device. " + "Unable to allocate softc\n", __func__); return(CAM_REQ_CMP_ERR); } @@ -331,10 +363,31 @@ passregister(struct cam_periph *periph, DEVSTAT_TYPE_PASS, DEVSTAT_PRIORITY_PASS); + /* + * Acquire a reference to the periph before we create the devfs + * instance for it. We'll release this reference once the devfs + * instance has been freed. + */ + if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + xpt_print(periph->path, "%s: lost periph during " + "registration!\n", __func__); + mtx_lock(periph->sim->mtx); + return (CAM_REQ_CMP_ERR); + } + /* Register the device */ softc->dev = make_dev(&pass_cdevsw, periph->unit_number, UID_ROOT, GID_OPERATOR, 0600, "%s%d", periph->periph_name, periph->unit_number); + + /* + * Now that we have made the devfs instance, hold a reference to it + * until the task queue has run to setup the physical path alias. + * That way devfs won't get rid of the device before we add our + * alias. + */ + dev_ref(softc->dev); + mtx_lock(periph->sim->mtx); softc->dev->si_drv1 = periph; From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 17:20:26 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38FA01065674; Wed, 20 Jun 2012 17:20:26 +0000 (UTC) (envelope-from mjacob@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 23DBF8FC19; Wed, 20 Jun 2012 17:20:26 +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 q5KHKPxK056953; Wed, 20 Jun 2012 17:20:25 GMT (envelope-from mjacob@svn.freebsd.org) Received: (from mjacob@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5KHKPq7056951; Wed, 20 Jun 2012 17:20:25 GMT (envelope-from mjacob@svn.freebsd.org) Message-Id: <201206201720.q5KHKPq7056951@svn.freebsd.org> From: Matt Jacob Date: Wed, 20 Jun 2012 17:20:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237329 - head/usr.sbin/mfiutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 17:20:26 -0000 Author: mjacob Date: Wed Jun 20 17:20:25 2012 New Revision: 237329 URL: http://svn.freebsd.org/changeset/base/237329 Log: Fix ARM compilation issue. X-MFC: 237260 Modified: head/usr.sbin/mfiutil/mfi_drive.c Modified: head/usr.sbin/mfiutil/mfi_drive.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_drive.c Wed Jun 20 17:08:00 2012 (r237328) +++ head/usr.sbin/mfiutil/mfi_drive.c Wed Jun 20 17:20:25 2012 (r237329) @@ -330,11 +330,13 @@ cam_strvis(char *dst, const char *src, i const char * mfi_pd_inq_string(struct mfi_pd_info *info) { - struct scsi_inquiry_data *inq_data; + struct scsi_inquiry_data iqd, *inq_data = &iqd; char vendor[16], product[48], revision[16], rstr[12], serial[SID_VENDOR_SPECIFIC_0_SIZE]; static char inq_string[64]; - inq_data = (struct scsi_inquiry_data *)info->inquiry_data; + memcpy(inq_data, info->inquiry_data, + (sizeof (iqd) < sizeof (info->inquiry_data))? + sizeof (iqd) : sizeof (info->inquiry_data)); if (SID_QUAL_IS_VENDOR_UNIQUE(inq_data)) return (NULL); if (SID_TYPE(inq_data) != T_DIRECT) From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 17:26:22 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D85E106566B; Wed, 20 Jun 2012 17:26:22 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8851F8FC1C; Wed, 20 Jun 2012 17:26:22 +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 q5KHQMWK057241; Wed, 20 Jun 2012 17:26:22 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5KHQMV4057239; Wed, 20 Jun 2012 17:26:22 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201206201726.q5KHQMV4057239@svn.freebsd.org> From: Sean Bruno Date: Wed, 20 Jun 2012 17:26:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237330 - head/share/man/man4 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 17:26:22 -0000 Author: sbruno Date: Wed Jun 20 17:26:22 2012 New Revision: 237330 URL: http://svn.freebsd.org/changeset/base/237330 Log: Now that there is an est(4) man page, reference it here in cpufreq(4). Modified: head/share/man/man4/cpufreq.4 Modified: head/share/man/man4/cpufreq.4 ============================================================================== --- head/share/man/man4/cpufreq.4 Wed Jun 20 17:20:25 2012 (r237329) +++ head/share/man/man4/cpufreq.4 Wed Jun 20 17:26:22 2012 (r237330) @@ -286,6 +286,7 @@ then it should set all elements to .Dv CPUFREQ_VAL_UNKNOWN . .Sh SEE ALSO .Xr acpi 4 , +.Xr est 4 , .Xr timecounters 4 , .Xr powerd 8 , .Xr sysctl 8 From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 18:00:27 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1F8E7106566C; Wed, 20 Jun 2012 18:00:27 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0B7B28FC08; Wed, 20 Jun 2012 18:00:27 +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 q5KI0QMT059136; Wed, 20 Jun 2012 18:00:26 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5KI0QQf059134; Wed, 20 Jun 2012 18:00:26 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206201800.q5KI0QQf059134@svn.freebsd.org> From: John Baldwin Date: Wed, 20 Jun 2012 18:00:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237334 - head/sys/vm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 18:00:27 -0000 Author: jhb Date: Wed Jun 20 18:00:26 2012 New Revision: 237334 URL: http://svn.freebsd.org/changeset/base/237334 Log: Move the per-thread deferred user map entries list into a private list in vm_map_process_deferred() which is then iterated to release map entries. This avoids having a nested vm map unlock operation called from the loop body attempt to recuse into vm_map_process_deferred(). This can happen if the vm_map_remove() triggers the OOM killer. Reviewed by: alc, kib MFC after: 1 week Modified: head/sys/vm/vm_map.c Modified: head/sys/vm/vm_map.c ============================================================================== --- head/sys/vm/vm_map.c Wed Jun 20 17:52:21 2012 (r237333) +++ head/sys/vm/vm_map.c Wed Jun 20 18:00:26 2012 (r237334) @@ -475,12 +475,14 @@ static void vm_map_process_deferred(void) { struct thread *td; - vm_map_entry_t entry; + vm_map_entry_t entry, next; vm_object_t object; td = curthread; - while ((entry = td->td_map_def_user) != NULL) { - td->td_map_def_user = entry->next; + entry = td->td_map_def_user; + td->td_map_def_user = NULL; + while (entry != NULL) { + next = entry->next; if ((entry->eflags & MAP_ENTRY_VN_WRITECNT) != 0) { /* * Decrement the object's writemappings and @@ -494,6 +496,7 @@ vm_map_process_deferred(void) entry->end); } vm_map_entry_deallocate(entry, FALSE); + entry = next; } } From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 18:25:52 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 431AC106566C; Wed, 20 Jun 2012 18:25:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2EC1F8FC23; Wed, 20 Jun 2012 18:25:52 +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 q5KIPqtX060918; Wed, 20 Jun 2012 18:25:52 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5KIPpjQ060916; Wed, 20 Jun 2012 18:25:51 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206201825.q5KIPpjQ060916@svn.freebsd.org> From: Alexander Motin Date: Wed, 20 Jun 2012 18:25:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237335 - head/sys/cam/scsi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 18:25:52 -0000 Author: mav Date: Wed Jun 20 18:25:51 2012 New Revision: 237335 URL: http://svn.freebsd.org/changeset/base/237335 Log: Check status of cam_periph_hold() inside cdclose(). If cd device was invalidated while open, cam_periph_hold() will return error and won't get the reference. Following reference release will crash the system. Sponsored by: iXsystems, Inc. MFC after: 3 days Modified: head/sys/cam/scsi/scsi_cd.c Modified: head/sys/cam/scsi/scsi_cd.c ============================================================================== --- head/sys/cam/scsi/scsi_cd.c Wed Jun 20 18:00:26 2012 (r237334) +++ head/sys/cam/scsi/scsi_cd.c Wed Jun 20 18:25:51 2012 (r237335) @@ -1041,6 +1041,7 @@ cdclose(struct disk *dp) { struct cam_periph *periph; struct cd_softc *softc; + int error; periph = (struct cam_periph *)dp->d_drv1; if (periph == NULL) @@ -1049,7 +1050,11 @@ cdclose(struct disk *dp) softc = (struct cd_softc *)periph->softc; cam_periph_lock(periph); - cam_periph_hold(periph, PRIBIO); + if ((error = cam_periph_hold(periph, PRIBIO)) != 0) { + cam_periph_unlock(periph); + cam_periph_release(periph); + return (0); + } CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH, ("cdclose\n")); From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 18:35:36 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C347E106566C; Wed, 20 Jun 2012 18:35:36 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AF8CC8FC15; Wed, 20 Jun 2012 18:35: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 q5KIZatu061357; Wed, 20 Jun 2012 18:35:36 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5KIZash061354; Wed, 20 Jun 2012 18:35:36 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206201835.q5KIZash061354@svn.freebsd.org> From: Alexander Motin Date: Wed, 20 Jun 2012 18:35:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237336 - head/sys/cam/scsi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 18:35:36 -0000 Author: mav Date: Wed Jun 20 18:35:36 2012 New Revision: 237336 URL: http://svn.freebsd.org/changeset/base/237336 Log: Remove unused error variables in cdclose() and daclose(). Modified: head/sys/cam/scsi/scsi_cd.c head/sys/cam/scsi/scsi_da.c Modified: head/sys/cam/scsi/scsi_cd.c ============================================================================== --- head/sys/cam/scsi/scsi_cd.c Wed Jun 20 18:25:51 2012 (r237335) +++ head/sys/cam/scsi/scsi_cd.c Wed Jun 20 18:35:36 2012 (r237336) @@ -1041,7 +1041,6 @@ cdclose(struct disk *dp) { struct cam_periph *periph; struct cd_softc *softc; - int error; periph = (struct cam_periph *)dp->d_drv1; if (periph == NULL) @@ -1050,7 +1049,7 @@ cdclose(struct disk *dp) softc = (struct cd_softc *)periph->softc; cam_periph_lock(periph); - if ((error = cam_periph_hold(periph, PRIBIO)) != 0) { + if (cam_periph_hold(periph, PRIBIO) != 0) { cam_periph_unlock(periph); cam_periph_release(periph); return (0); Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Wed Jun 20 18:25:51 2012 (r237335) +++ head/sys/cam/scsi/scsi_da.c Wed Jun 20 18:35:36 2012 (r237336) @@ -982,14 +982,13 @@ daclose(struct disk *dp) { struct cam_periph *periph; struct da_softc *softc; - int error; periph = (struct cam_periph *)dp->d_drv1; if (periph == NULL) return (0); cam_periph_lock(periph); - if ((error = cam_periph_hold(periph, PRIBIO)) != 0) { + if (cam_periph_hold(periph, PRIBIO) != 0) { cam_periph_unlock(periph); cam_periph_release(periph); return (0); From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 20:01:52 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 179681065672; Wed, 20 Jun 2012 20:01:52 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 048D98FC1C; Wed, 20 Jun 2012 20:01:52 +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 q5KK1pJV065041; Wed, 20 Jun 2012 20:01:51 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5KK1pbZ065039; Wed, 20 Jun 2012 20:01:51 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206202001.q5KK1pbZ065039@svn.freebsd.org> From: John Baldwin Date: Wed, 20 Jun 2012 20:01:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237337 - head/etc/periodic/daily X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 20:01:52 -0000 Author: jhb Date: Wed Jun 20 20:01:51 2012 New Revision: 237337 URL: http://svn.freebsd.org/changeset/base/237337 Log: Only output a list of file systems that need to be dumped if the system has a non-empty dumpdates file. Reviewed by: brooks MFC after: 1 week Modified: head/etc/periodic/daily/400.status-disks Modified: head/etc/periodic/daily/400.status-disks ============================================================================== --- head/etc/periodic/daily/400.status-disks Wed Jun 20 18:35:36 2012 (r237336) +++ head/etc/periodic/daily/400.status-disks Wed Jun 20 20:01:51 2012 (r237337) @@ -19,12 +19,15 @@ case "$daily_status_disks_enable" in df $daily_status_disks_df_flags && rc=1 || rc=3 # display which filesystems need backing up - if ! [ -f /etc/fstab ]; then - export PATH_FSTAB=/dev/null - fi + if [ -s /etc/dumpdates ]; then + if ! [ -f /etc/fstab ]; then + export PATH_FSTAB=/dev/null + fi - echo "" - dump W || rc=3;; + echo "" + dump W || rc=3 + fi + ;; *) rc=0;; esac From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 20:44:23 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E61C61065672 for ; Wed, 20 Jun 2012 20:44:23 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mail-gh0-f182.google.com (mail-gh0-f182.google.com [209.85.160.182]) by mx1.freebsd.org (Postfix) with ESMTP id 48D888FC0C for ; Wed, 20 Jun 2012 20:44:23 +0000 (UTC) Received: by ghbz22 with SMTP id z22so7051946ghb.13 for ; Wed, 20 Jun 2012 13:44:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=F8CakRuoZIGcLqsrSs6I4IE4fTc2pk5bGqbb/nY0Dc4=; b=JhzEp/VIfaFFNsxXpOsMuTxATmECvQgMc8IDOqPcqtJxof8Ll7DKgj4oe9x95ZXI52 I370Z7Zv6b1zE4V7hT3o2bQ0E5RlH0VD3+wWmuFHUaZqkT9VAdvuqOGbt+gPJ0gyOJvr MiMsXGGbffdMlSWw9fHUaSvWVci1rnAHpMhk8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding:x-gm-message-state; bh=F8CakRuoZIGcLqsrSs6I4IE4fTc2pk5bGqbb/nY0Dc4=; b=ldyebgyOZWe/l9+ggD8XvxYI+g4StlbddljoTKtgALZwuVE6SNf84EYiGbJTQ/2eS+ dcvtAr0+AmX6SJlXuszxJ4oEOhmJ2f89N8FvcUvpIR7WCpZKbkouKeB/5Ip7ERYcZZie AuxaTb5XU8Cula5DgxPInVvn/9oq7t1yqiqPTBt6/tvx9TRZ1abHS7f3oI392YyrOjk8 4KwB8rcWg3Rj1DoexUDISMqz3wlyv1hMPoeNvBlYL8H3VQ6OeXiEJtT3kDWO/nmmagDQ a8A6hFwtdc1bA/n+Lmil6wpgxHKwTUSAWpBPitNbRQ3MzD+1QJfktNoiq8t+eIaQh0bZ 6fqA== Received: by 10.60.14.68 with SMTP id n4mr23092990oec.24.1340225062516; Wed, 20 Jun 2012 13:44:22 -0700 (PDT) MIME-Version: 1.0 Sender: lists@eitanadler.com Received: by 10.182.125.70 with HTTP; Wed, 20 Jun 2012 13:43:52 -0700 (PDT) In-Reply-To: <201206201720.q5KHKPq7056951@svn.freebsd.org> References: <201206201720.q5KHKPq7056951@svn.freebsd.org> From: Eitan Adler Date: Wed, 20 Jun 2012 13:43:52 -0700 X-Google-Sender-Auth: J6LFroYC-CPFRNVpEHG7OZNeUWw Message-ID: To: Matt Jacob Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQltYnig1WA91NtMgnzx5ZrH97KArmqrQK4Pl7HYKB/D/5JMeHFKTH2wDwWQPXEnJNJErSU8 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237329 - head/usr.sbin/mfiutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 20:44:24 -0000 On 20 June 2012 10:20, Matt Jacob wrote: > Author: mjacob > Date: Wed Jun 20 17:20:25 2012 > New Revision: 237329 > URL: http://svn.freebsd.org/changeset/base/237329 > > Log: > =C2=A0Fix ARM compilation issue. > > =C2=A0X-MFC: 237260 Sorry about this. I had a sent a diff for approval, but was at work and unable to deal with it on time. --=20 Eitan Adler Source & Ports committer X11, Bugbusting teams From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 21:06:52 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8B8F41065670; Wed, 20 Jun 2012 21:06:52 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 767B48FC18; Wed, 20 Jun 2012 21:06:52 +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 q5KL6qjc067737; Wed, 20 Jun 2012 21:06:52 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5KL6q2N067734; Wed, 20 Jun 2012 21:06:52 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206202106.q5KL6q2N067734@svn.freebsd.org> From: John Baldwin Date: Wed, 20 Jun 2012 21:06:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237338 - head/sys/boot/common X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 21:06:52 -0000 Author: jhb Date: Wed Jun 20 21:06:51 2012 New Revision: 237338 URL: http://svn.freebsd.org/changeset/base/237338 Log: Don't return an error if a kld does not contain any modules (e.g. a kld that only contained a sysctl). The kernel linker allows such modules, so the boot loader should not reject them. MFC after: 2 weeks Modified: head/sys/boot/common/load_elf.c head/sys/boot/common/load_elf_obj.c Modified: head/sys/boot/common/load_elf.c ============================================================================== --- head/sys/boot/common/load_elf.c Wed Jun 20 20:01:51 2012 (r237337) +++ head/sys/boot/common/load_elf.c Wed Jun 20 21:06:51 2012 (r237338) @@ -612,7 +612,7 @@ __elfN(parse_modmetadata)(struct preload Elf_Addr v, p, p_stop; if (__elfN(lookup_symbol)(fp, ef, "__start_set_modmetadata_set", &sym) != 0) - return ENOENT; + return 0; p = sym.st_value + ef->off; if (__elfN(lookup_symbol)(fp, ef, "__stop_set_modmetadata_set", &sym) != 0) return ENOENT; Modified: head/sys/boot/common/load_elf_obj.c ============================================================================== --- head/sys/boot/common/load_elf_obj.c Wed Jun 20 20:01:51 2012 (r237337) +++ head/sys/boot/common/load_elf_obj.c Wed Jun 20 21:06:51 2012 (r237338) @@ -369,7 +369,7 @@ __elfN(obj_parse_modmetadata)(struct pre if (__elfN(obj_lookup_set)(fp, ef, "modmetadata_set", &p, &p_stop, &modcnt) != 0) - return ENOENT; + return 0; modcnt = 0; while (p < p_stop) { From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 21:10:39 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D1AD31065687; Wed, 20 Jun 2012 21:10:39 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BCBD88FC17; Wed, 20 Jun 2012 21:10:39 +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 q5KLAda5067927; Wed, 20 Jun 2012 21:10:39 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5KLAdi6067925; Wed, 20 Jun 2012 21:10:39 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201206202110.q5KLAdi6067925@svn.freebsd.org> From: Xin LI Date: Wed, 20 Jun 2012 21:10:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237339 - head/bin/rm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 21:10:39 -0000 Author: delphij Date: Wed Jun 20 21:10:38 2012 New Revision: 237339 URL: http://svn.freebsd.org/changeset/base/237339 Log: Polish previous revision: if the fts_* routines have lstat()'ed the directory entry then use the struct stat from that instead of doing it again, and skip the rm_overwrite() call if fts_read() indicated that the entry couldn't be a regular file. Obtained from: OpenBSD MFC after: 1 week Modified: head/bin/rm/rm.c Modified: head/bin/rm/rm.c ============================================================================== --- head/bin/rm/rm.c Wed Jun 20 21:06:51 2012 (r237338) +++ head/bin/rm/rm.c Wed Jun 20 21:10:38 2012 (r237339) @@ -301,10 +301,16 @@ rm_tree(char **argv) if (fflag) continue; /* FALLTHROUGH */ - default: + + case FTS_F: + case FTS_NSOK: if (Pflag) - if (!rm_overwrite(p->fts_accpath, NULL)) + if (!rm_overwrite(p->fts_accpath, p->fts_info == + FTS_NSOK ? NULL : p->fts_statp)) continue; + /* FALLTHROUGH */ + + default: rval = unlink(p->fts_accpath); if (rval == 0 || (fflag && errno == ENOENT)) { if (rval == 0 && vflag) From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 21:15:26 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 452AB1065670 for ; Wed, 20 Jun 2012 21:15:26 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 0E3C48FC1F for ; Wed, 20 Jun 2012 21:15:26 +0000 (UTC) Received: by pbbro2 with SMTP id ro2so1290367pbb.13 for ; Wed, 20 Jun 2012 14:15:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer :x-gm-message-state; bh=n2mAkYYH1H2kamlAz3EniseVJXGHI7N0jq/5RY4zn6o=; b=d/v1Zupe+NEY0wyYm62NkEndqUdQDrzIPA1Du0c6Xe6OdKmuOPWbogd2Cazonj8By3 9cs/XLjNQJ31i0pW7fnwSgnYy1d7cM0GuxThLhA+1FnQzRh98RuYNM1L0RCzMw7n07dE Mb225vfnEuLT58YWlnAUi6nTUeP6RuVxwTTE2eewMdFuV5RpUEgUhP3eKVNjnS7JcPDR J1S5lB+9cqHuSdRXG2YbHQIMGt2FoPsitBZbVlWwjYgpAKmGBtaQLFOZXfI6rTpIvTrI OaL7xLDP3ogL0iRtK3yFBYwEqnEFvIyKpQ/1PYQrR+Y1orMUirRNODg3t4yUYAmNUKO2 9HvA== Received: by 10.68.231.40 with SMTP id td8mr82026057pbc.150.1340226925859; Wed, 20 Jun 2012 14:15:25 -0700 (PDT) Received: from [10.30.101.53] ([209.117.142.2]) by mx.google.com with ESMTPS id he9sm33186270pbc.68.2012.06.20.14.15.24 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Jun 2012 14:15:25 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <4FE1FC23.9000904@freebsd.org> Date: Wed, 20 Jun 2012 15:15:17 -0600 Content-Transfer-Encoding: 7bit Message-Id: <690DF487-F7CB-421E-B6BC-F7CE6BC0F658@bsdimp.com> References: <201206200638.q5K6cg7u024024@svn.freebsd.org> <20120621015220.J2636@besplex.bde.org> <4FE1FC23.9000904@freebsd.org> To: Colin Percival X-Mailer: Apple Mail (2.1084) X-Gm-Message-State: ALoCoQmnSeM7U/EFBiUtP+u7unl//YdtXimKCUmqnl5Ug4pbpDOCBWkSaVeyZ7nMTY9MF+F3p/CT Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Eitan Adler , Bruce Evans Subject: Re: svn commit: r237286 - head/lib/libc/gen X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 21:15:26 -0000 On Jun 20, 2012, at 10:36 AM, Colin Percival wrote: > On 06/20/12 09:27, Bruce Evans wrote: >> On Wed, 20 Jun 2012, Eitan Adler wrote: >>> Log: >>> Don't close an uninitialized descriptor. [1] >>> Add a sanity check for the validity of the passed fd. >> >> Library functions shouldn't use assert() or abort(). > > Why not? We've tried to avoid things that make the library dump core... Warner From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 21:24:16 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E09231065676 for ; Wed, 20 Jun 2012 21:24:16 +0000 (UTC) (envelope-from bounces+73574-9504-svn-src-head=freebsd.org@sendgrid.me) Received: from o3.shared.sendgrid.net (o3.shared.sendgrid.net [208.117.48.85]) by mx1.freebsd.org (Postfix) with SMTP id 8D31A8FC18 for ; Wed, 20 Jun 2012 21:24:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.info; h= message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type:content-transfer-encoding; s=smtpapi; bh=cN88ZNaSC7tESRP+6oeN38JKN9Q=; b=TXTtpRnqrABHUbZ8qscGsHnUs/wY teM24AbRFCKkECUK/zqyrkaljbNmC1xghZA/ECgqG4M5xXJ31W+oc1IVPQhoqZgK VGyHdOWxWiG5FIIxz1To/oNGlc1MdjetXEjNSRWetgc3I8zIdWRiGJOxWDLxoOOR ru/+La3KXo/Hd70= Received: by 10.41.149.104 with SMTP id f04-01.8401.4FE23F7F3 Wed, 20 Jun 2012 21:24:15 +0000 (UTC) Received: from mail.tarsnap.com (unknown [10.9.180.5]) by mi3 (SG) with ESMTP id 4fe23f7f.1323.59b0b58 for ; Wed, 20 Jun 2012 16:24:15 -0500 (CST) Received: (qmail 87297 invoked from network); 20 Jun 2012 21:23:50 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by ec2-107-20-205-189.compute-1.amazonaws.com with ESMTP; 20 Jun 2012 21:23:50 -0000 Received: (qmail 91838 invoked from network); 20 Jun 2012 21:23:32 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by clamshell.daemonology.net with SMTP; 20 Jun 2012 21:23:32 -0000 Message-ID: <4FE23F54.5060409@freebsd.org> Date: Wed, 20 Jun 2012 14:23:32 -0700 From: Colin Percival User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20120509 Thunderbird/12.0.1 MIME-Version: 1.0 To: Warner Losh References: <201206200638.q5K6cg7u024024@svn.freebsd.org> <20120621015220.J2636@besplex.bde.org> <4FE1FC23.9000904@freebsd.org> <690DF487-F7CB-421E-B6BC-F7CE6BC0F658@bsdimp.com> In-Reply-To: <690DF487-F7CB-421E-B6BC-F7CE6BC0F658@bsdimp.com> X-Enigmail-Version: 1.5pre Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Sendgrid-EID: EvYvoie/qnEezyq2t4eRKjDm9X7ZKbCMt75WvXA+XNGfNxiEGu5bxcHtKqPfuImh1euKlni7QA0dH7Xem74E7eSlRp8ZHDpjmXUMpNkDIEqmAi4GxDwhiRpq7IRlQ67skQWnUMYLj8vjm+1F0ijuofYJE5eq1sqDZabQN0iLIsI= Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Eitan Adler , Bruce Evans Subject: Re: svn commit: r237286 - head/lib/libc/gen X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 21:24:17 -0000 On 06/20/12 14:15, Warner Losh wrote: > On Jun 20, 2012, at 10:36 AM, Colin Percival wrote: >> On 06/20/12 09:27, Bruce Evans wrote: >>> On Wed, 20 Jun 2012, Eitan Adler wrote: >>>> Log: >>>> Don't close an uninitialized descriptor. [1] >>>> Add a sanity check for the validity of the passed fd. >>> >>> Library functions shouldn't use assert() or abort(). >> >> Why not? > > We've tried to avoid things that make the library dump core... You mean, we avoid it except in the places where we don't? It seems to me that dumping core is exactly the right way to handle a "can't ever happen" situation inside libc -- just like the ~250 instances of assert() in jemalloc. If you mean "passing an invalid parameter to a library function shouldn't result in a core dump", I agree -- but that's not the case here. -- Colin Percival Security Officer Emeritus, FreeBSD | The power to serve Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 21:38:17 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4D83F106566C; Wed, 20 Jun 2012 21:38:17 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 388838FC08; Wed, 20 Jun 2012 21:38:17 +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 q5KLcH0R069356; Wed, 20 Jun 2012 21:38:17 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5KLcHvU069354; Wed, 20 Jun 2012 21:38:17 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201206202138.q5KLcHvU069354@svn.freebsd.org> From: "David E. O'Brien" Date: Wed, 20 Jun 2012 21:38:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237344 - head/tools/regression/usr.bin/make X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 21:38:17 -0000 Author: obrien Date: Wed Jun 20 21:38:16 2012 New Revision: 237344 URL: http://svn.freebsd.org/changeset/base/237344 Log: Provide a mechanism to not clear out the work and output dirs when developing tests. Modified: head/tools/regression/usr.bin/make/common.sh Modified: head/tools/regression/usr.bin/make/common.sh ============================================================================== --- head/tools/regression/usr.bin/make/common.sh Wed Jun 20 21:34:03 2012 (r237343) +++ head/tools/regression/usr.bin/make/common.sh Wed Jun 20 21:38:16 2012 (r237344) @@ -239,8 +239,10 @@ eval_clean() if [ -n "${TEST_CLEANUP}" ] ; then . ${SRC_DIR}/cleanup fi - rm -rf ${WORK_DIR} - rm -rf ${OUTPUT_DIR} + if [ -z "${NO_TEST_CLEANUP}" ] ; then + rm -rf ${WORK_DIR} + rm -rf ${OUTPUT_DIR} + fi } # From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 21:41:56 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9CD6A1065673; Wed, 20 Jun 2012 21:41:56 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from anubis.delphij.net (anubis.delphij.net [64.62.153.212]) by mx1.freebsd.org (Postfix) with ESMTP id 7AC8A8FC0C; Wed, 20 Jun 2012 21:41:56 +0000 (UTC) Received: from delta.delphij.net (drawbridge.ixsystems.com [206.40.55.65]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by anubis.delphij.net (Postfix) with ESMTPSA id 43E185AAF; Wed, 20 Jun 2012 14:41:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=delphij.net; s=anubis; t=1340228516; bh=XyU5PPr7jtVyqYdKpLbR9vJClbVqVCjpgLtzMB1bq5o=; h=Date:From:Reply-To:To:CC:Subject:References:In-Reply-To; b=zx102Ixt8DxQ4pvamheeOgUlwnlRbG+MVewALq5FAN6acjt85fNJk8jP5BDGLTGy6 BWTb6c5AnKDQw+TnWjQGoc+QV6eyaYoEfQyilMGR5r2hQ/l3lQlsXfPujfgleKolKC UZkZwyWHWBl8ldZ0KpfcET816CZBwiGWQp2CFLVs= Message-ID: <4FE243A3.1070202@delphij.net> Date: Wed, 20 Jun 2012 14:41:55 -0700 From: Xin Li Organization: The FreeBSD Project MIME-Version: 1.0 To: Colin Percival References: <201206200638.q5K6cg7u024024@svn.freebsd.org> <20120621015220.J2636@besplex.bde.org> <4FE1FC23.9000904@freebsd.org> <690DF487-F7CB-421E-B6BC-F7CE6BC0F658@bsdimp.com> <4FE23F54.5060409@freebsd.org> In-Reply-To: <4FE23F54.5060409@freebsd.org> X-Enigmail-Version: 1.4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: src-committers@freebsd.org, Eitan Adler , svn-src-all@freebsd.org, Warner Losh , Bruce Evans , svn-src-head@freebsd.org, d@delphij.net Subject: Re: svn commit: r237286 - head/lib/libc/gen X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: d@delphij.net List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 21:41:56 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 06/20/12 14:23, Colin Percival wrote: > On 06/20/12 14:15, Warner Losh wrote: >> On Jun 20, 2012, at 10:36 AM, Colin Percival wrote: >>> On 06/20/12 09:27, Bruce Evans wrote: >>>> On Wed, 20 Jun 2012, Eitan Adler wrote: >>>>> Log: Don't close an uninitialized descriptor. [1] Add a >>>>> sanity check for the validity of the passed fd. >>>> >>>> Library functions shouldn't use assert() or abort(). >>> >>> Why not? >> >> We've tried to avoid things that make the library dump core... > > You mean, we avoid it except in the places where we don't? It > seems to me that dumping core is exactly the right way to handle a > "can't ever happen" situation inside libc -- just like the ~250 > instances of assert() in jemalloc. > > If you mean "passing an invalid parameter to a library function > shouldn't result in a core dump", I agree -- but that's not the > case here. But malloc() is a rare place that we typically consider as "low level" enough where, no better remedies are provided from API prospective -- there is nothing better than crashing the program immediately, since that would likely to lead us to where the smoking gun is. Library procedures normally detect and report errors, but don't handle them like this. Also, as Bruce pointed out, it's a case that can never happen and thus the explicit assert is just a waste of space. Cheers, - -- Xin LI https://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQEcBAEBCAAGBQJP4kOjAAoJEG80Jeu8UPuzs/cH/ixT9Emrdb4MDoVA3WCE9TS6 W3DE0SbvFtRLrtsSI8i8EsET87sRtOiIoEjFUuRa7HYO3JL3hr9wzLLa84k2sCEW pSPa0pKJ3ZhQR7O3UMb3PxAQxwG4uoFhxST6MuAOci2ySojwbK0YAg5G+TyBf1ch V2MNG2ZIg3tGAmT96/YHONYmP3rleHNDSoYQ5N3m9Svu8am1qRrg8Tz+Z+M0c1db SpJvWBsmrk60xpcZUlHMlO6L1TB5eCAE+pxTiN41xDlL8sXwHIzWf+g7YUyzRa+n 82fpnDPnm6VfdnPHug3MBQ/gRdIMw2aApqEtwRmRTQHIz41t5MA1b48qAWrTH3o= =V4AY -----END PGP SIGNATURE----- From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 23:25:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 30500106566B; Wed, 20 Jun 2012 23:25:48 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0382E8FC15; Wed, 20 Jun 2012 23:25:48 +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 q5KNPlw7073881; Wed, 20 Jun 2012 23:25:47 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5KNPl6p073878; Wed, 20 Jun 2012 23:25:47 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201206202325.q5KNPl6p073878@svn.freebsd.org> From: Alan Cox Date: Wed, 20 Jun 2012 23:25:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237346 - head/sys/vm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 23:25:48 -0000 Author: alc Date: Wed Jun 20 23:25:47 2012 New Revision: 237346 URL: http://svn.freebsd.org/changeset/base/237346 Log: Selectively inline vm_page_dirty(). Modified: head/sys/vm/vm_page.c head/sys/vm/vm_page.h Modified: head/sys/vm/vm_page.c ============================================================================== --- head/sys/vm/vm_page.c Wed Jun 20 22:21:02 2012 (r237345) +++ head/sys/vm/vm_page.c Wed Jun 20 23:25:47 2012 (r237346) @@ -783,7 +783,7 @@ vm_page_sleep(vm_page_t m, const char *m } /* - * vm_page_dirty: + * vm_page_dirty_KBI: [ internal use only ] * * Set all bits in the page's dirty field. * @@ -791,11 +791,14 @@ vm_page_sleep(vm_page_t m, const char *m * call is made from the machine-independent layer. * * See vm_page_clear_dirty_mask(). + * + * This function should only be called by vm_page_dirty(). */ void -vm_page_dirty(vm_page_t m) +vm_page_dirty_KBI(vm_page_t m) { + /* These assertions refer to this operation by its public name. */ KASSERT((m->flags & PG_CACHED) == 0, ("vm_page_dirty: page in cache!")); KASSERT(!VM_PAGE_IS_FREE(m), Modified: head/sys/vm/vm_page.h ============================================================================== --- head/sys/vm/vm_page.h Wed Jun 20 22:21:02 2012 (r237345) +++ head/sys/vm/vm_page.h Wed Jun 20 23:25:47 2012 (r237346) @@ -360,7 +360,6 @@ void vm_page_hold(vm_page_t mem); void vm_page_unhold(vm_page_t mem); void vm_page_free(vm_page_t m); void vm_page_free_zero(vm_page_t m); -void vm_page_dirty(vm_page_t m); void vm_page_wakeup(vm_page_t m); void vm_pageq_remove(vm_page_t m); @@ -414,6 +413,7 @@ void vm_page_cowfault (vm_page_t); int vm_page_cowsetup(vm_page_t); void vm_page_cowclear (vm_page_t); +void vm_page_dirty_KBI(vm_page_t m); void vm_page_lock_KBI(vm_page_t m, const char *file, int line); void vm_page_unlock_KBI(vm_page_t m, const char *file, int line); int vm_page_trylock_KBI(vm_page_t m, const char *file, int line); @@ -429,6 +429,28 @@ void vm_page_object_lock_assert(vm_page_ #endif /* + * vm_page_dirty: + * + * Set all bits in the page's dirty field. + * + * The object containing the specified page must be locked if the + * call is made from the machine-independent layer. + * + * See vm_page_clear_dirty_mask(). + */ +static __inline void +vm_page_dirty(vm_page_t m) +{ + + /* Use vm_page_dirty_KBI() under INVARIANTS to save memory. */ +#if defined(KLD_MODULE) || defined(INVARIANTS) + vm_page_dirty_KBI(m); +#else + m->dirty = VM_PAGE_BITS_ALL; +#endif +} + +/* * vm_page_sleep_if_busy: * * Sleep and release the page queues lock if VPO_BUSY is set or, From owner-svn-src-head@FreeBSD.ORG Wed Jun 20 23:53:36 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DE11C1065672; Wed, 20 Jun 2012 23:53:36 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CA0D88FC14; Wed, 20 Jun 2012 23:53: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 q5KNraC3075109; Wed, 20 Jun 2012 23:53:36 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5KNraeG075107; Wed, 20 Jun 2012 23:53:36 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201206202353.q5KNraeG075107@svn.freebsd.org> From: Xin LI Date: Wed, 20 Jun 2012 23:53:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237348 - head/usr.bin/makewhatis X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 23:53:37 -0000 Author: delphij Date: Wed Jun 20 23:53:36 2012 New Revision: 237348 URL: http://svn.freebsd.org/changeset/base/237348 Log: Currently the code uses gzFile * for a zlib file descriptor, which is not correct. The code works by accident because gzFile is currently defined as void *, and internally it would be casted from or to its real type. A newer version of zlib will instead define it as a pointer to a specific type pointer (namely, struct gzFile_s *). This therefore would cause stricter checks and compiler would catch this type mismatch. This change does not cause any changes to the resulting binary, as validated with md5(1). MFC after: 3 days Modified: head/usr.bin/makewhatis/makewhatis.c Modified: head/usr.bin/makewhatis/makewhatis.c ============================================================================== --- head/usr.bin/makewhatis/makewhatis.c Wed Jun 20 23:47:48 2012 (r237347) +++ head/usr.bin/makewhatis/makewhatis.c Wed Jun 20 23:53:36 2012 (r237348) @@ -693,7 +693,7 @@ enum { STATE_UNKNOWN, STATE_MANSTYLE, ST static void process_page(struct page_info *page, char *section_dir) { - gzFile *in; + gzFile in; char buffer[4096]; char *line; StringList *names; From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 02:38:56 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9A761106566B; Thu, 21 Jun 2012 02:38:56 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail15.syd.optusnet.com.au (mail15.syd.optusnet.com.au [211.29.132.196]) by mx1.freebsd.org (Postfix) with ESMTP id 1EE498FC0C; Thu, 21 Jun 2012 02:38:55 +0000 (UTC) Received: from c122-106-171-232.carlnfd1.nsw.optusnet.com.au (c122-106-171-232.carlnfd1.nsw.optusnet.com.au [122.106.171.232]) by mail15.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q5L2cVBq028971 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 21 Jun 2012 12:38:34 +1000 Date: Thu, 21 Jun 2012 12:38:31 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: d@delphij.net In-Reply-To: <4FE243A3.1070202@delphij.net> Message-ID: <20120621112708.W901@besplex.bde.org> References: <201206200638.q5K6cg7u024024@svn.freebsd.org> <20120621015220.J2636@besplex.bde.org> <4FE1FC23.9000904@freebsd.org> <690DF487-F7CB-421E-B6BC-F7CE6BC0F658@bsdimp.com> <4FE23F54.5060409@freebsd.org> <4FE243A3.1070202@delphij.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: src-committers@freebsd.org, Eitan Adler , Colin Percival , svn-src-all@freebsd.org, Warner Losh , Bruce Evans , svn-src-head@freebsd.org Subject: Re: svn commit: r237286 - head/lib/libc/gen X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 02:38:56 -0000 On Wed, 20 Jun 2012, Xin Li wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > On 06/20/12 14:23, Colin Percival wrote: >> On 06/20/12 14:15, Warner Losh wrote: >>> On Jun 20, 2012, at 10:36 AM, Colin Percival wrote: >>>> On 06/20/12 09:27, Bruce Evans wrote: >>>>> On Wed, 20 Jun 2012, Eitan Adler wrote: >>>>>> Log: Don't close an uninitialized descriptor. [1] Add a >>>>>> sanity check for the validity of the passed fd. >>>>> >>>>> Library functions shouldn't use assert() or abort(). >>>> >>>> Why not? Because correctly designed APIs handle errors by returning an error status. Less correctly designed APIs might handle errors by dumping core, but then they have to document this. >>> We've tried to avoid things that make the library dump core... >> >> You mean, we avoid it except in the places where we don't? It >> seems to me that dumping core is exactly the right way to handle a >> "can't ever happen" situation inside libc -- just like the ~250 >> instances of assert() in jemalloc. Doesn't inspire confidence. I missed this because jemalloc doesn't include assert.h. It rolls its own assert() "to reduce the chance of deadlock during assertion failure". The library assert is indeed unusable in malloc() since it calls stdio, which may call malloc(). (It is a standard bug that assert() must write on stderr, since write() and STDERR_FILENO are not available in plain STDC. stderr is under more direct control of the application than is STDERR_FILENO. Although it is normally unbuffered, the application may set it into some mode that is buffered with the buffer not yet allocated, or otherwise uses malloc(). jemalloc's assert() avoids this problem by writing to STDERR_FILENO). But even in jemalloc, the assert()s are in debugging code and are turned off in production. It is apparently not ready for production, since MALLOC_PRODUCTION is apparently never configured. MALLOC_PRODUCTION also turns off the default malloc options of AJ. The default A option gives much larger standards breakage and core dumps, by aborting for all warnings. Not configuring MALLOC_PRODUCTION also results in configuring MALLOC_DEBUG and MALLOC_STATS. These result in malloc() using stdio in other ways, although it has mounds of code to avoid this in the production version. >> If you mean "passing an invalid parameter to a library function >> shouldn't result in a core dump", I agree -- but that's not the >> case here. Any undefined behaviour can cause a core dump, even when it is an invalid parameter passed to a library function (examples are null pointers passed to string and memory functions). However, the library should be more carefully written than applications, so it shouldn't have any undefined behaviours, and if it actually checks for undefined behaviours then it should try not to abort when it finds one. > But malloc() is a rare place that we typically consider as "low level" > enough where, no better remedies are provided from API prospective -- > there is nothing better than crashing the program immediately, since > that would likely to lead us to where the smoking gun is. Library > procedures normally detect and report errors, but don't handle them > like this. > > Also, as Bruce pointed out, it's a case that can never happen and thus > the explicit assert is just a waste of space. The only good think about the assert() in closelog() is that it detects a problem (that can't happen) in some cases and aborts before destroying the evidence. Here are all uses of LogFile in syslog.c. This shows that the assert() is even more bogus than I thought (since there are several closes of LogFile, but only an assert() for the recently changed one). Of course there are no assert()s for critical uses of LogFile. % static int LogFile = -1; /* fd for log */ % ... % if (send(LogFile, tbuf, cnt, 0) < 0) { % ... % if (send(LogFile, tbuf, cnt, 0) >= 0) { % ... These use LogFile without checking that it is not -1. This error can happen -- see below. % static void % disconnectlog(void) % { % /* % * If the user closed the FD and opened another in the same slot, % * that's their problem. They should close it before calling on % * system services. % */ % if (LogFile != -1) { % _close(LogFile); % LogFile = -1; % } % status = NOCONN; /* retry connect */ % } disconnect() is very similar to closelog(). It already had the check to avoid the unnecessary close when LogFile has not been allocated, but doesn't have an assert(). % ... % static void % connectlog(void) % { % struct sockaddr_un SyslogAddr; /* AF_UNIX address of local logger */ % % if (LogFile == -1) { % if ((LogFile = _socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) % return; % (void)_fcntl(LogFile, F_SETFD, FD_CLOEXEC); % } % if (LogFile != -1 && status == NOCONN) { Bogus check that LogFile != -1. If LogFile was -1, then we just called _socket() succeessfully to make it different from -1, or returned if _socket() failed. % ... % if (_connect(LogFile, (struct sockaddr *)&SyslogAddr, % ... % if (_connect(LogFile, (struct sockaddr *)&SyslogAddr, % ... % if (_connect(LogFile, (struct sockaddr *)&SyslogAddr, % ... % if (status == NOCONN) { % (void)_close(LogFile); % LogFile = -1; connectlog() also returns without allocating LogFile here. % } % ... % } % } Note that we don't bogusly assert() that LogFile >= 0 before we use it. We don't even check that it is not -1 before using it. And this seems to be an error that can actually happen. The 2 _send()s in the above are done soon after calling connectlog(). But connectlog() returns void, and doesn't abort() when it fails to allocate LogFile. It just leaves or resets LogFile to -1 and lets the _send()s fail. % ... % void % closelog(void) % { % THREAD_LOCK(); % assert(LogFile >= -1); The bogus assert(). We check for an error that can't happen (_socket() returning a negative value that is not -1, or something clobbering LogFile to a negative value that is not -1). We don't and can't check for another error that can't happen (something clobbering LogFile to a _non-negative_ but still invalid or conflicting value). % if (LogFile != -1) { % (void)_close(LogFile); % LogFile = -1; % } % LogTag = NULL; % status = NOCONN; % THREAD_UNLOCK(); % } Since closelog() doesn't really use LogFile, handling the case that can't happen (LogFile < -1) by trying the close and resetting state was as harmless as possible. It mainly destroys the evidence that LogFIle (and perhaps other state) got clobbered. But it doesn't detect the problem as early as possible. If you want that, then you need to check LogFile every time before it is used. Don't forget to check for parity errors in the CPU before every instruction too. Bruce From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 03:10:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id ECD761065674; Thu, 21 Jun 2012 03:10:48 +0000 (UTC) (envelope-from fjoe@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BE4A68FC0A; Thu, 21 Jun 2012 03:10:48 +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 q5L3AmFg084979; Thu, 21 Jun 2012 03:10:48 GMT (envelope-from fjoe@svn.freebsd.org) Received: (from fjoe@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5L3AmLd084976; Thu, 21 Jun 2012 03:10:48 GMT (envelope-from fjoe@svn.freebsd.org) Message-Id: <201206210310.q5L3AmLd084976@svn.freebsd.org> From: Max Khon Date: Thu, 21 Jun 2012 03:10:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237350 - head/sys/dev/puc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 03:10:49 -0000 Author: fjoe Date: Thu Jun 21 03:10:48 2012 New Revision: 237350 URL: http://svn.freebsd.org/changeset/base/237350 Log: Add support for the following Moxa PCIe multiport serial boards: - CP102E - CP102EL - CP132EL - CP114EL - CP118EL-A - CP168EL-A MFC after: 1 week Modified: head/sys/dev/puc/puc_cfg.h head/sys/dev/puc/pucdata.c Modified: head/sys/dev/puc/puc_cfg.h ============================================================================== --- head/sys/dev/puc/puc_cfg.h Thu Jun 21 02:48:49 2012 (r237349) +++ head/sys/dev/puc/puc_cfg.h Thu Jun 21 03:10:48 2012 (r237350) @@ -79,7 +79,7 @@ struct puc_cfg { int8_t ports; int8_t rid; /* Rid of first port */ int8_t d_rid; /* Delta rid of next ports */ - int8_t d_ofs; /* Delta offset of next ports */ + int16_t d_ofs; /* Delta offset of next ports */ puc_config_f *config_function; }; Modified: head/sys/dev/puc/pucdata.c ============================================================================== --- head/sys/dev/puc/pucdata.c Thu Jun 21 02:48:49 2012 (r237349) +++ head/sys/dev/puc/pucdata.c Thu Jun 21 03:10:48 2012 (r237350) @@ -507,6 +507,18 @@ const struct puc_cfg puc_pci_devices[] = .config_function = puc_config_quatech }, + { 0x1393, 0x1024, 0xffff, 0, + "Moxa Technologies, Smartio CP-102E/PCIe", + DEFAULT_RCLK * 8, + PUC_PORT_2S, 0x14, 0, 0x200 + }, + + { 0x1393, 0x1025, 0xffff, 0, + "Moxa Technologies, Smartio CP-102EL/PCIe", + DEFAULT_RCLK * 8, + PUC_PORT_2S, 0x14, 0, 0x200, + }, + { 0x1393, 0x1040, 0xffff, 0, "Moxa Technologies, Smartio C104H/PCI", DEFAULT_RCLK * 8, @@ -550,6 +562,25 @@ const struct puc_cfg puc_pci_devices[] = PUC_PORT_4S, 0x18, 0, 8, }, + { 0x1393, 0x1144, 0xffff, 0, + "Moxa Technologies, Smartio CP-114EL/PCIe", + DEFAULT_RCLK * 8, + PUC_PORT_4S, 0x14, 0, -1, + .config_function = puc_config_moxa + }, + + { 0x1393, 0x1182, 0xffff, 0, + "Moxa Technologies, Smartio CP-118EL-A/PCIe", + DEFAULT_RCLK * 8, + PUC_PORT_8S, 0x14, 0, 0x200, + }, + + { 0x1393, 0x1322, 0xffff, 0, + "Moxa Technologies, Smartio CP-132EL/PCIe", + DEFAULT_RCLK * 8, + PUC_PORT_2S, 0x14, 0, 0x200, + }, + { 0x1393, 0x1680, 0xffff, 0, "Moxa Technologies, C168H/PCI", DEFAULT_RCLK * 8, @@ -568,6 +599,12 @@ const struct puc_cfg puc_pci_devices[] = PUC_PORT_8S, 0x18, 0, 8, }, + { 0x1393, 0x1683, 0xffff, 0, + "Moxa Technologies, Smartio CP-168EL-A/PCIe", + DEFAULT_RCLK * 8, + PUC_PORT_8S, 0x14, 0, 0x200, + }, + { 0x13a8, 0x0152, 0xffff, 0, "Exar XR17C/D152", DEFAULT_RCLK * 8, @@ -1127,9 +1164,7 @@ static int puc_config_moxa(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port, intptr_t *res) { - const struct puc_cfg *cfg = sc->sc_cfg; - - if (cmd == PUC_CFG_GET_OFS && cfg->device == 0x1045) { + if (cmd == PUC_CFG_GET_OFS) { *res = ((port == 3) ? 7 : port) * 0x200; return 0; } From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 04:57:59 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B3FD41065674; Thu, 21 Jun 2012 04:57:59 +0000 (UTC) (envelope-from fjoe@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8FE918FC0C; Thu, 21 Jun 2012 04:57:59 +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 q5L4vx2H089870; Thu, 21 Jun 2012 04:57:59 GMT (envelope-from fjoe@svn.freebsd.org) Received: (from fjoe@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5L4vx1f089868; Thu, 21 Jun 2012 04:57:59 GMT (envelope-from fjoe@svn.freebsd.org) Message-Id: <201206210457.q5L4vx1f089868@svn.freebsd.org> From: Max Khon Date: Thu, 21 Jun 2012 04:57:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237357 - head/sys/dev/puc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 04:57:59 -0000 Author: fjoe Date: Thu Jun 21 04:57:59 2012 New Revision: 237357 URL: http://svn.freebsd.org/changeset/base/237357 Log: Remove Moxa CP-132EL definition (RS422/485-only board). Modified: head/sys/dev/puc/pucdata.c Modified: head/sys/dev/puc/pucdata.c ============================================================================== --- head/sys/dev/puc/pucdata.c Thu Jun 21 04:52:26 2012 (r237356) +++ head/sys/dev/puc/pucdata.c Thu Jun 21 04:57:59 2012 (r237357) @@ -575,12 +575,6 @@ const struct puc_cfg puc_pci_devices[] = PUC_PORT_8S, 0x14, 0, 0x200, }, - { 0x1393, 0x1322, 0xffff, 0, - "Moxa Technologies, Smartio CP-132EL/PCIe", - DEFAULT_RCLK * 8, - PUC_PORT_2S, 0x14, 0, 0x200, - }, - { 0x1393, 0x1680, 0xffff, 0, "Moxa Technologies, C168H/PCI", DEFAULT_RCLK * 8, From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 08:45:58 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 72B961065670; Thu, 21 Jun 2012 08:45:58 +0000 (UTC) (envelope-from SRS0=n8fm=EY=FreeBSD.org=brueffer@srs.kundenserver.de) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by mx1.freebsd.org (Postfix) with ESMTP id F29428FC08; Thu, 21 Jun 2012 08:45:57 +0000 (UTC) Received: from ip235-179.wireless.lu.se (ip235-179.wireless.lu.se [130.235.235.179]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0Mam0Q-1SRbH30vpC-00JyNK; Thu, 21 Jun 2012 10:45:43 +0200 Message-ID: <4FE2DF35.5040804@FreeBSD.org> Date: Thu, 21 Jun 2012 10:45:41 +0200 From: Christian Brueffer User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Steve Kargl References: <201204221818.q3MIIn4Y051313@svn.freebsd.org> <20120422184553.GA85374@troutmask.apl.washington.edu> In-Reply-To: <20120422184553.GA85374@troutmask.apl.washington.edu> Content-Type: multipart/mixed; boundary="------------010509040203020300000609" X-Provags-ID: V02:K0:ZXcv39qAy0XvvvssAm3RM666LfcvRFh1dkZixogyoJl D4Mlli+rbdfMwheUT9GPFUcQGS4fDH6gQ4KWYuFtTPJ4V2ojYk cLmHOCam5O2HlD7p3lGlVcnnXYfoI5WuS6R6uJs/TwGZZQ+qZO Kv5Gtn3YFoyzRJvSEZl9seuUuxPepbRmnTBF6iB3NDYXUIUTte OZmsNwfjcWqnPW7TDRN0tOOvRx3RwTNEwSGihVW1Ql6dyM+Bml YhqKWWnGDuxNpezNgFg74EdUmjOyeBkd8ZpHdFulYRn749bIdQ zpRDWF/K331PSCNNowb3HrOikToB4s0azWihzJf9Ss/sAGTzfx uwQZIxv9FfMwsC0e6gYq8B9xAmefp2rPZ65y3zolL Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r234577 - head/usr.bin/stat X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 08:45:58 -0000 This is a multi-part message in MIME format. --------------010509040203020300000609 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 4/22/12 20:45 , Steve Kargl wrote: > On Sun, Apr 22, 2012 at 06:18:49PM +0000, Christian Brueffer wrote: >> Author: brueffer >> Date: Sun Apr 22 18:18:49 2012 >> New Revision: 234577 >> URL: http://svn.freebsd.org/changeset/base/234577 >> >> Log: >> Remove duplicate -l description. >> >> Submitted by: Rainer Hurling >> MFC after: 1 week > > The patch should have also fixed the misordering > of the -n, -qi, and -x options. > Hi Steve, sorry for the late reply. Could you say more specifically how you would arrange the order? From a small sampling of our manpages, it seems we don't have "one true" style of ordering options (except from alphabetically, see attached patch). Some manpages order A-Z, then a-z, while others (Apple and OpenBSD seem to do this) order AaBb...Zz. Cheers, Chris --------------010509040203020300000609 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="stat.1.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="stat.1.diff" Index: stat.1 =================================================================== --- stat.1 (revision 237294) +++ stat.1 (working copy) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 22, 2012 +.Dd June 21, 2012 .Dt STAT 1 .Os .Sh NAME @@ -140,6 +140,15 @@ fall back on .Xr lstat 2 and report information about the link. +.It Fl f Ar format +Display information using the specified format. +See the +.Sx Formats +section for a description of valid formats. +.It Fl l +Display output in +.Nm ls Fl lT +format. .It Fl n Do not force a newline to appear at the end of each piece of output. .It Fl q @@ -151,15 +160,6 @@ When run as .Nm readlink , error messages are automatically suppressed. -.It Fl f Ar format -Display information using the specified format. -See the -.Sx Formats -section for a description of valid formats. -.It Fl l -Display output in -.Nm ls Fl lT -format. .It Fl r Display raw information. That is, for all the fields in the @@ -172,15 +172,15 @@ .Dq shell output format, suitable for initializing variables. -.It Fl x -Display information in a more verbose way as known from some -.Tn Linux -distributions. .It Fl t Ar timefmt Display timestamps using the specified format. This format is passed directly to .Xr strftime 3 . +.It Fl x +Display information in a more verbose way as known from some +.Tn Linux +distributions. .El .Ss Formats Format strings are similar to --------------010509040203020300000609-- From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 09:19:42 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9F3011065672; Thu, 21 Jun 2012 09:19:42 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 898518FC0A; Thu, 21 Jun 2012 09:19:42 +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 q5L9JgWn001683; Thu, 21 Jun 2012 09:19:42 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5L9JfoW001681; Thu, 21 Jun 2012 09:19:41 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206210919.q5L9JfoW001681@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 21 Jun 2012 09:19:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237365 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 09:19:42 -0000 Author: kib Date: Thu Jun 21 09:19:41 2012 New Revision: 237365 URL: http://svn.freebsd.org/changeset/base/237365 Log: Fix locking for f_offset, vn_read() and vn_write() cases only, for now. It seems that intended locking protocol for struct file f_offset field was as follows: f_offset should always be changed under the vnode lock (except fcntl(2) and lseek(2) did not followed the rules). Since read(2) uses shared vnode lock, FOFFSET_LOCKED block is additionally taken to serialize shared vnode lock owners. This was broken first by enabling shared lock on writes, then by fadvise changes, which moved f_offset assigned from under vnode lock, and last by vn_io_fault() doing chunked i/o. More, due to uio_offset not yet valid in vn_io_fault(), the range lock for reads was taken on the wrong region. Change the locking for f_offset to always use FOFFSET_LOCKED block, which is placed before rangelocks in the lock order. Extract foffset_lock() and foffset_unlock() functions which implements FOFFSET_LOCKED lock, and consistently lock f_offset with it in the vn_io_fault() both for reads and writes, even if MNTK_NO_IOPF flag is not set for the vnode mount. Indicate that f_offset is already valid for vn_read() and vn_write() calls from vn_io_fault() with FOF_OFFSET flag, and assert that all callers of vn_read() and vn_write() follow this protocol. Extract get_advice() function to calculate the POSIX_FADV_XXX value for the i/o region, and use it were appropriate. Reviewed by: jhb Tested by: pho MFC after: 2 weeks Modified: head/sys/kern/vfs_vnops.c Modified: head/sys/kern/vfs_vnops.c ============================================================================== --- head/sys/kern/vfs_vnops.c Thu Jun 21 09:12:33 2012 (r237364) +++ head/sys/kern/vfs_vnops.c Thu Jun 21 09:19:41 2012 (r237365) @@ -527,6 +527,66 @@ vn_rdwr_inchunks(rw, vp, base, len, offs return (error); } +static void +foffset_lock(struct file *fp, struct uio *uio, int flags) +{ + struct mtx *mtxp; + + if ((flags & FOF_OFFSET) != 0) + return; + + /* + * According to McKusick the vn lock was protecting f_offset here. + * It is now protected by the FOFFSET_LOCKED flag. + */ + mtxp = mtx_pool_find(mtxpool_sleep, fp); + mtx_lock(mtxp); + while (fp->f_vnread_flags & FOFFSET_LOCKED) { + fp->f_vnread_flags |= FOFFSET_LOCK_WAITING; + msleep(&fp->f_vnread_flags, mtxp, PUSER -1, + "vnread offlock", 0); + } + fp->f_vnread_flags |= FOFFSET_LOCKED; + uio->uio_offset = fp->f_offset; + mtx_unlock(mtxp); +} + +static int +get_advice(struct file *fp, struct uio *uio) +{ + struct mtx *mtxp; + int ret; + + ret = POSIX_FADV_NORMAL; + if (fp->f_advice == NULL) + return (ret); + + mtxp = mtx_pool_find(mtxpool_sleep, fp); + mtx_lock(mtxp); + if (uio->uio_offset >= fp->f_advice->fa_start && + uio->uio_offset + uio->uio_resid <= fp->f_advice->fa_end) + ret = fp->f_advice->fa_advice; + mtx_unlock(mtxp); + return (ret); +} + +static void +foffset_unlock(struct file *fp, struct uio *uio, int flags) +{ + struct mtx *mtxp; + + if ((flags & FOF_OFFSET) != 0) + return; + + fp->f_offset = uio->uio_offset; + mtxp = mtx_pool_find(mtxpool_sleep, fp); + mtx_lock(mtxp); + if (fp->f_vnread_flags & FOFFSET_LOCK_WAITING) + wakeup(&fp->f_vnread_flags); + fp->f_vnread_flags = 0; + mtx_unlock(mtxp); +} + /* * File table vnode read routine. */ @@ -539,44 +599,22 @@ vn_read(fp, uio, active_cred, flags, td) struct thread *td; { struct vnode *vp; - int error, ioflag; struct mtx *mtxp; + int error, ioflag; int advice, vfslocked; off_t offset, start, end; KASSERT(uio->uio_td == td, ("uio_td %p is not td %p", uio->uio_td, td)); - mtxp = NULL; + KASSERT(flags & FOF_OFFSET, ("No FOF_OFFSET")); vp = fp->f_vnode; ioflag = 0; if (fp->f_flag & FNONBLOCK) ioflag |= IO_NDELAY; if (fp->f_flag & O_DIRECT) ioflag |= IO_DIRECT; - advice = POSIX_FADV_NORMAL; + advice = get_advice(fp, uio); vfslocked = VFS_LOCK_GIANT(vp->v_mount); - /* - * According to McKusick the vn lock was protecting f_offset here. - * It is now protected by the FOFFSET_LOCKED flag. - */ - if ((flags & FOF_OFFSET) == 0 || fp->f_advice != NULL) { - mtxp = mtx_pool_find(mtxpool_sleep, fp); - mtx_lock(mtxp); - if ((flags & FOF_OFFSET) == 0) { - while (fp->f_vnread_flags & FOFFSET_LOCKED) { - fp->f_vnread_flags |= FOFFSET_LOCK_WAITING; - msleep(&fp->f_vnread_flags, mtxp, PUSER -1, - "vnread offlock", 0); - } - fp->f_vnread_flags |= FOFFSET_LOCKED; - uio->uio_offset = fp->f_offset; - } - if (fp->f_advice != NULL && - uio->uio_offset >= fp->f_advice->fa_start && - uio->uio_offset + uio->uio_resid <= fp->f_advice->fa_end) - advice = fp->f_advice->fa_advice; - mtx_unlock(mtxp); - } vn_lock(vp, LK_SHARED | LK_RETRY); switch (advice) { @@ -596,14 +634,6 @@ vn_read(fp, uio, active_cred, flags, td) if (error == 0) #endif error = VOP_READ(vp, uio, ioflag, fp->f_cred); - if ((flags & FOF_OFFSET) == 0) { - fp->f_offset = uio->uio_offset; - mtx_lock(mtxp); - if (fp->f_vnread_flags & FOFFSET_LOCK_WAITING) - wakeup(&fp->f_vnread_flags); - fp->f_vnread_flags = 0; - mtx_unlock(mtxp); - } fp->f_nextoff = uio->uio_offset; VOP_UNLOCK(vp, 0); if (error == 0 && advice == POSIX_FADV_NOREUSE && @@ -625,6 +655,7 @@ vn_read(fp, uio, active_cred, flags, td) */ start = offset; end = uio->uio_offset - 1; + mtxp = mtx_pool_find(mtxpool_sleep, fp); mtx_lock(mtxp); if (fp->f_advice != NULL && fp->f_advice->fa_advice == POSIX_FADV_NOREUSE) { @@ -656,13 +687,14 @@ vn_write(fp, uio, active_cred, flags, td { struct vnode *vp; struct mount *mp; - int error, ioflag, lock_flags; struct mtx *mtxp; + int error, ioflag, lock_flags; int advice, vfslocked; off_t offset, start, end; KASSERT(uio->uio_td == td, ("uio_td %p is not td %p", uio->uio_td, td)); + KASSERT(flags & FOF_OFFSET, ("No FOF_OFFSET")); vp = fp->f_vnode; vfslocked = VFS_LOCK_GIANT(vp->v_mount); if (vp->v_type == VREG) @@ -681,6 +713,8 @@ vn_write(fp, uio, active_cred, flags, td if (vp->v_type != VCHR && (error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) goto unlock; + + advice = get_advice(fp, uio); if ((MNT_SHARED_WRITES(mp) || ((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount))) && @@ -691,19 +725,6 @@ vn_write(fp, uio, active_cred, flags, td } vn_lock(vp, lock_flags | LK_RETRY); - if ((flags & FOF_OFFSET) == 0) - uio->uio_offset = fp->f_offset; - advice = POSIX_FADV_NORMAL; - mtxp = NULL; - if (fp->f_advice != NULL) { - mtxp = mtx_pool_find(mtxpool_sleep, fp); - mtx_lock(mtxp); - if (fp->f_advice != NULL && - uio->uio_offset >= fp->f_advice->fa_start && - uio->uio_offset + uio->uio_resid <= fp->f_advice->fa_end) - advice = fp->f_advice->fa_advice; - mtx_unlock(mtxp); - } switch (advice) { case POSIX_FADV_NORMAL: case POSIX_FADV_SEQUENTIAL: @@ -721,8 +742,6 @@ vn_write(fp, uio, active_cred, flags, td if (error == 0) #endif error = VOP_WRITE(vp, uio, ioflag, fp->f_cred); - if ((flags & FOF_OFFSET) == 0) - fp->f_offset = uio->uio_offset; fp->f_nextoff = uio->uio_offset; VOP_UNLOCK(vp, 0); if (vp->v_type != VCHR) @@ -761,6 +780,7 @@ vn_write(fp, uio, active_cred, flags, td */ start = offset; end = uio->uio_offset - 1; + mtxp = mtx_pool_find(mtxpool_sleep, fp); mtx_lock(mtxp); if (fp->f_advice != NULL && fp->f_advice->fa_advice == POSIX_FADV_NOREUSE) { @@ -845,11 +865,15 @@ vn_io_fault(struct file *fp, struct uio else doio = vn_write; vp = fp->f_vnode; + foffset_lock(fp, uio, flags); + if (uio->uio_segflg != UIO_USERSPACE || vp->v_type != VREG || ((mp = vp->v_mount) != NULL && (mp->mnt_kern_flag & MNTK_NO_IOPF) == 0) || - !vn_io_fault_enable) - return (doio(fp, uio, active_cred, flags, td)); + !vn_io_fault_enable) { + error = doio(fp, uio, active_cred, flags | FOF_OFFSET, td); + goto out_last; + } /* * The UFS follows IO_UNIT directive and replays back both @@ -882,7 +906,7 @@ vn_io_fault(struct file *fp, struct uio } save = vm_fault_disable_pagefaults(); - error = doio(fp, uio, active_cred, flags, td); + error = doio(fp, uio, active_cred, flags | FOF_OFFSET, td); if (error != EFAULT) goto out; @@ -933,7 +957,8 @@ vn_io_fault(struct file *fp, struct uio td->td_ma = ma; td->td_ma_cnt = cnt; - error = doio(fp, &short_uio, active_cred, flags, td); + error = doio(fp, &short_uio, active_cred, flags | FOF_OFFSET, + td); vm_page_unhold_pages(ma, cnt); adv = len - short_uio.uio_resid; @@ -956,6 +981,8 @@ out: vm_fault_enable_pagefaults(save); vn_rangelock_unlock(vp, rl_cookie); free(uio_clone, M_IOV); +out_last: + foffset_unlock(fp, uio, flags); return (error); } From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 09:20:08 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9B924106566C; Thu, 21 Jun 2012 09:20:08 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 673B28FC1A; Thu, 21 Jun 2012 09:20:08 +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 q5L9K8IJ001747; Thu, 21 Jun 2012 09:20:08 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5L9K8t5001745; Thu, 21 Jun 2012 09:20:08 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206210920.q5L9K8t5001745@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 21 Jun 2012 09:20:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237366 - head/sys/ufs/ffs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 09:20:08 -0000 Author: kib Date: Thu Jun 21 09:20:07 2012 New Revision: 237366 URL: http://svn.freebsd.org/changeset/base/237366 Log: Fix unbounded-length malloc, controlled from usermode. The added check is performed before exact size of the buffer is calculated, but the buffer cannot have size greater then the total space allocated for extended attributes. The existing check is executing with precise size, but it is too late, since buffer needs to be allocated in advance. Also, adapt to uio_resid being of ssize_t type. Use lblktosize instead of multiplying by fs block size by hand as well. Reported and tested by: pho MFC after: 1 week Modified: head/sys/ufs/ffs/ffs_vnops.c Modified: head/sys/ufs/ffs/ffs_vnops.c ============================================================================== --- head/sys/ufs/ffs/ffs_vnops.c Thu Jun 21 09:19:41 2012 (r237365) +++ head/sys/ufs/ffs/ffs_vnops.c Thu Jun 21 09:20:07 2012 (r237366) @@ -1648,7 +1648,8 @@ vop_setextattr { struct inode *ip; struct fs *fs; uint32_t ealength, ul; - int ealen, olen, eapad1, eapad2, error, i, easize; + ssize_t ealen; + int olen, eapad1, eapad2, error, i, easize; u_char *eae, *p; ip = VTOI(ap->a_vp); @@ -1667,6 +1668,10 @@ vop_setextattr { if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); + ealen = ap->a_uio->uio_resid; + if (ealen < 0 || ealen > lblktosize(fs, NXADDR)) + return (EINVAL); + error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, ap->a_cred, ap->a_td, VWRITE); if (error) { @@ -1684,7 +1689,6 @@ vop_setextattr { if (error) return (error); - ealen = ap->a_uio->uio_resid; ealength = sizeof(uint32_t) + 3 + strlen(ap->a_name); eapad1 = 8 - (ealength % 8); if (eapad1 == 8) @@ -1712,7 +1716,7 @@ vop_setextattr { easize += (ealength - ul); } } - if (easize > NXADDR * fs->fs_bsize) { + if (easize > lblktosize(fs, NXADDR)) { free(eae, M_TEMP); ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td); if (ip->i_ea_area != NULL && ip->i_ea_error == 0) From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 09:26:07 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 439B01065676; Thu, 21 Jun 2012 09:26:07 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2ED398FC12; Thu, 21 Jun 2012 09:26:07 +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 q5L9Q7TR002033; Thu, 21 Jun 2012 09:26:07 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5L9Q6nR002030; Thu, 21 Jun 2012 09:26:06 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206210926.q5L9Q6nR002030@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 21 Jun 2012 09:26:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237367 - head/sys/fs/nfsclient X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 09:26:07 -0000 Author: kib Date: Thu Jun 21 09:26:06 2012 New Revision: 237367 URL: http://svn.freebsd.org/changeset/base/237367 Log: Enable deadlock avoidance code for NFS client. MFC after: 2 weeks Modified: head/sys/fs/nfsclient/nfs_clbio.c head/sys/fs/nfsclient/nfs_clvfsops.c Modified: head/sys/fs/nfsclient/nfs_clbio.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clbio.c Thu Jun 21 09:20:07 2012 (r237366) +++ head/sys/fs/nfsclient/nfs_clbio.c Thu Jun 21 09:26:06 2012 (r237367) @@ -722,7 +722,7 @@ ncl_bioread(struct vnode *vp, struct uio }; if (n > 0) { - error = uiomove(bp->b_data + on, (int)n, uio); + error = vn_io_fault_uiomove(bp->b_data + on, (int)n, uio); } if (vp->v_type == VLNK) n = 0; @@ -1203,7 +1203,7 @@ again: } local_resid = uio->uio_resid; - error = uiomove((char *)bp->b_data + on, n, uio); + error = vn_io_fault_uiomove((char *)bp->b_data + on, n, uio); if (error != 0 && !bp_cached) { /* Modified: head/sys/fs/nfsclient/nfs_clvfsops.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clvfsops.c Thu Jun 21 09:20:07 2012 (r237366) +++ head/sys/fs/nfsclient/nfs_clvfsops.c Thu Jun 21 09:26:06 2012 (r237367) @@ -1136,7 +1136,8 @@ nfs_mount(struct mount *mp) out: if (!error) { MNT_ILOCK(mp); - mp->mnt_kern_flag |= (MNTK_MPSAFE|MNTK_LOOKUP_SHARED); + mp->mnt_kern_flag |= MNTK_MPSAFE | MNTK_LOOKUP_SHARED | + MNTK_NO_IOPF; MNT_IUNLOCK(mp); } return (error); From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 09:30:19 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 183FB106566B; Thu, 21 Jun 2012 09:30:19 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-gg0-f182.google.com (mail-gg0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id 8BBA78FC1A; Thu, 21 Jun 2012 09:30:18 +0000 (UTC) Received: by ggnm2 with SMTP id m2so308698ggn.13 for ; Thu, 21 Jun 2012 02:30:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=12ePM4cyRtxN5auL9eBXav9cj5LJhvL60wjlg9RG2rs=; b=HF0rRGFmwfA8kTZei1ozvEbhaZ37mvwVu/5o1P4tfWdtSMzdtZIioon5X8ie1fbVmm 0DfHIfG6vayoFDr7e7xwJpp0+s1dzMc0TyGcOzaDBD69BHKYkb7wqpWf3DomySyGB4gV oVeuoloiZr6Ol8XrHNDJ05jsQvbCJpT+5o8edHwYrsCA94XM6gkUUwccv4DU0wNum1VK fEt1DWobYfG6ssQIW8X0sK1jQmnskUdf96kNRY6HsdkxqBHos8El3NgIIcLTBl7NDr3Z xwuqXDt27nvQaZKj+OZ2hqRGyO2ysPD8IwuM/6MPbr9Yof6sdmLdmIvgBYnSru5Zs3A+ 3geQ== MIME-Version: 1.0 Received: by 10.50.149.134 with SMTP id ua6mr6780069igb.11.1340271017717; Thu, 21 Jun 2012 02:30:17 -0700 (PDT) Sender: pluknet@gmail.com Received: by 10.64.8.170 with HTTP; Thu, 21 Jun 2012 02:30:17 -0700 (PDT) In-Reply-To: <201206201825.q5KIPpjQ060916@svn.freebsd.org> References: <201206201825.q5KIPpjQ060916@svn.freebsd.org> Date: Thu, 21 Jun 2012 13:30:17 +0400 X-Google-Sender-Auth: fMHJ8rxJwhYRJj07F0LJqvArTxc Message-ID: From: Sergey Kandaurov To: Alexander Motin Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Oliver Fromme Subject: Re: svn commit: r237335 - head/sys/cam/scsi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 09:30:19 -0000 On 20 June 2012 22:25, Alexander Motin wrote: > Author: mav > Date: Wed Jun 20 18:25:51 2012 > New Revision: 237335 > URL: http://svn.freebsd.org/changeset/base/237335 > > Log: > =A0Check status of cam_periph_hold() inside cdclose(). =A0If cd device wa= s > =A0invalidated while open, cam_periph_hold() will return error and won't > =A0get the reference. =A0Following reference release will crash the syste= m. > > =A0Sponsored by: iXsystems, Inc. > =A0MFC after: =A0 =A03 days > > Modified: > =A0head/sys/cam/scsi/scsi_cd.c > > Modified: head/sys/cam/scsi/scsi_cd.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/cam/scsi/scsi_cd.c Wed Jun 20 18:00:26 2012 =A0 =A0 =A0 =A0(= r237334) > +++ head/sys/cam/scsi/scsi_cd.c Wed Jun 20 18:25:51 2012 =A0 =A0 =A0 =A0(= r237335) > @@ -1041,6 +1041,7 @@ cdclose(struct disk *dp) > =A0{ > =A0 =A0 =A0 =A0struct =A0cam_periph *periph; > =A0 =A0 =A0 =A0struct =A0cd_softc *softc; > + =A0 =A0 =A0 int error; > > =A0 =A0 =A0 =A0periph =3D (struct cam_periph *)dp->d_drv1; > =A0 =A0 =A0 =A0if (periph =3D=3D NULL) > @@ -1049,7 +1050,11 @@ cdclose(struct disk *dp) > =A0 =A0 =A0 =A0softc =3D (struct cd_softc *)periph->softc; > > =A0 =A0 =A0 =A0cam_periph_lock(periph); > - =A0 =A0 =A0 cam_periph_hold(periph, PRIBIO); > + =A0 =A0 =A0 if ((error =3D cam_periph_hold(periph, PRIBIO)) !=3D 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 cam_periph_unlock(periph); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 cam_periph_release(periph); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (0); > + =A0 =A0 =A0 } > > =A0 =A0 =A0 =A0CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH= , > =A0 =A0 =A0 =A0 =A0 =A0("cdclose\n")); Hi. Does it fix the reported crash with cd refcount underflow? It seems so. http://lists.freebsd.org/pipermail/freebsd-stable/2012-June/068175.html --=20 wbr, pluknet From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 09:51:51 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 41393106566B; Thu, 21 Jun 2012 09:51:51 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id 11E818FC29; Thu, 21 Jun 2012 09:51:49 +0000 (UTC) Received: by lbon10 with SMTP id n10so2339427lbo.13 for ; Thu, 21 Jun 2012 02:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=G5lQGJRTWb3baTo6RU58Pp/+W5dJ5vHccjZoucXeABI=; b=cl5phq0m5kt6rM97YGSv0ur3YNv6FsE59mvUh6a9duIH8PPiUgdyH967t924KwT+qG DcbiaGaaM5d/+Bvq4DABKUrTYpp0FaRmGM1BgQyURDYKgkoK1lsir0+rIV0P1zmL/J8P GrQOy4sa2cK+7GtSajYAtEPkLOjcebJkVOBw3Fxre48kjP+77VWxYffBlBbCiB2lGbKG 5KLBGvcxPtdiu+k0vqPuDU3j8S1fvRCKcNSk1GDnNNJ/og5ae13e+TsD1UlfISEoxcXa /9NjemziRSAVWAFwlnp8eqrYUYvMI3tYpV750zHQsFJI0OZ7q8z1CQp84m7j0P0UL+tQ TSxA== Received: by 10.112.24.194 with SMTP id w2mr11348720lbf.75.1340272308897; Thu, 21 Jun 2012 02:51:48 -0700 (PDT) Received: from mavbook2.mavhome.dp.ua (pc.mavhome.dp.ua. [212.86.226.226]) by mx.google.com with ESMTPS id p2sm18202725lbj.4.2012.06.21.02.51.43 (version=SSLv3 cipher=OTHER); Thu, 21 Jun 2012 02:51:44 -0700 (PDT) Sender: Alexander Motin Message-ID: <4FE2EEAD.3070706@FreeBSD.org> Date: Thu, 21 Jun 2012 12:51:41 +0300 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20120506 Thunderbird/12.0.1 MIME-Version: 1.0 To: Sergey Kandaurov References: <201206201825.q5KIPpjQ060916@svn.freebsd.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Oliver Fromme Subject: Re: svn commit: r237335 - head/sys/cam/scsi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 09:51:51 -0000 On 06/21/12 12:30, Sergey Kandaurov wrote: > On 20 June 2012 22:25, Alexander Motin wrote: >> Author: mav >> Date: Wed Jun 20 18:25:51 2012 >> New Revision: 237335 >> URL: http://svn.freebsd.org/changeset/base/237335 >> >> Log: >> Check status of cam_periph_hold() inside cdclose(). If cd device was >> invalidated while open, cam_periph_hold() will return error and won't >> get the reference. Following reference release will crash the system. >> >> Sponsored by: iXsystems, Inc. >> MFC after: 3 days >> >> Modified: >> head/sys/cam/scsi/scsi_cd.c >> >> Modified: head/sys/cam/scsi/scsi_cd.c >> ============================================================================== >> --- head/sys/cam/scsi/scsi_cd.c Wed Jun 20 18:00:26 2012 (r237334) >> +++ head/sys/cam/scsi/scsi_cd.c Wed Jun 20 18:25:51 2012 (r237335) >> @@ -1041,6 +1041,7 @@ cdclose(struct disk *dp) >> { >> struct cam_periph *periph; >> struct cd_softc *softc; >> + int error; >> >> periph = (struct cam_periph *)dp->d_drv1; >> if (periph == NULL) >> @@ -1049,7 +1050,11 @@ cdclose(struct disk *dp) >> softc = (struct cd_softc *)periph->softc; >> >> cam_periph_lock(periph); >> - cam_periph_hold(periph, PRIBIO); >> + if ((error = cam_periph_hold(periph, PRIBIO)) != 0) { >> + cam_periph_unlock(periph); >> + cam_periph_release(periph); >> + return (0); >> + } >> >> CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH, >> ("cdclose\n")); > > Does it fix the reported crash with cd refcount underflow? It seems so. > http://lists.freebsd.org/pipermail/freebsd-stable/2012-June/068175.html Yes, I think it should. At least diagnostics looks very alike. -- Alexander Motin From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 12:30:36 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 39491106566B; Thu, 21 Jun 2012 12:30:36 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mx1.sbone.de (mx1.sbone.de [IPv6:2a01:4f8:130:3ffc::401:25]) by mx1.freebsd.org (Postfix) with ESMTP id B5C468FC18; Thu, 21 Jun 2012 12:30:35 +0000 (UTC) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:31::2013:587]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPS id 931BB25D3A99; Thu, 21 Jun 2012 12:30:34 +0000 (UTC) Received: from content-filter.sbone.de (content-filter.sbone.de [IPv6:fde9:577b:c1a9:31::2013:2742]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id B3584BE84A9; Thu, 21 Jun 2012 12:30:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:31::2013:587]) by content-filter.sbone.de (content-filter.sbone.de [fde9:577b:c1a9:31::2013:2742]) (amavisd-new, port 10024) with ESMTP id rjsBnn-Do65y; Thu, 21 Jun 2012 12:30:32 +0000 (UTC) Received: from orange-en1.sbone.de (orange-en1.sbone.de [IPv6:fde9:577b:c1a9:31:cabc:c8ff:fecf:e8e3]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id 55117BE84A7; Thu, 21 Jun 2012 12:30:32 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: "Bjoern A. Zeeb" In-Reply-To: <201206201708.q5KH81EI056365@svn.freebsd.org> Date: Thu, 21 Jun 2012 12:30:31 +0000 Content-Transfer-Encoding: 7bit Message-Id: References: <201206201708.q5KH81EI056365@svn.freebsd.org> To: Kenneth D. Merry X-Mailer: Apple Mail (2.1084) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237328 - in head/sys/cam: . scsi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 12:30:36 -0000 On 20. Jun 2012, at 17:08 , Kenneth D. Merry wrote: > Author: ken > Date: Wed Jun 20 17:08:00 2012 > New Revision: 237328 > URL: http://svn.freebsd.org/changeset/base/237328 > > Log: > Fix several reference counting and object lifetime issues between > the pass(4) and enc(4) drivers and devfs. Just as a hint for the archives: enc(4) is completely unrelated to this commit as it's the "encapsulation device" used along with IPsec and has nothing to do with scsi_enc. -- Bjoern A. Zeeb You have to have visions! It does not matter how good you are. It matters what good you do! From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 12:51:24 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E6A34106566B; Thu, 21 Jun 2012 12:51:24 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D19DC8FC1D; Thu, 21 Jun 2012 12:51:24 +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 q5LCpOwQ013712; Thu, 21 Jun 2012 12:51:24 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5LCpOsc013710; Thu, 21 Jun 2012 12:51:24 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201206211251.q5LCpOsc013710@svn.freebsd.org> From: Michael Tuexen Date: Thu, 21 Jun 2012 12:51:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237392 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 12:51:25 -0000 Author: tuexen Date: Thu Jun 21 12:51:24 2012 New Revision: 237392 URL: http://svn.freebsd.org/changeset/base/237392 Log: Remove redundant #ifdef. Reported by gnn@. MFC after: 3 days Modified: head/sys/netinet/sctp_usrreq.c Modified: head/sys/netinet/sctp_usrreq.c ============================================================================== --- head/sys/netinet/sctp_usrreq.c Thu Jun 21 12:47:21 2012 (r237391) +++ head/sys/netinet/sctp_usrreq.c Thu Jun 21 12:51:24 2012 (r237392) @@ -6476,7 +6476,6 @@ sctp_peeraddr(struct socket *so, struct return (0); } -#ifdef INET struct pr_usrreqs sctp_usrreqs = { .pru_abort = sctp_abort, .pru_accept = sctp_accept, @@ -6499,4 +6498,3 @@ struct pr_usrreqs sctp_usrreqs = { }; #endif -#endif From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 12:52:16 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4ECEA1065674; Thu, 21 Jun 2012 12:52:16 +0000 (UTC) (envelope-from issyl0@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2F7B88FC15; Thu, 21 Jun 2012 12:52:16 +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 q5LCqGfn013787; Thu, 21 Jun 2012 12:52:16 GMT (envelope-from issyl0@svn.freebsd.org) Received: (from issyl0@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5LCqF8U013782; Thu, 21 Jun 2012 12:52:15 GMT (envelope-from issyl0@svn.freebsd.org) Message-Id: <201206211252.q5LCqF8U013782@svn.freebsd.org> From: Isabell Long Date: Thu, 21 Jun 2012 12:52:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237393 - head/lib/libc/string X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 12:52:16 -0000 Author: issyl0 (doc committer) Date: Thu Jun 21 12:52:15 2012 New Revision: 237393 URL: http://svn.freebsd.org/changeset/base/237393 Log: Add more locale-specific functions to the relevant man pages: - libc/string/strcoll.3 - libc/string/strstr.3 - libc/string/strxfrm.3 - libc/string/strcasecmp.3 Reviewed by: theraven, gabor Approved by: gabor (mentor) MFC after: 5 days Modified: head/lib/libc/string/strcasecmp.3 head/lib/libc/string/strcoll.3 head/lib/libc/string/strstr.3 head/lib/libc/string/strxfrm.3 Modified: head/lib/libc/string/strcasecmp.3 ============================================================================== --- head/lib/libc/string/strcasecmp.3 Thu Jun 21 12:51:24 2012 (r237392) +++ head/lib/libc/string/strcasecmp.3 Thu Jun 21 12:52:15 2012 (r237393) @@ -45,6 +45,12 @@ .Fn strcasecmp "const char *s1" "const char *s2" .Ft int .Fn strncasecmp "const char *s1" "const char *s2" "size_t len" +.In string.h +.In xlocale.h +.Ft int +.Fn strcasecmp_l "const char *s1" "const char *s2" "locale_t loc" +.Ft int +.Fn strncasecmp_l "const char *s1" "const char *s2" "site_t len" "locale_t loc" .Sh DESCRIPTION The .Fn strcasecmp @@ -58,16 +64,22 @@ and .Pp The .Fn strncasecmp -compares at most +function compares at most .Fa len characters. -.Sh RETURN VALUES The +.Fn strcasecmp_l +and +.Fn strncasecmp_l +functions do the same as their non-locale versions above, but take an +explicit locale rather than using the current locale. +.Sh RETURN VALUES +The functions .Fn strcasecmp and .Fn strncasecmp return an integer greater than, equal to, or less than 0, -according as +depending on whether .Fa s1 is lexicographically greater than, equal to, or less than .Fa s2 @@ -77,6 +89,11 @@ The comparison is done using unsigned ch .Sq Li \e200 is greater than .Ql \e0 . +The functions +.Fn strcasecmp_l +and +.Fn strncasecmp_l +do the same but take explicit locales. .Sh SEE ALSO .Xr bcmp 3 , .Xr memcmp 3 , Modified: head/lib/libc/string/strcoll.3 ============================================================================== --- head/lib/libc/string/strcoll.3 Thu Jun 21 12:51:24 2012 (r237392) +++ head/lib/libc/string/strcoll.3 Thu Jun 21 12:52:15 2012 (r237393) @@ -44,6 +44,8 @@ .In string.h .Ft int .Fn strcoll "const char *s1" "const char *s2" +.Ft int +.Fn strcoll_l "const char *s1" "const char *s2" "locale_t loc" .Sh DESCRIPTION The .Fn strcoll @@ -54,7 +56,7 @@ and .Fa s2 according to the current locale collation and returns an integer greater than, equal to, or less than 0, -according as +depending on whether .Fa s1 is greater than, equal to, or less than .Fa s2 . @@ -62,6 +64,9 @@ If information about the current locale the value of .Fn strcmp s1 s2 is returned. +The +.Fn strcoll_l +function uses an explicit locale argument rather than the system locale. .Sh SEE ALSO .Xr setlocale 3 , .Xr strcmp 3 , @@ -70,6 +75,9 @@ is returned. .Sh STANDARDS The .Fn strcoll -function -conforms to +function conforms to .St -isoC . +The +.Fn strcoll_l +function conforms to +.St -p1003.1-2008 . Modified: head/lib/libc/string/strstr.3 ============================================================================== --- head/lib/libc/string/strstr.3 Thu Jun 21 12:51:24 2012 (r237392) +++ head/lib/libc/string/strstr.3 Thu Jun 21 12:52:15 2012 (r237393) @@ -49,6 +49,10 @@ .Fn strcasestr "const char *big" "const char *little" .Ft char * .Fn strnstr "const char *big" "const char *little" "size_t len" +.In string.h +.In xlocale.h +.Ft char * +.Fn strcasestr_l "const char *big" "const char *little" "locale_t loc" .Sh DESCRIPTION The .Fn strstr @@ -65,6 +69,12 @@ function is similar to but ignores the case of both strings. .Pp The +.Fn strcasestr_l +function does the same as +.Fn strcasestr +but takes an explicit locale rather than using the current locale. +.Pp +The .Fn strnstr function locates the first occurrence of the null-terminated string Modified: head/lib/libc/string/strxfrm.3 ============================================================================== --- head/lib/libc/string/strxfrm.3 Thu Jun 21 12:51:24 2012 (r237392) +++ head/lib/libc/string/strxfrm.3 Thu Jun 21 12:52:15 2012 (r237393) @@ -44,6 +44,8 @@ .In string.h .Ft size_t .Fn strxfrm "char * restrict dst" "const char * restrict src" "size_t n" +.Ft size_t +.Fn strxfrm_l "char * restrict dst" "const char *restrict src" "size_t n" "locale_t loc" .Sh DESCRIPTION The .Fn strxfrm @@ -73,10 +75,16 @@ after is equal to comparing two original strings with .Fn strcoll . +.Pp +.Fn strxfrm_l +does the same, however takes an explicit locale rather than the global +locale. .Sh RETURN VALUES Upon successful completion, .Fn strxfrm -returns the length of the transformed string not including +and +.Fn strxfrm_l +return the length of the transformed string not including the terminating null character. If this value is .Fa n @@ -94,3 +102,7 @@ The function conforms to .St -isoC . +The +.Fn strxfrm_l +function conforms to +.St -p1003.1-2008 . From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 14:06:15 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 80C59106566C; Thu, 21 Jun 2012 14:06:15 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) by mx1.freebsd.org (Postfix) with ESMTP id 4296B8FC0A; Thu, 21 Jun 2012 14:06:15 +0000 (UTC) Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.5/8.14.5) with ESMTP id q5LE6973007066; Thu, 21 Jun 2012 07:06:09 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.5/8.14.5/Submit) id q5LE69qe007065; Thu, 21 Jun 2012 07:06:09 -0700 (PDT) (envelope-from sgk) Date: Thu, 21 Jun 2012 07:06:09 -0700 From: Steve Kargl To: Christian Brueffer Message-ID: <20120621140609.GA7051@troutmask.apl.washington.edu> References: <201204221818.q3MIIn4Y051313@svn.freebsd.org> <20120422184553.GA85374@troutmask.apl.washington.edu> <4FE2DF35.5040804@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4FE2DF35.5040804@FreeBSD.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r234577 - head/usr.bin/stat X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 14:06:15 -0000 On Thu, Jun 21, 2012 at 10:45:41AM +0200, Christian Brueffer wrote: > On 4/22/12 20:45 , Steve Kargl wrote: > >On Sun, Apr 22, 2012 at 06:18:49PM +0000, Christian Brueffer wrote: > >>Author: brueffer > >>Date: Sun Apr 22 18:18:49 2012 > >>New Revision: 234577 > >>URL: http://svn.freebsd.org/changeset/base/234577 > >> > >>Log: > >> Remove duplicate -l description. > >> > >> Submitted by: Rainer Hurling > >> MFC after: 1 week > > > >The patch should have also fixed the misordering > >of the -n, -qi, and -x options. > > > > Hi Steve, > > sorry for the late reply. Could you say more specifically how you > would arrange the order? From a small sampling of our manpages, it > seems we don't have "one true" style of ordering options (except from > alphabetically, see attached patch). > > Some manpages order A-Z, then a-z, while others (Apple and OpenBSD seem > to do this) order AaBb...Zz. > Upon further inspection, the order of the description of the options follows the order of the option in the SYNOPSIS. I suppose the manpage is fine. -- Steve From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 14:35:47 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 82AB310656B8; Thu, 21 Jun 2012 14:35:47 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6DEA48FC17; Thu, 21 Jun 2012 14:35:47 +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 q5LEZl2G018407; Thu, 21 Jun 2012 14:35:47 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5LEZlKS018405; Thu, 21 Jun 2012 14:35:47 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206211435.q5LEZlKS018405@svn.freebsd.org> From: Alexander Motin Date: Thu, 21 Jun 2012 14:35:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237398 - head/sys/cam X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 14:35:47 -0000 Author: mav Date: Thu Jun 21 14:35:46 2012 New Revision: 237398 URL: http://svn.freebsd.org/changeset/base/237398 Log: In camisr() clear CAM_SIM_ON_DONEQ flag after camisr_runqueue() purged SIM done queue. Clearing it before caused extra SIM queueing in some cases. It was invisible during normal operation, but during USB device unplug and respective SIM destruction it could keep pointer on SIM without having counted reference and as result crash the system by use afer free. Reported by: hselasky MFC after: 1 week Modified: head/sys/cam/cam_xpt.c Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Thu Jun 21 13:53:28 2012 (r237397) +++ head/sys/cam/cam_xpt.c Thu Jun 21 14:35:46 2012 (r237398) @@ -5005,8 +5005,8 @@ camisr(void *dummy) while ((sim = TAILQ_FIRST(&queue)) != NULL) { TAILQ_REMOVE(&queue, sim, links); CAM_SIM_LOCK(sim); - sim->flags &= ~CAM_SIM_ON_DONEQ; camisr_runqueue(&sim->sim_doneq); + sim->flags &= ~CAM_SIM_ON_DONEQ; CAM_SIM_UNLOCK(sim); } mtx_lock(&cam_simq_lock); From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 15:14:51 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CE26D106564A; Thu, 21 Jun 2012 15:14:51 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B90238FC15; Thu, 21 Jun 2012 15:14:51 +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 q5LFEpX4020274; Thu, 21 Jun 2012 15:14:51 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5LFEpIv020272; Thu, 21 Jun 2012 15:14:51 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206211514.q5LFEpIv020272@svn.freebsd.org> From: Alexander Motin Date: Thu, 21 Jun 2012 15:14:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237401 - head/sys/cam X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 15:14:51 -0000 Author: mav Date: Thu Jun 21 15:14:51 2012 New Revision: 237401 URL: http://svn.freebsd.org/changeset/base/237401 Log: Make cam_periph_hold() behavior consistent: drop taken reference and return ENXIO if periph was invalidated while we were waiting for it. MFC after: 1 week Modified: head/sys/cam/cam_periph.c Modified: head/sys/cam/cam_periph.c ============================================================================== --- head/sys/cam/cam_periph.c Thu Jun 21 14:55:35 2012 (r237400) +++ head/sys/cam/cam_periph.c Thu Jun 21 15:14:51 2012 (r237401) @@ -440,6 +440,10 @@ cam_periph_hold(struct cam_periph *perip cam_periph_release_locked(periph); return (error); } + if (periph->flags & CAM_PERIPH_INVALID) { + cam_periph_release_locked(periph); + return (ENXIO); + } } periph->flags |= CAM_PERIPH_LOCKED; From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 15:47:06 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F0BC1065676; Thu, 21 Jun 2012 15:47:06 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8991F8FC14; Thu, 21 Jun 2012 15:47:06 +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 q5LFl61J021832; Thu, 21 Jun 2012 15:47:06 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5LFl6xS021830; Thu, 21 Jun 2012 15:47:06 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201206211547.q5LFl6xS021830@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 21 Jun 2012 15:47:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237402 - head/lib/libc/net X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 15:47:06 -0000 Author: obrien Date: Thu Jun 21 15:47:06 2012 New Revision: 237402 URL: http://svn.freebsd.org/changeset/base/237402 Log: Be explicit about the dependency on nsparser.h. Modified: head/lib/libc/net/Makefile.inc Modified: head/lib/libc/net/Makefile.inc ============================================================================== --- head/lib/libc/net/Makefile.inc Thu Jun 21 15:14:51 2012 (r237401) +++ head/lib/libc/net/Makefile.inc Thu Jun 21 15:47:06 2012 (r237402) @@ -36,7 +36,7 @@ LFLAGS+=-P_nsyy CLEANFILES+=nslexer.c -nslexer.c: nslexer.l +nslexer.c: nslexer.l nsparser.h ${LEX} ${LFLAGS} -o/dev/stdout ${.IMPSRC} | \ sed -e '/YY_BUF_SIZE/s/16384/1024/' >${.TARGET} From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 16:37:37 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F120F106566B; Thu, 21 Jun 2012 16:37:36 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DC1698FC14; Thu, 21 Jun 2012 16:37: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 q5LGba4a024343; Thu, 21 Jun 2012 16:37:36 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5LGbaAN024340; Thu, 21 Jun 2012 16:37:36 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201206211637.q5LGbaAN024340@svn.freebsd.org> From: Alan Cox Date: Thu, 21 Jun 2012 16:37:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237404 - head/sys/amd64/amd64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 16:37:37 -0000 Author: alc Date: Thu Jun 21 16:37:36 2012 New Revision: 237404 URL: http://svn.freebsd.org/changeset/base/237404 Log: Update the PV stats in free_pv_entry() using atomics. After which, it is no longer necessary for free_pv_entry() to be serialized by the pvh global lock. Retire pmap_insert_entry() and pmap_remove_entry(). Once upon a time, these functions were called from multiple places within the pmap. Now, each has only one caller. Modified: head/sys/amd64/amd64/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Thu Jun 21 16:21:31 2012 (r237403) +++ head/sys/amd64/amd64/pmap.c Thu Jun 21 16:37:36 2012 (r237404) @@ -275,9 +275,6 @@ static int pmap_remove_pte(pmap_t pmap, static void pmap_remove_pt_page(pmap_t pmap, vm_page_t mpte); static void pmap_remove_page(pmap_t pmap, vm_offset_t va, pd_entry_t *pde, vm_page_t *free); -static void pmap_remove_entry(struct pmap *pmap, vm_page_t m, - vm_offset_t va); -static void pmap_insert_entry(pmap_t pmap, vm_offset_t va, vm_page_t m); static boolean_t pmap_try_insert_pv_entry(pmap_t pmap, vm_offset_t va, vm_page_t m, struct rwlock **lockp); static void pmap_update_pde(pmap_t pmap, vm_offset_t va, pd_entry_t *pde, @@ -2207,10 +2204,10 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv struct pv_chunk *pc; int idx, field, bit; - rw_assert(&pvh_global_lock, RA_WLOCKED); + rw_assert(&pvh_global_lock, RA_LOCKED); PMAP_LOCK_ASSERT(pmap, MA_OWNED); - PV_STAT(pv_entry_frees++); - PV_STAT(pv_entry_spare++); + PV_STAT(atomic_add_long(&pv_entry_frees, 1)); + PV_STAT(atomic_add_int(&pv_entry_spare, 1)); PV_STAT(atomic_subtract_long(&pv_entry_count, 1)); pc = pv_to_chunk(pv); idx = pv - &pc->pc_pventry[0]; @@ -2372,7 +2369,9 @@ pmap_pv_demote_pde(pmap_t pmap, vm_offse KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("pmap_pv_demote_pde: page %p is not managed", m)); va += PAGE_SIZE; - pmap_insert_entry(pmap, va, m); + pv = get_pv_entry(pmap, FALSE); + pv->pv_va = va; + TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_list); } while (va < va_last); } @@ -2430,36 +2429,6 @@ pmap_pvh_free(struct md_page *pvh, pmap_ free_pv_entry(pmap, pv); } -static void -pmap_remove_entry(pmap_t pmap, vm_page_t m, vm_offset_t va) -{ - struct md_page *pvh; - - rw_assert(&pvh_global_lock, RA_WLOCKED); - pmap_pvh_free(&m->md, pmap, va); - if (TAILQ_EMPTY(&m->md.pv_list) && (m->flags & PG_FICTITIOUS) == 0) { - pvh = pa_to_pvh(VM_PAGE_TO_PHYS(m)); - if (TAILQ_EMPTY(&pvh->pv_list)) - vm_page_aflag_clear(m, PGA_WRITEABLE); - } -} - -/* - * Create a pv entry for page at pa for - * (pmap, va). - */ -static void -pmap_insert_entry(pmap_t pmap, vm_offset_t va, vm_page_t m) -{ - pv_entry_t pv; - - rw_assert(&pvh_global_lock, RA_WLOCKED); - PMAP_LOCK_ASSERT(pmap, MA_OWNED); - pv = get_pv_entry(pmap, FALSE); - pv->pv_va = va; - TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_list); -} - /* * Conditionally create a pv entry. */ @@ -2711,6 +2680,7 @@ static int pmap_remove_pte(pmap_t pmap, pt_entry_t *ptq, vm_offset_t va, pd_entry_t ptepde, vm_page_t *free) { + struct md_page *pvh; pt_entry_t oldpte; vm_page_t m; @@ -2725,7 +2695,13 @@ pmap_remove_pte(pmap_t pmap, pt_entry_t vm_page_dirty(m); if (oldpte & PG_A) vm_page_aflag_set(m, PGA_REFERENCED); - pmap_remove_entry(pmap, m, va); + pmap_pvh_free(&m->md, pmap, va); + if (TAILQ_EMPTY(&m->md.pv_list) && + (m->flags & PG_FICTITIOUS) == 0) { + pvh = pa_to_pvh(VM_PAGE_TO_PHYS(m)); + if (TAILQ_EMPTY(&pvh->pv_list)) + vm_page_aflag_clear(m, PGA_WRITEABLE); + } } return (pmap_unuse_pt(pmap, va, ptepde, free)); } From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 16:37:37 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 61B78106566C; Thu, 21 Jun 2012 16:37:37 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail02.syd.optusnet.com.au (mail02.syd.optusnet.com.au [211.29.132.183]) by mx1.freebsd.org (Postfix) with ESMTP id DBA608FC12; Thu, 21 Jun 2012 16:37:36 +0000 (UTC) Received: from c122-106-171-232.carlnfd1.nsw.optusnet.com.au (c122-106-171-232.carlnfd1.nsw.optusnet.com.au [122.106.171.232]) by mail02.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q5LGbWnU006182 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 22 Jun 2012 02:37:35 +1000 Date: Fri, 22 Jun 2012 02:37:32 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Steve Kargl In-Reply-To: <20120621140609.GA7051@troutmask.apl.washington.edu> Message-ID: <20120622021805.H3133@besplex.bde.org> References: <201204221818.q3MIIn4Y051313@svn.freebsd.org> <20120422184553.GA85374@troutmask.apl.washington.edu> <4FE2DF35.5040804@FreeBSD.org> <20120621140609.GA7051@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Christian Brueffer Subject: Re: svn commit: r234577 - head/usr.bin/stat X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 16:37:37 -0000 On Thu, 21 Jun 2012, Steve Kargl wrote: > On Thu, Jun 21, 2012 at 10:45:41AM +0200, Christian Brueffer wrote: >> On 4/22/12 20:45 , Steve Kargl wrote: >>> On Sun, Apr 22, 2012 at 06:18:49PM +0000, Christian Brueffer wrote: >>>> Author: brueffer >>>> Date: Sun Apr 22 18:18:49 2012 >>>> New Revision: 234577 >>>> URL: http://svn.freebsd.org/changeset/base/234577 >>>> >>>> Log: >>>> Remove duplicate -l description. >>>> >>>> Submitted by: Rainer Hurling >>>> MFC after: 1 week >>> >>> The patch should have also fixed the misordering >>> of the -n, -qi, and -x options. >> >> sorry for the late reply. Could you say more specifically how you >> would arrange the order? From a small sampling of our manpages, it >> seems we don't have "one true" style of ordering options (except from >> alphabetically, see attached patch). >> >> Some manpages order A-Z, then a-z, while others (Apple and OpenBSD seem >> to do this) order AaBb...Zz. I think the latter is more common and correct for FreeBSD too. ps uses it. But ls uses A-Za-z0-9. > Upon further inspection, the order of the description of the > options follows the order of the option in the SYNOPSIS. I > suppose the manpage is fine. No, SYNOPSEs (and usage) normally put options with parameters last. DESCRIPTIONs of options shouldn't do that. For ls, there is only 1 option with a parameter (-D). This is sorted into A-Z in the DESCRIPTION section. For ps, there are many options with parameters. These used to be sorted after the ones without args in the SYNOPSEs, but -O and -o are now unsorted before all other options with parameters. The DESCRIPTION section in ps used to be sorted, but -c was added out of order. stat(1) has a sorted SYNOPSIS, with complications for -f that require grouping it with options that don't take pararmeters. These complications affect the DESCRIPTION section too much. Man pages like chmod(1) don't unsort the DESCRIPTION section for similar things (the SYNOPSIS says [-R [-H | -L | -P][, but the DESCRIPTION uses alphabetical ordering for -HLPR. Bruce From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 16:49:20 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC5FC106591E; Thu, 21 Jun 2012 16:49:20 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BC5508FC16; Thu, 21 Jun 2012 16:49:20 +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 q5LGnKYw024911; Thu, 21 Jun 2012 16:49:20 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5LGnKrn024904; Thu, 21 Jun 2012 16:49:20 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201206211649.q5LGnKrn024904@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Thu, 21 Jun 2012 16:49:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237406 - head/contrib/gcc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 16:49:21 -0000 Author: pfg Date: Thu Jun 21 16:49:20 2012 New Revision: 237406 URL: http://svn.freebsd.org/changeset/base/237406 Log: Bring a couple of fixes for gcc optimizations. The GCC4.3 branch contains some optimization fixes that were not considered regressions and therefore were never backported. We are bringing a couple of them that are under GPLv2 since they were made before the license switch upstream. While here, add the GCC revision numbers in the log. Discussed with: jkim MFC after: 1 week Modified: head/contrib/gcc/ChangeLog.gcc43 head/contrib/gcc/fold-const.c head/contrib/gcc/gimplify.c head/contrib/gcc/tree-ssa-ccp.c head/contrib/gcc/tree-ssa-pre.c Modified: head/contrib/gcc/ChangeLog.gcc43 ============================================================================== --- head/contrib/gcc/ChangeLog.gcc43 Thu Jun 21 16:48:56 2012 (r237405) +++ head/contrib/gcc/ChangeLog.gcc43 Thu Jun 21 16:49:20 2012 (r237406) @@ -5,6 +5,18 @@ with SSE3 instruction set support. * doc/invoke.texi: Likewise. +2007-04-12 Richard Guenther (r123736) + + PR tree-optimization/24689 + PR tree-optimization/31307 + * fold-const.c (operand_equal_p): Compare INTEGER_CST array + indices by value. + * gimplify.c (canonicalize_addr_expr): To be consistent with + gimplify_compound_lval only set operands two and three of + ARRAY_REFs if they are not gimple_min_invariant. This makes + it never at this place. + * tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise. + 2007-04-07 H.J. Lu (r123639) * config/i386/i386.c (ix86_handle_option): Handle SSSE3. @@ -96,7 +108,7 @@ * doc/invoke.texi: Add entry about geode processor. -2006-10-24 Richard Guenther +2006-10-24 Richard Guenther (r118001) PR middle-end/28796 * builtins.c (fold_builtin_classify): Use HONOR_INFINITIES @@ -170,7 +182,13 @@ * doc/invoke.texi: Document -mssse3/-mno-ssse3 switches. -2006-10-21 Richard Guenther +2006-10-21 Richard Guenther (r117932) + + PR tree-optimization/3511 + * tree-ssa-pre.c (phi_translate): Fold CALL_EXPRs that + got new invariant arguments during PHI translation. + +2006-10-21 Richard Guenther (r117929) * builtins.c (fold_builtin_classify): Fix typo. Modified: head/contrib/gcc/fold-const.c ============================================================================== --- head/contrib/gcc/fold-const.c Thu Jun 21 16:48:56 2012 (r237405) +++ head/contrib/gcc/fold-const.c Thu Jun 21 16:49:20 2012 (r237406) @@ -2802,9 +2802,13 @@ operand_equal_p (tree arg0, tree arg1, u case ARRAY_REF: case ARRAY_RANGE_REF: - /* Operands 2 and 3 may be null. */ + /* Operands 2 and 3 may be null. + Compare the array index by value if it is constant first as we + may have different types but same value here. */ return (OP_SAME (0) - && OP_SAME (1) + && (tree_int_cst_equal (TREE_OPERAND (arg0, 1), + TREE_OPERAND (arg1, 1)) + || OP_SAME (1)) && OP_SAME_WITH_NULL (2) && OP_SAME_WITH_NULL (3)); Modified: head/contrib/gcc/gimplify.c ============================================================================== --- head/contrib/gcc/gimplify.c Thu Jun 21 16:48:56 2012 (r237405) +++ head/contrib/gcc/gimplify.c Thu Jun 21 16:49:20 2012 (r237406) @@ -1600,9 +1600,7 @@ canonicalize_addr_expr (tree *expr_p) /* All checks succeeded. Build a new node to merge the cast. */ *expr_p = build4 (ARRAY_REF, dctype, obj_expr, TYPE_MIN_VALUE (TYPE_DOMAIN (datype)), - TYPE_MIN_VALUE (TYPE_DOMAIN (datype)), - size_binop (EXACT_DIV_EXPR, TYPE_SIZE_UNIT (dctype), - size_int (TYPE_ALIGN_UNIT (dctype)))); + NULL_TREE, NULL_TREE); *expr_p = build1 (ADDR_EXPR, ctype, *expr_p); } Modified: head/contrib/gcc/tree-ssa-ccp.c ============================================================================== --- head/contrib/gcc/tree-ssa-ccp.c Thu Jun 21 16:48:56 2012 (r237405) +++ head/contrib/gcc/tree-ssa-ccp.c Thu Jun 21 16:49:20 2012 (r237406) @@ -1621,9 +1621,7 @@ maybe_fold_offset_to_array_ref (tree bas if (!integer_zerop (elt_offset)) idx = int_const_binop (PLUS_EXPR, idx, elt_offset, 0); - return build4 (ARRAY_REF, orig_type, base, idx, min_idx, - size_int (tree_low_cst (elt_size, 1) - / (TYPE_ALIGN_UNIT (elt_type)))); + return build4 (ARRAY_REF, orig_type, base, idx, NULL_TREE, NULL_TREE); } Modified: head/contrib/gcc/tree-ssa-pre.c ============================================================================== --- head/contrib/gcc/tree-ssa-pre.c Thu Jun 21 16:48:56 2012 (r237405) +++ head/contrib/gcc/tree-ssa-pre.c Thu Jun 21 16:49:20 2012 (r237406) @@ -1076,6 +1076,7 @@ phi_translate (tree expr, value_set_t se tree newexpr; tree vh = get_value_handle (expr); bool listchanged = false; + bool invariantarg = false; VEC (tree, gc) *vuses = VALUE_HANDLE_VUSES (vh); VEC (tree, gc) *tvuses; @@ -1134,10 +1135,26 @@ phi_translate (tree expr, value_set_t se if (newval != oldval) { listchanged = true; + invariantarg |= is_gimple_min_invariant (newval); TREE_VALUE (newwalker) = get_value_handle (newval); } } } + + /* In case of new invariant args we might try to fold the call + again. */ + if (invariantarg) + { + tree tmp = fold_ternary (CALL_EXPR, TREE_TYPE (expr), + newop0, newarglist, newop2); + if (tmp) + { + STRIP_TYPE_NOPS (tmp); + if (is_gimple_min_invariant (tmp)) + return tmp; + } + } + if (listchanged) vn_lookup_or_add (newarglist, NULL); From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 17:30:38 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BC791106567D; Thu, 21 Jun 2012 17:30:38 +0000 (UTC) (envelope-from zeising@daemonic.se) Received: from mail.lysator.liu.se (mail.lysator.liu.se [IPv6:2001:6b0:17:f0a0::3]) by mx1.freebsd.org (Postfix) with ESMTP id 2A7468FC17; Thu, 21 Jun 2012 17:30:38 +0000 (UTC) Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 6051040005; Thu, 21 Jun 2012 19:30:37 +0200 (CEST) Received: by mail.lysator.liu.se (Postfix, from userid 1004) id 4FBE240007; Thu, 21 Jun 2012 19:30:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on bernadotte.lysator.liu.se X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.3.1 X-Spam-Score: 0.0 Received: from mx.daemonic.se (mx.daemonic.se [IPv6:2001:470:dca9:0:1::3]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id 90E5F40005; Thu, 21 Jun 2012 19:30:36 +0200 (CEST) Received: from mailscanner.daemonic.se (mailscanner.daemonic.se [IPv6:2001:470:dca9:0:1::6]) by mx.daemonic.se (Postfix) with ESMTPS id 3WJ90j48smz8ggx; Thu, 21 Jun 2012 19:30:29 +0200 (CEST) X-Virus-Scanned: amavisd-new at daemonic.se Received: from mx.daemonic.se ([10.1.0.3]) (using TLS with cipher CAMELLIA256-SHA) by mailscanner.daemonic.se (mailscanner.daemonic.se [10.1.0.6]) (amavisd-new, port 10025) with ESMTPS id 4xGcQtFjUFBn; Thu, 21 Jun 2012 19:30:26 +0200 (CEST) Received: from mail.daemonic.se (mail.daemonic.se [IPv6:2001:470:dca9:0:1::4]) by mx.daemonic.se (Postfix) with ESMTPS id 3WJ90f4GCmz8ggv; Thu, 21 Jun 2012 19:30:26 +0200 (CEST) Received: from tifa.daemonic.se (tifa.daemonic.se [10.32.0.6]) by mail.daemonic.se (Postfix) with ESMTPSA id 3WJ90f3gZdz9Ctq; Thu, 21 Jun 2012 19:30:26 +0200 (CEST) Received: from tifa.daemonic.se (localhost [IPv6:::1]) by tifa.daemonic.se (Postfix) with ESMTP id 5D23E22AC3; Thu, 21 Jun 2012 19:30:18 +0200 (CEST) Message-ID: <4FE35A2A.3030408@daemonic.se> Date: Thu, 21 Jun 2012 19:30:18 +0200 From: Niclas Zeising User-Agent: Mutt/1.5.21 MIME-Version: 1.0 To: "Pedro F. Giffuni" References: <201206211649.q5LGnKrn024904@svn.freebsd.org> In-Reply-To: <201206211649.q5LGnKrn024904@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237406 - head/contrib/gcc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 17:30:38 -0000 On 06/21/12 18:49, Pedro F. Giffuni wrote: > Author: pfg > Date: Thu Jun 21 16:49:20 2012 > New Revision: 237406 > URL: http://svn.freebsd.org/changeset/base/237406 > > Log: > Bring a couple of fixes for gcc optimizations. > > The GCC4.3 branch contains some optimization fixes > that were not considered regressions and therefore > were never backported. We are bringing a couple of > them that are under GPLv2 since they were made > before the license switch upstream. > > While here, add the GCC revision numbers in the > log. > > Discussed with: jkim > MFC after: 1 week > > Modified: > head/contrib/gcc/ChangeLog.gcc43 > head/contrib/gcc/fold-const.c > head/contrib/gcc/gimplify.c > head/contrib/gcc/tree-ssa-ccp.c > head/contrib/gcc/tree-ssa-pre.c > > Modified: head/contrib/gcc/ChangeLog.gcc43 > ============================================================================== > --- head/contrib/gcc/ChangeLog.gcc43 Thu Jun 21 16:48:56 2012 (r237405) > +++ head/contrib/gcc/ChangeLog.gcc43 Thu Jun 21 16:49:20 2012 (r237406) > @@ -5,6 +5,18 @@ > with SSE3 instruction set support. > * doc/invoke.texi: Likewise. > > +2007-04-12 Richard Guenther (r123736) > + > + PR tree-optimization/24689 > + PR tree-optimization/31307 > + * fold-const.c (operand_equal_p): Compare INTEGER_CST array > + indices by value. > + * gimplify.c (canonicalize_addr_expr): To be consistent with > + gimplify_compound_lval only set operands two and three of > + ARRAY_REFs if they are not gimple_min_invariant. This makes > + it never at this place. > + * tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise. > + > 2007-04-07 H.J. Lu (r123639) > > * config/i386/i386.c (ix86_handle_option): Handle SSSE3. > @@ -96,7 +108,7 @@ > > * doc/invoke.texi: Add entry about geode processor. > > -2006-10-24 Richard Guenther > +2006-10-24 Richard Guenther (r118001) > > PR middle-end/28796 > * builtins.c (fold_builtin_classify): Use HONOR_INFINITIES > @@ -170,7 +182,13 @@ > > * doc/invoke.texi: Document -mssse3/-mno-ssse3 switches. > > -2006-10-21 Richard Guenther > +2006-10-21 Richard Guenther (r117932) > + > + PR tree-optimization/3511 > + * tree-ssa-pre.c (phi_translate): Fold CALL_EXPRs that > + got new invariant arguments during PHI translation. > + > +2006-10-21 Richard Guenther (r117929) > > * builtins.c (fold_builtin_classify): Fix typo. > > > Modified: head/contrib/gcc/fold-const.c > ============================================================================== > --- head/contrib/gcc/fold-const.c Thu Jun 21 16:48:56 2012 (r237405) > +++ head/contrib/gcc/fold-const.c Thu Jun 21 16:49:20 2012 (r237406) > @@ -2802,9 +2802,13 @@ operand_equal_p (tree arg0, tree arg1, u > > case ARRAY_REF: > case ARRAY_RANGE_REF: > - /* Operands 2 and 3 may be null. */ > + /* Operands 2 and 3 may be null. > + Compare the array index by value if it is constant first as we > + may have different types but same value here. */ > return (OP_SAME (0) > - && OP_SAME (1) > + && (tree_int_cst_equal (TREE_OPERAND (arg0, 1), > + TREE_OPERAND (arg1, 1)) > + || OP_SAME (1)) > && OP_SAME_WITH_NULL (2) > && OP_SAME_WITH_NULL (3)); > > > Modified: head/contrib/gcc/gimplify.c > ============================================================================== > --- head/contrib/gcc/gimplify.c Thu Jun 21 16:48:56 2012 (r237405) > +++ head/contrib/gcc/gimplify.c Thu Jun 21 16:49:20 2012 (r237406) > @@ -1600,9 +1600,7 @@ canonicalize_addr_expr (tree *expr_p) > /* All checks succeeded. Build a new node to merge the cast. */ > *expr_p = build4 (ARRAY_REF, dctype, obj_expr, > TYPE_MIN_VALUE (TYPE_DOMAIN (datype)), > - TYPE_MIN_VALUE (TYPE_DOMAIN (datype)), > - size_binop (EXACT_DIV_EXPR, TYPE_SIZE_UNIT (dctype), > - size_int (TYPE_ALIGN_UNIT (dctype)))); > + NULL_TREE, NULL_TREE); > *expr_p = build1 (ADDR_EXPR, ctype, *expr_p); > } > > > Modified: head/contrib/gcc/tree-ssa-ccp.c > ============================================================================== > --- head/contrib/gcc/tree-ssa-ccp.c Thu Jun 21 16:48:56 2012 (r237405) > +++ head/contrib/gcc/tree-ssa-ccp.c Thu Jun 21 16:49:20 2012 (r237406) > @@ -1621,9 +1621,7 @@ maybe_fold_offset_to_array_ref (tree bas > if (!integer_zerop (elt_offset)) > idx = int_const_binop (PLUS_EXPR, idx, elt_offset, 0); > > - return build4 (ARRAY_REF, orig_type, base, idx, min_idx, > - size_int (tree_low_cst (elt_size, 1) > - / (TYPE_ALIGN_UNIT (elt_type)))); > + return build4 (ARRAY_REF, orig_type, base, idx, NULL_TREE, NULL_TREE); > } > > > > Modified: head/contrib/gcc/tree-ssa-pre.c > ============================================================================== > --- head/contrib/gcc/tree-ssa-pre.c Thu Jun 21 16:48:56 2012 (r237405) > +++ head/contrib/gcc/tree-ssa-pre.c Thu Jun 21 16:49:20 2012 (r237406) > @@ -1076,6 +1076,7 @@ phi_translate (tree expr, value_set_t se > tree newexpr; > tree vh = get_value_handle (expr); > bool listchanged = false; > + bool invariantarg = false; > VEC (tree, gc) *vuses = VALUE_HANDLE_VUSES (vh); > VEC (tree, gc) *tvuses; > > @@ -1134,10 +1135,26 @@ phi_translate (tree expr, value_set_t se > if (newval != oldval) > { > listchanged = true; > + invariantarg |= is_gimple_min_invariant (newval); > TREE_VALUE (newwalker) = get_value_handle (newval); > } > } > } > + > + /* In case of new invariant args we might try to fold the call > + again. */ > + if (invariantarg) > + { > + tree tmp = fold_ternary (CALL_EXPR, TREE_TYPE (expr), > + newop0, newarglist, newop2); > + if (tmp) > + { > + STRIP_TYPE_NOPS (tmp); > + if (is_gimple_min_invariant (tmp)) > + return tmp; > + } > + } > + > if (listchanged) > vn_lookup_or_add (newarglist, NULL); > Could this fix the issues with mozilla ports not compiling on -O2? I will test later, but I'm just checking if you have any insight... Regards! -- Niclas Zeising From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 18:28:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DA7B21065792; Thu, 21 Jun 2012 18:28:48 +0000 (UTC) (envelope-from issyl0@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C5B778FC18; Thu, 21 Jun 2012 18:28:48 +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 q5LISm5J029244; Thu, 21 Jun 2012 18:28:48 GMT (envelope-from issyl0@svn.freebsd.org) Received: (from issyl0@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5LISmkZ029242; Thu, 21 Jun 2012 18:28:48 GMT (envelope-from issyl0@svn.freebsd.org) Message-Id: <201206211828.q5LISmkZ029242@svn.freebsd.org> From: Isabell Long Date: Thu, 21 Jun 2012 18:28:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237409 - head/lib/libc/string X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 18:28:49 -0000 Author: issyl0 (doc committer) Date: Thu Jun 21 18:28:48 2012 New Revision: 237409 URL: http://svn.freebsd.org/changeset/base/237409 Log: Add the functions documented in the man pages in commit 237393 to the relevant Makefile. Reminded by: gavin Approved by: gabor (mentor) MFC after: 5 days Modified: head/lib/libc/string/Makefile.inc Modified: head/lib/libc/string/Makefile.inc ============================================================================== --- head/lib/libc/string/Makefile.inc Thu Jun 21 18:22:50 2012 (r237408) +++ head/lib/libc/string/Makefile.inc Thu Jun 21 18:28:48 2012 (r237409) @@ -42,10 +42,13 @@ MLINKS+=ffs.3 ffsl.3 \ ffs.3 flsll.3 MLINKS+=index.3 rindex.3 MLINKS+=memchr.3 memrchr.3 -MLINKS+=strcasecmp.3 strncasecmp.3 +MLINKS+=strcasecmp.3 strncasecmp.3 \ + strcasecmp.3 strcasecmp_l.3 \ + strcasecmp.3 strncasecmp_l.3 MLINKS+=strcat.3 strncat.3 MLINKS+=strchr.3 strrchr.3 MLINKS+=strcmp.3 strncmp.3 +MLINKS+=strcoll.3 strcoll_l.3 MLINKS+=strcpy.3 stpcpy.3 \ strcpy.3 stpncpy.3 \ strcpy.3 strncpy.3 @@ -57,8 +60,10 @@ MLINKS+=strerror.3 perror.3 \ MLINKS+=strlcpy.3 strlcat.3 MLINKS+=strlen.3 strnlen.3 MLINKS+=strstr.3 strcasestr.3 \ - strstr.3 strnstr.3 + strstr.3 strnstr.3 \ + strstr.3 strcasestr_l.3 MLINKS+=strtok.3 strtok_r.3 +MLINKS+=strxfrm.3 strxfrm_l.3 MLINKS+=wmemchr.3 wcpcpy.3 \ wmemchr.3 wcpncpy.3 \ wmemchr.3 wcscasecmp.3 \ From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 18:31:37 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7DFA1065673 for ; Thu, 21 Jun 2012 18:31:37 +0000 (UTC) (envelope-from pfg@freebsd.org) Received: from nm16-vm2.bullet.mail.ne1.yahoo.com (nm16-vm2.bullet.mail.ne1.yahoo.com [98.138.91.92]) by mx1.freebsd.org (Postfix) with SMTP id 443758FC12 for ; Thu, 21 Jun 2012 18:31:37 +0000 (UTC) Received: from [98.138.90.51] by nm16.bullet.mail.ne1.yahoo.com with NNFMP; 21 Jun 2012 18:28:26 -0000 Received: from [98.138.89.252] by tm4.bullet.mail.ne1.yahoo.com with NNFMP; 21 Jun 2012 18:28:26 -0000 Received: from [127.0.0.1] by omp1044.mail.ne1.yahoo.com with NNFMP; 21 Jun 2012 18:28:26 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 306326.24309.bm@omp1044.mail.ne1.yahoo.com Received: (qmail 16694 invoked by uid 60001); 21 Jun 2012 18:28:25 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1340303305; bh=dObkysRk/SmHjn82ZGuXKgJHS1Nl7JtC/s8tO9CFbIQ=; h=X-YMail-OSG:Received:X-RocketYMMF:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=eja3ITSrU/syQqB9xEz7xw/W5w4DgXUUTq4s+mCCTUzzbRgLlitiRfaJre1vpKtIvKkNkl1PNyTInbcPjsUvAySW35vXwt8bZEvqwaW64VDZXCWY2AWAx5qsr1I+VCxdSjU4Q8y8ttWiUJ8/EI/FGqc9GrrHe29CF7cU/bUs0WQ= X-YMail-OSG: NirYMaQVM1n0N3qzRhcmubxgXi4li_8lfczU_AUjH0P1H.e WV0rwu1vrRbUO1LmjFmqPY.3.rTmvhEieQXilLMQmSPkesAJHcojsfeEq9wm vwNkTjapR7ar8KcPiYS_PZr2nE3qY_AOHR_iITeqmv9Dh0kARBA32HP7q0Z5 Oe67KW8Ft0kAA7ftWplx0zoVuK3tz7xWTlcfiDDSuE4aLnftc6sdqrap096L e2snArIPu.9RWRqDukIImpoAbxnkgiy3LXtA0hR80m5jShAH2dLwXMPxLVrm oVMqc1JL1.l65wEFOtEtYuXRVnTn6zlAge1VqWgGN.PZV1EQ4uTxxfZmfPZl n6C8y5U78kakFGP9Gg7Fi0G6PSY5JWrKZK13.41dwmdU2L91vB6.L4I8ZqVv fQyHiPY8bGA_t_tE8lwgkxD8.RdGxhqgpoMeb5p3kH_pXQv8qDmHpgGS24rB FLq6bSUAWp_aMBLu.r9dxTDlqOfXpZQFtpFUfa6jiM0aMmzLq0XEPbLwYQ2f ZQw3q0RBK5I9lWy_rzXWltbXPyJ.amsf1Ug-- Received: from [200.118.157.7] by web113501.mail.gq1.yahoo.com via HTTP; Thu, 21 Jun 2012 11:28:25 PDT X-RocketYMMF: giffunip X-Mailer: YahooMailClassic/15.0.8 YahooMailWebService/0.8.118.349524 Message-ID: <1340303305.15705.YahooMailClassic@web113501.mail.gq1.yahoo.com> Date: Thu, 21 Jun 2012 11:28:25 -0700 (PDT) From: Pedro Giffuni To: Niclas Zeising In-Reply-To: <4FE35A2A.3030408@daemonic.se> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237406 - head/contrib/gcc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: pfg@freebsd.org List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 18:31:37 -0000 Hi Niclas;=0A=0A--- Gio 21/6/12, Niclas Zeising ha sc= ritto:=0A=0A> On 06/21/12 18:49, Pedro F. Giffuni wrote:=0A> > Author: pfg= =0A> > Date: Thu Jun 21 16:49:20 2012=0A> > New Revision: 237406=0A> > URL:= http://svn.freebsd.org/changeset/base/237406=0A> >=0A> > Log:=0A> >=A0 =A0= Bring a couple of fixes for gcc=0A> optimizations.=0A> >=0A> >=A0 =A0 The = GCC4.3 branch contains some optimization fixes=0A> >=A0 =A0 that were not c= onsidered regressions and therefore=0A> >=A0 =A0 were never backported. We = are bringing a couple of=0A> >=A0 =A0 them that are under GPLv2 since they = were made=0A> >=A0 =A0 before the license switch upstream.=0A> >=0A...=0A> = =0A> Could this fix the issues with mozilla ports not compiling=0A> on -O2?= =0A=0A=0AI don't think so :(.=0A=0AThese are issues that would generate non= -optimal code=0Abut will not fix anything that doesn't compile.=0A=0ASorry,= =0A=0APedro.=0A From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 18:50:26 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 165191065672; Thu, 21 Jun 2012 18:50:26 +0000 (UTC) (envelope-from zeising@daemonic.se) Received: from mail.lysator.liu.se (mail.lysator.liu.se [IPv6:2001:6b0:17:f0a0::3]) by mx1.freebsd.org (Postfix) with ESMTP id 8290E8FC15; Thu, 21 Jun 2012 18:50:25 +0000 (UTC) Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id BA7CA40005; Thu, 21 Jun 2012 20:50:24 +0200 (CEST) Received: by mail.lysator.liu.se (Postfix, from userid 1004) id AF8D440007; Thu, 21 Jun 2012 20:50:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on bernadotte.lysator.liu.se X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.3.1 X-Spam-Score: 0.0 Received: from mx.daemonic.se (mx.daemonic.se [IPv6:2001:470:dca9:0:1::3]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id 9810D40005; Thu, 21 Jun 2012 20:50:22 +0200 (CEST) Received: from mailscanner.daemonic.se (mailscanner.daemonic.se [IPv6:2001:470:dca9:0:1::6]) by mx.daemonic.se (Postfix) with ESMTPS id 3WJBms6ZW2z8ggv; Thu, 21 Jun 2012 20:50:21 +0200 (CEST) X-Virus-Scanned: amavisd-new at daemonic.se Received: from mx.daemonic.se ([IPv6:2001:470:dca9:0:1::3]) (using TLS with cipher CAMELLIA256-SHA) by mailscanner.daemonic.se (mailscanner.daemonic.se [2001:470:dca9:0:1::6]) (amavisd-new, port 10025) with ESMTPS id BRDqmyaz0tFD; Thu, 21 Jun 2012 20:50:19 +0200 (CEST) Received: from mail.daemonic.se (mail.daemonic.se [IPv6:2001:470:dca9:0:1::4]) by mx.daemonic.se (Postfix) with ESMTPS id 3WJBmq2ZjWz8gh0; Thu, 21 Jun 2012 20:50:19 +0200 (CEST) Received: from tifa.daemonic.se (tifa.daemonic.se [10.32.0.6]) by mail.daemonic.se (Postfix) with ESMTPSA id 3WJBmq2Gh5z9CvV; Thu, 21 Jun 2012 20:50:19 +0200 (CEST) Received: from tifa.daemonic.se (localhost [IPv6:::1]) by tifa.daemonic.se (Postfix) with ESMTP id 1DA2922AC3; Thu, 21 Jun 2012 20:50:19 +0200 (CEST) Message-ID: <4FE36CEA.4050104@daemonic.se> Date: Thu, 21 Jun 2012 20:50:18 +0200 From: Niclas Zeising User-Agent: Mutt/1.5.21 MIME-Version: 1.0 To: pfg@freebsd.org References: <1340303305.15705.YahooMailClassic@web113501.mail.gq1.yahoo.com> In-Reply-To: <1340303305.15705.YahooMailClassic@web113501.mail.gq1.yahoo.com> Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237406 - head/contrib/gcc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 18:50:26 -0000 On 06/21/12 20:28, Pedro Giffuni wrote: > Hi Niclas; > > --- Gio 21/6/12, Niclas Zeising ha scritto: > >> On 06/21/12 18:49, Pedro F. Giffuni wrote: >>> Author: pfg >>> Date: Thu Jun 21 16:49:20 2012 >>> New Revision: 237406 >>> URL: http://svn.freebsd.org/changeset/base/237406 >>> >>> Log: >>> Bring a couple of fixes for gcc >> optimizations. >>> >>> The GCC4.3 branch contains some optimization fixes >>> that were not considered regressions and therefore >>> were never backported. We are bringing a couple of >>> them that are under GPLv2 since they were made >>> before the license switch upstream. >>> > ... >> >> Could this fix the issues with mozilla ports not compiling >> on -O2? > > > I don't think so :(. > > These are issues that would generate non-optimal code > but will not fix anything that doesn't compile. > > Sorry, > > Pedro. > Ok. Something in g++ between FreeBSD 8 and current has broken something in the compile of mozilla related stuff on -O2. I haven't been able to figure out exactly which commit though. Regards! -- Niclas Zeising From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 21:47:09 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 014631065670; Thu, 21 Jun 2012 21:47:09 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DCEDC8FC14; Thu, 21 Jun 2012 21:47:08 +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 q5LLl88M037970; Thu, 21 Jun 2012 21:47:08 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5LLl8Qk037955; Thu, 21 Jun 2012 21:47:08 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201206212147.q5LLl8Qk037955@svn.freebsd.org> From: Xin LI Date: Thu, 21 Jun 2012 21:47:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237410 - in head: lib/libstand lib/libz lib/libz/contrib lib/libz/contrib/asm686 lib/libz/contrib/gcc_gvmat64 lib/libz/doc lib/libz/test sys/boot/userboot/libstand usr.bin/minigzip X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 21:47:09 -0000 Author: delphij Date: Thu Jun 21 21:47:08 2012 New Revision: 237410 URL: http://svn.freebsd.org/changeset/base/237410 Log: MFV: Update zlib to 1.2.7. (x86 assembler optimization disabled for now because it requires the new .cfi_* directives that is not supported by base system binutils). MFC after: 1 week Added: head/lib/libz/test/ - copied from r237252, vendor/libz/dist/test/ Deleted: head/lib/libz/example.c head/lib/libz/minigzip.c Modified: head/lib/libstand/Makefile head/lib/libz/ChangeLog head/lib/libz/FAQ head/lib/libz/FREEBSD-upgrade (contents, props changed) head/lib/libz/Makefile (contents, props changed) head/lib/libz/README head/lib/libz/Symbol.map (contents, props changed) head/lib/libz/Versions.def (contents, props changed) head/lib/libz/adler32.c head/lib/libz/contrib/asm686/match.S (contents, props changed) head/lib/libz/crc32.c head/lib/libz/crc32.h head/lib/libz/deflate.c head/lib/libz/deflate.h head/lib/libz/doc/algorithm.txt (contents, props changed) head/lib/libz/gzguts.h (contents, props changed) head/lib/libz/gzlib.c head/lib/libz/gzread.c head/lib/libz/gzwrite.c head/lib/libz/infback.c head/lib/libz/inffixed.h head/lib/libz/inflate.c head/lib/libz/inftrees.c head/lib/libz/trees.c head/lib/libz/zconf.h head/lib/libz/zlib.3 head/lib/libz/zlib.h head/lib/libz/zopen.c (contents, props changed) head/lib/libz/zutil.c head/lib/libz/zutil.h head/sys/boot/userboot/libstand/Makefile head/usr.bin/minigzip/Makefile Directory Properties: head/lib/libz/ (props changed) head/lib/libz/contrib/ (props changed) head/lib/libz/contrib/README.contrib (props changed) head/lib/libz/contrib/asm686/ (props changed) head/lib/libz/contrib/asm686/README.686 (props changed) head/lib/libz/contrib/gcc_gvmat64/ (props changed) head/lib/libz/contrib/gcc_gvmat64/gvmat64.S (props changed) head/lib/libz/doc/ (props changed) head/lib/libz/doc/rfc1950.txt (props changed) head/lib/libz/doc/rfc1951.txt (props changed) head/lib/libz/doc/rfc1952.txt (props changed) head/lib/libz/doc/txtvsbin.txt (props changed) head/lib/libz/gzclose.c (props changed) head/lib/libz/test/example.c (props changed) head/lib/libz/test/infcover.c (props changed) head/lib/libz/test/minigzip.c (props changed) Modified: head/lib/libstand/Makefile ============================================================================== --- head/lib/libstand/Makefile Thu Jun 21 18:28:48 2012 (r237409) +++ head/lib/libstand/Makefile Thu Jun 21 21:47:08 2012 (r237410) @@ -38,7 +38,7 @@ CFLAGS+= -msoft-float -D_STANDALONE .endif # standalone components and stuff we have modified locally -SRCS+= zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \ +SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \ globals.c pager.c printf.c strdup.c strerror.c strtol.c random.c \ sbrk.c twiddle.c zalloc.c zalloc_malloc.c @@ -118,23 +118,29 @@ libstand_bzlib_private.h: bzlib_private. # decompression functionality from libz .PATH: ${.CURDIR}/../libz CFLAGS+=-DHAVE_MEMCPY -I${.CURDIR}/../libz -SRCS+= adler32.c crc32.c libstand_zutil.h +SRCS+= adler32.c crc32.c libstand_zutil.h libstand_gzguts.h .for file in infback.c inffast.c inflate.c inftrees.c zutil.c SRCS+= _${file} CLEANFILES+= _${file} _${file}: ${file} - sed "s|zutil\.h|libstand_zutil.h|" ${.ALLSRC} > ${.TARGET} + sed -e "s|zutil\.h|libstand_zutil.h|" \ + -e "s|gzguts\.h|libstand_gzguts.h|" \ + ${.ALLSRC} > ${.TARGET} .endfor # depend on stand.h being able to be included multiple times -CLEANFILES+= libstand_zutil.h -libstand_zutil.h: zutil.h - sed -e 's||"stand.h"|' \ +.for file in zutil.h gzguts.h +CLEANFILES+= libstand_${file} +libstand_${file}: ${file} + sed -e 's||"stand.h"|' \ + -e 's||"stand.h"|' \ -e 's||"stand.h"|' \ + -e 's||"stand.h"|' \ -e 's||"stand.h"|' \ ${.ALLSRC} > ${.TARGET} +.endfor # io routines SRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \ Modified: head/lib/libz/ChangeLog ============================================================================== --- head/lib/libz/ChangeLog Thu Jun 21 18:28:48 2012 (r237409) +++ head/lib/libz/ChangeLog Thu Jun 21 21:47:08 2012 (r237410) @@ -1,12 +1,213 @@ ChangeLog file for zlib +Changes in 1.2.7 (2 May 2012) +- Replace use of memmove() with a simple copy for portability +- Test for existence of strerror +- Restore gzgetc_ for backward compatibility with 1.2.6 +- Fix build with non-GNU make on Solaris +- Require gcc 4.0 or later on Mac OS X to use the hidden attribute +- Include unistd.h for Watcom C +- Use __WATCOMC__ instead of __WATCOM__ +- Do not use the visibility attribute if NO_VIZ defined +- Improve the detection of no hidden visibility attribute +- Avoid using __int64 for gcc or solo compilation +- Cast to char * in gzprintf to avoid warnings [Zinser] +- Fix make_vms.com for VAX [Zinser] +- Don't use library or built-in byte swaps +- Simplify test and use of gcc hidden attribute +- Fix bug in gzclose_w() when gzwrite() fails to allocate memory +- Add "x" (O_EXCL) and "e" (O_CLOEXEC) modes support to gzopen() +- Fix bug in test/minigzip.c for configure --solo +- Fix contrib/vstudio project link errors [Mohanathas] +- Add ability to choose the builder in make_vms.com [Schweda] +- Add DESTDIR support to mingw32 win32/Makefile.gcc +- Fix comments in win32/Makefile.gcc for proper usage +- Allow overriding the default install locations for cmake +- Generate and install the pkg-config file with cmake +- Build both a static and a shared version of zlib with cmake +- Include version symbols for cmake builds +- If using cmake with MSVC, add the source directory to the includes +- Remove unneeded EXTRA_CFLAGS from win32/Makefile.gcc [Truta] +- Move obsolete emx makefile to old [Truta] +- Allow the use of -Wundef when compiling or using zlib +- Avoid the use of the -u option with mktemp +- Improve inflate() documentation on the use of Z_FINISH +- Recognize clang as gcc +- Add gzopen_w() in Windows for wide character path names +- Rename zconf.h in CMakeLists.txt to move it out of the way +- Add source directory in CMakeLists.txt for building examples +- Look in build directory for zlib.pc in CMakeLists.txt +- Remove gzflags from zlibvc.def in vc9 and vc10 +- Fix contrib/minizip compilation in the MinGW environment +- Update ./configure for Solaris, support --64 [Mooney] +- Remove -R. from Solaris shared build (possible security issue) +- Avoid race condition for parallel make (-j) running example +- Fix type mismatch between get_crc_table() and crc_table +- Fix parsing of version with "-" in CMakeLists.txt [Snider, Ziegler] +- Fix the path to zlib.map in CMakeLists.txt +- Force the native libtool in Mac OS X to avoid GNU libtool [Beebe] +- Add instructions to win32/Makefile.gcc for shared install [Torri] + +Changes in 1.2.6.1 (12 Feb 2012) +- Avoid the use of the Objective-C reserved name "id" +- Include io.h in gzguts.h for Microsoft compilers +- Fix problem with ./configure --prefix and gzgetc macro +- Include gz_header definition when compiling zlib solo +- Put gzflags() functionality back in zutil.c +- Avoid library header include in crc32.c for Z_SOLO +- Use name in GCC_CLASSIC as C compiler for coverage testing, if set +- Minor cleanup in contrib/minizip/zip.c [Vollant] +- Update make_vms.com [Zinser] +- Remove unnecessary gzgetc_ function +- Use optimized byte swap operations for Microsoft and GNU [Snyder] +- Fix minor typo in zlib.h comments [Rzesniowiecki] + +Changes in 1.2.6 (29 Jan 2012) +- Update the Pascal interface in contrib/pascal +- Fix function numbers for gzgetc_ in zlibvc.def files +- Fix configure.ac for contrib/minizip [Schiffer] +- Fix large-entry detection in minizip on 64-bit systems [Schiffer] +- Have ./configure use the compiler return code for error indication +- Fix CMakeLists.txt for cross compilation [McClure] +- Fix contrib/minizip/zip.c for 64-bit architectures [Dalsnes] +- Fix compilation of contrib/minizip on FreeBSD [Marquez] +- Correct suggested usages in win32/Makefile.msc [Shachar, Horvath] +- Include io.h for Turbo C / Borland C on all platforms [Truta] +- Make version explicit in contrib/minizip/configure.ac [Bosmans] +- Avoid warning for no encryption in contrib/minizip/zip.c [Vollant] +- Minor cleanup up contrib/minizip/unzip.c [Vollant] +- Fix bug when compiling minizip with C++ [Vollant] +- Protect for long name and extra fields in contrib/minizip [Vollant] +- Avoid some warnings in contrib/minizip [Vollant] +- Add -I../.. -L../.. to CFLAGS for minizip and miniunzip +- Add missing libs to minizip linker command +- Add support for VPATH builds in contrib/minizip +- Add an --enable-demos option to contrib/minizip/configure +- Add the generation of configure.log by ./configure +- Exit when required parameters not provided to win32/Makefile.gcc +- Have gzputc return the character written instead of the argument +- Use the -m option on ldconfig for BSD systems [Tobias] +- Correct in zlib.map when deflateResetKeep was added + +Changes in 1.2.5.3 (15 Jan 2012) +- Restore gzgetc function for binary compatibility +- Do not use _lseeki64 under Borland C++ [Truta] +- Update win32/Makefile.msc to build test/*.c [Truta] +- Remove old/visualc6 given CMakefile and other alternatives +- Update AS400 build files and documentation [Monnerat] +- Update win32/Makefile.gcc to build test/*.c [Truta] +- Permit stronger flushes after Z_BLOCK flushes +- Avoid extraneous empty blocks when doing empty flushes +- Permit Z_NULL arguments to deflatePending +- Allow deflatePrime() to insert bits in the middle of a stream +- Remove second empty static block for Z_PARTIAL_FLUSH +- Write out all of the available bits when using Z_BLOCK +- Insert the first two strings in the hash table after a flush + +Changes in 1.2.5.2 (17 Dec 2011) +- fix ld error: unable to find version dependency 'ZLIB_1.2.5' +- use relative symlinks for shared libs +- Avoid searching past window for Z_RLE strategy +- Assure that high-water mark initialization is always applied in deflate +- Add assertions to fill_window() in deflate.c to match comments +- Update python link in README +- Correct spelling error in gzread.c +- Fix bug in gzgets() for a concatenated empty gzip stream +- Correct error in comment for gz_make() +- Change gzread() and related to ignore junk after gzip streams +- Allow gzread() and related to continue after gzclearerr() +- Allow gzrewind() and gzseek() after a premature end-of-file +- Simplify gzseek() now that raw after gzip is ignored +- Change gzgetc() to a macro for speed (~40% speedup in testing) +- Fix gzclose() to return the actual error last encountered +- Always add large file support for windows +- Include zconf.h for windows large file support +- Include zconf.h.cmakein for windows large file support +- Update zconf.h.cmakein on make distclean +- Merge vestigial vsnprintf determination from zutil.h to gzguts.h +- Clarify how gzopen() appends in zlib.h comments +- Correct documentation of gzdirect() since junk at end now ignored +- Add a transparent write mode to gzopen() when 'T' is in the mode +- Update python link in zlib man page +- Get inffixed.h and MAKEFIXED result to match +- Add a ./config --solo option to make zlib subset with no libary use +- Add undocumented inflateResetKeep() function for CAB file decoding +- Add --cover option to ./configure for gcc coverage testing +- Add #define ZLIB_CONST option to use const in the z_stream interface +- Add comment to gzdopen() in zlib.h to use dup() when using fileno() +- Note behavior of uncompress() to provide as much data as it can +- Add files in contrib/minizip to aid in building libminizip +- Split off AR options in Makefile.in and configure +- Change ON macro to Z_ARG to avoid application conflicts +- Facilitate compilation with Borland C++ for pragmas and vsnprintf +- Include io.h for Turbo C / Borland C++ +- Move example.c and minigzip.c to test/ +- Simplify incomplete code table filling in inflate_table() +- Remove code from inflate.c and infback.c that is impossible to execute +- Test the inflate code with full coverage +- Allow deflateSetDictionary, inflateSetDictionary at any time (in raw) +- Add deflateResetKeep and fix inflateResetKeep to retain dictionary +- Fix gzwrite.c to accommodate reduced memory zlib compilation +- Have inflate() with Z_FINISH avoid the allocation of a window +- Do not set strm->adler when doing raw inflate +- Fix gzeof() to behave just like feof() when read is not past end of file +- Fix bug in gzread.c when end-of-file is reached +- Avoid use of Z_BUF_ERROR in gz* functions except for premature EOF +- Document gzread() capability to read concurrently written files +- Remove hard-coding of resource compiler in CMakeLists.txt [Blammo] + +Changes in 1.2.5.1 (10 Sep 2011) +- Update FAQ entry on shared builds (#13) +- Avoid symbolic argument to chmod in Makefile.in +- Fix bug and add consts in contrib/puff [Oberhumer] +- Update contrib/puff/zeros.raw test file to have all block types +- Add full coverage test for puff in contrib/puff/Makefile +- Fix static-only-build install in Makefile.in +- Fix bug in unzGetCurrentFileInfo() in contrib/minizip [Kuno] +- Add libz.a dependency to shared in Makefile.in for parallel builds +- Spell out "number" (instead of "nb") in zlib.h for total_in, total_out +- Replace $(...) with `...` in configure for non-bash sh [Bowler] +- Add darwin* to Darwin* and solaris* to SunOS\ 5* in configure [Groffen] +- Add solaris* to Linux* in configure to allow gcc use [Groffen] +- Add *bsd* to Linux* case in configure [Bar-Lev] +- Add inffast.obj to dependencies in win32/Makefile.msc +- Correct spelling error in deflate.h [Kohler] +- Change libzdll.a again to libz.dll.a (!) in win32/Makefile.gcc +- Add test to configure for GNU C looking for gcc in output of $cc -v +- Add zlib.pc generation to win32/Makefile.gcc [Weigelt] +- Fix bug in zlib.h for _FILE_OFFSET_BITS set and _LARGEFILE64_SOURCE not +- Add comment in zlib.h that adler32_combine with len2 < 0 makes no sense +- Make NO_DIVIDE option in adler32.c much faster (thanks to John Reiser) +- Make stronger test in zconf.h to include unistd.h for LFS +- Apply Darwin patches for 64-bit file offsets to contrib/minizip [Slack] +- Fix zlib.h LFS support when Z_PREFIX used +- Add updated as400 support (removed from old) [Monnerat] +- Avoid deflate sensitivity to volatile input data +- Avoid division in adler32_combine for NO_DIVIDE +- Clarify the use of Z_FINISH with deflateBound() amount of space +- Set binary for output file in puff.c +- Use u4 type for crc_table to avoid conversion warnings +- Apply casts in zlib.h to avoid conversion warnings +- Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller] +- Improve inflateSync() documentation to note indeterminancy +- Add deflatePending() function to return the amount of pending output +- Correct the spelling of "specification" in FAQ [Randers-Pehrson] +- Add a check in configure for stdarg.h, use for gzprintf() +- Check that pointers fit in ints when gzprint() compiled old style +- Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler] +- Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt] +- Add debug records in assmebler code [Londer] +- Update RFC references to use http://tools.ietf.org/html/... [Li] +- Add --archs option, use of libtool to configure for Mac OS X [Borstel] + Changes in 1.2.5 (19 Apr 2010) - Disable visibility attribute in win32/Makefile.gcc [Bar-Lev] - Default to libdir as sharedlibdir in configure [Nieder] - Update copyright dates on modified source files - Update trees.c to be able to generate modified trees.h - Exit configure for MinGW, suggesting win32/Makefile.gcc +- Check for NULL path in gz_open [Homurlu] Changes in 1.2.4.5 (18 Apr 2010) - Set sharedlibdir in configure [Torok] @@ -261,7 +462,7 @@ Changes in 1.2.3.4 (21 Dec 2009) - Clear bytes after deflate lookahead to avoid use of uninitialized data - Change a limit in inftrees.c to be more transparent to Coverity Prevent - Update win32/zlib.def with exported symbols from zlib.h -- Correct spelling error in zlib.h [Willem] +- Correct spelling errors in zlib.h [Willem, Sobrado] - Allow Z_BLOCK for deflate() to force a new block - Allow negative bits in inflatePrime() to delete existing bit buffer - Add Z_TREES flush option to inflate() to return at end of trees Modified: head/lib/libz/FAQ ============================================================================== --- head/lib/libz/FAQ Thu Jun 21 18:28:48 2012 (r237409) +++ head/lib/libz/FAQ Thu Jun 21 21:47:08 2012 (r237410) @@ -44,8 +44,8 @@ The lastest zlib FAQ is at http://zlib.n 6. Where's the zlib documentation (man pages, etc.)? - It's in zlib.h . Examples of zlib usage are in the files example.c and - minigzip.c, with more in examples/ . + It's in zlib.h . Examples of zlib usage are in the files test/example.c + and test/minigzip.c, with more in examples/ . 7. Why don't you use GNU autoconf or libtool or ...? @@ -84,8 +84,10 @@ The lastest zlib FAQ is at http://zlib.n 13. How can I make a Unix shared library? - make clean - ./configure -s + By default a shared (and a static) library is built for Unix. So: + + make distclean + ./configure make 14. How do I install a shared zlib library on Unix? @@ -325,7 +327,7 @@ The lastest zlib FAQ is at http://zlib.n correctly points to the zlib specification in RFC 1950 for the "deflate" transfer encoding, there have been reports of servers and browsers that incorrectly produce or expect raw deflate data per the deflate - specficiation in RFC 1951, most notably Microsoft. So even though the + specification in RFC 1951, most notably Microsoft. So even though the "deflate" transfer encoding using the zlib format would be the more efficient approach (and in fact exactly what the zlib format was designed for), using the "gzip" transfer encoding is probably more reliable due to Modified: head/lib/libz/FREEBSD-upgrade ============================================================================== --- head/lib/libz/FREEBSD-upgrade Thu Jun 21 18:28:48 2012 (r237409) +++ head/lib/libz/FREEBSD-upgrade Thu Jun 21 21:47:08 2012 (r237410) @@ -1,4 +1,4 @@ -$FreeBSD$ +$FreeBSD: head/lib/libz/FREEBSD-upgrade 146082 2005-05-11 03:50:50Z kientzle $ ZLib 1.2.2 Modified: head/lib/libz/Makefile ============================================================================== --- head/lib/libz/Makefile Thu Jun 21 18:28:48 2012 (r237409) +++ head/lib/libz/Makefile Thu Jun 21 21:47:08 2012 (r237410) @@ -1,5 +1,5 @@ # -# $FreeBSD$ +# $FreeBSD: head/lib/libz/Makefile 232263 2012-02-28 18:30:18Z dim $ # LIB= z @@ -35,12 +35,12 @@ SRCS+= uncompr.c SRCS+= zopen.c SRCS+= zutil.c -.if ${MACHINE_ARCH} == "i386" && ${MACHINE_CPU:M*i686*} -.PATH: ${.CURDIR}/contrib/asm686 -SRCS+= match.S -CFLAGS+= -DASMV -DNO_UNDERLINE -ACFLAGS+= -Wa,--noexecstack -.endif +#.if ${MACHINE_ARCH} == "i386" && ${MACHINE_CPU:M*i686*} +#.PATH: ${.CURDIR}/contrib/asm686 +#SRCS+= match.S +#CFLAGS+= -DASMV -DNO_UNDERLINE +#ACFLAGS+= -Wa,--noexecstack +#.endif #.if ${MACHINE_ARCH} == "amd64" #.PATH: ${.CURDIR}/contrib/gcc_gvmat64 Modified: head/lib/libz/README ============================================================================== --- head/lib/libz/README Thu Jun 21 18:28:48 2012 (r237409) +++ head/lib/libz/README Thu Jun 21 21:47:08 2012 (r237410) @@ -1,22 +1,22 @@ ZLIB DATA COMPRESSION LIBRARY -zlib 1.2.5 is a general purpose data compression library. All the code is +zlib 1.2.7 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files -http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) -and rfc1952.txt (gzip format). +http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and +rfc1952 (gzip format). All functions of the compression library are documented in the file zlib.h (volunteer to write man pages welcome, contact zlib@gzip.org). A usage example -of the library is given in the file example.c which also tests that the library -is working correctly. Another example is given in the file minigzip.c. The -compression library itself is composed of all source files except example.c and -minigzip.c. +of the library is given in the file test/example.c which also tests that +the library is working correctly. Another example is given in the file +test/minigzip.c. The compression library itself is composed of all source +files in the root directory. To compile all files and run the test program, follow the instructions given at the top of Makefile.in. In short "./configure; make test", and if that goes -well, "make install" should work for most flavors of Unix. For Windows, use one -of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use +well, "make install" should work for most flavors of Unix. For Windows, use +one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use make_vms.com. Questions about zlib should be sent to , or to Gilles Vollant @@ -31,7 +31,7 @@ Mark Nelson wrote an ar issue of Dr. Dobb's Journal; a copy of the article is available at http://marknelson.us/1997/01/01/zlib-engine/ . -The changes made in version 1.2.5 are documented in the file ChangeLog. +The changes made in version 1.2.7 are documented in the file ChangeLog. Unsupported third party contributions are provided in directory contrib/ . @@ -44,7 +44,7 @@ http://search.cpan.org/~pmqs/IO-Compress A Python interface to zlib written by A.M. Kuchling is available in Python 1.5 and later versions, see -http://www.python.org/doc/lib/module-zlib.html . +http://docs.python.org/library/zlib.html . zlib is built into tcl: http://wiki.tcl.tk/4610 . @@ -84,7 +84,7 @@ Acknowledgments: Copyright notice: - (C) 1995-2010 Jean-loup Gailly and Mark Adler + (C) 1995-2012 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages Modified: head/lib/libz/Symbol.map ============================================================================== --- head/lib/libz/Symbol.map Thu Jun 21 18:28:48 2012 (r237409) +++ head/lib/libz/Symbol.map Thu Jun 21 21:47:08 2012 (r237410) @@ -1,7 +1,14 @@ /* - * $FreeBSD$ + * $FreeBSD: head/lib/libz/Symbol.map 206709 2010-04-16 20:07:24Z delphij $ */ +ZLIB_1.2.7.0 { + deflatePending; + deflateResetKeep; + gzgetc_; + inflateResetKeep; +}; + ZLIB_1.2.4.0 { adler32; adler32_combine; Modified: head/lib/libz/Versions.def ============================================================================== --- head/lib/libz/Versions.def Thu Jun 21 18:28:48 2012 (r237409) +++ head/lib/libz/Versions.def Thu Jun 21 21:47:08 2012 (r237410) @@ -1,8 +1,11 @@ -# $FreeBSD$ +# $FreeBSD: head/lib/libz/Versions.def 205486 2010-03-22 22:12:27Z delphij $ ZLIB_1.2.4.0 { }; +ZLIB_1.2.7.0 { +} ZLIB_1.2.4.0; + FBSD_1.2 { } ZLIB_1.2.4.0; Modified: head/lib/libz/adler32.c ============================================================================== --- head/lib/libz/adler32.c Thu Jun 21 18:28:48 2012 (r237409) +++ head/lib/libz/adler32.c Thu Jun 21 21:47:08 2012 (r237410) @@ -1,5 +1,5 @@ /* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2007 Mark Adler + * Copyright (C) 1995-2011 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,9 +9,9 @@ #define local static -local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2); +local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); -#define BASE 65521UL /* largest prime smaller than 65536 */ +#define BASE 65521 /* largest prime smaller than 65536 */ #define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ @@ -21,39 +21,44 @@ local uLong adler32_combine_(uLong adler #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); #define DO16(buf) DO8(buf,0); DO8(buf,8); -/* use NO_DIVIDE if your processor does not do division in hardware */ +/* use NO_DIVIDE if your processor does not do division in hardware -- + try it both ways to see which is faster */ #ifdef NO_DIVIDE -# define MOD(a) \ +/* note that this assumes BASE is 65521, where 65536 % 65521 == 15 + (thank you to John Reiser for pointing this out) */ +# define CHOP(a) \ + do { \ + unsigned long tmp = a >> 16; \ + a &= 0xffffUL; \ + a += (tmp << 4) - tmp; \ + } while (0) +# define MOD28(a) \ do { \ - if (a >= (BASE << 16)) a -= (BASE << 16); \ - if (a >= (BASE << 15)) a -= (BASE << 15); \ - if (a >= (BASE << 14)) a -= (BASE << 14); \ - if (a >= (BASE << 13)) a -= (BASE << 13); \ - if (a >= (BASE << 12)) a -= (BASE << 12); \ - if (a >= (BASE << 11)) a -= (BASE << 11); \ - if (a >= (BASE << 10)) a -= (BASE << 10); \ - if (a >= (BASE << 9)) a -= (BASE << 9); \ - if (a >= (BASE << 8)) a -= (BASE << 8); \ - if (a >= (BASE << 7)) a -= (BASE << 7); \ - if (a >= (BASE << 6)) a -= (BASE << 6); \ - if (a >= (BASE << 5)) a -= (BASE << 5); \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ + CHOP(a); \ if (a >= BASE) a -= BASE; \ } while (0) -# define MOD4(a) \ +# define MOD(a) \ do { \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ + CHOP(a); \ + MOD28(a); \ + } while (0) +# define MOD63(a) \ + do { /* this assumes a is not negative */ \ + z_off64_t tmp = a >> 32; \ + a &= 0xffffffffL; \ + a += (tmp << 8) - (tmp << 5) + tmp; \ + tmp = a >> 16; \ + a &= 0xffffL; \ + a += (tmp << 4) - tmp; \ + tmp = a >> 16; \ + a &= 0xffffL; \ + a += (tmp << 4) - tmp; \ if (a >= BASE) a -= BASE; \ } while (0) #else # define MOD(a) a %= BASE -# define MOD4(a) a %= BASE +# define MOD28(a) a %= BASE +# define MOD63(a) a %= BASE #endif /* ========================================================================= */ @@ -92,7 +97,7 @@ uLong ZEXPORT adler32(adler, buf, len) } if (adler >= BASE) adler -= BASE; - MOD4(sum2); /* only added so many BASE's */ + MOD28(sum2); /* only added so many BASE's */ return adler | (sum2 << 16); } @@ -137,8 +142,13 @@ local uLong adler32_combine_(adler1, adl unsigned long sum2; unsigned rem; + /* for negative len, return invalid adler32 as a clue for debugging */ + if (len2 < 0) + return 0xffffffffUL; + /* the derivation of this formula is left as an exercise for the reader */ - rem = (unsigned)(len2 % BASE); + MOD63(len2); /* assumes len2 >= 0 */ + rem = (unsigned)len2; sum1 = adler1 & 0xffff; sum2 = rem * sum1; MOD(sum2); Modified: head/lib/libz/contrib/asm686/match.S ============================================================================== --- head/lib/libz/contrib/asm686/match.S Thu Jun 21 18:28:48 2012 (r237409) +++ head/lib/libz/contrib/asm686/match.S Thu Jun 21 21:47:08 2012 (r237410) @@ -83,17 +83,25 @@ .text /* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */ +.cfi_sections .debug_frame longest_match: +.cfi_startproc /* Save registers that the compiler may be using, and adjust %esp to */ /* make room for our stack frame. */ pushl %ebp + .cfi_def_cfa_offset 8 + .cfi_offset ebp, -8 pushl %edi + .cfi_def_cfa_offset 12 pushl %esi + .cfi_def_cfa_offset 16 pushl %ebx + .cfi_def_cfa_offset 20 subl $LocalVarsSize, %esp + .cfi_def_cfa_offset LocalVarsSize+20 /* Retrieve the function arguments. %ecx will hold cur_match */ /* throughout the entire function. %edx will hold the pointer to the */ @@ -108,7 +116,7 @@ longest_match: /* if (s->prev_length >= s->good_match) { */ /* chain_length >>= 2; */ /* } */ - + movl dsPrevLen(%edx), %eax movl dsGoodMatch(%edx), %ebx cmpl %ebx, %eax @@ -336,8 +344,14 @@ LookaheadRet: /* Restore the stack and return from whence we came. */ addl $LocalVarsSize, %esp + .cfi_def_cfa_offset 20 popl %ebx + .cfi_def_cfa_offset 16 popl %esi + .cfi_def_cfa_offset 12 popl %edi + .cfi_def_cfa_offset 8 popl %ebp + .cfi_def_cfa_offset 4 +.cfi_endproc match_init: ret Modified: head/lib/libz/crc32.c ============================================================================== --- head/lib/libz/crc32.c Thu Jun 21 18:28:48 2012 (r237409) +++ head/lib/libz/crc32.c Thu Jun 21 21:47:08 2012 (r237410) @@ -1,5 +1,5 @@ /* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2006, 2010 Mark Adler + * Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h * * Thanks to Rodney Brown for his contribution of faster @@ -17,6 +17,8 @@ of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should first call get_crc_table() to initialize the tables before allowing more than one thread to use crc32(). + + DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h. */ #ifdef MAKECRCH @@ -30,31 +32,11 @@ #define local static -/* Find a four-byte integer type for crc32_little() and crc32_big(). */ -#ifndef NOBYFOUR -# ifdef STDC /* need ANSI C limits.h to determine sizes */ -# include -# define BYFOUR -# if (UINT_MAX == 0xffffffffUL) - typedef unsigned int u4; -# else -# if (ULONG_MAX == 0xffffffffUL) - typedef unsigned long u4; -# else -# if (USHRT_MAX == 0xffffffffUL) - typedef unsigned short u4; -# else -# undef BYFOUR /* can't find a four-byte integer type! */ -# endif -# endif -# endif -# endif /* STDC */ -#endif /* !NOBYFOUR */ - /* Definitions for doing the crc four data bytes at a time. */ +#if !defined(NOBYFOUR) && defined(Z_U4) +# define BYFOUR +#endif #ifdef BYFOUR -# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \ - (((w)&0xff00)<<8)+(((w)&0xff)<<24)) local unsigned long crc32_little OF((unsigned long, const unsigned char FAR *, unsigned)); local unsigned long crc32_big OF((unsigned long, @@ -68,16 +50,16 @@ local unsigned long gf2_matrix_times OF((unsigned long *mat, unsigned long vec)); local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); -local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2); +local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2)); #ifdef DYNAMIC_CRC_TABLE local volatile int crc_table_empty = 1; -local unsigned long FAR crc_table[TBLS][256]; +local z_crc_t FAR crc_table[TBLS][256]; local void make_crc_table OF((void)); #ifdef MAKECRCH - local void write_table OF((FILE *, const unsigned long FAR *)); + local void write_table OF((FILE *, const z_crc_t FAR *)); #endif /* MAKECRCH */ /* Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: @@ -107,9 +89,9 @@ local void make_crc_table OF((void)); */ local void make_crc_table() { - unsigned long c; + z_crc_t c; int n, k; - unsigned long poly; /* polynomial exclusive-or pattern */ + z_crc_t poly; /* polynomial exclusive-or pattern */ /* terms of polynomial defining this crc (except x^32): */ static volatile int first = 1; /* flag to limit concurrent making */ static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; @@ -121,13 +103,13 @@ local void make_crc_table() first = 0; /* make exclusive-or pattern from polynomial (0xedb88320UL) */ - poly = 0UL; - for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) - poly |= 1UL << (31 - p[n]); + poly = 0; + for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++) + poly |= (z_crc_t)1 << (31 - p[n]); /* generate a crc for every 8-bit value */ for (n = 0; n < 256; n++) { - c = (unsigned long)n; + c = (z_crc_t)n; for (k = 0; k < 8; k++) c = c & 1 ? poly ^ (c >> 1) : c >> 1; crc_table[0][n] = c; @@ -138,11 +120,11 @@ local void make_crc_table() and then the byte reversal of those as well as the first table */ for (n = 0; n < 256; n++) { c = crc_table[0][n]; - crc_table[4][n] = REV(c); + crc_table[4][n] = ZSWAP32(c); for (k = 1; k < 4; k++) { c = crc_table[0][c & 0xff] ^ (c >> 8); crc_table[k][n] = c; - crc_table[k + 4][n] = REV(c); + crc_table[k + 4][n] = ZSWAP32(c); } } #endif /* BYFOUR */ @@ -164,7 +146,7 @@ local void make_crc_table() if (out == NULL) return; fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); - fprintf(out, "local const unsigned long FAR "); + fprintf(out, "local const z_crc_t FAR "); fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); write_table(out, crc_table[0]); # ifdef BYFOUR @@ -184,12 +166,13 @@ local void make_crc_table() #ifdef MAKECRCH local void write_table(out, table) FILE *out; - const unsigned long FAR *table; + const z_crc_t FAR *table; { int n; for (n = 0; n < 256; n++) - fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], + fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", + (unsigned long)(table[n]), n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); } #endif /* MAKECRCH */ @@ -204,13 +187,13 @@ local void write_table(out, table) /* ========================================================================= * This function can be used by asm versions of crc32() */ -const unsigned long FAR * ZEXPORT get_crc_table() +const z_crc_t FAR * ZEXPORT get_crc_table() { #ifdef DYNAMIC_CRC_TABLE if (crc_table_empty) make_crc_table(); #endif /* DYNAMIC_CRC_TABLE */ - return (const unsigned long FAR *)crc_table; + return (const z_crc_t FAR *)crc_table; } /* ========================================================================= */ @@ -232,7 +215,7 @@ unsigned long ZEXPORT crc32(crc, buf, le #ifdef BYFOUR if (sizeof(void *) == sizeof(ptrdiff_t)) { - u4 endian; + z_crc_t endian; endian = 1; if (*((unsigned char *)(&endian))) @@ -266,17 +249,17 @@ local unsigned long crc32_little(crc, bu const unsigned char FAR *buf; unsigned len; { - register u4 c; - register const u4 FAR *buf4; + register z_crc_t c; + register const z_crc_t FAR *buf4; - c = (u4)crc; + c = (z_crc_t)crc; c = ~c; while (len && ((ptrdiff_t)buf & 3)) { c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); len--; } - buf4 = (const u4 FAR *)(const void FAR *)buf; + buf4 = (const z_crc_t FAR *)(const void FAR *)buf; while (len >= 32) { DOLIT32; len -= 32; @@ -306,17 +289,17 @@ local unsigned long crc32_big(crc, buf, const unsigned char FAR *buf; unsigned len; { - register u4 c; - register const u4 FAR *buf4; + register z_crc_t c; + register const z_crc_t FAR *buf4; - c = REV((u4)crc); + c = ZSWAP32((z_crc_t)crc); c = ~c; while (len && ((ptrdiff_t)buf & 3)) { c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); len--; } - buf4 = (const u4 FAR *)(const void FAR *)buf; + buf4 = (const z_crc_t FAR *)(const void FAR *)buf; buf4--; while (len >= 32) { DOBIG32; @@ -333,7 +316,7 @@ local unsigned long crc32_big(crc, buf, c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); } while (--len); c = ~c; - return (unsigned long)(REV(c)); + return (unsigned long)(ZSWAP32(c)); } #endif /* BYFOUR */ Modified: head/lib/libz/crc32.h ============================================================================== --- head/lib/libz/crc32.h Thu Jun 21 18:28:48 2012 (r237409) +++ head/lib/libz/crc32.h Thu Jun 21 21:47:08 2012 (r237410) @@ -2,7 +2,7 @@ * Generated automatically by crc32.c */ -local const unsigned long FAR crc_table[TBLS][256] = +local const z_crc_t FAR crc_table[TBLS][256] = { { 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, Modified: head/lib/libz/deflate.c ============================================================================== --- head/lib/libz/deflate.c Thu Jun 21 18:28:48 2012 (r237409) +++ head/lib/libz/deflate.c Thu Jun 21 21:47:08 2012 (r237410) @@ -1,5 +1,5 @@ /* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler + * Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -37,7 +37,7 @@ * REFERENCES * * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". - * Available in http://www.ietf.org/rfc/rfc1951.txt + * Available in http://tools.ietf.org/html/rfc1951 * * A description of the Rabin and Karp algorithm is given in the book * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. @@ -52,7 +52,7 @@ #include "deflate.h" const char deflate_copyright[] = - " deflate 1.2.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler "; + " deflate 1.2.7 Copyright 1995-2012 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -155,6 +155,9 @@ local const config configuration_table[1 struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ #endif +/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */ +#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0)) + /* =========================================================================== * Update a hash value with the given input byte * IN assertion: all calls to to UPDATE_HASH are made with consecutive @@ -235,10 +238,19 @@ int ZEXPORT deflateInit2_(strm, level, m strm->msg = Z_NULL; if (strm->zalloc == (alloc_func)0) { +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else strm->zalloc = zcalloc; strm->opaque = (voidpf)0; +#endif } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; + if (strm->zfree == (free_func)0) +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else + strm->zfree = zcfree; +#endif #ifdef FASTEST if (level != 0) level = 1; @@ -314,43 +326,70 @@ int ZEXPORT deflateSetDictionary (strm, uInt dictLength; { deflate_state *s; - uInt length = dictLength; - uInt n; - IPos hash_head = 0; - - if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || - strm->state->wrap == 2 || - (strm->state->wrap == 1 && strm->state->status != INIT_STATE)) - return Z_STREAM_ERROR; + uInt str, n; + int wrap; + unsigned avail; + unsigned char *next; + if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL) + return Z_STREAM_ERROR; s = strm->state; - if (s->wrap) + wrap = s->wrap; + if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead) + return Z_STREAM_ERROR; + + /* when using zlib wrappers, compute Adler-32 for provided dictionary */ + if (wrap == 1) strm->adler = adler32(strm->adler, dictionary, dictLength); + s->wrap = 0; /* avoid computing Adler-32 in read_buf */ - if (length < MIN_MATCH) return Z_OK; - if (length > s->w_size) { - length = s->w_size; - dictionary += dictLength - length; /* use the tail of the dictionary */ - } - zmemcpy(s->window, dictionary, length); - s->strstart = length; - s->block_start = (long)length; - - /* Insert all strings in the hash table (except for the last two bytes). - * s->lookahead stays null, so s->ins_h will be recomputed at the next - * call of fill_window. - */ - s->ins_h = s->window[0]; - UPDATE_HASH(s, s->ins_h, s->window[1]); - for (n = 0; n <= length - MIN_MATCH; n++) { - INSERT_STRING(s, n, hash_head); - } - if (hash_head) hash_head = 0; /* to make compiler happy */ + /* if dictionary would fill window, just replace the history */ + if (dictLength >= s->w_size) { + if (wrap == 0) { /* already empty otherwise */ + CLEAR_HASH(s); + s->strstart = 0; + s->block_start = 0L; + s->insert = 0; + } + dictionary += dictLength - s->w_size; /* use the tail */ + dictLength = s->w_size; + } + + /* insert dictionary into window and hash */ + avail = strm->avail_in; + next = strm->next_in; + strm->avail_in = dictLength; + strm->next_in = (Bytef *)dictionary; + fill_window(s); + while (s->lookahead >= MIN_MATCH) { + str = s->strstart; + n = s->lookahead - (MIN_MATCH-1); + do { + UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); +#ifndef FASTEST + s->prev[str & s->w_mask] = s->head[s->ins_h]; +#endif + s->head[s->ins_h] = (Pos)str; + str++; + } while (--n); + s->strstart = str; + s->lookahead = MIN_MATCH-1; + fill_window(s); + } + s->strstart += s->lookahead; + s->block_start = (long)s->strstart; + s->insert = s->lookahead; + s->lookahead = 0; + s->match_length = s->prev_length = MIN_MATCH-1; + s->match_available = 0; + strm->next_in = next; + strm->avail_in = avail; + s->wrap = wrap; return Z_OK; } /* ========================================================================= */ -int ZEXPORT deflateReset (strm) +int ZEXPORT deflateResetKeep (strm) z_streamp strm; { deflate_state *s; @@ -380,12 +419,23 @@ int ZEXPORT deflateReset (strm) s->last_flush = Z_NO_FLUSH; _tr_init(s); - lm_init(s); return Z_OK; } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Thu Jun 21 22:06:58 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 19FA91065670; Thu, 21 Jun 2012 22:06:58 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 058DB8FC14; Thu, 21 Jun 2012 22:06:58 +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 q5LM6v4R038818; Thu, 21 Jun 2012 22:06:57 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5LM6vvK038816; Thu, 21 Jun 2012 22:06:57 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201206212206.q5LM6vvK038816@svn.freebsd.org> From: Ed Maste Date: Thu, 21 Jun 2012 22:06:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237411 - head/sys/dev/drm2 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 22:06:58 -0000 Author: emaste Date: Thu Jun 21 22:06:57 2012 New Revision: 237411 URL: http://svn.freebsd.org/changeset/base/237411 Log: Add PCI IDs for Ivy Bridge Modified: head/sys/dev/drm2/drm_pciids.h Modified: head/sys/dev/drm2/drm_pciids.h ============================================================================== --- head/sys/dev/drm2/drm_pciids.h Thu Jun 21 21:47:08 2012 (r237410) +++ head/sys/dev/drm2/drm_pciids.h Thu Jun 21 22:06:57 2012 (r237411) @@ -566,6 +566,12 @@ {0x8086, 0x0116, CHIP_I9XX|CHIP_I915, "Intel SandyBridge (M)"}, \ {0x8086, 0x0126, CHIP_I9XX|CHIP_I915, "Intel SandyBridge (M)"}, \ {0x8086, 0x010A, CHIP_I9XX|CHIP_I915, "Intel SandyBridge (M)"}, \ + {0x8086, 0x0152, CHIP_I9XX|CHIP_I915, "Intel IvyBridge"}, \ + {0x8086, 0x0162, CHIP_I9XX|CHIP_I915, "Intel IvyBridge"}, \ + {0x8086, 0x0156, CHIP_I9XX|CHIP_I915, "Intel IvyBridge (M)"}, \ + {0x8086, 0x0166, CHIP_I9XX|CHIP_I915, "Intel IvyBridge (M)"}, \ + {0x8086, 0x015A, CHIP_I9XX|CHIP_I915, "Intel IvyBridge (S)"}, \ + {0x8086, 0x016A, CHIP_I9XX|CHIP_I915, "Intel IvyBridge (S)"}, \ {0x8086, 0xA001, CHIP_I9XX|CHIP_I965, "Intel Pineview"}, \ {0x8086, 0xA011, CHIP_I9XX|CHIP_I965, "Intel Pineview (M)"}, \ {0, 0, 0, NULL} From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 00:40:45 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CBCC21065673; Fri, 22 Jun 2012 00:40:45 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B2BE38FC0A; Fri, 22 Jun 2012 00:40:45 +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 q5M0ejnt045415; Fri, 22 Jun 2012 00:40:45 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5M0ejNk045397; Fri, 22 Jun 2012 00:40:45 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201206220040.q5M0ejNk045397@svn.freebsd.org> From: Jung-uk Kim Date: Fri, 22 Jun 2012 00:40:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237412 - in head: sys/contrib/dev/acpica sys/contrib/dev/acpica/common sys/contrib/dev/acpica/compiler sys/contrib/dev/acpica/components/debugger sys/contrib/dev/acpica/components/disa... X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 00:40:45 -0000 Author: jkim Date: Fri Jun 22 00:40:44 2012 New Revision: 237412 URL: http://svn.freebsd.org/changeset/base/237412 Log: Merge ACPICA 20120620. Added: head/sys/contrib/dev/acpica/common/ahpredef.c - copied, changed from r237408, vendor-sys/acpica/dist/source/common/ahpredef.c Modified: head/sys/contrib/dev/acpica/changes.txt (contents, props changed) head/sys/contrib/dev/acpica/common/dmextern.c head/sys/contrib/dev/acpica/common/dmrestag.c head/sys/contrib/dev/acpica/compiler/aslcompile.c head/sys/contrib/dev/acpica/compiler/aslerror.c head/sys/contrib/dev/acpica/compiler/aslfiles.c head/sys/contrib/dev/acpica/compiler/asllookup.c head/sys/contrib/dev/acpica/compiler/aslmain.c head/sys/contrib/dev/acpica/compiler/aslsupport.l head/sys/contrib/dev/acpica/compiler/aslutils.c head/sys/contrib/dev/acpica/compiler/dttemplate.c head/sys/contrib/dev/acpica/components/debugger/dbdisply.c head/sys/contrib/dev/acpica/components/debugger/dbexec.c head/sys/contrib/dev/acpica/components/debugger/dbutils.c head/sys/contrib/dev/acpica/components/disassembler/dmopcode.c head/sys/contrib/dev/acpica/components/disassembler/dmwalk.c head/sys/contrib/dev/acpica/components/dispatcher/dsfield.c head/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c head/sys/contrib/dev/acpica/components/events/evgpe.c head/sys/contrib/dev/acpica/components/events/evgpeutil.c head/sys/contrib/dev/acpica/components/events/evxfgpe.c head/sys/contrib/dev/acpica/components/executer/exconfig.c head/sys/contrib/dev/acpica/components/utilities/utmisc.c head/sys/contrib/dev/acpica/include/acdebug.h head/sys/contrib/dev/acpica/include/acdisasm.h head/sys/contrib/dev/acpica/include/acglobal.h head/sys/contrib/dev/acpica/include/aclocal.h head/sys/contrib/dev/acpica/include/acpixf.h head/sys/contrib/dev/acpica/include/acpredef.h head/sys/contrib/dev/acpica/include/acutils.h head/usr.sbin/acpi/iasl/Makefile Directory Properties: head/sys/contrib/dev/acpica/ (props changed) head/sys/contrib/dev/acpica/common/ (props changed) head/sys/contrib/dev/acpica/compiler/ (props changed) head/sys/contrib/dev/acpica/components/debugger/ (props changed) head/sys/contrib/dev/acpica/components/disassembler/ (props changed) head/sys/contrib/dev/acpica/components/dispatcher/ (props changed) head/sys/contrib/dev/acpica/components/events/ (props changed) head/sys/contrib/dev/acpica/components/executer/ (props changed) head/sys/contrib/dev/acpica/components/utilities/ (props changed) head/sys/contrib/dev/acpica/include/ (props changed) Modified: head/sys/contrib/dev/acpica/changes.txt ============================================================================== --- head/sys/contrib/dev/acpica/changes.txt Thu Jun 21 22:06:57 2012 (r237411) +++ head/sys/contrib/dev/acpica/changes.txt Fri Jun 22 00:40:44 2012 (r237412) @@ -1,4 +1,68 @@ ---------------------------------------- +20 June 2012. Summary of changes for version 20120620: + +This release is available at https://www.acpica.org/downloads +The ACPI 5.0 specification is available at www.acpi.info + +1) ACPICA Kernel-resident Subsystem: + +Implemented support to expand the "implicit notify" feature to allow multiple +devices to be notified by a single GPE. This feature automatically generates a +runtime device notification in the absence of a BIOS-provided GPE control +method (_Lxx/_Exx) or a host-installed handler for the GPE. Implicit notify is +provided by ACPICA for Windows compatibility, and is a workaround for BIOS AML +code errors. See the description of the AcpiSetupGpeForWake interface in the +APCICA reference. Bob Moore, Rafael Wysocki. ACPICA BZ 918. + +Changed some comments and internal function names to simplify and ensure +correctness of the Linux code translation. No functional changes. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The debug +version of the code includes the debug output trace mechanism and has a much +larger code and data size. + + Previous Release: + Non-Debug Version: 93.0K Code, 25.1K Data, 118.1K Total + Debug Version: 172.7K Code, 73.6K Data, 246.3K Total + Current Release: + Non-Debug Version: 93.1K Code, 25.1K Data, 118.2K Total + Debug Version: 172.9K Code, 73.6K Data, 246.5K Total + + +2) iASL Compiler/Disassembler and Tools: + +Disassembler: Added support to emit short, commented descriptions for the ACPI +predefined names in order to improve the readability of the disassembled +output. ACPICA BZ 959. Changes include: + 1) Emit descriptions for all standard predefined names (_INI, _STA, _PRW, +etc.) + 2) Emit generic descriptions for the special names (_Exx, _Qxx, etc.) + 3) Emit descriptions for the resource descriptor names (_MIN, _LEN, etc.) + +AcpiSrc: Fixed several long-standing Linux code translation issues. Argument +descriptions in function headers are now translated properly to lower case and +underscores. ACPICA BZ 961. Also fixes translation problems such as these: +(old -> new) + i_aSL -> iASL + 00-7_f -> 00-7F + 16_k -> 16K + local_fADT -> local_FADT + execute_oSI -> execute_OSI + +iASL: Fixed a problem where null bytes were inadvertently emitted into some +listing files. + +iASL: Added the existing debug options to the standard help screen. There are +no longer two different help screens. ACPICA BZ 957. + +AcpiHelp: Fixed some typos in the various predefined name descriptions. Also +expand some of the descriptions where appropriate. + +iASL: Fixed the -ot option (display compile times/statistics). Was not working +properly for standard output; only worked for the debug file case. + +---------------------------------------- 18 May 2012. Summary of changes for version 20120518: Copied and modified: head/sys/contrib/dev/acpica/common/ahpredef.c (from r237408, vendor-sys/acpica/dist/source/common/ahpredef.c) ============================================================================== --- vendor-sys/acpica/dist/source/common/ahpredef.c Thu Jun 21 18:22:50 2012 (r237408, copy source) +++ head/sys/contrib/dev/acpica/common/ahpredef.c Fri Jun 22 00:40:44 2012 (r237412) @@ -41,8 +41,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include "acpi.h" -#include "accommon.h" +#include +#include /* * iASL only needs a partial table (short descriptions only). Modified: head/sys/contrib/dev/acpica/common/dmextern.c ============================================================================== --- head/sys/contrib/dev/acpica/common/dmextern.c Thu Jun 21 22:06:57 2012 (r237411) +++ head/sys/contrib/dev/acpica/common/dmextern.c Fri Jun 22 00:40:44 2012 (r237412) @@ -221,8 +221,10 @@ AcpiDmNormalizeParentPrefix ( */ ACPI_STRCAT (Fullpath, ParentPath); - /* Add dot separator (don't need dot if parent fullpath is a single "\") */ - + /* + * Add dot separator + * (don't need dot if parent fullpath is a single backslash) + */ if (ParentPath[1]) { ACPI_STRCAT (Fullpath, "."); Modified: head/sys/contrib/dev/acpica/common/dmrestag.c ============================================================================== --- head/sys/contrib/dev/acpica/common/dmrestag.c Thu Jun 21 22:06:57 2012 (r237411) +++ head/sys/contrib/dev/acpica/common/dmrestag.c Fri Jun 22 00:40:44 2012 (r237412) @@ -73,6 +73,7 @@ AcpiDmGetResourceTag ( static char * AcpiGetTagPathname ( + ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *BufferNode, ACPI_NAMESPACE_NODE *ResourceNode, UINT32 BitIndex); @@ -443,7 +444,6 @@ AcpiDmCheckResourceReference ( ACPI_NAMESPACE_NODE *BufferNode; ACPI_NAMESPACE_NODE *ResourceNode; const ACPI_OPCODE_INFO *OpInfo; - char *Pathname; UINT32 BitIndex; @@ -519,14 +519,7 @@ AcpiDmCheckResourceReference ( /* Translate the Index to a resource tag pathname */ - Pathname = AcpiGetTagPathname (BufferNode, ResourceNode, BitIndex); - if (Pathname) - { - /* Complete the conversion of the Index to a symbol */ - - IndexOp->Common.AmlOpcode = AML_INT_NAMEPATH_OP; - IndexOp->Common.Value.String = Pathname; - } + AcpiGetTagPathname (IndexOp, BufferNode, ResourceNode, BitIndex); } @@ -597,6 +590,7 @@ AcpiDmGetResourceNode ( static char * AcpiGetTagPathname ( + ACPI_PARSE_OBJECT *IndexOp, ACPI_NAMESPACE_NODE *BufferNode, ACPI_NAMESPACE_NODE *ResourceNode, UINT32 BitIndex) @@ -689,6 +683,15 @@ AcpiGetTagPathname ( AcpiNsInternalizeName (Pathname, &InternalPath); ACPI_FREE (Pathname); + + /* Update the Op with the symbol */ + + AcpiPsInitOp (IndexOp, AML_INT_NAMEPATH_OP); + IndexOp->Common.Value.String = InternalPath; + + /* We will need the tag later. Cheat by putting it in the Node field */ + + IndexOp->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Tag); return (InternalPath); } Modified: head/sys/contrib/dev/acpica/compiler/aslcompile.c ============================================================================== --- head/sys/contrib/dev/acpica/compiler/aslcompile.c Thu Jun 21 22:06:57 2012 (r237411) +++ head/sys/contrib/dev/acpica/compiler/aslcompile.c Fri Jun 22 00:40:44 2012 (r237412) @@ -67,6 +67,10 @@ FlConsumeNewComment ( FILE *Handle, ASL_FILE_STATUS *Status); +static void +CmDumpAllEvents ( + void); + /******************************************************************************* * @@ -717,45 +721,65 @@ CmDoOutputFiles ( /******************************************************************************* * - * FUNCTION: CmDumpEvent + * FUNCTION: CmDumpAllEvents * - * PARAMETERS: Event - A compiler event struct + * PARAMETERS: None * * RETURN: None. * - * DESCRIPTION: Dump a compiler event struct + * DESCRIPTION: Dump all compiler events * ******************************************************************************/ static void -CmDumpEvent ( - ASL_EVENT_INFO *Event) +CmDumpAllEvents ( + void) { + ASL_EVENT_INFO *Event; UINT32 Delta; UINT32 USec; UINT32 MSec; + UINT32 i; + - if (!Event->Valid) + Event = AslGbl_Events; + + DbgPrint (ASL_DEBUG_OUTPUT, "\n\nElapsed time for major events\n\n"); + if (Gbl_CompileTimesFlag) { - return; + printf ("\nElapsed time for major events\n\n"); } - /* Delta will be in 100-nanosecond units */ + for (i = 0; i < AslGbl_NextEvent; i++) + { + if (Event->Valid) + { + /* Delta will be in 100-nanosecond units */ - Delta = (UINT32) (Event->EndTime - Event->StartTime); + Delta = (UINT32) (Event->EndTime - Event->StartTime); - USec = Delta / 10; - MSec = Delta / 10000; + USec = Delta / 10; + MSec = Delta / 10000; - /* Round milliseconds up */ + /* Round milliseconds up */ - if ((USec - (MSec * 1000)) >= 500) - { - MSec++; - } + if ((USec - (MSec * 1000)) >= 500) + { + MSec++; + } + + DbgPrint (ASL_DEBUG_OUTPUT, "%8u usec %8u msec - %s\n", + USec, MSec, Event->EventName); + + if (Gbl_CompileTimesFlag) + { + printf ("%8u usec %8u msec - %s\n", + USec, MSec, Event->EventName); + } + } - DbgPrint (ASL_DEBUG_OUTPUT, "%8u usec %8u msec - %s\n", - USec, MSec, Event->EventName); + Event++; + } } @@ -786,20 +810,12 @@ CmCleanupAndExit ( AePrintErrorLog (ASL_FILE_STDOUT); } - DbgPrint (ASL_DEBUG_OUTPUT, "\n\nElapsed time for major events\n\n"); - for (i = 0; i < AslGbl_NextEvent; i++) - { - CmDumpEvent (&AslGbl_Events[i]); - } + /* Emit compile times if enabled */ + + CmDumpAllEvents (); if (Gbl_CompileTimesFlag) { - printf ("\nElapsed time for major events\n\n"); - for (i = 0; i < AslGbl_NextEvent; i++) - { - CmDumpEvent (&AslGbl_Events[i]); - } - printf ("\nMiscellaneous compile statistics\n\n"); printf ("%11u : %s\n", TotalParseNodes, "Parse nodes"); printf ("%11u : %s\n", Gbl_NsLookupCount, "Namespace searches"); Modified: head/sys/contrib/dev/acpica/compiler/aslerror.c ============================================================================== --- head/sys/contrib/dev/acpica/compiler/aslerror.c Thu Jun 21 22:06:57 2012 (r237411) +++ head/sys/contrib/dev/acpica/compiler/aslerror.c Fri Jun 22 00:40:44 2012 (r237412) @@ -341,7 +341,7 @@ AePrintException ( if (Gbl_VerboseErrors) { - fprintf (OutputFile, "%s %4.4d - ", + fprintf (OutputFile, "%s %4.4d -", AslErrorLevel[Enode->Level], Enode->MessageId + ((Enode->Level+1) * 1000)); } Modified: head/sys/contrib/dev/acpica/compiler/aslfiles.c ============================================================================== --- head/sys/contrib/dev/acpica/compiler/aslfiles.c Thu Jun 21 22:06:57 2012 (r237411) +++ head/sys/contrib/dev/acpica/compiler/aslfiles.c Fri Jun 22 00:40:44 2012 (r237412) @@ -754,7 +754,7 @@ FlOpenInputFile ( /* Open the input ASL file, text mode */ - FlOpenFile (ASL_FILE_INPUT, InputFilename, "r"); + FlOpenFile (ASL_FILE_INPUT, InputFilename, "rt"); AslCompilerin = Gbl_Files[ASL_FILE_INPUT].Handle; return (AE_OK); @@ -838,7 +838,7 @@ FlOpenMiscOutputFiles ( /* Open the hex file, text mode */ - FlOpenFile (ASL_FILE_HEX_OUTPUT, Filename, "w+"); + FlOpenFile (ASL_FILE_HEX_OUTPUT, Filename, "w+t"); AslCompilerSignon (ASL_FILE_HEX_OUTPUT); AslCompilerFileHeader (ASL_FILE_HEX_OUTPUT); @@ -889,7 +889,7 @@ FlOpenMiscOutputFiles ( /* Open the listing file, text mode */ - FlOpenFile (ASL_FILE_LISTING_OUTPUT, Filename, "w+"); + FlOpenFile (ASL_FILE_LISTING_OUTPUT, Filename, "w+t"); AslCompilerSignon (ASL_FILE_LISTING_OUTPUT); AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT); @@ -907,7 +907,7 @@ FlOpenMiscOutputFiles ( return (AE_ERROR); } - FlOpenFile (ASL_FILE_PREPROCESSOR, Filename, "w+b"); + FlOpenFile (ASL_FILE_PREPROCESSOR, Filename, "w+t"); } /* All done for data table compiler */ @@ -952,7 +952,7 @@ FlOpenMiscOutputFiles ( /* Open the assembly code source file, text mode */ - FlOpenFile (ASL_FILE_ASM_SOURCE_OUTPUT, Filename, "w+"); + FlOpenFile (ASL_FILE_ASM_SOURCE_OUTPUT, Filename, "w+t"); AslCompilerSignon (ASL_FILE_ASM_SOURCE_OUTPUT); AslCompilerFileHeader (ASL_FILE_ASM_SOURCE_OUTPUT); @@ -972,7 +972,7 @@ FlOpenMiscOutputFiles ( /* Open the C code source file, text mode */ - FlOpenFile (ASL_FILE_C_SOURCE_OUTPUT, Filename, "w+"); + FlOpenFile (ASL_FILE_C_SOURCE_OUTPUT, Filename, "w+t"); FlPrintFile (ASL_FILE_C_SOURCE_OUTPUT, "/*\n"); AslCompilerSignon (ASL_FILE_C_SOURCE_OUTPUT); @@ -993,7 +993,7 @@ FlOpenMiscOutputFiles ( /* Open the assembly include file, text mode */ - FlOpenFile (ASL_FILE_ASM_INCLUDE_OUTPUT, Filename, "w+"); + FlOpenFile (ASL_FILE_ASM_INCLUDE_OUTPUT, Filename, "w+t"); AslCompilerSignon (ASL_FILE_ASM_INCLUDE_OUTPUT); AslCompilerFileHeader (ASL_FILE_ASM_INCLUDE_OUTPUT); @@ -1013,7 +1013,7 @@ FlOpenMiscOutputFiles ( /* Open the C include file, text mode */ - FlOpenFile (ASL_FILE_C_INCLUDE_OUTPUT, Filename, "w+"); + FlOpenFile (ASL_FILE_C_INCLUDE_OUTPUT, Filename, "w+t"); FlPrintFile (ASL_FILE_C_INCLUDE_OUTPUT, "/*\n"); AslCompilerSignon (ASL_FILE_C_INCLUDE_OUTPUT); @@ -1034,7 +1034,7 @@ FlOpenMiscOutputFiles ( /* Open the namespace file, text mode */ - FlOpenFile (ASL_FILE_NAMESPACE_OUTPUT, Filename, "w+"); + FlOpenFile (ASL_FILE_NAMESPACE_OUTPUT, Filename, "w+t"); AslCompilerSignon (ASL_FILE_NAMESPACE_OUTPUT); AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT); Modified: head/sys/contrib/dev/acpica/compiler/asllookup.c ============================================================================== --- head/sys/contrib/dev/acpica/compiler/asllookup.c Thu Jun 21 22:06:57 2012 (r237411) +++ head/sys/contrib/dev/acpica/compiler/asllookup.c Fri Jun 22 00:40:44 2012 (r237412) @@ -1098,7 +1098,7 @@ LkNamespaceLocateBegin ( if (Message) { - sprintf (MsgBuffer, "Tag: %u bit%s, Field: %u bit%s", + sprintf (MsgBuffer, "Size mismatch, Tag: %u bit%s, Field: %u bit%s", TagBitLength, (TagBitLength > 1) ? "s" : "", FieldBitLength, (FieldBitLength > 1) ? "s" : ""); Modified: head/sys/contrib/dev/acpica/compiler/aslmain.c ============================================================================== --- head/sys/contrib/dev/acpica/compiler/aslmain.c Thu Jun 21 22:06:57 2012 (r237411) +++ head/sys/contrib/dev/acpica/compiler/aslmain.c Fri Jun 22 00:40:44 2012 (r237412) @@ -63,7 +63,7 @@ Options ( void); static void -HelpMessage ( +FilenameHelp ( void); static void @@ -170,27 +170,36 @@ Options ( ACPI_OPTION ("-g", "Get ACPI tables and write to files (*.dat)"); printf ("\nHelp:\n"); - ACPI_OPTION ("-h", "Additional help and compiler debug options"); + ACPI_OPTION ("-h", "This message"); ACPI_OPTION ("-hc", "Display operators allowed in constant expressions"); + ACPI_OPTION ("-hf", "Display help for output filename generation"); ACPI_OPTION ("-hr", "Display ACPI reserved method names"); ACPI_OPTION ("-ht", "Display currently supported ACPI table names"); + + printf ("\nDebug Options:\n"); + ACPI_OPTION ("-bf -bt", "Create debug file (full or parse tree only) (*.txt)"); + ACPI_OPTION ("-f", "Ignore errors, force creation of AML output file(s)"); + ACPI_OPTION ("-n", "Parse only, no output generation"); + ACPI_OPTION ("-ot", "Display compile times and statistics"); + ACPI_OPTION ("-x ", "Set debug level for trace output"); + ACPI_OPTION ("-z", "Do not insert new compiler ID for DataTables"); } /******************************************************************************* * - * FUNCTION: HelpMessage + * FUNCTION: FilenameHelp * * PARAMETERS: None * * RETURN: None * - * DESCRIPTION: Display help message + * DESCRIPTION: Display help message for output filename generation * ******************************************************************************/ static void -HelpMessage ( +FilenameHelp ( void) { @@ -202,17 +211,6 @@ HelpMessage ( printf (" 2) The prefix of the AMLFileName in the ASL Definition Block\n"); printf (" 3) The prefix of the input filename\n"); printf ("\n"); - - Options (); - - printf ("\nCompiler/Disassembler Debug Options:\n"); - ACPI_OPTION ("-bb -bp -bt", "Create compiler debug/trace file (*.txt)"); - ACPI_OPTION ("", "Types: Parse/Tree/Both"); - ACPI_OPTION ("-f", "Ignore errors, force creation of AML output file(s)"); - ACPI_OPTION ("-n", "Parse only, no output generation"); - ACPI_OPTION ("-ot", "Display compile times"); - ACPI_OPTION ("-x ", "Set debug level for trace output"); - ACPI_OPTION ("-z", "Do not insert new compiler ID for DataTables"); } @@ -430,13 +428,7 @@ AslDoOptions ( case 'b': /* Debug output options */ switch (AcpiGbl_Optarg[0]) { - case 'b': - AslCompilerdebug = 1; /* same as yydebug */ - DtParserdebug = 1; - PrParserdebug = 1; - break; - - case 'p': + case 'f': AslCompilerdebug = 1; /* same as yydebug */ DtParserdebug = 1; PrParserdebug = 1; @@ -530,13 +522,17 @@ AslDoOptions ( switch (AcpiGbl_Optarg[0]) { case '^': - HelpMessage (); + Usage (); exit (0); case 'c': UtDisplayConstantOpcodes (); exit (0); + case 'f': + FilenameHelp (); + exit (0); + case 'r': /* reserved names */ Modified: head/sys/contrib/dev/acpica/compiler/aslsupport.l ============================================================================== --- head/sys/contrib/dev/acpica/compiler/aslsupport.l Thu Jun 21 22:06:57 2012 (r237411) +++ head/sys/contrib/dev/acpica/compiler/aslsupport.l Fri Jun 22 00:40:44 2012 (r237412) @@ -92,19 +92,23 @@ static void AslDoLineDirective ( void) { - char c; + int c; char *Token; UINT32 LineNumber; char *Filename; + UINT32 i; /* Eat the entire line that contains the #line directive */ - while ((c = (char) input()) != '\n' && c != EOF) + Gbl_LineBufPtr = Gbl_CurrentLineBuffer; + + while ((c = input()) != '\n' && c != EOF) { - AslInsertLineBuffer (c); + *Gbl_LineBufPtr = c; + Gbl_LineBufPtr++; } - AslInsertLineBuffer (0); + *Gbl_LineBufPtr = 0; /* First argument is the actual line number */ @@ -114,10 +118,23 @@ AslDoLineDirective ( goto ResetAndExit; } - /* Convert line number. Subtract one to handle _this_ line */ + /* First argument is the line number */ LineNumber = (UINT32) UtDoConstant (Token); - FlSetLineNumber (LineNumber - 1); + + /* Emit the appropriate number of newlines */ + + Gbl_CurrentColumn = 0; + if (LineNumber > Gbl_CurrentLineNumber) + { + for (i = 0; i < (LineNumber - Gbl_CurrentLineNumber); i++) + { + FlWriteFile (ASL_FILE_SOURCE_OUTPUT, "\n", 1); + Gbl_CurrentColumn++; + } + } + + FlSetLineNumber (LineNumber); /* Second argument is the optional filename (in double quotes) */ @@ -132,7 +149,12 @@ AslDoLineDirective ( /* Third argument is not supported at this time */ ResetAndExit: - AslResetCurrentLineBuffer (); + + /* Reset globals for a new line */ + + Gbl_CurrentLineOffset += Gbl_CurrentColumn; + Gbl_CurrentColumn = 0; + Gbl_LineBufPtr = Gbl_CurrentLineBuffer; } @@ -408,8 +430,8 @@ static char AslDoComment ( void) { - char c; - char c1 = 0; + int c; + int c1 = 0; AslInsertLineBuffer ('/'); @@ -419,7 +441,7 @@ loop: /* Eat chars until end-of-comment */ - while ((c = (char) input()) != '*' && c != EOF) + while ((c = input()) != '*' && c != EOF) { AslInsertLineBuffer (c); c1 = c; @@ -446,7 +468,7 @@ loop: AslInsertLineBuffer (c); - if ((c1 = (char) input()) != '/' && c1 != EOF) + if ((c1 = input()) != '/' && c1 != EOF) { unput(c1); goto loop; @@ -489,13 +511,13 @@ static char AslDoCommentType2 ( void) { - char c; + int c; AslInsertLineBuffer ('/'); AslInsertLineBuffer ('/'); - while ((c = (char) input()) != '\n' && c != EOF) + while ((c = input()) != '\n' && c != EOF) { AslInsertLineBuffer (c); } @@ -531,7 +553,7 @@ AslDoStringLiteral ( char *StringBuffer = MsgBuffer; char *EndBuffer = MsgBuffer + ASL_MSG_BUFFER_SIZE; char *CleanString; - char StringChar; + int StringChar; UINT32 State = ASL_NORMAL_CHAR; UINT32 i = 0; UINT8 Digit; @@ -544,7 +566,7 @@ AslDoStringLiteral ( * source line buffer. */ AslInsertLineBuffer ('\"'); - while ((StringChar = (char) input()) != EOF) + while ((StringChar = input()) != EOF) { AslInsertLineBuffer (StringChar); Modified: head/sys/contrib/dev/acpica/compiler/aslutils.c ============================================================================== --- head/sys/contrib/dev/acpica/compiler/aslutils.c Thu Jun 21 22:06:57 2012 (r237411) +++ head/sys/contrib/dev/acpica/compiler/aslutils.c Fri Jun 22 00:40:44 2012 (r237412) @@ -139,7 +139,7 @@ UtDisplaySupportedTables ( /******************************************************************************* * - * FUNCTION: AcpiPsDisplayConstantOpcodes + * FUNCTION: UtDisplayConstantOpcodes * * PARAMETERS: None * @@ -172,11 +172,11 @@ UtDisplayConstantOpcodes ( * * FUNCTION: UtLocalCalloc * - * PARAMETERS: Size - Bytes to be allocated + * PARAMETERS: Size - Bytes to be allocated * - * RETURN: Pointer to the allocated memory. Guaranteed to be valid. + * RETURN: Pointer to the allocated memory. Guaranteed to be valid. * - * DESCRIPTION: Allocate zero-initialized memory. Aborts the compile on an + * DESCRIPTION: Allocate zero-initialized memory. Aborts the compile on an * allocation failure, on the assumption that nothing more can be * accomplished. * @@ -211,9 +211,9 @@ UtLocalCalloc ( * * FUNCTION: UtBeginEvent * - * PARAMETERS: Name - Ascii name of this event + * PARAMETERS: Name - Ascii name of this event * - * RETURN: Event - Event number (integer index) + * RETURN: Event number (integer index) * * DESCRIPTION: Saves the current time with this event * @@ -244,7 +244,7 @@ UtBeginEvent ( * * FUNCTION: UtEndEvent * - * PARAMETERS: Event - Event number (integer index) + * PARAMETERS: Event - Event number (integer index) * * RETURN: None * @@ -254,7 +254,7 @@ UtBeginEvent ( void UtEndEvent ( - UINT8 Event) + UINT8 Event) { if (Event >= ASL_NUM_EVENTS) @@ -272,7 +272,7 @@ UtEndEvent ( * * FUNCTION: UtHexCharToValue * - * PARAMETERS: HexChar - Hex character in Ascii + * PARAMETERS: HexChar - Hex character in Ascii * * RETURN: The binary value of the hex character * @@ -303,12 +303,13 @@ UtHexCharToValue ( * * FUNCTION: UtConvertByteToHex * - * PARAMETERS: RawByte - Binary data - * Buffer - Pointer to where the hex bytes will be stored + * PARAMETERS: RawByte - Binary data + * Buffer - Pointer to where the hex bytes will be + * stored * * RETURN: Ascii hex byte is stored in Buffer. * - * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed + * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed * with "0x" * ******************************************************************************/ @@ -331,12 +332,13 @@ UtConvertByteToHex ( * * FUNCTION: UtConvertByteToAsmHex * - * PARAMETERS: RawByte - Binary data - * Buffer - Pointer to where the hex bytes will be stored + * PARAMETERS: RawByte - Binary data + * Buffer - Pointer to where the hex bytes will be + * stored * * RETURN: Ascii hex byte is stored in Buffer. * - * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed + * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed * with "0x" * ******************************************************************************/ @@ -358,13 +360,13 @@ UtConvertByteToAsmHex ( * * FUNCTION: DbgPrint * - * PARAMETERS: Type - Type of output - * Fmt - Printf format string - * ... - variable printf list + * PARAMETERS: Type - Type of output + * Fmt - Printf format string + * ... - variable printf list * * RETURN: None * - * DESCRIPTION: Conditional print statement. Prints to stderr only if the + * DESCRIPTION: Conditional print statement. Prints to stderr only if the * debug flag is set. * ******************************************************************************/ @@ -438,7 +440,7 @@ UtPrintFormattedName ( * * FUNCTION: UtSetParseOpName * - * PARAMETERS: Op + * PARAMETERS: Op - Parse op to be named. * * RETURN: None * @@ -460,7 +462,7 @@ UtSetParseOpName ( * * FUNCTION: UtDisplaySummary * - * PARAMETERS: FileID - ID of outpout file + * PARAMETERS: FileID - ID of outpout file * * RETURN: None * @@ -571,11 +573,11 @@ UtDisplaySummary ( /******************************************************************************* * - * FUNCTION: UtDisplaySummary + * FUNCTION: UtCheckIntegerRange * - * PARAMETERS: Op - Integer parse node - * LowValue - Smallest allowed value - * HighValue - Largest allowed value + * PARAMETERS: Op - Integer parse node + * LowValue - Smallest allowed value + * HighValue - Largest allowed value * * RETURN: Op if OK, otherwise NULL * @@ -626,11 +628,11 @@ UtCheckIntegerRange ( * * FUNCTION: UtGetStringBuffer * - * PARAMETERS: Length - Size of buffer requested + * PARAMETERS: Length - Size of buffer requested * - * RETURN: Pointer to the buffer. Aborts on allocation failure + * RETURN: Pointer to the buffer. Aborts on allocation failure * - * DESCRIPTION: Allocate a string buffer. Bypass the local + * DESCRIPTION: Allocate a string buffer. Bypass the local * dynamic memory manager for performance reasons (This has a * major impact on the speed of the compiler.) * @@ -661,8 +663,8 @@ UtGetStringBuffer ( * * FUNCTION: UtInternalizeName * - * PARAMETERS: ExternalName - Name to convert - * ConvertedName - Where the converted name is returned + * PARAMETERS: ExternalName - Name to convert + * ConvertedName - Where the converted name is returned * * RETURN: Status * @@ -714,8 +716,8 @@ UtInternalizeName ( * * FUNCTION: UtPadNameWithUnderscores * - * PARAMETERS: NameSeg - Input nameseg - * PaddedNameSeg - Output padded nameseg + * PARAMETERS: NameSeg - Input nameseg + * PaddedNameSeg - Output padded nameseg * * RETURN: Padded nameseg. * @@ -752,8 +754,8 @@ UtPadNameWithUnderscores ( * * FUNCTION: UtAttachNameseg * - * PARAMETERS: Op - Parent parse node - * Name - Full ExternalName + * PARAMETERS: Op - Parent parse node + * Name - Full ExternalName * * RETURN: None; Sets the NameSeg field in parent node * @@ -809,12 +811,12 @@ UtAttachNameseg ( * * FUNCTION: UtAttachNamepathToOwner * - * PARAMETERS: Op - Parent parse node - * NameOp - Node that contains the name + * PARAMETERS: Op - Parent parse node + * NameOp - Node that contains the name * * RETURN: Sets the ExternalName and Namepath in the parent node * - * DESCRIPTION: Store the name in two forms in the parent node: The original + * DESCRIPTION: Store the name in two forms in the parent node: The original * (external) name, and the internalized name that is used within * the ACPI namespace manager. * @@ -854,11 +856,11 @@ UtAttachNamepathToOwner ( * * FUNCTION: UtDoConstant * - * PARAMETERS: String - Hex, Octal, or Decimal string + * PARAMETERS: String - Hex, Octal, or Decimal string * * RETURN: Converted Integer * - * DESCRIPTION: Convert a string to an integer. With error checking. + * DESCRIPTION: Convert a string to an integer, with error checking. * ******************************************************************************/ @@ -889,10 +891,10 @@ UtDoConstant ( * * FUNCTION: UtStrtoul64 * - * PARAMETERS: String - Null terminated string - * Terminater - Where a pointer to the terminating byte is - * returned - * Base - Radix of the string + * PARAMETERS: String - Null terminated string + * Terminater - Where a pointer to the terminating byte + * is returned + * Base - Radix of the string * * RETURN: Converted value * @@ -1072,5 +1074,3 @@ ErrorExit: return (Status); } - - Modified: head/sys/contrib/dev/acpica/compiler/dttemplate.c ============================================================================== --- head/sys/contrib/dev/acpica/compiler/dttemplate.c Thu Jun 21 22:06:57 2012 (r237411) +++ head/sys/contrib/dev/acpica/compiler/dttemplate.c Fri Jun 22 00:40:44 2012 (r237412) @@ -226,7 +226,7 @@ DtCreateAllTemplates ( } /* - * Create the "special ACPI tables: + * Create the special ACPI tables: * 1) DSDT/SSDT are AML tables, not data tables * 2) FACS and RSDP have non-standard headers */ Modified: head/sys/contrib/dev/acpica/components/debugger/dbdisply.c ============================================================================== --- head/sys/contrib/dev/acpica/components/debugger/dbdisply.c Thu Jun 21 22:06:57 2012 (r237411) +++ head/sys/contrib/dev/acpica/components/debugger/dbdisply.c Fri Jun 22 00:40:44 2012 (r237412) @@ -792,10 +792,12 @@ AcpiDbDisplayGpes ( ACPI_GPE_EVENT_INFO *GpeEventInfo; ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; char *GpeType; + ACPI_GPE_NOTIFY_INFO *Notify; UINT32 GpeIndex; UINT32 Block = 0; UINT32 i; UINT32 j; + UINT32 Count; char Buffer[80]; ACPI_BUFFER RetBuf; ACPI_STATUS Status; @@ -916,7 +918,14 @@ AcpiDbDisplayGpes ( AcpiOsPrintf ("Handler"); break; case ACPI_GPE_DISPATCH_NOTIFY: - AcpiOsPrintf ("Notify"); + Count = 0; + Notify = GpeEventInfo->Dispatch.NotifyList; + while (Notify) + { + Count++; + Notify = Notify->Next; + } + AcpiOsPrintf ("Implicit Notify on %u devices", Count); break; default: AcpiOsPrintf ("UNKNOWN: %X", Modified: head/sys/contrib/dev/acpica/components/debugger/dbexec.c ============================================================================== --- head/sys/contrib/dev/acpica/components/debugger/dbexec.c Thu Jun 21 22:06:57 2012 (r237411) +++ head/sys/contrib/dev/acpica/components/debugger/dbexec.c Fri Jun 22 00:40:44 2012 (r237412) @@ -872,8 +872,8 @@ AcpiDbMethodThread ( if (Info->InitArgs) { - AcpiDbUInt32ToHexString (Info->NumCreated, Info->IndexOfThreadStr); - AcpiDbUInt32ToHexString ((UINT32) AcpiOsGetThreadId (), Info->IdOfThreadStr); + AcpiDbUint32ToHexString (Info->NumCreated, Info->IndexOfThreadStr); + AcpiDbUint32ToHexString ((UINT32) AcpiOsGetThreadId (), Info->IdOfThreadStr); } if (Info->Threads && (Info->NumCreated < Info->NumThreads)) @@ -1063,7 +1063,7 @@ AcpiDbCreateExecutionThreads ( AcpiGbl_DbMethodInfo.ArgTypes[1] = ACPI_TYPE_INTEGER; AcpiGbl_DbMethodInfo.ArgTypes[2] = ACPI_TYPE_INTEGER; - AcpiDbUInt32ToHexString (NumThreads, AcpiGbl_DbMethodInfo.NumThreadsStr); + AcpiDbUint32ToHexString (NumThreads, AcpiGbl_DbMethodInfo.NumThreadsStr); AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); Modified: head/sys/contrib/dev/acpica/components/debugger/dbutils.c ============================================================================== --- head/sys/contrib/dev/acpica/components/debugger/dbutils.c Thu Jun 21 22:06:57 2012 (r237411) +++ head/sys/contrib/dev/acpica/components/debugger/dbutils.c Fri Jun 22 00:40:44 2012 (r237412) @@ -360,7 +360,7 @@ AcpiDbLocalNsLookup ( /******************************************************************************* * - * FUNCTION: AcpiDbUInt32ToHexString + * FUNCTION: AcpiDbUint32ToHexString * * PARAMETERS: Value - The value to be converted to string * Buffer - Buffer for result (not less than 11 bytes) @@ -375,7 +375,7 @@ AcpiDbLocalNsLookup ( ******************************************************************************/ void -AcpiDbUInt32ToHexString ( +AcpiDbUint32ToHexString ( UINT32 Value, char *Buffer) { Modified: head/sys/contrib/dev/acpica/components/disassembler/dmopcode.c ============================================================================== --- head/sys/contrib/dev/acpica/components/disassembler/dmopcode.c Thu Jun 21 22:06:57 2012 (r237411) +++ head/sys/contrib/dev/acpica/components/disassembler/dmopcode.c Fri Jun 22 00:40:44 2012 (r237412) @@ -46,6 +46,7 @@ #include #include #include +#include #ifdef ACPI_DISASSEMBLER @@ -61,6 +62,218 @@ AcpiDmMatchKeyword ( /******************************************************************************* * + * FUNCTION: AcpiDmPredefinedDescription + * + * PARAMETERS: Op - Name() parse object + * + * RETURN: None + * + * DESCRIPTION: Emit a description comment for a predefined ACPI name. + * Used for iASL compiler only. + * + ******************************************************************************/ + +void +AcpiDmPredefinedDescription ( + ACPI_PARSE_OBJECT *Op) +{ +#ifdef ACPI_ASL_COMPILER + const AH_PREDEFINED_NAME *Info; + char *NameString; + int LastCharIsDigit; + int LastCharsAreHex; + + + if (!Op) + { + return; + } + + /* Ensure that the comment field is emitted only once */ + + if (Op->Common.DisasmFlags & ACPI_PARSEOP_PREDEF_CHECKED) + { + return; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 05:01:37 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1B9B41065672; Fri, 22 Jun 2012 05:01:37 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E187A8FC0C; Fri, 22 Jun 2012 05:01: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 q5M51aJl056506; Fri, 22 Jun 2012 05:01:36 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5M51aPw056504; Fri, 22 Jun 2012 05:01:36 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201206220501.q5M51aPw056504@svn.freebsd.org> From: Alan Cox Date: Fri, 22 Jun 2012 05:01:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237414 - head/sys/amd64/amd64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 05:01:37 -0000 Author: alc Date: Fri Jun 22 05:01:36 2012 New Revision: 237414 URL: http://svn.freebsd.org/changeset/base/237414 Log: Introduce CHANGE_PV_LIST_LOCK_TO_{PHYS,VM_PAGE}() to avoid duplication of code. Modified: head/sys/amd64/amd64/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Fri Jun 22 00:41:37 2012 (r237413) +++ head/sys/amd64/amd64/pmap.c Fri Jun 22 05:01:36 2012 (r237414) @@ -173,6 +173,22 @@ __FBSDID("$FreeBSD$"); #define PHYS_TO_PV_LIST_LOCK(pa) \ (&pv_list_locks[pa_index(pa) % NPV_LIST_LOCKS]) +#define CHANGE_PV_LIST_LOCK_TO_PHYS(lockp, pa) do { \ + struct rwlock **_lockp = (lockp); \ + struct rwlock *_new_lock; \ + \ + _new_lock = PHYS_TO_PV_LIST_LOCK(pa); \ + if (_new_lock != *_lockp) { \ + if (*_lockp != NULL) \ + rw_wunlock(*_lockp); \ + *_lockp = _new_lock; \ + rw_wlock(*_lockp); \ + } \ +} while (0) + +#define CHANGE_PV_LIST_LOCK_TO_VM_PAGE(lockp, m) \ + CHANGE_PV_LIST_LOCK_TO_PHYS(lockp, VM_PAGE_TO_PHYS(m)) + #define VM_PAGE_TO_PV_LIST_LOCK(m) \ PHYS_TO_PV_LIST_LOCK(VM_PAGE_TO_PHYS(m)) @@ -2436,20 +2452,13 @@ static boolean_t pmap_try_insert_pv_entry(pmap_t pmap, vm_offset_t va, vm_page_t m, struct rwlock **lockp) { - struct rwlock *new_lock; pv_entry_t pv; rw_assert(&pvh_global_lock, RA_LOCKED); PMAP_LOCK_ASSERT(pmap, MA_OWNED); if ((pv = get_pv_entry(pmap, TRUE)) != NULL) { pv->pv_va = va; - new_lock = VM_PAGE_TO_PV_LIST_LOCK(m); - if (new_lock != *lockp) { - if (*lockp != NULL) - rw_wunlock(*lockp); - *lockp = new_lock; - rw_wlock(*lockp); - } + CHANGE_PV_LIST_LOCK_TO_VM_PAGE(lockp, m); TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_list); return (TRUE); } else @@ -2464,19 +2473,12 @@ pmap_pv_insert_pde(pmap_t pmap, vm_offse struct rwlock **lockp) { struct md_page *pvh; - struct rwlock *new_lock; pv_entry_t pv; rw_assert(&pvh_global_lock, RA_LOCKED); if ((pv = get_pv_entry(pmap, TRUE)) != NULL) { pv->pv_va = va; - new_lock = PHYS_TO_PV_LIST_LOCK(pa); - if (new_lock != *lockp) { - if (*lockp != NULL) - rw_wunlock(*lockp); - *lockp = new_lock; - rw_wlock(*lockp); - } + CHANGE_PV_LIST_LOCK_TO_PHYS(lockp, pa); pvh = pa_to_pvh(pa); TAILQ_INSERT_TAIL(&pvh->pv_list, pv, pv_list); return (TRUE); @@ -4159,7 +4161,7 @@ pmap_remove_pages(pmap_t pmap) pv_entry_t pv; struct md_page *pvh; struct pv_chunk *pc, *npc; - struct rwlock *lock, *new_lock; + struct rwlock *lock; int64_t bit; uint64_t inuse, bitmask; int allfree, field, freed, idx; @@ -4229,13 +4231,7 @@ pmap_remove_pages(pmap_t pmap) vm_page_dirty(m); } - new_lock = VM_PAGE_TO_PV_LIST_LOCK(m); - if (new_lock != lock) { - if (lock != NULL) - rw_wunlock(lock); - lock = new_lock; - rw_wlock(lock); - } + CHANGE_PV_LIST_LOCK_TO_VM_PAGE(&lock, m); /* Mark free */ pc->pc_map[field] |= bitmask; From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 05:54:34 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B0A3A1065670; Fri, 22 Jun 2012 05:54:34 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9C7698FC08; Fri, 22 Jun 2012 05:54:34 +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 q5M5sYex059526; Fri, 22 Jun 2012 05:54:34 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5M5sYwY059523; Fri, 22 Jun 2012 05:54:34 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201206220554.q5M5sYwY059523@svn.freebsd.org> From: Warner Losh Date: Fri, 22 Jun 2012 05:54:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237429 - head/sys/arm/at91 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 05:54:34 -0000 Author: imp Date: Fri Jun 22 05:54:34 2012 New Revision: 237429 URL: http://svn.freebsd.org/changeset/base/237429 Log: Move these #defines to at91reg.h (where I should have put them in the first place). Modified: head/sys/arm/at91/at91_machdep.c head/sys/arm/at91/at91reg.h Modified: head/sys/arm/at91/at91_machdep.c ============================================================================== --- head/sys/arm/at91/at91_machdep.c Fri Jun 22 05:48:53 2012 (r237428) +++ head/sys/arm/at91/at91_machdep.c Fri Jun 22 05:54:34 2012 (r237429) @@ -281,9 +281,6 @@ static const char *soc_subtype_name[] = [AT91_ST_SAM9X35] = "at91sam9x35", }; -#define AT91_DBGU0 0x0ffff200 /* Most */ -#define AT91_DBGU1 0x0fffee00 /* SAM9263, CAP9, and SAM9G45 */ - struct at91_soc_info soc_data; /* Modified: head/sys/arm/at91/at91reg.h ============================================================================== --- head/sys/arm/at91/at91reg.h Fri Jun 22 05:48:53 2012 (r237428) +++ head/sys/arm/at91/at91reg.h Fri Jun 22 05:54:34 2012 (r237429) @@ -46,6 +46,9 @@ #define AT91_SYS_BASE 0xffff000 #define AT91_SYS_SIZE 0x1000 +#define AT91_DBGU0 0x0ffff200 /* Most */ +#define AT91_DBGU1 0x0fffee00 /* SAM9263, CAP9, and SAM9G45 */ + #define AT91_DBGU_SIZE 0x200 #define DBGU_C1R (64) /* Chip ID1 Register */ #define DBGU_C2R (68) /* Chip ID2 Register */ From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 06:38:32 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 55E09106566B; Fri, 22 Jun 2012 06:38:32 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 364428FC14; Fri, 22 Jun 2012 06:38:32 +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 q5M6cW7V061429; Fri, 22 Jun 2012 06:38:32 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5M6cV4L061421; Fri, 22 Jun 2012 06:38:31 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206220638.q5M6cV4L061421@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 22 Jun 2012 06:38:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237430 - in head/sys: amd64/include arm/include i386/include ia64/include mips/include powerpc/include sparc64/include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 06:38:32 -0000 Author: kib Date: Fri Jun 22 06:38:31 2012 New Revision: 237430 URL: http://svn.freebsd.org/changeset/base/237430 Log: Reserve AT_TIMEKEEP auxv entry for providing usermode the pointer to timekeeping information. MFC after: 1 week Modified: head/sys/amd64/include/elf.h head/sys/arm/include/elf.h head/sys/i386/include/elf.h head/sys/ia64/include/elf.h head/sys/mips/include/elf.h head/sys/powerpc/include/elf.h head/sys/sparc64/include/elf.h Modified: head/sys/amd64/include/elf.h ============================================================================== --- head/sys/amd64/include/elf.h Fri Jun 22 05:54:34 2012 (r237429) +++ head/sys/amd64/include/elf.h Fri Jun 22 06:38:31 2012 (r237430) @@ -94,6 +94,7 @@ __ElfType(Auxinfo); #define AT_NCPUS 19 /* Number of CPUs. */ #define AT_PAGESIZES 20 /* Pagesizes. */ #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ #define AT_COUNT 24 /* Count of defined aux entry types. */ Modified: head/sys/arm/include/elf.h ============================================================================== --- head/sys/arm/include/elf.h Fri Jun 22 05:54:34 2012 (r237429) +++ head/sys/arm/include/elf.h Fri Jun 22 06:38:31 2012 (r237430) @@ -82,6 +82,7 @@ __ElfType(Auxinfo); #define AT_NCPUS 19 /* Number of CPUs. */ #define AT_PAGESIZES 20 /* Pagesizes. */ #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ #define AT_COUNT 24 /* Count of defined aux entry types. */ Modified: head/sys/i386/include/elf.h ============================================================================== --- head/sys/i386/include/elf.h Fri Jun 22 05:54:34 2012 (r237429) +++ head/sys/i386/include/elf.h Fri Jun 22 06:38:31 2012 (r237430) @@ -96,6 +96,7 @@ __ElfType(Auxinfo); #define AT_NCPUS 19 /* Number of CPUs. */ #define AT_PAGESIZES 20 /* Pagesizes. */ #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ #define AT_COUNT 24 /* Count of defined aux entry types. */ Modified: head/sys/ia64/include/elf.h ============================================================================== --- head/sys/ia64/include/elf.h Fri Jun 22 05:54:34 2012 (r237429) +++ head/sys/ia64/include/elf.h Fri Jun 22 06:38:31 2012 (r237430) @@ -95,6 +95,7 @@ __ElfType(Auxinfo); #define AT_NCPUS 19 /* Number of CPUs. */ #define AT_PAGESIZES 20 /* Pagesizes. */ #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ #define AT_COUNT 24 /* Count of defined aux entry types. */ Modified: head/sys/mips/include/elf.h ============================================================================== --- head/sys/mips/include/elf.h Fri Jun 22 05:54:34 2012 (r237429) +++ head/sys/mips/include/elf.h Fri Jun 22 06:38:31 2012 (r237430) @@ -278,6 +278,7 @@ __ElfType(Auxinfo); #define AT_NCPUS 19 /* Number of CPUs. */ #define AT_PAGESIZES 20 /* Pagesizes. */ #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ #define AT_COUNT 24 /* Count of defined aux entry types. */ Modified: head/sys/powerpc/include/elf.h ============================================================================== --- head/sys/powerpc/include/elf.h Fri Jun 22 05:54:34 2012 (r237429) +++ head/sys/powerpc/include/elf.h Fri Jun 22 06:38:31 2012 (r237430) @@ -106,8 +106,9 @@ __ElfType(Auxinfo); #define AT_PAGESIZES 18 /* Pagesizes. */ #define AT_PAGESIZESLEN 19 /* Number of pagesizes. */ #define AT_STACKPROT 21 /* Initial stack protection. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ -#define AT_COUNT 22 /* Count of defined aux entry types. */ +#define AT_COUNT 23 /* Count of defined aux entry types. */ /* * Relocation types. Modified: head/sys/sparc64/include/elf.h ============================================================================== --- head/sys/sparc64/include/elf.h Fri Jun 22 05:54:34 2012 (r237429) +++ head/sys/sparc64/include/elf.h Fri Jun 22 06:38:31 2012 (r237430) @@ -90,6 +90,7 @@ __ElfType(Auxinfo); #define AT_NCPUS 19 /* Number of CPUs. */ #define AT_PAGESIZES 20 /* Pagesizes. */ #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ #define AT_COUNT 24 /* Count of defined aux entry types. */ From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 06:39:29 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5356C10656E6; Fri, 22 Jun 2012 06:39:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3E8868FC15; Fri, 22 Jun 2012 06:39:29 +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 q5M6dTkb061505; Fri, 22 Jun 2012 06:39:29 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5M6dTrD061502; Fri, 22 Jun 2012 06:39:29 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206220639.q5M6dTrD061502@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 22 Jun 2012 06:39:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237431 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 06:39:29 -0000 Author: kib Date: Fri Jun 22 06:39:28 2012 New Revision: 237431 URL: http://svn.freebsd.org/changeset/base/237431 Log: Enchance the shared page chunk allocator. Do not rely on the busy state of the page from which we allocate the chunk, to protect allocator state. Use statically allocated sx lock instead. Provide more flexible KPI. In particular, allow to allocate chunk without providing initial data, and allow writes into existing allocation. Allow to get an sf buf which temporary maps the chunk, to allow sequential updates to shared page content without unmapping in between. Reviewed by: jhb Tested by: flo MFC after: 1 month Modified: head/sys/kern/kern_exec.c head/sys/sys/sysent.h Modified: head/sys/kern/kern_exec.c ============================================================================== --- head/sys/kern/kern_exec.c Fri Jun 22 06:38:31 2012 (r237430) +++ head/sys/kern/kern_exec.c Fri Jun 22 06:39:28 2012 (r237431) @@ -1512,33 +1512,81 @@ exec_unregister(execsw_arg) return (0); } +static struct sx shared_page_alloc_sx; static vm_object_t shared_page_obj; static int shared_page_free; -int -shared_page_fill(int size, int align, const char *data) +struct sf_buf * +shared_page_write_start(int base) { vm_page_t m; struct sf_buf *s; + + VM_OBJECT_LOCK(shared_page_obj); + m = vm_page_grab(shared_page_obj, OFF_TO_IDX(base), VM_ALLOC_RETRY); + VM_OBJECT_UNLOCK(shared_page_obj); + s = sf_buf_alloc(m, SFB_DEFAULT); + return (s); +} + +void +shared_page_write_end(struct sf_buf *sf) +{ + vm_page_t m; + + m = sf_buf_page(sf); + sf_buf_free(sf); + VM_OBJECT_LOCK(shared_page_obj); + vm_page_wakeup(m); + VM_OBJECT_UNLOCK(shared_page_obj); +} + +void +shared_page_write(int base, int size, const void *data) +{ + struct sf_buf *sf; vm_offset_t sk; + + sf = shared_page_write_start(base); + sk = sf_buf_kva(sf); + bcopy(data, (void *)(sk + (base & PAGE_MASK)), size); + shared_page_write_end(sf); +} + +static int +shared_page_alloc_locked(int size, int align) +{ int res; - VM_OBJECT_LOCK(shared_page_obj); - m = vm_page_grab(shared_page_obj, 0, VM_ALLOC_RETRY); res = roundup(shared_page_free, align); if (res + size >= IDX_TO_OFF(shared_page_obj->size)) res = -1; - else { - VM_OBJECT_UNLOCK(shared_page_obj); - s = sf_buf_alloc(m, SFB_DEFAULT); - sk = sf_buf_kva(s); - bcopy(data, (void *)(sk + res), size); + else shared_page_free = res + size; - sf_buf_free(s); - VM_OBJECT_LOCK(shared_page_obj); - } - vm_page_wakeup(m); - VM_OBJECT_UNLOCK(shared_page_obj); + return (res); +} + +int +shared_page_alloc(int size, int align) +{ + int res; + + sx_xlock(&shared_page_alloc_sx); + res = shared_page_alloc_locked(size, align); + sx_xunlock(&shared_page_alloc_sx); + return (res); +} + +int +shared_page_fill(int size, int align, const void *data) +{ + int res; + + sx_xlock(&shared_page_alloc_sx); + res = shared_page_alloc_locked(size, align); + if (res != -1) + shared_page_write(res, size, data); + sx_xunlock(&shared_page_alloc_sx); return (res); } @@ -1547,6 +1595,7 @@ shared_page_init(void *dummy __unused) { vm_page_t m; + sx_init(&shared_page_alloc_sx, "shpsx"); shared_page_obj = vm_pager_allocate(OBJT_PHYS, 0, PAGE_SIZE, VM_PROT_DEFAULT, 0, NULL); VM_OBJECT_LOCK(shared_page_obj); Modified: head/sys/sys/sysent.h ============================================================================== --- head/sys/sys/sysent.h Fri Jun 22 06:38:31 2012 (r237430) +++ head/sys/sys/sysent.h Fri Jun 22 06:39:28 2012 (r237431) @@ -256,8 +256,13 @@ int lkmressys(struct thread *, struct no int syscall_thread_enter(struct thread *td, struct sysent *se); void syscall_thread_exit(struct thread *td, struct sysent *se); -int shared_page_fill(int size, int align, const char *data); +struct sf_buf; +int shared_page_alloc(int size, int align); +int shared_page_fill(int size, int align, const void *data); +void shared_page_write(int base, int size, const void *data); void exec_sysvec_init(void *param); +struct sf_buf *shared_page_write_start(int base); +void shared_page_write_end(struct sf_buf *sf); #define INIT_SYSENTVEC(name, sv) \ SYSINIT(name, SI_SUB_EXEC, SI_ORDER_ANY, \ From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 06:44:22 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C768A1065673; Fri, 22 Jun 2012 06:44:22 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B30638FC16; Fri, 22 Jun 2012 06:44:22 +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 q5M6iMwA061751; Fri, 22 Jun 2012 06:44:22 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5M6iMCC061749; Fri, 22 Jun 2012 06:44:22 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201206220644.q5M6iMCC061749@svn.freebsd.org> From: Warner Losh Date: Fri, 22 Jun 2012 06:44:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237432 - head/sys/arm/at91 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 06:44:22 -0000 Author: imp Date: Fri Jun 22 06:44:22 2012 New Revision: 237432 URL: http://svn.freebsd.org/changeset/base/237432 Log: Fix a stray debug that I committed accidentally years ago... Modified: head/sys/arm/at91/at91_twi.c Modified: head/sys/arm/at91/at91_twi.c ============================================================================== --- head/sys/arm/at91/at91_twi.c Fri Jun 22 06:39:28 2012 (r237431) +++ head/sys/arm/at91/at91_twi.c Fri Jun 22 06:44:22 2012 (r237432) @@ -284,7 +284,6 @@ at91_twi_rst_card(device_t dev, u_char s WR4(sc, TWI_CR, TWI_CR_SWRST); WR4(sc, TWI_CR, TWI_CR_MSEN | TWI_CR_SVDIS); WR4(sc, TWI_CWGR, sc->cwgr); - printf("setting cwgr to %#x\n", sc->cwgr); AT91_TWI_UNLOCK(sc); return 0; From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 07:06:41 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 83C14106566B; Fri, 22 Jun 2012 07:06:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6A1B48FC0C; Fri, 22 Jun 2012 07:06:41 +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 q5M76fjg062772; Fri, 22 Jun 2012 07:06:41 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5M76fbO062751; Fri, 22 Jun 2012 07:06:41 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206220706.q5M76fbO062751@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 22 Jun 2012 07:06:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237433 - in head/sys: amd64/include arm/include conf i386/include ia64/include kern mips/include pc98/include powerpc/include sparc64/include sys x86/include x86/x86 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 07:06:41 -0000 Author: kib Date: Fri Jun 22 07:06:40 2012 New Revision: 237433 URL: http://svn.freebsd.org/changeset/base/237433 Log: Implement mechanism to export some kernel timekeeping data to usermode, using shared page. The structures and functions have vdso prefix, to indicate the intended location of the code in some future. The versioned per-algorithm data is exported in the format of struct vdso_timehands, which mostly repeats the content of in-kernel struct timehands. Usermode reading of the structure can be lockless. Compatibility export for 32bit processes on 64bit host is also provided. Kernel also provides usermode with indication about currently used timecounter, so that libc can fall back to syscall if configured timecounter is unknown to usermode code. The shared data updates are initiated both from the tc_windup(), where a fast task is queued to do the update, and from sysctl handlers which change timecounter. A manual override switch kern.timecounter.fast_gettime allows to turn off the mechanism. Only x86 architectures export the real algorithm data, and there, only for tsc timecounter. HPET counters page could be exported as well, but I prefer to not further glue the kernel and libc ABI there until proper vdso-based solution is developed. Minimal stubs neccessary for non-x86 architectures to still compile are provided. Discussed with: bde Reviewed by: jhb Tested by: flo MFC after: 1 month Added: head/sys/amd64/include/vdso.h (contents, props changed) head/sys/arm/include/vdso.h (contents, props changed) head/sys/i386/include/vdso.h (contents, props changed) head/sys/ia64/include/vdso.h (contents, props changed) head/sys/kern/subr_dummy_vdso_tc.c (contents, props changed) head/sys/mips/include/vdso.h (contents, props changed) head/sys/pc98/include/vdso.h (contents, props changed) head/sys/powerpc/include/vdso.h (contents, props changed) head/sys/sparc64/include/vdso.h (contents, props changed) head/sys/sys/vdso.h (contents, props changed) head/sys/x86/include/vdso.h (contents, props changed) Modified: head/sys/conf/files.arm head/sys/conf/files.ia64 head/sys/conf/files.mips head/sys/conf/files.powerpc head/sys/conf/files.sparc64 head/sys/kern/imgact_elf.c head/sys/kern/kern_exec.c head/sys/kern/kern_tc.c head/sys/sys/sysent.h head/sys/x86/x86/tsc.c Added: head/sys/amd64/include/vdso.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/amd64/include/vdso.h Fri Jun 22 07:06:40 2012 (r237433) @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include Added: head/sys/arm/include/vdso.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm/include/vdso.h Fri Jun 22 07:06:40 2012 (r237433) @@ -0,0 +1,34 @@ +/*- + * Copyright 2012 Konstantin Belousov . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _ARM_VDSO_H +#define _ARM_VDSO_H + +#define VDSO_TIMEHANDS_MD \ + uint32_t th_res[8]; + +#endif Modified: head/sys/conf/files.arm ============================================================================== --- head/sys/conf/files.arm Fri Jun 22 06:44:22 2012 (r237432) +++ head/sys/conf/files.arm Fri Jun 22 07:06:40 2012 (r237433) @@ -79,6 +79,7 @@ libkern/umoddi3.c standard #libkern/arm/strcmp.S standard #libkern/arm/strncmp.S standard # +kern/subr_dummy_vdso_tc.c standard board_id.h standard \ dependency "$S/arm/conf/genboardid.awk $S/arm/conf/mach-types" \ compile-with "${AWK} -f $S/arm/conf/genboardid.awk $S/arm/conf/mach-types > board_id.h" \ Modified: head/sys/conf/files.ia64 ============================================================================== --- head/sys/conf/files.ia64 Fri Jun 22 06:44:22 2012 (r237432) +++ head/sys/conf/files.ia64 Fri Jun 22 07:06:40 2012 (r237433) @@ -138,3 +138,4 @@ libkern/ia64/bswap16.S standard libkern/ia64/bswap32.S standard libkern/memmove.c standard libkern/memset.c standard +kern/subr_dummy_vdso_tc.c standard Modified: head/sys/conf/files.mips ============================================================================== --- head/sys/conf/files.mips Fri Jun 22 06:44:22 2012 (r237432) +++ head/sys/conf/files.mips Fri Jun 22 07:06:40 2012 (r237433) @@ -91,6 +91,7 @@ compat/freebsd32/freebsd32_misc.c option compat/freebsd32/freebsd32_syscalls.c optional compat_freebsd32 compat/freebsd32/freebsd32_sysent.c optional compat_freebsd32 kern/imgact_elf32.c optional compat_freebsd32 +kern/subr_dummy_vdso_tc.c standard mips/mips/freebsd32_machdep.c optional compat_freebsd32 kern/kern_clocksource.c standard Modified: head/sys/conf/files.powerpc ============================================================================== --- head/sys/conf/files.powerpc Fri Jun 22 06:44:22 2012 (r237432) +++ head/sys/conf/files.powerpc Fri Jun 22 07:06:40 2012 (r237433) @@ -61,6 +61,7 @@ dev/tsec/if_tsec.c optional tsec dev/tsec/if_tsec_fdt.c optional tsec fdt dev/uart/uart_cpu_powerpc.c optional uart aim kern/kern_clocksource.c standard +kern/subr_dummy_vdso_tc.c standard kern/syscalls.c optional ktr libkern/ashldi3.c optional powerpc libkern/ashrdi3.c optional powerpc Modified: head/sys/conf/files.sparc64 ============================================================================== --- head/sys/conf/files.sparc64 Fri Jun 22 06:44:22 2012 (r237432) +++ head/sys/conf/files.sparc64 Fri Jun 22 07:06:40 2012 (r237433) @@ -61,6 +61,7 @@ dev/syscons/scvtb.c optional sc dev/uart/uart_cpu_sparc64.c optional uart dev/uart/uart_kbd_sun.c optional uart sc kern/kern_clocksource.c standard +kern/subr_dummy_vdso_tc.c standard kern/syscalls.c optional ktr libkern/ffs.c standard libkern/ffsl.c standard Added: head/sys/i386/include/vdso.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/i386/include/vdso.h Fri Jun 22 07:06:40 2012 (r237433) @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include Added: head/sys/ia64/include/vdso.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/ia64/include/vdso.h Fri Jun 22 07:06:40 2012 (r237433) @@ -0,0 +1,41 @@ +/*- + * Copyright 2012 Konstantin Belousov . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _IA64_VDSO_H +#define _IA64_VDSO_H + +#define VDSO_TIMEHANDS_MD \ + uint32_t th_res[8]; + +#ifdef _KERNEL +#ifdef COMPAT_FREEBSD32 + +#define VDSO_TIMEHANDS_MD32 VDSO_TIMEHANDS_MD + +#endif +#endif +#endif Modified: head/sys/kern/imgact_elf.c ============================================================================== --- head/sys/kern/imgact_elf.c Fri Jun 22 06:44:22 2012 (r237432) +++ head/sys/kern/imgact_elf.c Fri Jun 22 07:06:40 2012 (r237433) @@ -1011,6 +1011,10 @@ __elfN(freebsd_fixup)(register_t **stack AUXARGS_ENTRY(pos, AT_PAGESIZES, imgp->pagesizes); AUXARGS_ENTRY(pos, AT_PAGESIZESLEN, imgp->pagesizeslen); } + if (imgp->sysent->sv_timekeep_base != 0) { + AUXARGS_ENTRY(pos, AT_TIMEKEEP, + imgp->sysent->sv_timekeep_base); + } AUXARGS_ENTRY(pos, AT_STACKPROT, imgp->sysent->sv_shared_page_obj != NULL && imgp->stack_prot != 0 ? imgp->stack_prot : imgp->sysent->sv_stackprot); Modified: head/sys/kern/kern_exec.c ============================================================================== --- head/sys/kern/kern_exec.c Fri Jun 22 06:44:22 2012 (r237432) +++ head/sys/kern/kern_exec.c Fri Jun 22 07:06:40 2012 (r237433) @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include "opt_capsicum.h" +#include "opt_compat.h" #include "opt_hwpmc_hooks.h" #include "opt_kdtrace.h" #include "opt_ktrace.h" @@ -64,6 +65,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #ifdef KTRACE @@ -1608,10 +1610,76 @@ shared_page_init(void *dummy __unused) SYSINIT(shp, SI_SUB_EXEC, SI_ORDER_FIRST, (sysinit_cfunc_t)shared_page_init, NULL); +static void +timehands_update(void *arg) +{ + struct sysentvec *sv; + struct sf_buf *sf; + struct vdso_timehands th; + struct vdso_timekeep *tk; + uint32_t enabled, idx; + + sv = arg; + sx_xlock(&shared_page_alloc_sx); + enabled = tc_fill_vdso_timehands(&th); + sf = shared_page_write_start(sv->sv_timekeep_off); + tk = (void *)(sf_buf_kva(sf) + (sv->sv_timekeep_off & PAGE_MASK)); + idx = sv->sv_timekeep_curr; + atomic_store_rel_32(&tk->tk_th[idx].th_gen, 0); + if (++idx >= VDSO_TH_NUM) + idx = 0; + sv->sv_timekeep_curr = idx; + if (++sv->sv_timekeep_gen == 0) + sv->sv_timekeep_gen = 1; + th.th_gen = 0; + if (enabled) + tk->tk_th[idx] = th; + tk->tk_enabled = enabled; + atomic_store_rel_32(&tk->tk_th[idx].th_gen, sv->sv_timekeep_gen); + tk->tk_current = idx; + shared_page_write_end(sf); + sx_xunlock(&shared_page_alloc_sx); +} + +#ifdef COMPAT_FREEBSD32 +static void +timehands_update32(void *arg) +{ + struct sysentvec *sv; + struct sf_buf *sf; + struct vdso_timekeep32 *tk; + struct vdso_timehands32 th; + uint32_t enabled, idx; + + sv = arg; + sx_xlock(&shared_page_alloc_sx); + enabled = tc_fill_vdso_timehands32(&th); + sf = shared_page_write_start(sv->sv_timekeep_off); + tk = (void *)(sf_buf_kva(sf) + (sv->sv_timekeep_off & PAGE_MASK)); + idx = sv->sv_timekeep_curr; + atomic_store_rel_32(&tk->tk_th[idx].th_gen, 0); + if (++idx >= VDSO_TH_NUM) + idx = 0; + sv->sv_timekeep_curr = idx; + if (++sv->sv_timekeep_gen == 0) + sv->sv_timekeep_gen = 1; + th.th_gen = 0; + if (enabled) + tk->tk_th[idx] = th; + tk->tk_enabled = enabled; + atomic_store_rel_32(&tk->tk_th[idx].th_gen, sv->sv_timekeep_gen); + tk->tk_current = idx; + shared_page_write_end(sf); + sx_xunlock(&shared_page_alloc_sx); +} +#endif + void exec_sysvec_init(void *param) { struct sysentvec *sv; + int tk_base; + uint32_t tk_ver; sv = (struct sysentvec *)param; @@ -1620,4 +1688,29 @@ exec_sysvec_init(void *param) sv->sv_shared_page_obj = shared_page_obj; sv->sv_sigcode_base = sv->sv_shared_page_base + shared_page_fill(*(sv->sv_szsigcode), 16, sv->sv_sigcode); + tk_ver = VDSO_TK_VER_CURR; +#ifdef COMPAT_FREEBSD32 + if ((sv->sv_flags & SV_ILP32) != 0) { + tk_base = shared_page_alloc(sizeof(struct vdso_timekeep32) + + sizeof(struct vdso_timehands32) * VDSO_TH_NUM, 16); + KASSERT(tk_base != -1, ("tk_base -1 for 32bit")); + EVENTHANDLER_REGISTER(tc_windup, timehands_update32, sv, + EVENTHANDLER_PRI_ANY); + shared_page_write(tk_base + offsetof(struct vdso_timekeep32, + tk_ver), sizeof(uint32_t), &tk_ver); + } else { +#endif + tk_base = shared_page_alloc(sizeof(struct vdso_timekeep) + + sizeof(struct vdso_timehands) * VDSO_TH_NUM, 16); + KASSERT(tk_base != -1, ("tk_base -1 for native")); + EVENTHANDLER_REGISTER(tc_windup, timehands_update, sv, + EVENTHANDLER_PRI_ANY); + shared_page_write(tk_base + offsetof(struct vdso_timekeep, + tk_ver), sizeof(uint32_t), &tk_ver); +#ifdef COMPAT_FREEBSD32 + } +#endif + sv->sv_timekeep_base = sv->sv_shared_page_base + tk_base; + sv->sv_timekeep_off = tk_base; + EVENTHANDLER_INVOKE(tc_windup); } Modified: head/sys/kern/kern_tc.c ============================================================================== --- head/sys/kern/kern_tc.c Fri Jun 22 06:44:22 2012 (r237432) +++ head/sys/kern/kern_tc.c Fri Jun 22 07:06:40 2012 (r237433) @@ -16,6 +16,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_compat.h" #include "opt_ntp.h" #include "opt_ffclock.h" @@ -30,8 +31,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include /* * A large step happens on boot. This constant detects such steps. @@ -118,8 +121,12 @@ SYSCTL_INT(_kern_timecounter, OID_AUTO, ×tepwarnings, 0, "Log time steps"); static void tc_windup(void); +static void tc_windup_push_vdso(void *ctx, int pending); static void cpu_tick_calibrate(int); +static struct task tc_windup_push_vdso_task = TASK_INITIALIZER(0, + tc_windup_push_vdso, 0); + static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) { @@ -1360,6 +1367,7 @@ tc_windup(void) #endif timehands = th; + taskqueue_enqueue_fast(taskqueue_fast, &tc_windup_push_vdso_task); } /* Report or change the active timecounter hardware. */ @@ -1386,6 +1394,7 @@ sysctl_kern_timecounter_hardware(SYSCTL_ (void)newtc->tc_get_timecount(newtc); timecounter = newtc; + EVENTHANDLER_INVOKE(tc_windup); return (0); } return (EINVAL); @@ -1844,3 +1853,78 @@ cputick2usec(uint64_t tick) } cpu_tick_f *cpu_ticks = tc_cpu_ticks; + +static int vdso_th_enable = 1; +static int +sysctl_fast_gettime(SYSCTL_HANDLER_ARGS) +{ + int old_vdso_th_enable, error; + + old_vdso_th_enable = vdso_th_enable; + error = sysctl_handle_int(oidp, &old_vdso_th_enable, 0, req); + if (error != 0) + return (error); + vdso_th_enable = old_vdso_th_enable; + EVENTHANDLER_INVOKE(tc_windup); + return (0); +} +SYSCTL_PROC(_kern_timecounter, OID_AUTO, fast_gettime, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, + NULL, 0, sysctl_fast_gettime, "I", "Enable fast time of day"); + +uint32_t +tc_fill_vdso_timehands(struct vdso_timehands *vdso_th) +{ + struct timehands *th; + uint32_t enabled; + int gen; + + do { + th = timehands; + gen = th->th_generation; + vdso_th->th_algo = VDSO_TH_ALGO_1; + vdso_th->th_scale = th->th_scale; + vdso_th->th_offset_count = th->th_offset_count; + vdso_th->th_counter_mask = th->th_counter->tc_counter_mask; + vdso_th->th_offset = th->th_offset; + vdso_th->th_boottime = boottimebin; + enabled = cpu_fill_vdso_timehands(vdso_th); + } while (gen == 0 || timehands->th_generation != gen); + if (!vdso_th_enable) + enabled = 0; + return (enabled); +} + +#ifdef COMPAT_FREEBSD32 +uint32_t +tc_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32) +{ + struct timehands *th; + uint32_t enabled; + int gen; + + do { + th = timehands; + gen = th->th_generation; + vdso_th32->th_algo = VDSO_TH_ALGO_1; + *(uint64_t *)&vdso_th32->th_scale[0] = th->th_scale; + vdso_th32->th_offset_count = th->th_offset_count; + vdso_th32->th_counter_mask = th->th_counter->tc_counter_mask; + vdso_th32->th_offset.sec = th->th_offset.sec; + *(uint64_t *)&vdso_th32->th_offset.frac[0] = th->th_offset.frac; + vdso_th32->th_boottime.sec = boottimebin.sec; + *(uint64_t *)&vdso_th32->th_boottime.frac[0] = boottimebin.frac; + enabled = cpu_fill_vdso_timehands32(vdso_th32); + } while (gen == 0 || timehands->th_generation != gen); + if (!vdso_th_enable) + enabled = 0; + return (enabled); +} +#endif + +static void +tc_windup_push_vdso(void *ctx, int pending) +{ + + EVENTHANDLER_INVOKE(tc_windup); +} Added: head/sys/kern/subr_dummy_vdso_tc.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/kern/subr_dummy_vdso_tc.c Fri Jun 22 07:06:40 2012 (r237433) @@ -0,0 +1,49 @@ +/*- + * Copyright 2012 Konstantin Belousov . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_compat.h" + +#include +#include + +uint32_t +cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th) +{ + + return (0); +} + +#ifdef COMPAT_FREEBSD32 +uint32_t +cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32) +{ + + return (0); +} +#endif Added: head/sys/mips/include/vdso.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/include/vdso.h Fri Jun 22 07:06:40 2012 (r237433) @@ -0,0 +1,41 @@ +/*- + * Copyright 2012 Konstantin Belousov . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MIPS_VDSO_H +#define _MIPS_VDSO_H + +#define VDSO_TIMEHANDS_MD \ + uint32_t th_res[8]; + +#ifdef _KERNEL +#ifdef COMPAT_FREEBSD32 + +#define VDSO_TIMEHANDS_MD32 VDSO_TIMEHANDS_MD + +#endif +#endif +#endif Added: head/sys/pc98/include/vdso.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/pc98/include/vdso.h Fri Jun 22 07:06:40 2012 (r237433) @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include Added: head/sys/powerpc/include/vdso.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/powerpc/include/vdso.h Fri Jun 22 07:06:40 2012 (r237433) @@ -0,0 +1,41 @@ +/*- + * Copyright 2012 Konstantin Belousov . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _POWERPC_VDSO_H +#define _POWERPC_VDSO_H + +#define VDSO_TIMEHANDS_MD \ + uint32_t th_res[8]; + +#ifdef _KERNEL +#ifdef COMPAT_FREEBSD32 + +#define VDSO_TIMEHANDS_MD32 VDSO_TIMEHANDS_MD + +#endif +#endif +#endif Added: head/sys/sparc64/include/vdso.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/sparc64/include/vdso.h Fri Jun 22 07:06:40 2012 (r237433) @@ -0,0 +1,34 @@ +/*- + * Copyright 2012 Konstantin Belousov . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SPARC64_VDSO_H +#define _SPARC64_VDSO_H + +#define VDSO_TIMEHANDS_MD \ + uint32_t th_res[8]; + +#endif Modified: head/sys/sys/sysent.h ============================================================================== --- head/sys/sys/sysent.h Fri Jun 22 06:44:22 2012 (r237432) +++ head/sys/sys/sysent.h Fri Jun 22 07:06:40 2012 (r237433) @@ -124,6 +124,10 @@ struct sysentvec { vm_offset_t sv_shared_page_base; vm_offset_t sv_shared_page_len; vm_offset_t sv_sigcode_base; + vm_offset_t sv_timekeep_base; + int sv_timekeep_off; + int sv_timekeep_curr; + uint32_t sv_timekeep_gen; void *sv_shared_page_obj; void (*sv_schedtail)(struct thread *); }; Added: head/sys/sys/vdso.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/sys/vdso.h Fri Jun 22 07:06:40 2012 (r237433) @@ -0,0 +1,124 @@ +/*- + * Copyright 2012 Konstantin Belousov . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SYS_VDSO_H +#define _SYS_VDSO_H + +#include +#include +#include + +struct vdso_timehands { + uint32_t th_algo; + uint32_t th_gen; + uint64_t th_scale; + uint32_t th_offset_count; + uint32_t th_counter_mask; + struct bintime th_offset; + struct bintime th_boottime; + VDSO_TIMEHANDS_MD +}; + +struct vdso_timekeep { + uint32_t tk_ver; + uint32_t tk_enabled; + uint32_t tk_current; + struct vdso_timehands tk_th[]; +}; + +#define VDSO_TK_CURRENT_BUSY 0xffffffff +#define VDSO_TK_VER_1 0x1 +#define VDSO_TK_VER_CURR VDSO_TK_VER_1 +#define VDSO_TH_ALGO_1 0x1 + +#ifndef _KERNEL + +struct timespec; +struct timeval; +struct timezone; + +int __vdso_clock_gettime(clockid_t clock_id, struct timespec *ts); +#pragma weak __vdso_clock_gettime + +int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz); +#pragma weak __vdso_gettimeofday + +u_int __vdso_gettc(const struct vdso_timehands *vdso_th); +#pragma weak __vdso_gettc + +#endif + +#ifdef _KERNEL + +uint32_t tc_fill_vdso_timehands(struct vdso_timehands *vdso_th); + +/* + * The cpu_fill_vdso_timehands() function should fill MD-part of the + * struct vdso_timehands, which is both machine- and + * timecounter-depended. The return value should be 1 if fast + * userspace timecounter is enabled by hardware, and 0 otherwise. The + * global sysctl enable override is handled by machine-independed code + * after cpu_fill_vdso_timehands() call is made. + */ +uint32_t cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th); + +typedef void (*tc_windup_fn)(void *); +EVENTHANDLER_DECLARE(tc_windup, tc_windup_fn); + +#define VDSO_TH_NUM 4 + +#ifdef COMPAT_FREEBSD32 +struct bintime32 { + uint32_t sec; + uint32_t frac[2]; +}; + +struct vdso_timehands32 { + uint32_t th_algo; + uint32_t th_gen; + uint32_t th_scale[2]; + uint32_t th_offset_count; + uint32_t th_counter_mask; + struct bintime32 th_offset; + struct bintime32 th_boottime; + VDSO_TIMEHANDS_MD32 +}; + +struct vdso_timekeep32 { + uint32_t tk_ver; + uint32_t tk_enabled; + uint32_t tk_current; + struct vdso_timehands32 tk_th[]; +}; + +uint32_t tc_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32); +uint32_t cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32); + +#endif +#endif + +#endif Added: head/sys/x86/include/vdso.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/x86/include/vdso.h Fri Jun 22 07:06:40 2012 (r237433) @@ -0,0 +1,42 @@ +/*- + * Copyright 2012 Konstantin Belousov . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _X86_VDSO_H +#define _X86_VDSO_H + +#define VDSO_TIMEHANDS_MD \ + uint32_t th_x86_shift; \ + uint32_t th_res[7]; + +#ifdef _KERNEL +#ifdef COMPAT_FREEBSD32 + +#define VDSO_TIMEHANDS_MD32 VDSO_TIMEHANDS_MD + +#endif +#endif +#endif Modified: head/sys/x86/x86/tsc.c ============================================================================== --- head/sys/x86/x86/tsc.c Fri Jun 22 06:44:22 2012 (r237432) +++ head/sys/x86/x86/tsc.c Fri Jun 22 07:06:40 2012 (r237433) @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_compat.h" #include "opt_clock.h" #include @@ -41,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -604,3 +606,23 @@ tsc_get_timecount_low(struct timecounter : "=a" (rv) : "c" ((int)(intptr_t)tc->tc_priv) : "edx"); return (rv); } + +uint32_t +cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th) +{ + + vdso_th->th_x86_shift = (int)(intptr_t)timecounter->tc_priv; + bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); + return (timecounter == &tsc_timecounter); +} + +#ifdef COMPAT_FREEBSD32 +uint32_t +cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32) +{ + + vdso_th32->th_x86_shift = (int)(intptr_t)timecounter->tc_priv; + bzero(vdso_th32->th_res, sizeof(vdso_th32->th_res)); + return (timecounter == &tsc_timecounter); +} +#endif From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 07:13:31 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 73F38106566B; Fri, 22 Jun 2012 07:13:31 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5C4268FC15; Fri, 22 Jun 2012 07:13:31 +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 q5M7DVOh063109; Fri, 22 Jun 2012 07:13:31 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5M7DVH0063098; Fri, 22 Jun 2012 07:13:31 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206220713.q5M7DVH0063098@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 22 Jun 2012 07:13:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 07:13:31 -0000 Author: kib Date: Fri Jun 22 07:13:30 2012 New Revision: 237434 URL: http://svn.freebsd.org/changeset/base/237434 Log: Use struct vdso_timehands data to implement fast gettimeofday(2) and clock_gettime(2) functions if supported. The speedup seen in microbenchmarks is in range 4x-7x depending on the hardware. Only amd64 and i386 architectures are supported. Libc uses rdtsc and kernel data to calculate current time, if enabled by kernel. Hopefully, this code is going to migrate into vdso in some future. Discussed with: bde Reviewed by: jhb Tested by: flo MFC after: 1 month Added: head/lib/libc/amd64/sys/__vdso_gettc.c (contents, props changed) head/lib/libc/i386/sys/__vdso_gettc.c (contents, props changed) head/lib/libc/sys/__vdso_gettimeofday.c (contents, props changed) head/lib/libc/sys/clock_gettime.c (contents, props changed) head/lib/libc/sys/gettimeofday.c (contents, props changed) Modified: head/lib/libc/amd64/sys/Makefile.inc head/lib/libc/gen/aux.c head/lib/libc/i386/sys/Makefile.inc head/lib/libc/include/libc_private.h head/lib/libc/sys/Makefile.inc Modified: head/lib/libc/amd64/sys/Makefile.inc ============================================================================== --- head/lib/libc/amd64/sys/Makefile.inc Fri Jun 22 07:06:40 2012 (r237433) +++ head/lib/libc/amd64/sys/Makefile.inc Fri Jun 22 07:13:30 2012 (r237434) @@ -1,7 +1,8 @@ # from: Makefile.inc,v 1.1 1993/09/03 19:04:23 jtc Exp # $FreeBSD$ -SRCS+= amd64_get_fsbase.c amd64_get_gsbase.c amd64_set_fsbase.c amd64_set_gsbase.c +SRCS+= amd64_get_fsbase.c amd64_get_gsbase.c amd64_set_fsbase.c \ + amd64_set_gsbase.c __vdso_gettc.c MDASM= vfork.S brk.S cerror.S exect.S getcontext.S pipe.S ptrace.S \ reboot.S sbrk.S setlogin.S sigreturn.S Added: head/lib/libc/amd64/sys/__vdso_gettc.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libc/amd64/sys/__vdso_gettc.c Fri Jun 22 07:13:30 2012 (r237434) @@ -0,0 +1,49 @@ +/*- + * Copyright (c) 2012 Konstantin Belousov + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +static u_int +__vdso_gettc_low(const struct vdso_timehands *th) +{ + uint32_t rv; + + __asm __volatile("rdtsc; shrd %%cl, %%edx, %0" + : "=a" (rv) : "c" (th->th_x86_shift) : "edx"); + return (rv); +} + +u_int +__vdso_gettc(const struct vdso_timehands *th) +{ + + return (th->th_x86_shift > 0 ? __vdso_gettc_low(th) : rdtsc32()); +} Modified: head/lib/libc/gen/aux.c ============================================================================== --- head/lib/libc/gen/aux.c Fri Jun 22 07:06:40 2012 (r237433) +++ head/lib/libc/gen/aux.c Fri Jun 22 07:13:30 2012 (r237434) @@ -66,6 +66,7 @@ __init_elf_aux_vector(void) static pthread_once_t aux_once = PTHREAD_ONCE_INIT; static int pagesize, osreldate, canary_len, ncpus, pagesizes_len; static char *canary, *pagesizes; +static void *timekeep; static void init_aux(void) @@ -101,6 +102,10 @@ init_aux(void) case AT_NCPUS: ncpus = aux->a_un.a_val; break; + + case AT_TIMEKEEP: + timekeep = aux->a_un.a_ptr; + break; } } } @@ -163,6 +168,16 @@ _elf_aux_info(int aux, void *buf, int bu } else res = EINVAL; break; + case AT_TIMEKEEP: + if (buflen == sizeof(void *)) { + if (timekeep != NULL) { + *(void **)buf = timekeep; + res = 0; + } else + res = ENOENT; + } else + res = EINVAL; + break; default: res = ENOENT; break; Modified: head/lib/libc/i386/sys/Makefile.inc ============================================================================== --- head/lib/libc/i386/sys/Makefile.inc Fri Jun 22 07:06:40 2012 (r237433) +++ head/lib/libc/i386/sys/Makefile.inc Fri Jun 22 07:13:30 2012 (r237434) @@ -5,7 +5,8 @@ SRCS+= i386_clr_watch.c i386_set_watch.c i386_vm86.c .endif SRCS+= i386_get_fsbase.c i386_get_gsbase.c i386_get_ioperm.c i386_get_ldt.c \ - i386_set_fsbase.c i386_set_gsbase.c i386_set_ioperm.c i386_set_ldt.c + i386_set_fsbase.c i386_set_gsbase.c i386_set_ioperm.c i386_set_ldt.c \ + __vdso_gettc.c MDASM= Ovfork.S brk.S cerror.S exect.S getcontext.S pipe.S ptrace.S \ reboot.S sbrk.S setlogin.S sigreturn.S syscall.S Added: head/lib/libc/i386/sys/__vdso_gettc.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libc/i386/sys/__vdso_gettc.c Fri Jun 22 07:13:30 2012 (r237434) @@ -0,0 +1,50 @@ +/*- + * Copyright (c) 2012 Konstantin Belousov + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +static u_int +__vdso_gettc_low(const struct vdso_timehands *th) +{ + uint32_t rv; + + __asm __volatile("rdtsc; shrd %%cl, %%edx, %0" + : "=a" (rv) : "c" (th->th_x86_shift) : "edx"); + return (rv); +} + +#pragma weak __vdso_gettc +u_int +__vdso_gettc(const struct vdso_timehands *th) +{ + + return (th->th_x86_shift > 0 ? __vdso_gettc_low(th) : rdtsc32()); +} Modified: head/lib/libc/include/libc_private.h ============================================================================== --- head/lib/libc/include/libc_private.h Fri Jun 22 07:06:40 2012 (r237433) +++ head/lib/libc/include/libc_private.h Fri Jun 22 07:13:30 2012 (r237434) @@ -34,6 +34,7 @@ #ifndef _LIBC_PRIVATE_H_ #define _LIBC_PRIVATE_H_ +#include #include /* @@ -245,6 +246,12 @@ extern void * __sys_freebsd6_mmap(void * /* Without back-compat translation */ extern int __sys_fcntl(int, int, ...); +struct timespec; +struct timeval; +struct timezone; +int __sys_gettimeofday(struct timeval *, struct timezone *); +int __sys_clock_gettime(__clockid_t, struct timespec *ts); + /* execve() with PATH processing to implement posix_spawnp() */ int _execvpe(const char *, char * const *, char * const *); Modified: head/lib/libc/sys/Makefile.inc ============================================================================== --- head/lib/libc/sys/Makefile.inc Fri Jun 22 07:06:40 2012 (r237433) +++ head/lib/libc/sys/Makefile.inc Fri Jun 22 07:13:30 2012 (r237434) @@ -15,6 +15,10 @@ # .sinclude "${.CURDIR}/${LIBC_ARCH}/sys/Makefile.inc" +SRCS+= clock_gettime.c gettimeofday.c __vdso_gettimeofday.c +NOASM+= clock_gettime.o gettimeofday.o +PSEUDO+= _clock_gettime.o _gettimeofday.o + # Sources common to both syscall interfaces: SRCS+= stack_protector.c stack_protector_compat.c __error.c .if !defined(WITHOUT_SYSCALL_COMPAT) Added: head/lib/libc/sys/__vdso_gettimeofday.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libc/sys/__vdso_gettimeofday.c Fri Jun 22 07:13:30 2012 (r237434) @@ -0,0 +1,142 @@ +/*- + * Copyright (c) 2012 Konstantin Belousov + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include "libc_private.h" + +static u_int +tc_delta(const struct vdso_timehands *th) +{ + + return ((__vdso_gettc(th) - th->th_offset_count) & + th->th_counter_mask); +} + +static int +binuptime(struct bintime *bt, struct vdso_timekeep *tk, int abs) +{ + struct vdso_timehands *th; + uint32_t curr, gen; + + do { + if (!tk->tk_enabled) + return (ENOSYS); + + /* + * XXXKIB. The load of tk->tk_current should use + * atomic_load_acq_32 to provide load barrier. But + * since tk points to r/o mapped page, x86 + * implementation of atomic_load_acq faults. + */ + curr = tk->tk_current; + rmb(); + th = &tk->tk_th[curr]; + if (th->th_algo != VDSO_TH_ALGO_1) + return (ENOSYS); + gen = th->th_gen; + *bt = th->th_offset; + bintime_addx(bt, th->th_scale * tc_delta(th)); + if (abs) + bintime_add(bt, &th->th_boottime); + + /* + * Barrier for load of both tk->tk_current and th->th_gen. + */ + rmb(); + } while (curr != tk->tk_current || gen == 0 || gen != th->th_gen); + return (0); +} + +static struct vdso_timekeep *tk; + +int +__vdso_gettimeofday(struct timeval *tv, struct timezone *tz) +{ + struct bintime bt; + int error; + + if (tz != NULL) + return (ENOSYS); + if (tk == NULL) { + error = _elf_aux_info(AT_TIMEKEEP, &tk, sizeof(tk)); + if (error != 0 || tk == NULL) + return (ENOSYS); + } + if (tk->tk_ver != VDSO_TK_VER_CURR) + return (ENOSYS); + error = binuptime(&bt, tk, 1); + if (error != 0) + return (error); + bintime2timeval(&bt, tv); + return (0); +} + +int +__vdso_clock_gettime(clockid_t clock_id, struct timespec *ts) +{ + struct bintime bt; + int abs, error; + + if (tk == NULL) { + error = _elf_aux_info(AT_TIMEKEEP, &tk, sizeof(tk)); + if (error != 0 || tk == NULL) + return (ENOSYS); + } + if (tk->tk_ver != VDSO_TK_VER_CURR) + return (ENOSYS); + switch (clock_id) { + case CLOCK_REALTIME: + case CLOCK_REALTIME_PRECISE: + case CLOCK_REALTIME_FAST: + case CLOCK_SECOND: + abs = 1; + break; + case CLOCK_MONOTONIC: + case CLOCK_MONOTONIC_PRECISE: + case CLOCK_MONOTONIC_FAST: + case CLOCK_UPTIME: + case CLOCK_UPTIME_PRECISE: + case CLOCK_UPTIME_FAST: + abs = 0; + break; + default: + return (ENOSYS); + } + error = binuptime(&bt, tk, abs); + if (error != 0) + return (error); + bintime2timespec(&bt, ts); + if (clock_id == CLOCK_SECOND) + ts->tv_nsec = 0; + return (0); +} Added: head/lib/libc/sys/clock_gettime.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libc/sys/clock_gettime.c Fri Jun 22 07:13:30 2012 (r237434) @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 2012 Konstantin Belousov + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include "libc_private.h" + +int __clock_gettime(clockid_t, struct timespec *ts); + +__weak_reference(__clock_gettime, clock_gettime); + +int +__clock_gettime(clockid_t clock_id, struct timespec *ts) +{ + int error; + + if (__vdso_clock_gettime != NULL && __vdso_gettc != NULL) + error = __vdso_clock_gettime(clock_id, ts); + else + error = ENOSYS; + if (error == ENOSYS) + error = __sys_clock_gettime(clock_id, ts); + return (error); +} Added: head/lib/libc/sys/gettimeofday.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libc/sys/gettimeofday.c Fri Jun 22 07:13:30 2012 (r237434) @@ -0,0 +1,51 @@ +/*- + * Copyright (c) 2012 Konstantin Belousov + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include "libc_private.h" + +int __gettimeofday(struct timeval *tv, struct timezone *tz); + +__weak_reference(__gettimeofday, gettimeofday); + +int +__gettimeofday(struct timeval *tv, struct timezone *tz) +{ + int error; + + if (__vdso_gettimeofday != NULL && __vdso_gettc != NULL) + error = __vdso_gettimeofday(tv, tz); + else + error = ENOSYS; + if (error == ENOSYS) + error = __sys_gettimeofday(tv, tz); + return (error); +} From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 07:16:30 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 91443106566C; Fri, 22 Jun 2012 07:16:30 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7C53E8FC14; Fri, 22 Jun 2012 07:16:30 +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 q5M7GUIq063281; Fri, 22 Jun 2012 07:16:30 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5M7GUCQ063278; Fri, 22 Jun 2012 07:16:30 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206220716.q5M7GUCQ063278@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 22 Jun 2012 07:16:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237435 - in head/sys/i386: i386 include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 07:16:30 -0000 Author: kib Date: Fri Jun 22 07:16:29 2012 New Revision: 237435 URL: http://svn.freebsd.org/changeset/base/237435 Log: Enable shared page on i386, now it has a use for vdso_timehands. MFC after: 1 month Modified: head/sys/i386/i386/elf_machdep.c head/sys/i386/include/vmparam.h Modified: head/sys/i386/i386/elf_machdep.c ============================================================================== --- head/sys/i386/i386/elf_machdep.c Fri Jun 22 07:13:30 2012 (r237434) +++ head/sys/i386/i386/elf_machdep.c Fri Jun 22 07:16:29 2012 (r237435) @@ -74,12 +74,15 @@ struct sysentvec elf32_freebsd_sysvec = .sv_setregs = exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, - .sv_flags = SV_ABI_FREEBSD | SV_IA32 | SV_ILP32, + .sv_flags = SV_ABI_FREEBSD | SV_IA32 | SV_ILP32 | SV_SHP, .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, + .sv_shared_page_base = SHAREDPAGE, + .sv_shared_page_len = PAGE_SIZE, .sv_schedtail = NULL, }; +INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec); static Elf32_Brandinfo freebsd_brand_info = { .brand = ELFOSABI_FREEBSD, Modified: head/sys/i386/include/vmparam.h ============================================================================== --- head/sys/i386/include/vmparam.h Fri Jun 22 07:13:30 2012 (r237434) +++ head/sys/i386/include/vmparam.h Fri Jun 22 07:16:29 2012 (r237435) @@ -165,7 +165,8 @@ #define VM_MAXUSER_ADDRESS VADDR(PTDPTDI, 0) -#define USRSTACK VM_MAXUSER_ADDRESS +#define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) +#define USRSTACK SHAREDPAGE #define VM_MAX_ADDRESS VADDR(PTDPTDI, PTDPTDI) #define VM_MIN_ADDRESS ((vm_offset_t)0) From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 07:34:58 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4397C106566C; Fri, 22 Jun 2012 07:34:58 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id CD8058FC0A; Fri, 22 Jun 2012 07:34:57 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.4/8.14.4/ALCHEMY.FRANKEN.DE) with ESMTP id q5M7YuVn032715; Fri, 22 Jun 2012 09:34:56 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.4/8.14.4/Submit) id q5M7YuwM032714; Fri, 22 Jun 2012 09:34:56 +0200 (CEST) (envelope-from marius) Date: Fri, 22 Jun 2012 09:34:56 +0200 From: Marius Strobl To: Konstantin Belousov Message-ID: <20120622073455.GE69382@alchemy.franken.de> References: <201206220713.q5M7DVH0063098@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201206220713.q5M7DVH0063098@svn.freebsd.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 07:34:58 -0000 On Fri, Jun 22, 2012 at 07:13:31AM +0000, Konstantin Belousov wrote: > Author: kib > Date: Fri Jun 22 07:13:30 2012 > New Revision: 237434 > URL: http://svn.freebsd.org/changeset/base/237434 > > Log: > Use struct vdso_timehands data to implement fast gettimeofday(2) and > clock_gettime(2) functions if supported. The speedup seen in > microbenchmarks is in range 4x-7x depending on the hardware. > > Only amd64 and i386 architectures are supported. Libc uses rdtsc and > kernel data to calculate current time, if enabled by kernel. I don't know much about x86 CPUs but is my understanding correct that TSCs are not synchronized in any way across CPUs, i.e. reading it on different CPUs may result in time going backwards etc., which is okay for this application though? Marius From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 07:48:37 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DB4651065670; Fri, 22 Jun 2012 07:48:36 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 7663D8FC15; Fri, 22 Jun 2012 07:48:36 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q5M7mHXN093337; Fri, 22 Jun 2012 10:48:17 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q5M7mHEb040779; Fri, 22 Jun 2012 10:48:17 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q5M7mHvo040778; Fri, 22 Jun 2012 10:48:17 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 22 Jun 2012 10:48:17 +0300 From: Konstantin Belousov To: Marius Strobl Message-ID: <20120622074817.GA2337@deviant.kiev.zoral.com.ua> References: <201206220713.q5M7DVH0063098@svn.freebsd.org> <20120622073455.GE69382@alchemy.franken.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="BhCmZxNx01sRldsR" Content-Disposition: inline In-Reply-To: <20120622073455.GE69382@alchemy.franken.de> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 07:48:37 -0000 --BhCmZxNx01sRldsR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 22, 2012 at 09:34:56AM +0200, Marius Strobl wrote: > On Fri, Jun 22, 2012 at 07:13:31AM +0000, Konstantin Belousov wrote: > > Author: kib > > Date: Fri Jun 22 07:13:30 2012 > > New Revision: 237434 > > URL: http://svn.freebsd.org/changeset/base/237434 > >=20 > > Log: > > Use struct vdso_timehands data to implement fast gettimeofday(2) and > > clock_gettime(2) functions if supported. The speedup seen in > > microbenchmarks is in range 4x-7x depending on the hardware. > > =20 > > Only amd64 and i386 architectures are supported. Libc uses rdtsc and > > kernel data to calculate current time, if enabled by kernel. >=20 > I don't know much about x86 CPUs but is my understanding correct > that TSCs are not synchronized in any way across CPUs, i.e. > reading it on different CPUs may result in time going backwards > etc., which is okay for this application though? Generally speaking, tsc state among different CPU after boot is not synchronized, you are right. Kernel has somewhat doubtful test which verifies whether the after-boot state of tsc looks good. If the test fails, TSC is not enabled by default as timecounter, and then usermode follows kernel policy and falls back to slow syscall. So we err on the safe side. I tested this on Core i7 2xxx, where the test (usually) passes. The test we currently have fails for me at least on single-package Nehalems, where the counter should be located on uncore part. This indicates some brokeness in the code, but I did not investigated the cause. The code can be developed which adjusts tsc msrs to be in sync. Or, rtdscp instruction can be used, which allow to handle counter skew in usermode in race-free manner. While you are there. do you have comments about sparc64 TICK counter ? On SMP, the counter of BSP is used by IPI. Is it unavoidable ? --BhCmZxNx01sRldsR Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/kI0EACgkQC3+MBN1Mb4jh9QCgnhWmDbvxGgbSNaOSUQ98p/wZ 5GIAnApRbgba9UHQIdftXy8A4CmfAAYH =kE+o -----END PGP SIGNATURE----- --BhCmZxNx01sRldsR-- From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 07:51:15 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A39181065676; Fri, 22 Jun 2012 07:51:15 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8BD818FC21; Fri, 22 Jun 2012 07:51:15 +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 q5M7pFEw064767; Fri, 22 Jun 2012 07:51:15 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5M7pF0k064763; Fri, 22 Jun 2012 07:51:15 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201206220751.q5M7pF0k064763@svn.freebsd.org> From: Navdeep Parhar Date: Fri, 22 Jun 2012 07:51:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237436 - in head/sys/dev/cxgbe: . common firmware tom X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 07:51:15 -0000 Author: np Date: Fri Jun 22 07:51:15 2012 New Revision: 237436 URL: http://svn.freebsd.org/changeset/base/237436 Log: cxgbe(4): update to firmware interface 1.5.2.0; updates to shared code. Modified: head/sys/dev/cxgbe/common/common.h head/sys/dev/cxgbe/common/t4_hw.c head/sys/dev/cxgbe/common/t4_msg.h head/sys/dev/cxgbe/firmware/t4fw_cfg.txt head/sys/dev/cxgbe/firmware/t4fw_cfg_uwire.txt head/sys/dev/cxgbe/firmware/t4fw_interface.h head/sys/dev/cxgbe/osdep.h head/sys/dev/cxgbe/t4_sge.c head/sys/dev/cxgbe/tom/t4_cpl_io.c Modified: head/sys/dev/cxgbe/common/common.h ============================================================================== --- head/sys/dev/cxgbe/common/common.h Fri Jun 22 07:16:29 2012 (r237435) +++ head/sys/dev/cxgbe/common/common.h Fri Jun 22 07:51:15 2012 (r237436) @@ -38,6 +38,8 @@ enum { SERNUM_LEN = 24, /* Serial # length */ EC_LEN = 16, /* E/C length */ ID_LEN = 16, /* ID length */ + PN_LEN = 16, /* Part Number length */ + MACADDR_LEN = 12, /* MAC Address length */ }; enum { MEM_EDC0, MEM_EDC1, MEM_MC }; @@ -62,8 +64,8 @@ enum { }; #define FW_VERSION_MAJOR 1 -#define FW_VERSION_MINOR 4 -#define FW_VERSION_MICRO 16 +#define FW_VERSION_MINOR 5 +#define FW_VERSION_MICRO 2 struct port_stats { u64 tx_octets; /* total # of octets in good frames */ @@ -219,6 +221,8 @@ struct vpd_params { u8 ec[EC_LEN + 1]; u8 sn[SERNUM_LEN + 1]; u8 id[ID_LEN + 1]; + u8 pn[PN_LEN + 1]; + u8 na[MACADDR_LEN + 1]; }; struct pci_params { @@ -356,6 +360,8 @@ void t4_write_indirect(struct adapter *a unsigned int data_reg, const u32 *vals, unsigned int nregs, unsigned int start_idx); +u32 t4_hw_pci_read_cfg4(adapter_t *adapter, int reg); + struct fw_filter_wr; void t4_intr_enable(struct adapter *adapter); @@ -374,7 +380,7 @@ int t4_seeprom_wp(struct adapter *adapte int t4_read_flash(struct adapter *adapter, unsigned int addr, unsigned int nwords, u32 *data, int byte_oriented); int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size); -int t4_load_boot(struct adapter *adap, const u8 *boot_data, +int t4_load_boot(struct adapter *adap, u8 *boot_data, unsigned int boot_addr, unsigned int size); unsigned int t4_flash_cfg_addr(struct adapter *adapter); int t4_load_cfg(struct adapter *adapter, const u8 *cfg_data, unsigned int size); @@ -431,6 +437,9 @@ int t4_mem_read(struct adapter *adap, in __be32 *data); void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p); +void t4_get_port_stats_offset(struct adapter *adap, int idx, + struct port_stats *stats, + struct port_stats *offset); void t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p); void t4_clr_port_stats(struct adapter *adap, int idx); @@ -472,6 +481,10 @@ int t4_fw_hello(struct adapter *adap, un enum dev_master master, enum dev_state *state); int t4_fw_bye(struct adapter *adap, unsigned int mbox); int t4_fw_reset(struct adapter *adap, unsigned int mbox, int reset); +int t4_fw_halt(struct adapter *adap, unsigned int mbox, int force); +int t4_fw_restart(struct adapter *adap, unsigned int mbox, int reset); +int t4_fw_upgrade(struct adapter *adap, unsigned int mbox, + const u8 *fw_data, unsigned int size, int force); int t4_fw_initialize(struct adapter *adap, unsigned int mbox); int t4_query_params(struct adapter *adap, unsigned int mbox, unsigned int pf, unsigned int vf, unsigned int nparams, const u32 *params, @@ -484,6 +497,10 @@ int t4_cfg_pfvf(struct adapter *adap, un unsigned int rxqi, unsigned int rxq, unsigned int tc, unsigned int vi, unsigned int cmask, unsigned int pmask, unsigned int exactf, unsigned int rcaps, unsigned int wxcaps); +int t4_alloc_vi_func(struct adapter *adap, unsigned int mbox, + unsigned int port, unsigned int pf, unsigned int vf, + unsigned int nmac, u8 *mac, unsigned int *rss_size, + unsigned int portfunc, unsigned int idstype); int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port, unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac, unsigned int *rss_size); @@ -524,5 +541,10 @@ int t4_sge_ctxt_rd(struct adapter *adap, enum ctxt_type ctype, u32 *data); int t4_sge_ctxt_rd_bd(struct adapter *adap, unsigned int cid, enum ctxt_type ctype, u32 *data); +int t4_sge_ctxt_flush(struct adapter *adap, unsigned int mbox); int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl); +int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox, u32 addr, u32 val); +int t4_config_scheduler(struct adapter *adapter, int mode, int level, int pktsize, + int sched_class, int port, int rate, int unit, + int weight, int minrate, int maxrate); #endif /* __CHELSIO_COMMON_H */ Modified: head/sys/dev/cxgbe/common/t4_hw.c ============================================================================== --- head/sys/dev/cxgbe/common/t4_hw.c Fri Jun 22 07:16:29 2012 (r237435) +++ head/sys/dev/cxgbe/common/t4_hw.c Fri Jun 22 07:51:15 2012 (r237436) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011 Chelsio Communications, Inc. + * Copyright (c) 2012 Chelsio Communications, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -135,6 +135,20 @@ void t4_write_indirect(struct adapter *a } /* + * Read a 32-bit PCI Configuration Space register via the PCI-E backdoor + * mechanism. This guarantees that we get the real value even if we're + * operating within a Virtual Machine and the Hypervisor is trapping our + * Configuration Space accesses. + */ +u32 t4_hw_pci_read_cfg4(adapter_t *adap, int reg) +{ + t4_write_reg(adap, A_PCIE_CFG_SPACE_REQ, + F_ENABLE | F_LOCALCFG | V_FUNCTION(adap->pf) | + V_REGISTER(reg)); + return t4_read_reg(adap, A_PCIE_CFG_SPACE_DATA); +} + +/* * Get the reply to a mailbox command and store it in @rpl in big-endian order. */ static void get_mbox_rpl(struct adapter *adap, __be64 *rpl, int nflit, @@ -196,7 +210,6 @@ int t4_wr_mbox_meat(struct adapter *adap u64 res; int i, ms, delay_idx; const __be64 *p = cmd; - u32 data_reg = PF_REG(mbox, A_CIM_PF_MAILBOX_DATA); u32 ctl_reg = PF_REG(mbox, A_CIM_PF_MAILBOX_CTRL); @@ -283,7 +296,7 @@ int t4_mc_read(struct adapter *adap, u32 #define MC_DATA(i) MC_BIST_STATUS_REG(A_MC_BIST_STATUS_RDATA, i) for (i = 15; i >= 0; i--) - *data++ = htonl(t4_read_reg(adap, MC_DATA(i))); + *data++ = ntohl(t4_read_reg(adap, MC_DATA(i))); if (ecc) *ecc = t4_read_reg64(adap, MC_DATA(16)); #undef MC_DATA @@ -321,7 +334,7 @@ int t4_edc_read(struct adapter *adap, in #define EDC_DATA(i) (EDC_BIST_STATUS_REG(A_EDC_BIST_STATUS_RDATA, i) + idx) for (i = 15; i >= 0; i--) - *data++ = htonl(t4_read_reg(adap, EDC_DATA(i))); + *data++ = ntohl(t4_read_reg(adap, EDC_DATA(i))); if (ecc) *ecc = t4_read_reg64(adap, EDC_DATA(16)); #undef EDC_DATA @@ -566,7 +579,7 @@ static int get_vpd_keyword_val(const str static int get_vpd_params(struct adapter *adapter, struct vpd_params *p) { int i, ret, addr; - int ec, sn; + int ec, sn, pn, na; u8 vpd[VPD_LEN], csum; const struct t4_vpd_hdr *v; @@ -602,6 +615,8 @@ static int get_vpd_params(struct adapter } FIND_VPD_KW(ec, "EC"); FIND_VPD_KW(sn, "SN"); + FIND_VPD_KW(pn, "PN"); + FIND_VPD_KW(na, "NA"); #undef FIND_VPD_KW memcpy(p->id, v->id_data, ID_LEN); @@ -611,6 +626,10 @@ static int get_vpd_params(struct adapter i = vpd[sn - VPD_INFO_FLD_HDR_SIZE + 2]; memcpy(p->sn, vpd + sn, min(i, SERNUM_LEN)); strstrip(p->sn); + memcpy(p->pn, vpd + pn, min(i, PN_LEN)); + strstrip((char *)p->pn); + memcpy(p->na, vpd + na, min(i, MACADDR_LEN)); + strstrip((char *)p->na); return 0; } @@ -954,7 +973,7 @@ int t4_load_cfg(struct adapter *adap, co if (ret || size == 0) goto out; - /* this will write to the flash up to SF_PAGE_SIZE at a time */ + /* this will write to the flash up to SF_PAGE_SIZE at a time */ for (i = 0; i< size; i+= SF_PAGE_SIZE) { if ( (size - i) < SF_PAGE_SIZE) n = size - i; @@ -1056,42 +1075,209 @@ out: return ret; } -/* BIOS boot header */ -typedef struct boot_header_s { - u8 signature[2]; /* signature */ - u8 length; /* image length (include header) */ - u8 offset[4]; /* initialization vector */ - u8 reserved[19]; /* reserved */ - u8 exheader[2]; /* offset to expansion header */ -} boot_header_t; +/* BIOS boot headers */ +typedef struct pci_expansion_rom_header { + u8 signature[2]; /* ROM Signature. Should be 0xaa55 */ + u8 reserved[22]; /* Reserved per processor Architecture data */ + u8 pcir_offset[2]; /* Offset to PCI Data Structure */ +} pci_exp_rom_header_t; /* PCI_EXPANSION_ROM_HEADER */ + +/* Legacy PCI Expansion ROM Header */ +typedef struct legacy_pci_expansion_rom_header { + u8 signature[2]; /* ROM Signature. Should be 0xaa55 */ + u8 size512; /* Current Image Size in units of 512 bytes */ + u8 initentry_point[4]; + u8 cksum; /* Checksum computed on the entire Image */ + u8 reserved[16]; /* Reserved */ + u8 pcir_offset[2]; /* Offset to PCI Data Struture */ +} legacy_pci_exp_rom_header_t; /* LEGACY_PCI_EXPANSION_ROM_HEADER */ + +/* EFI PCI Expansion ROM Header */ +typedef struct efi_pci_expansion_rom_header { + u8 signature[2]; // ROM signature. The value 0xaa55 + u8 initialization_size[2]; /* Units 512. Includes this header */ + u8 efi_signature[4]; /* Signature from EFI image header. 0x0EF1 */ + u8 efi_subsystem[2]; /* Subsystem value for EFI image header */ + u8 efi_machine_type[2]; /* Machine type from EFI image header */ + u8 compression_type[2]; /* Compression type. */ + /* + * Compression type definition + * 0x0: uncompressed + * 0x1: Compressed + * 0x2-0xFFFF: Reserved + */ + u8 reserved[8]; /* Reserved */ + u8 efi_image_header_offset[2]; /* Offset to EFI Image */ + u8 pcir_offset[2]; /* Offset to PCI Data Structure */ +} efi_pci_exp_rom_header_t; /* EFI PCI Expansion ROM Header */ + +/* PCI Data Structure Format */ +typedef struct pcir_data_structure { /* PCI Data Structure */ + u8 signature[4]; /* Signature. The string "PCIR" */ + u8 vendor_id[2]; /* Vendor Identification */ + u8 device_id[2]; /* Device Identification */ + u8 vital_product[2]; /* Pointer to Vital Product Data */ + u8 length[2]; /* PCIR Data Structure Length */ + u8 revision; /* PCIR Data Structure Revision */ + u8 class_code[3]; /* Class Code */ + u8 image_length[2]; /* Image Length. Multiple of 512B */ + u8 code_revision[2]; /* Revision Level of Code/Data */ + u8 code_type; /* Code Type. */ + /* + * PCI Expansion ROM Code Types + * 0x00: Intel IA-32, PC-AT compatible. Legacy + * 0x01: Open Firmware standard for PCI. FCODE + * 0x02: Hewlett-Packard PA RISC. HP reserved + * 0x03: EFI Image. EFI + * 0x04-0xFF: Reserved. + */ + u8 indicator; /* Indicator. Identifies the last image in the ROM */ + u8 reserved[2]; /* Reserved */ +} pcir_data_t; /* PCI__DATA_STRUCTURE */ +/* BOOT constants */ enum { BOOT_FLASH_BOOT_ADDR = 0x0,/* start address of boot image in flash */ BOOT_SIGNATURE = 0xaa55, /* signature of BIOS boot ROM */ BOOT_SIZE_INC = 512, /* image size measured in 512B chunks */ - BOOT_MIN_SIZE = sizeof(boot_header_t), /* at least basic header */ - BOOT_MAX_SIZE = 1024*BOOT_SIZE_INC /* 1 byte * length increment */ + BOOT_MIN_SIZE = sizeof(pci_exp_rom_header_t), /* basic header */ + BOOT_MAX_SIZE = 1024*BOOT_SIZE_INC, /* 1 byte * length increment */ + VENDOR_ID = 0x1425, /* Vendor ID */ + PCIR_SIGNATURE = 0x52494350 /* PCIR signature */ }; /* + * modify_device_id - Modifies the device ID of the Boot BIOS image + * @adatper: the device ID to write. + * @boot_data: the boot image to modify. + * + * Write the supplied device ID to the boot BIOS image. + */ +static void modify_device_id(int device_id, u8 *boot_data) +{ + legacy_pci_exp_rom_header_t *header; + pcir_data_t *pcir_header; + u32 cur_header = 0; + + /* + * Loop through all chained images and change the device ID's + */ + while (1) { + header = (legacy_pci_exp_rom_header_t *) &boot_data[cur_header]; + pcir_header = (pcir_data_t *) &boot_data[cur_header + + le16_to_cpu(*(u16*)header->pcir_offset)]; + + /* + * Only modify the Device ID if code type is Legacy or HP. + * 0x00: Okay to modify + * 0x01: FCODE. Do not be modify + * 0x03: Okay to modify + * 0x04-0xFF: Do not modify + */ + if (pcir_header->code_type == 0x00) { + u8 csum = 0; + int i; + + /* + * Modify Device ID to match current adatper + */ + *(u16*) pcir_header->device_id = device_id; + + /* + * Set checksum temporarily to 0. + * We will recalculate it later. + */ + header->cksum = 0x0; + + /* + * Calculate and update checksum + */ + for (i = 0; i < (header->size512 * 512); i++) + csum += (u8)boot_data[cur_header + i]; + + /* + * Invert summed value to create the checksum + * Writing new checksum value directly to the boot data + */ + boot_data[cur_header + 7] = -csum; + + } else if (pcir_header->code_type == 0x03) { + + /* + * Modify Device ID to match current adatper + */ + *(u16*) pcir_header->device_id = device_id; + + } + + + /* + * Check indicator element to identify if this is the last + * image in the ROM. + */ + if (pcir_header->indicator & 0x80) + break; + + /* + * Move header pointer up to the next image in the ROM. + */ + cur_header += header->size512 * 512; + } +} + +/* * t4_load_boot - download boot flash * @adapter: the adapter * @boot_data: the boot image to write + * @boot_addr: offset in flash to write boot_data * @size: image size * * Write the supplied boot image to the card's serial flash. * The boot image has the following sections: a 28-byte header and the * boot image. */ -int t4_load_boot(struct adapter *adap, const u8 *boot_data, +int t4_load_boot(struct adapter *adap, u8 *boot_data, unsigned int boot_addr, unsigned int size) { + pci_exp_rom_header_t *header; + int pcir_offset ; + pcir_data_t *pcir_header; int ret, addr; + uint16_t device_id; unsigned int i; unsigned int boot_sector = boot_addr * 1024; unsigned int sf_sec_size = adap->params.sf_size / adap->params.sf_nsec; /* + * Make sure the boot image does not encroach on the firmware region + */ + if ((boot_sector + size) >> 16 > FLASH_FW_START_SEC) { + CH_ERR(adap, "boot image encroaching on firmware region\n"); + return -EFBIG; + } + + /* + * Number of sectors spanned + */ + i = DIV_ROUND_UP(size ? size : FLASH_BOOTCFG_MAX_SIZE, + sf_sec_size); + ret = t4_flash_erase_sectors(adap, boot_sector >> 16, + (boot_sector >> 16) + i - 1); + + /* + * If size == 0 then we're simply erasing the FLASH sectors associated + * with the on-adapter option ROM file + */ + if (ret || (size == 0)) + goto out; + + /* Get boot header */ + header = (pci_exp_rom_header_t *)boot_data; + pcir_offset = le16_to_cpu(*(u16 *)header->pcir_offset); + /* PCIR Data Structure */ + pcir_header = (pcir_data_t *) &boot_data[pcir_offset]; + + /* * Perform some primitive sanity testing to avoid accidentally * writing garbage over the boot sectors. We ought to check for * more but it's not worth it for now ... @@ -1102,18 +1288,46 @@ int t4_load_boot(struct adapter *adap, c } /* - * Make sure the boot image does not encroach on the firmware region + * Check BOOT ROM header signature */ - if ((boot_sector + size) >> 16 > FLASH_FW_START_SEC) { - CH_ERR(adap, "boot image encroaching on firmware region\n"); - return -EFBIG; + if (le16_to_cpu(*(u16*)header->signature) != BOOT_SIGNATURE ) { + CH_ERR(adap, "Boot image missing signature\n"); + return -EINVAL; } - i = DIV_ROUND_UP(size, sf_sec_size); /* # of sectors spanned */ - ret = t4_flash_erase_sectors(adap, boot_sector >> 16, - (boot_sector >> 16) + i - 1); - if (ret) - goto out; + /* + * Check PCI header signature + */ + if (le32_to_cpu(*(u32*)pcir_header->signature) != PCIR_SIGNATURE) { + CH_ERR(adap, "PCI header missing signature\n"); + return -EINVAL; + } + + /* + * Check Vendor ID matches Chelsio ID + */ + if (le16_to_cpu(*(u16*)pcir_header->vendor_id) != VENDOR_ID) { + CH_ERR(adap, "Vendor ID missing signature\n"); + return -EINVAL; + } + + /* + * Retrieve adapter's device ID + */ + t4_os_pci_read_cfg2(adap, PCI_DEVICE_ID, &device_id); + /* Want to deal with PF 0 so I strip off PF 4 indicator */ + device_id = (device_id & 0xff) | 0x4000; + + /* + * Check PCIE Device ID + */ + if (le16_to_cpu(*(u16*)pcir_header->device_id) != device_id) { + /* + * Change the device ID in the Boot BIOS image to match + * the Device ID of the current adapter. + */ + modify_device_id(device_id, boot_data); + } /* * Skip over the first SF_PAGE_SIZE worth of data and write it after @@ -3206,7 +3420,11 @@ void t4_get_chan_txrate(struct adapter * * @enable: whether to enable or disable the filter * * Configures one of the tracing filters available in HW. If @enable is - * %0 @tp is not examined and may be %NULL. + * %0 @tp is not examined and may be %NULL. The user is responsible to + * set the single/multiple trace mode by writing to A_MPS_TRC_CFG register + * by using "cxgbtool iface reg reg_addr=val" command. See t4_sniffer/ + * docs/readme.txt for a complete description of how to setup traceing on + * T4. */ int t4_set_trace_filter(struct adapter *adap, const struct trace_params *tp, int idx, int enable) @@ -3217,45 +3435,45 @@ int t4_set_trace_filter(struct adapter * if (!enable) { t4_write_reg(adap, A_MPS_TRC_FILTER_MATCH_CTL_A + ofst, 0); - goto out; + return 0; } - if (tp->port > 11 || tp->invert > 1 || tp->skip_len > M_TFLENGTH || - tp->skip_ofst > M_TFOFFSET || tp->min_len > M_TFMINPKTSIZE || - tp->snap_len > 9600 || (idx && tp->snap_len > 256)) - return -EINVAL; - - if (tp->snap_len > 256) { /* must be tracer 0 */ - if ((t4_read_reg(adap, A_MPS_TRC_FILTER_MATCH_CTL_A + 4) | - t4_read_reg(adap, A_MPS_TRC_FILTER_MATCH_CTL_A + 8) | - t4_read_reg(adap, A_MPS_TRC_FILTER_MATCH_CTL_A + 12)) & - F_TFEN) - return -EINVAL; /* other tracers are enabled */ + /* + * TODO - After T4 data book is updated, specify the exact + * section below. + * + * See T4 data book - MPS section for a complete description + * of the below if..else handling of A_MPS_TRC_CFG register + * value. + */ + cfg = t4_read_reg(adap, A_MPS_TRC_CFG); + if (cfg & F_TRCMULTIFILTER) { + /* + * If multiple tracers are enabled, then maximum + * capture size is 2.5KB (FIFO size of a single channel) + * minus 2 flits for CPL_TRACE_PKT header. + */ + if (tp->snap_len > ((10 * 1024 / 4) - (2 * 8))) + return -EINVAL; + } + else { + /* + * If multiple tracers are disabled, to avoid deadlocks + * maximum packet capture size of 9600 bytes is recommended. + * Also in this mode, only trace0 can be enabled and running. + */ multitrc = 0; - } else if (idx) { - i = t4_read_reg(adap, A_MPS_TRC_FILTER_MATCH_CTL_B); - if (G_TFCAPTUREMAX(i) > 256 && - (t4_read_reg(adap, A_MPS_TRC_FILTER_MATCH_CTL_A) & F_TFEN)) + if (tp->snap_len > 9600 || idx) return -EINVAL; } + if (tp->port > 11 || tp->invert > 1 || tp->skip_len > M_TFLENGTH || + tp->skip_ofst > M_TFOFFSET || tp->min_len > M_TFMINPKTSIZE) + return -EINVAL; + /* stop the tracer we'll be changing */ t4_write_reg(adap, A_MPS_TRC_FILTER_MATCH_CTL_A + ofst, 0); - /* disable tracing globally if running in the wrong single/multi mode */ - cfg = t4_read_reg(adap, A_MPS_TRC_CFG); - if ((cfg & F_TRCEN) && multitrc != (cfg & F_TRCMULTIFILTER)) { - t4_write_reg(adap, A_MPS_TRC_CFG, cfg ^ F_TRCEN); - t4_read_reg(adap, A_MPS_TRC_CFG); /* flush */ - msleep(1); - if (!(t4_read_reg(adap, A_MPS_TRC_CFG) & F_TRCFIFOEMPTY)) - return -ETIMEDOUT; - } - /* - * At this point either the tracing is enabled and in the right mode or - * disabled. - */ - idx *= (A_MPS_TRC_FILTER1_MATCH - A_MPS_TRC_FILTER0_MATCH); data_reg = A_MPS_TRC_FILTER0_MATCH + idx; mask_reg = A_MPS_TRC_FILTER0_DONT_CARE + idx; @@ -3271,9 +3489,6 @@ int t4_set_trace_filter(struct adapter * V_TFOFFSET(tp->skip_ofst) | V_TFLENGTH(tp->skip_len) | V_TFPORT(tp->port) | F_TFEN | V_TFINVERTMATCH(tp->invert)); - cfg &= ~F_TRCMULTIFILTER; - t4_write_reg(adap, A_MPS_TRC_CFG, cfg | F_TRCEN | multitrc); -out: t4_read_reg(adap, A_MPS_TRC_CFG); /* flush */ return 0; } @@ -3373,6 +3588,28 @@ static unsigned int get_mps_bg_map(struc } /** + * t4_get_port_stats_offset - collect port stats relative to a previous + * snapshot + * @adap: The adapter + * @idx: The port + * @stats: Current stats to fill + * @offset: Previous stats snapshot + */ +void t4_get_port_stats_offset(struct adapter *adap, int idx, + struct port_stats *stats, + struct port_stats *offset) +{ + u64 *s, *o; + int i; + + t4_get_port_stats(adap, idx, stats); + for (i = 0, s = (u64 *)stats, o = (u64 *)offset ; + i < (sizeof(struct port_stats)/sizeof(u64)) ; + i++, s++, o++) + *s -= *o; +} + +/** * t4_get_port_stats - collect port statistics * @adap: the adapter * @idx: the port index @@ -3633,6 +3870,20 @@ void t4_mk_filtdelwr(unsigned int ftid, (var).retval_len16 = htonl(FW_LEN16(var)); \ } while (0) +int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox, u32 addr, u32 val) +{ + struct fw_ldst_cmd c; + + memset(&c, 0, sizeof(c)); + c.op_to_addrspace = htonl(V_FW_CMD_OP(FW_LDST_CMD) | F_FW_CMD_REQUEST | + F_FW_CMD_WRITE | V_FW_LDST_CMD_ADDRSPACE(FW_LDST_ADDRSPC_FIRMWARE)); + c.cycles_to_len16 = htonl(FW_LEN16(c)); + c.u.addrval.addr = htonl(addr); + c.u.addrval.val = htonl(val); + + return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL); +} + /** * t4_mdio_rd - read a PHY register through MDIO * @adap: the adapter @@ -3693,6 +3944,30 @@ int t4_mdio_wr(struct adapter *adap, uns } /** + * t4_sge_ctxt_flush - flush the SGE context cache + * @adap: the adapter + * @mbox: mailbox to use for the FW command + * + * Issues a FW command through the given mailbox to flush the + * SGE context cache. + */ +int t4_sge_ctxt_flush(struct adapter *adap, unsigned int mbox) +{ + int ret; + struct fw_ldst_cmd c; + + memset(&c, 0, sizeof(c)); + c.op_to_addrspace = htonl(V_FW_CMD_OP(FW_LDST_CMD) | F_FW_CMD_REQUEST | + F_FW_CMD_READ | + V_FW_LDST_CMD_ADDRSPACE(FW_LDST_ADDRSPC_SGE_EGRC)); + c.cycles_to_len16 = htonl(FW_LEN16(c)); + c.u.idctxt.msg_ctxtflush = htonl(F_FW_LDST_CMD_CTXTFLUSH); + + ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c); + return ret; +} + +/** * t4_sge_ctxt_rd - read an SGE context through FW * @adap: the adapter * @mbox: mailbox to use for the FW command @@ -3764,9 +4039,10 @@ int t4_sge_ctxt_rd_bd(struct adapter *ad * @mbox: mailbox to use for the FW command * @evt_mbox: mailbox to receive async FW events * @master: specifies the caller's willingness to be the device master - * @state: returns the current device state + * @state: returns the current device state (if non-NULL) * - * Issues a command to establish communication with FW. + * Issues a command to establish communication with FW. Returns either + * an error (negative integer) or the mailbox of the Master PF. */ int t4_fw_hello(struct adapter *adap, unsigned int mbox, unsigned int evt_mbox, enum dev_master master, enum dev_state *state) @@ -3918,6 +4194,175 @@ int t4_fw_reset(struct adapter *adap, un } /** + * t4_fw_halt - issue a reset/halt to FW and put uP into RESET + * @adap: the adapter + * @mbox: mailbox to use for the FW RESET command (if desired) + * @force: force uP into RESET even if FW RESET command fails + * + * Issues a RESET command to firmware (if desired) with a HALT indication + * and then puts the microprocessor into RESET state. The RESET command + * will only be issued if a legitimate mailbox is provided (mbox <= + * M_PCIE_FW_MASTER). + * + * This is generally used in order for the host to safely manipulate the + * adapter without fear of conflicting with whatever the firmware might + * be doing. The only way out of this state is to RESTART the firmware + * ... + */ +int t4_fw_halt(struct adapter *adap, unsigned int mbox, int force) +{ + int ret = 0; + + /* + * If a legitimate mailbox is provided, issue a RESET command + * with a HALT indication. + */ + if (mbox <= M_PCIE_FW_MASTER) { + struct fw_reset_cmd c; + + memset(&c, 0, sizeof(c)); + INIT_CMD(c, RESET, WRITE); + c.val = htonl(F_PIORST | F_PIORSTMODE); + c.halt_pkd = htonl(F_FW_RESET_CMD_HALT); + ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL); + } + + /* + * Normally we won't complete the operation if the firmware RESET + * command fails but if our caller insists we'll go ahead and put the + * uP into RESET. This can be useful if the firmware is hung or even + * missing ... We'll have to take the risk of putting the uP into + * RESET without the cooperation of firmware in that case. + * + * We also force the firmware's HALT flag to be on in case we bypassed + * the firmware RESET command above or we're dealing with old firmware + * which doesn't have the HALT capability. This will serve as a flag + * for the incoming firmware to know that it's coming out of a HALT + * rather than a RESET ... if it's new enough to understand that ... + */ + if (ret == 0 || force) { + t4_set_reg_field(adap, A_CIM_BOOT_CFG, F_UPCRST, F_UPCRST); + t4_set_reg_field(adap, A_PCIE_FW, F_PCIE_FW_HALT, F_PCIE_FW_HALT); + } + + /* + * And we always return the result of the firmware RESET command + * even when we force the uP into RESET ... + */ + return ret; +} + +/** + * t4_fw_restart - restart the firmware by taking the uP out of RESET + * @adap: the adapter + * @reset: if we want to do a RESET to restart things + * + * Restart firmware previously halted by t4_fw_halt(). On successful + * return the previous PF Master remains as the new PF Master and there + * is no need to issue a new HELLO command, etc. + * + * We do this in two ways: + * + * 1. If we're dealing with newer firmware we'll simply want to take + * the chip's microprocessor out of RESET. This will cause the + * firmware to start up from its start vector. And then we'll loop + * until the firmware indicates it's started again (PCIE_FW.HALT + * reset to 0) or we timeout. + * + * 2. If we're dealing with older firmware then we'll need to RESET + * the chip since older firmware won't recognize the PCIE_FW.HALT + * flag and automatically RESET itself on startup. + */ +int t4_fw_restart(struct adapter *adap, unsigned int mbox, int reset) +{ + if (reset) { + /* + * Since we're directing the RESET instead of the firmware + * doing it automatically, we need to clear the PCIE_FW.HALT + * bit. + */ + t4_set_reg_field(adap, A_PCIE_FW, F_PCIE_FW_HALT, 0); + + /* + * If we've been given a valid mailbox, first try to get the + * firmware to do the RESET. If that works, great and we can + * return success. Otherwise, if we haven't been given a + * valid mailbox or the RESET command failed, fall back to + * hitting the chip with a hammer. + */ + if (mbox <= M_PCIE_FW_MASTER) { + t4_set_reg_field(adap, A_CIM_BOOT_CFG, F_UPCRST, 0); + msleep(100); + if (t4_fw_reset(adap, mbox, + F_PIORST | F_PIORSTMODE) == 0) + return 0; + } + + t4_write_reg(adap, A_PL_RST, F_PIORST | F_PIORSTMODE); + msleep(2000); + } else { + int ms; + + t4_set_reg_field(adap, A_CIM_BOOT_CFG, F_UPCRST, 0); + for (ms = 0; ms < FW_CMD_MAX_TIMEOUT; ) { + if (!(t4_read_reg(adap, A_PCIE_FW) & F_PCIE_FW_HALT)) + return FW_SUCCESS; + msleep(100); + ms += 100; + } + return -ETIMEDOUT; + } + return 0; +} + +/** + * t4_fw_upgrade - perform all of the steps necessary to upgrade FW + * @adap: the adapter + * @mbox: mailbox to use for the FW RESET command (if desired) + * @fw_data: the firmware image to write + * @size: image size + * @force: force upgrade even if firmware doesn't cooperate + * + * Perform all of the steps necessary for upgrading an adapter's + * firmware image. Normally this requires the cooperation of the + * existing firmware in order to halt all existing activities + * but if an invalid mailbox token is passed in we skip that step + * (though we'll still put the adapter microprocessor into RESET in + * that case). + * + * On successful return the new firmware will have been loaded and + * the adapter will have been fully RESET losing all previous setup + * state. On unsuccessful return the adapter may be completely hosed ... + * positive errno indicates that the adapter is ~probably~ intact, a + * negative errno indicates that things are looking bad ... + */ +int t4_fw_upgrade(struct adapter *adap, unsigned int mbox, + const u8 *fw_data, unsigned int size, int force) +{ + const struct fw_hdr *fw_hdr = (const struct fw_hdr *)fw_data; + int reset, ret; + + ret = t4_fw_halt(adap, mbox, force); + if (ret < 0 && !force) + return ret; + + ret = t4_load_fw(adap, fw_data, size); + if (ret < 0) + return ret; + + /* + * Older versions of the firmware don't understand the new + * PCIE_FW.HALT flag and so won't know to perform a RESET when they + * restart. So for newly loaded older firmware we'll have to do the + * RESET for it so it starts up on a clean slate. We can tell if + * the newly loaded firmware will handle this right by checking + * its header flags to see if it advertises the capability. + */ + reset = ((ntohl(fw_hdr->flags) & FW_HDR_FLAGS_RESET_HALT) == 0); + return t4_fw_restart(adap, mbox, reset); +} + +/** * t4_fw_initialize - ask FW to initialize the device * @adap: the adapter * @mbox: mailbox to use for the FW command @@ -4059,7 +4504,7 @@ int t4_cfg_pfvf(struct adapter *adap, un } /** - * t4_alloc_vi - allocate a virtual interface + * t4_alloc_vi_func - allocate a virtual interface * @adap: the adapter * @mbox: mailbox to use for the FW command * @port: physical port associated with the VI @@ -4068,6 +4513,8 @@ int t4_cfg_pfvf(struct adapter *adap, un * @nmac: number of MAC addresses needed (1 to 5) * @mac: the MAC addresses of the VI * @rss_size: size of RSS table slice associated with this VI + * @portfunc: which Port Application Function MAC Address is desired + * @idstype: Intrusion Detection Type * * Allocates a virtual interface for the given physical port. If @mac is * not %NULL it contains the MAC addresses of the VI as assigned by FW. @@ -4075,9 +4522,10 @@ int t4_cfg_pfvf(struct adapter *adap, un * stored consecutively so the space needed is @nmac * 6 bytes. * Returns a negative error number or the non-negative VI id. */ -int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port, - unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac, - unsigned int *rss_size) +int t4_alloc_vi_func(struct adapter *adap, unsigned int mbox, + unsigned int port, unsigned int pf, unsigned int vf, + unsigned int nmac, u8 *mac, unsigned int *rss_size, + unsigned int portfunc, unsigned int idstype) { int ret; struct fw_vi_cmd c; @@ -4087,6 +4535,8 @@ int t4_alloc_vi(struct adapter *adap, un F_FW_CMD_WRITE | F_FW_CMD_EXEC | V_FW_VI_CMD_PFN(pf) | V_FW_VI_CMD_VFN(vf)); c.alloc_to_len16 = htonl(F_FW_VI_CMD_ALLOC | FW_LEN16(c)); + c.type_to_viid = htons(V_FW_VI_CMD_TYPE(idstype) | + V_FW_VI_CMD_FUNC(portfunc)); c.portid_pkd = V_FW_VI_CMD_PORTID(port); c.nmac = nmac - 1; @@ -4109,7 +4559,30 @@ int t4_alloc_vi(struct adapter *adap, un } if (rss_size) *rss_size = G_FW_VI_CMD_RSSSIZE(ntohs(c.rsssize_pkd)); - return G_FW_VI_CMD_VIID(ntohs(c.type_to_viid)); + return G_FW_VI_CMD_VIID(htons(c.type_to_viid)); +} + +/** + * t4_alloc_vi - allocate an [Ethernet Function] virtual interface + * @adap: the adapter + * @mbox: mailbox to use for the FW command + * @port: physical port associated with the VI + * @pf: the PF owning the VI + * @vf: the VF owning the VI + * @nmac: number of MAC addresses needed (1 to 5) + * @mac: the MAC addresses of the VI + * @rss_size: size of RSS table slice associated with this VI + * + * backwards compatible and convieniance routine to allocate a Virtual + * Interface with a Ethernet Port Application Function and Intrustion + * Detection System disabled. + */ +int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port, + unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac, + unsigned int *rss_size) +{ + return t4_alloc_vi_func(adap, mbox, port, pf, vf, nmac, mac, rss_size, + FW_VI_FUNC_ETH, 0); } /** @@ -4214,7 +4687,7 @@ int t4_alloc_mac_filt(struct adapter *ad unsigned int nfilters = 0; unsigned int rem = naddr; - if (naddr > FW_CLS_TCAM_NUM_ENTRIES) + if (naddr > NUM_MPS_CLS_SRAM_L_INSTANCES) return -EINVAL; for (offset = 0; offset < naddr ; /**/) { @@ -4255,10 +4728,10 @@ int t4_alloc_mac_filt(struct adapter *ad u16 index = G_FW_VI_MAC_CMD_IDX(ntohs(p->valid_to_idx)); if (idx) - idx[offset+i] = (index >= FW_CLS_TCAM_NUM_ENTRIES + idx[offset+i] = (index >= NUM_MPS_CLS_SRAM_L_INSTANCES ? 0xffff : index); - if (index < FW_CLS_TCAM_NUM_ENTRIES) + if (index < NUM_MPS_CLS_SRAM_L_INSTANCES) nfilters++; else if (hash) *hash |= (1ULL << hash_mac_addr(addr[offset+i])); @@ -4319,7 +4792,7 @@ int t4_change_mac(struct adapter *adap, ret = t4_wr_mbox_ns(adap, mbox, &c, sizeof(c), &c); if (ret == 0) { ret = G_FW_VI_MAC_CMD_IDX(ntohs(p->valid_to_idx)); - if (ret >= FW_CLS_TCAM_NUM_ENTRIES) + if (ret >= NUM_MPS_CLS_SRAM_L_INSTANCES) ret = -ENOMEM; } return ret; @@ -4540,10 +5013,12 @@ int t4_ofld_eq_free(struct adapter *adap int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl) { u8 opcode = *(const u8 *)rpl; + const struct fw_port_cmd *p = (const void *)rpl; + unsigned int action = G_FW_PORT_CMD_ACTION(ntohl(p->action_to_len16)); - if (opcode == FW_PORT_CMD) { /* link/module state change message */ + if (opcode == FW_PORT_CMD && action == FW_PORT_ACTION_GET_PORT_INFO) { + /* link/module state change message */ int speed = 0, fc = 0, i; - const struct fw_port_cmd *p = (const void *)rpl; int chan = G_FW_PORT_CMD_PORTID(ntohl(p->op_to_portid)); struct port_info *pi = NULL; struct link_config *lc; @@ -4580,6 +5055,10 @@ int t4_handle_fw_rpl(struct adapter *ada pi->mod_type = mod; t4_os_portmod_changed(adap, i); } + } else { + CH_WARN_RATELIMIT(adap, + "Unknown firmware reply 0x%x (0x%x)\n", opcode, action); + return -EINVAL; } return 0; } @@ -4706,6 +5185,11 @@ int __devinit t4_prep_adapter(struct ada get_pci_mode(adapter, &adapter->params.pci); adapter->params.rev = t4_read_reg(adapter, A_PL_REV); + /* T4A1 chip is no longer supported */ + if (adapter->params.rev == 1) { + CH_ALERT(adapter, "T4 rev 1 chip is no longer supported\n"); + return -EINVAL; + } adapter->params.pci.vpd_cap_addr = t4_os_find_pci_capability(adapter, PCI_CAP_ID_VPD); @@ -4717,9 +5201,11 @@ int __devinit t4_prep_adapter(struct ada if (ret < 0) return ret; - if (t4_read_reg(adapter, A_SGE_PC0_REQ_BIST_CMD) != 0xffffffff) { + if (t4_read_reg(adapter, A_PCIE_REVISION) != 0) { + /* FPGA */ adapter->params.cim_la_size = 2 * CIMLA_SIZE; } else { + /* ASIC */ adapter->params.cim_la_size = CIMLA_SIZE; } @@ -4783,3 +5269,43 @@ int __devinit t4_port_init(struct port_i return 0; } + +int t4_config_scheduler(struct adapter *adapter, int mode, int level, + int pktsize, int sched_class, int port, int unit, + int rate, int weight, int minrate, int maxrate) +{ + struct fw_sched_cmd cmd, rpl; + + if (rate < 0 || unit < 0) + return -EINVAL; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 08:09:03 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A091106564A; Fri, 22 Jun 2012 08:09:03 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id D715A8FC12; Fri, 22 Jun 2012 08:09:01 +0000 (UTC) Received: by lbon10 with SMTP id n10so3979240lbo.13 for ; Fri, 22 Jun 2012 01:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=8HIyPyCPmtu17dYLtBtk4zhogIHbPbrHS+kVhInLupI=; b=xjREB0lyB5q2BN/vsIPKtvHxrp4yIa5tLk4Zz2ohOWJZc54Vsp1BmGPsChC0z6HRHt w65eWIDDwMWZh3pmVBSaiRfga4mwQWjPMnNIE8r0813zR6O06OpU+RNZ0Gmlgp5GY51I YfEnxdm9n9iVKZA4LTLebq8fX7Tc6/+wNbgB1O6+USX0nedr5U4L7qN7EJFHG6uwv4Jw UJW7mwTFgVtV6CheLIZIoD1yFFS41a8CQso4mC41HVhu6mlqrY1SIKgs30n6lLzUhoQN twhOU8QflMF2o61dXmMir03nQi1lPkigf7JyHXeR/U2vOlX/PHDPXVjCaTTQw7V6qV10 Jk5A== Received: by 10.152.132.40 with SMTP id or8mr1199663lab.24.1340352534664; Fri, 22 Jun 2012 01:08:54 -0700 (PDT) Received: from mavbook2.mavhome.dp.ua (pc.mavhome.dp.ua. [212.86.226.226]) by mx.google.com with ESMTPS id fd1sm20373044lbb.7.2012.06.22.01.08.52 (version=SSLv3 cipher=OTHER); Fri, 22 Jun 2012 01:08:53 -0700 (PDT) Sender: Alexander Motin Message-ID: <4FE42812.3050807@FreeBSD.org> Date: Fri, 22 Jun 2012 11:08:50 +0300 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20120506 Thunderbird/12.0.1 MIME-Version: 1.0 To: Konstantin Belousov References: <201206220706.q5M76fbO062751@svn.freebsd.org> In-Reply-To: <201206220706.q5M76fbO062751@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237433 - in head/sys: amd64/include arm/include conf i386/include ia64/include kern mips/include pc98/include powerpc/include sparc64/include sys x86/include x86/x86 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 08:09:03 -0000 On 06/22/12 10:06, Konstantin Belousov wrote: > Author: kib > Date: Fri Jun 22 07:06:40 2012 > New Revision: 237433 > URL: http://svn.freebsd.org/changeset/base/237433 > > Log: > Implement mechanism to export some kernel timekeeping data to > usermode, using shared page. The structures and functions have vdso > prefix, to indicate the intended location of the code in some future. > > The versioned per-algorithm data is exported in the format of struct > vdso_timehands, which mostly repeats the content of in-kernel struct > timehands. Usermode reading of the structure can be lockless. > Compatibility export for 32bit processes on 64bit host is also > provided. Kernel also provides usermode with indication about > currently used timecounter, so that libc can fall back to syscall if > configured timecounter is unknown to usermode code. > > The shared data updates are initiated both from the tc_windup(), where > a fast task is queued to do the update, and from sysctl handlers which > change timecounter. A manual override switch > kern.timecounter.fast_gettime allows to turn off the mechanism. > > Only x86 architectures export the real algorithm data, and there, only > for tsc timecounter. HPET counters page could be exported as well, but > I prefer to not further glue the kernel and libc ABI there until > proper vdso-based solution is developed. > > Minimal stubs neccessary for non-x86 architectures to still compile > are provided. > > Discussed with: bde > Reviewed by: jhb > Tested by: flo > MFC after: 1 month > @@ -1360,6 +1367,7 @@ tc_windup(void) > #endif > > timehands = th; > + taskqueue_enqueue_fast(taskqueue_fast,&tc_windup_push_vdso_task); > } > > /* Report or change the active timecounter hardware. */ This taskqueue_enqueue_fast() will schedule extra thread to run each time hardclock() fires. One thread may be not a big problem, but together with callout swi and possible other threads woken up there it will wake up several other CPU cores from sleep just to put them back in few microseconds. Now davide@ and me are trying to fix that by avoiding callout SWI use for simple tasks. Please, let's not create another problem same time. -- Alexander Motin From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 08:11:38 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2DC40106564A; Fri, 22 Jun 2012 08:11:38 +0000 (UTC) (envelope-from theraven@theravensnest.org) Received: from theravensnest.org (theraven.freebsd.your.org [216.14.102.27]) by mx1.freebsd.org (Postfix) with ESMTP id EB8488FC16; Fri, 22 Jun 2012 08:11:37 +0000 (UTC) Received: from [192.168.0.2] (cpc2-cmbg15-2-0-cust445.5-4.cable.virginmedia.com [86.26.13.190]) (authenticated bits=0) by theravensnest.org (8.14.5/8.14.5) with ESMTP id q5M7fh02050990 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Fri, 22 Jun 2012 07:41:45 GMT (envelope-from theraven@theravensnest.org) Mime-Version: 1.0 (Apple Message framework v1257) Content-Type: text/plain; charset=us-ascii From: David Chisnall In-Reply-To: <20120622073455.GE69382@alchemy.franken.de> Date: Fri, 22 Jun 2012 08:41:38 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201206220713.q5M7DVH0063098@svn.freebsd.org> <20120622073455.GE69382@alchemy.franken.de> To: Marius Strobl X-Mailer: Apple Mail (2.1257) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Konstantin Belousov Subject: Re: svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 08:11:38 -0000 On 22 Jun 2012, at 08:34, Marius Strobl wrote: > I don't know much about x86 CPUs but is my understanding correct > that TSCs are not synchronized in any way across CPUs, i.e. > reading it on different CPUs may result in time going backwards > etc., which is okay for this application though? As long as the initial value is set on every context switch, it only = matters that the TSC is monotonic and increments at an approximately = constant rate. It is also possible to set the TSC value, but that's = less useful in this context. The one thing to be careful about is the fact that certain power saving = states will affect the speed at which the TSC increments, and so it is = important to update the ticks-per-second value whenever a core goes into = a low power state. This is more or less the same approach used by Xen, so most of the = issues have been ironed out: Oracle complained to CPU vendors about a = few corner cases and, because Oracle customers tend to buy a lot of = expensive Xeon and Opteron chips, they were fixed quite promptly. =20 David From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 08:25:10 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ECC2D1065672; Fri, 22 Jun 2012 08:25:10 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 6A03F8FC0C; Fri, 22 Jun 2012 08:25:10 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q5M8P2ST002909; Fri, 22 Jun 2012 11:25:02 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q5M8P2T6041027; Fri, 22 Jun 2012 11:25:02 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q5M8P2Y0041026; Fri, 22 Jun 2012 11:25:02 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 22 Jun 2012 11:25:02 +0300 From: Konstantin Belousov To: Alexander Motin Message-ID: <20120622082502.GB2337@deviant.kiev.zoral.com.ua> References: <201206220706.q5M76fbO062751@svn.freebsd.org> <4FE42812.3050807@FreeBSD.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="sEXf5qLefa2bWrwX" Content-Disposition: inline In-Reply-To: <4FE42812.3050807@FreeBSD.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r237433 - in head/sys: amd64/include arm/include conf i386/include ia64/include kern mips/include pc98/include powerpc/include sparc64/include sys x86/include x86/x86 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 08:25:11 -0000 --sEXf5qLefa2bWrwX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 22, 2012 at 11:08:50AM +0300, Alexander Motin wrote: > On 06/22/12 10:06, Konstantin Belousov wrote: > >Author: kib > >Date: Fri Jun 22 07:06:40 2012 > >New Revision: 237433 > >URL: http://svn.freebsd.org/changeset/base/237433 > > > >Log: > > Implement mechanism to export some kernel timekeeping data to > > usermode, using shared page. The structures and functions have vdso > > prefix, to indicate the intended location of the code in some future. > > > > The versioned per-algorithm data is exported in the format of struct > > vdso_timehands, which mostly repeats the content of in-kernel struct > > timehands. Usermode reading of the structure can be lockless. > > Compatibility export for 32bit processes on 64bit host is also > > provided. Kernel also provides usermode with indication about > > currently used timecounter, so that libc can fall back to syscall if > > configured timecounter is unknown to usermode code. > > > > The shared data updates are initiated both from the tc_windup(), where > > a fast task is queued to do the update, and from sysctl handlers which > > change timecounter. A manual override switch > > kern.timecounter.fast_gettime allows to turn off the mechanism. > > > > Only x86 architectures export the real algorithm data, and there, only > > for tsc timecounter. HPET counters page could be exported as well, but > > I prefer to not further glue the kernel and libc ABI there until > > proper vdso-based solution is developed. > > > > Minimal stubs neccessary for non-x86 architectures to still compile > > are provided. > > > > Discussed with: bde > > Reviewed by: jhb > > Tested by: flo > > MFC after: 1 month >=20 >=20 > >@@ -1360,6 +1367,7 @@ tc_windup(void) > > #endif > > > > timehands =3D th; > >+ taskqueue_enqueue_fast(taskqueue_fast,&tc_windup_push_vdso_task); > > } > > > > /* Report or change the active timecounter hardware. */ >=20 > This taskqueue_enqueue_fast() will schedule extra thread to run each=20 > time hardclock() fires. One thread may be not a big problem, but=20 > together with callout swi and possible other threads woken up there it=20 > will wake up several other CPU cores from sleep just to put them back in= =20 > few microseconds. Now davide@ and me are trying to fix that by avoiding= =20 > callout SWI use for simple tasks. Please, let's not create another=20 > problem same time. The patch was public for quite a time. If you have some comments about it, it would be much more productive to let me know about them before the commit, not after. Anyway, what is your proposal for 'let's not create another problem same time' part of the message ? It was discussed, as a possibility, to have permanent mapping for the shared page in the KVA and to perform lock-less update of the struct vdso_timehands directly from hardclock handler. My opinion was that amount of work added by tc_windup eventhandler is not trivial, so it is better to be postponed to less critical context. It also slightly more safe to not perform lockless update for vdso_timehands, since otherwise module load which register exec handler could cause transient gettimeofday() failure in usermode. This might boil down to the fact that tc_windup function is called too often, in fact. Also, packing execution of tc_windup eventhandler together with the clock swi is fine from my POV. --sEXf5qLefa2bWrwX Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/kK94ACgkQC3+MBN1Mb4i4lwCffVntk+LpPG5jXWFpo5em9EGt tRMAoKna5jQBrk/bloJfcNV0uK9iNM4z =IBkC -----END PGP SIGNATURE----- --sEXf5qLefa2bWrwX-- From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 08:37:34 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4FBA4106564A; Fri, 22 Jun 2012 08:37:34 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 21DB38FC15; Fri, 22 Jun 2012 08:37:34 +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 q5M8bXRk066829; Fri, 22 Jun 2012 08:37:33 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5M8bXEg066827; Fri, 22 Jun 2012 08:37:33 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201206220837.q5M8bXEg066827@svn.freebsd.org> From: Navdeep Parhar Date: Fri, 22 Jun 2012 08:37:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237439 - head/sys/dev/cxgbe X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 08:37:34 -0000 Author: np Date: Fri Jun 22 08:37:33 2012 New Revision: 237439 URL: http://svn.freebsd.org/changeset/base/237439 Log: Do not read registers with read side effects while performing a register dump for cxgbetool. Modified: head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Fri Jun 22 07:53:51 2012 (r237438) +++ head/sys/dev/cxgbe/t4_main.c Fri Jun 22 08:37:33 2012 (r237439) @@ -2705,7 +2705,9 @@ t4_get_regs(struct adapter *sc, struct t 0xdfc0, 0xdfe0, 0xe000, 0xea7c, 0xf000, 0x11190, - 0x19040, 0x19124, + 0x19040, 0x1906c, + 0x19078, 0x19080, + 0x1908c, 0x19124, 0x19150, 0x191b0, 0x191d0, 0x191e8, 0x19238, 0x1924c, @@ -2718,49 +2720,49 @@ t4_get_regs(struct adapter *sc, struct t 0x1a190, 0x1a1c4, 0x1a1fc, 0x1a1fc, 0x1e040, 0x1e04c, - 0x1e240, 0x1e28c, + 0x1e284, 0x1e28c, 0x1e2c0, 0x1e2c0, 0x1e2e0, 0x1e2e0, 0x1e300, 0x1e384, 0x1e3c0, 0x1e3c8, 0x1e440, 0x1e44c, - 0x1e640, 0x1e68c, + 0x1e684, 0x1e68c, 0x1e6c0, 0x1e6c0, 0x1e6e0, 0x1e6e0, 0x1e700, 0x1e784, 0x1e7c0, 0x1e7c8, 0x1e840, 0x1e84c, - 0x1ea40, 0x1ea8c, + 0x1ea84, 0x1ea8c, 0x1eac0, 0x1eac0, 0x1eae0, 0x1eae0, 0x1eb00, 0x1eb84, 0x1ebc0, 0x1ebc8, 0x1ec40, 0x1ec4c, - 0x1ee40, 0x1ee8c, + 0x1ee84, 0x1ee8c, 0x1eec0, 0x1eec0, 0x1eee0, 0x1eee0, 0x1ef00, 0x1ef84, 0x1efc0, 0x1efc8, 0x1f040, 0x1f04c, - 0x1f240, 0x1f28c, + 0x1f284, 0x1f28c, 0x1f2c0, 0x1f2c0, 0x1f2e0, 0x1f2e0, 0x1f300, 0x1f384, 0x1f3c0, 0x1f3c8, 0x1f440, 0x1f44c, - 0x1f640, 0x1f68c, + 0x1f684, 0x1f68c, 0x1f6c0, 0x1f6c0, 0x1f6e0, 0x1f6e0, 0x1f700, 0x1f784, 0x1f7c0, 0x1f7c8, 0x1f840, 0x1f84c, - 0x1fa40, 0x1fa8c, + 0x1fa84, 0x1fa8c, 0x1fac0, 0x1fac0, 0x1fae0, 0x1fae0, 0x1fb00, 0x1fb84, 0x1fbc0, 0x1fbc8, 0x1fc40, 0x1fc4c, - 0x1fe40, 0x1fe8c, + 0x1fe84, 0x1fe8c, 0x1fec0, 0x1fec0, 0x1fee0, 0x1fee0, 0x1ff00, 0x1ff84, From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 08:54:55 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E1B1A106566B; Fri, 22 Jun 2012 08:54:55 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id ED55C8FC0C; Fri, 22 Jun 2012 08:54:54 +0000 (UTC) Received: by lbon10 with SMTP id n10so4038519lbo.13 for ; Fri, 22 Jun 2012 01:54:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=BgGfywcsOZo6hMDfAJpkA/wkyhaIRvcoaHkAHCvLKj0=; b=XY9LCc1lsh8v8Jg33cTpeJcWZKZ5iAEwAywo0rqTkI25p3lTO2WEV68fPRhoUgILtP 7FUyfSKdRxFTSAhKZ07g7t6hfi0Gktv1FJGWG8rC4kNnYVor8ejJFMFURH3MJGjnjPLN 9gbOs08M41q7jibSocJxFOXWejLzZ2/OodPo2D14U2cYYGCzTkQ20JSle+xRPRzIVICk UqMbkMzdYTLV+0zB5qRmMidecQ++EivZppBlocbjXABf7+wAGdiggmZ4JhNQyqM13rLh gnx2A1FXQMAYIGdOTgIhMutDVYZBFYU5Wn7XldVV3hlpQoiWQJZrAJCOWk2rhKbUiEOT 6DmA== Received: by 10.152.148.169 with SMTP id tt9mr1270249lab.49.1340355293866; Fri, 22 Jun 2012 01:54:53 -0700 (PDT) Received: from mavbook.mavhome.dp.ua (pc.mavhome.dp.ua. [212.86.226.226]) by mx.google.com with ESMTPS id hi14sm51186795lab.4.2012.06.22.01.54.51 (version=SSLv3 cipher=OTHER); Fri, 22 Jun 2012 01:54:52 -0700 (PDT) Sender: Alexander Motin Message-ID: <4FE432C4.7000608@FreeBSD.org> Date: Fri, 22 Jun 2012 11:54:28 +0300 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:9.0) Gecko/20120116 Thunderbird/9.0 MIME-Version: 1.0 To: Konstantin Belousov References: <201206220706.q5M76fbO062751@svn.freebsd.org> <4FE42812.3050807@FreeBSD.org> <20120622082502.GB2337@deviant.kiev.zoral.com.ua> In-Reply-To: <20120622082502.GB2337@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r237433 - in head/sys: amd64/include arm/include conf i386/include ia64/include kern mips/include pc98/include powerpc/include sparc64/include sys x86/include x86/x86 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 08:54:56 -0000 On 22.06.2012 11:25, Konstantin Belousov wrote: > On Fri, Jun 22, 2012 at 11:08:50AM +0300, Alexander Motin wrote: >> On 06/22/12 10:06, Konstantin Belousov wrote: >>> Author: kib >>> Date: Fri Jun 22 07:06:40 2012 >>> New Revision: 237433 >>> URL: http://svn.freebsd.org/changeset/base/237433 >>> >>> Log: >>> Implement mechanism to export some kernel timekeeping data to >>> usermode, using shared page. The structures and functions have vdso >>> prefix, to indicate the intended location of the code in some future. >>> >>> The versioned per-algorithm data is exported in the format of struct >>> vdso_timehands, which mostly repeats the content of in-kernel struct >>> timehands. Usermode reading of the structure can be lockless. >>> Compatibility export for 32bit processes on 64bit host is also >>> provided. Kernel also provides usermode with indication about >>> currently used timecounter, so that libc can fall back to syscall if >>> configured timecounter is unknown to usermode code. >>> >>> The shared data updates are initiated both from the tc_windup(), where >>> a fast task is queued to do the update, and from sysctl handlers which >>> change timecounter. A manual override switch >>> kern.timecounter.fast_gettime allows to turn off the mechanism. >>> >>> Only x86 architectures export the real algorithm data, and there, only >>> for tsc timecounter. HPET counters page could be exported as well, but >>> I prefer to not further glue the kernel and libc ABI there until >>> proper vdso-based solution is developed. >>> >>> Minimal stubs neccessary for non-x86 architectures to still compile >>> are provided. >>> >>> Discussed with: bde >>> Reviewed by: jhb >>> Tested by: flo >>> MFC after: 1 month >> >> >>> @@ -1360,6 +1367,7 @@ tc_windup(void) >>> #endif >>> >>> timehands = th; >>> + taskqueue_enqueue_fast(taskqueue_fast,&tc_windup_push_vdso_task); >>> } >>> >>> /* Report or change the active timecounter hardware. */ >> >> This taskqueue_enqueue_fast() will schedule extra thread to run each >> time hardclock() fires. One thread may be not a big problem, but >> together with callout swi and possible other threads woken up there it >> will wake up several other CPU cores from sleep just to put them back in >> few microseconds. Now davide@ and me are trying to fix that by avoiding >> callout SWI use for simple tasks. Please, let's not create another >> problem same time. > > The patch was public for quite a time. If you have some comments about > it, it would be much more productive to let me know about them before > the commit, not after. I'm sorry, I haven't seen it. My mad. > Anyway, what is your proposal for 'let's not create another problem > same time' part of the message ? It was discussed, as a possibility, > to have permanent mapping for the shared page in the KVA and to perform > lock-less update of the struct vdso_timehands directly from hardclock > handler. My opinion was that amount of work added by tc_windup > eventhandler is not trivial, so it is better to be postponed to > less critical context. It also slightly more safe to not perform > lockless update for vdso_timehands, since otherwise module load which > register exec handler could cause transient gettimeofday() failure > in usermode. > > This might boil down to the fact that tc_windup function is called > too often, in fact. Also, packing execution of tc_windup eventhandler > together with the clock swi is fine from my POV. I have nothing against using shared pages. On UP system I would probably have not so much against several threads. But on SMP system it will cause at least one, but in many cases two extra CPUs to be woken up. There are two or more threads to run on hardclock(): this taskqueue, callout swi and some thread(s) woken from callouts. Scheduler has no idea how heavy they are. So it will try to move each of them to separate idle CPU. Does the amount of work done in event handlers worth extra Watts consumed by rapidly waking CPUs? As quite rare person running FreeBSD on laptop, I am not sure. I am not sure even that on desktop/server this won't kill all benefit of fast clocks by limiting TurboBoost. -- Alexander Motin From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 09:58:57 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C31D106566C; Fri, 22 Jun 2012 09:58:57 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 8B3DE8FC15; Fri, 22 Jun 2012 09:58:56 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q5M9wlAA026219; Fri, 22 Jun 2012 12:58:47 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q5M9wlhu041642; Fri, 22 Jun 2012 12:58:47 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q5M9wldc041641; Fri, 22 Jun 2012 12:58:47 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 22 Jun 2012 12:58:47 +0300 From: Konstantin Belousov To: Jung-uk Kim Message-ID: <20120622095847.GC2337@deviant.kiev.zoral.com.ua> References: <201206220040.q5M0ejNk045397@svn.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="sh1CKz+Jfn6GrauW" Content-Disposition: inline In-Reply-To: <201206220040.q5M0ejNk045397@svn.freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237412 - in head: sys/contrib/dev/acpica sys/contrib/dev/acpica/common sys/contrib/dev/acpica/compiler sys/contrib/dev/acpica/components/debugger sys/contrib/dev/acpica/components/disa... X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 09:58:57 -0000 --sh1CKz+Jfn6GrauW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 22, 2012 at 12:40:45AM +0000, Jung-uk Kim wrote: > Author: jkim > Date: Fri Jun 22 00:40:44 2012 > New Revision: 237412 > URL: http://svn.freebsd.org/changeset/base/237412 >=20 > Log: > Merge ACPICA 20120620. I think it is caused by import, malloc is called while spinlock is held: ACPI: Executed 1 blocks of module-level executable AML code acpi0: Power Button (fixed) panic: blockable sleep lock (sleep mutex) 16 @ /usr/home/kostik/work/build/= bsd/DEV/src/sys/vm/uma_core.c:2040 cpuid =3D 0 KDB: stack backtrace: db_trace_self_wrapper() at 0xffffffff80279d0a =3D db_trace_self_wrapper+0x2a panic() at 0xffffffff80325a28 =3D panic+0x1d8 witness_checkorder() at 0xffffffff80377938 =3D witness_checkorder+0x1d8 _mtx_lock_flags() at 0xffffffff80313777 =3D _mtx_lock_flags+0x87 uma_zalloc_arg() at 0xffffffff804db97a =3D uma_zalloc_arg+0x2ea malloc() at 0xffffffff8030f7cd =3D malloc+0xbd AcpiUtAllocate() at 0xffffffff802704f1 =3D AcpiUtAllocate+0x31 AcpiUtAllocateZeroed() at 0xffffffff80270559 =3D AcpiUtAllocateZeroed+0x19 AcpiSetupGpeForWake() at 0xffffffff8025becc =3D AcpiSetupGpeForWake+0xfc acpi_probe_child() at 0xffffffff802848e9 =3D acpi_probe_child+0x2b9 AcpiNsWalkNamespace() at 0xffffffff802686ef =3D AcpiNsWalkNamespace+0x15f AcpiWalkNamespace() at 0xffffffff80268c0f =3D AcpiWalkNamespace+0xbf acpi_attach() at 0xffffffff80283e43 =3D acpi_attach+0x993 device_attach() at 0xffffffff8035ab62 =3D device_attach+0x72 bus_generic_attach() at 0xffffffff8035bd3a =3D bus_generic_attach+0x1a nexus_acpi_attach() at 0xffffffff804fbd89 =3D nexus_acpi_attach+0x69 device_attach() at 0xffffffff8035ab62 =3D device_attach+0x72 bus_generic_new_pass() at 0xffffffff8035bf46 =3D bus_generic_new_pass+0xd6 bus_set_pass() at 0xffffffff803597ba =3D bus_set_pass+0x7a configure() at 0xffffffff804fd51a =3D configure+0xa mi_startup() at 0xffffffff802d5c17 =3D mi_startup+0x77 btext() at 0xffffffff802531cc =3D btext+0x2c KDB: enter: panic [ thread pid 0 tid 100000 ] Stopped at 0xffffffff8035fffb =3D kdb_enter+0x3b: movq $0,0x1027= d62(%rip) db> show alllocks Process 0 (kernel) thread 0xffffffff80837cc0 (100000) exclusive sleep mutex Giant (Giant) r =3D 0 (0xffffffff8133a900) locked @ /= usr/home/kostik/work/build/bsd/DEV/src/sys/kern/kern_module.c:116 exclusive spin mutex ACPI lock (0xfffffe000321da80) (ACPI lock (0xfffffe000= 321da80)) r =3D 0 (0xfffffe000321da80) locked @ /usr/home/kostik/work/build= /bsd/DEV/src/sys/dev/acpica/Osd/OsdSynch.c:535 --sh1CKz+Jfn6GrauW Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/kQdcACgkQC3+MBN1Mb4gXzwCeN/jRIUQboKt1g/W+0Uc5oAws gjIAmwTHt3NNImKA4iuPfQ9W11p8l8jR =Cd8O -----END PGP SIGNATURE----- --sh1CKz+Jfn6GrauW-- From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 10:23:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4102B106566C; Fri, 22 Jun 2012 10:23:48 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 658EB8FC15; Fri, 22 Jun 2012 10:23:47 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q5MANgB8033216; Fri, 22 Jun 2012 13:23:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q5MANgoa041797; Fri, 22 Jun 2012 13:23:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q5MANgwC041796; Fri, 22 Jun 2012 13:23:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 22 Jun 2012 13:23:42 +0300 From: Konstantin Belousov To: Alexander Motin Message-ID: <20120622102342.GD2337@deviant.kiev.zoral.com.ua> References: <201206220706.q5M76fbO062751@svn.freebsd.org> <4FE42812.3050807@FreeBSD.org> <20120622082502.GB2337@deviant.kiev.zoral.com.ua> <4FE432C4.7000608@FreeBSD.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qcmJb3WyrQSdDnng" Content-Disposition: inline In-Reply-To: <4FE432C4.7000608@FreeBSD.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237433 - in head/sys: amd64/include arm/include conf i386/include ia64/include kern mips/include pc98/include powerpc/include sparc64/include sys x86/include x86/x86 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 10:23:48 -0000 --qcmJb3WyrQSdDnng Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 22, 2012 at 11:54:28AM +0300, Alexander Motin wrote: > On 22.06.2012 11:25, Konstantin Belousov wrote: > >On Fri, Jun 22, 2012 at 11:08:50AM +0300, Alexander Motin wrote: > >>On 06/22/12 10:06, Konstantin Belousov wrote: > >>>Author: kib > >>>Date: Fri Jun 22 07:06:40 2012 > >>>New Revision: 237433 > >>>URL: http://svn.freebsd.org/changeset/base/237433 > >>> > >>>Log: > >>> Implement mechanism to export some kernel timekeeping data to > >>> usermode, using shared page. The structures and functions have vdso > >>> prefix, to indicate the intended location of the code in some futur= e. > >>> > >>> The versioned per-algorithm data is exported in the format of struct > >>> vdso_timehands, which mostly repeats the content of in-kernel struct > >>> timehands. Usermode reading of the structure can be lockless. > >>> Compatibility export for 32bit processes on 64bit host is also > >>> provided. Kernel also provides usermode with indication about > >>> currently used timecounter, so that libc can fall back to syscall if > >>> configured timecounter is unknown to usermode code. > >>> > >>> The shared data updates are initiated both from the tc_windup(), wh= ere > >>> a fast task is queued to do the update, and from sysctl handlers wh= ich > >>> change timecounter. A manual override switch > >>> kern.timecounter.fast_gettime allows to turn off the mechanism. > >>> > >>> Only x86 architectures export the real algorithm data, and there, o= nly > >>> for tsc timecounter. HPET counters page could be exported as well, = but > >>> I prefer to not further glue the kernel and libc ABI there until > >>> proper vdso-based solution is developed. > >>> > >>> Minimal stubs neccessary for non-x86 architectures to still compile > >>> are provided. > >>> > >>> Discussed with: bde > >>> Reviewed by: jhb > >>> Tested by: flo > >>> MFC after: 1 month > >> > >> > >>>@@ -1360,6 +1367,7 @@ tc_windup(void) > >>> #endif > >>> > >>> timehands =3D th; > >>>+ taskqueue_enqueue_fast(taskqueue_fast,&tc_windup_push_vdso_task); > >>> } > >>> > >>> /* Report or change the active timecounter hardware. */ > >> > >>This taskqueue_enqueue_fast() will schedule extra thread to run each > >>time hardclock() fires. One thread may be not a big problem, but > >>together with callout swi and possible other threads woken up there it > >>will wake up several other CPU cores from sleep just to put them back in > >>few microseconds. Now davide@ and me are trying to fix that by avoiding > >>callout SWI use for simple tasks. Please, let's not create another > >>problem same time. > > > >The patch was public for quite a time. If you have some comments about > >it, it would be much more productive to let me know about them before > >the commit, not after. >=20 > I'm sorry, I haven't seen it. My mad. >=20 > >Anyway, what is your proposal for 'let's not create another problem > >same time' part of the message ? It was discussed, as a possibility, > >to have permanent mapping for the shared page in the KVA and to perform > >lock-less update of the struct vdso_timehands directly from hardclock > >handler. My opinion was that amount of work added by tc_windup > >eventhandler is not trivial, so it is better to be postponed to > >less critical context. It also slightly more safe to not perform > >lockless update for vdso_timehands, since otherwise module load which > >register exec handler could cause transient gettimeofday() failure > >in usermode. > > > >This might boil down to the fact that tc_windup function is called > >too often, in fact. Also, packing execution of tc_windup eventhandler > >together with the clock swi is fine from my POV. >=20 > I have nothing against using shared pages. On UP system I would probably= =20 > have not so much against several threads. But on SMP system it will=20 > cause at least one, but in many cases two extra CPUs to be woken up.=20 > There are two or more threads to run on hardclock(): this taskqueue,=20 > callout swi and some thread(s) woken from callouts. Scheduler has no=20 > idea how heavy they are. So it will try to move each of them to separate= =20 > idle CPU. Does the amount of work done in event handlers worth extra=20 > Watts consumed by rapidly waking CPUs? As quite rare person running=20 > FreeBSD on laptop, I am not sure. I am not sure even that on=20 > desktop/server this won't kill all benefit of fast clocks by limiting=20 > TurboBoost. Patch below would probably work, but I cannot test it right now on real hardware due to ACPI issue. It worked for me in qemu. commit 4f2ffd93b36d20eae61495776fc6b0855745fd7f Author: Konstantin Belousov Date: Fri Jun 22 13:19:22 2012 +0300 Use persistent kernel mapping of the shared page, and update the vdso_timehands from hardclock, instead of scheduling task. diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 80502e3..9365223 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1517,42 +1517,13 @@ exec_unregister(execsw_arg) static struct sx shared_page_alloc_sx; static vm_object_t shared_page_obj; static int shared_page_free; - -struct sf_buf * -shared_page_write_start(int base) -{ - vm_page_t m; - struct sf_buf *s; - - VM_OBJECT_LOCK(shared_page_obj); - m =3D vm_page_grab(shared_page_obj, OFF_TO_IDX(base), VM_ALLOC_RETRY); - VM_OBJECT_UNLOCK(shared_page_obj); - s =3D sf_buf_alloc(m, SFB_DEFAULT); - return (s); -} - -void -shared_page_write_end(struct sf_buf *sf) -{ - vm_page_t m; - - m =3D sf_buf_page(sf); - sf_buf_free(sf); - VM_OBJECT_LOCK(shared_page_obj); - vm_page_wakeup(m); - VM_OBJECT_UNLOCK(shared_page_obj); -} +char *shared_page_mapping; =20 void shared_page_write(int base, int size, const void *data) { - struct sf_buf *sf; - vm_offset_t sk; =20 - sf =3D shared_page_write_start(base); - sk =3D sf_buf_kva(sf); - bcopy(data, (void *)(sk + (base & PAGE_MASK)), size); - shared_page_write_end(sf); + bcopy(data, shared_page_mapping + base, size); } =20 static int @@ -1596,6 +1567,7 @@ static void shared_page_init(void *dummy __unused) { vm_page_t m; + vm_offset_t addr; =20 sx_init(&shared_page_alloc_sx, "shpsx"); shared_page_obj =3D vm_pager_allocate(OBJT_PHYS, 0, PAGE_SIZE, @@ -1605,25 +1577,24 @@ shared_page_init(void *dummy __unused) VM_ALLOC_ZERO); m->valid =3D VM_PAGE_BITS_ALL; VM_OBJECT_UNLOCK(shared_page_obj); + addr =3D kmem_alloc_nofault(kernel_map, PAGE_SIZE); + pmap_qenter(addr, &m, 1); + shared_page_mapping =3D (char *)addr; } =20 SYSINIT(shp, SI_SUB_EXEC, SI_ORDER_FIRST, (sysinit_cfunc_t)shared_page_ini= t, NULL); =20 static void -timehands_update(void *arg) +timehands_update(struct sysentvec *sv) { - struct sysentvec *sv; - struct sf_buf *sf; struct vdso_timehands th; struct vdso_timekeep *tk; uint32_t enabled, idx; =20 - sv =3D arg; - sx_xlock(&shared_page_alloc_sx); enabled =3D tc_fill_vdso_timehands(&th); - sf =3D shared_page_write_start(sv->sv_timekeep_off); - tk =3D (void *)(sf_buf_kva(sf) + (sv->sv_timekeep_off & PAGE_MASK)); + tk =3D (struct vdso_timekeep *)(shared_page_mapping + + sv->sv_timekeep_off); idx =3D sv->sv_timekeep_curr; atomic_store_rel_32(&tk->tk_th[idx].th_gen, 0); if (++idx >=3D VDSO_TH_NUM) @@ -1637,25 +1608,19 @@ timehands_update(void *arg) tk->tk_enabled =3D enabled; atomic_store_rel_32(&tk->tk_th[idx].th_gen, sv->sv_timekeep_gen); tk->tk_current =3D idx; - shared_page_write_end(sf); - sx_xunlock(&shared_page_alloc_sx); } =20 #ifdef COMPAT_FREEBSD32 static void -timehands_update32(void *arg) +timehands_update32(struct sysentvec *sv) { - struct sysentvec *sv; - struct sf_buf *sf; struct vdso_timekeep32 *tk; struct vdso_timehands32 th; uint32_t enabled, idx; =20 - sv =3D arg; - sx_xlock(&shared_page_alloc_sx); enabled =3D tc_fill_vdso_timehands32(&th); - sf =3D shared_page_write_start(sv->sv_timekeep_off); - tk =3D (void *)(sf_buf_kva(sf) + (sv->sv_timekeep_off & PAGE_MASK)); + tk =3D (struct vdso_timekeep32 *)(shared_page_mapping + + sv->sv_timekeep_off); idx =3D sv->sv_timekeep_curr; atomic_store_rel_32(&tk->tk_th[idx].th_gen, 0); if (++idx >=3D VDSO_TH_NUM) @@ -1669,11 +1634,32 @@ timehands_update32(void *arg) tk->tk_enabled =3D enabled; atomic_store_rel_32(&tk->tk_th[idx].th_gen, sv->sv_timekeep_gen); tk->tk_current =3D idx; - shared_page_write_end(sf); - sx_xunlock(&shared_page_alloc_sx); } #endif =20 +/* + * This is hackish, but easiest way to avoid creating list structures + * that needs to be iterated over from the hardclock interrupt + * context. + */ +static struct sysentvec *host_sysentvec; +#ifdef COMPAT_FREEBSD32 +static struct sysentvec *compat32_sysentvec; +#endif + +void +timekeep_push_vdso(void) +{ + + if (host_sysentvec !=3D NULL && host_sysentvec->sv_timekeep_base !=3D 0) + timehands_update(host_sysentvec); +#ifdef COMPAT_FREEBSD32 + if (compat32_sysentvec !=3D NULL && + compat32_sysentvec->sv_timekeep_base !=3D 0) + timehands_update32(compat32_sysentvec); +#endif +} + void exec_sysvec_init(void *param) { @@ -1688,29 +1674,32 @@ exec_sysvec_init(void *param) sv->sv_shared_page_obj =3D shared_page_obj; sv->sv_sigcode_base =3D sv->sv_shared_page_base + shared_page_fill(*(sv->sv_szsigcode), 16, sv->sv_sigcode); + if ((sv->sv_flags & SV_ABI_MASK) !=3D SV_ABI_FREEBSD) + return; tk_ver =3D VDSO_TK_VER_CURR; #ifdef COMPAT_FREEBSD32 if ((sv->sv_flags & SV_ILP32) !=3D 0) { tk_base =3D shared_page_alloc(sizeof(struct vdso_timekeep32) + sizeof(struct vdso_timehands32) * VDSO_TH_NUM, 16); KASSERT(tk_base !=3D -1, ("tk_base -1 for 32bit")); - EVENTHANDLER_REGISTER(tc_windup, timehands_update32, sv, - EVENTHANDLER_PRI_ANY); shared_page_write(tk_base + offsetof(struct vdso_timekeep32, tk_ver), sizeof(uint32_t), &tk_ver); + KASSERT(compat32_sysentvec =3D=3D 0, + ("Native compat32 already registered")); + compat32_sysentvec =3D sv; } else { #endif tk_base =3D shared_page_alloc(sizeof(struct vdso_timekeep) + sizeof(struct vdso_timehands) * VDSO_TH_NUM, 16); KASSERT(tk_base !=3D -1, ("tk_base -1 for native")); - EVENTHANDLER_REGISTER(tc_windup, timehands_update, sv, - EVENTHANDLER_PRI_ANY); shared_page_write(tk_base + offsetof(struct vdso_timekeep, tk_ver), sizeof(uint32_t), &tk_ver); + KASSERT(host_sysentvec =3D=3D 0, ("Native already registered")); + host_sysentvec =3D sv; #ifdef COMPAT_FREEBSD32 } #endif sv->sv_timekeep_base =3D sv->sv_shared_page_base + tk_base; sv->sv_timekeep_off =3D tk_base; - EVENTHANDLER_INVOKE(tc_windup); + timekeep_push_vdso(); } diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 0b8fefe..2950380 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -121,12 +120,8 @@ SYSCTL_INT(_kern_timecounter, OID_AUTO, stepwarnings, = CTLFLAG_RW, ×tepwarnings, 0, "Log time steps"); =20 static void tc_windup(void); -static void tc_windup_push_vdso(void *ctx, int pending); static void cpu_tick_calibrate(int); =20 -static struct task tc_windup_push_vdso_task =3D TASK_INITIALIZER(0, - tc_windup_push_vdso, 0); - static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) { @@ -1367,7 +1362,7 @@ tc_windup(void) #endif =20 timehands =3D th; - taskqueue_enqueue_fast(taskqueue_fast, &tc_windup_push_vdso_task); + timekeep_push_vdso(); } =20 /* Report or change the active timecounter hardware. */ @@ -1394,7 +1389,7 @@ sysctl_kern_timecounter_hardware(SYSCTL_HANDLER_ARGS) (void)newtc->tc_get_timecount(newtc); =20 timecounter =3D newtc; - EVENTHANDLER_INVOKE(tc_windup); + timekeep_push_vdso(); return (0); } return (EINVAL); @@ -1865,7 +1860,7 @@ sysctl_fast_gettime(SYSCTL_HANDLER_ARGS) if (error !=3D 0) return (error); vdso_th_enable =3D old_vdso_th_enable; - EVENTHANDLER_INVOKE(tc_windup); + timekeep_push_vdso(); return (0); } SYSCTL_PROC(_kern_timecounter, OID_AUTO, fast_gettime, @@ -1921,10 +1916,3 @@ tc_fill_vdso_timehands32(struct vdso_timehands32 *vd= so_th32) return (enabled); } #endif - -static void -tc_windup_push_vdso(void *ctx, int pending) -{ - - EVENTHANDLER_INVOKE(tc_windup); -} diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index 22769c2..6de72d9 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -265,8 +265,6 @@ int shared_page_alloc(int size, int align); int shared_page_fill(int size, int align, const void *data); void shared_page_write(int base, int size, const void *data); void exec_sysvec_init(void *param); -struct sf_buf *shared_page_write_start(int base); -void shared_page_write_end(struct sf_buf *sf); =20 #define INIT_SYSENTVEC(name, sv) \ SYSINIT(name, SI_SUB_EXEC, SI_ORDER_ANY, \ diff --git a/sys/sys/vdso.h b/sys/sys/vdso.h index 9f3f3af..653a606 100644 --- a/sys/sys/vdso.h +++ b/sys/sys/vdso.h @@ -29,7 +29,6 @@ #define _SYS_VDSO_H =20 #include -#include #include =20 struct vdso_timehands { @@ -74,6 +73,8 @@ u_int __vdso_gettc(const struct vdso_timehands *vdso_th); =20 #ifdef _KERNEL =20 +void timekeep_push_vdso(void); + uint32_t tc_fill_vdso_timehands(struct vdso_timehands *vdso_th); =20 /* @@ -86,9 +87,6 @@ uint32_t tc_fill_vdso_timehands(struct vdso_timehands *vd= so_th); */ uint32_t cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th); =20 -typedef void (*tc_windup_fn)(void *); -EVENTHANDLER_DECLARE(tc_windup, tc_windup_fn); - #define VDSO_TH_NUM 4 =20 #ifdef COMPAT_FREEBSD32 --qcmJb3WyrQSdDnng Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/kR64ACgkQC3+MBN1Mb4iD0wCfV2ntAMF9n2NrsT6mDQi0oAyV 7JoAn3M8eagjY12jGxrhQpIxC5+mU6oR =c0ch -----END PGP SIGNATURE----- --qcmJb3WyrQSdDnng-- From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 10:46:35 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E7794106566C; Fri, 22 Jun 2012 10:46:35 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id CF24F8FC0C; Fri, 22 Jun 2012 10:46:34 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q5MAkQS9039120; Fri, 22 Jun 2012 13:46:26 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q5MAkQbu041972; Fri, 22 Jun 2012 13:46:26 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q5MAkQAA041971; Fri, 22 Jun 2012 13:46:26 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 22 Jun 2012 13:46:26 +0300 From: Konstantin Belousov To: Alexander Motin Message-ID: <20120622104626.GE2337@deviant.kiev.zoral.com.ua> References: <201206220706.q5M76fbO062751@svn.freebsd.org> <4FE42812.3050807@FreeBSD.org> <20120622082502.GB2337@deviant.kiev.zoral.com.ua> <4FE432C4.7000608@FreeBSD.org> <20120622102342.GD2337@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="r5UKZFo5ar5Icv+k" Content-Disposition: inline In-Reply-To: <20120622102342.GD2337@deviant.kiev.zoral.com.ua> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237433 - in head/sys: amd64/include arm/include conf i386/include ia64/include kern mips/include pc98/include powerpc/include sparc64/include sys x86/include x86/x86 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 10:46:36 -0000 --r5UKZFo5ar5Icv+k Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 22, 2012 at 01:23:42PM +0300, Konstantin Belousov wrote: > On Fri, Jun 22, 2012 at 11:54:28AM +0300, Alexander Motin wrote: > > On 22.06.2012 11:25, Konstantin Belousov wrote: > > >On Fri, Jun 22, 2012 at 11:08:50AM +0300, Alexander Motin wrote: > > >>On 06/22/12 10:06, Konstantin Belousov wrote: > > >>>Author: kib > > >>>Date: Fri Jun 22 07:06:40 2012 > > >>>New Revision: 237433 > > >>>URL: http://svn.freebsd.org/changeset/base/237433 > > >>> > > >>>Log: > > >>> Implement mechanism to export some kernel timekeeping data to > > >>> usermode, using shared page. The structures and functions have v= dso > > >>> prefix, to indicate the intended location of the code in some fut= ure. > > >>> > > >>> The versioned per-algorithm data is exported in the format of str= uct > > >>> vdso_timehands, which mostly repeats the content of in-kernel str= uct > > >>> timehands. Usermode reading of the structure can be lockless. > > >>> Compatibility export for 32bit processes on 64bit host is also > > >>> provided. Kernel also provides usermode with indication about > > >>> currently used timecounter, so that libc can fall back to syscall= if > > >>> configured timecounter is unknown to usermode code. > > >>> > > >>> The shared data updates are initiated both from the tc_windup(), = where > > >>> a fast task is queued to do the update, and from sysctl handlers = which > > >>> change timecounter. A manual override switch > > >>> kern.timecounter.fast_gettime allows to turn off the mechanism. > > >>> > > >>> Only x86 architectures export the real algorithm data, and there,= only > > >>> for tsc timecounter. HPET counters page could be exported as well= , but > > >>> I prefer to not further glue the kernel and libc ABI there until > > >>> proper vdso-based solution is developed. > > >>> > > >>> Minimal stubs neccessary for non-x86 architectures to still compi= le > > >>> are provided. > > >>> > > >>> Discussed with: bde > > >>> Reviewed by: jhb > > >>> Tested by: flo > > >>> MFC after: 1 month > > >> > > >> > > >>>@@ -1360,6 +1367,7 @@ tc_windup(void) > > >>> #endif > > >>> > > >>> timehands =3D th; > > >>>+ taskqueue_enqueue_fast(taskqueue_fast,&tc_windup_push_vdso_task); > > >>> } > > >>> > > >>> /* Report or change the active timecounter hardware. */ > > >> > > >>This taskqueue_enqueue_fast() will schedule extra thread to run each > > >>time hardclock() fires. One thread may be not a big problem, but > > >>together with callout swi and possible other threads woken up there it > > >>will wake up several other CPU cores from sleep just to put them back= in > > >>few microseconds. Now davide@ and me are trying to fix that by avoidi= ng > > >>callout SWI use for simple tasks. Please, let's not create another > > >>problem same time. > > > > > >The patch was public for quite a time. If you have some comments about > > >it, it would be much more productive to let me know about them before > > >the commit, not after. > >=20 > > I'm sorry, I haven't seen it. My mad. > >=20 > > >Anyway, what is your proposal for 'let's not create another problem > > >same time' part of the message ? It was discussed, as a possibility, > > >to have permanent mapping for the shared page in the KVA and to perform > > >lock-less update of the struct vdso_timehands directly from hardclock > > >handler. My opinion was that amount of work added by tc_windup > > >eventhandler is not trivial, so it is better to be postponed to > > >less critical context. It also slightly more safe to not perform > > >lockless update for vdso_timehands, since otherwise module load which > > >register exec handler could cause transient gettimeofday() failure > > >in usermode. > > > > > >This might boil down to the fact that tc_windup function is called > > >too often, in fact. Also, packing execution of tc_windup eventhandler > > >together with the clock swi is fine from my POV. > >=20 > > I have nothing against using shared pages. On UP system I would probabl= y=20 > > have not so much against several threads. But on SMP system it will=20 > > cause at least one, but in many cases two extra CPUs to be woken up.=20 > > There are two or more threads to run on hardclock(): this taskqueue,=20 > > callout swi and some thread(s) woken from callouts. Scheduler has no=20 > > idea how heavy they are. So it will try to move each of them to separat= e=20 > > idle CPU. Does the amount of work done in event handlers worth extra=20 > > Watts consumed by rapidly waking CPUs? As quite rare person running=20 > > FreeBSD on laptop, I am not sure. I am not sure even that on=20 > > desktop/server this won't kill all benefit of fast clocks by limiting= =20 > > TurboBoost. >=20 > Patch below would probably work, but I cannot test it right now on real > hardware due to ACPI issue. It worked for me in qemu. >=20 > commit 4f2ffd93b36d20eae61495776fc6b0855745fd7f > Author: Konstantin Belousov > Date: Fri Jun 22 13:19:22 2012 +0300 >=20 > Use persistent kernel mapping of the shared page, and update the > vdso_timehands from hardclock, instead of scheduling task. Slightly improved version. Since tc_fill_vdso_timehands is now called from hardclock context, thee is no need to spin waiting for valid current generation of timehands. diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 80502e3..9365223 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1517,42 +1517,13 @@ exec_unregister(execsw_arg) static struct sx shared_page_alloc_sx; static vm_object_t shared_page_obj; static int shared_page_free; - -struct sf_buf * -shared_page_write_start(int base) -{ - vm_page_t m; - struct sf_buf *s; - - VM_OBJECT_LOCK(shared_page_obj); - m =3D vm_page_grab(shared_page_obj, OFF_TO_IDX(base), VM_ALLOC_RETRY); - VM_OBJECT_UNLOCK(shared_page_obj); - s =3D sf_buf_alloc(m, SFB_DEFAULT); - return (s); -} - -void -shared_page_write_end(struct sf_buf *sf) -{ - vm_page_t m; - - m =3D sf_buf_page(sf); - sf_buf_free(sf); - VM_OBJECT_LOCK(shared_page_obj); - vm_page_wakeup(m); - VM_OBJECT_UNLOCK(shared_page_obj); -} +char *shared_page_mapping; =20 void shared_page_write(int base, int size, const void *data) { - struct sf_buf *sf; - vm_offset_t sk; =20 - sf =3D shared_page_write_start(base); - sk =3D sf_buf_kva(sf); - bcopy(data, (void *)(sk + (base & PAGE_MASK)), size); - shared_page_write_end(sf); + bcopy(data, shared_page_mapping + base, size); } =20 static int @@ -1596,6 +1567,7 @@ static void shared_page_init(void *dummy __unused) { vm_page_t m; + vm_offset_t addr; =20 sx_init(&shared_page_alloc_sx, "shpsx"); shared_page_obj =3D vm_pager_allocate(OBJT_PHYS, 0, PAGE_SIZE, @@ -1605,25 +1577,24 @@ shared_page_init(void *dummy __unused) VM_ALLOC_ZERO); m->valid =3D VM_PAGE_BITS_ALL; VM_OBJECT_UNLOCK(shared_page_obj); + addr =3D kmem_alloc_nofault(kernel_map, PAGE_SIZE); + pmap_qenter(addr, &m, 1); + shared_page_mapping =3D (char *)addr; } =20 SYSINIT(shp, SI_SUB_EXEC, SI_ORDER_FIRST, (sysinit_cfunc_t)shared_page_ini= t, NULL); =20 static void -timehands_update(void *arg) +timehands_update(struct sysentvec *sv) { - struct sysentvec *sv; - struct sf_buf *sf; struct vdso_timehands th; struct vdso_timekeep *tk; uint32_t enabled, idx; =20 - sv =3D arg; - sx_xlock(&shared_page_alloc_sx); enabled =3D tc_fill_vdso_timehands(&th); - sf =3D shared_page_write_start(sv->sv_timekeep_off); - tk =3D (void *)(sf_buf_kva(sf) + (sv->sv_timekeep_off & PAGE_MASK)); + tk =3D (struct vdso_timekeep *)(shared_page_mapping + + sv->sv_timekeep_off); idx =3D sv->sv_timekeep_curr; atomic_store_rel_32(&tk->tk_th[idx].th_gen, 0); if (++idx >=3D VDSO_TH_NUM) @@ -1637,25 +1608,19 @@ timehands_update(void *arg) tk->tk_enabled =3D enabled; atomic_store_rel_32(&tk->tk_th[idx].th_gen, sv->sv_timekeep_gen); tk->tk_current =3D idx; - shared_page_write_end(sf); - sx_xunlock(&shared_page_alloc_sx); } =20 #ifdef COMPAT_FREEBSD32 static void -timehands_update32(void *arg) +timehands_update32(struct sysentvec *sv) { - struct sysentvec *sv; - struct sf_buf *sf; struct vdso_timekeep32 *tk; struct vdso_timehands32 th; uint32_t enabled, idx; =20 - sv =3D arg; - sx_xlock(&shared_page_alloc_sx); enabled =3D tc_fill_vdso_timehands32(&th); - sf =3D shared_page_write_start(sv->sv_timekeep_off); - tk =3D (void *)(sf_buf_kva(sf) + (sv->sv_timekeep_off & PAGE_MASK)); + tk =3D (struct vdso_timekeep32 *)(shared_page_mapping + + sv->sv_timekeep_off); idx =3D sv->sv_timekeep_curr; atomic_store_rel_32(&tk->tk_th[idx].th_gen, 0); if (++idx >=3D VDSO_TH_NUM) @@ -1669,11 +1634,32 @@ timehands_update32(void *arg) tk->tk_enabled =3D enabled; atomic_store_rel_32(&tk->tk_th[idx].th_gen, sv->sv_timekeep_gen); tk->tk_current =3D idx; - shared_page_write_end(sf); - sx_xunlock(&shared_page_alloc_sx); } #endif =20 +/* + * This is hackish, but easiest way to avoid creating list structures + * that needs to be iterated over from the hardclock interrupt + * context. + */ +static struct sysentvec *host_sysentvec; +#ifdef COMPAT_FREEBSD32 +static struct sysentvec *compat32_sysentvec; +#endif + +void +timekeep_push_vdso(void) +{ + + if (host_sysentvec !=3D NULL && host_sysentvec->sv_timekeep_base !=3D 0) + timehands_update(host_sysentvec); +#ifdef COMPAT_FREEBSD32 + if (compat32_sysentvec !=3D NULL && + compat32_sysentvec->sv_timekeep_base !=3D 0) + timehands_update32(compat32_sysentvec); +#endif +} + void exec_sysvec_init(void *param) { @@ -1688,29 +1674,32 @@ exec_sysvec_init(void *param) sv->sv_shared_page_obj =3D shared_page_obj; sv->sv_sigcode_base =3D sv->sv_shared_page_base + shared_page_fill(*(sv->sv_szsigcode), 16, sv->sv_sigcode); + if ((sv->sv_flags & SV_ABI_MASK) !=3D SV_ABI_FREEBSD) + return; tk_ver =3D VDSO_TK_VER_CURR; #ifdef COMPAT_FREEBSD32 if ((sv->sv_flags & SV_ILP32) !=3D 0) { tk_base =3D shared_page_alloc(sizeof(struct vdso_timekeep32) + sizeof(struct vdso_timehands32) * VDSO_TH_NUM, 16); KASSERT(tk_base !=3D -1, ("tk_base -1 for 32bit")); - EVENTHANDLER_REGISTER(tc_windup, timehands_update32, sv, - EVENTHANDLER_PRI_ANY); shared_page_write(tk_base + offsetof(struct vdso_timekeep32, tk_ver), sizeof(uint32_t), &tk_ver); + KASSERT(compat32_sysentvec =3D=3D 0, + ("Native compat32 already registered")); + compat32_sysentvec =3D sv; } else { #endif tk_base =3D shared_page_alloc(sizeof(struct vdso_timekeep) + sizeof(struct vdso_timehands) * VDSO_TH_NUM, 16); KASSERT(tk_base !=3D -1, ("tk_base -1 for native")); - EVENTHANDLER_REGISTER(tc_windup, timehands_update, sv, - EVENTHANDLER_PRI_ANY); shared_page_write(tk_base + offsetof(struct vdso_timekeep, tk_ver), sizeof(uint32_t), &tk_ver); + KASSERT(host_sysentvec =3D=3D 0, ("Native already registered")); + host_sysentvec =3D sv; #ifdef COMPAT_FREEBSD32 } #endif sv->sv_timekeep_base =3D sv->sv_shared_page_base + tk_base; sv->sv_timekeep_off =3D tk_base; - EVENTHANDLER_INVOKE(tc_windup); + timekeep_push_vdso(); } diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 0b8fefe..4a75af5 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -121,12 +120,8 @@ SYSCTL_INT(_kern_timecounter, OID_AUTO, stepwarnings, = CTLFLAG_RW, ×tepwarnings, 0, "Log time steps"); =20 static void tc_windup(void); -static void tc_windup_push_vdso(void *ctx, int pending); static void cpu_tick_calibrate(int); =20 -static struct task tc_windup_push_vdso_task =3D TASK_INITIALIZER(0, - tc_windup_push_vdso, 0); - static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) { @@ -1367,7 +1362,7 @@ tc_windup(void) #endif =20 timehands =3D th; - taskqueue_enqueue_fast(taskqueue_fast, &tc_windup_push_vdso_task); + timekeep_push_vdso(); } =20 /* Report or change the active timecounter hardware. */ @@ -1394,7 +1389,7 @@ sysctl_kern_timecounter_hardware(SYSCTL_HANDLER_ARGS) (void)newtc->tc_get_timecount(newtc); =20 timecounter =3D newtc; - EVENTHANDLER_INVOKE(tc_windup); + timekeep_push_vdso(); return (0); } return (EINVAL); @@ -1865,7 +1860,7 @@ sysctl_fast_gettime(SYSCTL_HANDLER_ARGS) if (error !=3D 0) return (error); vdso_th_enable =3D old_vdso_th_enable; - EVENTHANDLER_INVOKE(tc_windup); + timekeep_push_vdso(); return (0); } SYSCTL_PROC(_kern_timecounter, OID_AUTO, fast_gettime, @@ -1877,19 +1872,15 @@ tc_fill_vdso_timehands(struct vdso_timehands *vdso_= th) { struct timehands *th; uint32_t enabled; - int gen; =20 - do { - th =3D timehands; - gen =3D th->th_generation; - vdso_th->th_algo =3D VDSO_TH_ALGO_1; - vdso_th->th_scale =3D th->th_scale; - vdso_th->th_offset_count =3D th->th_offset_count; - vdso_th->th_counter_mask =3D th->th_counter->tc_counter_mask; - vdso_th->th_offset =3D th->th_offset; - vdso_th->th_boottime =3D boottimebin; - enabled =3D cpu_fill_vdso_timehands(vdso_th); - } while (gen =3D=3D 0 || timehands->th_generation !=3D gen); + th =3D timehands; + vdso_th->th_algo =3D VDSO_TH_ALGO_1; + vdso_th->th_scale =3D th->th_scale; + vdso_th->th_offset_count =3D th->th_offset_count; + vdso_th->th_counter_mask =3D th->th_counter->tc_counter_mask; + vdso_th->th_offset =3D th->th_offset; + vdso_th->th_boottime =3D boottimebin; + enabled =3D cpu_fill_vdso_timehands(vdso_th); if (!vdso_th_enable) enabled =3D 0; return (enabled); @@ -1901,30 +1892,19 @@ tc_fill_vdso_timehands32(struct vdso_timehands32 *v= dso_th32) { struct timehands *th; uint32_t enabled; - int gen; =20 - do { - th =3D timehands; - gen =3D th->th_generation; - vdso_th32->th_algo =3D VDSO_TH_ALGO_1; - *(uint64_t *)&vdso_th32->th_scale[0] =3D th->th_scale; - vdso_th32->th_offset_count =3D th->th_offset_count; - vdso_th32->th_counter_mask =3D th->th_counter->tc_counter_mask; - vdso_th32->th_offset.sec =3D th->th_offset.sec; - *(uint64_t *)&vdso_th32->th_offset.frac[0] =3D th->th_offset.frac; - vdso_th32->th_boottime.sec =3D boottimebin.sec; - *(uint64_t *)&vdso_th32->th_boottime.frac[0] =3D boottimebin.frac; - enabled =3D cpu_fill_vdso_timehands32(vdso_th32); - } while (gen =3D=3D 0 || timehands->th_generation !=3D gen); + th =3D timehands; + vdso_th32->th_algo =3D VDSO_TH_ALGO_1; + *(uint64_t *)&vdso_th32->th_scale[0] =3D th->th_scale; + vdso_th32->th_offset_count =3D th->th_offset_count; + vdso_th32->th_counter_mask =3D th->th_counter->tc_counter_mask; + vdso_th32->th_offset.sec =3D th->th_offset.sec; + *(uint64_t *)&vdso_th32->th_offset.frac[0] =3D th->th_offset.frac; + vdso_th32->th_boottime.sec =3D boottimebin.sec; + *(uint64_t *)&vdso_th32->th_boottime.frac[0] =3D boottimebin.frac; + enabled =3D cpu_fill_vdso_timehands32(vdso_th32); if (!vdso_th_enable) enabled =3D 0; return (enabled); } #endif - -static void -tc_windup_push_vdso(void *ctx, int pending) -{ - - EVENTHANDLER_INVOKE(tc_windup); -} diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index 22769c2..6de72d9 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -265,8 +265,6 @@ int shared_page_alloc(int size, int align); int shared_page_fill(int size, int align, const void *data); void shared_page_write(int base, int size, const void *data); void exec_sysvec_init(void *param); -struct sf_buf *shared_page_write_start(int base); -void shared_page_write_end(struct sf_buf *sf); =20 #define INIT_SYSENTVEC(name, sv) \ SYSINIT(name, SI_SUB_EXEC, SI_ORDER_ANY, \ diff --git a/sys/sys/vdso.h b/sys/sys/vdso.h index 9f3f3af..653a606 100644 --- a/sys/sys/vdso.h +++ b/sys/sys/vdso.h @@ -29,7 +29,6 @@ #define _SYS_VDSO_H =20 #include -#include #include =20 struct vdso_timehands { @@ -74,6 +73,8 @@ u_int __vdso_gettc(const struct vdso_timehands *vdso_th); =20 #ifdef _KERNEL =20 +void timekeep_push_vdso(void); + uint32_t tc_fill_vdso_timehands(struct vdso_timehands *vdso_th); =20 /* @@ -86,9 +87,6 @@ uint32_t tc_fill_vdso_timehands(struct vdso_timehands *vd= so_th); */ uint32_t cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th); =20 -typedef void (*tc_windup_fn)(void *); -EVENTHANDLER_DECLARE(tc_windup, tc_windup_fn); - #define VDSO_TH_NUM 4 =20 #ifdef COMPAT_FREEBSD32 --r5UKZFo5ar5Icv+k Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/kTQEACgkQC3+MBN1Mb4j1JwCbBlIe+aX2TtvQoMbqZCMiLbeq bZIAnRAqwAxtQl8uMWjTfO/+Xi+ysCfM =nV8y -----END PGP SIGNATURE----- --r5UKZFo5ar5Icv+k-- From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 10:56:03 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 75CDD106566B; Fri, 22 Jun 2012 10:56:03 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id 687EF8FC1C; Fri, 22 Jun 2012 10:56:02 +0000 (UTC) Received: by lbon10 with SMTP id n10so4199785lbo.13 for ; Fri, 22 Jun 2012 03:56:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=n56Zzf2SkirEAWcoEB4xiY4eaFX+eMcCwkymXk2Ics8=; b=M7XL42czxv2CWSSs2sFBfR7oRaxTBsVXpI2mh0vXh92bebnb+eo4JzwAV/zqTx+fXF S31ecsBynR03KZ9r4Je3A8fsfb5WCw38kjU+4G7CvDOxwvQ4wl3WIYP3/HnKkrTL2Jl9 iYHPFcMcgeDAnFAVdCcJ+XB2ki5o02xsEg6/dHvu17FgR3Epf5PhA70wgNL37EoTqCvL jVHExiTmhPWHHUrv+QyQq6O9S589Zx3/ioRzUfPteTN38NyHIBKnWD49yU4DaW7LtHQF LHeTEkMmqyMXe/iCx1qVLe0LfdbkPFcN97NB1Zba/NQ9/PFIZxJNwRxAVJFaByb+s5ct FV+Q== Received: by 10.112.103.130 with SMTP id fw2mr1270950lbb.107.1340362561056; Fri, 22 Jun 2012 03:56:01 -0700 (PDT) Received: from mavbook2.mavhome.dp.ua (pc.mavhome.dp.ua. [212.86.226.226]) by mx.google.com with ESMTPS id q8sm20660474lbj.2.2012.06.22.03.55.58 (version=SSLv3 cipher=OTHER); Fri, 22 Jun 2012 03:56:00 -0700 (PDT) Sender: Alexander Motin Message-ID: <4FE44F3C.5040108@FreeBSD.org> Date: Fri, 22 Jun 2012 13:55:56 +0300 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:13.0) Gecko/20120618 Thunderbird/13.0 MIME-Version: 1.0 To: Konstantin Belousov References: <201206220706.q5M76fbO062751@svn.freebsd.org> <4FE42812.3050807@FreeBSD.org> <20120622082502.GB2337@deviant.kiev.zoral.com.ua> <4FE432C4.7000608@FreeBSD.org> <20120622102342.GD2337@deviant.kiev.zoral.com.ua> <20120622104626.GE2337@deviant.kiev.zoral.com.ua> In-Reply-To: <20120622104626.GE2337@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237433 - in head/sys: amd64/include arm/include conf i386/include ia64/include kern mips/include pc98/include powerpc/include sparc64/include sys x86/include x86/x86 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 10:56:03 -0000 On 06/22/12 13:46, Konstantin Belousov wrote: > On Fri, Jun 22, 2012 at 01:23:42PM +0300, Konstantin Belousov wrote: >> On Fri, Jun 22, 2012 at 11:54:28AM +0300, Alexander Motin wrote: >>> On 22.06.2012 11:25, Konstantin Belousov wrote: >>>> On Fri, Jun 22, 2012 at 11:08:50AM +0300, Alexander Motin wrote: >>>>> On 06/22/12 10:06, Konstantin Belousov wrote: >>>>>> Author: kib >>>>>> Date: Fri Jun 22 07:06:40 2012 >>>>>> New Revision: 237433 >>>>>> URL: http://svn.freebsd.org/changeset/base/237433 >>>>>> >>>>>> Log: >>>>>> Implement mechanism to export some kernel timekeeping data to >>>>>> usermode, using shared page. The structures and functions have vdso >>>>>> prefix, to indicate the intended location of the code in some future. >>>>>> >>>>>> The versioned per-algorithm data is exported in the format of struct >>>>>> vdso_timehands, which mostly repeats the content of in-kernel struct >>>>>> timehands. Usermode reading of the structure can be lockless. >>>>>> Compatibility export for 32bit processes on 64bit host is also >>>>>> provided. Kernel also provides usermode with indication about >>>>>> currently used timecounter, so that libc can fall back to syscall if >>>>>> configured timecounter is unknown to usermode code. >>>>>> >>>>>> The shared data updates are initiated both from the tc_windup(), where >>>>>> a fast task is queued to do the update, and from sysctl handlers which >>>>>> change timecounter. A manual override switch >>>>>> kern.timecounter.fast_gettime allows to turn off the mechanism. >>>>>> >>>>>> Only x86 architectures export the real algorithm data, and there, only >>>>>> for tsc timecounter. HPET counters page could be exported as well, but >>>>>> I prefer to not further glue the kernel and libc ABI there until >>>>>> proper vdso-based solution is developed. >>>>>> >>>>>> Minimal stubs neccessary for non-x86 architectures to still compile >>>>>> are provided. >>>>>> >>>>>> Discussed with: bde >>>>>> Reviewed by: jhb >>>>>> Tested by: flo >>>>>> MFC after: 1 month >>>>> >>>>> >>>>>> @@ -1360,6 +1367,7 @@ tc_windup(void) >>>>>> #endif >>>>>> >>>>>> timehands = th; >>>>>> + taskqueue_enqueue_fast(taskqueue_fast,&tc_windup_push_vdso_task); >>>>>> } >>>>>> >>>>>> /* Report or change the active timecounter hardware. */ >>>>> >>>>> This taskqueue_enqueue_fast() will schedule extra thread to run each >>>>> time hardclock() fires. One thread may be not a big problem, but >>>>> together with callout swi and possible other threads woken up there it >>>>> will wake up several other CPU cores from sleep just to put them back in >>>>> few microseconds. Now davide@ and me are trying to fix that by avoiding >>>>> callout SWI use for simple tasks. Please, let's not create another >>>>> problem same time. >>>> >>>> The patch was public for quite a time. If you have some comments about >>>> it, it would be much more productive to let me know about them before >>>> the commit, not after. >>> >>> I'm sorry, I haven't seen it. My mad. >>> >>>> Anyway, what is your proposal for 'let's not create another problem >>>> same time' part of the message ? It was discussed, as a possibility, >>>> to have permanent mapping for the shared page in the KVA and to perform >>>> lock-less update of the struct vdso_timehands directly from hardclock >>>> handler. My opinion was that amount of work added by tc_windup >>>> eventhandler is not trivial, so it is better to be postponed to >>>> less critical context. It also slightly more safe to not perform >>>> lockless update for vdso_timehands, since otherwise module load which >>>> register exec handler could cause transient gettimeofday() failure >>>> in usermode. >>>> >>>> This might boil down to the fact that tc_windup function is called >>>> too often, in fact. Also, packing execution of tc_windup eventhandler >>>> together with the clock swi is fine from my POV. >>> >>> I have nothing against using shared pages. On UP system I would probably >>> have not so much against several threads. But on SMP system it will >>> cause at least one, but in many cases two extra CPUs to be woken up. >>> There are two or more threads to run on hardclock(): this taskqueue, >>> callout swi and some thread(s) woken from callouts. Scheduler has no >>> idea how heavy they are. So it will try to move each of them to separate >>> idle CPU. Does the amount of work done in event handlers worth extra >>> Watts consumed by rapidly waking CPUs? As quite rare person running >>> FreeBSD on laptop, I am not sure. I am not sure even that on >>> desktop/server this won't kill all benefit of fast clocks by limiting >>> TurboBoost. >> >> Patch below would probably work, but I cannot test it right now on real >> hardware due to ACPI issue. It worked for me in qemu. >> >> commit 4f2ffd93b36d20eae61495776fc6b0855745fd7f >> Author: Konstantin Belousov >> Date: Fri Jun 22 13:19:22 2012 +0300 >> >> Use persistent kernel mapping of the shared page, and update the >> vdso_timehands from hardclock, instead of scheduling task. > > Slightly improved version. Since tc_fill_vdso_timehands is now > called from hardclock context, thee is no need to spin waiting for > valid current generation of timehands. I can't evaluate how much "hackish" this is from memory management side, but I'm glad there is some viable solution. Thank you! -- Alexander Motin From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 14:24:21 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 348421065670; Fri, 22 Jun 2012 14:24:21 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id 073888FC0A; Fri, 22 Jun 2012 14:24:21 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 4A5F1B96C; Fri, 22 Jun 2012 10:24:20 -0400 (EDT) From: John Baldwin To: Marius Strobl Date: Fri, 22 Jun 2012 09:57:01 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p13; KDE/4.5.5; amd64; ; ) References: <201206220713.q5M7DVH0063098@svn.freebsd.org> <20120622073455.GE69382@alchemy.franken.de> In-Reply-To: <20120622073455.GE69382@alchemy.franken.de> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201206220957.01341.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 22 Jun 2012 10:24:20 -0400 (EDT) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Konstantin Belousov Subject: Re: svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 14:24:21 -0000 On Friday, June 22, 2012 3:34:56 am Marius Strobl wrote: > On Fri, Jun 22, 2012 at 07:13:31AM +0000, Konstantin Belousov wrote: > > Author: kib > > Date: Fri Jun 22 07:13:30 2012 > > New Revision: 237434 > > URL: http://svn.freebsd.org/changeset/base/237434 > > > > Log: > > Use struct vdso_timehands data to implement fast gettimeofday(2) and > > clock_gettime(2) functions if supported. The speedup seen in > > microbenchmarks is in range 4x-7x depending on the hardware. > > > > Only amd64 and i386 architectures are supported. Libc uses rdtsc and > > kernel data to calculate current time, if enabled by kernel. > > I don't know much about x86 CPUs but is my understanding correct > that TSCs are not synchronized in any way across CPUs, i.e. > reading it on different CPUs may result in time going backwards > etc., which is okay for this application though? Hmm, in practice I have found that on modern x86 CPUs (Penryn and later) the TSC is in fact sychronized across packages at work. At least, when I measure skew across packages it appears to be consistent with the time it would take a write to propagate from one to the other. -- John Baldwin From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 15:53:32 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1D78A106564A; Fri, 22 Jun 2012 15:53:32 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from hammer.pct.niksun.com (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 5E33E8FC08; Fri, 22 Jun 2012 15:53:31 +0000 (UTC) Message-ID: <4FE494FA.1030907@FreeBSD.org> Date: Fri, 22 Jun 2012 11:53:30 -0400 From: Jung-uk Kim User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:13.0) Gecko/20120612 Thunderbird/13.0 MIME-Version: 1.0 To: Konstantin Belousov References: <201206220040.q5M0ejNk045397@svn.freebsd.org> <20120622095847.GC2337@deviant.kiev.zoral.com.ua> In-Reply-To: <20120622095847.GC2337@deviant.kiev.zoral.com.ua> X-Enigmail-Version: 1.4.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237412 - in head: sys/contrib/dev/acpica sys/contrib/dev/acpica/common sys/contrib/dev/acpica/compiler sys/contrib/dev/acpica/components/debugger sys/contrib/dev/acpica/components/disa... X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 15:53:32 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 2012-06-22 05:58:47 -0400, Konstantin Belousov wrote: > On Fri, Jun 22, 2012 at 12:40:45AM +0000, Jung-uk Kim wrote: >> Author: jkim Date: Fri Jun 22 00:40:44 2012 New Revision: 237412 >> URL: http://svn.freebsd.org/changeset/base/237412 >> >> Log: Merge ACPICA 20120620. > > I think it is caused by import, malloc is called while spinlock is > held: > > ACPI: Executed 1 blocks of module-level executable AML code acpi0: > Power Button (fixed) panic: blockable sleep lock (sleep mutex) 16 @ > /usr/home/kostik/work/build/bsd/DEV/src/sys/vm/uma_core.c:2040 > cpuid = 0 KDB: stack backtrace: db_trace_self_wrapper() at > 0xffffffff80279d0a = db_trace_self_wrapper+0x2a panic() at > 0xffffffff80325a28 = panic+0x1d8 witness_checkorder() at > 0xffffffff80377938 = witness_checkorder+0x1d8 _mtx_lock_flags() at > 0xffffffff80313777 = _mtx_lock_flags+0x87 uma_zalloc_arg() at > 0xffffffff804db97a = uma_zalloc_arg+0x2ea malloc() at > 0xffffffff8030f7cd = malloc+0xbd AcpiUtAllocate() at > 0xffffffff802704f1 = AcpiUtAllocate+0x31 AcpiUtAllocateZeroed() at > 0xffffffff80270559 = AcpiUtAllocateZeroed+0x19 > AcpiSetupGpeForWake() at 0xffffffff8025becc = > AcpiSetupGpeForWake+0xfc acpi_probe_child() at 0xffffffff802848e9 = > acpi_probe_child+0x2b9 AcpiNsWalkNamespace() at 0xffffffff802686ef > = AcpiNsWalkNamespace+0x15f AcpiWalkNamespace() at > 0xffffffff80268c0f = AcpiWalkNamespace+0xbf acpi_attach() at > 0xffffffff80283e43 = acpi_attach+0x993 device_attach() at > 0xffffffff8035ab62 = device_attach+0x72 bus_generic_attach() at > 0xffffffff8035bd3a = bus_generic_attach+0x1a nexus_acpi_attach() at > 0xffffffff804fbd89 = nexus_acpi_attach+0x69 device_attach() at > 0xffffffff8035ab62 = device_attach+0x72 bus_generic_new_pass() at > 0xffffffff8035bf46 = bus_generic_new_pass+0xd6 bus_set_pass() at > 0xffffffff803597ba = bus_set_pass+0x7a configure() at > 0xffffffff804fd51a = configure+0xa mi_startup() at > 0xffffffff802d5c17 = mi_startup+0x77 btext() at 0xffffffff802531cc > = btext+0x2c KDB: enter: panic [ thread pid 0 tid 100000 ] Stopped > at 0xffffffff8035fffb = kdb_enter+0x3b: movq > $0,0x1027d62(%rip) db> show alllocks Process 0 (kernel) thread > 0xffffffff80837cc0 (100000) exclusive sleep mutex Giant (Giant) r = > 0 (0xffffffff8133a900) locked @ > /usr/home/kostik/work/build/bsd/DEV/src/sys/kern/kern_module.c:116 > exclusive spin mutex ACPI lock (0xfffffe000321da80) (ACPI lock > (0xfffffe000321da80)) r = 0 (0xfffffe000321da80) locked @ > /usr/home/kostik/work/build/bsd/DEV/src/sys/dev/acpica/Osd/OsdSynch.c:535 Hmm... > I was afraid it might happen. I'll look into it ASAP. Sorry for the trouble, Jung-uk Kim -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk/klPoACgkQmlay1b9qnVMg+QCggRXxXE2Wpc6kXWSpwbykhrWq RvQAniVjs7p/084ZnlDPA+GQqyxTIF/w =+7Iw -----END PGP SIGNATURE----- From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 16:05:57 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2B2321065677; Fri, 22 Jun 2012 16:05:57 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 162DA8FC19; Fri, 22 Jun 2012 16:05:57 +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 q5MG5uGK087329; Fri, 22 Jun 2012 16:05:56 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5MG5uJJ087327; Fri, 22 Jun 2012 16:05:56 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206221605.q5MG5uJJ087327@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 22 Jun 2012 16:05:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237445 - head/sys/i386/i386 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 16:05:57 -0000 Author: kib Date: Fri Jun 22 16:05:56 2012 New Revision: 237445 URL: http://svn.freebsd.org/changeset/base/237445 Log: Commit changes missed from r237435. Properly calculate the signal trampoline addresses after the shared page is enabled. Handle FreeBSD ABIs without shared page support too. Reported and tested by: David Wolfskill (previous version) Pointy hat to: kib MFC after: 1 month Modified: head/sys/i386/i386/machdep.c Modified: head/sys/i386/i386/machdep.c ============================================================================== --- head/sys/i386/i386/machdep.c Fri Jun 22 14:58:40 2012 (r237444) +++ head/sys/i386/i386/machdep.c Fri Jun 22 16:05:56 2012 (r237445) @@ -469,7 +469,13 @@ osendsig(sig_t catcher, ksiginfo_t *ksi, } regs->tf_esp = (int)fp; - regs->tf_eip = PS_STRINGS - szosigcode; + if (p->p_sysent->sv_sigcode_base != 0) { + regs->tf_eip = p->p_sysent->sv_sigcode_base + szsigcode - + szosigcode; + } else { + /* a.out sysentvec does not use shared page */ + regs->tf_eip = p->p_sysent->sv_psstrings - szosigcode; + } regs->tf_eflags &= ~(PSL_T | PSL_D); regs->tf_cs = _ucodesel; regs->tf_ds = _udatasel; @@ -596,7 +602,8 @@ freebsd4_sendsig(sig_t catcher, ksiginfo } regs->tf_esp = (int)sfp; - regs->tf_eip = PS_STRINGS - szfreebsd4_sigcode; + regs->tf_eip = p->p_sysent->sv_sigcode_base + szsigcode - + szfreebsd4_sigcode; regs->tf_eflags &= ~(PSL_T | PSL_D); regs->tf_cs = _ucodesel; regs->tf_ds = _udatasel; @@ -747,7 +754,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, } regs->tf_esp = (int)sfp; - regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode); + regs->tf_eip = p->p_sysent->sv_sigcode_base; regs->tf_eflags &= ~(PSL_T | PSL_D); regs->tf_cs = _ucodesel; regs->tf_ds = _udatasel; From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 16:20:13 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E6CC8106566C; Fri, 22 Jun 2012 16:20:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D17318FC18; Fri, 22 Jun 2012 16:20:13 +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 q5MGKD7g087943; Fri, 22 Jun 2012 16:20:13 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5MGKDIW087941; Fri, 22 Jun 2012 16:20:13 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206221620.q5MGKDIW087941@svn.freebsd.org> From: Alexander Motin Date: Fri, 22 Jun 2012 16:20:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237446 - head/sys/cam X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 16:20:14 -0000 Author: mav Date: Fri Jun 22 16:20:13 2012 New Revision: 237446 URL: http://svn.freebsd.org/changeset/base/237446 Log: Don't print SCSI Queue Full and CAM_REQUEUE_REQ statuses as errors if they were handled and retried. They are part of normal operation for SCSI TCQ. MFC after: 3 days Modified: head/sys/cam/cam_periph.c Modified: head/sys/cam/cam_periph.c ============================================================================== --- head/sys/cam/cam_periph.c Fri Jun 22 16:05:56 2012 (r237445) +++ head/sys/cam/cam_periph.c Fri Jun 22 16:20:13 2012 (r237446) @@ -1354,6 +1354,7 @@ camperiphscsistatuserror(union ccb *ccb, } *timeout = 0; error = ERESTART; + *print = 0; break; } /* FALLTHROUGH */ @@ -1683,8 +1684,10 @@ cam_periph_error(union ccb *ccb, cam_fla } else if (sense_flags & SF_NO_RETRY) { error = EIO; action_string = "Retry was blocked"; - } else + } else { error = ERESTART; + print = 0; + } break; case CAM_RESRC_UNAVAIL: /* Wait a bit for the resource shortage to abate. */ From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 18:01:23 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 63132106566B; Fri, 22 Jun 2012 18:01:23 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4BA768FC12; Fri, 22 Jun 2012 18:01:23 +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 q5MI1NNS092252; Fri, 22 Jun 2012 18:01:23 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5MI1NxN092238; Fri, 22 Jun 2012 18:01:23 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201206221801.q5MI1NxN092238@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Fri, 22 Jun 2012 18:01:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237448 - head/lib/libedit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 18:01:23 -0000 Author: pfg Date: Fri Jun 22 18:01:22 2012 New Revision: 237448 URL: http://svn.freebsd.org/changeset/base/237448 Log: Merge changes from upstream libedit. Our libedit has been diverging from the mainstream version maintained in NetBSD. As a consequence it has been difficult to do an appropriate MFV and we have been bringing only partial updates. Here we update most of the files to at least match the version available in NetBSD's snapshot of 20091228. This version was chosen because it still doesn't include wide character support (UTF-8), which involves many changes and new files. From NetBSD's logs: Dec 15 22:13:33 2006 - editline.3 el.c el.h histedit.h add EL_GETFP, and EL_SETFP. Apr 5 15:53:28 2008 - editline.3 el.c histedit.h readline.c add EL_REFRESH for the benefit of readline Sep 10 15:45:37 2008 - common.c el.c read.c refresh.c sig.c term.c term.h tty.c Allow a single process to control multiple ttys (for pthreads using _REENTRANT) using multiple EditLine objects. Jan 18 12:17:24 2009 - el.c read.c readline.c fix -Wsign-compare issues Feb 6 14:40:32 2009 - history.c Plug memory leak, from MySQL. Feb 5 19:15:44 2009 - histedit.h read.c match documentation in el_push Feb 6 13:14:37 2009 - vi.c Portability fix. Feb 12 13:39:49 2009 - readline.c term.c More fixes for existing portability stuff. Feb 15 21:24:13 2009 - el.h read.c don't restart on EINTR, instead return NULL immediately. From Anon Ymous Feb 15 21:25:01 2009 - sig.c sig.h in order for read() to return EINTR we need to use sigaction, not signal, otherwise SA_RESTART is set. Feb 15 21:55:23 2009 - chared.c chared.h common.c emacs.c filecomplete.c filecomplete.h key.c key.h read.c readline.c refresh.c search.c term.c tokenizer.c tty.c vi.c pass lint on _LP64. Feb 17 21:34:26 2009 - el.c histedit.h prompt.c prompt.h allow for a prompt argument. Feb 18 15:04:40 2009 - sig.c SA_RESTART for all signals but SIGINT. From Anon Ymous. Feb 19 15:20:22 2009 - read.c sig.c sig.h reset and redraw on sigcont. From Anon Ymous. Feb 21 23:31:56 2009 - key.c key.h readline.c vi.c more size_t stuff. Mar 10 20:46:15 2009 - editline.3 read.c make el_gets set the count to -1 on error to distinguish between EOF and error. Mar 31 17:38:27 2009 - editline.3 el.c histedit.h prompt.c prompt.h refresh.c term.c term.h Implement literal prompt sequences. Now someone can implement RL_PROMPT_START_LITERAL/RL_PROMPT_END_LITERAL :-) Mar 31 21:33:17 2009 - term.c cast to size_t to avoid sign / unsigned comparison warning. Apr 23 02:03 2009 - term.c Apply patch (requested by msaitoh in ticket #2007): Coverity CID 1668: Plug memory leak when malloc() failed.:55 2009 May 11 18:33:30 2009 - editline.3 el.c histedit.h restore binary compatibility by providing new prompt functions that take an extra literal character. May 19 21:45:14 2009 - refresh.c always scroll when we advance past bottom. From Caleb Welton cwelton at greenplum dot com. Jul 17 12:27:57 2009 - term.c - off by one in the term.h case. - make code more similar to tcsh (if we want to handle wide chars, this is needed; for now it is a no-op) Jul 22 15:56:29 2009 - el.c Move filename to the scope it is being used. From Michael Cook mcook at bbn dot com Jul 22 15:57:00 2009 - read.c Always initialize nread since it is an out param. From Michael Cook mcook at bbn dot com Jul 22 18:25:26 2009 - el.c Only need path if we have issetugid... From Anon Ymous Jul 25 21:19:23 2009 - el.c Ignore comment lines in .editrc from Jess Thrysoee Sep 7 21:24:33 2009 histedit.h history.c readline.c apply apple patches from: http://opensource.apple.com/source/libedit/libedit-11/patches/ Dec 28 21:52:43 2009 - refresh.c Fix bug where tab completion on the second or > line that caused listing ended up corrupting the display by an extra space in the beginning. Reported by Mac Chan. Dec 28 22:15:36 2009 - refresh.c term.c reduce diff with tcsh Obtained from: NetBSD Tested by: bapt, jilles and current@ MFC after: 1 week Modified: head/lib/libedit/common.c head/lib/libedit/editline.3 head/lib/libedit/editrc.5 head/lib/libedit/el.c head/lib/libedit/el.h head/lib/libedit/histedit.h head/lib/libedit/history.c head/lib/libedit/key.c head/lib/libedit/key.h head/lib/libedit/prompt.c head/lib/libedit/prompt.h head/lib/libedit/read.c head/lib/libedit/refresh.c head/lib/libedit/search.c head/lib/libedit/sig.c head/lib/libedit/sig.h head/lib/libedit/term.c head/lib/libedit/term.h head/lib/libedit/tty.c head/lib/libedit/vi.c Modified: head/lib/libedit/common.c ============================================================================== --- head/lib/libedit/common.c Fri Jun 22 16:31:00 2012 (r237447) +++ head/lib/libedit/common.c Fri Jun 22 18:01:22 2012 (r237448) @@ -905,7 +905,7 @@ ed_command(EditLine *el, int c __unused) int tmplen; tmplen = c_gets(el, tmpbuf, "\n: "); - term__putc('\n'); + term__putc(el, '\n'); if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1) term_beep(el); Modified: head/lib/libedit/editline.3 ============================================================================== --- head/lib/libedit/editline.3 Fri Jun 22 16:31:00 2012 (r237447) +++ head/lib/libedit/editline.3 Fri Jun 22 18:01:22 2012 (r237448) @@ -1,4 +1,4 @@ -.\" $NetBSD: editline.3,v 1.55 2007/01/12 16:31:13 christos Exp $ +.\" $NetBSD: editline.3,v 1.70 2009/07/05 21:55:24 perry Exp $ .\" .\" Copyright (c) 1997-2003 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 12, 2007 +.Dd July 5, 2009 .Dt EDITLINE 3 .Os .Sh NAME @@ -162,6 +162,14 @@ is modified to contain the number of cha Returns the line read if successful, or .Dv NULL if no characters were read or if an error occurred. +If an error occurred, +.Fa count +is set to \-1 and +.Dv errno +contains the error code that caused it. +The return value may not remain valid across calls to +.Fn el_gets +and must be copied if the data is to be retained. .It Fn el_getc Read a character from the tty. .Fa ch @@ -222,10 +230,30 @@ are supported, along with the required a Define prompt printing function as .Fa f , which is to return a string that contains the prompt. +.It Dv EL_PROMPT_ESC , Fa "char *(*f)(EditLine *)" , Fa "char c" +Same as +.Dv EL_PROMPT , +but the +.Fa c +argument indicates the start/stop literal prompt character. +.Pp +If a start/stop literal character is found in the prompt, the +character itself +is not printed, but characters after it are printed directly to the +terminal without affecting the state of the current line. +A subsequent second start/stop literal character ends this behavior. +This is typically used to embed literal escape sequences that change the +color/style of the terminal in the prompt. +.Dv 0 +unsets it. +.It Dv EL_REFRESH +Re-display the current line on the next terminal line. .It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)" Define right side prompt printing function as .Fa f , which is to return a string that contains the prompt. +.It Dv EL_RPROMPT_ESC , Fa "char *(*f)(EditLine *)" , Fa "char c" +Define the right prompt printing function but with a literal escape character. .It Dv EL_TERMINAL , Fa "const char *type" Define terminal type of the tty to be .Fa type , @@ -259,66 +287,43 @@ reading command input: and .Dv SIGWINCH . Otherwise, the current signal handlers will be used. -.It Dv EL_BIND , Xo -.Fa "const char *" , -.Fa "..." , -.Dv NULL -.Xc +.It Dv EL_BIND , Fa "const char *" , Fa "..." , Dv NULL Perform the .Ic bind builtin command. Refer to .Xr editrc 5 for more information. -.It Dv EL_ECHOTC , Xo -.Fa "const char *" , -.Fa "..." , -.Dv NULL -.Xc +.It Dv EL_ECHOTC , Fa "const char *" , Fa "..." , Dv NULL Perform the .Ic echotc builtin command. Refer to .Xr editrc 5 for more information. -.It Dv EL_SETTC , Xo -.Fa "const char *" , -.Fa "..." , -.Dv NULL -.Xc +.It Dv EL_SETTC , Fa "const char *" , Fa "..." , Dv NULL Perform the .Ic settc builtin command. Refer to .Xr editrc 5 for more information. -.It Dv EL_SETTY , Xo -.Fa "const char *" , -.Fa "..." , -.Dv NULL -.Xc +.It Dv EL_SETTY , Fa "const char *" , Fa "..." , Dv NULL Perform the .Ic setty builtin command. Refer to .Xr editrc 5 for more information. -.It Dv EL_TELLTC , Xo -.Fa "const char *" , -.Fa "..." , -.Dv NULL -.Xc +.It Dv EL_TELLTC , Fa "const char *" , Fa "..." , Dv NULL Perform the .Ic telltc builtin command. Refer to .Xr editrc 5 for more information. -.It Dv EL_ADDFN , Xo -.Fa "const char *name" , -.Fa "const char *help" , -.Fa "unsigned char (*func)(EditLine *e, int ch)" -.Xc +.It Dv EL_ADDFN , Fa "const char *name" , Fa "const char *help" , \ +Fa "unsigned char (*func)(EditLine *e, int ch)" Add a user defined function, .Fn func , referred to as @@ -360,10 +365,8 @@ Beep, and flush tty. .It Dv CC_FATAL Fatal error, reset tty to known state. .El -.It Dv EL_HIST , Xo -.Fa "History *(*func)(History *, int op, ...)" , -.Fa "const char *ptr" -.Xc +.It Dv EL_HIST , Fa "History *(*func)(History *, int op, ...)" , \ +Fa "const char *ptr" Defines which history function to use, which is usually .Fn history . .Fa ptr @@ -435,10 +438,22 @@ The following values for are supported, along with actual type of .Fa result : .Bl -tag -width 4n -.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)" -Return a pointer to the function that displays the prompt. -.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)" -Return a pointer to the function that displays the rightside prompt. +.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)" , Fa "char *c" +Return a pointer to the function that displays the prompt in +.Fa f . +If +.Fa c +is not +.Dv NULL , +return the start/stop literal prompt character in it. +.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)" , Fa "char *c" +Return a pointer to the function that displays the prompt in +.Fa f . +If +.Fa c +is not +.Dv NULL , +return the start/stop literal prompt character in it. .It Dv EL_EDITOR , Fa "const char *" Return the name of the editor, which will be one of .Dq emacs @@ -603,18 +618,11 @@ assumed to be created with .Fn history_init . .It Dv H_CLEAR Clear the history. -.It Dv H_FUNC , Xo -.Fa "void *ptr" , -.Fa "history_gfun_t first" , -.Fa "history_gfun_t next" , -.Fa "history_gfun_t last" , -.Fa "history_gfun_t prev" , -.Fa "history_gfun_t curr" , -.Fa "history_sfun_t set" , -.Fa "history_vfun_t clear" , -.Fa "history_efun_t enter" , -.Fa "history_efun_t add" -.Xc +.It Dv H_FUNC , Fa "void *ptr" , Fa "history_gfun_t first" , \ +Fa "history_gfun_t next" , Fa "history_gfun_t last" , \ +Fa "history_gfun_t prev" , Fa "history_gfun_t curr" , \ +Fa "history_sfun_t set" , Fa "history_vfun_t clear" , \ +Fa "history_efun_t enter" , Fa "history_efun_t add" Define functions to perform various history operations. .Fa ptr is the argument given to a function when it is invoked. Modified: head/lib/libedit/editrc.5 ============================================================================== --- head/lib/libedit/editrc.5 Fri Jun 22 16:31:00 2012 (r237447) +++ head/lib/libedit/editrc.5 Fri Jun 22 18:01:22 2012 (r237448) @@ -1,4 +1,4 @@ -.\" $NetBSD: editrc.5,v 1.20 2006/08/21 12:45:30 christos Exp $ +.\" $NetBSD: editrc.5,v 1.24 2009/04/11 22:17:52 wiz Exp $ .\" .\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -89,16 +89,8 @@ shell. .Pp The following builtin commands are available: .Bl -tag -width 4n -.It Ic bind Xo -.Op Fl a -.Op Fl e -.Op Fl k -.Op Fl l -.Op Fl r -.Op Fl s -.Op Fl v -.Op Ar key Op Ar command -.Xc +.It Ic bind Oo Fl a Oc Oo Fl e Oc Oo Fl k Oc Oo Fl l Oc Oo Fl r Oc \ +Oo Fl s Oc Oo Fl v Oc Oo Ar key Op Ar command Oc Without options, list all bound keys, and the editor command to which each is bound. If @@ -192,11 +184,7 @@ if it has any, notably .Sq \e and .Sq ^ . -.It Ic echotc Xo -.Op Fl sv -.Ar arg -.Ar ... -.Xc +.It Ic echotc Oo Fl sv Oc Ar arg Ar ... Exercise terminal capabilities given in .Ar arg Ar ... . If @@ -252,16 +240,8 @@ to as defined in .Xr termcap 5 . No sanity checking is done. -.It Ic setty Xo -.Op Fl a -.Op Fl d -.Op Fl q -.Op Fl x -.Op Ar +mode -.Op Ar -mode -.Op Ar mode -.Op Ar char=c -.Xc +.It Ic setty Oo Fl a Oc Oo Fl d Oc Oo Fl q Oc Oo Fl x Oc Oo Ar +mode Oc \ +Oo Ar -mode Oc Oo Ar mode Oc Oo Ar char=c Oc Control which tty modes that .Nm will not allow the user to change. Modified: head/lib/libedit/el.c ============================================================================== --- head/lib/libedit/el.c Fri Jun 22 16:31:00 2012 (r237447) +++ head/lib/libedit/el.c Fri Jun 22 18:01:22 2012 (r237448) @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $NetBSD: el.c,v 1.44 2006/12/15 22:13:33 christos Exp $ + * $NetBSD: el.c,v 1.55 2009/07/25 21:19:23 christos Exp $ */ #if !defined(lint) && !defined(SCCSID) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "el.h" #define HAVE_ISSETUGID @@ -156,9 +157,21 @@ el_set(EditLine *el, int op, ...) switch (op) { case EL_PROMPT: - case EL_RPROMPT: - rv = prompt_set(el, va_arg(ap, el_pfunc_t), op); + case EL_RPROMPT: { + el_pfunc_t p = va_arg(ap, el_pfunc_t); + + rv = prompt_set(el, p, 0, op); break; + } + + case EL_PROMPT_ESC: + case EL_RPROMPT_ESC: { + el_pfunc_t p = va_arg(ap, el_pfunc_t); + char c = va_arg(ap, int); + + rv = prompt_set(el, p, c, op); + break; + } case EL_TERMINAL: rv = term_set(el, va_arg(ap, char *)); @@ -309,6 +322,12 @@ el_set(EditLine *el, int op, ...) break; } + case EL_REFRESH: + re_clear_display(el); + re_refresh(el); + term__flush(el); + break; + default: rv = -1; break; @@ -335,9 +354,13 @@ el_get(EditLine *el, int op, ...) switch (op) { case EL_PROMPT: - case EL_RPROMPT: - rv = prompt_get(el, va_arg(ap, el_pfunc_t *), op); + case EL_RPROMPT: { + el_pfunc_t *p = va_arg(ap, el_pfunc_t *); + char *c = va_arg(ap, char *); + + rv = prompt_get(el, p, c, op); break; + } case EL_EDITOR: rv = map_get_editor(el, va_arg(ap, const char **)); @@ -364,7 +387,7 @@ el_get(EditLine *el, int op, ...) char *argv[20]; int i; - for (i = 1; i < sizeof(argv) / sizeof(argv[0]); i++) + for (i = 1; i < (int)(sizeof(argv) / sizeof(argv[0])); i++) if ((argv[i] = va_arg(ap, char *)) == NULL) break; @@ -495,12 +518,14 @@ el_source(EditLine *el, const char *fnam FILE *fp; size_t len; char *ptr; +#ifdef HAVE_ISSETUGID + char path[MAXPATHLEN]; +#endif fp = NULL; if (fname == NULL) { #ifdef HAVE_ISSETUGID static const char elpath[] = "/.editrc"; - char path[MAXPATHLEN]; if (issetugid()) return (-1); @@ -529,6 +554,13 @@ el_source(EditLine *el, const char *fnam if (len > 0 && ptr[len - 1] == '\n') --len; ptr[len] = '\0'; + + /* loop until first non-space char or EOL */ + while (*ptr != '\0' && isspace((unsigned char)*ptr)) + ptr++; + if (*ptr == '#') + continue; /* ignore, this is a comment line */ + if (parse_line(el, ptr) == -1) { (void) fclose(fp); return (-1); Modified: head/lib/libedit/el.h ============================================================================== --- head/lib/libedit/el.h Fri Jun 22 16:31:00 2012 (r237447) +++ head/lib/libedit/el.h Fri Jun 22 18:01:22 2012 (r237448) @@ -115,6 +115,7 @@ struct editline { FILE *el_errfile; /* Stdio stuff */ int el_infd; /* Input file descriptor */ int el_flags; /* Various flags. */ + int el_errno; /* Local copy of errno */ coord_t el_cursor; /* Cursor location */ char **el_display; /* Real screen image = what is there */ char **el_vdisplay; /* Virtual screen image = what we see */ Modified: head/lib/libedit/histedit.h ============================================================================== --- head/lib/libedit/histedit.h Fri Jun 22 16:31:00 2012 (r237447) +++ head/lib/libedit/histedit.h Fri Jun 22 18:01:22 2012 (r237448) @@ -131,10 +131,10 @@ unsigned char _el_fn_sh_complete(EditLin #define EL_GETCFN 13 /* , el_rfunc_t); */ #define EL_CLIENTDATA 14 /* , void *); */ #define EL_UNBUFFERED 15 /* , int); */ -#define EL_PREP_TERM 16 /* , int); */ +#define EL_PREP_TERM 16 /* , int); */ #define EL_GETTC 17 /* , const char *, ..., NULL); */ -#define EL_GETFP 18 /* , int, FILE **) */ -#define EL_SETFP 19 /* , int, FILE *) */ +#define EL_GETFP 18 /* , int, FILE **); */ +#define EL_SETFP 19 /* , int, FILE *); */ #define EL_REFRESH 20 /* , void); set */ #define EL_PROMPT_ESC 21 /* , prompt_func, Char); set/get */ #define EL_RPROMPT_ESC 22 /* , prompt_func, Char); set/get */ Modified: head/lib/libedit/history.c ============================================================================== --- head/lib/libedit/history.c Fri Jun 22 16:31:00 2012 (r237447) +++ head/lib/libedit/history.c Fri Jun 22 18:01:22 2012 (r237448) @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $NetBSD: history.c,v 1.32 2006/09/28 13:52:51 christos Exp $ + * $NetBSD: history.c,v 1.34 2009/09/07 21:24:33 christos Exp $ */ #if !defined(lint) && !defined(SCCSID) @@ -116,6 +116,7 @@ private int history_prev_string(History */ typedef struct hentry_t { HistEvent ev; /* What we return */ + void *data; /* data */ struct hentry_t *next; /* Next entry */ struct hentry_t *prev; /* Previous entry */ } hentry_t; @@ -145,6 +146,9 @@ private int history_def_init(ptr_t *, Hi private int history_def_insert(history_t *, HistEvent *, const char *); private void history_def_delete(history_t *, HistEvent *, hentry_t *); +private int history_deldata_nth(history_t *, HistEvent *, int, void **); +private int history_set_nth(ptr_t, HistEvent *, int); + #define history_def_setsize(p, num)(void) (((history_t *)p)->max = (num)) #define history_def_getsize(p) (((history_t *)p)->cur) #define history_def_getunique(p) (((((history_t *)p)->flags) & H_UNIQUE) != 0) @@ -335,6 +339,31 @@ history_def_set(ptr_t p, HistEvent *ev, } +/* history_set_nth(): + * Default function to set the current event in the history to the + * n-th one. + */ +private int +history_set_nth(ptr_t p, HistEvent *ev, int n) +{ + history_t *h = (history_t *) p; + + if (h->cur == 0) { + he_seterrev(ev, _HE_EMPTY_LIST); + return (-1); + } + for (h->cursor = h->list.prev; h->cursor != &h->list; + h->cursor = h->cursor->prev) + if (n-- <= 0) + break; + if (h->cursor == &h->list) { + he_seterrev(ev, _HE_NOT_FOUND); + return (-1); + } + return (0); +} + + /* history_def_add(): * Append string to element */ @@ -363,6 +392,24 @@ history_def_add(ptr_t p, HistEvent *ev, } +private int +history_deldata_nth(history_t *h, HistEvent *ev, + int num, void **data) +{ + if (history_set_nth(h, ev, num) != 0) + return (-1); + /* magic value to skip delete (just set to n-th history) */ + if (data == (void **)-1) + return (0); + ev->str = strdup(h->cursor->ev.str); + ev->num = h->cursor->ev.num; + if (data) + *data = h->cursor->data; + history_def_delete(h, ev, h->cursor); + return (0); +} + + /* history_def_del(): * Delete element hp of the h list */ @@ -392,8 +439,11 @@ history_def_delete(history_t *h, HistEventPrivate *evp = (void *)&hp->ev; if (hp == &h->list) abort(); - if (h->cursor == hp) + if (h->cursor == hp) { h->cursor = hp->prev; + if (h->cursor == &h->list) + h->cursor = hp->next; + } hp->prev->next = hp->next; hp->next->prev = hp->prev; h_free((ptr_t) evp->str); @@ -416,6 +466,7 @@ history_def_insert(history_t *h, HistEve h_free((ptr_t)h->cursor); goto oomem; } + h->cursor->data = NULL; h->cursor->ev.num = ++h->eventid; h->cursor->next = h->list.next; h->cursor->prev = &h->list; @@ -711,8 +762,8 @@ history_load(History *h, const char *fna (void) strunvis(ptr, line); line[sz] = c; if (HENTER(h, &ev, ptr) == -1) { - h_free((ptr_t)ptr); - return -1; + i = -1; + goto oomem; } } oomem: @@ -787,6 +838,23 @@ history_prev_event(History *h, HistEvent } +private int +history_next_evdata(History *h, HistEvent *ev, int num, void **d) +{ + int retval; + + for (retval = HCURR(h, ev); retval != -1; retval = HPREV(h, ev)) + if (num-- <= 0) { + if (d) + *d = ((history_t *)h->h_ref)->cursor->data; + return (0); + } + + he_seterrev(ev, _HE_NOT_FOUND); + return (-1); +} + + /* history_next_event(): * Find the next event, with number given */ @@ -976,11 +1044,42 @@ history(History *h, HistEvent *ev, int f retval = 0; break; + case H_NEXT_EVDATA: + { + int num = va_arg(va, int); + void **d = va_arg(va, void **); + retval = history_next_evdata(h, ev, num, d); + break; + } + + case H_DELDATA: + { + int num = va_arg(va, int); + void **d = va_arg(va, void **); + retval = history_deldata_nth((history_t *)h->h_ref, ev, num, d); + break; + } + + case H_REPLACE: /* only use after H_NEXT_EVDATA */ + { + const char *line = va_arg(va, const char *); + void *d = va_arg(va, void *); + const char *s; + if(!line || !(s = strdup(line))) { + retval = -1; + break; + } + ((history_t *)h->h_ref)->cursor->ev.str = s; + ((history_t *)h->h_ref)->cursor->data = d; + retval = 0; + break; + } + default: retval = -1; he_seterrev(ev, _HE_UNKNOWN); break; } va_end(va); - return (retval); + return retval; } Modified: head/lib/libedit/key.c ============================================================================== --- head/lib/libedit/key.c Fri Jun 22 16:31:00 2012 (r237447) +++ head/lib/libedit/key.c Fri Jun 22 18:01:22 2012 (r237448) @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $NetBSD: key.c,v 1.19 2006/03/23 20:22:51 christos Exp $ + * $NetBSD: key.c,v 1.20 2009/02/15 21:55:23 christos Exp $ */ #if !defined(lint) && !defined(SCCSID) @@ -86,8 +86,8 @@ private void node__free(key_node_t *); private void node__put(EditLine *, key_node_t *); private int node__delete(EditLine *, key_node_t **, const char *); private int node_lookup(EditLine *, const char *, key_node_t *, - int); -private int node_enum(EditLine *, key_node_t *, int); + size_t); +private int node_enum(EditLine *, key_node_t *, size_t); #define KEY_BUFSIZ EL_BUFSIZ @@ -478,9 +478,9 @@ node__free(key_node_t *k) * Print if last node */ private int -node_lookup(EditLine *el, const char *str, key_node_t *ptr, int cnt) +node_lookup(EditLine *el, const char *str, key_node_t *ptr, size_t cnt) { - int ncnt; + size_t ncnt; if (ptr == NULL) return (-1); /* cannot have null ptr */ @@ -493,7 +493,8 @@ node_lookup(EditLine *el, const char *st /* If match put this char into el->el_key.buf. Recurse */ if (ptr->ch == *str) { /* match found */ - ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt, + ncnt = key__decode_char(el->el_key.buf, + (size_t)KEY_BUFSIZ, cnt, (unsigned char) ptr->ch); if (ptr->next != NULL) /* not yet at leaf */ @@ -527,9 +528,9 @@ node_lookup(EditLine *el, const char *st * Traverse the node printing the characters it is bound in buffer */ private int -node_enum(EditLine *el, key_node_t *ptr, int cnt) +node_enum(EditLine *el, key_node_t *ptr, size_t cnt) { - int ncnt; + size_t ncnt; if (cnt >= KEY_BUFSIZ - 5) { /* buffer too small */ el->el_key.buf[++cnt] = '"'; @@ -547,7 +548,7 @@ node_enum(EditLine *el, key_node_t *ptr, return (-1); } /* put this char at end of str */ - ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt, + ncnt = key__decode_char(el->el_key.buf, (size_t)KEY_BUFSIZ, cnt, (unsigned char)ptr->ch); if (ptr->next == NULL) { /* print this key and function */ @@ -615,8 +616,8 @@ key_kprint(EditLine *el, const char *key /* key__decode_char(): * Put a printable form of char in buf. */ -protected int -key__decode_char(char *buf, int cnt, int off, int ch) +protected size_t +key__decode_char(char *buf, size_t cnt, size_t off, int ch) { char *sb = buf + off; char *eb = buf + cnt; @@ -626,7 +627,7 @@ key__decode_char(char *buf, int cnt, int if (ch == 0) { ADDC('^'); ADDC('@'); - return b - sb; + return (int)(b - sb); } if (iscntrl(ch)) { ADDC('^'); @@ -648,15 +649,15 @@ key__decode_char(char *buf, int cnt, int ADDC((((unsigned int) ch >> 3) & 7) + '0'); ADDC((ch & 7) + '0'); } - return b - sb; + return (size_t)(b - sb); } /* key__decode_str(): * Make a printable version of the ey */ -protected int -key__decode_str(const char *str, char *buf, int len, const char *sep) +protected size_t +key__decode_str(const char *str, char *buf, size_t len, const char *sep) { char *b = buf, *eb = b + len; const char *p; @@ -699,7 +700,7 @@ key__decode_str(const char *str, char *b } done: ADDC('\0'); - if (b - buf >= len) + if ((size_t)(b - buf) >= len) buf[len - 1] = '\0'; - return b - buf; + return (size_t)(b - buf); } Modified: head/lib/libedit/key.h ============================================================================== --- head/lib/libedit/key.h Fri Jun 22 16:31:00 2012 (r237447) +++ head/lib/libedit/key.h Fri Jun 22 18:01:22 2012 (r237448) @@ -76,8 +76,8 @@ protected int key_delete(EditLine *, c protected void key_print(EditLine *, const char *); protected void key_kprint(EditLine *, const char *, key_value_t *, int); -protected int key__decode_str(const char *, char *, int, +protected size_t key__decode_str(const char *, char *, size_t, const char *); -protected int key__decode_char(char *, int, int, int); +protected size_t key__decode_char(char *, size_t, size_t, int); #endif /* _h_el_key */ Modified: head/lib/libedit/prompt.c ============================================================================== --- head/lib/libedit/prompt.c Fri Jun 22 16:31:00 2012 (r237447) +++ head/lib/libedit/prompt.c Fri Jun 22 18:01:22 2012 (r237448) @@ -85,14 +85,23 @@ prompt_print(EditLine *el, int op) { el_prompt_t *elp; char *p; + int ignore = 0; if (op == EL_PROMPT) elp = &el->el_prompt; else elp = &el->el_rprompt; - p = (elp->p_func) (el); - while (*p) - re_putc(el, *p++, 1); + + for (p = (*elp->p_func)(el); *p; p++) { + if (elp->p_ignore == *p) { + ignore = !ignore; + continue; + } + if (ignore) + term__putc(el, *p); + else + re_putc(el, *p, 1); + } elp->p_pos.v = el->el_refresh.r_cursor.v; elp->p_pos.h = el->el_refresh.r_cursor.h; @@ -109,10 +118,12 @@ prompt_init(EditLine *el) el->el_prompt.p_func = prompt_default; el->el_prompt.p_pos.v = 0; el->el_prompt.p_pos.h = 0; + el->el_prompt.p_ignore = '\0'; el->el_rprompt.p_func = prompt_default_r; el->el_rprompt.p_pos.v = 0; el->el_rprompt.p_pos.h = 0; - return (0); + el->el_rprompt.p_ignore = '\0'; + return 0; } @@ -130,24 +141,29 @@ prompt_end(EditLine *el __unused) * Install a prompt printing function */ protected int -prompt_set(EditLine *el, el_pfunc_t prf, int op) +prompt_set(EditLine *el, el_pfunc_t prf, char c, int op) { el_prompt_t *p; - if (op == EL_PROMPT) + if (op == EL_PROMPT || op == EL_PROMPT_ESC) p = &el->el_prompt; else p = &el->el_rprompt; + if (prf == NULL) { - if (op == EL_PROMPT) + if (op == EL_PROMPT || op == EL_PROMPT_ESC) p->p_func = prompt_default; else p->p_func = prompt_default_r; } else p->p_func = prf; + + p->p_ignore = c; + p->p_pos.v = 0; p->p_pos.h = 0; - return (0); + + return 0; } @@ -155,14 +171,22 @@ prompt_set(EditLine *el, el_pfunc_t prf, * Retrieve the prompt printing function */ protected int -prompt_get(EditLine *el, el_pfunc_t *prf, int op) +prompt_get(EditLine *el, el_pfunc_t *prf, char *c, int op) { + el_prompt_t *p; if (prf == NULL) - return (-1); + return -1; + if (op == EL_PROMPT) - *prf = el->el_prompt.p_func; + p = &el->el_prompt; else - *prf = el->el_rprompt.p_func; - return (0); + p = &el->el_rprompt; + + *prf = el->el_rprompt.p_func; + + if (c) + *c = p->p_ignore; + + return 0; } Modified: head/lib/libedit/prompt.h ============================================================================== --- head/lib/libedit/prompt.h Fri Jun 22 16:31:00 2012 (r237447) +++ head/lib/libedit/prompt.h Fri Jun 22 18:01:22 2012 (r237448) @@ -47,11 +47,13 @@ typedef char * (*el_pfunc_t)(EditLine*); typedef struct el_prompt_t { el_pfunc_t p_func; /* Function to return the prompt */ coord_t p_pos; /* position in the line after prompt */ + char p_ignore; /* character to start/end literal +*/ } el_prompt_t; protected void prompt_print(EditLine *, int); -protected int prompt_set(EditLine *, el_pfunc_t, int); -protected int prompt_get(EditLine *, el_pfunc_t *, int); +protected int prompt_set(EditLine *, el_pfunc_t, char, int); +protected int prompt_get(EditLine *, el_pfunc_t *, char *, int); protected int prompt_init(EditLine *); protected void prompt_end(EditLine *); Modified: head/lib/libedit/read.c ============================================================================== --- head/lib/libedit/read.c Fri Jun 22 16:31:00 2012 (r237447) +++ head/lib/libedit/read.c Fri Jun 22 18:01:22 2012 (r237448) @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $NetBSD: read.c,v 1.40 2007/03/01 21:41:45 christos Exp $ + * $NetBSD: read.c,v 1.52 2009/07/22 15:57:00 christos Exp $ */ #if !defined(lint) && !defined(SCCSID) @@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include "el.h" -#define OKCMD -1 +#define OKCMD -1 /* must be -1! */ private int read__fixio(int, int); private int read_preread(EditLine *); @@ -170,7 +170,7 @@ read__fixio(int fd __unused, int e) return (e ? 0 : -1); case EINTR: - return (0); + return (-1); default: return (-1); @@ -222,7 +222,7 @@ el_push(EditLine *el, const char *str) ma->level--; } term_beep(el); - term__flush(); + term__flush(el); } @@ -235,9 +235,12 @@ read_getcmd(EditLine *el, el_action_t *c el_action_t cmd; int num; + el->el_errno = 0; do { - if ((num = el_getc(el, ch)) != 1) /* if EOF or error */ + if ((num = el_getc(el, ch)) != 1) { /* if EOF or error */ + el->el_errno = num == 0 ? 0 : errno; return (num); + } #ifdef KANJI if ((*ch & 0200)) { @@ -286,18 +289,25 @@ read_getcmd(EditLine *el, el_action_t *c private int read_char(EditLine *el, char *cp) { - int num_read; + ssize_t num_read; int tried = 0; - while ((num_read = read(el->el_infd, cp, 1)) == -1) + again: + el->el_signal->sig_no = 0; + while ((num_read = read(el->el_infd, cp, 1)) == -1) { + if (el->el_signal->sig_no == SIGCONT) { + sig_set(el); + el_set(el, EL_REFRESH); + goto again; + } if (!tried && read__fixio(el->el_infd, errno) == 0) tried = 1; else { *cp = '\0'; return (-1); } - - return (num_read); + } + return (int)num_read; } /* read_pop(): @@ -309,8 +319,9 @@ read_pop(c_macro_t *ma) int i; el_free(ma->macro[0]); - for (i = ma->level--; i > 0; i--) - ma->macro[i - 1] = ma->macro[i]; + for (i = 0; i < ma->level; i++) + ma->macro[i] = ma->macro[i + 1]; + ma->level--; ma->offset = 0; } @@ -323,7 +334,7 @@ el_getc(EditLine *el, char *cp) int num_read; c_macro_t *ma = &el->el_chared.c_macro; - term__flush(); + term__flush(el); for (;;) { if (ma->level < 0) { if (!read_preread(el)) @@ -382,7 +393,7 @@ read_prepare(EditLine *el) re_refresh(el); /* print the prompt */ if (el->el_flags & UNBUFFERED) - term__flush(); + term__flush(el); } protected void @@ -402,15 +413,20 @@ el_gets(EditLine *el, int *nread) int num; /* how many chars we have read at NL */ char ch; int crlf = 0; + int nrb; #ifdef FIONREAD c_macro_t *ma = &el->el_chared.c_macro; #endif /* FIONREAD */ + if (nread == NULL) + nread = &nrb; + *nread = 0; + if (el->el_flags & NO_TTY) { char *cp = el->el_line.buffer; size_t idx; - while ((*el->el_read.read_char)(el, cp) == 1) { + while ((num = (*el->el_read.read_char)(el, cp)) == 1) { /* make sure there is space for next character */ if (cp + 1 >= el->el_line.limit) { idx = (cp - el->el_line.buffer); @@ -424,12 +440,16 @@ el_gets(EditLine *el, int *nread) if (cp[-1] == '\r' || cp[-1] == '\n') break; } + if (num == -1) { + if (errno == EINTR) + cp = el->el_line.buffer; + el->el_errno = errno; + } el->el_line.cursor = el->el_line.lastchar = cp; *cp = '\0'; - if (nread) - *nread = el->el_line.cursor - el->el_line.buffer; - return (el->el_line.buffer); + *nread = (int)(el->el_line.cursor - el->el_line.buffer); + goto done; } @@ -440,8 +460,8 @@ el_gets(EditLine *el, int *nread) (void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 18:34:12 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 096E71065675; Fri, 22 Jun 2012 18:34:12 +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 E85E38FC0C; Fri, 22 Jun 2012 18:34:11 +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 q5MIYBtS093751; Fri, 22 Jun 2012 18:34:11 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5MIYBMn093749; Fri, 22 Jun 2012 18:34:11 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201206221834.q5MIYBMn093749@svn.freebsd.org> From: Attilio Rao Date: Fri, 22 Jun 2012 18:34:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237451 - head/sys/vm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 18:34:12 -0000 Author: attilio Date: Fri Jun 22 18:34:11 2012 New Revision: 237451 URL: http://svn.freebsd.org/changeset/base/237451 Log: - Add a comment explaining the locking of the cached pages pool held by vm_objects. - Add flags for the per-object lock and free pages queue mutex lock. Use the newly added flags to mark the cache root within the vm_object structure. Please note that other vm_object members should be marked with correct locking but they are left for other commits. In collabouration with: alc MFC after: 3 days3 days3 days Modified: head/sys/vm/vm_object.h Modified: head/sys/vm/vm_object.h ============================================================================== --- head/sys/vm/vm_object.h Fri Jun 22 18:20:26 2012 (r237450) +++ head/sys/vm/vm_object.h Fri Jun 22 18:34:11 2012 (r237451) @@ -76,8 +76,21 @@ * * vm_object_t Virtual memory object. * + * The root of cached pages pool is protected by both the per-object mutex + * and the free pages queue mutex. + * On insert in the cache splay tree, the per-object mutex is expected + * to be already held and the free pages queue mutex will be + * acquired during the operation too. + * On remove and lookup from the cache splay tree, only the free + * pages queue mutex is expected to be locked. + * These rules allow for reliably checking for the presence of cached + * pages with only the per-object lock held, thereby reducing contention + * for the free pages queue mutex. + * * List of locks * (c) const until freed + * (o) per-object mutex + * (f) free pages queue mutex * */ @@ -102,7 +115,7 @@ struct vm_object { vm_ooffset_t backing_object_offset;/* Offset in backing object */ TAILQ_ENTRY(vm_object) pager_object_list; /* list of all objects of this pager type */ LIST_HEAD(, vm_reserv) rvq; /* list of reservations */ - vm_page_t cache; /* root of the cache page splay tree */ + vm_page_t cache; /* (o + f) root of the cache page splay tree */ void *handle; union { /* From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 18:57:07 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3A6F3106564A; Fri, 22 Jun 2012 18:57:07 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1C3798FC15; Fri, 22 Jun 2012 18:57:07 +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 q5MIv6K0094688; Fri, 22 Jun 2012 18:57:06 GMT (envelope-from ken@svn.freebsd.org) Received: (from ken@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5MIv6iX094684; Fri, 22 Jun 2012 18:57:06 GMT (envelope-from ken@svn.freebsd.org) Message-Id: <201206221857.q5MIv6iX094684@svn.freebsd.org> From: "Kenneth D. Merry" Date: Fri, 22 Jun 2012 18:57:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237452 - in head: sbin/camcontrol sys/cam/scsi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 18:57:07 -0000 Author: ken Date: Fri Jun 22 18:57:06 2012 New Revision: 237452 URL: http://svn.freebsd.org/changeset/base/237452 Log: Change 'camcontrol defects' to first probe a drive to find out how much defect information it has before grabbing the full defect list. This works around a bug with some Hitachi drives that generate data overrun errors when they are asked for more defect data than they have. The change is done in a spec-compliant way, so it should have no negative impact on drives that don't have this issue. This is based on work originally done at Sandvine. scsi_da.h: Add a define for the maximum amount of data that can be contained in a defect list. camcontrol.c: Update the readdefects() function to issue an initial command to determine the length of the defect list, and then use that length in the request for the full defect list. camcontrol.8: Add a note that some drives will report 0 defects available if you don't request either the PLIST or GLIST. Submitted by: Mark Johnston (original version) MFC after: 3 days Modified: head/sbin/camcontrol/camcontrol.8 head/sbin/camcontrol/camcontrol.c head/sys/cam/scsi/scsi_da.h Modified: head/sbin/camcontrol/camcontrol.8 ============================================================================== --- head/sbin/camcontrol/camcontrol.8 Fri Jun 22 18:34:11 2012 (r237451) +++ head/sbin/camcontrol/camcontrol.8 Fri Jun 22 18:57:06 2012 (r237452) @@ -497,6 +497,8 @@ is specified, .Nm will print out the number of defects given in the READ DEFECT DATA header returned from the drive. +Some drives will report 0 defects if neither the primary or grown defect +lists are requested. .It Ic modepage Allows the user to display and optionally edit a SCSI mode page. The mode Modified: head/sbin/camcontrol/camcontrol.c ============================================================================== --- head/sbin/camcontrol/camcontrol.c Fri Jun 22 18:34:11 2012 (r237451) +++ head/sbin/camcontrol/camcontrol.c Fri Jun 22 18:57:06 2012 (r237452) @@ -1799,13 +1799,14 @@ readdefects(struct cam_device *device, i union ccb *ccb = NULL; struct scsi_read_defect_data_10 *rdd_cdb; u_int8_t *defect_list = NULL; - u_int32_t dlist_length = 65000; + u_int32_t max_dlist_length = SRDD10_MAX_LENGTH, dlist_length = 0; u_int32_t returned_length = 0; u_int32_t num_returned = 0; u_int8_t returned_format; unsigned int i; int c, error = 0; - int lists_specified = 0; + int lists_specified; + int get_length = 1; while ((c = getopt(argc, argv, combinedopt)) != -1) { switch(c){ @@ -1842,20 +1843,33 @@ readdefects(struct cam_device *device, i ccb = cam_getccb(device); /* - * Hopefully 65000 bytes is enough to hold the defect list. If it - * isn't, the disk is probably dead already. We'd have to go with - * 12 byte command (i.e. alloc_length is 32 bits instead of 16) - * to hold them all. + * Eventually we should probably support the 12 byte READ DEFECT + * DATA command. It supports a longer parameter list, which may be + * necessary on newer drives with lots of defects. According to + * the SBC-3 spec, drives are supposed to return an illegal request + * if they have more defect data than will fit in 64K. */ - defect_list = malloc(dlist_length); + defect_list = malloc(max_dlist_length); if (defect_list == NULL) { warnx("can't malloc memory for defect list"); error = 1; goto defect_bailout; } + /* + * We start off asking for just the header to determine how much + * defect data is available. Some Hitachi drives return an error + * if you ask for more data than the drive has. Once we know the + * length, we retry the command with the returned length. + */ + dlist_length = sizeof(struct scsi_read_defect_data_hdr_10); + rdd_cdb =(struct scsi_read_defect_data_10 *)&ccb->csio.cdb_io.cdb_bytes; +retry: + + lists_specified = 0; + /* * cam_getccb() zeros the CCB header only. So we need to zero the * payload portion of the ccb. @@ -1917,6 +1931,51 @@ readdefects(struct cam_device *device, i returned_length = scsi_2btoul(((struct scsi_read_defect_data_hdr_10 *)defect_list)->length); + if (get_length != 0) { + get_length = 0; + + if ((ccb->ccb_h.status & CAM_STATUS_MASK) == + CAM_SCSI_STATUS_ERROR) { + struct scsi_sense_data *sense; + int error_code, sense_key, asc, ascq; + + sense = &ccb->csio.sense_data; + scsi_extract_sense_len(sense, ccb->csio.sense_len - + ccb->csio.sense_resid, &error_code, &sense_key, + &asc, &ascq, /*show_errors*/ 1); + + /* + * If the drive is reporting that it just doesn't + * support the defect list format, go ahead and use + * the length it reported. Otherwise, the length + * may not be valid, so use the maximum. + */ + if ((sense_key == SSD_KEY_RECOVERED_ERROR) + && (asc == 0x1c) && (ascq == 0x00) + && (returned_length > 0)) { + dlist_length = returned_length + + sizeof(struct scsi_read_defect_data_hdr_10); + dlist_length = min(dlist_length, + SRDD10_MAX_LENGTH); + } else + dlist_length = max_dlist_length; + } else if ((ccb->ccb_h.status & CAM_STATUS_MASK) != + CAM_REQ_CMP){ + error = 1; + warnx("Error reading defect header"); + if (arglist & CAM_ARG_VERBOSE) + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + goto defect_bailout; + } else { + dlist_length = returned_length + + sizeof(struct scsi_read_defect_data_hdr_10); + dlist_length = min(dlist_length, SRDD10_MAX_LENGTH); + } + + goto retry; + } + returned_format = ((struct scsi_read_defect_data_hdr_10 *) defect_list)->format; Modified: head/sys/cam/scsi/scsi_da.h ============================================================================== --- head/sys/cam/scsi/scsi_da.h Fri Jun 22 18:34:11 2012 (r237451) +++ head/sys/cam/scsi/scsi_da.h Fri Jun 22 18:57:06 2012 (r237452) @@ -111,6 +111,7 @@ struct scsi_read_defect_data_10 u_int8_t reserved[4]; u_int8_t alloc_length[2]; +#define SRDD10_MAX_LENGTH 0xffff u_int8_t control; }; From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 19:48:39 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 55B77106567E; Fri, 22 Jun 2012 19:48:39 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 359F58FC0A; Fri, 22 Jun 2012 19:48:39 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q5MJmdT4019092; Fri, 22 Jun 2012 19:48:39 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q5MJmcjL019090; Fri, 22 Jun 2012 19:48:38 GMT (envelope-from bapt@FreeBSD.org) X-Authentication-Warning: freefall.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f Date: Fri, 22 Jun 2012 21:48:35 +0200 From: Baptiste Daroussin To: "Pedro F. Giffuni" Message-ID: <20120622194835.GE83730@ithaqua.etoilebsd.net> References: <201206221801.q5MI1NxN092238@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="G6nVm6DDWH/FONJq" Content-Disposition: inline In-Reply-To: <201206221801.q5MI1NxN092238@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r237448 - head/lib/libedit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 19:48:39 -0000 --G6nVm6DDWH/FONJq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 22, 2012 at 06:01:23PM +0000, Pedro F. Giffuni wrote: > Author: pfg > Date: Fri Jun 22 18:01:22 2012 > New Revision: 237448 > URL: http://svn.freebsd.org/changeset/base/237448 >=20 > Log: > Merge changes from upstream libedit. > =20 > Our libedit has been diverging from the mainstream version > maintained in NetBSD. As a consequence it has been difficult > to do an appropriate MFV and we have been bringing only > partial updates. > =20 > Here we update most of the files to at least match the > version available in NetBSD's snapshot of 20091228. This > version was chosen because it still doesn't include wide > character support (UTF-8), which involves many changes and > new files. > =20 > From NetBSD's logs: > =20 > Dec 15 22:13:33 2006 - editline.3 el.c el.h histedit.h > add EL_GETFP, and EL_SETFP. > =20 > Apr 5 15:53:28 2008 - editline.3 el.c histedit.h readline.c > add EL_REFRESH for the benefit of readline > =20 > Sep 10 15:45:37 2008 - common.c el.c read.c refresh.c sig.c term.c term= =2Eh tty.c > Allow a single process to control multiple ttys (for pthreads using _RE= ENTRANT) > using multiple EditLine objects. > =20 > Jan 18 12:17:24 2009 - el.c read.c readline.c > fix -Wsign-compare issues > =20 > Feb 6 14:40:32 2009 - history.c > Plug memory leak, from MySQL. > =20 > Feb 5 19:15:44 2009 - histedit.h read.c > match documentation in el_push > =20 > Feb 6 13:14:37 2009 - vi.c > Portability fix. > =20 > Feb 12 13:39:49 2009 - readline.c term.c > More fixes for existing portability stuff. > =20 > Feb 15 21:24:13 2009 - el.h read.c > don't restart on EINTR, instead return NULL immediately. From Anon Ymous > =20 > Feb 15 21:25:01 2009 - sig.c sig.h > in order for read() to return EINTR we need to use sigaction, not signa= l, > otherwise SA_RESTART is set. > =20 > Feb 15 21:55:23 2009 - chared.c chared.h common.c emacs.c filecomplete.c > filecomplete.h key.c key.h read.c readline.c refresh.c search.c > term.c tokenizer.c tty.c vi.c > pass lint on _LP64. > =20 > Feb 17 21:34:26 2009 - el.c histedit.h prompt.c prompt.h > allow for a prompt argument. > =20 > Feb 18 15:04:40 2009 - sig.c > SA_RESTART for all signals but SIGINT. From Anon Ymous. > =20 > Feb 19 15:20:22 2009 - read.c sig.c sig.h > reset and redraw on sigcont. From Anon Ymous. > =20 > Feb 21 23:31:56 2009 - key.c key.h readline.c vi.c > more size_t stuff. > =20 > Mar 10 20:46:15 2009 - editline.3 read.c > make el_gets set the count to -1 on error to distinguish between EOF and > error. > =20 > Mar 31 17:38:27 2009 - editline.3 el.c histedit.h prompt.c prompt.h > refresh.c term.c term.h > Implement literal prompt sequences. Now someone can implement > RL_PROMPT_START_LITERAL/RL_PROMPT_END_LITERAL :-) > =20 > Mar 31 21:33:17 2009 - term.c > cast to size_t to avoid sign / unsigned comparison warning. > =20 > Apr 23 02:03 2009 - term.c > Apply patch (requested by msaitoh in ticket #2007): > Coverity CID 1668: Plug memory leak when malloc() failed.:55 2009 > =20 > May 11 18:33:30 2009 - editline.3 el.c histedit.h > restore binary compatibility by providing new prompt functions that take > an extra literal character. > =20 > May 19 21:45:14 2009 - refresh.c > always scroll when we advance past bottom. From Caleb Welton > cwelton at greenplum dot com. > =20 > Jul 17 12:27:57 2009 - term.c > - off by one in the term.h case. > - make code more similar to tcsh (if we want to handle wide chars, this= is > needed; for now it is a no-op) > =20 > Jul 22 15:56:29 2009 - el.c > Move filename to the scope it is being used. > From Michael Cook mcook at bbn dot com > =20 > Jul 22 15:57:00 2009 - read.c > Always initialize nread since it is an out param. > From Michael Cook mcook at bbn dot com > =20 > Jul 22 18:25:26 2009 - el.c > Only need path if we have issetugid... From Anon Ymous > =20 > Jul 25 21:19:23 2009 - el.c > Ignore comment lines in .editrc from Jess Thrysoee > =20 > Sep 7 21:24:33 2009 > histedit.h history.c readline.c > apply apple patches from: > http://opensource.apple.com/source/libedit/libedit-11/patches/ > =20 > Dec 28 21:52:43 2009 - refresh.c > Fix bug where tab completion on the second or > line that caused listing > ended up corrupting the display by an extra space in the beginning. Rep= orted > by Mac Chan. > =20 > Dec 28 22:15:36 2009 - refresh.c term.c > reduce diff with tcsh > =20 > Obtained from: NetBSD > Tested by: bapt, jilles and current@ > MFC after: 1 week >=20 > Modified: > head/lib/libedit/common.c > head/lib/libedit/editline.3 > head/lib/libedit/editrc.5 > head/lib/libedit/el.c > head/lib/libedit/el.h > head/lib/libedit/histedit.h > head/lib/libedit/history.c > head/lib/libedit/key.c > head/lib/libedit/key.h > head/lib/libedit/prompt.c > head/lib/libedit/prompt.h > head/lib/libedit/read.c > head/lib/libedit/refresh.c > head/lib/libedit/search.c > head/lib/libedit/sig.c > head/lib/libedit/sig.h > head/lib/libedit/term.c > head/lib/libedit/term.h > head/lib/libedit/tty.c > head/lib/libedit/vi.c >=20 > Modified: head/lib/libedit/common.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/lib/libedit/common.c Fri Jun 22 16:31:00 2012 (r237447) > +++ head/lib/libedit/common.c Fri Jun 22 18:01:22 2012 (r237448) > @@ -905,7 +905,7 @@ ed_command(EditLine *el, int c __unused) > int tmplen; > =20 > tmplen =3D c_gets(el, tmpbuf, "\n: "); > - term__putc('\n'); > + term__putc(el, '\n'); > =20 > if (tmplen < 0 || (tmpbuf[tmplen] =3D 0, parse_line(el, tmpbuf)) =3D=3D= -1) > term_beep(el); >=20 > Modified: head/lib/libedit/editline.3 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/lib/libedit/editline.3 Fri Jun 22 16:31:00 2012 (r237447) > +++ head/lib/libedit/editline.3 Fri Jun 22 18:01:22 2012 (r237448) > @@ -1,4 +1,4 @@ > -.\" $NetBSD: editline.3,v 1.55 2007/01/12 16:31:13 christos Exp $ > +.\" $NetBSD: editline.3,v 1.70 2009/07/05 21:55:24 perry Exp $ > .\" > .\" Copyright (c) 1997-2003 The NetBSD Foundation, Inc. > .\" All rights reserved. > @@ -28,7 +28,7 @@ > .\" > .\" $FreeBSD$ > .\" > -.Dd January 12, 2007 > +.Dd July 5, 2009 > .Dt EDITLINE 3 > .Os > .Sh NAME > @@ -162,6 +162,14 @@ is modified to contain the number of cha > Returns the line read if successful, or > .Dv NULL > if no characters were read or if an error occurred. > +If an error occurred, > +.Fa count > +is set to \-1 and > +.Dv errno > +contains the error code that caused it. > +The return value may not remain valid across calls to > +.Fn el_gets > +and must be copied if the data is to be retained. > .It Fn el_getc > Read a character from the tty. > .Fa ch > @@ -222,10 +230,30 @@ are supported, along with the required a > Define prompt printing function as > .Fa f , > which is to return a string that contains the prompt. > +.It Dv EL_PROMPT_ESC , Fa "char *(*f)(EditLine *)" , Fa "char c" > +Same as > +.Dv EL_PROMPT , > +but the > +.Fa c > +argument indicates the start/stop literal prompt character. > +.Pp > +If a start/stop literal character is found in the prompt, the > +character itself > +is not printed, but characters after it are printed directly to the > +terminal without affecting the state of the current line. > +A subsequent second start/stop literal character ends this behavior. > +This is typically used to embed literal escape sequences that change the > +color/style of the terminal in the prompt. > +.Dv 0 > +unsets it. > +.It Dv EL_REFRESH > +Re-display the current line on the next terminal line. > .It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)" > Define right side prompt printing function as > .Fa f , > which is to return a string that contains the prompt. > +.It Dv EL_RPROMPT_ESC , Fa "char *(*f)(EditLine *)" , Fa "char c" > +Define the right prompt printing function but with a literal escape char= acter. > .It Dv EL_TERMINAL , Fa "const char *type" > Define terminal type of the tty to be > .Fa type , > @@ -259,66 +287,43 @@ reading command input: > and > .Dv SIGWINCH . > Otherwise, the current signal handlers will be used. > -.It Dv EL_BIND , Xo > -.Fa "const char *" , > -.Fa "..." , > -.Dv NULL > -.Xc > +.It Dv EL_BIND , Fa "const char *" , Fa "..." , Dv NULL > Perform the > .Ic bind > builtin command. > Refer to > .Xr editrc 5 > for more information. > -.It Dv EL_ECHOTC , Xo > -.Fa "const char *" , > -.Fa "..." , > -.Dv NULL > -.Xc > +.It Dv EL_ECHOTC , Fa "const char *" , Fa "..." , Dv NULL > Perform the > .Ic echotc > builtin command. > Refer to > .Xr editrc 5 > for more information. > -.It Dv EL_SETTC , Xo > -.Fa "const char *" , > -.Fa "..." , > -.Dv NULL > -.Xc > +.It Dv EL_SETTC , Fa "const char *" , Fa "..." , Dv NULL > Perform the > .Ic settc > builtin command. > Refer to > .Xr editrc 5 > for more information. > -.It Dv EL_SETTY , Xo > -.Fa "const char *" , > -.Fa "..." , > -.Dv NULL > -.Xc > +.It Dv EL_SETTY , Fa "const char *" , Fa "..." , Dv NULL > Perform the > .Ic setty > builtin command. > Refer to > .Xr editrc 5 > for more information. > -.It Dv EL_TELLTC , Xo > -.Fa "const char *" , > -.Fa "..." , > -.Dv NULL > -.Xc > +.It Dv EL_TELLTC , Fa "const char *" , Fa "..." , Dv NULL > Perform the > .Ic telltc > builtin command. > Refer to > .Xr editrc 5 > for more information. > -.It Dv EL_ADDFN , Xo > -.Fa "const char *name" , > -.Fa "const char *help" , > -.Fa "unsigned char (*func)(EditLine *e, int ch)" > -.Xc > +.It Dv EL_ADDFN , Fa "const char *name" , Fa "const char *help" , \ > +Fa "unsigned char (*func)(EditLine *e, int ch)" > Add a user defined function, > .Fn func , > referred to as > @@ -360,10 +365,8 @@ Beep, and flush tty. > .It Dv CC_FATAL > Fatal error, reset tty to known state. > .El > -.It Dv EL_HIST , Xo > -.Fa "History *(*func)(History *, int op, ...)" , > -.Fa "const char *ptr" > -.Xc > +.It Dv EL_HIST , Fa "History *(*func)(History *, int op, ...)" , \ > +Fa "const char *ptr" > Defines which history function to use, which is usually > .Fn history . > .Fa ptr > @@ -435,10 +438,22 @@ The following values for > are supported, along with actual type of > .Fa result : > .Bl -tag -width 4n > -.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)" > -Return a pointer to the function that displays the prompt. > -.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)" > -Return a pointer to the function that displays the rightside prompt. > +.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)" , Fa "char *c" > +Return a pointer to the function that displays the prompt in > +.Fa f . > +If > +.Fa c > +is not > +.Dv NULL , > +return the start/stop literal prompt character in it. > +.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)" , Fa "char *c" > +Return a pointer to the function that displays the prompt in > +.Fa f . > +If > +.Fa c > +is not > +.Dv NULL , > +return the start/stop literal prompt character in it. > .It Dv EL_EDITOR , Fa "const char *" > Return the name of the editor, which will be one of > .Dq emacs > @@ -603,18 +618,11 @@ assumed to be created with > .Fn history_init . > .It Dv H_CLEAR > Clear the history. > -.It Dv H_FUNC , Xo > -.Fa "void *ptr" , > -.Fa "history_gfun_t first" , > -.Fa "history_gfun_t next" , > -.Fa "history_gfun_t last" , > -.Fa "history_gfun_t prev" , > -.Fa "history_gfun_t curr" , > -.Fa "history_sfun_t set" , > -.Fa "history_vfun_t clear" , > -.Fa "history_efun_t enter" , > -.Fa "history_efun_t add" > -.Xc > +.It Dv H_FUNC , Fa "void *ptr" , Fa "history_gfun_t first" , \ > +Fa "history_gfun_t next" , Fa "history_gfun_t last" , \ > +Fa "history_gfun_t prev" , Fa "history_gfun_t curr" , \ > +Fa "history_sfun_t set" , Fa "history_vfun_t clear" , \ > +Fa "history_efun_t enter" , Fa "history_efun_t add" > Define functions to perform various history operations. > .Fa ptr > is the argument given to a function when it is invoked. >=20 > Modified: head/lib/libedit/editrc.5 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/lib/libedit/editrc.5 Fri Jun 22 16:31:00 2012 (r237447) > +++ head/lib/libedit/editrc.5 Fri Jun 22 18:01:22 2012 (r237448) > @@ -1,4 +1,4 @@ > -.\" $NetBSD: editrc.5,v 1.20 2006/08/21 12:45:30 christos Exp $ > +.\" $NetBSD: editrc.5,v 1.24 2009/04/11 22:17:52 wiz Exp $ > .\" > .\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc. > .\" All rights reserved. > @@ -89,16 +89,8 @@ shell. > .Pp > The following builtin commands are available: > .Bl -tag -width 4n > -.It Ic bind Xo > -.Op Fl a > -.Op Fl e > -.Op Fl k > -.Op Fl l > -.Op Fl r > -.Op Fl s > -.Op Fl v > -.Op Ar key Op Ar command > -.Xc > +.It Ic bind Oo Fl a Oc Oo Fl e Oc Oo Fl k Oc Oo Fl l Oc Oo Fl r Oc \ > +Oo Fl s Oc Oo Fl v Oc Oo Ar key Op Ar command Oc > Without options, list all bound keys, and the editor command to which > each is bound. > If > @@ -192,11 +184,7 @@ if it has any, notably > .Sq \e > and > .Sq ^ . > -.It Ic echotc Xo > -.Op Fl sv > -.Ar arg > -.Ar ... > -.Xc > +.It Ic echotc Oo Fl sv Oc Ar arg Ar ... > Exercise terminal capabilities given in > .Ar arg Ar ... . > If > @@ -252,16 +240,8 @@ to > as defined in > .Xr termcap 5 . > No sanity checking is done. > -.It Ic setty Xo > -.Op Fl a > -.Op Fl d > -.Op Fl q > -.Op Fl x > -.Op Ar +mode > -.Op Ar -mode > -.Op Ar mode > -.Op Ar char=3Dc > -.Xc > +.It Ic setty Oo Fl a Oc Oo Fl d Oc Oo Fl q Oc Oo Fl x Oc Oo Ar +mode Oc \ > +Oo Ar -mode Oc Oo Ar mode Oc Oo Ar char=3Dc Oc > Control which tty modes that > .Nm > will not allow the user to change. >=20 > Modified: head/lib/libedit/el.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/lib/libedit/el.c Fri Jun 22 16:31:00 2012 (r237447) > +++ head/lib/libedit/el.c Fri Jun 22 18:01:22 2012 (r237448) > @@ -29,7 +29,7 @@ > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > - * $NetBSD: el.c,v 1.44 2006/12/15 22:13:33 christos Exp $ > + * $NetBSD: el.c,v 1.55 2009/07/25 21:19:23 christos Exp $ > */ > =20 > #if !defined(lint) && !defined(SCCSID) > @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #include "el.h" > =20 > #define HAVE_ISSETUGID > @@ -156,9 +157,21 @@ el_set(EditLine *el, int op, ...) > =20 > switch (op) { > case EL_PROMPT: > - case EL_RPROMPT: > - rv =3D prompt_set(el, va_arg(ap, el_pfunc_t), op); > + case EL_RPROMPT: { > + el_pfunc_t p =3D va_arg(ap, el_pfunc_t); > + > + rv =3D prompt_set(el, p, 0, op); > break; > + } > + > + case EL_PROMPT_ESC: > + case EL_RPROMPT_ESC: { > + el_pfunc_t p =3D va_arg(ap, el_pfunc_t); > + char c =3D va_arg(ap, int); > + > + rv =3D prompt_set(el, p, c, op); > + break; > + } > =20 > case EL_TERMINAL: > rv =3D term_set(el, va_arg(ap, char *)); > @@ -309,6 +322,12 @@ el_set(EditLine *el, int op, ...) > break; > } > =20 > + case EL_REFRESH: > + re_clear_display(el); > + re_refresh(el); > + term__flush(el); > + break; > + > default: > rv =3D -1; > break; > @@ -335,9 +354,13 @@ el_get(EditLine *el, int op, ...) > =20 > switch (op) { > case EL_PROMPT: > - case EL_RPROMPT: > - rv =3D prompt_get(el, va_arg(ap, el_pfunc_t *), op); > + case EL_RPROMPT: { > + el_pfunc_t *p =3D va_arg(ap, el_pfunc_t *); > + char *c =3D va_arg(ap, char *); > + > + rv =3D prompt_get(el, p, c, op); > break; > + } > =20 > case EL_EDITOR: > rv =3D map_get_editor(el, va_arg(ap, const char **)); > @@ -364,7 +387,7 @@ el_get(EditLine *el, int op, ...) > char *argv[20]; > int i; > =20 > - for (i =3D 1; i < sizeof(argv) / sizeof(argv[0]); i++) > + for (i =3D 1; i < (int)(sizeof(argv) / sizeof(argv[0])); i++) > if ((argv[i] =3D va_arg(ap, char *)) =3D=3D NULL) > break; > =20 > @@ -495,12 +518,14 @@ el_source(EditLine *el, const char *fnam > FILE *fp; > size_t len; > char *ptr; > +#ifdef HAVE_ISSETUGID > + char path[MAXPATHLEN]; > +#endif > =20 > fp =3D NULL; > if (fname =3D=3D NULL) { > #ifdef HAVE_ISSETUGID > static const char elpath[] =3D "/.editrc"; > - char path[MAXPATHLEN]; > =20 > if (issetugid()) > return (-1); > @@ -529,6 +554,13 @@ el_source(EditLine *el, const char *fnam > if (len > 0 && ptr[len - 1] =3D=3D '\n') > --len; > ptr[len] =3D '\0'; > + > + /* loop until first non-space char or EOL */ > + while (*ptr !=3D '\0' && isspace((unsigned char)*ptr)) > + ptr++; > + if (*ptr =3D=3D '#') > + continue; /* ignore, this is a comment line */ > + > if (parse_line(el, ptr) =3D=3D -1) { > (void) fclose(fp); > return (-1); >=20 > Modified: head/lib/libedit/el.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/lib/libedit/el.h Fri Jun 22 16:31:00 2012 (r237447) > +++ head/lib/libedit/el.h Fri Jun 22 18:01:22 2012 (r237448) > @@ -115,6 +115,7 @@ struct editline { > FILE *el_errfile; /* Stdio stuff */ > int el_infd; /* Input file descriptor */ > int el_flags; /* Various flags. */ > + int el_errno; /* Local copy of errno */ > coord_t el_cursor; /* Cursor location */ > char **el_display; /* Real screen image =3D what is there */ > char **el_vdisplay; /* Virtual screen image =3D what we see */ >=20 > Modified: head/lib/libedit/histedit.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/lib/libedit/histedit.h Fri Jun 22 16:31:00 2012 (r237447) > +++ head/lib/libedit/histedit.h Fri Jun 22 18:01:22 2012 (r237448) > @@ -131,10 +131,10 @@ unsigned char _el_fn_sh_complete(EditLin > #define EL_GETCFN 13 /* , el_rfunc_t); */ > #define EL_CLIENTDATA 14 /* , void *); */ > #define EL_UNBUFFERED 15 /* , int); */ > -#define EL_PREP_TERM 16 /* , int); */ > +#define EL_PREP_TERM 16 /* , int); */ > #define EL_GETTC 17 /* , const char *, ..., NULL); */ > -#define EL_GETFP 18 /* , int, FILE **) */ > -#define EL_SETFP 19 /* , int, FILE *) */ > +#define EL_GETFP 18 /* , int, FILE **); */ > +#define EL_SETFP 19 /* , int, FILE *); */ > #define EL_REFRESH 20 /* , void); set */ > #define EL_PROMPT_ESC 21 /* , prompt_func, Char); set/get */ > #define EL_RPROMPT_ESC 22 /* , prompt_func, Char); set/get */ >=20 > Modified: head/lib/libedit/history.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/lib/libedit/history.c Fri Jun 22 16:31:00 2012 (r237447) > +++ head/lib/libedit/history.c Fri Jun 22 18:01:22 2012 (r237448) > @@ -29,7 +29,7 @@ > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > - * $NetBSD: history.c,v 1.32 2006/09/28 13:52:51 christos Exp $ > + * $NetBSD: history.c,v 1.34 2009/09/07 21:24:33 christos Exp $ > */ > =20 > #if !defined(lint) && !defined(SCCSID) > @@ -116,6 +116,7 @@ private int history_prev_string(History=20 > */ > typedef struct hentry_t { > HistEvent ev; /* What we return */ > + void *data; /* data */ > struct hentry_t *next; /* Next entry */ > struct hentry_t *prev; /* Previous entry */ > } hentry_t; > @@ -145,6 +146,9 @@ private int history_def_init(ptr_t *, Hi > private int history_def_insert(history_t *, HistEvent *, const char *); > private void history_def_delete(history_t *, HistEvent *, hentry_t *); > =20 > +private int history_deldata_nth(history_t *, HistEvent *, int, void **); > +private int history_set_nth(ptr_t, HistEvent *, int); > + > #define history_def_setsize(p, num)(void) (((history_t *)p)->max =3D (nu= m)) > #define history_def_getsize(p) (((history_t *)p)->cur) > #define history_def_getunique(p) (((((history_t *)p)->flags) & H_UNIQUE)= !=3D 0) > @@ -335,6 +339,31 @@ history_def_set(ptr_t p, HistEvent *ev,=20 > } > =20 > =20 > +/* history_set_nth(): > + * Default function to set the current event in the history to the > + * n-th one. > + */ > +private int > +history_set_nth(ptr_t p, HistEvent *ev, int n) > +{ > + history_t *h =3D (history_t *) p; > + > + if (h->cur =3D=3D 0) { > + he_seterrev(ev, _HE_EMPTY_LIST); > + return (-1); > + } > + for (h->cursor =3D h->list.prev; h->cursor !=3D &h->list; > + h->cursor =3D h->cursor->prev) > + if (n-- <=3D 0) > + break; > + if (h->cursor =3D=3D &h->list) { > + he_seterrev(ev, _HE_NOT_FOUND); > + return (-1); > + } > + return (0); > +} > + > + > /* history_def_add(): > * Append string to element > */ > @@ -363,6 +392,24 @@ history_def_add(ptr_t p, HistEvent *ev,=20 > } > =20 > =20 > +private int > +history_deldata_nth(history_t *h, HistEvent *ev, > + int num, void **data) > +{ > + if (history_set_nth(h, ev, num) !=3D 0) > + return (-1); > + /* magic value to skip delete (just set to n-th history) */ > + if (data =3D=3D (void **)-1) > + return (0); > + ev->str =3D strdup(h->cursor->ev.str); > + ev->num =3D h->cursor->ev.num; > + if (data) > + *data =3D h->cursor->data; > + history_def_delete(h, ev, h->cursor); > + return (0); > +} > + > + > /* history_def_del(): > * Delete element hp of the h list > */ > @@ -392,8 +439,11 @@ history_def_delete(history_t *h,=20 > HistEventPrivate *evp =3D (void *)&hp->ev; > if (hp =3D=3D &h->list) > abort(); > - if (h->cursor =3D=3D hp) > + if (h->cursor =3D=3D hp) { > h->cursor =3D hp->prev; > + if (h->cursor =3D=3D &h->list) > + h->cursor =3D hp->next; > + } > hp->prev->next =3D hp->next; > hp->next->prev =3D hp->prev; > h_free((ptr_t) evp->str); > @@ -416,6 +466,7 @@ history_def_insert(history_t *h, HistEve > h_free((ptr_t)h->cursor); > goto oomem; > } > + h->cursor->data =3D NULL; > h->cursor->ev.num =3D ++h->eventid; > h->cursor->next =3D h->list.next; > h->cursor->prev =3D &h->list; > @@ -711,8 +762,8 @@ history_load(History *h, const char *fna > (void) strunvis(ptr, line); > line[sz] =3D c; > if (HENTER(h, &ev, ptr) =3D=3D -1) { > - h_free((ptr_t)ptr); > - return -1; > + i =3D -1; > + goto oomem; > } > } > oomem: > @@ -787,6 +838,23 @@ history_prev_event(History *h, HistEvent > } > =20 > =20 > +private int > +history_next_evdata(History *h, HistEvent *ev, int num, void **d) > +{ > + int retval; > + > + for (retval =3D HCURR(h, ev); retval !=3D -1; retval =3D HPREV(h, ev)) > + if (num-- <=3D 0) { > + if (d) > + *d =3D ((history_t *)h->h_ref)->cursor->data; > + return (0); > + } > + > + he_seterrev(ev, _HE_NOT_FOUND); > + return (-1); > +} > + > + > /* history_next_event(): > * Find the next event, with number given > */ > @@ -976,11 +1044,42 @@ history(History *h, HistEvent *ev, int f > retval =3D 0; > break; > =20 > + case H_NEXT_EVDATA: > + { > + int num =3D va_arg(va, int); > + void **d =3D va_arg(va, void **); > + retval =3D history_next_evdata(h, ev, num, d); > + break; > + } > + > + case H_DELDATA: > + { > + int num =3D va_arg(va, int); > + void **d =3D va_arg(va, void **); > + retval =3D history_deldata_nth((history_t *)h->h_ref, ev, num, d); > + break; > + } > + > + case H_REPLACE: /* only use after H_NEXT_EVDATA */ > + { > + const char *line =3D va_arg(va, const char *); > + void *d =3D va_arg(va, void *); > + const char *s; > + if(!line || !(s =3D strdup(line))) { > + retval =3D -1; > + break; > + } > + ((history_t *)h->h_ref)->cursor->ev.str =3D s; > + ((history_t *)h->h_ref)->cursor->data =3D d; > + retval =3D 0; > + break; > + } > + > default: > retval =3D -1; > he_seterrev(ev, _HE_UNKNOWN); > break; > } > va_end(va); > - return (retval); > + return retval; > } >=20 > Modified: head/lib/libedit/key.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/lib/libedit/key.c Fri Jun 22 16:31:00 2012 (r237447) > +++ head/lib/libedit/key.c Fri Jun 22 18:01:22 2012 (r237448) > @@ -29,7 +29,7 @@ > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > - * $NetBSD: key.c,v 1.19 2006/03/23 20:22:51 christos Exp $ > + * $NetBSD: key.c,v 1.20 2009/02/15 21:55:23 christos Exp $ > */ > =20 > #if !defined(lint) && !defined(SCCSID) > @@ -86,8 +86,8 @@ private void node__free(key_node_t *); > private void node__put(EditLine *, key_node_t *); > private int node__delete(EditLine *, key_node_t **, const char *); > private int node_lookup(EditLine *, const char *, key_node_t *, > - int); > -private int node_enum(EditLine *, key_node_t *, int); > + size_t); > +private int node_enum(EditLine *, key_node_t *, size_t); > =20 > #define KEY_BUFSIZ EL_BUFSIZ > =20 > @@ -478,9 +478,9 @@ node__free(key_node_t *k) > * Print if last node > */ > private int > -node_lookup(EditLine *el, const char *str, key_node_t *ptr, int cnt) > +node_lookup(EditLine *el, const char *str, key_node_t *ptr, size_t cnt) > { > - int ncnt; > + size_t ncnt; > =20 > if (ptr =3D=3D NULL) > return (-1); /* cannot have null ptr */ > @@ -493,7 +493,8 @@ node_lookup(EditLine *el, const char *st > /* If match put this char into el->el_key.buf. Recurse */ > if (ptr->ch =3D=3D *str) { > /* match found */ > - ncnt =3D key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt, > + ncnt =3D key__decode_char(el->el_key.buf, > + (size_t)KEY_BUFSIZ, cnt, > (unsigned char) ptr->ch); > if (ptr->next !=3D NULL) > /* not yet at leaf */ > @@ -527,9 +528,9 @@ node_lookup(EditLine *el, const char *st > * Traverse the node printing the characters it is bound in buffer > */ > private int > -node_enum(EditLine *el, key_node_t *ptr, int cnt) > +node_enum(EditLine *el, key_node_t *ptr, size_t cnt) > { > - int ncnt; > + size_t ncnt; > =20 > if (cnt >=3D KEY_BUFSIZ - 5) { /* buffer too small */ > el->el_key.buf[++cnt] =3D '"'; > @@ -547,7 +548,7 @@ node_enum(EditLine *el, key_node_t *ptr, > return (-1); > } > /* put this char at end of str */ > - ncnt =3D key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt, > + ncnt =3D key__decode_char(el->el_key.buf, (size_t)KEY_BUFSIZ, cnt, > (unsigned char)ptr->ch); > if (ptr->next =3D=3D NULL) { > /* print this key and function */ > @@ -615,8 +616,8 @@ key_kprint(EditLine *el, const char *key > /* key__decode_char(): > * Put a printable form of char in buf. > */ > -protected int > -key__decode_char(char *buf, int cnt, int off, int ch) > +protected size_t > +key__decode_char(char *buf, size_t cnt, size_t off, int ch) > { > char *sb =3D buf + off; > char *eb =3D buf + cnt; > @@ -626,7 +627,7 @@ key__decode_char(char *buf, int cnt, int > if (ch =3D=3D 0) { > ADDC('^'); > ADDC('@'); > - return b - sb; > + return (int)(b - sb); > } > if (iscntrl(ch)) { > ADDC('^'); > @@ -648,15 +649,15 @@ key__decode_char(char *buf, int cnt, int > ADDC((((unsigned int) ch >> 3) & 7) + '0'); > ADDC((ch & 7) + '0'); > } > - return b - sb; > + return (size_t)(b - sb); > } > =20 > =20 > /* key__decode_str(): > * Make a printable version of the ey > */ > -protected int > -key__decode_str(const char *str, char *buf, int len, const char *sep) > +protected size_t > +key__decode_str(const char *str, char *buf, size_t len, const char *sep) > { > char *b =3D buf, *eb =3D b + len; > const char *p; > @@ -699,7 +700,7 @@ key__decode_str(const char *str, char *b > } > done: > ADDC('\0'); > - if (b - buf >=3D len) > + if ((size_t)(b - buf) >=3D len) > buf[len - 1] =3D '\0'; > - return b - buf; > + return (size_t)(b - buf); > } >=20 > Modified: head/lib/libedit/key.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/lib/libedit/key.h Fri Jun 22 16:31:00 2012 (r237447) > +++ head/lib/libedit/key.h Fri Jun 22 18:01:22 2012 (r237448) > @@ -76,8 +76,8 @@ protected int key_delete(EditLine *, c > protected void key_print(EditLine *, const char *); > protected void key_kprint(EditLine *, const char *, key_value_t= *, > int); > -protected int key__decode_str(const char *, char *, int, > +protected size_t key__decode_str(const char *, char *, size_t, > const char *); > -protected int key__decode_char(char *, int, int, int); > +protected size_t key__decode_char(char *, size_t, size_t, int); > =20 > #endif /* _h_el_key */ >=20 > Modified: head/lib/libedit/prompt.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/lib/libedit/prompt.c Fri Jun 22 16:31:00 2012 (r237447) > +++ head/lib/libedit/prompt.c Fri Jun 22 18:01:22 2012 (r237448) > @@ -85,14 +85,23 @@ prompt_print(EditLine *el, int op) > { > el_prompt_t *elp; > char *p; > + int ignore =3D 0; > =20 > if (op =3D=3D EL_PROMPT) > elp =3D &el->el_prompt; > else > elp =3D &el->el_rprompt; > - p =3D (elp->p_func) (el); > - while (*p) > - re_putc(el, *p++, 1); > + > + for (p =3D (*elp->p_func)(el); *p; p++) { > + if (elp->p_ignore =3D=3D *p) { > + ignore =3D !ignore; > + continue; > + } > + if (ignore) > + term__putc(el, *p); > + else > + re_putc(el, *p, 1); > + } > =20 > elp->p_pos.v =3D el->el_refresh.r_cursor.v; > elp->p_pos.h =3D el->el_refresh.r_cursor.h; > @@ -109,10 +118,12 @@ prompt_init(EditLine *el) > el->el_prompt.p_func =3D prompt_default; > el->el_prompt.p_pos.v =3D 0; > el->el_prompt.p_pos.h =3D 0; > + el->el_prompt.p_ignore =3D '\0'; > el->el_rprompt.p_func =3D prompt_default_r; > el->el_rprompt.p_pos.v =3D 0; > el->el_rprompt.p_pos.h =3D 0; > - return (0); > + el->el_rprompt.p_ignore =3D '\0'; > + return 0; > } > =20 > =20 > @@ -130,24 +141,29 @@ prompt_end(EditLine *el __unused) > * Install a prompt printing function > */ > protected int > -prompt_set(EditLine *el, el_pfunc_t prf, int op) > +prompt_set(EditLine *el, el_pfunc_t prf, char c, int op) > { > el_prompt_t *p; > =20 > - if (op =3D=3D EL_PROMPT) > + if (op =3D=3D EL_PROMPT || op =3D=3D EL_PROMPT_ESC) > p =3D &el->el_prompt; > else > p =3D &el->el_rprompt; > + > if (prf =3D=3D NULL) { > - if (op =3D=3D EL_PROMPT) > + if (op =3D=3D EL_PROMPT || op =3D=3D EL_PROMPT_ESC) > p->p_func =3D prompt_default; > else > p->p_func =3D prompt_default_r; > } else > p->p_func =3D prf; > + > + p->p_ignore =3D c; > + > p->p_pos.v =3D 0; > p->p_pos.h =3D 0; > - return (0); > + > + return 0; > } > =20 > =20 > @@ -155,14 +171,22 @@ prompt_set(EditLine *el, el_pfunc_t prf, > * Retrieve the prompt printing function > */ > protected int > -prompt_get(EditLine *el, el_pfunc_t *prf, int op) > +prompt_get(EditLine *el, el_pfunc_t *prf, char *c, int op) > { > + el_prompt_t *p; > =20 > if (prf =3D=3D NULL) > - return (-1); > + return -1; > + > if (op =3D=3D EL_PROMPT) > - *prf =3D el->el_prompt.p_func; > + p =3D &el->el_prompt; > else > - *prf =3D el->el_rprompt.p_func; > - return (0); > + p =3D &el->el_rprompt; > + > + *prf =3D el->el_rprompt.p_func; > + > + if (c) > + *c =3D p->p_ignore; > + > + return 0; > } >=20 > Modified: head/lib/libedit/prompt.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/lib/libedit/prompt.h Fri Jun 22 16:31:00 2012 (r237447) > +++ head/lib/libedit/prompt.h Fri Jun 22 18:01:22 2012 (r237448) > @@ -47,11 +47,13 @@ typedef char * (*el_pfunc_t)(EditLine*); > typedef struct el_prompt_t { > el_pfunc_t p_func; /* Function to return the prompt */ > coord_t p_pos; /* position in the line after prompt */ > + char p_ignore; /* character to start/end literal=20 > +*/ > } el_prompt_t; > =20 > protected void prompt_print(EditLine *, int); > -protected int prompt_set(EditLine *, el_pfunc_t, int); > -protected int prompt_get(EditLine *, el_pfunc_t *, int); > +protected int prompt_set(EditLine *, el_pfunc_t, char, int); > +protected int prompt_get(EditLine *, el_pfunc_t *, char *, int); > protected int prompt_init(EditLine *); > protected void prompt_end(EditLine *); > =20 >=20 > Modified: head/lib/libedit/read.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/lib/libedit/read.c Fri Jun 22 16:31:00 2012 (r237447) > +++ head/lib/libedit/read.c Fri Jun 22 18:01:22 2012 (r237448) > @@ -29,7 +29,7 @@ > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > - * $NetBSD: read.c,v 1.40 2007/03/01 21:41:45 christos Exp $ > + * $NetBSD: read.c,v 1.52 2009/07/22 15:57:00 christos Exp $ > */ > =20 > #if !defined(lint) && !defined(SCCSID) > @@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$"); > #include > #include "el.h" > =20 > -#define OKCMD -1 > +#define OKCMD -1 /* must be -1! */ > =20 > private int read__fixio(int, int); > private int read_preread(EditLine *); > @@ -170,7 +170,7 @@ read__fixio(int fd __unused, int e) > return (e ? 0 : -1); > =20 > case EINTR: > - return (0); > + return (-1); > =20 > default: > return (-1); > @@ -222,7 +222,7 @@ el_push(EditLine *el, const char *str) > ma->level--; > } > term_beep(el); > - term__flush(); > + term__flush(el); > } > =20 > =20 > @@ -235,9 +235,12 @@ read_getcmd(EditLine *el, el_action_t *c > el_action_t cmd; > int num; > =20 > + el->el_errno =3D 0; > do { > - if ((num =3D el_getc(el, ch)) !=3D 1) /* if EOF or error */ > + if ((num =3D el_getc(el, ch)) !=3D 1) { /* if EOF or error */ > + el->el_errno =3D num =3D=3D 0 ? 0 : errno; > return (num); > + } > =20 > #ifdef KANJI > if ((*ch & 0200)) { > @@ -286,18 +289,25 @@ read_getcmd(EditLine *el, el_action_t *c > private int > read_char(EditLine *el, char *cp) > { > - int num_read; > + ssize_t num_read; > int tried =3D 0; > =20 > - while ((num_read =3D read(el->el_infd, cp, 1)) =3D=3D -1) > + again: > + el->el_signal->sig_no =3D 0; > + while ((num_read =3D read(el->el_infd, cp, 1)) =3D=3D -1) { > + if (el->el_signal->sig_no =3D=3D SIGCONT) { > + sig_set(el); > + el_set(el, EL_REFRESH); > + goto again; > + } > if (!tried && read__fixio(el->el_infd, errno) =3D=3D 0) > tried =3D 1; > else { > *cp =3D '\0'; > return (-1); > } > - > - return (num_read); > + } > + return (int)num_read; > } > =20 > /* read_pop(): > @@ -309,8 +319,9 @@ read_pop(c_macro_t *ma) > int i; > =20 > el_free(ma->macro[0]); > - for (i =3D ma->level--; i > 0; i--) > - ma->macro[i - 1] =3D ma->macro[i]; > + for (i =3D 0; i < ma->level; i++) > + ma->macro[i] =3D ma->macro[i + 1]; > + ma->level--; > ma->offset =3D 0; > } > =20 > @@ -323,7 +334,7 @@ el_getc(EditLine *el, char *cp) > int num_read; > c_macro_t *ma =3D &el->el_chared.c_macro; > =20 > - term__flush(); > + term__flush(el); > for (;;) { > if (ma->level < 0) { > if (!read_preread(el)) > @@ -382,7 +393,7 @@ read_prepare(EditLine *el) > re_refresh(el); /* print the prompt */ > =20 > if (el->el_flags & UNBUFFERED) > - term__flush(); > + term__flush(el); > } > =20 > protected void > @@ -402,15 +413,20 @@ el_gets(EditLine *el, int *nread) > int num; /* how many chars we have read at NL */ > char ch; > int crlf =3D 0; > + int nrb; > #ifdef FIONREAD > c_macro_t *ma =3D &el->el_chared.c_macro; > #endif /* FIONREAD */ > =20 > + if (nread =3D=3D NULL) > + nread =3D &nrb; > + *nread =3D 0; > + > if (el->el_flags & NO_TTY) { > char *cp =3D el->el_line.buffer; > size_t idx; > =20 > - while ((*el->el_read.read_char)(el, cp) =3D=3D 1) { > + while ((num =3D (*el->el_read.read_char)(el, cp)) =3D=3D 1) { > /* make sure there is space for next character */ > if (cp + 1 >=3D el->el_line.limit) { > idx =3D (cp - el->el_line.buffer); > @@ -424,12 +440,16 @@ el_gets(EditLine *el, int *nread) > if (cp[-1] =3D=3D '\r' || cp[-1] =3D=3D '\n') > break; > } > + if (num =3D=3D -1) { > + if (errno =3D=3D EINTR) > + cp =3D el->el_line.buffer; > + el->el_errno =3D errno; > + } > =20 > el->el_line.cursor =3D el->el_line.lastchar =3D cp; > *cp =3D '\0'; > - if (nread) > - *nread =3D el->el_line.cursor - el->el_line.buffer; > - return (el->el_line.buffer); > + *nread =3D (int)(el->el_line.cursor - el->el_line.buffer); > + goto done; > } > =20 > =20 > @@ -440,8 +460,8 @@ el_gets(EditLine *el, int *nread) > (void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs); >=20 > *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** > _______________________________________________ > svn-src-all@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" Thanks you for this work !! regards, Bapt --G6nVm6DDWH/FONJq Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAk/kzBMACgkQ8kTtMUmk6EyyAACffsLhGWZ9evLdTHAsKhIO3gDU xUAAnRKAKSX84WuXvcMJ1V/naFEEZ36e =QL50 -----END PGP SIGNATURE----- --G6nVm6DDWH/FONJq-- From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 20:29:08 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id CDDC2106564A; Fri, 22 Jun 2012 20:29:08 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from opti.dougb.net (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id 42AB8151DCA; Fri, 22 Jun 2012 20:29:08 +0000 (UTC) Message-ID: <4FE4D593.4040907@FreeBSD.org> Date: Fri, 22 Jun 2012 13:29:07 -0700 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:13.0) Gecko/20120621 Thunderbird/13.0.1 MIME-Version: 1.0 To: Baptiste Daroussin References: <201206221801.q5MI1NxN092238@svn.freebsd.org> <20120622194835.GE83730@ithaqua.etoilebsd.net> In-Reply-To: <20120622194835.GE83730@ithaqua.etoilebsd.net> X-Enigmail-Version: 1.4.2 OpenPGP: id=1A1ABC84 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, "Pedro F. Giffuni" , src-committers@FreeBSD.org Subject: Re: svn commit: r237448 - head/lib/libedit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 20:29:08 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 As a general rule, please trim out replies. This list is worse than most in the sense that people often reply to hundreds of lines only to add a line or 2 at the bottom. By trimming your reply you both save electrons, and make it easier for people to see what you have to say. Doug -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQEcBAEBCAAGBQJP5NWTAAoJEFzGhvEaGryEpVsH/3I60AiJ6JODDA9mx+ufW9LG SAr/p13YGlswZxL5LOLCLOvwjNrvK6CJieb42XI+70PYkGAGH8syKunTy9s4EPuQ 2wXWHw4jlJaUfMTOFsXOvoZIFTrH0YPRt3qZic4TdfuxWlEkqrk4G37+lVNMhdsW 0MLJD/eJC5rV3Ve/YMKB2OSPK47mukOmY0spFXG/N2NQRryOuV8N3D6ycbWGDn7q YJwpO98YxbbyxLEV394rGwVCK8T6taJXRBOLMu9VFR0L7321TPuayPc3cLg+0hQC owr6vN2ga0uD7vjhoKbApBTTHzWAGYVWN1LU+rpE0/b5QGZByq2Muiz5SARBncI= =cYw2 -----END PGP SIGNATURE----- From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 20:42:12 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 021B8106564A; Fri, 22 Jun 2012 20:42:12 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E192F8FC12; Fri, 22 Jun 2012 20:42:11 +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 q5MKgBtk099298; Fri, 22 Jun 2012 20:42:11 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5MKgBvR099296; Fri, 22 Jun 2012 20:42:11 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201206222042.q5MKgBvR099296@svn.freebsd.org> From: Martin Matuska Date: Fri, 22 Jun 2012 20:42:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237458 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 20:42:12 -0000 Author: mm Date: Fri Jun 22 20:42:11 2012 New Revision: 237458 URL: http://svn.freebsd.org/changeset/base/237458 Log: Import Illumos revision 13736:9f1d48e1681f 2901 ZFS receive fails for exabyte sparse files References: https://www.illumos.org/issues/2901 Obtained from: illumos (issue #2901) MFC after: 1 week Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Fri Jun 22 20:38:08 2012 (r237457) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Fri Jun 22 20:42:11 2012 (r237458) @@ -93,6 +93,9 @@ dump_free(dmu_sendarg_t *dsp, uint64_t o { struct drr_free *drrf = &(dsp->dsa_drr->drr_u.drr_free); + if (length != -1ULL && offset + length < offset) + length = -1ULL; + /* * If there is a pending op, but it's not PENDING_FREE, push it out, * since free block aggregation can only be done for blocks of the From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 21:26:35 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9AFD5106566B; Fri, 22 Jun 2012 21:26:35 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 868298FC08; Fri, 22 Jun 2012 21:26:35 +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 q5MLQZPu001261; Fri, 22 Jun 2012 21:26:35 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5MLQZtv001259; Fri, 22 Jun 2012 21:26:35 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201206222126.q5MLQZtv001259@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Fri, 22 Jun 2012 21:26:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237459 - head/sys/netinet6 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 21:26:35 -0000 Author: bz Date: Fri Jun 22 21:26:35 2012 New Revision: 237459 URL: http://svn.freebsd.org/changeset/base/237459 Log: Just add a comment to further investigate when being closer to that code again next time. The condition of the 2nd if() is very unlikely ever met. Modified: head/sys/netinet6/in6_src.c Modified: head/sys/netinet6/in6_src.c ============================================================================== --- head/sys/netinet6/in6_src.c Fri Jun 22 20:42:11 2012 (r237458) +++ head/sys/netinet6/in6_src.c Fri Jun 22 21:26:35 2012 (r237459) @@ -597,6 +597,7 @@ selectroute(struct sockaddr_in6 *dstsock if (ron->ro_rt == NULL) { in6_rtalloc(ron, fibnum); /* multi path case? */ if (ron->ro_rt == NULL) { + /* XXX-BZ WT.? */ if (ron->ro_rt) { RTFREE(ron->ro_rt); ron->ro_rt = NULL; From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 21:46:42 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C07E11065673; Fri, 22 Jun 2012 21:46:42 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AB5718FC12; Fri, 22 Jun 2012 21:46:42 +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 q5MLkgHq002120; Fri, 22 Jun 2012 21:46:42 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5MLkgvI002118; Fri, 22 Jun 2012 21:46:42 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206222146.q5MLkgvI002118@svn.freebsd.org> From: Alexander Motin Date: Fri, 22 Jun 2012 21:46:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237460 - head/sys/dev/twa X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 21:46:42 -0000 Author: mav Date: Fri Jun 22 21:46:41 2012 New Revision: 237460 URL: http://svn.freebsd.org/changeset/base/237460 Log: Return CAM_SEL_TIMEOUT and CAM_DEV_NOT_THERE instead of CAM_TID_INVALID and CAM_LUN_INVALID for case of missing devices. In removes tons of error messages from CAM during bus scans. Reported and tested by: Mike Tancsa MFC after: 3 days Modified: head/sys/dev/twa/tw_osl_cam.c Modified: head/sys/dev/twa/tw_osl_cam.c ============================================================================== --- head/sys/dev/twa/tw_osl_cam.c Fri Jun 22 21:26:35 2012 (r237459) +++ head/sys/dev/twa/tw_osl_cam.c Fri Jun 22 21:46:41 2012 (r237460) @@ -678,9 +678,9 @@ tw_osl_complete_io(struct tw_cl_req_hand ccb->ccb_h.status = CAM_REQ_CMP; else { if (req_pkt->status & TW_CL_ERR_REQ_INVALID_TARGET) - ccb->ccb_h.status |= CAM_TID_INVALID; + ccb->ccb_h.status |= CAM_SEL_TIMEOUT; else if (req_pkt->status & TW_CL_ERR_REQ_INVALID_LUN) - ccb->ccb_h.status |= CAM_LUN_INVALID; + ccb->ccb_h.status |= CAM_DEV_NOT_THERE; else if (req_pkt->status & TW_CL_ERR_REQ_SCSI_ERROR) ccb->ccb_h.status |= CAM_SCSI_STATUS_ERROR; else if (req_pkt->status & TW_CL_ERR_REQ_BUS_RESET) From owner-svn-src-head@FreeBSD.ORG Fri Jun 22 22:59:43 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 75462106564A; Fri, 22 Jun 2012 22:59:43 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 469568FC08; Fri, 22 Jun 2012 22:59:43 +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 q5MMxhnR005243; Fri, 22 Jun 2012 22:59:43 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5MMxhNA005240; Fri, 22 Jun 2012 22:59:43 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201206222259.q5MMxhNA005240@svn.freebsd.org> From: Navdeep Parhar Date: Fri, 22 Jun 2012 22:59:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237463 - head/sys/dev/cxgbe X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2012 22:59:43 -0000 Author: np Date: Fri Jun 22 22:59:42 2012 New Revision: 237463 URL: http://svn.freebsd.org/changeset/base/237463 Log: Do not allocate extra vectors when adapter is not TOE capable (or toecaps have been disallowed by the user). + one very minor unrelated cleanup in t4_sge.c Modified: head/sys/dev/cxgbe/t4_main.c head/sys/dev/cxgbe/t4_sge.c Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Fri Jun 22 22:50:50 2012 (r237462) +++ head/sys/dev/cxgbe/t4_main.c Fri Jun 22 22:59:42 2012 (r237463) @@ -1308,10 +1308,12 @@ cfg_itype_and_nqueues(struct adapter *sc iaq->nrxq10g = nrxq10g = t4_nrxq10g; iaq->nrxq1g = nrxq1g = t4_nrxq1g; #ifdef TCP_OFFLOAD - iaq->nofldtxq10g = t4_nofldtxq10g; - iaq->nofldtxq1g = t4_nofldtxq1g; - iaq->nofldrxq10g = nofldrxq10g = t4_nofldrxq10g; - iaq->nofldrxq1g = nofldrxq1g = t4_nofldrxq1g; + if (is_offload(sc)) { + iaq->nofldtxq10g = t4_nofldtxq10g; + iaq->nofldtxq1g = t4_nofldtxq1g; + iaq->nofldrxq10g = nofldrxq10g = t4_nofldrxq10g; + iaq->nofldrxq1g = nofldrxq1g = t4_nofldrxq1g; + } #endif for (itype = INTR_MSIX; itype; itype >>= 1) { @@ -1380,7 +1382,8 @@ restart: } iaq->nrxq10g = min(n, nrxq10g); #ifdef TCP_OFFLOAD - iaq->nofldrxq10g = min(n, nofldrxq10g); + if (is_offload(sc)) + iaq->nofldrxq10g = min(n, nofldrxq10g); #endif } @@ -1395,7 +1398,8 @@ restart: } iaq->nrxq1g = min(n, nrxq1g); #ifdef TCP_OFFLOAD - iaq->nofldrxq1g = min(n, nofldrxq1g); + if (is_offload(sc)) + iaq->nofldrxq1g = min(n, nofldrxq1g); #endif } @@ -1408,7 +1412,8 @@ restart: */ iaq->nirq = iaq->nrxq10g = iaq->nrxq1g = 1; #ifdef TCP_OFFLOAD - iaq->nofldrxq10g = iaq->nofldrxq1g = 1; + if (is_offload(sc)) + iaq->nofldrxq10g = iaq->nofldrxq1g = 1; #endif allocate: Modified: head/sys/dev/cxgbe/t4_sge.c ============================================================================== --- head/sys/dev/cxgbe/t4_sge.c Fri Jun 22 22:50:50 2012 (r237462) +++ head/sys/dev/cxgbe/t4_sge.c Fri Jun 22 22:59:42 2012 (r237463) @@ -1031,7 +1031,7 @@ get_fl_payload(struct adapter *sc, struc static int t4_eth_rx(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m0) { - struct sge_rxq *rxq = (void *)iq; + struct sge_rxq *rxq = iq_to_rxq(iq); struct ifnet *ifp = rxq->ifp; const struct cpl_rx_pkt *cpl = (const void *)(rss + 1); #ifdef INET From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 06:03:52 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6A65B106566C; Sat, 23 Jun 2012 06:03:52 +0000 (UTC) (envelope-from marcel@xcllnt.net) Received: from mail.xcllnt.net (mail.xcllnt.net [70.36.220.4]) by mx1.freebsd.org (Postfix) with ESMTP id 4545F8FC16; Sat, 23 Jun 2012 06:03:52 +0000 (UTC) Received: from [192.168.2.58] (wifi.xcllnt.net [70.36.220.6] (may be forged)) (authenticated bits=0) by mail.xcllnt.net (8.14.5/8.14.5) with ESMTP id q5N63e9M061390 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Fri, 22 Jun 2012 23:03:51 -0700 (PDT) (envelope-from marcel@xcllnt.net) Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=us-ascii From: Marcel Moolenaar In-Reply-To: <201206210310.q5L3AmLd084976@svn.freebsd.org> Date: Fri, 22 Jun 2012 23:03:40 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <6526CF11-F29B-4BEC-B577-5F5392D17223@xcllnt.net> References: <201206210310.q5L3AmLd084976@svn.freebsd.org> To: Max Khon X-Mailer: Apple Mail (2.1278) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r237350 - head/sys/dev/puc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 06:03:52 -0000 On Jun 20, 2012, at 8:10 PM, Max Khon wrote: >=20 > Modified: head/sys/dev/puc/puc_cfg.h > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/dev/puc/puc_cfg.h Thu Jun 21 02:48:49 2012 = (r237349) > +++ head/sys/dev/puc/puc_cfg.h Thu Jun 21 03:10:48 2012 = (r237350) > @@ -79,7 +79,7 @@ struct puc_cfg { > int8_t ports; > int8_t rid; /* Rid of first port */ > int8_t d_rid; /* Delta rid of next ports */ > - int8_t d_ofs; /* Delta offset of next ports */ > + int16_t d_ofs; /* Delta offset of next ports */ > puc_config_f *config_function; > }; The purpose of the uint8_t is to minimize wastage. For the uncommon cases there's the config_function. Given that uint8_t has been adequate for a very long time, I think it's fair to say that the MOXA devices have an uncommon configuration and that you shouldn't pessimize the common case by extending the type of d_ofs and as a side-effect add padding before it *and* after it -- the structure was optimal for both ILP32 and LP64. Please revert the above change and handle the uncommonly large offset by extending the existing moxa configuration file. It's the precedence that should have been followed anyway. Thanks, --=20 Marcel Moolenaar marcel@xcllnt.net From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 09:33:07 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D9EE106566B; Sat, 23 Jun 2012 09:33:07 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 16E268FC17; Sat, 23 Jun 2012 09:33:07 +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 q5N9X6Bl032385; Sat, 23 Jun 2012 09:33:06 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5N9X6gr032380; Sat, 23 Jun 2012 09:33:06 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206230933.q5N9X6gr032380@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 23 Jun 2012 09:33:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237474 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 09:33:07 -0000 Author: kib Date: Sat Jun 23 09:33:06 2012 New Revision: 237474 URL: http://svn.freebsd.org/changeset/base/237474 Log: Stop updating the struct vdso_timehands from even handler executed in the scheduled task from tc_windup(). Do it directly from tc_windup in interrupt context [1]. Establish the permanent mapping of the shared page into the kernel address space, avoiding the potential need to sleep waiting for allocation of sf buffer during vdso_timehands update. As a consequence, shared_page_write_start() and shared_page_write_end() functions are not needed anymore. Guess and memorize the pointers to native host and compat32 sysentvec during initialization, to avoid the need to get shared_page_alloc_sx lock during the update. In tc_fill_vdso_timehands(), do not loop waiting for timehands generation to stabilize, since vdso_timehands is written in the same interrupt context which wrote timehands. Requested by: mav [1] MFC after: 29 days Modified: head/sys/kern/kern_exec.c head/sys/kern/kern_tc.c head/sys/sys/sysent.h head/sys/sys/vdso.h Modified: head/sys/kern/kern_exec.c ============================================================================== --- head/sys/kern/kern_exec.c Sat Jun 23 08:36:49 2012 (r237473) +++ head/sys/kern/kern_exec.c Sat Jun 23 09:33:06 2012 (r237474) @@ -1517,42 +1517,13 @@ exec_unregister(execsw_arg) static struct sx shared_page_alloc_sx; static vm_object_t shared_page_obj; static int shared_page_free; - -struct sf_buf * -shared_page_write_start(int base) -{ - vm_page_t m; - struct sf_buf *s; - - VM_OBJECT_LOCK(shared_page_obj); - m = vm_page_grab(shared_page_obj, OFF_TO_IDX(base), VM_ALLOC_RETRY); - VM_OBJECT_UNLOCK(shared_page_obj); - s = sf_buf_alloc(m, SFB_DEFAULT); - return (s); -} - -void -shared_page_write_end(struct sf_buf *sf) -{ - vm_page_t m; - - m = sf_buf_page(sf); - sf_buf_free(sf); - VM_OBJECT_LOCK(shared_page_obj); - vm_page_wakeup(m); - VM_OBJECT_UNLOCK(shared_page_obj); -} +char *shared_page_mapping; void shared_page_write(int base, int size, const void *data) { - struct sf_buf *sf; - vm_offset_t sk; - sf = shared_page_write_start(base); - sk = sf_buf_kva(sf); - bcopy(data, (void *)(sk + (base & PAGE_MASK)), size); - shared_page_write_end(sf); + bcopy(data, shared_page_mapping + base, size); } static int @@ -1596,6 +1567,7 @@ static void shared_page_init(void *dummy __unused) { vm_page_t m; + vm_offset_t addr; sx_init(&shared_page_alloc_sx, "shpsx"); shared_page_obj = vm_pager_allocate(OBJT_PHYS, 0, PAGE_SIZE, @@ -1605,25 +1577,24 @@ shared_page_init(void *dummy __unused) VM_ALLOC_ZERO); m->valid = VM_PAGE_BITS_ALL; VM_OBJECT_UNLOCK(shared_page_obj); + addr = kmem_alloc_nofault(kernel_map, PAGE_SIZE); + pmap_qenter(addr, &m, 1); + shared_page_mapping = (char *)addr; } SYSINIT(shp, SI_SUB_EXEC, SI_ORDER_FIRST, (sysinit_cfunc_t)shared_page_init, NULL); static void -timehands_update(void *arg) +timehands_update(struct sysentvec *sv) { - struct sysentvec *sv; - struct sf_buf *sf; struct vdso_timehands th; struct vdso_timekeep *tk; uint32_t enabled, idx; - sv = arg; - sx_xlock(&shared_page_alloc_sx); enabled = tc_fill_vdso_timehands(&th); - sf = shared_page_write_start(sv->sv_timekeep_off); - tk = (void *)(sf_buf_kva(sf) + (sv->sv_timekeep_off & PAGE_MASK)); + tk = (struct vdso_timekeep *)(shared_page_mapping + + sv->sv_timekeep_off); idx = sv->sv_timekeep_curr; atomic_store_rel_32(&tk->tk_th[idx].th_gen, 0); if (++idx >= VDSO_TH_NUM) @@ -1637,25 +1608,19 @@ timehands_update(void *arg) tk->tk_enabled = enabled; atomic_store_rel_32(&tk->tk_th[idx].th_gen, sv->sv_timekeep_gen); tk->tk_current = idx; - shared_page_write_end(sf); - sx_xunlock(&shared_page_alloc_sx); } #ifdef COMPAT_FREEBSD32 static void -timehands_update32(void *arg) +timehands_update32(struct sysentvec *sv) { - struct sysentvec *sv; - struct sf_buf *sf; struct vdso_timekeep32 *tk; struct vdso_timehands32 th; uint32_t enabled, idx; - sv = arg; - sx_xlock(&shared_page_alloc_sx); enabled = tc_fill_vdso_timehands32(&th); - sf = shared_page_write_start(sv->sv_timekeep_off); - tk = (void *)(sf_buf_kva(sf) + (sv->sv_timekeep_off & PAGE_MASK)); + tk = (struct vdso_timekeep32 *)(shared_page_mapping + + sv->sv_timekeep_off); idx = sv->sv_timekeep_curr; atomic_store_rel_32(&tk->tk_th[idx].th_gen, 0); if (++idx >= VDSO_TH_NUM) @@ -1669,11 +1634,32 @@ timehands_update32(void *arg) tk->tk_enabled = enabled; atomic_store_rel_32(&tk->tk_th[idx].th_gen, sv->sv_timekeep_gen); tk->tk_current = idx; - shared_page_write_end(sf); - sx_xunlock(&shared_page_alloc_sx); } #endif +/* + * This is hackish, but easiest way to avoid creating list structures + * that needs to be iterated over from the hardclock interrupt + * context. + */ +static struct sysentvec *host_sysentvec; +#ifdef COMPAT_FREEBSD32 +static struct sysentvec *compat32_sysentvec; +#endif + +void +timekeep_push_vdso(void) +{ + + if (host_sysentvec != NULL && host_sysentvec->sv_timekeep_base != 0) + timehands_update(host_sysentvec); +#ifdef COMPAT_FREEBSD32 + if (compat32_sysentvec != NULL && + compat32_sysentvec->sv_timekeep_base != 0) + timehands_update32(compat32_sysentvec); +#endif +} + void exec_sysvec_init(void *param) { @@ -1688,29 +1674,32 @@ exec_sysvec_init(void *param) sv->sv_shared_page_obj = shared_page_obj; sv->sv_sigcode_base = sv->sv_shared_page_base + shared_page_fill(*(sv->sv_szsigcode), 16, sv->sv_sigcode); + if ((sv->sv_flags & SV_ABI_MASK) != SV_ABI_FREEBSD) + return; tk_ver = VDSO_TK_VER_CURR; #ifdef COMPAT_FREEBSD32 if ((sv->sv_flags & SV_ILP32) != 0) { tk_base = shared_page_alloc(sizeof(struct vdso_timekeep32) + sizeof(struct vdso_timehands32) * VDSO_TH_NUM, 16); KASSERT(tk_base != -1, ("tk_base -1 for 32bit")); - EVENTHANDLER_REGISTER(tc_windup, timehands_update32, sv, - EVENTHANDLER_PRI_ANY); shared_page_write(tk_base + offsetof(struct vdso_timekeep32, tk_ver), sizeof(uint32_t), &tk_ver); + KASSERT(compat32_sysentvec == 0, + ("Native compat32 already registered")); + compat32_sysentvec = sv; } else { #endif tk_base = shared_page_alloc(sizeof(struct vdso_timekeep) + sizeof(struct vdso_timehands) * VDSO_TH_NUM, 16); KASSERT(tk_base != -1, ("tk_base -1 for native")); - EVENTHANDLER_REGISTER(tc_windup, timehands_update, sv, - EVENTHANDLER_PRI_ANY); shared_page_write(tk_base + offsetof(struct vdso_timekeep, tk_ver), sizeof(uint32_t), &tk_ver); + KASSERT(host_sysentvec == 0, ("Native already registered")); + host_sysentvec = sv; #ifdef COMPAT_FREEBSD32 } #endif sv->sv_timekeep_base = sv->sv_shared_page_base + tk_base; sv->sv_timekeep_off = tk_base; - EVENTHANDLER_INVOKE(tc_windup); + timekeep_push_vdso(); } Modified: head/sys/kern/kern_tc.c ============================================================================== --- head/sys/kern/kern_tc.c Sat Jun 23 08:36:49 2012 (r237473) +++ head/sys/kern/kern_tc.c Sat Jun 23 09:33:06 2012 (r237474) @@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -121,12 +120,8 @@ SYSCTL_INT(_kern_timecounter, OID_AUTO, ×tepwarnings, 0, "Log time steps"); static void tc_windup(void); -static void tc_windup_push_vdso(void *ctx, int pending); static void cpu_tick_calibrate(int); -static struct task tc_windup_push_vdso_task = TASK_INITIALIZER(0, - tc_windup_push_vdso, 0); - static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) { @@ -1367,7 +1362,7 @@ tc_windup(void) #endif timehands = th; - taskqueue_enqueue_fast(taskqueue_fast, &tc_windup_push_vdso_task); + timekeep_push_vdso(); } /* Report or change the active timecounter hardware. */ @@ -1394,7 +1389,7 @@ sysctl_kern_timecounter_hardware(SYSCTL_ (void)newtc->tc_get_timecount(newtc); timecounter = newtc; - EVENTHANDLER_INVOKE(tc_windup); + timekeep_push_vdso(); return (0); } return (EINVAL); @@ -1865,7 +1860,7 @@ sysctl_fast_gettime(SYSCTL_HANDLER_ARGS) if (error != 0) return (error); vdso_th_enable = old_vdso_th_enable; - EVENTHANDLER_INVOKE(tc_windup); + timekeep_push_vdso(); return (0); } SYSCTL_PROC(_kern_timecounter, OID_AUTO, fast_gettime, @@ -1877,19 +1872,15 @@ tc_fill_vdso_timehands(struct vdso_timeh { struct timehands *th; uint32_t enabled; - int gen; - do { - th = timehands; - gen = th->th_generation; - vdso_th->th_algo = VDSO_TH_ALGO_1; - vdso_th->th_scale = th->th_scale; - vdso_th->th_offset_count = th->th_offset_count; - vdso_th->th_counter_mask = th->th_counter->tc_counter_mask; - vdso_th->th_offset = th->th_offset; - vdso_th->th_boottime = boottimebin; - enabled = cpu_fill_vdso_timehands(vdso_th); - } while (gen == 0 || timehands->th_generation != gen); + th = timehands; + vdso_th->th_algo = VDSO_TH_ALGO_1; + vdso_th->th_scale = th->th_scale; + vdso_th->th_offset_count = th->th_offset_count; + vdso_th->th_counter_mask = th->th_counter->tc_counter_mask; + vdso_th->th_offset = th->th_offset; + vdso_th->th_boottime = boottimebin; + enabled = cpu_fill_vdso_timehands(vdso_th); if (!vdso_th_enable) enabled = 0; return (enabled); @@ -1901,30 +1892,19 @@ tc_fill_vdso_timehands32(struct vdso_tim { struct timehands *th; uint32_t enabled; - int gen; - do { - th = timehands; - gen = th->th_generation; - vdso_th32->th_algo = VDSO_TH_ALGO_1; - *(uint64_t *)&vdso_th32->th_scale[0] = th->th_scale; - vdso_th32->th_offset_count = th->th_offset_count; - vdso_th32->th_counter_mask = th->th_counter->tc_counter_mask; - vdso_th32->th_offset.sec = th->th_offset.sec; - *(uint64_t *)&vdso_th32->th_offset.frac[0] = th->th_offset.frac; - vdso_th32->th_boottime.sec = boottimebin.sec; - *(uint64_t *)&vdso_th32->th_boottime.frac[0] = boottimebin.frac; - enabled = cpu_fill_vdso_timehands32(vdso_th32); - } while (gen == 0 || timehands->th_generation != gen); + th = timehands; + vdso_th32->th_algo = VDSO_TH_ALGO_1; + *(uint64_t *)&vdso_th32->th_scale[0] = th->th_scale; + vdso_th32->th_offset_count = th->th_offset_count; + vdso_th32->th_counter_mask = th->th_counter->tc_counter_mask; + vdso_th32->th_offset.sec = th->th_offset.sec; + *(uint64_t *)&vdso_th32->th_offset.frac[0] = th->th_offset.frac; + vdso_th32->th_boottime.sec = boottimebin.sec; + *(uint64_t *)&vdso_th32->th_boottime.frac[0] = boottimebin.frac; + enabled = cpu_fill_vdso_timehands32(vdso_th32); if (!vdso_th_enable) enabled = 0; return (enabled); } #endif - -static void -tc_windup_push_vdso(void *ctx, int pending) -{ - - EVENTHANDLER_INVOKE(tc_windup); -} Modified: head/sys/sys/sysent.h ============================================================================== --- head/sys/sys/sysent.h Sat Jun 23 08:36:49 2012 (r237473) +++ head/sys/sys/sysent.h Sat Jun 23 09:33:06 2012 (r237474) @@ -265,8 +265,6 @@ int shared_page_alloc(int size, int alig int shared_page_fill(int size, int align, const void *data); void shared_page_write(int base, int size, const void *data); void exec_sysvec_init(void *param); -struct sf_buf *shared_page_write_start(int base); -void shared_page_write_end(struct sf_buf *sf); #define INIT_SYSENTVEC(name, sv) \ SYSINIT(name, SI_SUB_EXEC, SI_ORDER_ANY, \ Modified: head/sys/sys/vdso.h ============================================================================== --- head/sys/sys/vdso.h Sat Jun 23 08:36:49 2012 (r237473) +++ head/sys/sys/vdso.h Sat Jun 23 09:33:06 2012 (r237474) @@ -29,7 +29,6 @@ #define _SYS_VDSO_H #include -#include #include struct vdso_timehands { @@ -74,6 +73,8 @@ u_int __vdso_gettc(const struct vdso_tim #ifdef _KERNEL +void timekeep_push_vdso(void); + uint32_t tc_fill_vdso_timehands(struct vdso_timehands *vdso_th); /* @@ -86,9 +87,6 @@ uint32_t tc_fill_vdso_timehands(struct v */ uint32_t cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th); -typedef void (*tc_windup_fn)(void *); -EVENTHANDLER_DECLARE(tc_windup, tc_windup_fn); - #define VDSO_TH_NUM 4 #ifdef COMPAT_FREEBSD32 From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 10:14:51 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E8952106566C; Sat, 23 Jun 2012 10:14:51 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D36028FC0A; Sat, 23 Jun 2012 10:14:51 +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 q5NAEpgB034213; Sat, 23 Jun 2012 10:14:51 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5NAEpUL034211; Sat, 23 Jun 2012 10:14:51 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206231014.q5NAEpUL034211@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 23 Jun 2012 10:14:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237476 - head/sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 10:14:52 -0000 Author: kib Date: Sat Jun 23 10:14:51 2012 New Revision: 237476 URL: http://svn.freebsd.org/changeset/base/237476 Log: Remove no longer needed forward declaration for struct sf_buf. MFC after: 29 days Modified: head/sys/sys/sysent.h Modified: head/sys/sys/sysent.h ============================================================================== --- head/sys/sys/sysent.h Sat Jun 23 09:50:41 2012 (r237475) +++ head/sys/sys/sysent.h Sat Jun 23 10:14:51 2012 (r237476) @@ -260,7 +260,6 @@ int lkmressys(struct thread *, struct no int syscall_thread_enter(struct thread *td, struct sysent *se); void syscall_thread_exit(struct thread *td, struct sysent *se); -struct sf_buf; int shared_page_alloc(int size, int align); int shared_page_fill(int size, int align, const void *data); void shared_page_write(int base, int size, const void *data); From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 10:15:23 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DFC8310657C1; Sat, 23 Jun 2012 10:15:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C959C8FC14; Sat, 23 Jun 2012 10:15:23 +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 q5NAFNhU034278; Sat, 23 Jun 2012 10:15:23 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5NAFN7v034274; Sat, 23 Jun 2012 10:15:23 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206231015.q5NAFN7v034274@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 23 Jun 2012 10:15:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237477 - in head/sys: conf kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 10:15:24 -0000 Author: kib Date: Sat Jun 23 10:15:23 2012 New Revision: 237477 URL: http://svn.freebsd.org/changeset/base/237477 Log: Move the code dealing with shared page into a dedicated kern_sharedpage.c source file from kern_exec.c. MFC after: 29 days Added: head/sys/kern/kern_sharedpage.c - copied, changed from r237475, head/sys/kern/kern_exec.c Modified: head/sys/conf/files head/sys/kern/kern_exec.c Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Sat Jun 23 10:14:51 2012 (r237476) +++ head/sys/conf/files Sat Jun 23 10:15:23 2012 (r237477) @@ -2567,6 +2567,7 @@ kern/kern_rmlock.c standard kern/kern_rwlock.c standard kern/kern_sdt.c optional kdtrace_hooks kern/kern_sema.c standard +kern/kern_sharedpage.c standard kern/kern_shutdown.c standard kern/kern_sig.c standard kern/kern_switch.c standard Modified: head/sys/kern/kern_exec.c ============================================================================== --- head/sys/kern/kern_exec.c Sat Jun 23 10:14:51 2012 (r237476) +++ head/sys/kern/kern_exec.c Sat Jun 23 10:15:23 2012 (r237477) @@ -28,7 +28,6 @@ __FBSDID("$FreeBSD$"); #include "opt_capsicum.h" -#include "opt_compat.h" #include "opt_hwpmc_hooks.h" #include "opt_kdtrace.h" #include "opt_ktrace.h" @@ -65,7 +64,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #ifdef KTRACE @@ -1513,193 +1511,3 @@ exec_unregister(execsw_arg) execsw = newexecsw; return (0); } - -static struct sx shared_page_alloc_sx; -static vm_object_t shared_page_obj; -static int shared_page_free; -char *shared_page_mapping; - -void -shared_page_write(int base, int size, const void *data) -{ - - bcopy(data, shared_page_mapping + base, size); -} - -static int -shared_page_alloc_locked(int size, int align) -{ - int res; - - res = roundup(shared_page_free, align); - if (res + size >= IDX_TO_OFF(shared_page_obj->size)) - res = -1; - else - shared_page_free = res + size; - return (res); -} - -int -shared_page_alloc(int size, int align) -{ - int res; - - sx_xlock(&shared_page_alloc_sx); - res = shared_page_alloc_locked(size, align); - sx_xunlock(&shared_page_alloc_sx); - return (res); -} - -int -shared_page_fill(int size, int align, const void *data) -{ - int res; - - sx_xlock(&shared_page_alloc_sx); - res = shared_page_alloc_locked(size, align); - if (res != -1) - shared_page_write(res, size, data); - sx_xunlock(&shared_page_alloc_sx); - return (res); -} - -static void -shared_page_init(void *dummy __unused) -{ - vm_page_t m; - vm_offset_t addr; - - sx_init(&shared_page_alloc_sx, "shpsx"); - shared_page_obj = vm_pager_allocate(OBJT_PHYS, 0, PAGE_SIZE, - VM_PROT_DEFAULT, 0, NULL); - VM_OBJECT_LOCK(shared_page_obj); - m = vm_page_grab(shared_page_obj, 0, VM_ALLOC_RETRY | VM_ALLOC_NOBUSY | - VM_ALLOC_ZERO); - m->valid = VM_PAGE_BITS_ALL; - VM_OBJECT_UNLOCK(shared_page_obj); - addr = kmem_alloc_nofault(kernel_map, PAGE_SIZE); - pmap_qenter(addr, &m, 1); - shared_page_mapping = (char *)addr; -} - -SYSINIT(shp, SI_SUB_EXEC, SI_ORDER_FIRST, (sysinit_cfunc_t)shared_page_init, - NULL); - -static void -timehands_update(struct sysentvec *sv) -{ - struct vdso_timehands th; - struct vdso_timekeep *tk; - uint32_t enabled, idx; - - enabled = tc_fill_vdso_timehands(&th); - tk = (struct vdso_timekeep *)(shared_page_mapping + - sv->sv_timekeep_off); - idx = sv->sv_timekeep_curr; - atomic_store_rel_32(&tk->tk_th[idx].th_gen, 0); - if (++idx >= VDSO_TH_NUM) - idx = 0; - sv->sv_timekeep_curr = idx; - if (++sv->sv_timekeep_gen == 0) - sv->sv_timekeep_gen = 1; - th.th_gen = 0; - if (enabled) - tk->tk_th[idx] = th; - tk->tk_enabled = enabled; - atomic_store_rel_32(&tk->tk_th[idx].th_gen, sv->sv_timekeep_gen); - tk->tk_current = idx; -} - -#ifdef COMPAT_FREEBSD32 -static void -timehands_update32(struct sysentvec *sv) -{ - struct vdso_timekeep32 *tk; - struct vdso_timehands32 th; - uint32_t enabled, idx; - - enabled = tc_fill_vdso_timehands32(&th); - tk = (struct vdso_timekeep32 *)(shared_page_mapping + - sv->sv_timekeep_off); - idx = sv->sv_timekeep_curr; - atomic_store_rel_32(&tk->tk_th[idx].th_gen, 0); - if (++idx >= VDSO_TH_NUM) - idx = 0; - sv->sv_timekeep_curr = idx; - if (++sv->sv_timekeep_gen == 0) - sv->sv_timekeep_gen = 1; - th.th_gen = 0; - if (enabled) - tk->tk_th[idx] = th; - tk->tk_enabled = enabled; - atomic_store_rel_32(&tk->tk_th[idx].th_gen, sv->sv_timekeep_gen); - tk->tk_current = idx; -} -#endif - -/* - * This is hackish, but easiest way to avoid creating list structures - * that needs to be iterated over from the hardclock interrupt - * context. - */ -static struct sysentvec *host_sysentvec; -#ifdef COMPAT_FREEBSD32 -static struct sysentvec *compat32_sysentvec; -#endif - -void -timekeep_push_vdso(void) -{ - - if (host_sysentvec != NULL && host_sysentvec->sv_timekeep_base != 0) - timehands_update(host_sysentvec); -#ifdef COMPAT_FREEBSD32 - if (compat32_sysentvec != NULL && - compat32_sysentvec->sv_timekeep_base != 0) - timehands_update32(compat32_sysentvec); -#endif -} - -void -exec_sysvec_init(void *param) -{ - struct sysentvec *sv; - int tk_base; - uint32_t tk_ver; - - sv = (struct sysentvec *)param; - - if ((sv->sv_flags & SV_SHP) == 0) - return; - sv->sv_shared_page_obj = shared_page_obj; - sv->sv_sigcode_base = sv->sv_shared_page_base + - shared_page_fill(*(sv->sv_szsigcode), 16, sv->sv_sigcode); - if ((sv->sv_flags & SV_ABI_MASK) != SV_ABI_FREEBSD) - return; - tk_ver = VDSO_TK_VER_CURR; -#ifdef COMPAT_FREEBSD32 - if ((sv->sv_flags & SV_ILP32) != 0) { - tk_base = shared_page_alloc(sizeof(struct vdso_timekeep32) + - sizeof(struct vdso_timehands32) * VDSO_TH_NUM, 16); - KASSERT(tk_base != -1, ("tk_base -1 for 32bit")); - shared_page_write(tk_base + offsetof(struct vdso_timekeep32, - tk_ver), sizeof(uint32_t), &tk_ver); - KASSERT(compat32_sysentvec == 0, - ("Native compat32 already registered")); - compat32_sysentvec = sv; - } else { -#endif - tk_base = shared_page_alloc(sizeof(struct vdso_timekeep) + - sizeof(struct vdso_timehands) * VDSO_TH_NUM, 16); - KASSERT(tk_base != -1, ("tk_base -1 for native")); - shared_page_write(tk_base + offsetof(struct vdso_timekeep, - tk_ver), sizeof(uint32_t), &tk_ver); - KASSERT(host_sysentvec == 0, ("Native already registered")); - host_sysentvec = sv; -#ifdef COMPAT_FREEBSD32 - } -#endif - sv->sv_timekeep_base = sv->sv_shared_page_base + tk_base; - sv->sv_timekeep_off = tk_base; - timekeep_push_vdso(); -} Copied and modified: head/sys/kern/kern_sharedpage.c (from r237475, head/sys/kern/kern_exec.c) ============================================================================== --- head/sys/kern/kern_exec.c Sat Jun 23 09:50:41 2012 (r237475, copy source) +++ head/sys/kern/kern_sharedpage.c Sat Jun 23 10:15:23 2012 (r237477) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1993, David Greenman + * Copyright (c) 2010, 2012 Konstantin Belousov * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,1493 +27,28 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_capsicum.h" #include "opt_compat.h" -#include "opt_hwpmc_hooks.h" -#include "opt_kdtrace.h" -#include "opt_ktrace.h" #include "opt_vm.h" #include -#include #include -#include -#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include #include #include -#include -#include -#ifdef KTRACE -#include -#endif #include #include #include -#include -#include -#include #include +#include +#include #include +#include #include -#ifdef HWPMC_HOOKS -#include -#endif - -#include - -#include -#include - -#ifdef KDTRACE_HOOKS -#include -dtrace_execexit_func_t dtrace_fasttrap_exec; -#endif - -SDT_PROVIDER_DECLARE(proc); -SDT_PROBE_DEFINE(proc, kernel, , exec, exec); -SDT_PROBE_ARGTYPE(proc, kernel, , exec, 0, "char *"); -SDT_PROBE_DEFINE(proc, kernel, , exec_failure, exec-failure); -SDT_PROBE_ARGTYPE(proc, kernel, , exec_failure, 0, "int"); -SDT_PROBE_DEFINE(proc, kernel, , exec_success, exec-success); -SDT_PROBE_ARGTYPE(proc, kernel, , exec_success, 0, "char *"); - -MALLOC_DEFINE(M_PARGS, "proc-args", "Process arguments"); - -static int sysctl_kern_ps_strings(SYSCTL_HANDLER_ARGS); -static int sysctl_kern_usrstack(SYSCTL_HANDLER_ARGS); -static int sysctl_kern_stackprot(SYSCTL_HANDLER_ARGS); -static int do_execve(struct thread *td, struct image_args *args, - struct mac *mac_p); - -/* XXX This should be vm_size_t. */ -SYSCTL_PROC(_kern, KERN_PS_STRINGS, ps_strings, CTLTYPE_ULONG|CTLFLAG_RD, - NULL, 0, sysctl_kern_ps_strings, "LU", ""); - -/* XXX This should be vm_size_t. */ -SYSCTL_PROC(_kern, KERN_USRSTACK, usrstack, CTLTYPE_ULONG|CTLFLAG_RD| - CTLFLAG_CAPRD, NULL, 0, sysctl_kern_usrstack, "LU", ""); - -SYSCTL_PROC(_kern, OID_AUTO, stackprot, CTLTYPE_INT|CTLFLAG_RD, - NULL, 0, sysctl_kern_stackprot, "I", ""); - -u_long ps_arg_cache_limit = PAGE_SIZE / 16; -SYSCTL_ULONG(_kern, OID_AUTO, ps_arg_cache_limit, CTLFLAG_RW, - &ps_arg_cache_limit, 0, ""); - -static int map_at_zero = 0; -TUNABLE_INT("security.bsd.map_at_zero", &map_at_zero); -SYSCTL_INT(_security_bsd, OID_AUTO, map_at_zero, CTLFLAG_RW, &map_at_zero, 0, - "Permit processes to map an object at virtual address 0."); - -static int -sysctl_kern_ps_strings(SYSCTL_HANDLER_ARGS) -{ - struct proc *p; - int error; - - p = curproc; -#ifdef SCTL_MASK32 - if (req->flags & SCTL_MASK32) { - unsigned int val; - val = (unsigned int)p->p_sysent->sv_psstrings; - error = SYSCTL_OUT(req, &val, sizeof(val)); - } else -#endif - error = SYSCTL_OUT(req, &p->p_sysent->sv_psstrings, - sizeof(p->p_sysent->sv_psstrings)); - return error; -} - -static int -sysctl_kern_usrstack(SYSCTL_HANDLER_ARGS) -{ - struct proc *p; - int error; - - p = curproc; -#ifdef SCTL_MASK32 - if (req->flags & SCTL_MASK32) { - unsigned int val; - val = (unsigned int)p->p_sysent->sv_usrstack; - error = SYSCTL_OUT(req, &val, sizeof(val)); - } else -#endif - error = SYSCTL_OUT(req, &p->p_sysent->sv_usrstack, - sizeof(p->p_sysent->sv_usrstack)); - return error; -} - -static int -sysctl_kern_stackprot(SYSCTL_HANDLER_ARGS) -{ - struct proc *p; - - p = curproc; - return (SYSCTL_OUT(req, &p->p_sysent->sv_stackprot, - sizeof(p->p_sysent->sv_stackprot))); -} - -/* - * Each of the items is a pointer to a `const struct execsw', hence the - * double pointer here. - */ -static const struct execsw **execsw; - -#ifndef _SYS_SYSPROTO_H_ -struct execve_args { - char *fname; - char **argv; - char **envv; -}; -#endif - -int -sys_execve(td, uap) - struct thread *td; - struct execve_args /* { - char *fname; - char **argv; - char **envv; - } */ *uap; -{ - int error; - struct image_args args; - - error = exec_copyin_args(&args, uap->fname, UIO_USERSPACE, - uap->argv, uap->envv); - if (error == 0) - error = kern_execve(td, &args, NULL); - return (error); -} - -#ifndef _SYS_SYSPROTO_H_ -struct fexecve_args { - int fd; - char **argv; - char **envv; -} -#endif -int -sys_fexecve(struct thread *td, struct fexecve_args *uap) -{ - int error; - struct image_args args; - - error = exec_copyin_args(&args, NULL, UIO_SYSSPACE, - uap->argv, uap->envv); - if (error == 0) { - args.fd = uap->fd; - error = kern_execve(td, &args, NULL); - } - return (error); -} - -#ifndef _SYS_SYSPROTO_H_ -struct __mac_execve_args { - char *fname; - char **argv; - char **envv; - struct mac *mac_p; -}; -#endif - -int -sys___mac_execve(td, uap) - struct thread *td; - struct __mac_execve_args /* { - char *fname; - char **argv; - char **envv; - struct mac *mac_p; - } */ *uap; -{ -#ifdef MAC - int error; - struct image_args args; - - error = exec_copyin_args(&args, uap->fname, UIO_USERSPACE, - uap->argv, uap->envv); - if (error == 0) - error = kern_execve(td, &args, uap->mac_p); - return (error); -#else - return (ENOSYS); -#endif -} - -/* - * XXX: kern_execve has the astonishing property of not always returning to - * the caller. If sufficiently bad things happen during the call to - * do_execve(), it can end up calling exit1(); as a result, callers must - * avoid doing anything which they might need to undo (e.g., allocating - * memory). - */ -int -kern_execve(td, args, mac_p) - struct thread *td; - struct image_args *args; - struct mac *mac_p; -{ - struct proc *p = td->td_proc; - int error; - - AUDIT_ARG_ARGV(args->begin_argv, args->argc, - args->begin_envv - args->begin_argv); - AUDIT_ARG_ENVV(args->begin_envv, args->envc, - args->endp - args->begin_envv); - if (p->p_flag & P_HADTHREADS) { - PROC_LOCK(p); - if (thread_single(SINGLE_BOUNDARY)) { - PROC_UNLOCK(p); - exec_free_args(args); - return (ERESTART); /* Try again later. */ - } - PROC_UNLOCK(p); - } - - error = do_execve(td, args, mac_p); - - if (p->p_flag & P_HADTHREADS) { - PROC_LOCK(p); - /* - * If success, we upgrade to SINGLE_EXIT state to - * force other threads to suicide. - */ - if (error == 0) - thread_single(SINGLE_EXIT); - else - thread_single_end(); - PROC_UNLOCK(p); - } - - return (error); -} - -/* - * In-kernel implementation of execve(). All arguments are assumed to be - * userspace pointers from the passed thread. - */ -static int -do_execve(td, args, mac_p) - struct thread *td; - struct image_args *args; - struct mac *mac_p; -{ - struct proc *p = td->td_proc; - struct nameidata nd; - struct ucred *newcred = NULL, *oldcred; - struct uidinfo *euip; - register_t *stack_base; - int error, i; - struct image_params image_params, *imgp; - struct vattr attr; - int (*img_first)(struct image_params *); - struct pargs *oldargs = NULL, *newargs = NULL; - struct sigacts *oldsigacts, *newsigacts; -#ifdef KTRACE - struct vnode *tracevp = NULL; - struct ucred *tracecred = NULL; -#endif - struct vnode *textvp = NULL, *binvp = NULL; - int credential_changing; - int vfslocked; - int textset; -#ifdef MAC - struct label *interpvplabel = NULL; - int will_transition; -#endif -#ifdef HWPMC_HOOKS - struct pmckern_procexec pe; -#endif - static const char fexecv_proc_title[] = "(fexecv)"; - - vfslocked = 0; - imgp = &image_params; - - /* - * Lock the process and set the P_INEXEC flag to indicate that - * it should be left alone until we're done here. This is - * necessary to avoid race conditions - e.g. in ptrace() - - * that might allow a local user to illicitly obtain elevated - * privileges. - */ - PROC_LOCK(p); - KASSERT((p->p_flag & P_INEXEC) == 0, - ("%s(): process already has P_INEXEC flag", __func__)); - p->p_flag |= P_INEXEC; - PROC_UNLOCK(p); - - /* - * Initialize part of the common data - */ - imgp->proc = p; - imgp->execlabel = NULL; - imgp->attr = &attr; - imgp->entry_addr = 0; - imgp->reloc_base = 0; - imgp->vmspace_destroyed = 0; - imgp->interpreted = 0; - imgp->opened = 0; - imgp->interpreter_name = NULL; - imgp->auxargs = NULL; - imgp->vp = NULL; - imgp->object = NULL; - imgp->firstpage = NULL; - imgp->ps_strings = 0; - imgp->auxarg_size = 0; - imgp->args = args; - imgp->execpath = imgp->freepath = NULL; - imgp->execpathp = 0; - imgp->canary = 0; - imgp->canarylen = 0; - imgp->pagesizes = 0; - imgp->pagesizeslen = 0; - imgp->stack_prot = 0; - -#ifdef MAC - error = mac_execve_enter(imgp, mac_p); - if (error) - goto exec_fail; -#endif - - imgp->image_header = NULL; - - /* - * Translate the file name. namei() returns a vnode pointer - * in ni_vp amoung other things. - * - * XXXAUDIT: It would be desirable to also audit the name of the - * interpreter if this is an interpreted binary. - */ - if (args->fname != NULL) { - NDINIT(&nd, LOOKUP, ISOPEN | LOCKLEAF | FOLLOW | SAVENAME - | MPSAFE | AUDITVNODE1, UIO_SYSSPACE, args->fname, td); - } - - SDT_PROBE(proc, kernel, , exec, args->fname, 0, 0, 0, 0 ); - -interpret: - if (args->fname != NULL) { -#ifdef CAPABILITY_MODE - /* - * While capability mode can't reach this point via direct - * path arguments to execve(), we also don't allow - * interpreters to be used in capability mode (for now). - * Catch indirect lookups and return a permissions error. - */ - if (IN_CAPABILITY_MODE(td)) { - error = ECAPMODE; - goto exec_fail; - } -#endif - error = namei(&nd); - if (error) - goto exec_fail; - - vfslocked = NDHASGIANT(&nd); - binvp = nd.ni_vp; - imgp->vp = binvp; - } else { - AUDIT_ARG_FD(args->fd); - /* - * Some might argue that CAP_READ and/or CAP_MMAP should also - * be required here; such arguments will be entertained. - */ - error = fgetvp_read(td, args->fd, CAP_FEXECVE, &binvp); - if (error) - goto exec_fail; - vfslocked = VFS_LOCK_GIANT(binvp->v_mount); - vn_lock(binvp, LK_EXCLUSIVE | LK_RETRY); - AUDIT_ARG_VNODE1(binvp); - imgp->vp = binvp; - } - - /* - * Check file permissions (also 'opens' file) - */ - error = exec_check_permissions(imgp); - if (error) - goto exec_fail_dealloc; - - imgp->object = imgp->vp->v_object; - if (imgp->object != NULL) - vm_object_reference(imgp->object); - - /* - * Set VV_TEXT now so no one can write to the executable while we're - * activating it. - * - * Remember if this was set before and unset it in case this is not - * actually an executable image. - */ - textset = imgp->vp->v_vflag & VV_TEXT; - ASSERT_VOP_ELOCKED(imgp->vp, "vv_text"); - imgp->vp->v_vflag |= VV_TEXT; - - error = exec_map_first_page(imgp); - if (error) - goto exec_fail_dealloc; - - imgp->proc->p_osrel = 0; - /* - * If the current process has a special image activator it - * wants to try first, call it. For example, emulating shell - * scripts differently. - */ - error = -1; - if ((img_first = imgp->proc->p_sysent->sv_imgact_try) != NULL) - error = img_first(imgp); - - /* - * Loop through the list of image activators, calling each one. - * An activator returns -1 if there is no match, 0 on success, - * and an error otherwise. - */ - for (i = 0; error == -1 && execsw[i]; ++i) { - if (execsw[i]->ex_imgact == NULL || - execsw[i]->ex_imgact == img_first) { - continue; - } - error = (*execsw[i]->ex_imgact)(imgp); - } - - if (error) { - if (error == -1) { - if (textset == 0) { - ASSERT_VOP_ELOCKED(imgp->vp, "vv_text"); - imgp->vp->v_vflag &= ~VV_TEXT; - } - error = ENOEXEC; - } - goto exec_fail_dealloc; - } - - /* - * Special interpreter operation, cleanup and loop up to try to - * activate the interpreter. - */ - if (imgp->interpreted) { - exec_unmap_first_page(imgp); - /* - * VV_TEXT needs to be unset for scripts. There is a short - * period before we determine that something is a script where - * VV_TEXT will be set. The vnode lock is held over this - * entire period so nothing should illegitimately be blocked. - */ - imgp->vp->v_vflag &= ~VV_TEXT; - /* free name buffer and old vnode */ - if (args->fname != NULL) - NDFREE(&nd, NDF_ONLY_PNBUF); -#ifdef MAC - mac_execve_interpreter_enter(binvp, &interpvplabel); -#endif - if (imgp->opened) { - VOP_CLOSE(binvp, FREAD, td->td_ucred, td); - imgp->opened = 0; - } - vput(binvp); - vm_object_deallocate(imgp->object); - imgp->object = NULL; - VFS_UNLOCK_GIANT(vfslocked); - vfslocked = 0; - /* set new name to that of the interpreter */ - NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME | MPSAFE, - UIO_SYSSPACE, imgp->interpreter_name, td); - args->fname = imgp->interpreter_name; - goto interpret; - } - - /* - * NB: We unlock the vnode here because it is believed that none - * of the sv_copyout_strings/sv_fixup operations require the vnode. - */ - VOP_UNLOCK(imgp->vp, 0); - - /* - * Do the best to calculate the full path to the image file. - */ - if (imgp->auxargs != NULL && - ((args->fname != NULL && args->fname[0] == '/') || - vn_fullpath(td, imgp->vp, &imgp->execpath, &imgp->freepath) != 0)) - imgp->execpath = args->fname; - - /* - * Copy out strings (args and env) and initialize stack base - */ - if (p->p_sysent->sv_copyout_strings) - stack_base = (*p->p_sysent->sv_copyout_strings)(imgp); - else - stack_base = exec_copyout_strings(imgp); - - /* - * If custom stack fixup routine present for this process - * let it do the stack setup. - * Else stuff argument count as first item on stack - */ - if (p->p_sysent->sv_fixup != NULL) - (*p->p_sysent->sv_fixup)(&stack_base, imgp); - else - suword(--stack_base, imgp->args->argc); - - /* - * For security and other reasons, the file descriptor table cannot - * be shared after an exec. - */ - fdunshare(p, td); - - /* - * Malloc things before we need locks. - */ - newcred = crget(); - euip = uifind(attr.va_uid); - i = imgp->args->begin_envv - imgp->args->begin_argv; - /* Cache arguments if they fit inside our allowance */ - if (ps_arg_cache_limit >= i + sizeof(struct pargs)) { - newargs = pargs_alloc(i); - bcopy(imgp->args->begin_argv, newargs->ar_args, i); - } - - /* close files on exec */ - fdcloseexec(td); - vn_lock(imgp->vp, LK_SHARED | LK_RETRY); - - /* Get a reference to the vnode prior to locking the proc */ - VREF(binvp); - - /* - * For security and other reasons, signal handlers cannot - * be shared after an exec. The new process gets a copy of the old - * handlers. In execsigs(), the new process will have its signals - * reset. - */ - PROC_LOCK(p); - oldcred = crcopysafe(p, newcred); - if (sigacts_shared(p->p_sigacts)) { - oldsigacts = p->p_sigacts; - PROC_UNLOCK(p); - newsigacts = sigacts_alloc(); - sigacts_copy(newsigacts, oldsigacts); - PROC_LOCK(p); - p->p_sigacts = newsigacts; - } else - oldsigacts = NULL; - - /* Stop profiling */ - stopprofclock(p); - - /* reset caught signals */ - execsigs(p); - - /* name this process - nameiexec(p, ndp) */ - bzero(p->p_comm, sizeof(p->p_comm)); - if (args->fname) - bcopy(nd.ni_cnd.cn_nameptr, p->p_comm, - min(nd.ni_cnd.cn_namelen, MAXCOMLEN)); - else if (vn_commname(binvp, p->p_comm, sizeof(p->p_comm)) != 0) - bcopy(fexecv_proc_title, p->p_comm, sizeof(fexecv_proc_title)); - bcopy(p->p_comm, td->td_name, sizeof(td->td_name)); -#ifdef KTR - sched_clear_tdname(td); -#endif - - /* - * mark as execed, wakeup the process that vforked (if any) and tell - * it that it now has its own resources back - */ - p->p_flag |= P_EXEC; - if (p->p_pptr && (p->p_flag & P_PPWAIT)) { - p->p_flag &= ~P_PPWAIT; - cv_broadcast(&p->p_pwait); - } - - /* - * Implement image setuid/setgid. - * - * Don't honor setuid/setgid if the filesystem prohibits it or if - * the process is being traced. - * - * We disable setuid/setgid/etc in compatibility mode on the basis - * that most setugid applications are not written with that - * environment in mind, and will therefore almost certainly operate - * incorrectly. In principle there's no reason that setugid - * applications might not be useful in capability mode, so we may want - * to reconsider this conservative design choice in the future. - * - * XXXMAC: For the time being, use NOSUID to also prohibit - * transitions on the file system. - */ - credential_changing = 0; - credential_changing |= (attr.va_mode & S_ISUID) && oldcred->cr_uid != - attr.va_uid; - credential_changing |= (attr.va_mode & S_ISGID) && oldcred->cr_gid != - attr.va_gid; -#ifdef MAC - will_transition = mac_vnode_execve_will_transition(oldcred, imgp->vp, - interpvplabel, imgp); - credential_changing |= will_transition; -#endif - - if (credential_changing && -#ifdef CAPABILITY_MODE - ((oldcred->cr_flags & CRED_FLAG_CAPMODE) == 0) && -#endif - (imgp->vp->v_mount->mnt_flag & MNT_NOSUID) == 0 && - (p->p_flag & P_TRACED) == 0) { - /* - * Turn off syscall tracing for set-id programs, except for - * root. Record any set-id flags first to make sure that - * we do not regain any tracing during a possible block. - */ - setsugid(p); - -#ifdef KTRACE - if (priv_check_cred(oldcred, PRIV_DEBUG_DIFFCRED, 0)) - ktrprocexec(p, &tracecred, &tracevp); -#endif - /* - * Close any file descriptors 0..2 that reference procfs, - * then make sure file descriptors 0..2 are in use. - * - * setugidsafety() may call closef() and then pfind() - * which may grab the process lock. - * fdcheckstd() may call falloc() which may block to - * allocate memory, so temporarily drop the process lock. - */ - PROC_UNLOCK(p); - VOP_UNLOCK(imgp->vp, 0); - setugidsafety(td); - error = fdcheckstd(td); - vn_lock(imgp->vp, LK_SHARED | LK_RETRY); - if (error != 0) - goto done1; - PROC_LOCK(p); - /* - * Set the new credentials. - */ - if (attr.va_mode & S_ISUID) - change_euid(newcred, euip); - if (attr.va_mode & S_ISGID) - change_egid(newcred, attr.va_gid); -#ifdef MAC - if (will_transition) { - mac_vnode_execve_transition(oldcred, newcred, imgp->vp, - interpvplabel, imgp); - } -#endif - /* - * Implement correct POSIX saved-id behavior. - * - * XXXMAC: Note that the current logic will save the - * uid and gid if a MAC domain transition occurs, even - * though maybe it shouldn't. - */ - change_svuid(newcred, newcred->cr_uid); - change_svgid(newcred, newcred->cr_gid); - p->p_ucred = newcred; - newcred = NULL; - } else { - if (oldcred->cr_uid == oldcred->cr_ruid && - oldcred->cr_gid == oldcred->cr_rgid) - p->p_flag &= ~P_SUGID; - /* - * Implement correct POSIX saved-id behavior. - * - * XXX: It's not clear that the existing behavior is - * POSIX-compliant. A number of sources indicate that the - * saved uid/gid should only be updated if the new ruid is - * not equal to the old ruid, or the new euid is not equal - * to the old euid and the new euid is not equal to the old - * ruid. The FreeBSD code always updates the saved uid/gid. - * Also, this code uses the new (replaced) euid and egid as - * the source, which may or may not be the right ones to use. - */ - if (oldcred->cr_svuid != oldcred->cr_uid || - oldcred->cr_svgid != oldcred->cr_gid) { - change_svuid(newcred, newcred->cr_uid); - change_svgid(newcred, newcred->cr_gid); - p->p_ucred = newcred; - newcred = NULL; - } - } - - /* - * Store the vp for use in procfs. This vnode was referenced prior - * to locking the proc lock. - */ - textvp = p->p_textvp; - p->p_textvp = binvp; - -#ifdef KDTRACE_HOOKS - /* - * Tell the DTrace fasttrap provider about the exec if it - * has declared an interest. - */ - if (dtrace_fasttrap_exec) - dtrace_fasttrap_exec(p); -#endif - - /* - * Notify others that we exec'd, and clear the P_INEXEC flag - * as we're now a bona fide freshly-execed process. - */ - KNOTE_LOCKED(&p->p_klist, NOTE_EXEC); - p->p_flag &= ~P_INEXEC; - - /* clear "fork but no exec" flag, as we _are_ execing */ - p->p_acflag &= ~AFORK; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 12:32:54 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 39C30106566B; Sat, 23 Jun 2012 12:32:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1E5D78FC19; Sat, 23 Jun 2012 12:32:54 +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 q5NCWrgo040973; Sat, 23 Jun 2012 12:32:53 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5NCWrc5040967; Sat, 23 Jun 2012 12:32:53 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206231232.q5NCWrc5040967@svn.freebsd.org> From: Alexander Motin Date: Sat, 23 Jun 2012 12:32:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237478 - in head/sys/cam: . scsi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 12:32:54 -0000 Author: mav Date: Sat Jun 23 12:32:53 2012 New Revision: 237478 URL: http://svn.freebsd.org/changeset/base/237478 Log: Add scsi_extract_sense_ccb() -- wrapper around scsi_extract_sense_len(). It allows to remove number of duplicate checks from several places. Modified: head/sys/cam/cam_periph.c head/sys/cam/scsi/scsi_all.c head/sys/cam/scsi/scsi_all.h head/sys/cam/scsi/scsi_cd.c head/sys/cam/scsi/scsi_da.c Modified: head/sys/cam/cam_periph.c ============================================================================== --- head/sys/cam/cam_periph.c Sat Jun 23 10:15:23 2012 (r237477) +++ head/sys/cam/cam_periph.c Sat Jun 23 12:32:53 2012 (r237478) @@ -1147,22 +1147,15 @@ camperiphdone(struct cam_periph *periph, union ccb *saved_ccb; cam_status status; struct scsi_start_stop_unit *scsi_cmd; + int error_code, sense_key, asc, ascq; scsi_cmd = (struct scsi_start_stop_unit *) &done_ccb->csio.cdb_io.cdb_bytes; status = done_ccb->ccb_h.status; if ((status & CAM_STATUS_MASK) != CAM_REQ_CMP) { - if ((status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR && - (status & CAM_AUTOSNS_VALID)) { - struct scsi_sense_data *sense; - int error_code, sense_key, asc, ascq, sense_len; - - sense = &done_ccb->csio.sense_data; - sense_len = done_ccb->csio.sense_len - - done_ccb->csio.sense_resid; - scsi_extract_sense_len(sense, sense_len, &error_code, - &sense_key, &asc, &ascq, /*show_errors*/ 1); + if (scsi_extract_sense_ccb(done_ccb, + &error_code, &sense_key, &asc, &ascq)) { /* * If the error is "invalid field in CDB", * and the load/eject flag is set, turn the @@ -1421,12 +1414,8 @@ camperiphscsisenseerror(union ccb *ccb, cgd.ccb_h.func_code = XPT_GDEV_TYPE; xpt_action((union ccb *)&cgd); - if ((ccb->ccb_h.status & CAM_AUTOSNS_VALID) != 0) - err_action = scsi_error_action(&ccb->csio, - &cgd.inq_data, - sense_flags); - else - err_action = SS_RETRY|SSQ_DECREMENT_COUNT|EIO; + err_action = scsi_error_action(&ccb->csio, &cgd.inq_data, + sense_flags); error = err_action & SS_ERRMASK; /* Modified: head/sys/cam/scsi/scsi_all.c ============================================================================== --- head/sys/cam/scsi/scsi_all.c Sat Jun 23 10:15:23 2012 (r237477) +++ head/sys/cam/scsi/scsi_all.c Sat Jun 23 12:32:53 2012 (r237478) @@ -2834,11 +2834,10 @@ scsi_error_action(struct ccb_scsiio *csi int error_code, sense_key, asc, ascq; scsi_sense_action action; - scsi_extract_sense_len(&csio->sense_data, csio->sense_len - - csio->sense_resid, &error_code, - &sense_key, &asc, &ascq, /*show_errors*/ 1); - - if ((error_code == SSD_DEFERRED_ERROR) + if (!scsi_extract_sense_ccb((union ccb *)csio, + &error_code, &sense_key, &asc, &ascq)) { + action = SS_RETRY | SSQ_DECREMENT_COUNT | SSQ_PRINT_SENSE | EIO; + } else if ((error_code == SSD_DEFERRED_ERROR) || (error_code == SSD_DESC_DEFERRED_ERROR)) { /* * XXX dufault@FreeBSD.org @@ -4622,6 +4621,36 @@ scsi_extract_sense(struct scsi_sense_dat } /* + * Extract basic sense information from SCSI I/O CCB structure. + */ +int +scsi_extract_sense_ccb(union ccb *ccb, + int *error_code, int *sense_key, int *asc, int *ascq) +{ + struct scsi_sense_data *sense_data; + + /* Make sure there are some sense data we can access. */ + if (ccb->ccb_h.func_code != XPT_SCSI_IO || + (ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_SCSI_STATUS_ERROR || + (ccb->csio.scsi_status != SCSI_STATUS_CHECK_COND) || + (ccb->ccb_h.status & CAM_AUTOSNS_VALID) == 0 || + (ccb->ccb_h.flags & CAM_SENSE_PHYS)) + return (0); + + if (ccb->ccb_h.flags & CAM_SENSE_PTR) + bcopy(&ccb->csio.sense_data, &sense_data, + sizeof(struct scsi_sense_data *)); + else + sense_data = &ccb->csio.sense_data; + scsi_extract_sense_len(sense_data, + ccb->csio.sense_len - ccb->csio.sense_resid, + error_code, sense_key, asc, ascq, 1); + if (*error_code == -1) + return (0); + return (1); +} + +/* * Extract basic sense information. If show_errors is set, sense values * will be set to -1 if they are not present. */ Modified: head/sys/cam/scsi/scsi_all.h ============================================================================== --- head/sys/cam/scsi/scsi_all.h Sat Jun 23 10:15:23 2012 (r237477) +++ head/sys/cam/scsi/scsi_all.h Sat Jun 23 12:32:53 2012 (r237478) @@ -2388,6 +2388,8 @@ int scsi_devid_match(uint8_t *rhs, size void scsi_extract_sense(struct scsi_sense_data *sense, int *error_code, int *sense_key, int *asc, int *ascq); +int scsi_extract_sense_ccb(union ccb *ccb, int *error_code, int *sense_key, + int *asc, int *ascq); void scsi_extract_sense_len(struct scsi_sense_data *sense, u_int sense_len, int *error_code, int *sense_key, int *asc, int *ascq, int show_errors); Modified: head/sys/cam/scsi/scsi_cd.c ============================================================================== --- head/sys/cam/scsi/scsi_cd.c Sat Jun 23 10:15:23 2012 (r237477) +++ head/sys/cam/scsi/scsi_cd.c Sat Jun 23 12:32:53 2012 (r237478) @@ -1676,7 +1676,6 @@ cddone(struct cam_periph *periph, union return; } else if (error != 0) { - struct scsi_sense_data *sense; int asc, ascq; int sense_key, error_code; int have_sense; @@ -1699,20 +1698,12 @@ cddone(struct cam_periph *periph, union cgd.ccb_h.func_code = XPT_GDEV_TYPE; xpt_action((union ccb *)&cgd); - if (((csio->ccb_h.flags & CAM_SENSE_PHYS) != 0) - || ((csio->ccb_h.flags & CAM_SENSE_PTR) != 0) - || ((status & CAM_AUTOSNS_VALID) == 0)) - have_sense = FALSE; - else + if (scsi_extract_sense_ccb(done_ccb, + &error_code, &sense_key, &asc, &ascq)) have_sense = TRUE; + else + have_sense = FALSE; - if (have_sense) { - sense = &csio->sense_data; - scsi_extract_sense_len(sense, - csio->sense_len - csio->sense_resid, - &error_code, &sense_key, &asc, - &ascq, /*show_errors*/ 1); - } /* * Attach to anything that claims to be a * CDROM or WORM device, as long as it @@ -3138,7 +3129,7 @@ cderror(union ccb *ccb, u_int32_t cam_fl { struct cd_softc *softc; struct cam_periph *periph; - int error; + int error, error_code, sense_key, asc, ascq; periph = xpt_path_periph(ccb->ccb_h.path); softc = (struct cd_softc *)periph->softc; @@ -3152,19 +3143,10 @@ cderror(union ccb *ccb, u_int32_t cam_fl */ if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INVALID) { error = cd6byteworkaround(ccb); - } else if (((ccb->ccb_h.status & CAM_STATUS_MASK) == - CAM_SCSI_STATUS_ERROR) - && (ccb->ccb_h.status & CAM_AUTOSNS_VALID) - && (ccb->csio.scsi_status == SCSI_STATUS_CHECK_COND) - && ((ccb->ccb_h.flags & CAM_SENSE_PHYS) == 0) - && ((ccb->ccb_h.flags & CAM_SENSE_PTR) == 0)) { - int sense_key, error_code, asc, ascq; - - scsi_extract_sense_len(&ccb->csio.sense_data, - ccb->csio.sense_len - ccb->csio.sense_resid, &error_code, - &sense_key, &asc, &ascq, /*show_errors*/ 1); + } else if (scsi_extract_sense_ccb(ccb, + &error_code, &sense_key, &asc, &ascq)) { if (sense_key == SSD_KEY_ILLEGAL_REQUEST) - error = cd6byteworkaround(ccb); + error = cd6byteworkaround(ccb); } if (error == ERESTART) Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Sat Jun 23 10:15:23 2012 (r237477) +++ head/sys/cam/scsi/scsi_da.c Sat Jun 23 12:32:53 2012 (r237478) @@ -2254,7 +2254,6 @@ dadone(struct cam_periph *periph, union */ return; } else if (error != 0) { - struct scsi_sense_data *sense; int asc, ascq; int sense_key, error_code; int have_sense; @@ -2277,20 +2276,12 @@ dadone(struct cam_periph *periph, union cgd.ccb_h.func_code = XPT_GDEV_TYPE; xpt_action((union ccb *)&cgd); - if (((csio->ccb_h.flags & CAM_SENSE_PHYS) != 0) - || ((csio->ccb_h.flags & CAM_SENSE_PTR) != 0) - || ((status & CAM_AUTOSNS_VALID) == 0)) - have_sense = FALSE; - else + if (scsi_extract_sense_ccb(done_ccb, + &error_code, &sense_key, &asc, &ascq)) have_sense = TRUE; + else + have_sense = FALSE; - if (have_sense) { - sense = &csio->sense_data; - scsi_extract_sense_len(sense, - csio->sense_len - csio->sense_resid, - &error_code, &sense_key, &asc, - &ascq, /*show_errors*/ 1); - } /* * If we tried READ CAPACITY(16) and failed, * fallback to READ CAPACITY(10). @@ -2428,7 +2419,7 @@ daerror(union ccb *ccb, u_int32_t cam_fl { struct da_softc *softc; struct cam_periph *periph; - int error; + int error, error_code, sense_key, asc, ascq; periph = xpt_path_periph(ccb->ccb_h.path); softc = (struct da_softc *)periph->softc; @@ -2440,16 +2431,8 @@ daerror(union ccb *ccb, u_int32_t cam_fl error = 0; if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INVALID) { error = cmd6workaround(ccb); - } else if (((ccb->ccb_h.status & CAM_STATUS_MASK) == - CAM_SCSI_STATUS_ERROR) - && (ccb->ccb_h.status & CAM_AUTOSNS_VALID) - && (ccb->csio.scsi_status == SCSI_STATUS_CHECK_COND) - && ((ccb->ccb_h.flags & CAM_SENSE_PHYS) == 0) - && ((ccb->ccb_h.flags & CAM_SENSE_PTR) == 0)) { - int sense_key, error_code, asc, ascq; - - scsi_extract_sense(&ccb->csio.sense_data, - &error_code, &sense_key, &asc, &ascq); + } else if (scsi_extract_sense_ccb(ccb, + &error_code, &sense_key, &asc, &ascq)) { if (sense_key == SSD_KEY_ILLEGAL_REQUEST) error = cmd6workaround(ccb); /* From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 12:40:25 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 47C4E106564A; Sat, 23 Jun 2012 12:40:25 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1E96F8FC0A; Sat, 23 Jun 2012 12:40:25 +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 q5NCeO1t041305; Sat, 23 Jun 2012 12:40:24 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5NCeOQB041303; Sat, 23 Jun 2012 12:40:24 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201206231240.q5NCeOQB041303@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Sat, 23 Jun 2012 12:40:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237479 - head/sys/netinet/ipfw X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 12:40:25 -0000 Author: melifaro Date: Sat Jun 23 12:40:24 2012 New Revision: 237479 URL: http://svn.freebsd.org/changeset/base/237479 Log: Fix interface matching by ipfw table Submitted by: Ihor Kaharlichenko Tested by: Ihor Kaharlichenko Approved by: kib(mentor) MFC after: 3 days Modified: head/sys/netinet/ipfw/ip_fw_table.c Modified: head/sys/netinet/ipfw/ip_fw_table.c ============================================================================== --- head/sys/netinet/ipfw/ip_fw_table.c Sat Jun 23 12:32:53 2012 (r237478) +++ head/sys/netinet/ipfw/ip_fw_table.c Sat Jun 23 12:40:24 2012 (r237479) @@ -568,7 +568,8 @@ ipfw_lookup_table_extended(struct ip_fw_ break; case IPFW_TABLE_INTERFACE: - KEY_LEN(iface) = strlcpy(iface.ifname, (char *)paddr, IF_NAMESIZE); + KEY_LEN(iface) = KEY_LEN_IFACE + + strlcpy(iface.ifname, (char *)paddr, IF_NAMESIZE); /* Assume direct match */ /* FIXME: Add interface pattern matching */ xent = (struct table_xentry *)(rnh->rnh_lookup(&iface, NULL, rnh)); From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 13:18:05 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7C56E106564A; Sat, 23 Jun 2012 13:18:05 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 1ECE68FC08; Sat, 23 Jun 2012 13:18:04 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.4/8.14.4/ALCHEMY.FRANKEN.DE) with ESMTP id q5NDHvGq042912; Sat, 23 Jun 2012 15:17:57 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.4/8.14.4/Submit) id q5NDHvLf042911; Sat, 23 Jun 2012 15:17:57 +0200 (CEST) (envelope-from marius) Date: Sat, 23 Jun 2012 15:17:57 +0200 From: Marius Strobl To: Konstantin Belousov Message-ID: <20120623131757.GB46065@alchemy.franken.de> References: <201206220713.q5M7DVH0063098@svn.freebsd.org> <20120622073455.GE69382@alchemy.franken.de> <20120622074817.GA2337@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120622074817.GA2337@deviant.kiev.zoral.com.ua> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 13:18:05 -0000 On Fri, Jun 22, 2012 at 10:48:17AM +0300, Konstantin Belousov wrote: > On Fri, Jun 22, 2012 at 09:34:56AM +0200, Marius Strobl wrote: > > On Fri, Jun 22, 2012 at 07:13:31AM +0000, Konstantin Belousov wrote: > > > Author: kib > > > Date: Fri Jun 22 07:13:30 2012 > > > New Revision: 237434 > > > URL: http://svn.freebsd.org/changeset/base/237434 > > > > > > Log: > > > Use struct vdso_timehands data to implement fast gettimeofday(2) and > > > clock_gettime(2) functions if supported. The speedup seen in > > > microbenchmarks is in range 4x-7x depending on the hardware. > > > > > > Only amd64 and i386 architectures are supported. Libc uses rdtsc and > > > kernel data to calculate current time, if enabled by kernel. > > > > I don't know much about x86 CPUs but is my understanding correct > > that TSCs are not synchronized in any way across CPUs, i.e. > > reading it on different CPUs may result in time going backwards > > etc., which is okay for this application though? > > Generally speaking, tsc state among different CPU after boot is not > synchronized, you are right. > > Kernel has somewhat doubtful test which verifies whether the after-boot > state of tsc looks good. If the test fails, TSC is not enabled by > default as timecounter, and then usermode follows kernel policy and > falls back to slow syscall. So we err on the safe side. > I tested this on Core i7 2xxx, where the test (usually) passes. Okay, so for x86 the TSCs are not used as timecounters by either the kernel or userland in the SMP case if they don't appear to be synchronized, correct? > > While you are there. do you have comments about sparc64 TICK counter ? > On SMP, the counter of BSP is used by IPI. Is it unavoidable ? The TICK counters are per-core and not synchronized by the hardware. We synchronize APs with the BSP on bring-up but they drift over time and the initial synchronization might not be perfect in the first place. At least in the past, drifting TICK counters caused all sorts of issues and strange behavior in FreeBSD when used as timecounter in the SMP case. If my understanding of the above is right, as is this still rules them out as timecounters for userland. Linux has some complex code (based on equivalent code origining in their ia64 port) for constantly synchronizing the TICK counters. In order to avoid that complexity and overhead, what I do in FreeBSD in the SMP case is to (ab)use counters (either intended for that purpose or bus cycle counters probably intended for debugging the hardware during development) available in the various host-to-foo bridges so it doesn't matter which CPU they are read by. This works just fine except for pre-PCI-Express based USIIIi machines, where the bus cycle counters are broken. That's where the TICK counter is always read from the BSP using an IPI in the SMP case. The latter is done as sched_bind(9) isn't possible with td_critnest > 1 according to information from jhb@ and mav@. So apart from introducing code to constantly synchronize the TICK counters, using the timecounters on the host busses also seems to be the only viable solution for userland. The latter should be doable but is long-winded as besides duplicating portions of the corresponding device drivers in userland, it probably also means to get some additional infrastructure like being able to memory map registers for devices on the nexus(4) level in place ... Marius From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 13:52:45 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B0A8C106564A; Sat, 23 Jun 2012 13:52:45 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9B1868FC0C; Sat, 23 Jun 2012 13:52:45 +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 q5NDqjch044371; Sat, 23 Jun 2012 13:52:45 GMT (envelope-from jhibbits@svn.freebsd.org) Received: (from jhibbits@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5NDqjbp044369; Sat, 23 Jun 2012 13:52:45 GMT (envelope-from jhibbits@svn.freebsd.org) Message-Id: <201206231352.q5NDqjbp044369@svn.freebsd.org> From: Justin Hibbits Date: Sat, 23 Jun 2012 13:52:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237480 - head/sys/dev/adb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 13:52:45 -0000 Author: jhibbits Date: Sat Jun 23 13:52:44 2012 New Revision: 237480 URL: http://svn.freebsd.org/changeset/base/237480 Log: Release the ADB keyboard mutex when handling the power button press/release. Found by WITNESS. Approved by: nwhitehorn (mentor) MFC after: 3 days Modified: head/sys/dev/adb/adb_kbd.c Modified: head/sys/dev/adb/adb_kbd.c ============================================================================== --- head/sys/dev/adb/adb_kbd.c Sat Jun 23 12:40:24 2012 (r237479) +++ head/sys/dev/adb/adb_kbd.c Sat Jun 23 13:52:44 2012 (r237480) @@ -426,8 +426,10 @@ adb_kbd_receive_packet(device_t dev, u_c /* 0x7f is always the power button */ if (data[0] == 0x7f && devctl_process_running()) { devctl_notify("PMU", "Button", "pressed", NULL); + mtx_unlock(&sc->sc_mutex); return (0); } else if (data[0] == 0xff) { + mtx_unlock(&sc->sc_mutex); return (0); /* Ignore power button release. */ } if ((data[0] & 0x7f) == 57 && sc->buffers < 7) { From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 14:06:02 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A96A2106566B; Sat, 23 Jun 2012 14:06:02 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 3EFA48FC1E; Sat, 23 Jun 2012 14:06:02 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q5NE5u5x076827; Sat, 23 Jun 2012 17:05:56 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q5NE5uWm063779; Sat, 23 Jun 2012 17:05:56 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q5NE5uFC063778; Sat, 23 Jun 2012 17:05:56 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 23 Jun 2012 17:05:56 +0300 From: Konstantin Belousov To: Marius Strobl Message-ID: <20120623140556.GU2337@deviant.kiev.zoral.com.ua> References: <201206220713.q5M7DVH0063098@svn.freebsd.org> <20120622073455.GE69382@alchemy.franken.de> <20120622074817.GA2337@deviant.kiev.zoral.com.ua> <20120623131757.GB46065@alchemy.franken.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="x5H/dHEtcMgsAT6y" Content-Disposition: inline In-Reply-To: <20120623131757.GB46065@alchemy.franken.de> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 14:06:02 -0000 --x5H/dHEtcMgsAT6y Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jun 23, 2012 at 03:17:57PM +0200, Marius Strobl wrote: > On Fri, Jun 22, 2012 at 10:48:17AM +0300, Konstantin Belousov wrote: > > On Fri, Jun 22, 2012 at 09:34:56AM +0200, Marius Strobl wrote: > > > On Fri, Jun 22, 2012 at 07:13:31AM +0000, Konstantin Belousov wrote: > > > > Author: kib > > > > Date: Fri Jun 22 07:13:30 2012 > > > > New Revision: 237434 > > > > URL: http://svn.freebsd.org/changeset/base/237434 > > > >=20 > > > > Log: > > > > Use struct vdso_timehands data to implement fast gettimeofday(2) = and > > > > clock_gettime(2) functions if supported. The speedup seen in > > > > microbenchmarks is in range 4x-7x depending on the hardware. > > > > =20 > > > > Only amd64 and i386 architectures are supported. Libc uses rdtsc = and > > > > kernel data to calculate current time, if enabled by kernel. > > >=20 > > > I don't know much about x86 CPUs but is my understanding correct > > > that TSCs are not synchronized in any way across CPUs, i.e. > > > reading it on different CPUs may result in time going backwards > > > etc., which is okay for this application though? > >=20 > > Generally speaking, tsc state among different CPU after boot is not > > synchronized, you are right. > >=20 > > Kernel has somewhat doubtful test which verifies whether the after-boot > > state of tsc looks good. If the test fails, TSC is not enabled by > > default as timecounter, and then usermode follows kernel policy and > > falls back to slow syscall. So we err on the safe side. > > I tested this on Core i7 2xxx, where the test (usually) passes. >=20 > Okay, so for x86 the TSCs are not used as timecounters by either > the kernel or userland in the SMP case if they don't appear to > be synchronized, correct? Correct as for now. But this is bug and not a feature. The tscs shall be synchronized, or skew tables calculated instead of refusing to use it. >=20 > >=20 > > While you are there. do you have comments about sparc64 TICK counter ? > > On SMP, the counter of BSP is used by IPI. Is it unavoidable ? >=20 > The TICK counters are per-core and not synchronized by the hardware. > We synchronize APs with the BSP on bring-up but they drift over time > and the initial synchronization might not be perfect in the first > place. At least in the past, drifting TICK counters caused all sorts > of issues and strange behavior in FreeBSD when used as timecounter > in the SMP case. If my understanding of the above is right, as is > this still rules them out as timecounters for userland. > Linux has some complex code (based on equivalent code origining in > their ia64 port) for constantly synchronizing the TICK counters. > In order to avoid that complexity and overhead, what I do in > FreeBSD in the SMP case is to (ab)use counters (either intended > for that purpose or bus cycle counters probably intended for > debugging the hardware during development) available in the > various host-to-foo bridges so it doesn't matter which CPU they > are read by. This works just fine except for pre-PCI-Express > based USIIIi machines, where the bus cycle counters are broken. > That's where the TICK counter is always read from the BSP > using an IPI in the SMP case. The latter is done as sched_bind(9) > isn't possible with td_critnest > 1 according to information > from jhb@ and mav@. > So apart from introducing code to constantly synchronize the > TICK counters, using the timecounters on the host busses also > seems to be the only viable solution for userland. The latter > should be doable but is long-winded as besides duplicating > portions of the corresponding device drivers in userland, it > probably also means to get some additional infrastructure > like being able to memory map registers for devices on the > nexus(4) level in place ... Understand. I do plan eventually to map HPET counters page into usermode on x86. Also, as I noted above, some code to synchronize per-package counters would be useful for x86, so it might be developed with multi-arch usage in mind. --x5H/dHEtcMgsAT6y Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/lzUQACgkQC3+MBN1Mb4jrTwCgjeoJh5/3fqsZBgaU+F4o3bou yg8An2Ac82EdegqYqBYGUVZhiyI6NuzC =fGTg -----END PGP SIGNATURE----- --x5H/dHEtcMgsAT6y-- From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 14:36:01 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F1E6E1065679; Sat, 23 Jun 2012 14:36:01 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 9858E8FC15; Sat, 23 Jun 2012 14:36:01 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.4/8.14.4/ALCHEMY.FRANKEN.DE) with ESMTP id q5NEa0xH043192; Sat, 23 Jun 2012 16:36:00 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.4/8.14.4/Submit) id q5NEa0vr043191; Sat, 23 Jun 2012 16:36:00 +0200 (CEST) (envelope-from marius) Date: Sat, 23 Jun 2012 16:35:59 +0200 From: Marius Strobl To: Konstantin Belousov Message-ID: <20120623143559.GF69382@alchemy.franken.de> References: <201206220713.q5M7DVH0063098@svn.freebsd.org> <20120622073455.GE69382@alchemy.franken.de> <20120622074817.GA2337@deviant.kiev.zoral.com.ua> <20120623131757.GB46065@alchemy.franken.de> <20120623140556.GU2337@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120623140556.GU2337@deviant.kiev.zoral.com.ua> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 14:36:02 -0000 On Sat, Jun 23, 2012 at 05:05:56PM +0300, Konstantin Belousov wrote: > On Sat, Jun 23, 2012 at 03:17:57PM +0200, Marius Strobl wrote: > > On Fri, Jun 22, 2012 at 10:48:17AM +0300, Konstantin Belousov wrote: > > > On Fri, Jun 22, 2012 at 09:34:56AM +0200, Marius Strobl wrote: > > > > On Fri, Jun 22, 2012 at 07:13:31AM +0000, Konstantin Belousov wrote: > > > > > Author: kib > > > > > Date: Fri Jun 22 07:13:30 2012 > > > > > New Revision: 237434 > > > > > URL: http://svn.freebsd.org/changeset/base/237434 > > > > > > > > > > Log: > > > > > Use struct vdso_timehands data to implement fast gettimeofday(2) and > > > > > clock_gettime(2) functions if supported. The speedup seen in > > > > > microbenchmarks is in range 4x-7x depending on the hardware. > > > > > > > > > > Only amd64 and i386 architectures are supported. Libc uses rdtsc and > > > > > kernel data to calculate current time, if enabled by kernel. > > > > > > > > I don't know much about x86 CPUs but is my understanding correct > > > > that TSCs are not synchronized in any way across CPUs, i.e. > > > > reading it on different CPUs may result in time going backwards > > > > etc., which is okay for this application though? > > > > > > Generally speaking, tsc state among different CPU after boot is not > > > synchronized, you are right. > > > > > > Kernel has somewhat doubtful test which verifies whether the after-boot > > > state of tsc looks good. If the test fails, TSC is not enabled by > > > default as timecounter, and then usermode follows kernel policy and > > > falls back to slow syscall. So we err on the safe side. > > > I tested this on Core i7 2xxx, where the test (usually) passes. > > > > Okay, so for x86 the TSCs are not used as timecounters by either > > the kernel or userland in the SMP case if they don't appear to > > be synchronized, correct? > Correct as for now. But this is bug and not a feature. The tscs shall > be synchronized, or skew tables calculated instead of refusing to use it. > > > > > > > > > While you are there. do you have comments about sparc64 TICK counter ? > > > On SMP, the counter of BSP is used by IPI. Is it unavoidable ? > > > > The TICK counters are per-core and not synchronized by the hardware. > > We synchronize APs with the BSP on bring-up but they drift over time > > and the initial synchronization might not be perfect in the first > > place. At least in the past, drifting TICK counters caused all sorts > > of issues and strange behavior in FreeBSD when used as timecounter > > in the SMP case. If my understanding of the above is right, as is > > this still rules them out as timecounters for userland. > > Linux has some complex code (based on equivalent code origining in > > their ia64 port) for constantly synchronizing the TICK counters. > > In order to avoid that complexity and overhead, what I do in > > FreeBSD in the SMP case is to (ab)use counters (either intended > > for that purpose or bus cycle counters probably intended for > > debugging the hardware during development) available in the > > various host-to-foo bridges so it doesn't matter which CPU they > > are read by. This works just fine except for pre-PCI-Express > > based USIIIi machines, where the bus cycle counters are broken. > > That's where the TICK counter is always read from the BSP > > using an IPI in the SMP case. The latter is done as sched_bind(9) > > isn't possible with td_critnest > 1 according to information > > from jhb@ and mav@. > > So apart from introducing code to constantly synchronize the > > TICK counters, using the timecounters on the host busses also > > seems to be the only viable solution for userland. The latter > > should be doable but is long-winded as besides duplicating > > portions of the corresponding device drivers in userland, it > > probably also means to get some additional infrastructure > > like being able to memory map registers for devices on the > > nexus(4) level in place ... > > Understand. I do plan eventually to map HPET counters page into usermode > on x86. > > Also, as I noted above, some code to synchronize per-package counters > would be useful for x86, so it might be developed with multi-arch > usage in mind. That would be great. Marius From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 14:43:25 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D8BD51065674; Sat, 23 Jun 2012 14:43:25 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AA5568FC08; Sat, 23 Jun 2012 14:43:25 +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 q5NEhP4I046643; Sat, 23 Jun 2012 14:43:25 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5NEhPoX046641; Sat, 23 Jun 2012 14:43:25 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201206231443.q5NEhPoX046641@svn.freebsd.org> From: Marius Strobl Date: Sat, 23 Jun 2012 14:43:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237483 - head/sys/conf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 14:43:25 -0000 Author: marius Date: Sat Jun 23 14:43:25 2012 New Revision: 237483 URL: http://svn.freebsd.org/changeset/base/237483 Log: Unbreak options ZFS after r236884. Modified: head/sys/conf/files Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Sat Jun 23 14:15:13 2012 (r237482) +++ head/sys/conf/files Sat Jun 23 14:43:25 2012 (r237483) @@ -161,9 +161,11 @@ cddl/compat/opensolaris/kern/opensolaris cddl/compat/opensolaris/kern/opensolaris_zone.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/common/acl/acl_common.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/common/avl/avl.c optional zfs compile-with "${ZFS_C}" +cddl/contrib/opensolaris/common/nvpair/fnvpair.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/common/nvpair/nvpair.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/common/nvpair/nvpair_alloc_fixed.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/common/unicode/u8_textprep.c optional zfs compile-with "${ZFS_C}" +cddl/contrib/opensolaris/common/zfs/zfeature_common.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/common/zfs/zfs_comutil.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/common/zfs/zfs_deleg.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/common/zfs/zfs_fletcher.c optional zfs compile-with "${ZFS_C}" @@ -177,6 +179,7 @@ cddl/contrib/opensolaris/uts/common/fs/v cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/bplist.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.c optional zfs compile-with "${ZFS_C}" +cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/ddt_zap.c optional zfs compile-with "${ZFS_C}" @@ -228,6 +231,7 @@ cddl/contrib/opensolaris/uts/common/fs/z cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/zap_leaf.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c optional zfs compile-with "${ZFS_C}" +cddl/contrib/opensolaris/uts/common/fs/zfs/zfeature.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_byteswap.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c optional zfs compile-with "${ZFS_C}" From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 14:56:19 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E1A671065674; Sat, 23 Jun 2012 14:56:19 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 6F6BE8FC0C; Sat, 23 Jun 2012 14:56:19 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.4/8.14.4/ALCHEMY.FRANKEN.DE) with ESMTP id q5NEuI7l043265; Sat, 23 Jun 2012 16:56:18 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.4/8.14.4/Submit) id q5NEuIee043264; Sat, 23 Jun 2012 16:56:18 +0200 (CEST) (envelope-from marius) Date: Sat, 23 Jun 2012 16:56:18 +0200 From: Marius Strobl To: Martin Matuska Message-ID: <20120623145618.GG69382@alchemy.franken.de> References: <201206111135.q5BBZMva081982@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201206111135.q5BBZMva081982@svn.freebsd.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r236884 - in head: . cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/cmd/zhack cddl/contrib/opensolaris/cmd/zpool cddl/contrib/opensolaris/cmd/ztest cddl/contrib/opensolaris/l... X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 14:56:20 -0000 On Mon, Jun 11, 2012 at 11:35:22AM +0000, Martin Matuska wrote: > Author: mm > Date: Mon Jun 11 11:35:22 2012 > New Revision: 236884 > URL: http://svn.freebsd.org/changeset/base/236884 > > Log: > Introduce "feature flags" for ZFS pools (bump SPA version to 5000). > Add first feature "com.delphix:async_destroy" (asynchronous destroy > of ZFS datasets). > Implement features support in ZFS boot code. This commit is strange; it broke compling ZFS statically as the newly added kernel files referenced by dsl*.c etc. were missing from sys/conf/files (fixed in r237483). However, I don't see how these files except fnvpair.c but including dsl*.c are compiled into the module case either, but for some reason it apparently links and works anyway ... Marius From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 15:26:25 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2046A1065675; Sat, 23 Jun 2012 15:26:25 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from fallbackmx06.syd.optusnet.com.au (fallbackmx06.syd.optusnet.com.au [211.29.132.8]) by mx1.freebsd.org (Postfix) with ESMTP id 92E6B8FC18; Sat, 23 Jun 2012 15:26:24 +0000 (UTC) Received: from mail08.syd.optusnet.com.au (mail08.syd.optusnet.com.au [211.29.132.189]) by fallbackmx06.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q5NFQGPh015068; Sun, 24 Jun 2012 01:26:16 +1000 Received: from c122-106-171-232.carlnfd1.nsw.optusnet.com.au (c122-106-171-232.carlnfd1.nsw.optusnet.com.au [122.106.171.232]) by mail08.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q5NFQ1Ma028943 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 24 Jun 2012 01:26:02 +1000 Date: Sun, 24 Jun 2012 01:26:01 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov In-Reply-To: <20120623140556.GU2337@deviant.kiev.zoral.com.ua> Message-ID: <20120624005418.W2417@besplex.bde.org> References: <201206220713.q5M7DVH0063098@svn.freebsd.org> <20120622073455.GE69382@alchemy.franken.de> <20120622074817.GA2337@deviant.kiev.zoral.com.ua> <20120623131757.GB46065@alchemy.franken.de> <20120623140556.GU2337@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Marius Strobl Subject: Re: svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 15:26:25 -0000 On Sat, 23 Jun 2012, Konstantin Belousov wrote: > On Sat, Jun 23, 2012 at 03:17:57PM +0200, Marius Strobl wrote: >> On Fri, Jun 22, 2012 at 10:48:17AM +0300, Konstantin Belousov wrote: >>> On Fri, Jun 22, 2012 at 09:34:56AM +0200, Marius Strobl wrote: >>>> On Fri, Jun 22, 2012 at 07:13:31AM +0000, Konstantin Belousov wrote: >>>>> Author: kib >>>>> Date: Fri Jun 22 07:13:30 2012 >>>>> New Revision: 237434 >>>>> URL: http://svn.freebsd.org/changeset/base/237434 >>>>> >>>>> Log: >>>>> Use struct vdso_timehands data to implement fast gettimeofday(2) and >>>>> clock_gettime(2) functions if supported. The speedup seen in >>>>> microbenchmarks is in range 4x-7x depending on the hardware. >>>>> >>>>> Only amd64 and i386 architectures are supported. Libc uses rdtsc and >>>>> kernel data to calculate current time, if enabled by kernel. >>>> >>>> I don't know much about x86 CPUs but is my understanding correct >>>> that TSCs are not synchronized in any way across CPUs, i.e. >>>> reading it on different CPUs may result in time going backwards >>>> etc., which is okay for this application though? >>> >>> Generally speaking, tsc state among different CPU after boot is not >>> synchronized, you are right. >>> >>> Kernel has somewhat doubtful test which verifies whether the after-boot >>> state of tsc looks good. If the test fails, TSC is not enabled by >>> default as timecounter, and then usermode follows kernel policy and >>> falls back to slow syscall. So we err on the safe side. >>> I tested this on Core i7 2xxx, where the test (usually) passes. >> >> Okay, so for x86 the TSCs are not used as timecounters by either >> the kernel or userland in the SMP case if they don't appear to >> be synchronized, correct? > Correct as for now. But this is bug and not a feature. The tscs shall > be synchronized, or skew tables calculated instead of refusing to use it. >>> >>> While you are there. do you have comments about sparc64 TICK counter ? >>> On SMP, the counter of BSP is used by IPI. Is it unavoidable ? >> >> The TICK counters are per-core and not synchronized by the hardware. >> We synchronize APs with the BSP on bring-up but they drift over time >> and the initial synchronization might not be perfect in the first >> place. At least in the past, drifting TICK counters caused all sorts >> of issues and strange behavior in FreeBSD when used as timecounter >> in the SMP case. If my understanding of the above is right, as is >> this still rules them out as timecounters for userland. >> Linux has some complex code (based on equivalent code origining in >> their ia64 port) for constantly synchronizing the TICK counters. >> In order to avoid that complexity and overhead, what I do in >> FreeBSD in the SMP case is to (ab)use counters (either intended Attempted synchronization of TSCs is left out for the same reason on x86. Except some half-baked synchronization for a home made time function in dtrace (dtrace_gethrtime() on amd64 and i386) crept in. >> for that purpose or bus cycle counters probably intended for >> debugging the hardware during development) available in the >> various host-to-foo bridges so it doesn't matter which CPU they >> are read by. This works just fine except for pre-PCI-Express >> based USIIIi machines, where the bus cycle counters are broken. >> That's where the TICK counter is always read from the BSP >> using an IPI in the SMP case. The latter is done as sched_bind(9) >> isn't possible with td_critnest > 1 according to information >> from jhb@ and mav@. How can it work fine? Buses are too slow. On x86, ACPI-fast takes 700-1900 nsec on machines that I've tested (mostly pre-PCIe ones). HPET seems to be only slightly faster (maybe 500 nsec). >> So apart from introducing code to constantly synchronize the >> TICK counters, using the timecounters on the host busses also >> seems to be the only viable solution for userland. The latter >> should be doable but is long-winded as besides duplicating >> portions of the corresponding device drivers in userland, it >> probably also means to get some additional infrastructure >> like being able to memory map registers for devices on the >> nexus(4) level in place ... There is little point in optimizations to avoid syscalls for hardware. On x86, a syscall takes 100-400 nsec extra, so if the hardware takes 500-2000 nsec then reduction the total time by 100-400 nsec is not very useful. > Understand. I do plan eventually to map HPET counters page into usermode > on x86. This should be left out too. > Also, as I noted above, some code to synchronize per-package counters > would be useful for x86, so it might be developed with multi-arch > usage in mind. It's only worth synchonizing fast timecounter hardware so that it can be used in more cases. It probably needs to be non-bus based to be fast. That means the TSC on x86. The new timeout code to support tickless kernels looks like it will give large pessimizations unless the timecounter is fast. Instead of using the tick counter (1 atomic increment on every clock tick) and some getbinuptime() calls in places like select(), it uses the hardware timecounter via binuptime() in most places (since without a tick counter and without clock interrupts updating the timehands periodically, it takes a hardware timecounter read to determine the time). So callout_reset() might start taking thousands of nsec for per call, depending on how slow the timecounter is. This fix is probably to use a fuzzy time for long long timeouts and to discourage use of short timeouts and/or to turn them into long or fuzzy timeouts so that they are not very useful. Bruce From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 15:36:32 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C3FC3106564A; Sat, 23 Jun 2012 15:36:32 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AF0C68FC1A; Sat, 23 Jun 2012 15:36:32 +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 q5NFaWqT049030; Sat, 23 Jun 2012 15:36:32 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5NFaWuJ049028; Sat, 23 Jun 2012 15:36:32 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206231536.q5NFaWuJ049028@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 23 Jun 2012 15:36:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237484 - head/sys/dev/agp X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 15:36:32 -0000 Author: kib Date: Sat Jun 23 15:36:32 2012 New Revision: 237484 URL: http://svn.freebsd.org/changeset/base/237484 Log: Correct device id for GPU on some server SandyBridge model. Submitted and tested by: Thomas Zander MFC after: 3 days Modified: head/sys/dev/agp/agp_i810.c Modified: head/sys/dev/agp/agp_i810.c ============================================================================== --- head/sys/dev/agp/agp_i810.c Sat Jun 23 14:43:25 2012 (r237483) +++ head/sys/dev/agp/agp_i810.c Sat Jun 23 15:36:32 2012 (r237484) @@ -700,7 +700,7 @@ static const struct agp_i810_match { .driver = &agp_i810_sb_driver }, { - .devid = 0x01088086, + .devid = 0x010a8086, .name = "SandyBridge server IG", .driver = &agp_i810_sb_driver }, From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 18:43:56 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0B04F1065672; Sat, 23 Jun 2012 18:43:55 +0000 (UTC) (envelope-from iwasaki@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 646508FC0C; Sat, 23 Jun 2012 18:43:55 +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 q5NIhtqi057818; Sat, 23 Jun 2012 18:43:55 GMT (envelope-from iwasaki@svn.freebsd.org) Received: (from iwasaki@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5NIhtoh057816; Sat, 23 Jun 2012 18:43:55 GMT (envelope-from iwasaki@svn.freebsd.org) Message-Id: <201206231843.q5NIhtoh057816@svn.freebsd.org> From: Mitsuru IWASAKI Date: Sat, 23 Jun 2012 18:43:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237493 - head/sys/dev/acpi_support X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 18:43:56 -0000 Author: iwasaki Date: Sat Jun 23 18:43:54 2012 New Revision: 237493 URL: http://svn.freebsd.org/changeset/base/237493 Log: Add in-driver event handler. MFC after: 3 days Modified: head/sys/dev/acpi_support/acpi_ibm.c Modified: head/sys/dev/acpi_support/acpi_ibm.c ============================================================================== --- head/sys/dev/acpi_support/acpi_ibm.c Sat Jun 23 18:43:11 2012 (r237492) +++ head/sys/dev/acpi_support/acpi_ibm.c Sat Jun 23 18:43:54 2012 (r237493) @@ -50,6 +50,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -70,6 +72,7 @@ ACPI_MODULE_NAME("IBM") #define ACPI_IBM_METHOD_FANLEVEL 11 #define ACPI_IBM_METHOD_FANSTATUS 12 #define ACPI_IBM_METHOD_THERMAL 13 +#define ACPI_IBM_METHOD_HANDLEREVENTS 14 /* Hotkeys/Buttons */ #define IBM_RTC_HOTKEY1 0x64 @@ -126,6 +129,21 @@ ACPI_MODULE_NAME("IBM") #define IBM_NAME_EVENTS_GET "MHKP" #define IBM_NAME_EVENTS_AVAILMASK "MHKA" +/* Event Code */ +#define IBM_EVENT_LCD_BACKLIGHT 0x03 +#define IBM_EVENT_SUSPEND_TO_RAM 0x04 +#define IBM_EVENT_BLUETOOTH 0x05 +#define IBM_EVENT_SCREEN_EXPAND 0x07 +#define IBM_EVENT_SUSPEND_TO_DISK 0x0c +#define IBM_EVENT_BRIGHTNESS_UP 0x10 +#define IBM_EVENT_BRIGHTNESS_DOWN 0x11 +#define IBM_EVENT_THINKLIGHT 0x12 +#define IBM_EVENT_ZOOM 0x14 +#define IBM_EVENT_VOLUME_UP 0x15 +#define IBM_EVENT_VOLUME_DOWN 0x16 +#define IBM_EVENT_MUTE 0x17 +#define IBM_EVENT_ACCESS_IBM_BUTTON 0x18 + #define ABS(x) (((x) < 0)? -(x) : (x)) struct acpi_ibm_softc { @@ -164,6 +182,8 @@ struct acpi_ibm_softc { int events_mask_supported; int events_enable; + unsigned int handler_events; + struct sysctl_ctx_list *sysctl_ctx; struct sysctl_oid *sysctl_tree; }; @@ -267,8 +287,15 @@ static int acpi_ibm_sysctl_set(struct ac static int acpi_ibm_eventmask_set(struct acpi_ibm_softc *sc, int val); static int acpi_ibm_thermal_sysctl(SYSCTL_HANDLER_ARGS); +static int acpi_ibm_handlerevents_sysctl(SYSCTL_HANDLER_ARGS); static void acpi_ibm_notify(ACPI_HANDLE h, UINT32 notify, void *context); +static int acpi_ibm_brightness_set(struct acpi_ibm_softc *sc, int arg); +static int acpi_ibm_bluetooth_set(struct acpi_ibm_softc *sc, int arg); +static int acpi_ibm_thinklight_set(struct acpi_ibm_softc *sc, int arg); +static int acpi_ibm_volume_set(struct acpi_ibm_softc *sc, int arg); +static int acpi_ibm_mute_set(struct acpi_ibm_softc *sc, int arg); + static device_method_t acpi_ibm_methods[] = { /* Device interface */ DEVMETHOD(device_probe, acpi_ibm_probe), @@ -404,6 +431,15 @@ acpi_ibm_attach(device_t dev) "Thermal zones"); } + /* Hook up handlerevents node */ + if (acpi_ibm_sysctl_init(sc, ACPI_IBM_METHOD_HANDLEREVENTS)) { + SYSCTL_ADD_PROC(sc->sysctl_ctx, + SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, + "handlerevents", CTLTYPE_STRING | CTLFLAG_RW, + sc, 0, acpi_ibm_handlerevents_sysctl, "I", + "devd(8) events handled by acpi_ibm"); + } + /* Handle notifies */ AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY, acpi_ibm_notify, dev); @@ -656,10 +692,8 @@ acpi_ibm_sysctl_get(struct acpi_ibm_soft static int acpi_ibm_sysctl_set(struct acpi_ibm_softc *sc, int method, int arg) { - int val, step; + int val; UINT64 val_ec; - ACPI_OBJECT Arg; - ACPI_OBJECT_LIST Args; ACPI_STATUS status; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); @@ -683,101 +717,23 @@ acpi_ibm_sysctl_set(struct acpi_ibm_soft break; case ACPI_IBM_METHOD_BRIGHTNESS: - if (arg < 0 || arg > 7) - return (EINVAL); - - if (sc->cmos_handle) { - /* Read the current brightness */ - status = ACPI_EC_READ(sc->ec_dev, IBM_EC_BRIGHTNESS, &val_ec, 1); - if (ACPI_FAILURE(status)) - return (status); - val = val_ec & IBM_EC_MASK_BRI; - - Args.Count = 1; - Args.Pointer = &Arg; - Arg.Type = ACPI_TYPE_INTEGER; - Arg.Integer.Value = (arg > val) ? IBM_CMOS_BRIGHTNESS_UP : IBM_CMOS_BRIGHTNESS_DOWN; - - step = (arg > val) ? 1 : -1; - for (int i = val; i != arg; i += step) { - status = AcpiEvaluateObject(sc->cmos_handle, NULL, &Args, NULL); - if (ACPI_FAILURE(status)) - break; - } - } - return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_BRIGHTNESS, arg, 1); + return acpi_ibm_brightness_set(sc, arg); break; case ACPI_IBM_METHOD_VOLUME: - if (arg < 0 || arg > 14) - return (EINVAL); - - status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1); - if (ACPI_FAILURE(status)) - return (status); - - if (sc->cmos_handle) { - val = val_ec & IBM_EC_MASK_VOL; - - Args.Count = 1; - Args.Pointer = &Arg; - Arg.Type = ACPI_TYPE_INTEGER; - Arg.Integer.Value = (arg > val) ? IBM_CMOS_VOLUME_UP : IBM_CMOS_VOLUME_DOWN; - - step = (arg > val) ? 1 : -1; - for (int i = val; i != arg; i += step) { - status = AcpiEvaluateObject(sc->cmos_handle, NULL, &Args, NULL); - if (ACPI_FAILURE(status)) - break; - } - } - return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_VOLUME, arg + (val_ec & (~IBM_EC_MASK_VOL)), 1); + return acpi_ibm_volume_set(sc, arg); break; case ACPI_IBM_METHOD_MUTE: - if (arg < 0 || arg > 1) - return (EINVAL); - - status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1); - if (ACPI_FAILURE(status)) - return (status); - - if (sc->cmos_handle) { - Args.Count = 1; - Args.Pointer = &Arg; - Arg.Type = ACPI_TYPE_INTEGER; - Arg.Integer.Value = IBM_CMOS_VOLUME_MUTE; - - status = AcpiEvaluateObject(sc->cmos_handle, NULL, &Args, NULL); - if (ACPI_FAILURE(status)) - break; - } - return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_VOLUME, (arg==1) ? val_ec | IBM_EC_MASK_MUTE : val_ec & (~IBM_EC_MASK_MUTE), 1); + return acpi_ibm_mute_set(sc, arg); break; case ACPI_IBM_METHOD_THINKLIGHT: - if (arg < 0 || arg > 1) - return (EINVAL); - - if (sc->light_set_supported) { - Args.Count = 1; - Args.Pointer = &Arg; - Arg.Type = ACPI_TYPE_INTEGER; - Arg.Integer.Value = arg ? sc->light_cmd_on : sc->light_cmd_off; - - status = AcpiEvaluateObject(sc->light_handle, NULL, &Args, NULL); - if (ACPI_SUCCESS(status)) - sc->light_val = arg; - return (status); - } + return acpi_ibm_thinklight_set(sc, arg); break; case ACPI_IBM_METHOD_BLUETOOTH: - if (arg < 0 || arg > 1) - return (EINVAL); - - val = (arg == 1) ? sc->wlan_bt_flags | IBM_NAME_MASK_BT : sc->wlan_bt_flags & (~IBM_NAME_MASK_BT); - return acpi_SetInteger(sc->handle, IBM_NAME_WLAN_BT_SET, val); + return acpi_ibm_bluetooth_set(sc, arg); break; case ACPI_IBM_METHOD_FANLEVEL: @@ -898,6 +854,9 @@ acpi_ibm_sysctl_init(struct acpi_ibm_sof return (TRUE); } return (FALSE); + + case ACPI_IBM_METHOD_HANDLEREVENTS: + return (TRUE); } return (FALSE); } @@ -937,6 +896,328 @@ acpi_ibm_thermal_sysctl(SYSCTL_HANDLER_A return (error); } +static int +acpi_ibm_handlerevents_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct acpi_ibm_softc *sc; + int error = 0; + struct sbuf sb; + char *cp, *ep; + int l, val; + unsigned int handler_events; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + + sc = (struct acpi_ibm_softc *)oidp->oid_arg1; + + if (sbuf_new(&sb, NULL, 128, SBUF_AUTOEXTEND) == NULL) + return (ENOMEM); + + ACPI_SERIAL_BEGIN(ibm); + + /* Get old values if this is a get request. */ + if (req->newptr == NULL) { + for (int i = 0; i < 8 * sizeof(sc->handler_events); i++) + if (sc->handler_events & (1 << i)) + sbuf_printf(&sb, "0x%02x ", i + 1); + if (sbuf_len(&sb) == 0) + sbuf_printf(&sb, "NONE"); + } + + sbuf_trim(&sb); + sbuf_finish(&sb); + + /* Copy out the old values to the user. */ + error = SYSCTL_OUT(req, sbuf_data(&sb), sbuf_len(&sb)); + sbuf_delete(&sb); + + if (error != 0 || req->newptr == NULL) + goto out; + + /* If the user is setting a string, parse it. */ + handler_events = 0; + cp = (char *)req->newptr; + while (*cp) { + if (isspace(*cp)) { + cp++; + continue; + } + + ep = cp; + + while (*ep && !isspace(*ep)) + ep++; + + l = ep - cp; + if (l == 0) + break; + + if (strncmp(cp, "NONE", 4) == 0) { + cp = ep; + continue; + } + + if (l >= 3 && cp[0] == '0' && (cp[1] == 'X' || cp[1] == 'x')) + val = strtoul(cp, &ep, 16); + else + val = strtoul(cp, &ep, 10); + + if (val == 0 || ep == cp || val >= 8 * sizeof(handler_events)) { + cp[l] = '\0'; + device_printf(sc->dev, "invalid event code: %s\n", cp); + error = EINVAL; + goto out; + } + + handler_events |= 1 << (val - 1); + + cp = ep; + } + + sc->handler_events = handler_events; +out: + ACPI_SERIAL_END(ibm); + return (error); +} + +static int +acpi_ibm_brightness_set(struct acpi_ibm_softc *sc, int arg) +{ + int val, step; + UINT64 val_ec; + ACPI_OBJECT Arg; + ACPI_OBJECT_LIST Args; + ACPI_STATUS status; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + ACPI_SERIAL_ASSERT(ibm); + + if (arg < 0 || arg > 7) + return (EINVAL); + + /* Read the current brightness */ + status = ACPI_EC_READ(sc->ec_dev, IBM_EC_BRIGHTNESS, &val_ec, 1); + if (ACPI_FAILURE(status)) + return (status); + + if (sc->cmos_handle) { + val = val_ec & IBM_EC_MASK_BRI; + + Args.Count = 1; + Args.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = (arg > val) ? IBM_CMOS_BRIGHTNESS_UP : + IBM_CMOS_BRIGHTNESS_DOWN; + + step = (arg > val) ? 1 : -1; + for (int i = val; i != arg; i += step) { + status = AcpiEvaluateObject(sc->cmos_handle, NULL, + &Args, NULL); + if (ACPI_FAILURE(status)) { + /* Record the last value */ + if (i != val) { + ACPI_EC_WRITE(sc->ec_dev, + IBM_EC_BRIGHTNESS, i - step, 1); + } + return (status); + } + } + } + + return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_BRIGHTNESS, arg, 1); +} + +static int +acpi_ibm_bluetooth_set(struct acpi_ibm_softc *sc, int arg) +{ + int val; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + ACPI_SERIAL_ASSERT(ibm); + + if (arg < 0 || arg > 1) + return (EINVAL); + + val = (arg == 1) ? sc->wlan_bt_flags | IBM_NAME_MASK_BT : + sc->wlan_bt_flags & (~IBM_NAME_MASK_BT); + return acpi_SetInteger(sc->handle, IBM_NAME_WLAN_BT_SET, val); +} + +static int +acpi_ibm_thinklight_set(struct acpi_ibm_softc *sc, int arg) +{ + ACPI_OBJECT Arg; + ACPI_OBJECT_LIST Args; + ACPI_STATUS status; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + ACPI_SERIAL_ASSERT(ibm); + + if (arg < 0 || arg > 1) + return (EINVAL); + + if (sc->light_set_supported) { + Args.Count = 1; + Args.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = arg ? sc->light_cmd_on : sc->light_cmd_off; + + status = AcpiEvaluateObject(sc->light_handle, NULL, + &Args, NULL); + if (ACPI_SUCCESS(status)) + sc->light_val = arg; + return (status); + } + + return (0); +} + +static int +acpi_ibm_volume_set(struct acpi_ibm_softc *sc, int arg) +{ + int val, step; + UINT64 val_ec; + ACPI_OBJECT Arg; + ACPI_OBJECT_LIST Args; + ACPI_STATUS status; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + ACPI_SERIAL_ASSERT(ibm); + + if (arg < 0 || arg > 14) + return (EINVAL); + + /* Read the current volume */ + status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1); + if (ACPI_FAILURE(status)) + return (status); + + if (sc->cmos_handle) { + val = val_ec & IBM_EC_MASK_VOL; + + Args.Count = 1; + Args.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = (arg > val) ? IBM_CMOS_VOLUME_UP : + IBM_CMOS_VOLUME_DOWN; + + step = (arg > val) ? 1 : -1; + for (int i = val; i != arg; i += step) { + status = AcpiEvaluateObject(sc->cmos_handle, NULL, + &Args, NULL); + if (ACPI_FAILURE(status)) { + /* Record the last value */ + if (i != val) { + val_ec = i - step + + (val_ec & (~IBM_EC_MASK_VOL)); + ACPI_EC_WRITE(sc->ec_dev, IBM_EC_VOLUME, + val_ec, 1); + } + return (status); + } + } + } + + val_ec = arg + (val_ec & (~IBM_EC_MASK_VOL)); + return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_VOLUME, val_ec, 1); +} + +static int +acpi_ibm_mute_set(struct acpi_ibm_softc *sc, int arg) +{ + UINT64 val_ec; + ACPI_OBJECT Arg; + ACPI_OBJECT_LIST Args; + ACPI_STATUS status; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + ACPI_SERIAL_ASSERT(ibm); + + if (arg < 0 || arg > 1) + return (EINVAL); + + status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1); + if (ACPI_FAILURE(status)) + return (status); + + if (sc->cmos_handle) { + Args.Count = 1; + Args.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = IBM_CMOS_VOLUME_MUTE; + + status = AcpiEvaluateObject(sc->cmos_handle, NULL, &Args, NULL); + if (ACPI_FAILURE(status)) + return (status); + } + + val_ec = (arg == 1) ? val_ec | IBM_EC_MASK_MUTE : + val_ec & (~IBM_EC_MASK_MUTE); + return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_VOLUME, val_ec, 1); +} + +static void +acpi_ibm_eventhandler(struct acpi_ibm_softc *sc, int arg) +{ + int val; + UINT64 val_ec; + ACPI_STATUS status; + + ACPI_SERIAL_BEGIN(ibm); + switch (arg) { + case IBM_EVENT_SUSPEND_TO_RAM: + power_pm_suspend(POWER_SLEEP_STATE_SUSPEND); + break; + + case IBM_EVENT_BLUETOOTH: + acpi_ibm_bluetooth_set(sc, (sc->wlan_bt_flags == 0)); + break; + + case IBM_EVENT_BRIGHTNESS_UP: + case IBM_EVENT_BRIGHTNESS_DOWN: + /* Read the current brightness */ + status = ACPI_EC_READ(sc->ec_dev, IBM_EC_BRIGHTNESS, + &val_ec, 1); + if (ACPI_FAILURE(status)) + return; + + val = val_ec & IBM_EC_MASK_BRI; + val = (arg == IBM_EVENT_BRIGHTNESS_UP) ? val + 1 : val - 1; + acpi_ibm_brightness_set(sc, val); + break; + + case IBM_EVENT_THINKLIGHT: + acpi_ibm_thinklight_set(sc, (sc->light_val == 0)); + break; + + case IBM_EVENT_VOLUME_UP: + case IBM_EVENT_VOLUME_DOWN: + /* Read the current volume */ + status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1); + if (ACPI_FAILURE(status)) + return; + + val = val_ec & IBM_EC_MASK_VOL; + val = (arg == IBM_EVENT_VOLUME_UP) ? val + 1 : val - 1; + acpi_ibm_volume_set(sc, val); + break; + + case IBM_EVENT_MUTE: + /* Read the current value */ + status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1); + if (ACPI_FAILURE(status)) + return; + + val = ((val_ec & IBM_EC_MASK_MUTE) == IBM_EC_MASK_MUTE); + acpi_ibm_mute_set(sc, (val == 0)); + break; + + default: + break; + } + ACPI_SERIAL_END(ibm); +} + static void acpi_ibm_notify(ACPI_HANDLE h, UINT32 notify, void *context) { @@ -965,6 +1246,10 @@ acpi_ibm_notify(ACPI_HANDLE h, UINT32 no break; } + /* Execute event handler */ + if (sc->handler_events & (1 << (arg - 1))) + acpi_ibm_eventhandler(sc, (arg & 0xff)); + /* Notify devd(8) */ acpi_UserNotify("IBM", h, (arg & 0xff)); break; From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 18:45:32 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B7C05106564A; Sat, 23 Jun 2012 18:45:32 +0000 (UTC) (envelope-from iwasaki@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A325E8FC16; Sat, 23 Jun 2012 18:45:32 +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 q5NIjWR0057952; Sat, 23 Jun 2012 18:45:32 GMT (envelope-from iwasaki@svn.freebsd.org) Received: (from iwasaki@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5NIjWqV057950; Sat, 23 Jun 2012 18:45:32 GMT (envelope-from iwasaki@svn.freebsd.org) Message-Id: <201206231845.q5NIjWqV057950@svn.freebsd.org> From: Mitsuru IWASAKI Date: Sat, 23 Jun 2012 18:45:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237494 - head/share/man/man4 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 18:45:32 -0000 Author: iwasaki Date: Sat Jun 23 18:45:32 2012 New Revision: 237494 URL: http://svn.freebsd.org/changeset/base/237494 Log: Add description about dev.acpi_ibm.0.handlerevents. MFC after: 3 days Modified: head/share/man/man4/acpi_ibm.4 Modified: head/share/man/man4/acpi_ibm.4 ============================================================================== --- head/share/man/man4/acpi_ibm.4 Sat Jun 23 18:43:54 2012 (r237493) +++ head/share/man/man4/acpi_ibm.4 Sat Jun 23 18:45:32 2012 (r237494) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 8, 2010 +.Dd June 24, 2012 .Dt ACPI_IBM 4 .Os .Sh NAME @@ -335,6 +335,17 @@ Built-in battery .It UltraBay battery .El +.It Va dev.acpi_ibm.0.handlerevents +.Xr devd 8 +events handled by +.Nm +when +.Va events +is set to 1. +Events are specified as a whitespace-separated list of event code in +hexadecimal or decimal form. +Note that the event maybe handled twice (eg. Brightness up/down) if ACPI BIOS +already handled the event. .El .Pp Defaults for these sysctls can be set in @@ -436,6 +447,20 @@ then fi exit 0 .Ed +.Pp +The following example specify that event code 0x04 (Suspend to RAM), +0x10 (Brightness up) and 0x11 (Brightness down) are handled by +.Nm . +.Bd -literal -offset indent +sysctl dev.acpi_ibm.0.handlerevents='0x04 0x10 0x11' +.Ed +.Pp +in +.Xr sysctl.conf 5 : +.Bd -literal -offset indent +dev.acpi_ibm.0.handlerevents=0x04\\ 0x10\\ 0x11 +.Ed +.Pp .Sh SEE ALSO .Xr acpi 4 , .Xr led 4 , From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 20:01:37 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B0003106564A; Sat, 23 Jun 2012 20:01:37 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id 8F0658FC0C; Sat, 23 Jun 2012 20:01:36 +0000 (UTC) Received: by lbon10 with SMTP id n10so6053921lbo.13 for ; Sat, 23 Jun 2012 13:01:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=UxHRq11drzO9aLCPpmSfVKOsy/JsYWriSoBZ0UdeyAM=; b=bgCWX2CjSwA9KexYntx3c7INIgcmM7UjcEeYYVnfeWL9LmMu8cpmJvxIrX0qn68tUL hM3XA1MKlup8pOBrB3HL3YpoTUFr/eX9nE7BdG037wptbIgr4O1294xn6pIqnBnyw0ch szMTz7lau6O0bl3Y/CIDKmcWK+vXVL+w0EmL5PM3DAVz4tUF6rA+znpki78gcaVbUORG /46dKYnmpEkn4zcGk1zuXY8fisjZInvTGvHT1BnyxfvQIbsMk48yrWV2h42QatumK/0h UJuXq6u59E2e+Qk6llg1Z4GMFA+drlEcxYrLa7J3SfXdM3b2Rv0tECREk6ZgPSw7PDVH HdjQ== Received: by 10.112.30.136 with SMTP id s8mr3417033lbh.51.1340481695323; Sat, 23 Jun 2012 13:01:35 -0700 (PDT) Received: from mavbook2.mavhome.dp.ua (pc.mavhome.dp.ua. [212.86.226.226]) by mx.google.com with ESMTPS id xx8sm60286269lab.10.2012.06.23.13.01.32 (version=SSLv3 cipher=OTHER); Sat, 23 Jun 2012 13:01:34 -0700 (PDT) Sender: Alexander Motin Message-ID: <4FE6209B.7050809@FreeBSD.org> Date: Sat, 23 Jun 2012 23:01:31 +0300 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:13.0) Gecko/20120621 Thunderbird/13.0.1 MIME-Version: 1.0 To: Bruce Evans References: <201206220713.q5M7DVH0063098@svn.freebsd.org> <20120622073455.GE69382@alchemy.franken.de> <20120622074817.GA2337@deviant.kiev.zoral.com.ua> <20120623131757.GB46065@alchemy.franken.de> <20120623140556.GU2337@deviant.kiev.zoral.com.ua> <20120624005418.W2417@besplex.bde.org> In-Reply-To: <20120624005418.W2417@besplex.bde.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Davide Italiano , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org, Marius Strobl , Konstantin Belousov Subject: Re: svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 20:01:37 -0000 On 06/23/12 18:26, Bruce Evans wrote: > On Sat, 23 Jun 2012, Konstantin Belousov wrote: >> On Sat, Jun 23, 2012 at 03:17:57PM +0200, Marius Strobl wrote: >>> So apart from introducing code to constantly synchronize the >>> TICK counters, using the timecounters on the host busses also >>> seems to be the only viable solution for userland. The latter >>> should be doable but is long-winded as besides duplicating >>> portions of the corresponding device drivers in userland, it >>> probably also means to get some additional infrastructure >>> like being able to memory map registers for devices on the >>> nexus(4) level in place ... > > There is little point in optimizations to avoid syscalls for hardware. > On x86, a syscall takes 100-400 nsec extra, so if the hardware takes > 500-2000 nsec then reduction the total time by 100-400 nsec is not > very useful. Just out of curiosity I've run my own binuptime() micro-benchmarks: - on Core i5-650: TSC 11ns HPET 433ns ACPI-fast 515ns i8254 3736ns - on dual-socket Xeon E5645: TSC 15ns HPET 580ns ACPI-fast 1118ns i8254 3911ns I think it could be useful to have that small benchmark in base kernel. >> Understand. I do plan eventually to map HPET counters page into usermode >> on x86. > > This should be left out too. > >> Also, as I noted above, some code to synchronize per-package counters >> would be useful for x86, so it might be developed with multi-arch >> usage in mind. > > It's only worth synchonizing fast timecounter hardware so that it can be > used in more cases. It probably needs to be non-bus based to be fast. > That means the TSC on x86. > > The new timeout code to support tickless kernels looks like it will give > large pessimizations unless the timecounter is fast. Instead of using > the tick counter (1 atomic increment on every clock tick) and some > getbinuptime() calls in places like select(), it uses the hardware > timecounter via binuptime() in most places (since without a tick counter > and without clock interrupts updating the timehands periodically, it takes > a hardware timecounter read to determine the time). So callout_reset() > might start taking thousands of nsec for per call, depending on how slow > the timecounter is. This fix is probably to use a fuzzy time for long > long timeouts and to discourage use of short timeouts and/or to turn them > into long or fuzzy timeouts so that they are not very useful. The new timeout code is still in active development and optimization was not the first priority yet. My idea was to use much faster getbinuptime() for periods above let's say 100ms. Legacy ticks-oriented callout_reset() functions are by default not supposed to provide sub-tick resolution and with some assumptions could use getbinuptime(). For new interfaces it depends on caller, how will it get present time. I understand that integer tick counter is as fast as nothing else can ever be. But sorry, 32bit counter doesn't fit present goals. To have more we need some artificial atomicity -- exactly what getbinuptime() implements. What I would like to see there is tc_tick removal to make tc_windup() called for every hardclock tick. Having new tick-irrelevant callout interfaces we probably won't so much need to increase HZ too high any more, while this simplification would make ticks and getbinuptime() precision equal, solving some of your valid arguments against the last. -- Alexander Motin From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 20:44:46 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 02DA9106566B; Sat, 23 Jun 2012 20:44:46 +0000 (UTC) (envelope-from joel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C9C4D8FC08; Sat, 23 Jun 2012 20:44:45 +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 q5NKijTi063743; Sat, 23 Jun 2012 20:44:45 GMT (envelope-from joel@svn.freebsd.org) Received: (from joel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5NKij1q063741; Sat, 23 Jun 2012 20:44:45 GMT (envelope-from joel@svn.freebsd.org) Message-Id: <201206232044.q5NKij1q063741@svn.freebsd.org> From: Joel Dahl Date: Sat, 23 Jun 2012 20:44:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237509 - head/share/man/man4 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 20:44:46 -0000 Author: joel (doc committer) Date: Sat Jun 23 20:44:45 2012 New Revision: 237509 URL: http://svn.freebsd.org/changeset/base/237509 Log: Remove superfluous paragraph macro. Modified: head/share/man/man4/acpi_ibm.4 Modified: head/share/man/man4/acpi_ibm.4 ============================================================================== --- head/share/man/man4/acpi_ibm.4 Sat Jun 23 20:37:27 2012 (r237508) +++ head/share/man/man4/acpi_ibm.4 Sat Jun 23 20:44:45 2012 (r237509) @@ -460,7 +460,6 @@ in .Bd -literal -offset indent dev.acpi_ibm.0.handlerevents=0x04\\ 0x10\\ 0x11 .Ed -.Pp .Sh SEE ALSO .Xr acpi 4 , .Xr led 4 , From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 22:12:28 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B961106564A; Sat, 23 Jun 2012 22:12:28 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2DAFD8FC18; Sat, 23 Jun 2012 22:12:28 +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 q5NMCSkv067616; Sat, 23 Jun 2012 22:12:28 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5NMCRwR067614; Sat, 23 Jun 2012 22:12:27 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201206232212.q5NMCRwR067614@svn.freebsd.org> From: Navdeep Parhar Date: Sat, 23 Jun 2012 22:12:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237512 - head/sys/dev/cxgbe X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 22:12:28 -0000 Author: np Date: Sat Jun 23 22:12:27 2012 New Revision: 237512 URL: http://svn.freebsd.org/changeset/base/237512 Log: Better way to determine the status page length and rx pad boundary. Modified: head/sys/dev/cxgbe/t4_sge.c Modified: head/sys/dev/cxgbe/t4_sge.c ============================================================================== --- head/sys/dev/cxgbe/t4_sge.c Sat Jun 23 21:29:53 2012 (r237511) +++ head/sys/dev/cxgbe/t4_sge.c Sat Jun 23 22:12:27 2012 (r237512) @@ -70,12 +70,8 @@ enum { FL_PKTSHIFT = 2 }; -#define FL_ALIGN min(CACHE_LINE_SIZE, 32) -#if CACHE_LINE_SIZE > 64 -#define SPG_LEN 128 -#else -#define SPG_LEN 64 -#endif +static int fl_pad = CACHE_LINE_SIZE; +static int spg_len = 64; /* Used to track coalesced tx work request */ struct txpkts { @@ -167,6 +163,10 @@ static int handle_fw_rpl(struct sge_iq * static int sysctl_uint16(SYSCTL_HANDLER_ARGS); +#if defined(__i386__) || defined(__amd64__) +extern u_int cpu_clflush_line_size; +#endif + /* * Called on MOD_LOAD and fills up fl_buf_info[]. */ @@ -188,6 +188,11 @@ t4_sge_modload(void) FL_BUF_TYPE(i) = m_gettype(bufsize[i]); FL_BUF_ZONE(i) = m_getzone(bufsize[i]); } + +#if defined(__i386__) || defined(__amd64__) + fl_pad = max(cpu_clflush_line_size, 32); + spg_len = cpu_clflush_line_size > 64 ? 128 : 64; +#endif } /** @@ -209,8 +214,8 @@ t4_sge_init(struct adapter *sc) V_INGPADBOUNDARY(M_INGPADBOUNDARY) | F_EGRSTATUSPAGESIZE; ctrl_val = V_PKTSHIFT(FL_PKTSHIFT) | F_RXPKTCPLMODE | - V_INGPADBOUNDARY(ilog2(FL_ALIGN) - 5) | - V_EGRSTATUSPAGESIZE(SPG_LEN == 128); + V_INGPADBOUNDARY(ilog2(fl_pad) - 5) | + V_EGRSTATUSPAGESIZE(spg_len == 128); hpsize = V_HOSTPAGESIZEPF0(PAGE_SHIFT - 10) | V_HOSTPAGESIZEPF1(PAGE_SHIFT - 10) | @@ -1372,8 +1377,8 @@ t4_update_fl_bufsize(struct ifnet *ifp) int i, bufsize; /* large enough for a frame even when VLAN extraction is disabled */ - bufsize = FL_PKTSHIFT + ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN + - ifp->if_mtu; + bufsize = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN + ifp->if_mtu; + bufsize = roundup(bufsize + FL_PKTSHIFT, fl_pad); for_each_rxq(pi, i, rxq) { fl = &rxq->fl; @@ -1570,7 +1575,7 @@ alloc_iq_fl(struct port_info *pi, struct return (rc); /* Allocate space for one software descriptor per buffer. */ - fl->cap = (fl->qsize - SPG_LEN / RX_FL_ESIZE) * 8; + fl->cap = (fl->qsize - spg_len / RX_FL_ESIZE) * 8; FL_LOCK(fl); rc = alloc_fl_sdesc(fl); FL_UNLOCK(fl); @@ -2070,7 +2075,7 @@ alloc_eq(struct adapter *sc, struct port if (rc) return (rc); - eq->cap = eq->qsize - SPG_LEN / EQ_ESIZE; + eq->cap = eq->qsize - spg_len / EQ_ESIZE; eq->spg = (void *)&eq->desc[eq->cap]; eq->avail = eq->cap - 1; /* one less to avoid cidx = pidx */ eq->pidx = eq->cidx = 0; From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 22:16:29 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC677106566B; Sat, 23 Jun 2012 22:16:28 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 62C888FC0A; Sat, 23 Jun 2012 22:16:28 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.4/8.14.4/ALCHEMY.FRANKEN.DE) with ESMTP id q5NMGQKn045015; Sun, 24 Jun 2012 00:16:27 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.4/8.14.4/Submit) id q5NMGQGg045014; Sun, 24 Jun 2012 00:16:26 +0200 (CEST) (envelope-from marius) Date: Sun, 24 Jun 2012 00:16:26 +0200 From: Marius Strobl To: John Baldwin Message-ID: <20120623221626.GH69382@alchemy.franken.de> References: <201206131504.q5DF4opt031336@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201206131504.q5DF4opt031336@svn.freebsd.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237008 - head/sys/dev/pci X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 22:16:29 -0000 On Wed, Jun 13, 2012 at 03:04:50PM +0000, John Baldwin wrote: > Author: jhb > Date: Wed Jun 13 15:04:50 2012 > New Revision: 237008 > URL: http://svn.freebsd.org/changeset/base/237008 > > Log: > Fix a couple of bugs that prevented windows in PCI-PCI bridges from > growing "downward" (moving the start address down). First, an off by > one error caused the end address to be moved down an extra alignment > chunk unnecessarily. Second, when aligning the new candidate starting > address, the wrong bits were masked off. > Unfortunately, this now panics a sparc64 machine on the first attempt to use a grown resource via bus_space(9) for me: pcib3: at device 0.0 on pci2 pcib2: allocated I/O port range (0x1000-0x1fff) for rid 1c of pcib3 pcib2: allocated memory range (0x200000-0x3ffffff) for rid 20 of pcib3 pcib3: domain 0 pcib3: secondary bus 5 pcib3: subordinate bus 5 pcib3: I/O decode 0x1000-0x1fff pcib3: memory decode 0x200000-0x3ffffff pcib3: no prefetched decode pcib3: Subtractively decoded bridge. <...> pci3: on pcib3 <...> isab0: at device 30.0 on pci3 isa0: on isab0 <...> rtc0: at port 0x70-0x73 on isa0 pcib3: attempting to grow I/O port window for (0x70-0x73,0x4) front candidate range: 0x70-0x73 pcib3: grew I/O port window to 0x70-0x1fff panic: start address is not aligned Alternatively, this may also be a data access trap, which also indicates that some invalid address being used for the access. before: rtc0: at port 0x70-0x73 on isa0 pcib3: attempting to grow I/O port window for (0x70-0x73,0x4) pcib2: allocated I/O port range (0x70-0x73) for rid 0 of rtc0 Shouldn't a subtractively decoded resource actually be outside of the window of the parent PCI-PCI bridge, i.e. it seems we shouldn't try to grow the window in that case? The below patch fixes this for me, I'm not sure whether that actually is the right approach though. Marius Index: pci_pci.c =================================================================== --- pci_pci.c (revision 237511) +++ pci_pci.c (working copy) @@ -1038,7 +1038,7 @@ pcib_alloc_resource(device_t dev, device_t child, case SYS_RES_IOPORT: r = pcib_suballoc_resource(sc, &sc->io, child, type, rid, start, end, count, flags); - if (r != NULL) + if (r != NULL || (sc->flags & PCIB_SUBTRACTIVE) != 0) break; if (pcib_grow_window(sc, &sc->io, type, start, end, count, flags) == 0) @@ -1062,7 +1062,7 @@ pcib_alloc_resource(device_t dev, device_t child, } r = pcib_suballoc_resource(sc, &sc->mem, child, type, rid, start, end, count, flags); - if (r != NULL) + if (r != NULL || (sc->flags & PCIB_SUBTRACTIVE) != 0) break; if (flags & RF_PREFETCHABLE) { if (pcib_grow_window(sc, &sc->pmem, type, start, end, From owner-svn-src-head@FreeBSD.ORG Sat Jun 23 22:54:26 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 499741065672; Sat, 23 Jun 2012 22:54:26 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 34AE88FC0C; Sat, 23 Jun 2012 22:54:26 +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 q5NMsQkk069427; Sat, 23 Jun 2012 22:54:26 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5NMsPGR069425; Sat, 23 Jun 2012 22:54:26 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201206232254.q5NMsPGR069425@svn.freebsd.org> From: Alan Cox Date: Sat, 23 Jun 2012 22:54:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237513 - head/sys/amd64/amd64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 22:54:26 -0000 Author: alc Date: Sat Jun 23 22:54:25 2012 New Revision: 237513 URL: http://svn.freebsd.org/changeset/base/237513 Log: Introduce reserve_pv_entry() and use it in pmap_pv_demote_pde(). In order to add PV list locking to pmap_pv_demote_pde(), it is necessary to change the way that pmap_pv_demote_pde() allocates PV entries. Specifically, once pmap_pv_demote_pde() begins modifying the PV lists, it can't allocate any new PV chunks, because that could require the PV list lock to be dropped. So, all necessary PV chunks must be allocated in advance. To my surprise, this new approach is a few percent faster than the old one. Modified: head/sys/amd64/amd64/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Sat Jun 23 22:12:27 2012 (r237512) +++ head/sys/amd64/amd64/pmap.c Sat Jun 23 22:54:25 2012 (r237513) @@ -256,6 +256,8 @@ static caddr_t crashdumpmap; static void free_pv_chunk(struct pv_chunk *pc); static void free_pv_entry(pmap_t pmap, pv_entry_t pv); static pv_entry_t get_pv_entry(pmap_t pmap, boolean_t try); +static int popcnt_pc_map_elem(uint64_t elem); +static void reserve_pv_entry(pmap_t pmap, int needed); static void pmap_pv_demote_pde(pmap_t pmap, vm_offset_t va, vm_paddr_t pa); static boolean_t pmap_pv_insert_pde(pmap_t pmap, vm_offset_t va, vm_paddr_t pa, struct rwlock **lockp); @@ -2331,6 +2333,85 @@ retry: } /* + * Returns the number of one bits within the given PV chunk map element. + */ +static int +popcnt_pc_map_elem(uint64_t elem) +{ + int count; + + /* + * This simple method of counting the one bits performs well because + * the given element typically contains more zero bits than one bits. + */ + count = 0; + for (; elem != 0; elem &= elem - 1) + count++; + return (count); +} + +/* + * Ensure that the number of spare PV entries in the specified pmap meets or + * exceeds the given count, "needed". + */ +static void +reserve_pv_entry(pmap_t pmap, int needed) +{ + struct pch new_tail; + struct pv_chunk *pc; + int avail, free; + vm_page_t m; + + rw_assert(&pvh_global_lock, RA_LOCKED); + PMAP_LOCK_ASSERT(pmap, MA_OWNED); + + /* + * Newly allocated PV chunks must be stored in a private list until + * the required number of PV chunks have been allocated. Otherwise, + * pmap_pv_reclaim() could recycle one of these chunks. In contrast, + * these chunks must be added to the pmap upon allocation. + */ + TAILQ_INIT(&new_tail); +retry: + avail = 0; + TAILQ_FOREACH(pc, &pmap->pm_pvchunk, pc_list) { + free = popcnt_pc_map_elem(pc->pc_map[0]); + free += popcnt_pc_map_elem(pc->pc_map[1]); + free += popcnt_pc_map_elem(pc->pc_map[2]); + if (free == 0) + break; + avail += free; + if (avail >= needed) + break; + } + for (; avail < needed; avail += _NPCPV) { + m = vm_page_alloc(NULL, 0, VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ | + VM_ALLOC_WIRED); + if (m == NULL) { + m = pmap_pv_reclaim(pmap); + if (m == NULL) + goto retry; + } + PV_STAT(atomic_add_int(&pc_chunk_count, 1)); + PV_STAT(atomic_add_int(&pc_chunk_allocs, 1)); + dump_add_page(m->phys_addr); + pc = (void *)PHYS_TO_DMAP(m->phys_addr); + pc->pc_pmap = pmap; + pc->pc_map[0] = PC_FREE0; + pc->pc_map[1] = PC_FREE1; + pc->pc_map[2] = PC_FREE2; + TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list); + TAILQ_INSERT_TAIL(&new_tail, pc, pc_lru); + PV_STAT(atomic_add_int(&pv_entry_spare, _NPCPV)); + } + if (!TAILQ_EMPTY(&new_tail)) { + mtx_lock(&pv_chunks_mutex); + TAILQ_CONCAT(&pv_chunks, &new_tail, pc_lru); + mtx_unlock(&pv_chunks_mutex); + } +} + +/* * First find and then remove the pv entry for the specified pmap and virtual * address from the specified pv list. Returns the pv entry if found and NULL * otherwise. This operation can be performed on pv lists for either 4KB or @@ -2367,6 +2448,7 @@ pmap_pv_demote_pde(pmap_t pmap, vm_offse rw_assert(&pvh_global_lock, RA_WLOCKED); KASSERT((pa & PDRMASK) == 0, ("pmap_pv_demote_pde: pa is not 2mpage aligned")); + reserve_pv_entry(pmap, NPTEPG - 1); /* * Transfer the 2mpage's pv entry for this mapping to the first @@ -2385,7 +2467,7 @@ pmap_pv_demote_pde(pmap_t pmap, vm_offse KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("pmap_pv_demote_pde: page %p is not managed", m)); va += PAGE_SIZE; - pv = get_pv_entry(pmap, FALSE); + pv = get_pv_entry(pmap, TRUE); pv->pv_va = va; TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_list); } while (va < va_last);