From owner-svn-src-head@FreeBSD.ORG Sun Apr 3 03:26:12 2011 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 810A91065674; Sun, 3 Apr 2011 03:26:12 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 66F358FC18; Sun, 3 Apr 2011 03:26:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p333QCHC000943; Sun, 3 Apr 2011 03:26:12 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p333QCoV000940; Sun, 3 Apr 2011 03:26:12 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201104030326.p333QCoV000940@svn.freebsd.org> From: Marcel Moolenaar Date: Sun, 3 Apr 2011 03:26:12 +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: r220283 - head/sys/boot/ia64/ski 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, 03 Apr 2011 03:26:12 -0000 Author: marcel Date: Sun Apr 3 03:26:12 2011 New Revision: 220283 URL: http://svn.freebsd.org/changeset/base/220283 Log: Make the ski loader functional again after the previous set of changes. Modified: head/sys/boot/ia64/ski/efi_stub.c head/sys/boot/ia64/ski/skimd.c Modified: head/sys/boot/ia64/ski/efi_stub.c ============================================================================== --- head/sys/boot/ia64/ski/efi_stub.c Sat Apr 2 21:52:58 2011 (r220282) +++ head/sys/boot/ia64/ski/efi_stub.c Sun Apr 3 03:26:12 2011 (r220283) @@ -223,39 +223,37 @@ ResetSystem(enum efi_reset type, efi_sta void efi_stub_init(struct bootinfo *bi) { - struct efi_md *memp; + static struct efi_md memmap[4]; /* Describe the SKI memory map. */ - bi->bi_memmap = (u_int64_t)(bi + 1); - bi->bi_memmap_size = 4 * sizeof(struct efi_md); + bi->bi_memmap = (uintptr_t)(void *)memmap; + bi->bi_memmap_size = sizeof(memmap); bi->bi_memdesc_size = sizeof(struct efi_md); bi->bi_memdesc_version = 1; - memp = (struct efi_md *)bi->bi_memmap; - - memp[0].md_type = EFI_MD_TYPE_PALCODE; - memp[0].md_phys = 0x100000; - memp[0].md_virt = NULL; - memp[0].md_pages = (4L*1024*1024)>>12; - memp[0].md_attr = EFI_MD_ATTR_WB | EFI_MD_ATTR_RT; - - memp[1].md_type = EFI_MD_TYPE_FREE; - memp[1].md_phys = 5L*1024*1024; - memp[1].md_virt = NULL; - memp[1].md_pages = (128L*1024*1024)>>12; - memp[1].md_attr = EFI_MD_ATTR_WB; - - memp[2].md_type = EFI_MD_TYPE_FREE; - memp[2].md_phys = 4L*1024*1024*1024; - memp[2].md_virt = NULL; - memp[2].md_pages = (64L*1024*1024)>>12; - memp[2].md_attr = EFI_MD_ATTR_WB; - - memp[3].md_type = EFI_MD_TYPE_IOPORT; - memp[3].md_phys = 0xffffc000000; - memp[3].md_virt = NULL; - memp[3].md_pages = (64L*1024*1024)>>12; - memp[3].md_attr = EFI_MD_ATTR_UC; + memmap[0].md_type = EFI_MD_TYPE_PALCODE; + memmap[0].md_phys = 0x100000; + memmap[0].md_virt = NULL; + memmap[0].md_pages = (1L*1024*1024)>>12; + memmap[0].md_attr = EFI_MD_ATTR_WB | EFI_MD_ATTR_RT; + + memmap[1].md_type = EFI_MD_TYPE_FREE; + memmap[1].md_phys = 4L*1024*1024; + memmap[1].md_virt = NULL; + memmap[1].md_pages = (128L*1024*1024)>>12; + memmap[1].md_attr = EFI_MD_ATTR_WB; + + memmap[2].md_type = EFI_MD_TYPE_FREE; + memmap[2].md_phys = 4L*1024*1024*1024; + memmap[2].md_virt = NULL; + memmap[2].md_pages = (64L*1024*1024)>>12; + memmap[2].md_attr = EFI_MD_ATTR_WB; + + memmap[3].md_type = EFI_MD_TYPE_IOPORT; + memmap[3].md_phys = 0xffffc000000; + memmap[3].md_virt = NULL; + memmap[3].md_pages = (64L*1024*1024)>>12; + memmap[3].md_attr = EFI_MD_ATTR_UC; bi->bi_systab = (u_int64_t)&efi_systab; } Modified: head/sys/boot/ia64/ski/skimd.c ============================================================================== --- head/sys/boot/ia64/ski/skimd.c Sat Apr 2 21:52:58 2011 (r220282) +++ head/sys/boot/ia64/ski/skimd.c Sun Apr 3 03:26:12 2011 (r220283) @@ -43,9 +43,9 @@ ia64_platform_alloc(vm_offset_t va, vm_s vm_paddr_t pa; if (va == 0) - pa = 1024 * 1024; + pa = 2 * 1024 * 1024; else - pa = (va - IA64_PBVM_BASE) + (64 * 1024 * 1024); + pa = (va - IA64_PBVM_BASE) + (32 * 1024 * 1024); return (pa); } @@ -65,7 +65,9 @@ ia64_platform_bootinfo(struct bootinfo * sal_stub_init(); acpi_stub_init(); - *res = &bootinfo; + if (IS_LEGACY_KERNEL()) + *res = &bootinfo; + return (0); } From owner-svn-src-head@FreeBSD.ORG Sun Apr 3 03:42:42 2011 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 7C16A1065670; Sun, 3 Apr 2011 03:42:42 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6C4218FC0A; Sun, 3 Apr 2011 03:42:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p333ggcn001400; Sun, 3 Apr 2011 03:42:42 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p333ggvN001394; Sun, 3 Apr 2011 03:42:42 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <201104030342.p333ggvN001394@svn.freebsd.org> From: Edwin Groothuis Date: Sun, 3 Apr 2011 03:42: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: r220286 - head/contrib/tzdata 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, 03 Apr 2011 03:42:42 -0000 Author: edwin Date: Sun Apr 3 03:42:42 2011 New Revision: 220286 URL: http://svn.freebsd.org/changeset/base/220286 Log: MFV of tzdata2011e: Change for Africa/Casablanca: - The 3rd april 2011 at 00:00:00, [it] will be 3rd april 1:00:00 - The 31th july 2011 at 00:59:59, [it] will be 31th July 00:00:00 Update for SouthAmerica/Chili: - Chile's clocks will go back an hour this year on the 7th of May instead of this Saturday. They will go forward again the 3rd Saturday in August, not in October as they have since 1968. This is a pilot plan which will be reevaluated in 2012. Modified: head/contrib/tzdata/africa head/contrib/tzdata/asia head/contrib/tzdata/europe head/contrib/tzdata/southamerica head/contrib/tzdata/zone.tab Directory Properties: head/contrib/tzdata/ (props changed) Modified: head/contrib/tzdata/africa ============================================================================== --- head/contrib/tzdata/africa Sun Apr 3 03:40:57 2011 (r220285) +++ head/contrib/tzdata/africa Sun Apr 3 03:42:42 2011 (r220286) @@ -1,5 +1,5 @@ #
-# @(#)africa	8.28
+# @(#)africa	8.30
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -712,6 +712,48 @@ Zone	Indian/Mayotte	3:00:56 -	LMT	1911 J
 # http://www.timeanddate.com/news/time/morocco-starts-dst-2010.html
 # 
 
+# From Dan Abitol (2011-03-30):
+# ...Rules for Africa/Casablanca are the following (24h format)
+# The 3rd april 2011 at 00:00:00, [it] will be 3rd april 1:00:00
+# The 31th july 2011 at 00:59:59,  [it] will be 31th July 00:00:00
+# ...Official links of change in morocco
+# The change was broadcast on the FM Radio
+# I ve called ANRT (telecom regulations in Morocco) at
+# +212.537.71.84.00
+# 
+# http://www.anrt.net.ma/fr/
+# 
+# They said that
+# 
+# http://www.map.ma/fr/sections/accueil/l_heure_legale_au_ma/view
+# 
+# is the official publication to look at.
+# They said that the decision was already taken.
+#
+# More articles in the press
+# 
+# http://www.yabiladi.com/articles/details/5058/secret-l-heure-d-ete-maroc-lev
+# 
+# e.html
+# 
+# http://www.lematin.ma/Actualite/Express/Article.asp?id=148923
+# 
+# 
+# http://www.lavieeco.com/actualite/Le-Maroc-passe-sur-GMT%2B1-a-partir-de-dim
+# anche-prochain-5538.html
+# 
+
+# From Petr Machata (2011-03-30):
+# They have it written in English here:
+# 
+# http://www.map.ma/eng/sections/home/morocco_to_spring_fo/view
+# 
+#
+# It says there that "Morocco will resume its standard time on July 31,
+# 2011 at midnight." Now they don't say whether they mean midnight of
+# wall clock time (i.e. 11pm UTC), but that's what I would assume. It has
+# also been like that in the past.
+
 # RULE	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 
 Rule	Morocco	1939	only	-	Sep	12	 0:00	1:00	S
@@ -735,6 +777,8 @@ Rule	Morocco	2009	only	-	Jun	 1	 0:00	1:
 Rule	Morocco	2009	only	-	Aug	 21	 0:00	0	-
 Rule	Morocco	2010	only	-	May	 2	 0:00	1:00	S
 Rule	Morocco	2010	only	-	Aug	 8	 0:00	0	-
+Rule	Morocco	2011	only	-	Apr	 3	 0:00	1:00	S
+Rule	Morocco	2011	only	-	Jul	 31	 0	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Africa/Casablanca	-0:30:20 -	LMT	1913 Oct 26
 			 0:00	Morocco	WE%sT	1984 Mar 16

Modified: head/contrib/tzdata/asia
==============================================================================
--- head/contrib/tzdata/asia	Sun Apr  3 03:40:57 2011	(r220285)
+++ head/contrib/tzdata/asia	Sun Apr  3 03:42:42 2011	(r220286)
@@ -1,4 +1,4 @@
-# @(#)asia	8.62
+# @(#)asia	8.64
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 

Modified: head/contrib/tzdata/europe
==============================================================================
--- head/contrib/tzdata/europe	Sun Apr  3 03:40:57 2011	(r220285)
+++ head/contrib/tzdata/europe	Sun Apr  3 03:42:42 2011	(r220286)
@@ -1,5 +1,5 @@
 # 
-# @(#)europe	8.28
+# @(#)europe	8.31
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 

Modified: head/contrib/tzdata/southamerica
==============================================================================
--- head/contrib/tzdata/southamerica	Sun Apr  3 03:40:57 2011	(r220285)
+++ head/contrib/tzdata/southamerica	Sun Apr  3 03:42:42 2011	(r220286)
@@ -1,5 +1,5 @@
 # 
-# @(#)southamerica	8.45
+# @(#)southamerica	8.47
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -1171,6 +1171,19 @@ Zone America/Rio_Branco	-4:31:12 -	LMT	1
 # From Arthur David Olson (2011-03-02):
 # The emol.com article mentions a water shortage as the cause of the
 # postponement, which may mean that it's not a permanent change.
+
+# From Glenn Eychaner (2011-03-28):
+# The article:
+# 
+# http://diario.elmercurio.com/2011/03/28/_portada/_portada/noticias/7565897A-CA86-49E6-9E03-660B21A4883E.htm?id=3D{7565897A-CA86-49E6-9E03-660B21A4883E}
+# 
+#
+# In English:
+# Chile's clocks will go back an hour this year on the 7th of May instead
+# of this Saturday. They will go forward again the 3rd Saturday in
+# August, not in October as they have since 1968. This is a pilot plan
+# which will be reevaluated in 2012.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Chile	1927	1932	-	Sep	 1	0:00	1:00	S
 Rule	Chile	1928	1932	-	Apr	 1	0:00	0	-
@@ -1200,13 +1213,16 @@ Rule	Chile	1997	only	-	Mar	30	3:00u	0	-
 Rule	Chile	1998	only	-	Mar	Sun>=9	3:00u	0	-
 Rule	Chile	1998	only	-	Sep	27	4:00u	1:00	S
 Rule	Chile	1999	only	-	Apr	 4	3:00u	0	-
-Rule	Chile	1999	max	-	Oct	Sun>=9	4:00u	1:00	S
+Rule	Chile	1999	2010	-	Oct	Sun>=9	4:00u	1:00	S
+Rule	Chile	2011	only	-	Aug	Sun>=16	4:00u	1:00	S
+Rule	Chile	2012	max	-	Oct	Sun>=9	4:00u	1:00	S
 Rule	Chile	2000	2007	-	Mar	Sun>=9	3:00u	0	-
 # N.B.: the end of March 29 in Chile is March 30 in Universal time,
 # which is used below in specifying the transition.
 Rule	Chile	2008	only	-	Mar	30	3:00u	0	-
 Rule	Chile	2009	only	-	Mar	Sun>=9	3:00u	0	-
-Rule	Chile	2010	2011	-	Apr	Sun>=1	3:00u	0	-
+Rule	Chile	2010	only	-	Apr	Sun>=1	3:00u	0	-
+Rule	Chile	2011	only	-	May	Sun>=2	3:00u	0	-
 Rule	Chile	2012	max	-	Mar	Sun>=9	3:00u	0	-
 # IATA SSIM anomalies: (1992-02) says 1992-03-14;
 # (1996-09) says 1998-03-08.  Ignore these.

Modified: head/contrib/tzdata/zone.tab
==============================================================================
--- head/contrib/tzdata/zone.tab	Sun Apr  3 03:40:57 2011	(r220285)
+++ head/contrib/tzdata/zone.tab	Sun Apr  3 03:42:42 2011	(r220286)
@@ -1,5 +1,5 @@
 # 
-# @(#)zone.tab	8.41
+# @(#)zone.tab	8.43
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 #

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 05:09:26 2011
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 3DE2B106566B;
	Sun,  3 Apr 2011 05:09:26 +0000 (UTC)
	(envelope-from marcel@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2DA638FC14;
	Sun,  3 Apr 2011 05:09:26 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3359QY9003519;
	Sun, 3 Apr 2011 05:09:26 GMT (envelope-from marcel@svn.freebsd.org)
Received: (from marcel@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3359QZi003516;
	Sun, 3 Apr 2011 05:09:26 GMT (envelope-from marcel@svn.freebsd.org)
Message-Id: <201104030509.p3359QZi003516@svn.freebsd.org>
From: Marcel Moolenaar 
Date: Sun, 3 Apr 2011 05:09: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: r220290 - in head/sys/boot: common sparc64/loader
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, 03 Apr 2011 05:09:26 -0000

Author: marcel
Date: Sun Apr  3 05:09:25 2011
New Revision: 220290
URL: http://svn.freebsd.org/changeset/base/220290

Log:
  Revert rev 165325. The arch_maphint interface hasn't been in use for
  more than 4 years.

Modified:
  head/sys/boot/common/bootstrap.h
  head/sys/boot/sparc64/loader/main.c

Modified: head/sys/boot/common/bootstrap.h
==============================================================================
--- head/sys/boot/common/bootstrap.h	Sun Apr  3 03:45:45 2011	(r220289)
+++ head/sys/boot/common/bootstrap.h	Sun Apr  3 05:09:25 2011	(r220290)
@@ -296,8 +296,6 @@ struct arch_switch
     /* Perform ISA byte port I/O (only for systems with ISA) */
     int		(*arch_isainb)(int port);
     void	(*arch_isaoutb)(int port, int value);
-    /* Pass in initial kernel memory size */
-    void        (*arch_maphint)(vm_offset_t va, size_t len);	
 };
 extern struct arch_switch archsw;
 

Modified: head/sys/boot/sparc64/loader/main.c
==============================================================================
--- head/sys/boot/sparc64/loader/main.c	Sun Apr  3 03:45:45 2011	(r220289)
+++ head/sys/boot/sparc64/loader/main.c	Sun Apr  3 05:09:25 2011	(r220290)
@@ -107,7 +107,6 @@ extern vm_offset_t md_load(char *, vm_of
 static int sparc64_autoload(void);
 static ssize_t sparc64_readin(const int, vm_offset_t, const size_t);
 static ssize_t sparc64_copyin(const void *, vm_offset_t, size_t);
-static void sparc64_maphint(vm_offset_t, size_t);
 static vm_offset_t claim_virt(vm_offset_t, size_t, int);
 static vm_offset_t alloc_phys(size_t, int);
 static int map_phys(int, size_t, vm_offset_t, vm_offset_t);
@@ -296,50 +295,6 @@ sparc64_copyin(const void *src, vm_offse
 	return (len);
 }
 
-static void
-sparc64_maphint(vm_offset_t va, size_t len)
-{
-	vm_paddr_t pa;
-	vm_offset_t mva;
-	size_t size;
-	int i, free_excess = 0;
-
-	if (!is_sun4v)
-		return;
-
-	if (tlb_store[va >> 22].te_pa != -1)
-		return;
-
-	/* round up to nearest 4MB page */
-	size = (len + PAGE_MASK_4M) & ~PAGE_MASK_4M;
-#if 0
-	pa = alloc_phys(PAGE_SIZE_256M, PAGE_SIZE_256M);
-
-	if (pa != -1)
-		free_excess = 1;
-	else
-#endif
-		pa = alloc_phys(size, PAGE_SIZE_256M);
-	if (pa == -1)
-		pa = alloc_phys(size, PAGE_SIZE_4M);
-	if (pa == -1)
-		panic("%s: out of memory", __func__);
-
-	for (i = 0; i < size; i += PAGE_SIZE_4M) {
-		mva = claim_virt(va + i, PAGE_SIZE_4M, 0);
-		if (mva != (va + i))
-			panic("%s: can't claim virtual page "
-			    "(wanted %#lx, got %#lx)",
-			    __func__, va, mva);
-
-		tlb_store[mva >> 22].te_pa = pa + i;
-		if (map_phys(-1, PAGE_SIZE_4M, mva, pa + i) != 0)
-			printf("%s: can't map physical page\n", __func__);
-	}
-	if (free_excess)
-		release_phys(pa, PAGE_SIZE_256M);
-}
-
 /*
  * other MD functions
  */
@@ -809,7 +764,6 @@ main(int (*openfirm)(void *))
 	archsw.arch_copyout = ofw_copyout;
 	archsw.arch_readin = sparc64_readin;
 	archsw.arch_autoload = sparc64_autoload;
-	archsw.arch_maphint = sparc64_maphint;
 
 	if (init_heap() == (vm_offset_t)-1)
 		OF_exit();

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 11:55:48 2011
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 AC05E1065670;
	Sun,  3 Apr 2011 11:55: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 7F1808FC08;
	Sun,  3 Apr 2011 11:55:48 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p33BtmEZ020914;
	Sun, 3 Apr 2011 11:55:48 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p33BtmCt020911;
	Sun, 3 Apr 2011 11:55:48 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104031155.p33BtmCt020911@svn.freebsd.org>
From: Adrian Chadd 
Date: Sun, 3 Apr 2011 11:55: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: r220292 - in head/sys: conf dev/nvram2env
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, 03 Apr 2011 11:55:48 -0000

Author: adrian
Date: Sun Apr  3 11:55:48 2011
New Revision: 220292
URL: http://svn.freebsd.org/changeset/base/220292

Log:
  Import nvram2env, a device driver which imports various NVRAM-style
  environments into the kernel environment.
  
  The eventual aim is to replace these with specific drivers for
  the various bootloaders (redboot, uboot, etc.) This however will
  work for the time being until it can be properly addressed.
  
  Submitted by: Aleksandr Rybalko 

Added:
  head/sys/dev/nvram2env/
  head/sys/dev/nvram2env/nvram2env.c   (contents, props changed)
Modified:
  head/sys/conf/files.mips

Modified: head/sys/conf/files.mips
==============================================================================
--- head/sys/conf/files.mips	Sun Apr  3 08:44:57 2011	(r220291)
+++ head/sys/conf/files.mips	Sun Apr  3 11:55:48 2011	(r220292)
@@ -105,3 +105,5 @@ dev/siba/siba_pcib.c		optional	siba pci
 
 dev/hwpmc/hwpmc_mips.c		optional hwpmc
 dev/hwpmc/hwpmc_mips24k.c	optional hwpmc
+
+dev/nvram2env/nvram2env.c	optional	nvram2env

Added: head/sys/dev/nvram2env/nvram2env.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/nvram2env/nvram2env.c	Sun Apr  3 11:55:48 2011	(r220292)
@@ -0,0 +1,317 @@
+/*-
+ * Copyright (c) 2010 Aleksandr Rybalko.
+ * 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.
+ */
+
+/*
+ * Pseudo driver to copy the NVRAM settings from various sources
+ * into the kernel environment.
+ *
+ * Drivers (such as ethernet devices) can then use environment
+ * variables to set default parameters.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+#define nvram2env_read_1(sc, reg)				\
+	bus_space_read_1((sc)->sc_bt, (sc)->sc_bh,(reg))
+
+#define nvram2env_read_2(sc, reg)				\
+	bus_space_read_2((sc)->sc_bt, (sc)->sc_bh,(reg))
+
+#define nvram2env_read_4(sc, reg)				\
+	bus_space_read_4((sc)->sc_bt, (sc)->sc_bh,(reg))
+
+#define nvram2env_write_1(sc, reg, val)			\
+	bus_space_write_1((sc)->sc_bt, (sc)->sc_bh,	\
+			 (reg), (val))
+
+#define nvram2env_write_2(sc, reg, val)			\
+	bus_space_write_2((sc)->sc_bt, (sc)->sc_bh,	\
+			 (reg), (val))
+
+#define nvram2env_write_4(sc, reg, val)			\
+	bus_space_write_4((sc)->sc_bt, (sc)->sc_bh,	\
+			 (reg), (val))
+
+struct nvram2env_softc {
+	bus_space_tag_t bst;
+	bus_space_handle_t bsh;
+	bus_addr_t addr;
+	int need_swap;
+	uint32_t sig;
+	uint32_t flags;
+#define NVRAM_FLAGS_NOCHECK	0x0001	/* Do not check(CRC or somthing else)*/
+#define NVRAM_FLAGS_GENERIC	0x0002	/* Format Generic, skip 4b and read */
+#define NVRAM_FLAGS_BROADCOM	0x0004	/* Format Broadcom, use struct nvram */
+#define NVRAM_FLAGS_UBOOT	0x0008	/* Format Generic, skip 4b of CRC and read */
+	uint32_t maxsize;
+	uint32_t crc;
+};
+
+static int	nvram2env_attach(device_t);
+static int	nvram2env_probe(device_t);
+
+#define NVRAM_MAX_SIZE 0x10000
+
+static void
+nvram2env_identify(driver_t * drv, device_t parent)
+{
+	int i, ivar;
+
+	for (i = 0; !resource_int_value("nvram", i, "base", &ivar); i++)
+		BUS_ADD_CHILD(parent, 0, "nvram2env", i);
+}
+
+static int
+nvram2env_probe(device_t dev)
+{
+	uint32_t i, ivar, sig;
+	struct nvram2env_softc * sc = device_get_softc(dev);
+	sc->bst = mips_bus_space_generic;
+
+	if (resource_int_value("nvram", device_get_unit(dev), "sig",
+	    &sc->sig) != 0 || sc->sig == 0)
+		sc->sig = 0x48534c46;
+
+	if (resource_int_value("nvram", device_get_unit(dev), "maxsize",
+	    &sc->maxsize) != 0 || sc->maxsize == 0)
+		sc->maxsize = NVRAM_MAX_SIZE;
+
+	if (resource_int_value("nvram", device_get_unit(dev), "flags", 
+	    &sc->flags) != 0 || sc->flags == 0)
+		sc->flags = NVRAM_FLAGS_GENERIC;
+
+
+	for (i = 0; i < 2; i ++)
+	{
+		if (resource_int_value("nvram", device_get_unit(dev), 
+			(!i)?"base":"fallbackbase", &ivar) != 0 ||
+		    ivar == 0)
+			continue;
+
+		sc->addr = MIPS_PHYS_TO_KSEG1(ivar);
+
+		if (bootverbose)
+			device_printf(dev, "base=0x%08x sig=0x%08x "
+			    "maxsize=0x%08x flags=0x%08x\n",
+			    sc->addr, sc->sig, sc->maxsize, sc->flags);
+
+		if (bus_space_map(sc->bst, sc->addr, sc->maxsize, 0,
+		    &sc->bsh) != 0)
+			continue;
+
+		sig = bus_space_read_4(sc->bst, sc->bsh, 0);
+		if ( sig == sc->sig /*FLSH*/)
+		{
+			device_printf(dev, "Found NVRAM at %#x\n", 
+			    (uint32_t)ivar);
+			sc->need_swap = 0;
+			goto unmap_done;
+		}
+		else if ( htole32(sig) == sc->sig /*HSLF*/)
+		{
+			device_printf(dev, "Found NVRAM at %#x\n", 
+			    (uint32_t)ivar);
+			sc->need_swap = 1;
+			goto unmap_done;
+		} else if (sc->flags & NVRAM_FLAGS_UBOOT) {
+			device_printf(dev, "Use NVRAM at %#x\n", 
+			    (uint32_t)ivar);
+			sc->crc = sig;
+			goto unmap_done;
+		}
+		bus_space_unmap(sc->bst, sc->bsh, NVRAM_MAX_SIZE);
+	}
+	sc->bst = 0;
+	sc->bsh = 0;
+	sc->addr = 0;
+	return (ENXIO);
+
+unmap_done:
+	bus_space_unmap(sc->bst, sc->bsh, NVRAM_MAX_SIZE);
+	device_set_desc(dev, "NVRAM to ENV pseudo-device");
+	return (BUS_PROBE_SPECIFIC);
+
+}
+
+struct nvram {
+	u_int32_t sig;
+	u_int32_t size;
+	u_int32_t unknown1;
+	u_int32_t unknown2;
+	u_int32_t unknown3;
+	char data[];
+};
+
+static uint32_t read_4(struct nvram2env_softc * sc, int offset) 
+{
+	if (sc->need_swap) 
+		return (bswap32(bus_space_read_4(sc->bst, sc->bsh, offset)));
+	else
+		return (bus_space_read_4(sc->bst, sc->bsh, offset));
+}
+
+
+static int
+nvram2env_attach(device_t dev)
+{
+	struct nvram2env_softc * sc = device_get_softc(dev);
+	struct nvram * nv;
+	char *pair, *value, *assign;
+	uint32_t sig, size, i;
+
+	if (sc->bst == 0 || sc->addr == 0)
+		return (ENXIO);
+
+	if (bus_space_map(sc->bst, sc->addr, NVRAM_MAX_SIZE, 0,
+		&sc->bsh) != 0)
+		return (ENXIO);
+
+	sig  = read_4(sc, 0);
+	size = read_4(sc, 4);
+#if 1
+	if (bootverbose)
+		device_printf(dev, " size=0x%05x maxsize=0x%05x\n", size, sc->maxsize);
+#endif
+	size = (size > sc->maxsize)?sc->maxsize:size;
+
+
+	if (sig == sc->sig || (sc->flags & NVRAM_FLAGS_UBOOT))
+	{
+
+		/* align and shift size to 32bit size*/
+		size += 3;
+		size >>= 2;
+
+		nv = malloc(size<<2, M_DEVBUF, M_WAITOK | M_ZERO);
+		if (!nv)
+			return (ENOMEM);
+
+		for (i = 0; i < size; i ++)
+			((uint32_t *)nv)[i] = read_4(sc, i<<2);
+
+		if (sc->flags & NVRAM_FLAGS_BROADCOM) {
+			device_printf(dev, "sig = %#x\n",  nv->sig);
+			device_printf(dev, "size = %#x\n", nv->size);
+		}
+
+		if (!(sc->flags & NVRAM_FLAGS_NOCHECK)) {
+			/* TODO: need checksum verification */
+		}
+
+		if (sc->flags & NVRAM_FLAGS_GENERIC)
+			pair = (char*)nv+4;
+		if (sc->flags & NVRAM_FLAGS_UBOOT)
+			pair = (char*)nv+4;
+		else if (sc->flags & NVRAM_FLAGS_BROADCOM)
+			pair = (char*)nv+20;
+		else
+			pair = (char*)nv+4;
+
+		for ( ; 
+		    (u_int32_t)pair < ((u_int32_t)nv + size - 4); 
+		    pair = pair + strlen(pair) + 1 + strlen(value) + 1 ) {
+
+			if (pair && strlen(pair)) {
+
+#if 0
+				printf("ENV: %s\n", pair);
+#endif
+				/* hint.nvram.0. */
+				assign = strchr(pair,'=');
+				assign[0] = '\0';
+				value = assign+1;
+#if 1
+				if (bootverbose)
+					printf("ENV: %s=%s\n", pair, value);
+#endif
+				setenv(pair, value);
+
+				if (strcasecmp(pair, "WAN_MAC_ADDR") == 0) {
+					/* Alias for MAC address of eth0 */
+					if (bootverbose)
+						printf("ENV: aliasing "
+						    "WAN_MAC_ADDR to ethaddr"
+						    " = %s\n",  value);
+					setenv("ethaddr", value);
+				}
+				else if (strcasecmp(pair, "LAN_MAC_ADDR") == 0){
+					/* Alias for MAC address of eth1 */
+					if (bootverbose)
+						printf("ENV: aliasing "
+						    "LAN_MAC_ADDR to eth1addr"
+						    " = %s\n",  value);
+					setenv("eth1addr", value);
+				}
+
+				if (strcmp(pair, "bootverbose") == 0)
+					bootverbose = strtoul(value, 0, 0);
+				if (strcmp(pair, "boothowto"  ) == 0)
+					boothowto   = strtoul(value, 0, 0);
+			}
+			else
+				break;
+		}
+		free(nv, M_DEVBUF);
+	}
+
+	bus_space_unmap(sc->bst, sc->bsh, NVRAM_MAX_SIZE);
+
+	return (0);
+}
+
+static device_method_t nvram2env_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_identify, 	nvram2env_identify),
+	DEVMETHOD(device_probe,		nvram2env_probe),
+	DEVMETHOD(device_attach,	nvram2env_attach),
+	{0, 0},
+};
+
+static driver_t nvram2env_driver = {
+	"nvram2env",
+	nvram2env_methods,
+	sizeof(struct nvram2env_softc),
+};
+static devclass_t nvram2env_devclass;
+
+DRIVER_MODULE(nvram2env, nexus, nvram2env_driver, nvram2env_devclass, 0, 0);
+

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 11:59:52 2011
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 A41CF106564A;
	Sun,  3 Apr 2011 11:59:52 +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 953CC8FC12;
	Sun,  3 Apr 2011 11:59:52 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p33BxqmA022406;
	Sun, 3 Apr 2011 11:59:52 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p33BxqUo022404;
	Sun, 3 Apr 2011 11:59:52 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104031159.p33BxqUo022404@svn.freebsd.org>
From: Adrian Chadd 
Date: Sun, 3 Apr 2011 11:59: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: r220293 - head/sys/dev/ath/ath_hal/ar9001
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, 03 Apr 2011 11:59:52 -0000

Author: adrian
Date: Sun Apr  3 11:59:52 2011
New Revision: 220293
URL: http://svn.freebsd.org/changeset/base/220293

Log:
  Add an explanation of the inivals

Modified:
  head/sys/dev/ath/ath_hal/ar9001/ar9160.ini

Modified: head/sys/dev/ath/ath_hal/ar9001/ar9160.ini
==============================================================================
--- head/sys/dev/ath/ath_hal/ar9001/ar9160.ini	Sun Apr  3 11:55:48 2011	(r220292)
+++ head/sys/dev/ath/ath_hal/ar9001/ar9160.ini	Sun Apr  3 11:59:52 2011	(r220293)
@@ -19,6 +19,7 @@
 /* Auto Generated PCI Register Writes.  Created: 05/22/08 */
 
 static const uint32_t ar9160Modes[][6] = {
+    /* Address      5G-HT20     5G-HT40     2G-HT40     2G-HT20     Turbo   */
     { 0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160, 0x000001e0 },
     { 0x00001070, 0x00000168, 0x000002d0, 0x00000318, 0x0000018c, 0x000001e0 },
     { 0x000010b0, 0x00000e60, 0x00001cc0, 0x00007c70, 0x00003e38, 0x00001180 },

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 12:02:49 2011
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 5C839106564A;
	Sun,  3 Apr 2011 12:02:49 +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 4DAC08FC08;
	Sun,  3 Apr 2011 12:02:49 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p33C2nhB023428;
	Sun, 3 Apr 2011 12:02:49 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p33C2n4j023426;
	Sun, 3 Apr 2011 12:02:49 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104031202.p33C2n4j023426@svn.freebsd.org>
From: Adrian Chadd 
Date: Sun, 3 Apr 2011 12:02: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: r220294 - head/sys/dev/ath/ath_hal/ar5416
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, 03 Apr 2011 12:02:49 -0000

Author: adrian
Date: Sun Apr  3 12:02:49 2011
New Revision: 220294
URL: http://svn.freebsd.org/changeset/base/220294

Log:
  Import a fix from the ath9k - reduce the TX FIFO size for Kite (AR9285.)

Modified:
  head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c	Sun Apr  3 11:59:52 2011	(r220293)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c	Sun Apr  3 12:02:49 2011	(r220294)
@@ -480,7 +480,15 @@ ar5416InitDMA(struct ath_hal *ah)
 	 * reduce the number of usable entries in PCU TXBUF to avoid
 	 * wrap around.
 	 */
-	OS_REG_WRITE(ah, AR_PCU_TXBUF_CTRL, AR_PCU_TXBUF_CTRL_USABLE_SIZE);
+	if (AR_SREV_KITE(ah))
+		/*
+		 * For AR9285 the number of Fifos are reduced to half.
+		 * So set the usable tx buf size also to half to
+		 * avoid data/delimiter underruns
+		 */
+		OS_REG_WRITE(ah, AR_PCU_TXBUF_CTRL, AR_9285_PCU_TXBUF_CTRL_USABLE_SIZE);
+	else
+		OS_REG_WRITE(ah, AR_PCU_TXBUF_CTRL, AR_PCU_TXBUF_CTRL_USABLE_SIZE);
 }
 
 static void

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 13:19:59 2011
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 90E4D106566B;
	Sun,  3 Apr 2011 13:19:59 +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 8198F8FC08;
	Sun,  3 Apr 2011 13:19:59 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p33DJxt5028687;
	Sun, 3 Apr 2011 13:19:59 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p33DJxjG028682;
	Sun, 3 Apr 2011 13:19:59 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104031319.p33DJxjG028682@svn.freebsd.org>
From: Adrian Chadd 
Date: Sun, 3 Apr 2011 13:19: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: r220295 - head/sys/mips/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: Sun, 03 Apr 2011 13:19:59 -0000

Author: adrian
Date: Sun Apr  3 13:19:58 2011
New Revision: 220295
URL: http://svn.freebsd.org/changeset/base/220295

Log:
  Commit configuration files for the AR913x SoC and the TP-Link WR-1043ND.
  
  The AR91XX_BASE{,.hints} files define all the common parameters for
  the AR913x SoC systems.
  
  The TP-1043ND config file adds local parameters.

Added:
  head/sys/mips/conf/AR91XX_BASE   (contents, props changed)
  head/sys/mips/conf/AR91XX_BASE.hints   (contents, props changed)
  head/sys/mips/conf/TP-WN1043ND   (contents, props changed)
  head/sys/mips/conf/TP-WN1043ND.hints   (contents, props changed)

Added: head/sys/mips/conf/AR91XX_BASE
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/mips/conf/AR91XX_BASE	Sun Apr  3 13:19:58 2011	(r220295)
@@ -0,0 +1,96 @@
+#
+# AR91XX -- Kernel configuration base file for the Atheros AR913x SoC.
+#
+# This file (and the hints file accompanying it) are not designed to be
+# used by themselves. Instead, users of this file should create a kernel
+# config file which includes this file (which gets the basic hints), then
+# override the default options (adding devices as needed) and adding
+# hints as needed (for example, the GPIO and LAN PHY.)
+#
+# $FreeBSD$
+#
+
+machine         mips mipseb
+ident		AR91XX_BASE
+cpu		CPU_MIPS4KC
+options 	ISA_MIPS32
+makeoptions	KERNLOADADDR=0x80050000
+options		HZ=1000
+
+files		"../atheros/files.ar71xx"
+hints		"AR91XX_BASE.hints"
+
+makeoptions	DEBUG=-g		#Build kernel with gdb(1) debug symbols
+makeoptions	MODULES_OVERRIDE=""
+
+options		DDB
+options		KDB
+
+options		SCHED_4BSD		#4BSD scheduler
+options		INET			#InterNETworking
+options		INET6			#InterNETworking
+options		NFSCLIENT		#Network Filesystem Client
+options		PSEUDOFS		#Pseudo-filesystem framework
+options		_KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
+
+# options		NFS_LEGACYRPC
+# Debugging for use in -current
+# options		INVARIANTS
+# options		INVARIANT_SUPPORT
+# options		WITNESS
+# options		WITNESS_SKIPSPIN
+options         FFS                     #Berkeley Fast Filesystem
+options         SOFTUPDATES             #Enable FFS soft updates support
+options         UFS_ACL                 #Support for access control lists
+options         UFS_DIRHASH             #Improve performance on big directories
+
+
+# Wireless NIC cards
+options		IEEE80211_DEBUG
+options		IEEE80211_SUPPORT_MESH
+options		IEEE80211_SUPPORT_TDMA
+#device		wlan            # 802.11 support
+#device		wlan_wep        # 802.11 WEP support
+#device		wlan_ccmp       # 802.11 CCMP support
+#device		wlan_tkip       # 802.11 TKIP support
+#device		wlan_xauth	# 802.11 hostap support
+
+# This will come later -adrian
+#device		ath             # Atheros pci/cardbus NIC's
+options 	ATH_DEBUG
+options		ATH_DIAGAPI
+options		AH_DEBUG
+#device		ath_hal
+option		AH_SUPPORT_AR5416
+option		AH_RXCFG_SDMAMW_4BYTES  # See NOTES for details of this WAR
+option		AH_NEED_DESC_SWAP	# ?
+#device		ath_rate_sample
+#device		ath_ahb
+option		AH_AR5416_INTERRUPT_MITIGATION
+
+device		mii
+device		arge
+
+device		usb
+options		USB_EHCI_BIG_ENDIAN_DESC        # handle big-endian byte order
+options		USB_DEBUG
+options		USB_HOST_ALIGN=32		# AR71XX (MIPS in general?) requires this
+device		ehci
+
+device		scbus
+device		umass
+device		da
+
+device		spibus
+device		ar71xx_spi
+device		mx25l
+device		ar71xx_wdog
+
+device		uart
+
+device		loop
+device		ether
+device		md
+device		bpf
+device		random
+device		if_bridge

Added: head/sys/mips/conf/AR91XX_BASE.hints
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/mips/conf/AR91XX_BASE.hints	Sun Apr  3 13:19:58 2011	(r220295)
@@ -0,0 +1,52 @@
+# This file (and the kernel config file accompanying it) are not designed 
+# to be used by themselves. Instead, users of this file should create a
+# kernel # config file which includes this file (which gets the basic hints),
+# then override the default options (adding devices as needed) and adding
+# hints as needed (for example, the GPIO and LAN PHY.)
+
+# $FreeBSD$
+
+hint.apb.0.at="nexus0"
+hint.apb.0.irq=4
+
+# uart0
+hint.uart.0.at="apb0"
+# see atheros/uart_cpu_ar71xx.c why +3
+hint.uart.0.maddr=0x18020003
+hint.uart.0.msize=0x18
+hint.uart.0.irq=3
+
+#ehci - note the 0x100 offset for the AR913x/AR724x
+hint.ehci.0.at="nexus0"
+hint.ehci.0.maddr=0x1b000100
+hint.ehci.0.msize=0x00ffff00
+hint.ehci.0.irq=1
+
+hint.arge.0.at="nexus0"
+hint.arge.0.maddr=0x19000000
+hint.arge.0.msize=0x1000
+hint.arge.0.irq=2
+
+hint.arge.1.at="nexus0"
+hint.arge.1.maddr=0x1a000000
+hint.arge.1.msize=0x1000
+hint.arge.1.irq=3
+
+hint.ath.0.at="nexus0"
+hint.ath.0.maddr=0x180c0000
+hint.ath.0.msize=0x30000
+hint.ath.0.irq=0
+# Set this to define where the ath calibration data
+# should be fetched from in physical memory.
+# hint.ath.0.eepromaddr=0x1fff1000
+
+# SPI flash
+hint.spi.0.at="nexus0"
+hint.spi.0.maddr=0x1f000000
+hint.spi.0.msize=0x10
+
+hint.mx25l.0.at="spibus0"
+hint.mx25l.0.cs=0
+
+# Watchdog
+hint.ar71xx_wdog.0.at="nexus0"

Added: head/sys/mips/conf/TP-WN1043ND
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/mips/conf/TP-WN1043ND	Sun Apr  3 13:19:58 2011	(r220295)
@@ -0,0 +1,30 @@
+#
+# TP-1043ND -- Kernel configuration file for the TP-Link WR-1043ND
+#
+# $FreeBSD$
+#
+
+# Include the default AR913x parameters common to all AR913x SoC users.
+include         "AR91XX_BASE"
+
+ident           TP-WN1043ND
+
+# Override hints with board values
+hints           "TP-WN1043ND.hints"
+
+# Force the board memory - 32mb
+options         AR71XX_REALMEM=32*1024*1024
+
+# read MSDOS formatted disks - USB
+options		MSDOSFS
+options		GEOM_PART_BSD
+options		GEOM_PART_MBR
+
+# Just make sure the thing boots off of the first attached SCSI device for now!
+#options		ROOTDEVNAME=\"ufs:da0a\"
+# Or an MDROOT for testing.
+options		MD_ROOT
+options		MD_ROOT_SIZE=5120
+device		geom_uzip
+options		GEOM_UZIP
+options		ROOTDEVNAME=\"ufs:/dev/md0.uzip\"

Added: head/sys/mips/conf/TP-WN1043ND.hints
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/mips/conf/TP-WN1043ND.hints	Sun Apr  3 13:19:58 2011	(r220295)
@@ -0,0 +1,19 @@
+#
+# This file adds to the values in AR91XX_BASE.hints.
+#
+# $FreeBSD$
+
+# Hard-code the PHY for now, until there's switch phy support.
+hint.arge.0.phymask=0x000c
+hint.arge.0.media=1000
+hint.arge.0.fduplex=1
+# Where is the MAC address stored in flash for this particular unit.
+hint.arge.0.eeprommac=0x1f01fc00
+
+# This isn't used, but configure it anyway.
+# This should eventually just not be configured, but the if then
+# needs to be properly disabled or spurious interrupts occur.
+hint.arge.1.phymask=0x0
+
+# Where the ART is
+hint.ath.0.eepromaddr=0x1fff1000

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 14:34:28 2011
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 867181065672;
	Sun,  3 Apr 2011 14:34: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 773F68FC15;
	Sun,  3 Apr 2011 14:34:28 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p33EYS1Z030269;
	Sun, 3 Apr 2011 14:34:28 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p33EYS6B030267;
	Sun, 3 Apr 2011 14:34:28 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104031434.p33EYS6B030267@svn.freebsd.org>
From: Adrian Chadd 
Date: Sun, 3 Apr 2011 14:34: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: r220296 - head/sys/mips/atheros
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, 03 Apr 2011 14:34:28 -0000

Author: adrian
Date: Sun Apr  3 14:34:28 2011
New Revision: 220296
URL: http://svn.freebsd.org/changeset/base/220296

Log:
  Add in some missing flags in the EHCI initialisation code,
  needed to get USB working on the AR913x/AR724x.

Modified:
  head/sys/mips/atheros/ar71xx_ehci.c

Modified: head/sys/mips/atheros/ar71xx_ehci.c
==============================================================================
--- head/sys/mips/atheros/ar71xx_ehci.c	Sun Apr  3 13:19:58 2011	(r220295)
+++ head/sys/mips/atheros/ar71xx_ehci.c	Sun Apr  3 14:34:28 2011	(r220296)
@@ -206,6 +206,13 @@ ar71xx_ehci_attach(device_t self)
 			break;
 	}
 
+	/*
+	 * ehci_reset() needs the correct offset to access the host controller
+	 * registers. The AR724x/AR913x offsets aren't 0.
+	*/
+	sc->sc_offs = EHCI_CAPLENGTH(EREAD4(sc, EHCI_CAPLEN_HCIVERSION));
+
+
 	(void) ehci_reset(sc);
 
 	err = ehci_init(sc);

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 14:39:55 2011
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 AD1A3106566B;
	Sun,  3 Apr 2011 14:39:55 +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 9BEFF8FC13;
	Sun,  3 Apr 2011 14:39:55 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p33EdtmE030444;
	Sun, 3 Apr 2011 14:39:55 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p33EdtH4030436;
	Sun, 3 Apr 2011 14:39:55 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104031439.p33EdtH4030436@svn.freebsd.org>
From: Adrian Chadd 
Date: Sun, 3 Apr 2011 14:39: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: r220297 - in head/sys/mips: conf rt305x
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, 03 Apr 2011 14:39:55 -0000

Author: adrian
Date: Sun Apr  3 14:39:55 2011
New Revision: 220297
URL: http://svn.freebsd.org/changeset/base/220297

Log:
  Import the initial CPU support for the MIPS RALink RT305x SoC.
  This is a MIPS4KC CPU with various embedded peripherals, including
  wireless and ethernet support.
  
  This commit includes the platform, UART, ethernet MAC and GPIO support.
  The interrupt-driven GPIO code is disabled for now pending GPIO changes
  from the submitter.
  
  Submitted by:	Aleksandr Rybalko 

Added:
  head/sys/mips/conf/RT305X   (contents, props changed)
  head/sys/mips/conf/RT305X.hints   (contents, props changed)
  head/sys/mips/rt305x/
  head/sys/mips/rt305x/files.rt305x   (contents, props changed)
  head/sys/mips/rt305x/obio.c   (contents, props changed)
  head/sys/mips/rt305x/obiovar.h   (contents, props changed)
  head/sys/mips/rt305x/rt305x_dotg.c   (contents, props changed)
  head/sys/mips/rt305x/rt305x_gpio.c   (contents, props changed)
  head/sys/mips/rt305x/rt305x_gpio.h   (contents, props changed)
  head/sys/mips/rt305x/rt305x_gpiovar.h   (contents, props changed)
  head/sys/mips/rt305x/rt305x_ic.c   (contents, props changed)
  head/sys/mips/rt305x/rt305x_icvar.h   (contents, props changed)
  head/sys/mips/rt305x/rt305x_machdep.c   (contents, props changed)
  head/sys/mips/rt305x/rt305x_sysctl.c   (contents, props changed)
  head/sys/mips/rt305x/rt305x_sysctlvar.h   (contents, props changed)
  head/sys/mips/rt305x/rt305xreg.h   (contents, props changed)
  head/sys/mips/rt305x/rt_swreg.h   (contents, props changed)
  head/sys/mips/rt305x/std.rt305x   (contents, props changed)
  head/sys/mips/rt305x/uart_bus_rt305x.c   (contents, props changed)
  head/sys/mips/rt305x/uart_cpu_rt305x.c   (contents, props changed)
  head/sys/mips/rt305x/uart_dev_rt305x.c   (contents, props changed)
  head/sys/mips/rt305x/uart_dev_rt305x.h   (contents, props changed)

Added: head/sys/mips/conf/RT305X
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/mips/conf/RT305X	Sun Apr  3 14:39:55 2011	(r220297)
@@ -0,0 +1,134 @@
+# RT305X -- Kernel configuration file for FreeBSD/mips for Ralink RT305xF systems
+#
+# For more information on this file, please read the handbook section on
+# Kernel Configuration Files:
+#
+#    http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
+#
+# The handbook is also available locally in /usr/share/doc/handbook
+# if you've installed the doc distribution, otherwise always see the
+# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
+# latest information.
+#
+# An exhaustive list of options and more detailed explanations of the
+# device lines is also present in the ../../conf/NOTES and NOTES files. 
+# If you are in doubt as to the purpose or necessity of a line, check first 
+# in NOTES.
+#
+# $FreeBSD$
+
+ident		RT305X
+
+machine		mips mipsel
+makeoptions	MIPS_LITTLE_ENDIAN=defined
+makeoptions	KERNLOADADDR=0x80001000
+
+# Don't build any modules yet.
+makeoptions	MODULES_OVERRIDE="wlan_xauth wlan_wep wlan_tkip wlan_acl wlan_amrr wlan_ccmp wlan_rssadapt random if_bridge bridgestp msdosfs md ipfw dummynet libalias geom/geom_label ufs usb/uplcom usb/u3g usb/umodem usb/umass usb/ucom cam zlib"
+makeoptions	RT3052F
+
+include		"../rt305x/std.rt305x"
+
+hints		"RT305X.hints"		#Default places to look for devices.
+
+#makeoptions	DEBUG=-g		#Build kernel with gdb(1) debug symbols
+
+# Debugging for use in -current
+#options 	DEADLKRES		#Enable the deadlock resolver
+#options		INVARIANTS		#Enable calls of extra sanity checking
+#options		INVARIANT_SUPPORT	#Extra sanity checks of internal structures, required by INVARIANTS
+#options		WITNESS			#Enable checks to detect deadlocks and cycles
+#options		WITNESS_SKIPSPIN	#Don't run witness on spinlocks for speed
+#options         DIAGNOSTIC
+#options     DEBUG_LOCKS
+#options     DEBUG_VFS_LOCKS
+#options 	GDB
+options 	DDB
+options 	KDB
+
+options 	SCHED_ULE
+#options 	SCHED_4BSD		#4BSD scheduler
+#options		COMPAT_43
+options 	INET			#InterNETworking
+options 	NFSCLIENT		#Network Filesystem Client
+options 	NFS_ROOT		#NFS usable as /, requires NFSCLIENT
+options 	PSEUDOFS		#Pseudo-filesystem framework
+#options 	_KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
+
+options 	BOOTP
+#options 	BOOTP_NFSROOT
+options 	BOOTP_NFSV3
+options 	BOOTP_WIRED_TO=rt0
+options 	BOOTP_COMPAT
+options 	CD9660			# ISO 9660 Filesystem
+options		ROOTDEVNAME=\"cd9660:/dev/map/rootfs.uncompress\"
+options 	TMPFS			# TMP Memory Filesystem
+
+#options 	FFS			#Berkeley Fast Filesystem
+#options 	SOFTUPDATES		#Enable FFS soft updates support
+#options 	UFS_ACL			#Support for access control lists
+#options 	UFS_DIRHASH		#Improve performance on big directories
+#options 	ROOTDEVNAME=\"nfs:10.0.0.1:/mnt/bsd\"
+
+# Options for making kernel less hangry
+makeoptions	INLINE_LIMIT=1024
+options		MAXUSERS=3
+options		MAXFILES=512
+options		NSFBUFS=256
+options		SHMALL=128
+options		MSGBUF_SIZE=65536
+
+# Options for making kernel smallest 
+options		NO_SYSCTL_DESCR		# No description string of sysctl
+#options		NO_FFS_SNAPSHOT		# Disable Snapshot supporting
+options		SCSI_NO_SENSE_STRINGS
+options		SCSI_NO_OP_STRINGS
+options		RWLOCK_NOINLINE
+options		SX_NOINLINE
+options		NO_SWAPPING
+options 	ZERO_COPY_SOCKETS
+options         MROUTING                # Multicast routing
+options		IPFIREWALL_DEFAULT_TO_ACCEPT
+
+device		random
+device		loop
+# RT3050F, RT3052F have only pseudo PHYs
+#device		mii
+#device		miibus
+device 		pty			# Pseudo-ttys (telnet etc)
+device		ether
+device 		bpf			# Berkeley packet filter
+device		vlan
+#device		lagg
+#device          if_bridge
+device		uart
+nodevice	uart_ns8250
+device 		tun			# Packet tunnel.
+
+device		wlan
+
+
+device		gpio
+device		gpioled
+
+device		cfi			# Detect Flash memmory
+device		cfid
+
+device		nvram2env
+
+device		usb
+#device		dotg			# DWC like USB OTG Controller driver
+#device		u3g
+#device		umodem
+#device		uplcom
+#device		umass
+#device		da
+#device		pass
+#device		scbus
+options 	SCSI_DELAY=1000		# Delay (in ms) before probing SCSI
+
+#options		USB_EHCI_BIG_ENDIAN_DESC        # handle big-endian byte order
+#options		USB_DEBUG
+#options		USB_REQ_DEBUG
+
+

Added: head/sys/mips/conf/RT305X.hints
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/mips/conf/RT305X.hints	Sun Apr  3 14:39:55 2011	(r220297)
@@ -0,0 +1,136 @@
+# $FreeBSD$
+# device.hints
+hint.obio.0.at="nexus0"
+hint.obio.0.maddr=0x10000000
+hint.obio.0.msize=0x10000000
+
+hint.nvram.0.sig=0xe5e60a74
+hint.nvram.0.base=0x1f030000
+hint.nvram.0.maxsize=0x2000
+hint.nvram.0.flags=3 # 1 = No check, 2 = Format Generic
+hint.nvram.1.sig=0x5a045e94
+hint.nvram.1.base=0x1f032000
+hint.nvram.1.maxsize=0x4000
+hint.nvram.1.flags=3 # 1 = No check, 2 = Format Generic
+
+# on-board Ralink Frame Engine
+#hint.rt.0.at="nexus0"
+#hint.rt.0.maddr=0x12000000
+#hint.rt.0.msize=0x200000
+#hint.rt.0.irq=9
+hint.rt.0.macaddr="00:18:e7:d5:83:90"
+
+# on-board Ralink 2872 802.11n core
+hint.rt2860.0.at="nexus0"
+hint.rt2860.0.maddr=0x10180000
+hint.rt2860.0.msize=0x40000
+hint.rt2860.0.irq=4
+
+# uart0
+#hint.uart.0.at="obio0"
+#hint.uart.0.maddr=0x10000C00
+#hint.uart.0.msize=0x100
+#hint.uart.0.irq=12
+#hint.uart.0.flags="0x30"
+
+# uart1
+#hint.uart.1.at="obio0"
+#hint.uart.1.maddr=0x10000500
+#hint.uart.1.msize=0x100
+#hint.uart.1.irq=5
+#hint.uart.1.flags="0x30"
+
+
+# gpio
+# GPIO0  - WPS BTN	IN II IO
+hint.gpiobutton.0.at="gpiobus0"
+hint.gpiobutton.0.pins="0x01"
+hint.gpiobutton.0.name="wps"
+hint.gpiobutton.0.flags="0x0581"
+
+# GPIO7  - MODE SW AP	IN II IO
+hint.gpiobutton.1.at="gpiobus0"
+hint.gpiobutton.1.pins="0x80"
+hint.gpiobutton.1.name="mode_ap"
+hint.gpiobutton.1.flags="0x0581"
+
+# GPIO8  - ST LEDRED	OUT	/* 2pin BiDir RED/BLUE LED */
+# GPIO9  - ST LEDBLUE	OUT
+hint.gpioled.0.at="gpiobus0"
+hint.gpioled.0.pins="0x100"
+hint.gpioled.0.name="status_red"
+hint.gpioled.0.flags="0x0002"
+hint.gpioled.1.at="gpiobus0"
+hint.gpioled.1.pins="0x200"
+#hint.gpioled.1.name="status_blue"
+hint.gpioled.1.name="status"
+hint.gpioled.1.flags="0x0002"
+
+# GPIO10 - RST BTN	IN II IO
+hint.gpiobutton.2.at="gpiobus0"
+hint.gpiobutton.2.pins="0x400"
+hint.gpiobutton.2.name="reset"
+hint.gpiobutton.2.flags="0x0581"
+
+# GPIO11 - MODE SW CL	IN II IO
+hint.gpiobutton.3.at="gpiobus0"
+hint.gpiobutton.3.pins="0x800"
+hint.gpiobutton.3.name="mode_wlan_client"
+hint.gpiobutton.3.flags="0x0581"
+
+# GPIO14 - WPS LED	OUT II IO
+hint.gpioled.2.at="gpiobus0"
+hint.gpioled.2.pins="0x4000"
+hint.gpioled.2.name="wps"
+hint.gpioled.2.flags="0x0182"
+
+
+
+#0x00000000-0x00030000 : "Bootloader"
+#0x00030000-0x00040000 : "Factory"
+#0x00040000-0x00070000 : "Config"
+#0x00070000-0x000b0000 : "Language"
+#0x000b0000-0x001a0000 : "Kernel"
+#0x001a0000-0x01000000 : "RootFS"
+
+hint.map.0.at="cfid0"
+hint.map.0.start=0x00000000
+hint.map.0.end=0x00030000
+hint.map.0.name="bootloader"
+hint.map.0.readonly=1
+
+hint.map.1.at="cfid0"
+hint.map.1.start=0x00030000
+hint.map.1.end=0x00040000
+hint.map.1.name="factory"
+
+hint.map.2.at="cfid0"
+hint.map.2.start=0x00040000
+hint.map.2.end=0x00800000
+hint.map.2.name="upgrade"
+
+hint.map.3.at="cfid0"
+hint.map.3.start=0x00040000
+hint.map.3.end=0x00050000
+hint.map.3.name="config"
+
+hint.map.4.at="cfid0"
+hint.map.4.start=0x00000000
+hint.map.4.end=0x00000000
+hint.map.4.name="language"
+
+hint.map.5.at="cfid0"
+hint.map.5.start=0x00050000
+hint.map.5.end=0x00150000
+hint.map.5.name="kernel"
+
+hint.map.6.at="cfid0"
+hint.map.6.start=0x00150000
+hint.map.6.end=0x00800000
+hint.map.6.name="rootfs"
+
+
+hint.rt.0.phymask=0x1f
+hint.rt.0.media=100
+hint.rt.0.fduplex=1
+

Added: head/sys/mips/rt305x/files.rt305x
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/mips/rt305x/files.rt305x	Sun Apr  3 14:39:55 2011	(r220297)
@@ -0,0 +1,13 @@
+# $FreeBSD$
+
+# RT305X on-board devices
+mips/rt305x/rt305x_machdep.c	standard
+mips/rt305x/obio.c		standard
+mips/rt305x/rt305x_sysctl.c	standard
+mips/rt305x/rt305x_ic.c		standard
+mips/rt305x/rt305x_gpio.c	optional gpio
+mips/rt305x/uart_bus_rt305x.c	optional uart
+mips/rt305x/uart_cpu_rt305x.c	optional uart
+mips/rt305x/uart_dev_rt305x.c	optional uart
+mips/mips/intr_machdep.c        standard
+mips/mips/tick.c		standard

Added: head/sys/mips/rt305x/obio.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/mips/rt305x/obio.c	Sun Apr  3 14:39:55 2011	(r220297)
@@ -0,0 +1,627 @@
+/*	$NetBSD: obio.c,v 1.11 2003/07/15 00:25:05 lukem Exp $	*/
+
+/*-
+ * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Jason R. Thorpe for Wasabi Systems, Inc.
+ *
+ * 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 WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
+ * 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 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+/* MIPS HW interrupts of IRQ/FIQ respectively */
+#define RT305X_INTR		0
+#define RT305X_FAST_INTR	1
+
+/* Interrupt levels */
+#define INTR_IRQ 0
+#define INTR_FIQ 1
+
+
+int irq_priorities[NIRQS] = {
+	INTR_IRQ,	/* SYSCTL */
+	INTR_FIQ,	/* TIMER0 */
+	INTR_FIQ,	/* WDTIMER */
+	INTR_IRQ,	/* Illegal Access */
+	INTR_IRQ,	/* PCM */
+	INTR_IRQ,	/* UART */
+	INTR_IRQ,	/* GPIO */
+	INTR_FIQ,	/* GDMA */
+	INTR_IRQ,	/* NAND */
+	INTR_IRQ,	/* Perfomance Counter */
+	INTR_IRQ,	/* I2S */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* UARTLITE */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* EtherNet Switch */
+	INTR_FIQ,	/* OTG */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* unknown */
+	INTR_IRQ,	/* unknown */
+};
+
+
+#define REG_READ(o) *((volatile uint32_t *)MIPS_PHYS_TO_KSEG1(INTCTL_BASE + (o)))
+#define REG_WRITE(o,v) (REG_READ(o)) = (v)
+
+static int	obio_activate_resource(device_t, device_t, int, int,
+		    struct resource *);
+static device_t	obio_add_child(device_t, u_int, const char *, int);
+static struct resource *
+		obio_alloc_resource(device_t, device_t, int, int *, u_long,
+		    u_long, u_long, u_int);
+static int	obio_attach(device_t);
+static int	obio_deactivate_resource(device_t, device_t, int, int,
+		    struct resource *);
+static struct resource_list *
+		obio_get_resource_list(device_t, device_t);
+static void	obio_add_res_child(device_t, const char *, int, long, int, int);
+static void	obio_hinted_child(device_t, const char *, int);
+static int	obio_intr(void *);
+static int	obio_probe(device_t);
+static int	obio_release_resource(device_t, device_t, int, int,
+		    struct resource *);
+static int	obio_setup_intr(device_t, device_t, struct resource *, int,
+		    driver_filter_t *, driver_intr_t *, void *, void **);
+static int	obio_teardown_intr(device_t, device_t, struct resource *,
+		    void *);
+
+static void 
+obio_mask_irq(void *source)
+{
+	int irq;
+	uint32_t irqmask;
+
+	irq = (int)source;
+	irqmask = 1 << irq;
+
+	/* disable IRQ */
+	rt305x_ic_set(IC_INT_DIS, irqmask);
+}
+
+static void 
+obio_unmask_irq(void *source)
+{
+	int irq;
+	uint32_t irqmask;
+
+	irq = (int)source;
+	irqmask = 1 << irq;
+
+	/* enable IRQ */
+	rt305x_ic_set(IC_INT_ENA, irqmask);
+
+}
+
+
+static int
+obio_probe(device_t dev)
+{
+
+	return (0);
+}
+
+static int
+obio_attach(device_t dev)
+{
+	struct obio_softc *sc = device_get_softc(dev);
+	int rid;
+
+	sc->oba_mem_rman.rm_type = RMAN_ARRAY;
+	sc->oba_mem_rman.rm_descr = "OBIO memory";
+	if (rman_init(&sc->oba_mem_rman) != 0 ||
+	    rman_manage_region(&sc->oba_mem_rman, OBIO_MEM_START,
+	        OBIO_MEM_END) != 0)
+		panic("obio_attach: failed to set up I/O rman");
+
+	sc->oba_irq_rman.rm_type = RMAN_ARRAY;
+	sc->oba_irq_rman.rm_descr = "OBIO IRQ";
+	if (rman_init(&sc->oba_irq_rman) != 0 ||
+	    rman_manage_region(&sc->oba_irq_rman, 0, NIRQS-1) != 0)
+		panic("obio_attach: failed to set up IRQ rman");
+
+	/* Hook up our interrupt handler. */
+	if ((sc->sc_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
+	    RT305X_INTR, RT305X_INTR, 1,
+	    RF_SHAREABLE | RF_ACTIVE)) == NULL) {
+		device_printf(dev, "unable to allocate IRQ resource\n");
+		return (ENXIO);
+	}
+
+	if ((bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_MISC, obio_intr, NULL,
+	    sc, &sc->sc_ih))) {
+		device_printf(dev,
+		    "WARNING: unable to register interrupt handler\n");
+		return (ENXIO);
+	}
+
+	/* Hook up our FAST interrupt handler. */
+	if ((sc->sc_fast_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
+	    RT305X_FAST_INTR, RT305X_FAST_INTR, 1,
+	    RF_SHAREABLE | RF_ACTIVE)) == NULL) {
+		device_printf(dev, "unable to allocate IRQ resource\n");
+		return (ENXIO);
+	}
+
+	if ((bus_setup_intr(dev, sc->sc_fast_irq, INTR_TYPE_MISC, obio_intr,
+	    NULL, sc, &sc->sc_fast_ih))) {
+		device_printf(dev,
+		    "WARNING: unable to register interrupt handler\n");
+		return (ENXIO);
+	}
+
+	/* disable all interrupts */
+	rt305x_ic_set(IC_INT_DIS, IC_INT_MASK|IC_LINE_GLOBAL);
+
+	bus_generic_probe(dev);
+
+	obio_add_res_child(dev, "rt305x_sysctl", 0, 
+	    SYSCTL_BASE, (SYSCTL_END - SYSCTL_BASE + 1),
+	    IC_SYSCTL);
+	obio_add_res_child(dev, "rt305x_ic", 0, 
+	    INTCTL_BASE, (INTCTL_END - INTCTL_BASE + 1),
+	    -1);
+#ifdef notyet
+	obio_add_res_child(dev, "timer",0, 
+	    TIMER_BASE, (TIMER_END - TIMER_BASE  + 1),
+	    IC_TIMER0);
+	obio_add_res_child(dev, "rt305x_memc", 0,
+	    MEMCTRL_BASE, (MEMCTRL_END - MEMCTRL_BASE + 1),
+	    -1);
+	obio_add_res_child(dev, "pcm", 	0, 
+	    PCM_BASE, (PCM_END - PCM_BASE  + 1),
+	    IC_PCM);
+	obio_add_res_child(dev, "uart", 0, 
+	    UART_BASE, (UART_END - UART_BASE + 1),
+	    IC_UART);
+#endif
+	obio_add_res_child(dev, "gpio", 0, 
+	    PIO_BASE, (PIO_END - PIO_BASE  + 1),
+	    IC_PIO);
+#ifdef notyet
+	obio_add_res_child(dev, "rt305x_dma", 0,
+	    GDMA_BASE, (GDMA_END - GDMA_BASE + 1),
+	    IC_DMA);
+	obio_add_res_child(dev, "rt305x_nandc", 0,
+	    NANDFC_BASE, (NANDFC_END - NANDFC_BASE  + 1),
+	    IC_NAND);
+	obio_add_res_child(dev, "i2c", 	0,
+	    I2C_BASE, (I2C_END - I2C_BASE  + 1),
+	    -1);
+	obio_add_res_child(dev, "i2s", 0,
+	    I2S_BASE, (I2S_END - I2S_BASE  + 1),
+	    IC_I2S);
+	obio_add_res_child(dev, "spi", 0, 
+	    SPI_BASE, (SPI_END - SPI_BASE  + 1),
+	    -1);
+#endif
+	obio_add_res_child(dev, "uart", 1,
+	    UARTLITE_BASE, (UARTLITE_END - UARTLITE_BASE + 1),
+	    IC_UARTLITE);
+	obio_add_res_child(dev, "cfi", 	0,
+	    FLASH_BASE, (FLASH_END - FLASH_BASE  + 1),
+	    -1);
+	obio_add_res_child(dev, "dotg", 0,
+	    USB_OTG_BASE, (USB_OTG_END - USB_OTG_BASE  + 1),
+	    IC_OTG);
+	obio_add_res_child(dev, "switch", 0,
+	    ETHSW_BASE, (ETHSW_END - ETHSW_BASE  + 1),
+	    IC_ETHSW);
+
+	bus_enumerate_hinted_children(dev);
+	bus_generic_attach(dev);
+
+	/* enable IC */
+	rt305x_ic_set(IC_INT_ENA, IC_LINE_GLOBAL);
+
+	return (0);
+}
+
+static struct resource *
+obio_alloc_resource(device_t bus, device_t child, int type, int *rid,
+    u_long start, u_long end, u_long count, u_int flags)
+{
+	struct obio_softc		*sc = device_get_softc(bus);
+	struct obio_ivar		*ivar = device_get_ivars(child);
+	struct resource			*rv;
+	struct resource_list_entry	*rle;
+	struct rman			*rm;
+	int				 isdefault, needactivate, passthrough;
+
+	isdefault = (start == 0UL && end == ~0UL && count == 1);
+	needactivate = flags & RF_ACTIVE;
+	passthrough = (device_get_parent(child) != bus);
+	rle = NULL;
+
+	if (passthrough)
+		return (BUS_ALLOC_RESOURCE(device_get_parent(bus), child, type,
+		    rid, start, end, count, flags));
+
+	/*
+	 * If this is an allocation of the "default" range for a given RID,
+	 * and we know what the resources for this device are (ie. they aren't
+	 * maintained by a child bus), then work out the start/end values.
+	 */
+	if (isdefault) {
+		rle = resource_list_find(&ivar->resources, type, *rid);
+		if (rle == NULL)
+			return (NULL);
+		if (rle->res != NULL) {
+			panic("%s: resource entry is busy", __func__);
+		}
+		start = rle->start;
+		end = rle->end;
+		count = rle->count;
+	}
+
+	switch (type) {
+	case SYS_RES_IRQ:
+		rm = &sc->oba_irq_rman;
+		break;
+	case SYS_RES_MEMORY:
+		rm = &sc->oba_mem_rman;
+		break;
+	default:
+		printf("%s: unknown resource type %d\n", __func__, type);
+		return (0);
+	}
+
+	rv = rman_reserve_resource(rm, start, end, count, flags, child);
+	if (rv == 0) {
+		printf("%s: could not reserve resource\n", __func__);
+		return (0);
+	}
+
+	rman_set_rid(rv, *rid);
+
+	if (needactivate) {
+		if (bus_activate_resource(child, type, *rid, rv)) {
+			printf("%s: could not activate resource\n", __func__);
+			rman_release_resource(rv);
+			return (0);
+		}
+	}
+
+	return (rv);
+}
+
+static int
+obio_activate_resource(device_t bus, device_t child, int type, int rid,
+    struct resource *r)
+{
+
+	/*
+	 * If this is a memory resource, track the direct mapping
+	 * in the uncached MIPS KSEG1 segment.
+	 */
+	if (type == SYS_RES_MEMORY) {
+		void *vaddr;
+
+		vaddr = (void *)MIPS_PHYS_TO_KSEG1((intptr_t)rman_get_start(r));
+		rman_set_virtual(r, vaddr);
+		rman_set_bustag(r, mips_bus_space_generic);
+		rman_set_bushandle(r, (bus_space_handle_t)vaddr);
+	}
+
+	return (rman_activate_resource(r));
+}
+
+static int
+obio_deactivate_resource(device_t bus, device_t child, int type, int rid,
+    struct resource *r)
+{
+
+	return (rman_deactivate_resource(r));
+}
+
+static int
+obio_release_resource(device_t dev, device_t child, int type,
+    int rid, struct resource *r)
+{
+	struct resource_list *rl;
+	struct resource_list_entry *rle;
+
+	rl = obio_get_resource_list(dev, child);
+	if (rl == NULL)
+		return (EINVAL);
+	rle = resource_list_find(rl, type, rid);
+	if (rle == NULL)
+		return (EINVAL);
+	rman_release_resource(r);
+	rle->res = NULL;
+
+	return (0);
+}
+
+static int
+obio_setup_intr(device_t dev, device_t child, struct resource *ires,
+		int flags, driver_filter_t *filt, driver_intr_t *handler,
+		void *arg, void **cookiep)
+{
+	struct obio_softc *sc = device_get_softc(dev);
+	struct intr_event *event;
+	int irq, error, priority;
+	uint32_t irqmask;
+
+	irq = rman_get_start(ires);
+
+	if (irq >= NIRQS)
+		panic("%s: bad irq %d", __func__, irq);
+
+	event = sc->sc_eventstab[irq];
+	if (event == NULL) {
+		error = intr_event_create(&event, (void *)irq, 0, irq,
+		    obio_mask_irq, obio_unmask_irq,
+		    NULL, NULL, "obio intr%d:", irq);
+
+		sc->sc_eventstab[irq] = event;
+	}
+	else
+		panic("obio: Can't share IRQs");
+
+	intr_event_add_handler(event, device_get_nameunit(child), filt,
+	    handler, arg, intr_priority(flags), flags, cookiep);
+
+	irqmask = 1 << irq;
+	priority = irq_priorities[irq];
+
+	if (priority == INTR_FIQ)
+		rt305x_ic_set(IC_INTTYPE, rt305x_ic_get(IC_INTTYPE) | irqmask);
+	else
+		rt305x_ic_set(IC_INTTYPE, rt305x_ic_get(IC_INTTYPE) & ~irqmask);
+
+	/* enable */
+	obio_unmask_irq((void*)irq);
+
+	return (0);
+}
+
+static int
+obio_teardown_intr(device_t dev, device_t child, struct resource *ires,
+    void *cookie)
+{
+	struct obio_softc *sc = device_get_softc(dev);
+	int irq, result, priority;
+	uint32_t irqmask;
+
+	irq = rman_get_start(ires);
+	if (irq >= NIRQS)
+		panic("%s: bad irq %d", __func__, irq);
+
+	if (sc->sc_eventstab[irq] == NULL)
+		panic("Trying to teardown unoccupied IRQ");
+
+	irqmask = (1 << irq);
+	priority = irq_priorities[irq];
+
+	if (priority == INTR_FIQ)
+		rt305x_ic_set(IC_INTTYPE, rt305x_ic_get(IC_INTTYPE) & ~irqmask);
+	else
+		rt305x_ic_set(IC_INTTYPE, rt305x_ic_get(IC_INTTYPE) | irqmask);
+
+	/* disable */
+	obio_mask_irq((void*)irq);
+
+	result = intr_event_remove_handler(cookie);
+	if (!result) {
+		sc->sc_eventstab[irq] = NULL;
+	}
+
+	return (result);
+}
+
+static int
+obio_intr(void *arg)
+{
+	struct obio_softc *sc = arg;
+	struct intr_event *event;
+	uint32_t irqstat;
+	int irq;
+
+	irqstat = rt305x_ic_get(IC_IRQ0STAT);
+	irqstat |= rt305x_ic_get(IC_IRQ1STAT);
+
+	irq = 0;
+	while (irqstat != 0) {
+		if ((irqstat & 1) == 1) {
+			event = sc->sc_eventstab[irq];
+			if (!event || TAILQ_EMPTY(&event->ie_handlers))
+				continue;
+
+			/* TODO: pass frame as an argument*/
+			/* TODO: log stray interrupt */
+			intr_event_handle(event, NULL);
+		}
+		irq++;
+		irqstat >>= 1;
+	}
+
+	return (FILTER_HANDLED);
+}
+
+static void
+obio_add_res_child(device_t bus, const char *dname, int dunit, 
+    long maddr, int msize, int irq)
+{
+	device_t		child;
+	int			result;
+
+	child = BUS_ADD_CHILD(bus, 0, dname, dunit);
+
+	result = bus_set_resource(child, SYS_RES_MEMORY, 0,
+	    maddr, msize);
+	if (result != 0)
+		device_printf(bus, "warning: bus_set_resource() failed\n");
+
+	if (irq != -1) {
+		result = bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1);
+		if (result != 0)
+			device_printf(bus,
+			    "warning: bus_set_resource() failed\n");
+	}
+}
+
+static void
+obio_hinted_child(device_t bus, const char *dname, int dunit)
+{
+	long			maddr;
+	int			msize;
+	int			irq;
+
+	/*
+	 * Set hard-wired resources for hinted child using
+	 * specific RIDs.
+	 */
+	resource_long_value(dname, dunit, "maddr", &maddr);
+	resource_int_value(dname, dunit, "msize", &msize);
+
+
+	if (resource_int_value(dname, dunit, "irq", &irq) == 0) irq = -1;
+
+	obio_add_res_child(bus, dname, dunit, maddr, msize, irq);
+}
+
+static device_t
+obio_add_child(device_t bus, u_int order, const char *name, int unit)
+{
+	device_t		child;
+	struct obio_ivar	*ivar;
+
+	ivar = malloc(sizeof(struct obio_ivar), M_DEVBUF, M_WAITOK | M_ZERO);
+	if (ivar == NULL) {
+		printf("Failed to allocate ivar\n");
+		return (0);
+	}
+	resource_list_init(&ivar->resources);
+
+	child = device_add_child_ordered(bus, order, name, unit);
+	if (child == NULL) {
+		printf("Can't add child %s%d ordered\n", name, unit);
+		return (0);
+	}
+
+	device_set_ivars(child, ivar);
+
+	return (child);
+}
+
+/*
+ * Helper routine for bus_generic_rl_get_resource/bus_generic_rl_set_resource
+ * Provides pointer to resource_list for these routines
+ */
+static struct resource_list *
+obio_get_resource_list(device_t dev, device_t child)
+{
+	struct obio_ivar *ivar;
+
+	ivar = device_get_ivars(child);
+	return (&(ivar->resources));
+}
+
+static int
+obio_print_all_resources(device_t dev)
+{
+	struct obio_ivar *ivar = device_get_ivars(dev);
+	struct resource_list *rl = &ivar->resources;
+	int retval = 0;
+
+	if (STAILQ_FIRST(rl))
+		retval += printf(" at");
+
+	retval += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx");
+	retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
+
+	return (retval);
+}
+
+static int
+obio_print_child(device_t bus, device_t child)
+{
+	int retval = 0;
+
+	retval += bus_print_child_header(bus, child);
+	retval += obio_print_all_resources(child);
+	if (device_get_flags(child))
+		retval += printf(" flags %#x", device_get_flags(child));
+	retval += printf(" on %s\n", device_get_nameunit(bus));
+
+	return (retval);
+}
+
+static device_method_t obio_methods[] = {
+	DEVMETHOD(bus_activate_resource,	obio_activate_resource),
+	DEVMETHOD(bus_add_child,		obio_add_child),
+	DEVMETHOD(bus_alloc_resource,		obio_alloc_resource),
+	DEVMETHOD(bus_deactivate_resource,	obio_deactivate_resource),
+	DEVMETHOD(bus_get_resource_list,	obio_get_resource_list),
+	DEVMETHOD(bus_hinted_child,		obio_hinted_child),
+	DEVMETHOD(bus_print_child,		obio_print_child),
+	DEVMETHOD(bus_release_resource,		obio_release_resource),
+	DEVMETHOD(bus_setup_intr,		obio_setup_intr),
+	DEVMETHOD(bus_teardown_intr,		obio_teardown_intr),
+	DEVMETHOD(device_attach,		obio_attach),
+	DEVMETHOD(device_probe,			obio_probe),
+        DEVMETHOD(bus_get_resource,		bus_generic_rl_get_resource),
+        DEVMETHOD(bus_set_resource,		bus_generic_rl_set_resource),
+
+	{0, 0},
+};
+
+static driver_t obio_driver = {
+	"obio",
+	obio_methods,
+	sizeof(struct obio_softc),
+};
+static devclass_t obio_devclass;
+
+DRIVER_MODULE(obio, nexus, obio_driver, obio_devclass, 0, 0);

Added: head/sys/mips/rt305x/obiovar.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/mips/rt305x/obiovar.h	Sun Apr  3 14:39:55 2011	(r220297)
@@ -0,0 +1,58 @@
+/*	$NetBSD: obiovar.h,v 1.4 2003/06/16 17:40:53 thorpej Exp $	*/
+
+/*-
+ * Copyright (c) 2002, 2003 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Jason R. Thorpe for Wasabi Systems, Inc.
+ *
+ * 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 WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
+ * 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 _RT305X_OBIOVAR_H_
+#define	_RT305X_OBIOVAR_H_
+
+#include 
+
+/* Number of IRQs */
+#define	NIRQS	32
+
+
+struct obio_softc {
+	struct rman		oba_mem_rman;
+	struct rman		oba_irq_rman;
+	struct rman		oba_gpio_rman;
+	struct intr_event	*sc_eventstab[NIRQS]; /* IRQ events structs */
+	struct resource		*sc_irq;	/* IRQ resource */
+	void			*sc_ih;		/* interrupt cookie */
+	struct resource		*sc_fast_irq;	/* IRQ resource */
+	void			*sc_fast_ih;	/* interrupt cookie */
+};
+
+struct obio_ivar {
+	struct resource_list	resources;
+};
+
+#endif /* _RT305X_OBIOVAR_H_ */

Added: head/sys/mips/rt305x/rt305x_dotg.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/mips/rt305x/rt305x_dotg.c	Sun Apr  3 14:39:55 2011	(r220297)
@@ -0,0 +1,247 @@
+#include 
+__FBSDID("$FreeBSD$");
+
+/*-
+ * Copyright (c) 2010,2011 Aleksandr Rybalko. All rights reserved.
+ * Copyright (c) 2007-2008 Hans Petter Selasky. 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

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 14:56:57 2011
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 1AF081065670;
	Sun,  3 Apr 2011 14:56:57 +0000 (UTC)
	(envelope-from bzeeb-lists@lists.zabbadoz.net)
Received: from mx1.sbone.de (mx1.sbone.de [IPv6:2a01:4f8:130:3ffc::401:25])
	by mx1.freebsd.org (Postfix) with ESMTP id 6DB678FC14;
	Sun,  3 Apr 2011 14:56:56 +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 5B1CC25D386F;
	Sun,  3 Apr 2011 14:56:55 +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 7B18D159C2F4;
	Sun,  3 Apr 2011 14:56:54 +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 fmjOemQoQvvT; Sun,  3 Apr 2011 14:56:51 +0000 (UTC)
Received: from nv.sbone.de (nv.sbone.de [IPv6:fde9:577b:c1a9:31::2013:138])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mail.sbone.de (Postfix) with ESMTPSA id 2FFD1159C2F3;
	Sun,  3 Apr 2011 14:56:51 +0000 (UTC)
Date: Sun, 3 Apr 2011 14:56:50 +0000 (UTC)
From: "Bjoern A. Zeeb" 
To: Ed Maste 
In-Reply-To: <201103300119.p2U1J18L046334@svn.freebsd.org>
Message-ID: 
References: <201103300119.p2U1J18L046334@svn.freebsd.org>
X-OpenPGP-Key: 0x14003F198FEFA3E77207EE8D2B58B8F83CCF1842
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: r220153 - head/etc/rc.d
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, 03 Apr 2011 14:56:57 -0000

On Wed, 30 Mar 2011, Ed Maste wrote:

> Author: emaste
> Date: Wed Mar 30 01:19:00 2011
> New Revision: 220153
> URL: http://svn.freebsd.org/changeset/base/220153
>
> Log:
>  Replace ${SYSCTL_W} with ${SYSCTL} in rc.d scripts, as they are identical.
>  This is a further clean up after r202988.
>
>  SYSCTL_W is still initialized in rc.subr as some ports may still use it.

I think this is a lazyness on our side.  Not sure what the official
reference is but for example OSX really requires the -w to alter a
sysctl while we permit without.   I thin kthe correct fix should have
been to add a -w to SYSCTL_W. That way one can grep for a read vs.
write in the startup scrpits a lot more easily, etc.

No this might be completely counter-intuitive to what we decided to do
in the past in which case I'll just shut up:)

> Modified:
>  head/etc/rc.d/faith
>  head/etc/rc.d/hostid
>  head/etc/rc.d/initrandom
>  head/etc/rc.d/ipfw
>  head/etc/rc.d/jail
>  head/etc/rc.d/netoptions
>  head/etc/rc.d/routing
>  head/etc/rc.d/securelevel
>
> Modified: head/etc/rc.d/faith
> ==============================================================================
> --- head/etc/rc.d/faith	Wed Mar 30 01:10:11 2011	(r220152)
> +++ head/etc/rc.d/faith	Wed Mar 30 01:19:00 2011	(r220153)
> @@ -21,7 +21,7 @@ faith_up()
> 	*)
> 		echo "Configuring IPv6-to-IPv4 TCP relay capturing interface:" \
> 		    " faith0."
> -		${SYSCTL_W} net.inet6.ip6.keepfaith=1
> +		${SYSCTL} net.inet6.ip6.keepfaith=1
> 		ifconfig faith0 create >/dev/null 2>&1
> 		ifconfig faith0 up
> 		for prefix in ${ipv6_faith_prefix}; do
> @@ -48,7 +48,7 @@ faith_down()
> {
> 	echo "Removing IPv6-to-IPv4 TCP relay capturing interface: faith0."
> 	ifconfig faith0 destroy
> -	${SYSCTL_W} net.inet6.ip6.keepfaith=0
> +	${SYSCTL} net.inet6.ip6.keepfaith=0
>
> 	case ${ipv6_faith_prefix} in
> 	[Nn][Oo] | '')
>
> Modified: head/etc/rc.d/hostid
> ==============================================================================
> --- head/etc/rc.d/hostid	Wed Mar 30 01:10:11 2011	(r220152)
> +++ head/etc/rc.d/hostid	Wed Mar 30 01:19:00 2011	(r220153)
> @@ -50,9 +50,9 @@ hostid_set()
> 	# Set both kern.hostuuid and kern.hostid.
> 	#
> 	check_startmsgs && echo "Setting hostuuid: ${uuid}."
> -	${SYSCTL_W} kern.hostuuid="${uuid}" >/dev/null
> +	${SYSCTL} kern.hostuuid="${uuid}" >/dev/null
> 	check_startmsgs && echo "Setting hostid: ${id}."
> -	${SYSCTL_W} kern.hostid=${id} >/dev/null
> +	${SYSCTL} kern.hostid=${id} >/dev/null
> }
>
> hostid_hardware()
>
> Modified: head/etc/rc.d/initrandom
> ==============================================================================
> --- head/etc/rc.d/initrandom	Wed Mar 30 01:10:11 2011	(r220152)
> +++ head/etc/rc.d/initrandom	Wed Mar 30 01:19:00 2011	(r220153)
> @@ -31,24 +31,24 @@ initrandom_start()
>
> 		if [ -w /dev/random ]; then
> 			if checkyesno harvest_interrupt; then
> -				${SYSCTL_W} kern.random.sys.harvest.interrupt=1 >/dev/null
> +				${SYSCTL} kern.random.sys.harvest.interrupt=1 >/dev/null
> 				echo -n ' interrupts'
> 			else
> -				${SYSCTL_W} kern.random.sys.harvest.interrupt=0 >/dev/null
> +				${SYSCTL} kern.random.sys.harvest.interrupt=0 >/dev/null
> 			fi
>
> 			if checkyesno harvest_ethernet; then
> -				${SYSCTL_W} kern.random.sys.harvest.ethernet=1 >/dev/null
> +				${SYSCTL} kern.random.sys.harvest.ethernet=1 >/dev/null
> 				echo -n ' ethernet'
> 			else
> -				${SYSCTL_W} kern.random.sys.harvest.ethernet=0 >/dev/null
> +				${SYSCTL} kern.random.sys.harvest.ethernet=0 >/dev/null
> 			fi
>
> 			if checkyesno harvest_p_to_p; then
> -				${SYSCTL_W} kern.random.sys.harvest.point_to_point=1 >/dev/null
> +				${SYSCTL} kern.random.sys.harvest.point_to_point=1 >/dev/null
> 				echo -n ' point_to_point'
> 			else
> -				${SYSCTL_W} kern.random.sys.harvest.point_to_point=0 >/dev/null
> +				${SYSCTL} kern.random.sys.harvest.point_to_point=0 >/dev/null
> 			fi
> 		fi
>
>
> Modified: head/etc/rc.d/ipfw
> ==============================================================================
> --- head/etc/rc.d/ipfw	Wed Mar 30 01:10:11 2011	(r220152)
> +++ head/etc/rc.d/ipfw	Wed Mar 30 01:19:00 2011	(r220153)
> @@ -73,11 +73,11 @@ ipfw_poststart()
>
> 	# Enable the firewall
> 	#
> -	if ! ${SYSCTL_W} net.inet.ip.fw.enable=1 1>/dev/null 2>&1; then
> +	if ! ${SYSCTL} net.inet.ip.fw.enable=1 1>/dev/null 2>&1; then
> 		warn "failed to enable IPv4 firewall"
> 	fi
> 	if afexists inet6; then
> -		if ! ${SYSCTL_W} net.inet6.ip6.fw.enable=1 1>/dev/null 2>&1
> +		if ! ${SYSCTL} net.inet6.ip6.fw.enable=1 1>/dev/null 2>&1
> 		then
> 			warn "failed to enable IPv6 firewall"
> 		fi
> @@ -90,9 +90,9 @@ ipfw_stop()
>
> 	# Disable the firewall
> 	#
> -	${SYSCTL_W} net.inet.ip.fw.enable=0
> +	${SYSCTL} net.inet.ip.fw.enable=0
> 	if afexists inet6; then
> -		${SYSCTL_W} net.inet6.ip6.fw.enable=0
> +		${SYSCTL} net.inet6.ip6.fw.enable=0
> 	fi
>
> 	# Stop firewall coscripts
>
> Modified: head/etc/rc.d/jail
> ==============================================================================
> --- head/etc/rc.d/jail	Wed Mar 30 01:10:11 2011	(r220152)
> +++ head/etc/rc.d/jail	Wed Mar 30 01:19:00 2011	(r220153)
> @@ -219,12 +219,12 @@ set_sysctl()
> 	if checkyesno $_knob ; then
> 		if [ "$_current" -ne 1 ]; then
> 			echo -n " ${_msg}=YES"
> -			${SYSCTL_W} 1>/dev/null ${_mib}=1
> +			${SYSCTL} 1>/dev/null ${_mib}=1
> 		fi
> 	else
> 		if [ "$_current" -ne 0 ]; then
> 			echo -n " ${_msg}=NO"
> -			${SYSCTL_W} 1>/dev/null ${_mib}=0
> +			${SYSCTL} 1>/dev/null ${_mib}=0
> 		fi
> 	fi
> }
>
> Modified: head/etc/rc.d/netoptions
> ==============================================================================
> --- head/etc/rc.d/netoptions	Wed Mar 30 01:10:11 2011	(r220152)
> +++ head/etc/rc.d/netoptions	Wed Mar 30 01:19:00 2011	(r220153)
> @@ -40,44 +40,44 @@ netoptions_inet()
> 	[12])
> 		netoptions_init
> 		echo -n " log_in_vain=${log_in_vain}"
> -		${SYSCTL_W} net.inet.tcp.log_in_vain=${log_in_vain} >/dev/null
> -		${SYSCTL_W} net.inet.udp.log_in_vain=${log_in_vain} >/dev/null
> +		${SYSCTL} net.inet.tcp.log_in_vain=${log_in_vain} >/dev/null
> +		${SYSCTL} net.inet.udp.log_in_vain=${log_in_vain} >/dev/null
> 		;;
> 	*)
> -		${SYSCTL_W} net.inet.tcp.log_in_vain=0 >/dev/null
> -		${SYSCTL_W} net.inet.udp.log_in_vain=0 >/dev/null
> +		${SYSCTL} net.inet.tcp.log_in_vain=0 >/dev/null
> +		${SYSCTL} net.inet.udp.log_in_vain=0 >/dev/null
> 		;;
> 	esac
>
> 	if checkyesno tcp_extensions; then
> -		${SYSCTL_W} net.inet.tcp.rfc1323=1 >/dev/null
> +		${SYSCTL} net.inet.tcp.rfc1323=1 >/dev/null
> 	else
> 		netoptions_init
> 		echo -n " rfc1323 extensions=${tcp_extensions}"
> -		${SYSCTL_W} net.inet.tcp.rfc1323=0 >/dev/null
> +		${SYSCTL} net.inet.tcp.rfc1323=0 >/dev/null
> 	fi
>
> 	if checkyesno tcp_keepalive; then
> -		${SYSCTL_W} net.inet.tcp.always_keepalive=1 >/dev/null
> +		${SYSCTL} net.inet.tcp.always_keepalive=1 >/dev/null
> 	else
> 		netoptions_init
> 		echo -n " TCP keepalive=${tcp_keepalive}"
> -		${SYSCTL_W} net.inet.tcp.always_keepalive=0 >/dev/null
> +		${SYSCTL} net.inet.tcp.always_keepalive=0 >/dev/null
> 	fi
>
> 	if checkyesno tcp_drop_synfin; then
> 		netoptions_init
> 		echo -n " drop SYN+FIN packets=${tcp_drop_synfin}"
> -		${SYSCTL_W} net.inet.tcp.drop_synfin=1 >/dev/null
> +		${SYSCTL} net.inet.tcp.drop_synfin=1 >/dev/null
> 	else
> -		${SYSCTL_W} net.inet.tcp.drop_synfin=0 >/dev/null
> +		${SYSCTL} net.inet.tcp.drop_synfin=0 >/dev/null
> 	fi
>
> 	case ${ip_portrange_first} in
> 	[0-9]*)
> 		netoptions_init
> 		echo -n " ip_portrange_first=$ip_portrange_first"
> -		${SYSCTL_W} net.inet.ip.portrange.first=$ip_portrange_first >/dev/null
> +		${SYSCTL} net.inet.ip.portrange.first=$ip_portrange_first >/dev/null
> 		;;
> 	esac
>
> @@ -85,7 +85,7 @@ netoptions_inet()
> 	[0-9]*)
> 		netoptions_init
> 		echo -n " ip_portrange_last=$ip_portrange_last"
> -		${SYSCTL_W} net.inet.ip.portrange.last=$ip_portrange_last >/dev/null
> +		${SYSCTL} net.inet.ip.portrange.last=$ip_portrange_last >/dev/null
> 		;;
> 	esac
> }
> @@ -95,16 +95,16 @@ netoptions_inet6()
> 	if checkyesno ipv6_ipv4mapping; then
> 		netoptions_init
> 		echo -n " ipv4-mapped-ipv6=${ipv6_ipv4mapping}"
> -		${SYSCTL_W} net.inet6.ip6.v6only=0 >/dev/null
> +		${SYSCTL} net.inet6.ip6.v6only=0 >/dev/null
> 	else
> -		${SYSCTL_W} net.inet6.ip6.v6only=1 >/dev/null
> +		${SYSCTL} net.inet6.ip6.v6only=1 >/dev/null
> 	fi
>
> 	if checkyesno ipv6_privacy; then
> 		netoptions_init
> 		echo -n " IPv6 Privacy Addresses"
> -		${SYSCTL_W} net.inet6.ip6.use_tempaddr=1 >/dev/null
> -		${SYSCTL_W} net.inet6.ip6.prefer_tempaddr=1 >/dev/null
> +		${SYSCTL} net.inet6.ip6.use_tempaddr=1 >/dev/null
> +		${SYSCTL} net.inet6.ip6.prefer_tempaddr=1 >/dev/null
> 	fi
> }
>
>
> Modified: head/etc/rc.d/routing
> ==============================================================================
> --- head/etc/rc.d/routing	Wed Mar 30 01:10:11 2011	(r220152)
> +++ head/etc/rc.d/routing	Wed Mar 30 01:19:00 2011	(r220153)
> @@ -264,57 +264,57 @@ options_inet()
> 	if checkyesno icmp_bmcastecho; then
> 		ropts_init
> 		echo -n ' broadcast ping responses=YES'
> -		${SYSCTL_W} net.inet.icmp.bmcastecho=1 > /dev/null
> +		${SYSCTL} net.inet.icmp.bmcastecho=1 > /dev/null
> 	else
> -		${SYSCTL_W} net.inet.icmp.bmcastecho=0 > /dev/null
> +		${SYSCTL} net.inet.icmp.bmcastecho=0 > /dev/null
> 	fi
>
> 	if checkyesno icmp_drop_redirect; then
> 		ropts_init
> 		echo -n ' ignore ICMP redirect=YES'
> -		${SYSCTL_W} net.inet.icmp.drop_redirect=1 > /dev/null
> +		${SYSCTL} net.inet.icmp.drop_redirect=1 > /dev/null
> 	else
> -		${SYSCTL_W} net.inet.icmp.drop_redirect=0 > /dev/null
> +		${SYSCTL} net.inet.icmp.drop_redirect=0 > /dev/null
> 	fi
>
> 	if checkyesno icmp_log_redirect; then
> 		ropts_init
> 		echo -n ' log ICMP redirect=YES'
> -		${SYSCTL_W} net.inet.icmp.log_redirect=1 > /dev/null
> +		${SYSCTL} net.inet.icmp.log_redirect=1 > /dev/null
> 	else
> -		${SYSCTL_W} net.inet.icmp.log_redirect=0 > /dev/null
> +		${SYSCTL} net.inet.icmp.log_redirect=0 > /dev/null
> 	fi
>
> 	if checkyesno gateway_enable; then
> 		ropts_init
> 		echo -n ' IPv4 gateway=YES'
> -		${SYSCTL_W} net.inet.ip.forwarding=1 > /dev/null
> +		${SYSCTL} net.inet.ip.forwarding=1 > /dev/null
> 	else
> -		${SYSCTL_W} net.inet.ip.forwarding=0 > /dev/null
> +		${SYSCTL} net.inet.ip.forwarding=0 > /dev/null
> 	fi
>
> 	if checkyesno forward_sourceroute; then
> 		ropts_init
> 		echo -n ' do source routing=YES'
> -		${SYSCTL_W} net.inet.ip.sourceroute=1 > /dev/null
> +		${SYSCTL} net.inet.ip.sourceroute=1 > /dev/null
> 	else
> -		${SYSCTL_W} net.inet.ip.sourceroute=0 > /dev/null
> +		${SYSCTL} net.inet.ip.sourceroute=0 > /dev/null
> 	fi
>
> 	if checkyesno accept_sourceroute; then
> 		ropts_init
> 		echo -n ' accept source routing=YES'
> -		${SYSCTL_W} net.inet.ip.accept_sourceroute=1 > /dev/null
> +		${SYSCTL} net.inet.ip.accept_sourceroute=1 > /dev/null
> 	else
> -		${SYSCTL_W} net.inet.ip.accept_sourceroute=0 > /dev/null
> +		${SYSCTL} net.inet.ip.accept_sourceroute=0 > /dev/null
> 	fi
>
> 	if checkyesno arpproxy_all; then
> 		ropts_init
> 		echo -n ' ARP proxyall=YES'
> -		${SYSCTL_W} net.link.ether.inet.proxyall=1 > /dev/null
> +		${SYSCTL} net.link.ether.inet.proxyall=1 > /dev/null
> 	else
> -		${SYSCTL_W} net.link.ether.inet.proxyall=0 > /dev/null
> +		${SYSCTL} net.link.ether.inet.proxyall=0 > /dev/null
> 	fi
> }
>
> @@ -323,9 +323,9 @@ options_inet6()
> 	if checkyesno ipv6_gateway_enable; then
> 		ropts_init
> 		echo -n ' IPv6 gateway=YES'
> -		${SYSCTL_W} net.inet6.ip6.forwarding=1 > /dev/null
> +		${SYSCTL} net.inet6.ip6.forwarding=1 > /dev/null
> 	else
> -		${SYSCTL_W} net.inet6.ip6.forwarding=0 > /dev/null
> +		${SYSCTL} net.inet6.ip6.forwarding=0 > /dev/null
> 	fi
> }
>
> @@ -338,9 +338,9 @@ options_ipx()
> 	if checkyesno ipxgateway_enable; then
> 		ropts_init
> 		echo -n ' IPX gateway=YES'
> -		${SYSCTL_W} net.ipx.ipx.ipxforwarding=1 > /dev/null
> +		${SYSCTL} net.ipx.ipx.ipxforwarding=1 > /dev/null
> 	else
> -		${SYSCTL_W} net.ipx.ipx.ipxforwarding=0 > /dev/null
> +		${SYSCTL} net.ipx.ipx.ipxforwarding=0 > /dev/null
> 	fi
> }
>
>
> Modified: head/etc/rc.d/securelevel
> ==============================================================================
> --- head/etc/rc.d/securelevel	Wed Mar 30 01:10:11 2011	(r220152)
> +++ head/etc/rc.d/securelevel	Wed Mar 30 01:19:00 2011	(r220153)
> @@ -20,7 +20,7 @@ securelevel_start()
> {
> 	if [ ${kern_securelevel} -ge 0 ]; then
> 		echo 'Raising kernel security level: '
> -		${SYSCTL_W} kern.securelevel=${kern_securelevel}
> +		${SYSCTL} kern.securelevel=${kern_securelevel}
> 	fi
> }
>
>

-- 
Bjoern A. Zeeb                                 You have to have visions!
          Stop bit received. Insert coin for new address family.

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 16:16:53 2011
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 6ACF4106566B;
	Sun,  3 Apr 2011 16:16:53 +0000 (UTC)
	(envelope-from emaste@freebsd.org)
Received: from mail1.sandvine.com (Mail1.sandvine.com [64.7.137.134])
	by mx1.freebsd.org (Postfix) with ESMTP id 210808FC17;
	Sun,  3 Apr 2011 16:16:53 +0000 (UTC)
Received: from labgw2.phaedrus.sandvine.com (192.168.222.22) by
	WTL-EXCH-1.sandvine.com (192.168.196.31) with Microsoft SMTP Server id
	14.0.694.0; Sun, 3 Apr 2011 12:06:02 -0400
Received: by labgw2.phaedrus.sandvine.com (Postfix, from userid 10332)	id
	403F633C00; Sun,  3 Apr 2011 12:06:02 -0400 (EDT)
Date: Sun, 3 Apr 2011 12:06:02 -0400
From: Ed Maste 
To: "Bjoern A. Zeeb" 
Message-ID: <20110403160602.GA67576@sandvine.com>
References: <201103300119.p2U1J18L046334@svn.freebsd.org>
	
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
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, Ed Maste 
Subject: Re: svn commit: r220153 - head/etc/rc.d
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, 03 Apr 2011 16:16:53 -0000

On Sun, Apr 03, 2011 at 02:56:50PM +0000, Bjoern A. Zeeb wrote:

> On Wed, 30 Mar 2011, Ed Maste wrote:

> > Replace ${SYSCTL_W} with ${SYSCTL} in rc.d scripts, as they are identical.
> 
>              ... for example OSX really requires the -w to alter a
> sysctl while we permit without.   I thin kthe correct fix should have
> been to add a -w to SYSCTL_W.

NetBSD also requires -w as far as I know.  However, we've deprecated the
switch -- see sysctl(8):

   The -w option has been deprecated and is silently ignored.

I don't think there's much value in using a deprecated and ignored flag
in our startup scripts.

> That way one can grep for a read vs.
> write in the startup scrpits a lot more easily, etc.

Something along the lines of egrep -ir 'sysctl.*=' can be used to find
places that sysctls are written; this has the benefit of finding the
cases where we're already not using a ${SYSCTL} or ${SYSCTL_W} variable
today.

-Ed

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 17:36:34 2011
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 6BAD6106564A;
	Sun,  3 Apr 2011 17:36: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 3DEC98FC0C;
	Sun,  3 Apr 2011 17:36:34 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p33HaYbc044814;
	Sun, 3 Apr 2011 17:36:34 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p33HaY3Q044812;
	Sun, 3 Apr 2011 17:36:34 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104031736.p33HaY3Q044812@svn.freebsd.org>
From: Adrian Chadd 
Date: Sun, 3 Apr 2011 17:36: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: r220298 - head/sys/dev/ath/ath_hal
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, 03 Apr 2011 17:36:34 -0000

Author: adrian
Date: Sun Apr  3 17:36:32 2011
New Revision: 220298
URL: http://svn.freebsd.org/changeset/base/220298

Log:
  Add in the clock timing calculation when Merlin is using the 5ghz fast clock.
  This is a 44mhz clock, not a 40mhz clock like normal for 5ghz operation.

Modified:
  head/sys/dev/ath/ath_hal/ah.c

Modified: head/sys/dev/ath/ath_hal/ah.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.c	Sun Apr  3 14:39:55 2011	(r220297)
+++ head/sys/dev/ath/ath_hal/ah.c	Sun Apr  3 17:36:32 2011	(r220298)
@@ -21,6 +21,7 @@
 #include "ah.h"
 #include "ah_internal.h"
 #include "ah_devid.h"
+#include "ah_eeprom.h"			/* for 5ghz fast clock flag */
 
 #include "ar5416/ar5416reg.h"		/* NB: includes ar5212reg.h */
 
@@ -419,6 +420,8 @@ ath_hal_chan2wmode(struct ath_hal *ah, c
                                      /* 11a Turbo  11b  11g  108g */
 static const uint8_t CLOCK_RATE[]  = { 40,  80,   22,  44,   88  };
 
+#define	CLOCK_FAST_RATE_5GHZ_OFDM	44
+
 u_int
 ath_hal_mac_clks(struct ath_hal *ah, u_int usecs)
 {
@@ -426,7 +429,12 @@ ath_hal_mac_clks(struct ath_hal *ah, u_i
 	u_int clks;
 
 	/* NB: ah_curchan may be null when called attach time */
-	if (c != AH_NULL) {
+	/* XXX merlin and later specific workaround - 5ghz fast clock is 44 */
+	if (c != AH_NULL && IS_5GHZ_FAST_CLOCK_EN(ah, c)) {
+		clks = usecs * CLOCK_FAST_RATE_5GHZ_OFDM;
+		if (IEEE80211_IS_CHAN_HT40(c))
+			clks <<= 1;
+	} else if (c != AH_NULL) {
 		clks = usecs * CLOCK_RATE[ath_hal_chan2wmode(ah, c)];
 		if (IEEE80211_IS_CHAN_HT40(c))
 			clks <<= 1;
@@ -442,7 +450,12 @@ ath_hal_mac_usec(struct ath_hal *ah, u_i
 	u_int usec;
 
 	/* NB: ah_curchan may be null when called attach time */
-	if (c != AH_NULL) {
+	/* XXX merlin and later specific workaround - 5ghz fast clock is 44 */
+	if (c != AH_NULL && IS_5GHZ_FAST_CLOCK_EN(ah, c)) {
+		usec = clks / CLOCK_FAST_RATE_5GHZ_OFDM;
+		if (IEEE80211_IS_CHAN_HT40(c))
+			usec >>= 1;
+	} else if (c != AH_NULL) {
 		usec = clks / CLOCK_RATE[ath_hal_chan2wmode(ah, c)];
 		if (IEEE80211_IS_CHAN_HT40(c))
 			usec >>= 1;

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 17:38:13 2011
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 BFA541065674;
	Sun,  3 Apr 2011 17:38:13 +0000 (UTC)
	(envelope-from trociny@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id ACD948FC0C;
	Sun,  3 Apr 2011 17:38:13 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p33HcDNI044941;
	Sun, 3 Apr 2011 17:38:13 GMT (envelope-from trociny@svn.freebsd.org)
Received: (from trociny@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p33HcDXa044940;
	Sun, 3 Apr 2011 17:38:13 GMT (envelope-from trociny@svn.freebsd.org)
Message-Id: <201104031738.p33HcDXa044940@svn.freebsd.org>
From: Mikolaj Golub 
Date: Sun, 3 Apr 2011 17:38: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: r220299 - head/sys/geom/eli
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, 03 Apr 2011 17:38:13 -0000

Author: trociny
Date: Sun Apr  3 17:38:12 2011
New Revision: 220299
URL: http://svn.freebsd.org/changeset/base/220299

Log:
  In g_eli_read_done() and g_eli_write_done(), for a bio with
  bio_children > 1, g_destroy_bio() is never called and the bio
  leaks. Fix this by calling g_destroy_bio() earlier, before the check.
  
  Submitted by:	Victor Balada Diaz  (initial version)
  Approved by:	pjd (mentor)
  MFC after:	1 week

Modified:
  head/sys/geom/eli/g_eli.c

Modified: head/sys/geom/eli/g_eli.c
==============================================================================
--- head/sys/geom/eli/g_eli.c	Sun Apr  3 17:36:32 2011	(r220298)
+++ head/sys/geom/eli/g_eli.c	Sun Apr  3 17:38:12 2011	(r220299)
@@ -161,13 +161,13 @@ g_eli_read_done(struct bio *bp)
 	pbp = bp->bio_parent;
 	if (pbp->bio_error == 0)
 		pbp->bio_error = bp->bio_error;
+	g_destroy_bio(bp);
 	/*
 	 * Do we have all sectors already?
 	 */
 	pbp->bio_inbed++;
 	if (pbp->bio_inbed < pbp->bio_children)
 		return;
-	g_destroy_bio(bp);
 	sc = pbp->bio_to->geom->softc;
 	if (pbp->bio_error != 0) {
 		G_ELI_LOGREQ(0, pbp, "%s() failed", __func__);
@@ -203,6 +203,7 @@ g_eli_write_done(struct bio *bp)
 		if (bp->bio_error != 0)
 			pbp->bio_error = bp->bio_error;
 	}
+	g_destroy_bio(bp);
 	/*
 	 * Do we have all sectors already?
 	 */
@@ -216,7 +217,6 @@ g_eli_write_done(struct bio *bp)
 		    pbp->bio_error);
 		pbp->bio_completed = 0;
 	}
-	g_destroy_bio(bp);
 	/*
 	 * Write is finished, send it up.
 	 */

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 20:03:46 2011
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 30A47106566B;
	Sun,  3 Apr 2011 20:03:46 +0000 (UTC)
	(envelope-from hselasky@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1F9E38FC13;
	Sun,  3 Apr 2011 20:03:46 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p33K3kGh054194;
	Sun, 3 Apr 2011 20:03:46 GMT (envelope-from hselasky@svn.freebsd.org)
Received: (from hselasky@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p33K3kkw054188;
	Sun, 3 Apr 2011 20:03:46 GMT (envelope-from hselasky@svn.freebsd.org)
Message-Id: <201104032003.p33K3kkw054188@svn.freebsd.org>
From: Hans Petter Selasky 
Date: Sun, 3 Apr 2011 20:03:46 +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: r220301 - in head: sys/dev/usb usr.sbin/usbdump
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, 03 Apr 2011 20:03:46 -0000

Author: hselasky
Date: Sun Apr  3 20:03:45 2011
New Revision: 220301
URL: http://svn.freebsd.org/changeset/base/220301

Log:
  - Improvements to USB PF solution
  - Add more fields for USB device and host mode
  - Add more information to USB PF header so that decoding
    can easily be done by software analyzer tools like
    Wireshark.
  - Optimise usbdump to display USB streams in text format
    more efficiently.
  - Software using USB PF must be recompiled after
    this commit, due to structure changes.
  
  MFC after:	7 days
  Approved by:	thompsa (mentor)

Modified:
  head/sys/dev/usb/usb_pf.c
  head/sys/dev/usb/usb_pf.h
  head/sys/dev/usb/usb_transfer.c
  head/sys/dev/usb/usbdi.h
  head/usr.sbin/usbdump/usbdump.c

Modified: head/sys/dev/usb/usb_pf.c
==============================================================================
--- head/sys/dev/usb/usb_pf.c	Sun Apr  3 18:56:16 2011	(r220300)
+++ head/sys/dev/usb/usb_pf.c	Sun Apr  3 20:03:45 2011	(r220301)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -57,28 +58,44 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+static int usb_no_pf;
+
+SYSCTL_INT(_hw_usb, OID_AUTO, no_pf, CTLFLAG_RW,
+    &usb_no_pf, 0, "Set to disable USB packet filtering");
+
+TUNABLE_INT("hw.usb.no_pf", &usb_no_pf);
+
 void
 usbpf_attach(struct usb_bus *ubus)
 {
 	struct ifnet *ifp;
 
+	if (usb_no_pf != 0) {
+		ubus->ifp = NULL;
+		return;
+	}
+
 	ifp = ubus->ifp = if_alloc(IFT_USB);
+	if (ifp == NULL) {
+		device_printf(ubus->parent, "usbpf: Could not allocate "
+		    "instance\n");
+		return;
+	}
+
 	if_initname(ifp, "usbus", device_get_unit(ubus->bdev));
 	ifp->if_flags = IFF_CANTCONFIG;
 	if_attach(ifp);
 	if_up(ifp);
 
-	KASSERT(sizeof(struct usbpf_pkthdr) == USBPF_HDR_LEN,
-	    ("wrong USB pf header length (%zd)", sizeof(struct usbpf_pkthdr)));
-
 	/*
-	 * XXX According to the specification of DLT_USB, it indicates packets
-	 * beginning with USB setup header.  But not sure all packets would be.
+	 * XXX According to the specification of DLT_USB, it indicates
+	 * packets beginning with USB setup header. But not sure all
+	 * packets would be.
 	 */
 	bpfattach(ifp, DLT_USB, USBPF_HDR_LEN);
 
 	if (bootverbose)
-		device_printf(ubus->parent, "usbpf attached\n");
+		device_printf(ubus->parent, "usbpf: Attached\n");
 }
 
 void
@@ -172,79 +189,204 @@ usbpf_aggregate_status(struct usb_xfer_f
 	return (val);
 }
 
+static int
+usbpf_xfer_frame_is_read(struct usb_xfer *xfer, uint32_t frame)
+{
+	int isread;
+
+	if ((frame == 0) && (xfer->flags_int.control_xfr != 0) &&
+	    (xfer->flags_int.control_hdr != 0)) {
+		/* special case */
+		if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) {
+			/* The device controller writes to memory */
+			isread = 1;
+		} else {
+			/* The host controller reads from memory */
+			isread = 0;
+		}
+	} else {
+		isread = USB_GET_DATA_ISREAD(xfer);
+	}
+	return (isread);
+}
+
+static uint32_t
+usbpf_xfer_precompute_size(struct usb_xfer *xfer, int type)
+{
+	uint32_t totlen;
+	uint32_t x;
+	uint32_t nframes;
+
+	if (type == USBPF_XFERTAP_SUBMIT)
+		nframes = xfer->nframes;
+	else
+		nframes = xfer->aframes;
+
+	totlen = USBPF_HDR_LEN + (USBPF_FRAME_HDR_LEN * nframes);
+
+	/* precompute all trace lengths */
+	for (x = 0; x != nframes; x++) {
+		if (usbpf_xfer_frame_is_read(xfer, x)) {
+			if (type != USBPF_XFERTAP_SUBMIT) {
+				totlen += USBPF_FRAME_ALIGN(
+				    xfer->frlengths[x]);
+			}
+		} else {
+			if (type == USBPF_XFERTAP_SUBMIT) {
+				totlen += USBPF_FRAME_ALIGN(
+				    xfer->frlengths[x]);
+			}
+		}
+	}
+	return (totlen);
+}
+
 void
 usbpf_xfertap(struct usb_xfer *xfer, int type)
 {
-	struct usb_endpoint *ep = xfer->endpoint;
-	struct usb_page_search res;
-	struct usb_xfer_root *info = xfer->xroot;
-	struct usb_bus *bus = info->bus;
+	struct usb_bus *bus;
 	struct usbpf_pkthdr *up;
-	usb_frlength_t isoc_offset = 0;
-	int i;
-	char *buf, *ptr, *end;
+	struct usbpf_framehdr *uf;
+	usb_frlength_t offset;
+	uint32_t totlen;
+	uint32_t frame;
+	uint32_t temp;
+	uint32_t nframes;
+	uint32_t x;
+	uint8_t *buf;
+	uint8_t *ptr;
+
+	bus = xfer->xroot->bus;
 
+	/* sanity checks */
+	if (usb_no_pf != 0)
+		return;
+	if (bus->ifp == NULL)
+		return;
 	if (!bpf_peers_present(bus->ifp->if_bpf))
 		return;
 
+	totlen = usbpf_xfer_precompute_size(xfer, type);
+
+	if (type == USBPF_XFERTAP_SUBMIT)
+		nframes = xfer->nframes;
+	else
+		nframes = xfer->aframes;
+
 	/*
-	 * XXX TODO
-	 * Allocating the buffer here causes copy operations twice what's
-	 * really inefficient. Copying usbpf_pkthdr and data is for USB packet
-	 * read filter to pass a virtually linear buffer.
+	 * XXX TODO XXX
+	 *
+	 * When BPF supports it we could pass a fragmented array of
+	 * buffers avoiding the data copy operation here.
 	 */
-	buf = ptr = malloc(sizeof(struct usbpf_pkthdr) + (USB_PAGE_SIZE * 5),
-	    M_TEMP, M_NOWAIT);
+	buf = ptr = malloc(totlen, M_TEMP, M_NOWAIT);
 	if (buf == NULL) {
-		printf("usbpf_xfertap: out of memory\n");	/* XXX */
+		device_printf(bus->parent, "usbpf: Out of memory\n");
 		return;
 	}
-	end = buf + sizeof(struct usbpf_pkthdr) + (USB_PAGE_SIZE * 5);
 
-	bzero(ptr, sizeof(struct usbpf_pkthdr));
 	up = (struct usbpf_pkthdr *)ptr;
-	up->up_busunit = htole32(device_get_unit(bus->bdev));
+	ptr += USBPF_HDR_LEN;
+
+	/* fill out header */
+	temp = device_get_unit(bus->bdev);
+	up->up_totlen = htole32(totlen);
+	up->up_busunit = htole32(temp);
+	up->up_address = xfer->xroot->udev->device_index;
+	if (xfer->flags_int.usb_mode == USB_MODE_DEVICE)
+		up->up_mode = USBPF_MODE_DEVICE;
+	else
+		up->up_mode = USBPF_MODE_HOST;
 	up->up_type = type;
-	up->up_xfertype = ep->edesc->bmAttributes & UE_XFERTYPE;
-	up->up_address = xfer->address;
-	up->up_endpoint = xfer->endpointno;
-	up->up_flags = htole32(usbpf_aggregate_xferflags(&xfer->flags));
-	up->up_status = htole32(usbpf_aggregate_status(&xfer->flags_int));
-	switch (type) {
-	case USBPF_XFERTAP_SUBMIT:
-		up->up_length = htole32(xfer->sumlen);
-		up->up_frames = htole32(xfer->nframes);
-		break;
-	case USBPF_XFERTAP_DONE:
-		up->up_length = htole32(xfer->actlen);
-		up->up_frames = htole32(xfer->aframes);
-		break;
-	default:
-		panic("wrong usbpf type (%d)", type);
-	}
-
-	up->up_error = htole32(xfer->error);
-	up->up_interval = htole32(xfer->interval);
-	ptr += sizeof(struct usbpf_pkthdr);
-
-	for (i = 0; i < up->up_frames; i++) {
-		if (ptr + sizeof(uint32_t) >= end)
-			goto done;
-		*((uint32_t *)ptr) = htole32(xfer->frlengths[i]);
-		ptr += sizeof(uint32_t);
-
-		if (ptr + xfer->frlengths[i] >= end)
-			goto done;
-		if (xfer->flags_int.isochronous_xfr == 1) {
-			usbd_get_page(&xfer->frbuffers[0], isoc_offset, &res);
-			isoc_offset += xfer->frlengths[i];
-		} else
-			usbd_get_page(&xfer->frbuffers[i], 0, &res);
-		bcopy(res.buffer, ptr, xfer->frlengths[i]);
-		ptr += xfer->frlengths[i];
+	up->up_xfertype = xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE;
+	temp = usbpf_aggregate_xferflags(&xfer->flags);
+	up->up_flags = htole32(temp);
+	temp = usbpf_aggregate_status(&xfer->flags_int);
+	up->up_status = htole32(temp);
+	temp = xfer->error;
+	up->up_error = htole32(temp);
+	temp = xfer->interval;
+	up->up_interval = htole32(temp);
+	up->up_frames = htole32(nframes);
+	temp = xfer->max_packet_size;
+	up->up_packet_size = htole32(temp);
+	temp = xfer->max_packet_count;
+	up->up_packet_count = htole32(temp);
+	temp = xfer->endpointno;
+	up->up_endpoint = htole32(temp);
+	up->up_speed = xfer->xroot->udev->speed;
+
+	/* clear reserved area */
+	memset(up->up_reserved, 0, sizeof(up->up_reserved));
+
+	/* init offset and frame */
+	offset = 0;
+	frame = 0;
+
+	/* iterate all the USB frames and copy data, if any */
+	for (x = 0; x != nframes; x++) {
+		uint32_t length;
+		int isread;
+
+		/* get length */
+		length = xfer->frlengths[x];
+
+		/* get frame header pointer */
+		uf = (struct usbpf_framehdr *)ptr;
+		ptr += USBPF_FRAME_HDR_LEN;
+
+		/* fill out packet header */
+		uf->length = htole32(length);
+		uf->flags = 0;
+
+		/* get information about data read/write */
+		isread = usbpf_xfer_frame_is_read(xfer, x);
+
+		/* check if we need to copy any data */
+		if (isread) {
+			if (type == USBPF_XFERTAP_SUBMIT)
+				length = 0;
+			else {
+				uf->flags |= htole32(
+				    USBPF_FRAMEFLAG_DATA_FOLLOWS);
+			}
+		} else {
+			if (type != USBPF_XFERTAP_SUBMIT)
+				length = 0;
+			else {
+				uf->flags |= htole32(
+				    USBPF_FRAMEFLAG_DATA_FOLLOWS);
+			}
+		}
+
+		/* check if data is read direction */
+		if (isread)
+			uf->flags |= htole32(USBPF_FRAMEFLAG_READ);
+
+		/* copy USB data, if any */
+		if (length != 0) {
+			/* copy data */
+			usbd_copy_out(&xfer->frbuffers[frame],
+			    offset, ptr, length);
+
+			/* align length */
+			temp = USBPF_FRAME_ALIGN(length);
+
+			/* zero pad */
+			if (temp != length)
+				memset(ptr + length, 0, temp - length);
+
+			ptr += temp;
+		}
+
+		if (xfer->flags_int.isochronous_xfr) {
+			offset += usbd_xfer_old_frame_length(xfer, x);
+		} else {
+			frame ++;
+		}
 	}
 
-	bpf_tap(bus->ifp->if_bpf, buf, ptr - buf);
-done:
+	bpf_tap(bus->ifp->if_bpf, buf, totlen);
+
 	free(buf, M_TEMP);
 }

Modified: head/sys/dev/usb/usb_pf.h
==============================================================================
--- head/sys/dev/usb/usb_pf.h	Sun Apr  3 18:56:16 2011	(r220300)
+++ head/sys/dev/usb/usb_pf.h	Sun Apr  3 20:03:45 2011	(r220301)
@@ -38,11 +38,14 @@
 #define	_DEV_USB_PF_H
 
 struct usbpf_pkthdr {
+	uint32_t	up_totlen;	/* Total length including all headers */
 	uint32_t	up_busunit;	/* Host controller unit number */
-	uint8_t		up_address;	/* USB device address */
-	uint8_t		up_endpoint;	/* USB endpoint */
+	uint8_t		up_address;	/* USB device index */
+	uint8_t		up_mode;	/* Mode of transfer */
+#define	USBPF_MODE_HOST		0
+#define	USBPF_MODE_DEVICE	1
 	uint8_t		up_type;	/* points SUBMIT / DONE */
-	uint8_t		up_xfertype;	/* Transfer type */
+	uint8_t		up_xfertype;	/* Transfer type, see USB2.0 spec. */
 	uint32_t	up_flags;	/* Transfer flags */
 #define	USBPF_FLAG_FORCE_SHORT_XFER	(1 << 0)
 #define	USBPF_FLAG_SHORT_XFER_OK	(1 << 1)
@@ -67,24 +70,43 @@ struct usbpf_pkthdr {
 #define	USBPF_STATUS_CONTROL_STALL	(1 << 10)
 #define	USBPF_STATUS_SHORT_FRAMES_OK	(1 << 11)
 #define	USBPF_STATUS_SHORT_XFER_OK	(1 << 12)
-#if USB_HAVE_BUSDMA
 #define	USBPF_STATUS_BDMA_ENABLE	(1 << 13)
 #define	USBPF_STATUS_BDMA_NO_POST_SYNC	(1 << 14)
 #define	USBPF_STATUS_BDMA_SETUP		(1 << 15)
-#endif
 #define	USBPF_STATUS_ISOCHRONOUS_XFR	(1 << 16)
 #define	USBPF_STATUS_CURR_DMA_SET	(1 << 17)
 #define	USBPF_STATUS_CAN_CANCEL_IMMED	(1 << 18)
 #define	USBPF_STATUS_DOING_CALLBACK	(1 << 19)
-	uint32_t	up_length;	/* Total data length (submit/actual) */
-	uint32_t	up_frames;	/* USB frame number (submit/actual) */
-	uint32_t	up_error;	/* usb_error_t */
-	uint32_t	up_interval;	/* for interrupt and isoc */
+	uint32_t	up_error;	/* USB error, see USB_ERR_XXX */
+	uint32_t	up_interval;	/* For interrupt and isoc (ms) */
+	uint32_t	up_frames;	/* Number of following frames */
+	uint32_t	up_packet_size;	/* Packet size used */
+	uint32_t	up_packet_count;	/* Packet count used */
+	uint32_t	up_endpoint;	/* USB endpoint / stream ID */
+	uint8_t		up_speed;	/* USB speed, see USB_SPEED_XXX */
 	/* sizeof(struct usbpf_pkthdr) == 128 bytes */
-	uint8_t		up_reserved[96];
+	uint8_t		up_reserved[83];
+};
+
+struct usbpf_framehdr {
+	/*
+	 * The frame length field excludes length of frame header and
+	 * any alignment.
+	 */
+	uint32_t length;
+#define	USBPF_FRAME_ALIGN(x)		(((x) + 3) & ~3)
+	uint32_t flags;
+#define	USBPF_FRAMEFLAG_READ		(1 << 0)
+#define	USBPF_FRAMEFLAG_DATA_FOLLOWS	(1 << 1)
 };
 
-#define	USBPF_HDR_LEN		128
+#define	USBPF_HDR_LEN		128	/* bytes */
+#define	USBPF_FRAME_HDR_LEN	8	/* bytes */
+
+extern uint8_t usbpf_pkthdr_size_ok[
+    (sizeof(struct usbpf_pkthdr) == USBPF_HDR_LEN) ? 1 : -1];
+extern uint8_t usbpf_framehdr_size_ok[
+    (sizeof(struct usbpf_framehdr) == USBPF_FRAME_HDR_LEN) ? 1 : -1];
 
 #define	USBPF_XFERTAP_SUBMIT	0
 #define	USBPF_XFERTAP_DONE	1

Modified: head/sys/dev/usb/usb_transfer.c
==============================================================================
--- head/sys/dev/usb/usb_transfer.c	Sun Apr  3 18:56:16 2011	(r220300)
+++ head/sys/dev/usb/usb_transfer.c	Sun Apr  3 20:03:45 2011	(r220301)
@@ -664,9 +664,13 @@ usbd_transfer_setup_sub(struct usb_setup
 		}
 		xfer->max_data_length -= REQ_SIZE;
 	}
-	/* setup "frlengths" */
+	/*
+	 * Setup "frlengths" and shadow "frlengths" for keeping the
+	 * initial frame lengths when a USB transfer is complete. This
+	 * information is useful when computing isochronous offsets.
+	 */
 	xfer->frlengths = parm->xfer_length_ptr;
-	parm->xfer_length_ptr += n_frlengths;
+	parm->xfer_length_ptr += 2 * n_frlengths;
 
 	/* setup "frbuffers" */
 	xfer->frbuffers = parm->xfer_page_cache_ptr;
@@ -1579,9 +1583,12 @@ usbd_transfer_submit(struct usb_xfer *xf
 		USB_BUS_UNLOCK(bus);
 		return;
 	}
-	/* compute total transfer length */
+	/* compute some variables */
 
 	for (x = 0; x != xfer->nframes; x++) {
+		/* make a copy of the frlenghts[] */
+		xfer->frlengths[x + xfer->max_frame_count] = xfer->frlengths[x];
+		/* compute total transfer length */
 		xfer->sumlen += xfer->frlengths[x];
 		if (xfer->sumlen < xfer->frlengths[x]) {
 			/* length wrapped around */
@@ -1970,6 +1977,22 @@ usbd_xfer_frame_data(struct usb_xfer *xf
 		*len = xfer->frlengths[frindex];
 }
 
+/*------------------------------------------------------------------------*
+ *	usbd_xfer_old_frame_length
+ *
+ * This function returns the framelength of the given frame at the
+ * time the transfer was submitted. This function can be used to
+ * compute the starting data pointer of the next isochronous frame
+ * when an isochronous transfer has completed.
+ *------------------------------------------------------------------------*/
+usb_frlength_t
+usbd_xfer_old_frame_length(struct usb_xfer *xfer, usb_frcount_t frindex)
+{
+	KASSERT(frindex < xfer->max_frame_count, ("frame index overflow"));
+
+	return (xfer->frlengths[frindex + xfer->max_frame_count]);
+}
+
 void
 usbd_xfer_status(struct usb_xfer *xfer, int *actlen, int *sumlen, int *aframes,
     int *nframes)

Modified: head/sys/dev/usb/usbdi.h
==============================================================================
--- head/sys/dev/usb/usbdi.h	Sun Apr  3 18:56:16 2011	(r220300)
+++ head/sys/dev/usb/usbdi.h	Sun Apr  3 20:03:45 2011	(r220301)
@@ -496,6 +496,8 @@ void	usbd_set_power_mode(struct usb_devi
 uint8_t	usbd_filter_power_mode(struct usb_device *udev, uint8_t power_mode);
 uint8_t	usbd_device_attached(struct usb_device *udev);
 
+usb_frlength_t
+	usbd_xfer_old_frame_length(struct usb_xfer *xfer, usb_frcount_t frindex);
 void	usbd_xfer_status(struct usb_xfer *xfer, int *actlen, int *sumlen,
 	    int *aframes, int *nframes);
 struct usb_page_cache *usbd_xfer_get_frame(struct usb_xfer *xfer,

Modified: head/usr.sbin/usbdump/usbdump.c
==============================================================================
--- head/usr.sbin/usbdump/usbdump.c	Sun Apr  3 18:56:16 2011	(r220300)
+++ head/usr.sbin/usbdump/usbdump.c	Sun Apr  3 20:03:45 2011	(r220301)
@@ -52,8 +52,8 @@
 
 struct usbcap {
 	int		fd;		/* fd for /dev/usbpf */
-	u_int		bufsize;
-	char		*buffer;
+	uint32_t	bufsize;
+	uint8_t		*buffer;
 
 	/* for -w option */
 	int		wfd;
@@ -62,11 +62,11 @@ struct usbcap {
 };
 
 struct usbcap_filehdr {
-	u_int		magic;
+	uint32_t	magic;
 #define	USBCAP_FILEHDR_MAGIC	0x9a90000e
-	u_char		major;
-	u_char		minor;
-	u_char		reserved[26];
+	uint8_t   	major;
+	uint8_t		minor;
+	uint8_t		reserved[26];
 } __packed;
 
 static int doexit = 0;
@@ -76,7 +76,7 @@ static const char *i_arg = "usbus0";
 static const char *r_arg = NULL;
 static const char *w_arg = NULL;
 static const char *errstr_table[USB_ERR_MAX] = {
-	[USB_ERR_NORMAL_COMPLETION]	= "NORMAL_COMPLETION",
+	[USB_ERR_NORMAL_COMPLETION]	= "0",
 	[USB_ERR_PENDING_REQUESTS]	= "PENDING_REQUESTS",
 	[USB_ERR_NOT_STARTED]		= "NOT_STARTED",
 	[USB_ERR_INVAL]			= "INVAL",
@@ -107,13 +107,21 @@ static const char *errstr_table[USB_ERR_
 	[USB_ERR_NOT_LOCKED]		= "NOT_LOCKED",
 };
 
-static const char *xfertype_table[] = {
+static const char *xfertype_table[4] = {
 	[UE_CONTROL]			= "CTRL",
 	[UE_ISOCHRONOUS]		= "ISOC",
 	[UE_BULK]			= "BULK",
 	[UE_INTERRUPT]			= "INTR"
 };
 
+static const char *speed_table[USB_SPEED_MAX] = {
+	[USB_SPEED_FULL] = "FULL",
+	[USB_SPEED_HIGH] = "HIGH",
+	[USB_SPEED_LOW] = "LOW",
+	[USB_SPEED_VARIABLE] = "VARI",
+	[USB_SPEED_SUPER] = "SUPER",
+};
+
 static void
 handle_sigint(int sig)
 {
@@ -122,182 +130,282 @@ handle_sigint(int sig)
 	doexit = 1;
 }
 
-static void
-print_flags(u_int32_t flags)
+#define	FLAGS(x, name)	\
+	(((x) & USBPF_FLAG_##name) ? #name "|" : "")
+
+#define	STATUS(x, name) \
+	(((x) & USBPF_STATUS_##name) ? #name "|" : "")
+
+static const char *
+usb_errstr(uint32_t error)
 {
-#define	PRINTFLAGS(name)			\
-	if ((flags & USBPF_FLAG_##name) != 0)	\
-		printf("%s ", #name);
-	printf(" flags %#x", flags);
-	printf(" < ");
-	PRINTFLAGS(FORCE_SHORT_XFER);
-	PRINTFLAGS(SHORT_XFER_OK);
-	PRINTFLAGS(SHORT_FRAMES_OK);
-	PRINTFLAGS(PIPE_BOF);
-	PRINTFLAGS(PROXY_BUFFER);
-	PRINTFLAGS(EXT_BUFFER);
-	PRINTFLAGS(MANUAL_STATUS);
-	PRINTFLAGS(NO_PIPE_OK);
-	PRINTFLAGS(STALL_PIPE);
-	printf(">\n");
-#undef PRINTFLAGS
+	if (error >= USB_ERR_MAX || errstr_table[error] == NULL)
+		return ("UNKNOWN");
+	else
+		return (errstr_table[error]);
+}
+
+static const char *
+usb_speedstr(uint8_t speed)
+{
+	if (speed >= USB_SPEED_MAX  || speed_table[speed] == NULL)
+		return ("UNKNOWN");
+	else
+		return (speed_table[speed]);
+}
+
+static void
+print_flags(uint32_t flags)
+{
+	printf(" flags %#x <%s%s%s%s%s%s%s%s%s0>\n",
+	    flags,
+	    FLAGS(flags, FORCE_SHORT_XFER),
+	    FLAGS(flags, SHORT_XFER_OK),
+	    FLAGS(flags, SHORT_FRAMES_OK),
+	    FLAGS(flags, PIPE_BOF),
+	    FLAGS(flags, PROXY_BUFFER),
+	    FLAGS(flags, EXT_BUFFER),
+	    FLAGS(flags, MANUAL_STATUS),
+	    FLAGS(flags, NO_PIPE_OK),
+	    FLAGS(flags, STALL_PIPE));
+}
+
+static void
+print_status(uint32_t status)
+{
+	printf(" status %#x <%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s0>\n",
+	    status, 
+	    STATUS(status, OPEN),
+	    STATUS(status, TRANSFERRING),
+	    STATUS(status, DID_DMA_DELAY),
+	    STATUS(status, DID_CLOSE),
+	    STATUS(status, DRAINING),
+	    STATUS(status, STARTED),
+	    STATUS(status, BW_RECLAIMED),
+	    STATUS(status, CONTROL_XFR),
+	    STATUS(status, CONTROL_HDR),
+	    STATUS(status, CONTROL_ACT),
+	    STATUS(status, CONTROL_STALL),
+	    STATUS(status, SHORT_FRAMES_OK),
+	    STATUS(status, SHORT_XFER_OK),
+	    STATUS(status, BDMA_ENABLE),
+	    STATUS(status, BDMA_NO_POST_SYNC),
+	    STATUS(status, BDMA_SETUP),
+	    STATUS(status, ISOCHRONOUS_XFR),
+	    STATUS(status, CURR_DMA_SET),
+	    STATUS(status, CAN_CANCEL_IMMED),
+	    STATUS(status, DOING_CALLBACK));
 }
 
+/*
+ * Dump a byte into hex format.
+ */
 static void
-print_status(u_int32_t status)
-{
-#define	PRINTSTATUS(name)				\
-	if ((status & USBPF_STATUS_##name) != 0)	\
-		printf("%s ", #name);
-
-	printf(" status %#x", status);
-	printf(" < ");
-	PRINTSTATUS(OPEN);
-	PRINTSTATUS(TRANSFERRING);
-	PRINTSTATUS(DID_DMA_DELAY);
-	PRINTSTATUS(DID_CLOSE);
-	PRINTSTATUS(DRAINING);
-	PRINTSTATUS(STARTED);
-	PRINTSTATUS(BW_RECLAIMED);
-	PRINTSTATUS(CONTROL_XFR);
-	PRINTSTATUS(CONTROL_HDR);
-	PRINTSTATUS(CONTROL_ACT);
-	PRINTSTATUS(CONTROL_STALL);
-	PRINTSTATUS(SHORT_FRAMES_OK);
-	PRINTSTATUS(SHORT_XFER_OK);
-#if USB_HAVE_BUSDMA
-	PRINTSTATUS(BDMA_ENABLE);
-	PRINTSTATUS(BDMA_NO_POST_SYNC);
-	PRINTSTATUS(BDMA_SETUP);
-#endif
-	PRINTSTATUS(ISOCHRONOUS_XFR);
-	PRINTSTATUS(CURR_DMA_SET);
-	PRINTSTATUS(CAN_CANCEL_IMMED);
-	PRINTSTATUS(DOING_CALLBACK);
-	printf(">\n");
-#undef PRINTSTATUS
+hexbyte(char *buf, uint8_t temp)
+{
+	uint8_t lo;
+	uint8_t hi;
+
+	lo = temp & 0xF;
+	hi = temp >> 4;
+
+	if (hi < 10)
+		buf[0] = '0' + hi;
+	else
+		buf[0] = 'A' + hi - 10;
+
+	if (lo < 10)
+		buf[1] = '0' + lo;
+	else
+		buf[1] = 'A' + lo - 10;
 }
 
 /*
  * Display a region in traditional hexdump format.
  */
 static void
-hexdump(const char *region, size_t len)
+hexdump(const uint8_t *region, uint32_t len)
 {
-	const char *line;
+	const uint8_t *line;
+	char linebuf[128];
+	int i;
 	int x;
 	int c;
-#define EMIT(fmt, ...)	do {		\
-	printf(fmt,## __VA_ARGS__);	\
-} while (0)
 
 	for (line = region; line < (region + len); line += 16) {
-		EMIT(" %04lx  ", (long) (line - region));
+
+		i = 0;
+
+		linebuf[i] = ' ';
+		hexbyte(linebuf + i + 1, ((line - region) >> 8) & 0xFF);
+		hexbyte(linebuf + i + 3, (line - region) & 0xFF);
+		linebuf[i + 5] = ' ';
+		linebuf[i + 6] = ' ';
+		i += 7;
+
 		for (x = 0; x < 16; x++) {
-			if ((line + x) < (region + len))
-				EMIT("%02x ", *(const u_int8_t *)(line + x));
-			else
-				EMIT("-- ");
-			if (x == 7)
-				EMIT(" ");
+		  if ((line + x) < (region + len)) {
+			hexbyte(linebuf + i,
+			    *(const u_int8_t *)(line + x));
+		  } else {
+			  linebuf[i] = '-';
+			  linebuf[i + 1] = '-';
+			}
+			linebuf[i + 2] = ' ';
+			if (x == 7) {
+			  linebuf[i + 3] = ' ';
+			  i += 4;
+			} else {
+			  i += 3;
+			}
 		}
-		EMIT(" |");
+		linebuf[i] = ' ';
+		linebuf[i + 1] = '|';
+		i += 2;
 		for (x = 0; x < 16; x++) {
 			if ((line + x) < (region + len)) {
 				c = *(const u_int8_t *)(line + x);
 				/* !isprint(c) */
 				if ((c < ' ') || (c > '~'))
 					c = '.';
-				EMIT("%c", c);
-			} else
-				EMIT(" ");
+				linebuf[i] = c;
+			} else {
+				linebuf[i] = ' ';
+			}
+			i++;
 		}
-		EMIT("|\n");
+		linebuf[i] = '|';
+		linebuf[i + 1] = 0;
+		i += 2;
+		puts(linebuf);
 	}
-#undef EMIT
 }
 
 static void
-print_apacket(const struct bpf_xhdr *hdr, struct usbpf_pkthdr *up,
-    const char *payload)
+print_apacket(const struct bpf_xhdr *hdr, const uint8_t *ptr, int ptr_len)
 {
 	struct tm *tm;
+	struct usbpf_pkthdr up_temp;
+	struct usbpf_pkthdr *up;
 	struct timeval tv;
 	size_t len;
-	u_int32_t framelen, x;
-	const char *ptr = payload;
+	uint32_t x;
 	char buf[64];
 
-	/* A packet from the kernel is based on little endian byte order. */
+	ptr += USBPF_HDR_LEN;
+	ptr_len -= USBPF_HDR_LEN;
+	if (ptr_len < 0)
+		return;
+
+	/* make sure we don't change the source buffer */
+	memcpy(&up_temp, ptr - USBPF_HDR_LEN, sizeof(up_temp));
+	up = &up_temp;
+
+	/*
+	 * A packet from the kernel is based on little endian byte
+	 * order.
+	 */
+	up->up_totlen = le32toh(up->up_totlen);
 	up->up_busunit = le32toh(up->up_busunit);
+	up->up_address = le32toh(up->up_address);
 	up->up_flags = le32toh(up->up_flags);
 	up->up_status = le32toh(up->up_status);
-	up->up_length = le32toh(up->up_length);
-	up->up_frames = le32toh(up->up_frames);
 	up->up_error = le32toh(up->up_error);
 	up->up_interval = le32toh(up->up_interval);
+	up->up_frames = le32toh(up->up_frames);
+	up->up_packet_size = le32toh(up->up_packet_size);
+	up->up_packet_count = le32toh(up->up_packet_count);
+	up->up_endpoint = le32toh(up->up_endpoint);
 
 	tv.tv_sec = hdr->bh_tstamp.bt_sec;
 	tv.tv_usec = hdr->bh_tstamp.bt_frac;
 	tm = localtime(&tv.tv_sec);
 
 	len = strftime(buf, sizeof(buf), "%H:%M:%S", tm);
-	printf("%.*s.%06ju", (int)len, buf, tv.tv_usec);
-	printf(" usbus%d.%d 0x%02x %s %s", up->up_busunit, up->up_address,
-	    up->up_endpoint,
+
+	printf("%.*s.%06ju usbus%d.%d %s-%s-EP=%08x,SPD=%s,NFR=%d,SLEN=%d,IVAL=%d%s%s\n",
+	    (int)len, buf, tv.tv_usec,
+	    (int)up->up_busunit, (int)up->up_address,
+	    (up->up_type == USBPF_XFERTAP_SUBMIT) ? "SUBM" : "DONE",
 	    xfertype_table[up->up_xfertype],
-	    up->up_type == USBPF_XFERTAP_SUBMIT ? "S" : "D");
-	printf(" (%d/%d)", up->up_frames, up->up_length);
-	if (up->up_type == USBPF_XFERTAP_DONE)
-		printf(" %s", errstr_table[up->up_error]);
-	if (up->up_xfertype == UE_BULK || up->up_xfertype == UE_ISOCHRONOUS)
-		printf(" %d", up->up_interval);
-	printf("\n");
+	    (unsigned int)up->up_endpoint,
+	    usb_speedstr(up->up_speed),
+	    (int)up->up_frames,
+	    (int)(up->up_totlen - USBPF_HDR_LEN -
+	    (USBPF_FRAME_HDR_LEN * up->up_frames)),
+	    (int)up->up_interval,
+	    (up->up_type == USBPF_XFERTAP_DONE) ? ",ERR=" : "",
+	    (up->up_type == USBPF_XFERTAP_DONE) ?
+	    usb_errstr(up->up_error) : "");
 
 	if (verbose >= 1) {
-		for (x = 0; x < up->up_frames; x++) {
-			framelen = le32toh(*((const u_int32_t *)ptr));
-			ptr += sizeof(u_int32_t);
-			printf(" frame[%u] len %d\n", x, framelen);
-			assert(framelen < (1024 * 4));
-			hexdump(ptr, framelen);
-			ptr += framelen;
+		for (x = 0; x != up->up_frames; x++) {
+			const struct usbpf_framehdr *uf;
+			uint32_t framelen;
+			uint32_t flags;
+
+			uf = (const struct usbpf_framehdr *)ptr;
+			ptr += USBPF_FRAME_HDR_LEN;
+			ptr_len -= USBPF_FRAME_HDR_LEN;
+			if (ptr_len < 0)
+				return;
+
+			framelen = le32toh(uf->length);
+			flags = le32toh(uf->flags);
+
+			printf(" frame[%u] %s %d bytes\n",
+			    (unsigned int)x,
+			    (flags & USBPF_FRAMEFLAG_READ) ? "READ" : "WRITE",
+			    (int)framelen);
+
+			if (flags & USBPF_FRAMEFLAG_DATA_FOLLOWS) {
+
+				int tot_frame_len;
+
+				tot_frame_len = USBPF_FRAME_ALIGN(framelen);
+
+				ptr_len -= tot_frame_len;
+
+				if (tot_frame_len < 0 ||
+				    (int)framelen < 0 || (int)ptr_len < 0)
+					break;
+
+				hexdump(ptr, framelen);
+
+				ptr += tot_frame_len;
+			}
 		}
 	}
-	if (verbose >= 2) {
+	if (verbose >= 2)
 		print_flags(up->up_flags);
+	if (verbose >= 3)
 		print_status(up->up_status);
-	}
 }
 
 static void
-print_packets(char *data, const int datalen)
+print_packets(uint8_t *data, const int datalen)
 {
-	struct usbpf_pkthdr *up;
 	const struct bpf_xhdr *hdr;
-	u_int32_t framelen, x;
-	char *ptr, *next;
+	uint8_t *ptr;
+	uint8_t *next;
 
 	for (ptr = data; ptr < (data + datalen); ptr = next) {
 		hdr = (const struct bpf_xhdr *)ptr;
-		up = (struct usbpf_pkthdr *)(ptr + hdr->bh_hdrlen);
 		next = ptr + BPF_WORDALIGN(hdr->bh_hdrlen + hdr->bh_caplen);
 
-		ptr = ((char *)up) + sizeof(struct usbpf_pkthdr);
-		if (w_arg == NULL)
-			print_apacket(hdr, up, ptr);
-		pkt_captured++;
-		for (x = 0; x < up->up_frames; x++) {
-			framelen = le32toh(*((const u_int32_t *)ptr));
-			ptr += sizeof(u_int32_t) + framelen;
+		if (w_arg == NULL) {
+			print_apacket(hdr, ptr +
+			    hdr->bh_hdrlen, hdr->bh_caplen);
 		}
+		pkt_captured++;
 	}
 }
 
 static void
-write_packets(struct usbcap *p, const char *data, const int datalen)
+write_packets(struct usbcap *p, const uint8_t *data, const int datalen)
 {
-	int len = htole32(datalen), ret;
+	int len = htole32(datalen);
+	int ret;
 
 	ret = write(p->wfd, &len, sizeof(int));
 	assert(ret == sizeof(int));
@@ -308,8 +416,9 @@ write_packets(struct usbcap *p, const ch
 static void
 read_file(struct usbcap *p)
 {
-	int datalen, ret;
-	char *data;
+	int datalen;
+	int ret;
+	uint8_t *data;
 
 	while ((ret = read(p->rfd, &datalen, sizeof(int))) == sizeof(int)) {
 		datalen = le32toh(datalen);
@@ -330,7 +439,7 @@ do_loop(struct usbcap *p)
 	int cc;
 
 	while (doexit == 0) {
-		cc = read(p->fd, (char *)p->buffer, p->bufsize);
+		cc = read(p->fd, (uint8_t *)p->buffer, p->bufsize);
 		if (cc < 0) {
 			switch (errno) {
 			case EINTR:
@@ -364,7 +473,7 @@ init_rfile(struct usbcap *p)
 	assert(ret == sizeof(uf));
 	assert(le32toh(uf.magic) == USBCAP_FILEHDR_MAGIC);
 	assert(uf.major == 0);
-	assert(uf.minor == 1);
+	assert(uf.minor == 2);
 }
 
 static void
@@ -381,7 +490,7 @@ init_wfile(struct usbcap *p)
 	bzero(&uf, sizeof(uf));
 	uf.magic = htole32(USBCAP_FILEHDR_MAGIC);
 	uf.major = 0;
-	uf.minor = 1;
+	uf.minor = 2;
 	ret = write(p->wfd, (const void *)&uf, sizeof(uf));
 	assert(ret == sizeof(uf));
 }
@@ -412,7 +521,7 @@ main(int argc, char *argv[])
 	struct usbcap uc, *p = &uc;
 	struct ifreq ifr;
 	long snapshot = 192;
-	u_int v;
+	uint32_t v;
 	int fd, o;
 	const char *optstring;
 
@@ -471,9 +580,13 @@ main(int argc, char *argv[])
 		return (EXIT_FAILURE);
 	}
 
-	if ((ioctl(fd, BIOCGBLEN, (caddr_t)&v) < 0) || v < 4096)
-		v = 4096;
-	for ( ; v != 0; v >>= 1) {
+	/* USB transfers can be greater than 64KByte */
+	v = 1U << 16;
+
+	/* clear ifr structure */
+	memset(&ifr, 0, sizeof(ifr));
+
+	for ( ; v >= USBPF_HDR_LEN; v >>= 1) {
 		(void)ioctl(fd, BIOCSBLEN, (caddr_t)&v);
 		(void)strncpy(ifr.ifr_name, i_arg, sizeof(ifr.ifr_name));
 		if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) >= 0)
@@ -490,7 +603,7 @@ main(int argc, char *argv[])
 	}
 
 	p->bufsize = v;
-	p->buffer = (u_char *)malloc(p->bufsize);
+	p->buffer = (uint8_t *)malloc(p->bufsize);
 	if (p->buffer == NULL) {
 		fprintf(stderr, "malloc: %s", strerror(errno));
 		return (EXIT_FAILURE);

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 20:15:42 2011
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 56C6C106566C;
	Sun,  3 Apr 2011 20:15: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 472AD8FC16;
	Sun,  3 Apr 2011 20:15:42 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p33KFgSg054467;
	Sun, 3 Apr 2011 20:15:42 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p33KFg9r054464;
	Sun, 3 Apr 2011 20:15:42 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104032015.p33KFg9r054464@svn.freebsd.org>
From: Adrian Chadd 
Date: Sun, 3 Apr 2011 20:15: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: r220302 - in head/sys/dev/ath/ath_hal: . ar5416
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, 03 Apr 2011 20:15:42 -0000

Author: adrian
Date: Sun Apr  3 20:15:41 2011
New Revision: 220302
URL: http://svn.freebsd.org/changeset/base/220302

Log:
  I missed committing this last time - it's needed for the 5ghz fast clock calculation.

Modified:
  head/sys/dev/ath/ath_hal/ah_internal.h
  head/sys/dev/ath/ath_hal/ar5416/ar5416.h

Modified: head/sys/dev/ath/ath_hal/ah_internal.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_internal.h	Sun Apr  3 20:03:45 2011	(r220301)
+++ head/sys/dev/ath/ath_hal/ah_internal.h	Sun Apr  3 20:15:41 2011	(r220302)
@@ -796,4 +796,10 @@ extern	HAL_BOOL ath_ee_FillVpdTable(uint
 extern	int16_t ath_ee_interpolate(uint16_t target, uint16_t srcLeft,
 	uint16_t srcRight, int16_t targetLeft, int16_t targetRight);
 
+/* Whether 5ghz fast clock is needed for Merlin and later */
+#define	IS_5GHZ_FAST_CLOCK_EN(_ah, _c) \
+	(IEEE80211_IS_CHAN_5GHZ(_c) && \
+	ath_hal_eepromGetFlag(ah, AR_EEP_FSTCLK_5G))
+
+
 #endif /* _ATH_AH_INTERAL_H_ */

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416.h	Sun Apr  3 20:03:45 2011	(r220301)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416.h	Sun Apr  3 20:15:41 2011	(r220302)
@@ -133,10 +133,6 @@ extern	void ar5416Detach(struct ath_hal 
 extern	void ar5416AttachPCIE(struct ath_hal *ah);
 extern	HAL_BOOL ar5416FillCapabilityInfo(struct ath_hal *ah);
 
-#define	IS_5GHZ_FAST_CLOCK_EN(_ah, _c) \
-	(IEEE80211_IS_CHAN_5GHZ(_c) && \
-	 ath_hal_eepromGetFlag(ah, AR_EEP_FSTCLK_5G))
-
 extern	void ar5416AniAttach(struct ath_hal *, const struct ar5212AniParams *,
 		const struct ar5212AniParams *, HAL_BOOL ena);
 extern	void ar5416AniDetach(struct ath_hal *);

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 20:17:49 2011
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 A0A0F106566C;
	Sun,  3 Apr 2011 20:17:49 +0000 (UTC)
	(envelope-from hselasky@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 905448FC0A;
	Sun,  3 Apr 2011 20:17:49 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p33KHnrO054545;
	Sun, 3 Apr 2011 20:17:49 GMT (envelope-from hselasky@svn.freebsd.org)
Received: (from hselasky@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p33KHnut054538;
	Sun, 3 Apr 2011 20:17:49 GMT (envelope-from hselasky@svn.freebsd.org)
Message-Id: <201104032017.p33KHnut054538@svn.freebsd.org>
From: Hans Petter Selasky 
Date: Sun, 3 Apr 2011 20:17: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: r220303 - in head/sys: arm/econa dev/usb/controller
	mips/atheros mips/rmi
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, 03 Apr 2011 20:17:49 -0000

Author: hselasky
Date: Sun Apr  3 20:17:49 2011
New Revision: 220303
URL: http://svn.freebsd.org/changeset/base/220303

Log:
  - Correct EHCI interrupt disabling at detach.
  
  Submitted by:	Luiz Otavio O Souza
  MFC after:	7 days
  Approved by:	thompsa (mentor)

Modified:
  head/sys/arm/econa/ehci_ebus.c
  head/sys/dev/usb/controller/ehci_ixp4xx.c
  head/sys/dev/usb/controller/ehci_mv.c
  head/sys/dev/usb/controller/ehci_pci.c
  head/sys/mips/atheros/ar71xx_ehci.c
  head/sys/mips/rmi/xls_ehci.c

Modified: head/sys/arm/econa/ehci_ebus.c
==============================================================================
--- head/sys/arm/econa/ehci_ebus.c	Sun Apr  3 20:15:41 2011	(r220302)
+++ head/sys/arm/econa/ehci_ebus.c	Sun Apr  3 20:17:49 2011	(r220303)
@@ -241,7 +241,7 @@ ehci_ebus_detach(device_t self)
 	 * disable interrupts that might have been switched on in ehci_init
 	 */
 	if (sc->sc_io_res) {
-		EWRITE4(sc, EHCI_USBINTR, 0);
+		EOWRITE4(sc, EHCI_USBINTR, 0);
 		EWRITE4(sc, USB_BRIDGE_INTR_MASK, 0);
 	}
 	if (sc->sc_irq_res && sc->sc_intr_hdl) {

Modified: head/sys/dev/usb/controller/ehci_ixp4xx.c
==============================================================================
--- head/sys/dev/usb/controller/ehci_ixp4xx.c	Sun Apr  3 20:15:41 2011	(r220302)
+++ head/sys/dev/usb/controller/ehci_ixp4xx.c	Sun Apr  3 20:17:49 2011	(r220303)
@@ -263,7 +263,7 @@ ehci_ixp_detach(device_t self)
 	 * disable interrupts that might have been switched on in ehci_init
 	 */
 	if (sc->sc_io_res) {
-		EWRITE4(sc, EHCI_USBINTR, 0);
+		EOWRITE4(sc, EHCI_USBINTR, 0);
 	}
 
  	if (sc->sc_irq_res && sc->sc_intr_hdl) {

Modified: head/sys/dev/usb/controller/ehci_mv.c
==============================================================================
--- head/sys/dev/usb/controller/ehci_mv.c	Sun Apr  3 20:15:41 2011	(r220302)
+++ head/sys/dev/usb/controller/ehci_mv.c	Sun Apr  3 20:17:49 2011	(r220303)
@@ -295,7 +295,7 @@ mv_ehci_detach(device_t self)
 	 * disable interrupts that might have been switched on in ehci_init
 	 */
 	if (sc->sc_io_res) {
-		EWRITE4(sc, EHCI_USBINTR, 0);
+		EOWRITE4(sc, EHCI_USBINTR, 0);
 		EWRITE4(sc, USB_BRIDGE_INTR_MASK, 0);
 	}
 	if (sc->sc_irq_res && sc->sc_intr_hdl) {

Modified: head/sys/dev/usb/controller/ehci_pci.c
==============================================================================
--- head/sys/dev/usb/controller/ehci_pci.c	Sun Apr  3 20:15:41 2011	(r220302)
+++ head/sys/dev/usb/controller/ehci_pci.c	Sun Apr  3 20:17:49 2011	(r220303)
@@ -506,7 +506,7 @@ ehci_pci_detach(device_t self)
 	 * disable interrupts that might have been switched on in ehci_init
 	 */
 	if (sc->sc_io_res) {
-		EWRITE4(sc, EHCI_USBINTR, 0);
+		EOWRITE4(sc, EHCI_USBINTR, 0);
 	}
 	if (sc->sc_irq_res && sc->sc_intr_hdl) {
 		/*

Modified: head/sys/mips/atheros/ar71xx_ehci.c
==============================================================================
--- head/sys/mips/atheros/ar71xx_ehci.c	Sun Apr  3 20:15:41 2011	(r220302)
+++ head/sys/mips/atheros/ar71xx_ehci.c	Sun Apr  3 20:17:49 2011	(r220303)
@@ -250,7 +250,7 @@ ar71xx_ehci_detach(device_t self)
 	 * disable interrupts that might have been switched on in ehci_init
 	 */
 	if (sc->sc_io_res) {
-		EWRITE4(sc, EHCI_USBINTR, 0);
+		EOWRITE4(sc, EHCI_USBINTR, 0);
 	}
 
  	if (sc->sc_irq_res && sc->sc_intr_hdl) {

Modified: head/sys/mips/rmi/xls_ehci.c
==============================================================================
--- head/sys/mips/rmi/xls_ehci.c	Sun Apr  3 20:15:41 2011	(r220302)
+++ head/sys/mips/rmi/xls_ehci.c	Sun Apr  3 20:17:49 2011	(r220303)
@@ -220,7 +220,7 @@ ehci_xls_detach(device_t self)
 	 * disable interrupts that might have been switched on in ehci_init
 	 */
 	if (sc->sc_io_res) {
-		EWRITE4(sc, EHCI_USBINTR, 0);
+		EOWRITE4(sc, EHCI_USBINTR, 0);
 	}
 
 	if (sc->sc_irq_res && sc->sc_intr_hdl) {

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 20:22:50 2011
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 0B761106566B;
	Sun,  3 Apr 2011 20:22:50 +0000 (UTC)
	(envelope-from hselasky@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F07C08FC0A;
	Sun,  3 Apr 2011 20:22:49 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p33KMngL054682;
	Sun, 3 Apr 2011 20:22:49 GMT (envelope-from hselasky@svn.freebsd.org)
Received: (from hselasky@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p33KMnGY054680;
	Sun, 3 Apr 2011 20:22:49 GMT (envelope-from hselasky@svn.freebsd.org)
Message-Id: <201104032022.p33KMnGY054680@svn.freebsd.org>
From: Hans Petter Selasky 
Date: Sun, 3 Apr 2011 20:22: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: r220304 - head/sys/dev/usb
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, 03 Apr 2011 20:22:50 -0000

Author: hselasky
Date: Sun Apr  3 20:22:49 2011
New Revision: 220304
URL: http://svn.freebsd.org/changeset/base/220304

Log:
  - Fix for missing event if a libUSB USB transfer is started and
  stopped rapidly in succession.
  
  Reported by:	J.R. Oldroyd
  MFC after:	7 days
  Approved by:	thompsa (mentor)

Modified:
  head/sys/dev/usb/usb_generic.c

Modified: head/sys/dev/usb/usb_generic.c
==============================================================================
--- head/sys/dev/usb/usb_generic.c	Sun Apr  3 20:17:49 2011	(r220303)
+++ head/sys/dev/usb/usb_generic.c	Sun Apr  3 20:22:49 2011	(r220304)
@@ -1399,6 +1399,7 @@ ugen_ioctl(struct usb_fifo *f, u_long cm
 	}     u;
 	struct usb_endpoint *ep;
 	struct usb_endpoint_descriptor *ed;
+	struct usb_xfer *xfer;
 	int error = 0;
 	uint8_t iface_index;
 	uint8_t isread;
@@ -1425,11 +1426,11 @@ ugen_ioctl(struct usb_fifo *f, u_long cm
 
 	case USB_FS_START:
 		error = ugen_fs_copy_in(f, u.pstart->ep_index);
-		if (error) {
+		if (error)
 			break;
-		}
 		mtx_lock(f->priv_mtx);
-		usbd_transfer_start(f->fs_xfer[u.pstart->ep_index]);
+		xfer = f->fs_xfer[u.pstart->ep_index];
+		usbd_transfer_start(xfer);
 		mtx_unlock(f->priv_mtx);
 		break;
 
@@ -1439,7 +1440,19 @@ ugen_ioctl(struct usb_fifo *f, u_long cm
 			break;
 		}
 		mtx_lock(f->priv_mtx);
-		usbd_transfer_stop(f->fs_xfer[u.pstop->ep_index]);
+		xfer = f->fs_xfer[u.pstart->ep_index];
+		if (usbd_transfer_pending(xfer)) {
+			usbd_transfer_stop(xfer);
+			/*
+			 * Check if the USB transfer was stopped
+			 * before it was even started. Else a cancel
+			 * callback will be pending.
+			 */
+			if (!xfer->flags_int.transferring) {
+				ugen_fs_set_complete(xfer->priv_sc,
+				    USB_P2U(xfer->priv_fifo));
+			}
+		}
 		mtx_unlock(f->priv_mtx);
 		break;
 

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 22:31:51 2011
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 C8BF1106564A;
	Sun,  3 Apr 2011 22:31:51 +0000 (UTC)
	(envelope-from marcel@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B91148FC16;
	Sun,  3 Apr 2011 22:31:51 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p33MVpZx063174;
	Sun, 3 Apr 2011 22:31:51 GMT (envelope-from marcel@svn.freebsd.org)
Received: (from marcel@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p33MVpcL063168;
	Sun, 3 Apr 2011 22:31:51 GMT (envelope-from marcel@svn.freebsd.org)
Message-Id: <201104032231.p33MVpcL063168@svn.freebsd.org>
From: Marcel Moolenaar 
Date: Sun, 3 Apr 2011 22:31: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: r220311 - in head/sys/boot: common pc98/loader
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, 03 Apr 2011 22:31:51 -0000

Author: marcel
Date: Sun Apr  3 22:31:51 2011
New Revision: 220311
URL: http://svn.freebsd.org/changeset/base/220311

Log:
  Add 2 new archsw interfaces:
  1.  arch_loadaddr - used by platform code to adjust the address at which
      the object gets loaded. Implement PC98 using this new interface instead
      of using conditional compilation. For ELF objects the ELF header is
      passed as the data pointer. For raw files it's the filename. Note that
      ELF objects are first considered as raw files.
  2.  arch_loadseg - used by platform code to keep track of actual segments,
      so that (instruction) caches can be flushed or translations can be
      created. Both the ELF header as well as the program header are passed
      to allow platform code to treat the kernel proper differently from any
      additional modules and to have all the relevant details of the loaded
      segment (e.g. protection).

Modified:
  head/sys/boot/common/bootstrap.h
  head/sys/boot/common/load_elf.c
  head/sys/boot/common/load_elf_obj.c
  head/sys/boot/common/module.c
  head/sys/boot/pc98/loader/main.c

Modified: head/sys/boot/common/bootstrap.h
==============================================================================
--- head/sys/boot/common/bootstrap.h	Sun Apr  3 22:21:40 2011	(r220310)
+++ head/sys/boot/common/bootstrap.h	Sun Apr  3 22:31:51 2011	(r220311)
@@ -296,6 +296,24 @@ struct arch_switch
     /* Perform ISA byte port I/O (only for systems with ISA) */
     int		(*arch_isainb)(int port);
     void	(*arch_isaoutb)(int port, int value);
+
+    /*
+     * Interface to adjust the load address according to the "object"
+     * being loaded.
+     */
+    uint64_t	(*arch_loadaddr)(u_int type, void *data, uint64_t addr);
+#define	LOAD_ELF	1	/* data points to the ELF header. */
+#define	LOAD_RAW	2	/* data points to the file name. */
+
+    /*
+     * Interface to inform MD code about a loaded (ELF) segment. This
+     * can be used to flush caches and/or set up translations.
+     */
+#ifdef __elfN
+    void	(*arch_loadseg)(Elf_Ehdr *eh, Elf_Phdr *ph, uint64_t delta);
+#else
+    void	(*arch_loadseg)(void *eh, void *ph, uint64_t delta);
+#endif
 };
 extern struct arch_switch archsw;
 

Modified: head/sys/boot/common/load_elf.c
==============================================================================
--- head/sys/boot/common/load_elf.c	Sun Apr  3 22:21:40 2011	(r220310)
+++ head/sys/boot/common/load_elf.c	Sun Apr  3 22:31:51 2011	(r220311)
@@ -97,7 +97,6 @@ __elfN(loadfile)(char *filename, u_int64
     struct elf_file		ef;
     Elf_Ehdr 			*ehdr;
     int				err;
-    u_int			pad;
     ssize_t			bytes_read;
 
     fp = NULL;
@@ -157,12 +156,6 @@ __elfN(loadfile)(char *filename, u_int64
 	/* Looks OK, got ahead */
 	ef.kernel = 0;
 
-	/* Page-align the load address */
-	pad = (u_int)dest & PAGE_MASK;
-	if (pad != 0) {
-	    pad = PAGE_SIZE - pad;
-	    dest += pad;
-	}
     } else if (ehdr->e_type == ET_EXEC) {
 	/* Looks like a kernel */
 	if (kfp != NULL) {
@@ -173,7 +166,7 @@ __elfN(loadfile)(char *filename, u_int64
 	/* 
 	 * Calculate destination address based on kernel entrypoint 	
 	 */
-	dest = ehdr->e_entry;
+	dest = (ehdr->e_entry & ~PAGE_MASK);
 	if (dest == 0) {
 	    printf("elf" __XSTRING(__ELF_WORD_SIZE) "_loadfile: not a kernel (maybe static binary?)\n");
 	    err = EPERM;
@@ -186,6 +179,11 @@ __elfN(loadfile)(char *filename, u_int64
 	goto oerr;
     }
 
+    if (archsw.arch_loadaddr != NULL)
+	dest = archsw.arch_loadaddr(LOAD_ELF, ehdr, dest);
+    else
+	dest = roundup(dest, PAGE_SIZE);
+
     /* 
      * Ok, we think we should handle this.
      */
@@ -202,7 +200,7 @@ __elfN(loadfile)(char *filename, u_int64
 
 #ifdef ELF_VERBOSE
     if (ef.kernel)
-	printf("%s entry at 0x%jx\n", filename, (uintmax_t)dest);
+	printf("%s entry at 0x%jx\n", filename, (uintmax_t)ehdr->e_entry);
 #else
     printf("%s ", filename);
 #endif
@@ -362,6 +360,9 @@ __elfN(loadimage)(struct preloaded_file 
 	printf("\n");
 #endif
 
+	if (archsw.arch_loadseg != NULL)
+	    archsw.arch_loadseg(ehdr, phdr + i, off);
+
 	if (firstaddr == 0 || firstaddr > (phdr[i].p_vaddr + off))
 	    firstaddr = phdr[i].p_vaddr + off;
 	if (lastaddr == 0 || lastaddr < (phdr[i].p_vaddr + off + phdr[i].p_memsz))

Modified: head/sys/boot/common/load_elf_obj.c
==============================================================================
--- head/sys/boot/common/load_elf_obj.c	Sun Apr  3 22:21:40 2011	(r220310)
+++ head/sys/boot/common/load_elf_obj.c	Sun Apr  3 22:31:51 2011	(r220311)
@@ -144,8 +144,10 @@ __elfN(obj_loadfile)(char *filename, u_i
 		goto oerr;
 	}
 
-	/* Page-align the load address */
-	dest = roundup(dest, PAGE_SIZE);
+	if (archsw.arch_loadaddr != NULL)
+		dest = archsw.arch_loadaddr(LOAD_ELF, hdr, dest);
+	else
+		dest = roundup(dest, PAGE_SIZE);
 
 	/*
 	 * Ok, we think we should handle this.

Modified: head/sys/boot/common/module.c
==============================================================================
--- head/sys/boot/common/module.c	Sun Apr  3 22:21:40 2011	(r220310)
+++ head/sys/boot/common/module.c	Sun Apr  3 22:31:51 2011	(r220311)
@@ -275,6 +275,9 @@ file_load(char *filename, vm_offset_t de
     int error;
     int i;
 
+    if (archsw.arch_loadaddr != NULL)
+	dest = archsw.arch_loadaddr(LOAD_RAW, filename, dest);
+
     error = EFTYPE;
     for (i = 0, fp = NULL; file_formats[i] && fp == NULL; i++) {
 	error = (file_formats[i]->l_load)(filename, loadaddr, &fp);
@@ -352,9 +355,6 @@ file_loadraw(char *type, char *name)
     char			*cp;
     int				fd, got;
     vm_offset_t			laddr;
-#ifdef PC98
-    struct stat			st;
-#endif
 
     /* We can't load first */
     if ((file_findfile(NULL, NULL)) == NULL) {
@@ -369,20 +369,15 @@ file_loadraw(char *type, char *name)
 	return(CMD_ERROR);
     }
     name = cp;
-    
+
     if ((fd = open(name, O_RDONLY)) < 0) {
 	sprintf(command_errbuf, "can't open '%s': %s", name, strerror(errno));
 	free(name);
 	return(CMD_ERROR);
     }
 
-#ifdef PC98
-    /* We cannot use 15M-16M area on pc98. */
-    if (loadaddr < 0x1000000 &&
-	fstat(fd, &st) == 0 &&
-	(st.st_size == -1 || loadaddr + st.st_size > 0xf00000))
-	loadaddr = 0x1000000;
-#endif
+    if (archsw.arch_loadaddr != NULL)
+	loadaddr = archsw.arch_loadaddr(LOAD_RAW, name, loadaddr);
 
     laddr = loadaddr;
     for (;;) {
@@ -489,14 +484,6 @@ mod_loadkld(const char *kldname, int arg
 	;
 
     do {
-#ifdef PC98
-	/* We cannot use 15M-16M area on pc98. */
-	struct stat st;
-	if (loadaddr < 0x1000000 &&
-	    stat(filename, &st) == 0 &&
-	    (st.st_size == -1 || loadaddr + st.st_size > 0xf00000))
-	    loadaddr = 0x1000000;
-#endif
 	err = file_load(filename, loadaddr, &fp);
 	if (err)
 	    break;

Modified: head/sys/boot/pc98/loader/main.c
==============================================================================
--- head/sys/boot/pc98/loader/main.c	Sun Apr  3 22:21:40 2011	(r220310)
+++ head/sys/boot/pc98/loader/main.c	Sun Apr  3 22:31:51 2011	(r220311)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "bootstrap.h"
@@ -77,6 +78,21 @@ extern char end[];
 static void *heap_top;
 static void *heap_bottom;
 
+static uint64_t
+pc98_loadaddr(u_int type, void *data, uint64_t addr)
+{
+	struct stat st;
+
+	if (type == LOAD_ELF)
+		return (roundup(addr, PAGE_SIZE));
+
+	/* We cannot use 15M-16M area on pc98. */
+	if (type == LOAD_RAW && addr < 0x1000000 && stat(data, &st) == 0 &&
+	    (st.st_size == -1 || addr + st.st_size > 0xf00000))
+		addr = 0x1000000;
+	return (addr);
+}
+
 int
 main(void)
 {
@@ -160,6 +176,7 @@ main(void)
     archsw.arch_readin = i386_readin;
     archsw.arch_isainb = isa_inb;
     archsw.arch_isaoutb = isa_outb;
+    archsw.arch_loadaddr = pc98_loadaddr;
 
     /*
      * March through the device switch probing for things.

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 22:36:40 2011
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 C97B5106564A;
	Sun,  3 Apr 2011 22:36:40 +0000 (UTC)
	(envelope-from hselasky@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id BB3B48FC14;
	Sun,  3 Apr 2011 22:36:40 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p33MaeiY063323;
	Sun, 3 Apr 2011 22:36:40 GMT (envelope-from hselasky@svn.freebsd.org)
Received: (from hselasky@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p33Maedk063321;
	Sun, 3 Apr 2011 22:36:40 GMT (envelope-from hselasky@svn.freebsd.org)
Message-Id: <201104032236.p33Maedk063321@svn.freebsd.org>
From: Hans Petter Selasky 
Date: Sun, 3 Apr 2011 22:36: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: r220312 - head/usr.sbin
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, 03 Apr 2011 22:36:40 -0000

Author: hselasky
Date: Sun Apr  3 22:36:40 2011
New Revision: 220312
URL: http://svn.freebsd.org/changeset/base/220312

Log:
  - Include usbdump into default build.
  
  MFC after:	7 days
  Approved by:	thompsa (mentor)

Modified:
  head/usr.sbin/Makefile

Modified: head/usr.sbin/Makefile
==============================================================================
--- head/usr.sbin/Makefile	Sun Apr  3 22:31:51 2011	(r220311)
+++ head/usr.sbin/Makefile	Sun Apr  3 22:36:40 2011	(r220312)
@@ -296,6 +296,7 @@ SUBDIR+=	crunch
 SUBDIR+=	uathload
 SUBDIR+=	uhsoctl
 SUBDIR+=	usbconfig
+SUBDIR+=	usbdump
 .endif
 
 .if ${MK_WIRELESS} != "no"

From owner-svn-src-head@FreeBSD.ORG  Sun Apr  3 23:49:21 2011
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 16829106564A;
	Sun,  3 Apr 2011 23:49:21 +0000 (UTC)
	(envelope-from marcel@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 055578FC1B;
	Sun,  3 Apr 2011 23:49:21 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p33NnKMM064744;
	Sun, 3 Apr 2011 23:49:21 GMT (envelope-from marcel@svn.freebsd.org)
Received: (from marcel@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p33NnKPD064736;
	Sun, 3 Apr 2011 23:49:20 GMT (envelope-from marcel@svn.freebsd.org)
Message-Id: <201104032349.p33NnKPD064736@svn.freebsd.org>
From: Marcel Moolenaar 
Date: Sun, 3 Apr 2011 23: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: r220313 - in head/sys: boot/ia64/common boot/ia64/efi
	boot/ia64/ski ia64/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: Sun, 03 Apr 2011 23:49:21 -0000

Author: marcel
Date: Sun Apr  3 23:49:20 2011
New Revision: 220313
URL: http://svn.freebsd.org/changeset/base/220313

Log:
  Use the new arch_loadaddr I/F to align ELF objects to PBVM page
  boundaries. For good measure, align all other objects to cache
  lines boundaries.
  
  Use the new arch_loadseg I/F to keep track of kernel text and
  data so that we can wire as much of it as is possible. It is
  the responsibility of the kernel to link critical (read IVT
  related) code and data at the front of the respective segment
  so that it's covered by TRs before the kernel has a chance to
  add more translations.
  
  Use a better way of determining whether we're loading a legacy
  kernel or not. We can't check for the presence of the PBVM page
  table, because we may have unloaded that kernel and loaded an
  older (legacy) kernel after that. Simply use the latest load
  address for it.

Modified:
  head/sys/boot/ia64/common/copy.c
  head/sys/boot/ia64/common/exec.c
  head/sys/boot/ia64/common/libia64.h
  head/sys/boot/ia64/efi/main.c
  head/sys/boot/ia64/ski/efi_stub.c
  head/sys/boot/ia64/ski/main.c
  head/sys/ia64/include/bootinfo.h

Modified: head/sys/boot/ia64/common/copy.c
==============================================================================
--- head/sys/boot/ia64/common/copy.c	Sun Apr  3 22:36:40 2011	(r220312)
+++ head/sys/boot/ia64/common/copy.c	Sun Apr  3 23:49:20 2011	(r220313)
@@ -28,10 +28,12 @@
 __FBSDID("$FreeBSD$");
 
 #include 
-#include 
+#include 
 
 #include "libia64.h"
 
+u_int ia64_legacy_kernel;
+
 uint64_t *ia64_pgtbl;
 uint32_t ia64_pgtblsz;
 
@@ -80,8 +82,8 @@ pgtbl_extend(u_int idx)
 	return (0);
 }
 
-static void *
-va2pa(vm_offset_t va, size_t *len)
+void *
+ia64_va2pa(vm_offset_t va, size_t *len)
 {
 	uint64_t pa;
 	u_int idx, ofs;
@@ -89,6 +91,7 @@ va2pa(vm_offset_t va, size_t *len)
 
 	/* Backward compatibility. */
 	if (va >= IA64_RR_BASE(7)) {
+		ia64_legacy_kernel = 1;
 		pa = IA64_RR_MASK(va);
 		return ((void *)pa);
 	}
@@ -98,6 +101,8 @@ va2pa(vm_offset_t va, size_t *len)
 		goto fail;
 	}
 
+	ia64_legacy_kernel = 0;
+
 	idx = (va - IA64_PBVM_BASE) >> IA64_PBVM_PAGE_SHIFT;
 	if (idx >= (ia64_pgtblsz >> 3)) {
 		error = pgtbl_extend(idx);
@@ -138,7 +143,7 @@ ia64_copyin(const void *src, vm_offset_t
 	res = 0;
 	while (len > 0) {
 		sz = len;
-		pa = va2pa(va, &sz);
+		pa = ia64_va2pa(va, &sz);
 		if (sz == 0)
 			break;
 		bcopy(src, pa, sz);
@@ -159,7 +164,7 @@ ia64_copyout(vm_offset_t va, void *dst, 
 	res = 0;
 	while (len > 0) {
 		sz = len;
-		pa = va2pa(va, &sz);
+		pa = ia64_va2pa(va, &sz);
 		if (sz == 0)
 			break;
 		bcopy(pa, dst, sz);
@@ -170,6 +175,19 @@ ia64_copyout(vm_offset_t va, void *dst, 
 	return (res);
 }
 
+uint64_t
+ia64_loadaddr(u_int type, void *data, uint64_t addr)
+{
+	uint64_t align;
+
+	/*
+	 * Align ELF objects at PBVM page boundaries.  Align all other
+	 * objects at cache line boundaries for good measure.
+	 */
+	align = (type == LOAD_ELF) ? IA64_PBVM_PAGE_SIZE : CACHE_LINE_SIZE;
+	return ((addr + align - 1) & ~(align - 1));
+}
+
 ssize_t
 ia64_readin(int fd, vm_offset_t va, size_t len)
 {
@@ -180,7 +198,7 @@ ia64_readin(int fd, vm_offset_t va, size
 	res = 0;
 	while (len > 0) {
 		sz = len;
-		pa = va2pa(va, &sz);
+		pa = ia64_va2pa(va, &sz);
 		if (sz == 0)
 			break;
 		s = read(fd, pa, sz);

Modified: head/sys/boot/ia64/common/exec.c
==============================================================================
--- head/sys/boot/ia64/common/exec.c	Sun Apr  3 22:36:40 2011	(r220312)
+++ head/sys/boot/ia64/common/exec.c	Sun Apr  3 23:49:20 2011	(r220313)
@@ -36,13 +36,20 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
-
 #include 
 #include 
 
 #include "libia64.h"
 
+static u_int itr_idx = 0;
+static u_int dtr_idx = 0;
+
+static vm_offset_t ia64_text_start;
+static size_t ia64_text_size;
+
+static vm_offset_t ia64_data_start;
+static size_t ia64_data_size;
+
 static int elf64_exec(struct preloaded_file *amp);
 static int elf64_obj_exec(struct preloaded_file *amp);
 
@@ -61,6 +68,26 @@ struct file_format *file_formats[] = {
 	NULL
 };
 
+static u_int
+sz2shft(vm_offset_t ofs, vm_size_t sz)
+{
+	vm_size_t s;
+	u_int shft;
+
+	shft = 12;	/* Start with 4K */
+	s = 1 << shft;
+	while (s < sz) {
+		shft++;
+		s <<= 1;
+	}
+	do {
+		shft--;
+		s >>= 1;
+	} while (ofs & (s - 1));
+
+	return (shft);
+}
+
 /*
  * Entered with psr.ic and psr.i both zero.
  */
@@ -84,49 +111,43 @@ enter_kernel(uint64_t start, struct boot
 	/* NOTREACHED */
 }
 
-static void
-mmu_wire(vm_offset_t va, vm_paddr_t pa, vm_size_t sz, u_int acc)
+static u_int
+mmu_wire(vm_offset_t va, vm_paddr_t pa, u_int pgshft, u_int acc)
 {
-	static u_int iidx = 0, didx = 0;
 	pt_entry_t pte;
-	u_int shft;
 
 	/* Round up to the smallest possible page size. */
-	if (sz < 4096)
-		sz = 4096;
-	/* Determine the exponent (base 2). */
-	shft = 0;
-	while (sz > 1) {
-		shft++;
-		sz >>= 1;
-	}
+	if (pgshft < 12)
+		pgshft = 12;
 	/* Truncate to the largest possible page size (256MB). */
-	if (shft > 28)
-		shft = 28;
+	if (pgshft > 28)
+		pgshft = 28;
 	/* Round down to a valid (mappable) page size. */
-	if (shft > 14 && (shft & 1) != 0)
-		shft--;
+	if (pgshft > 14 && (pgshft & 1) != 0)
+		pgshft--;
 
 	pte = PTE_PRESENT | PTE_MA_WB | PTE_ACCESSED | PTE_DIRTY |
 	    PTE_PL_KERN | (acc & PTE_AR_MASK) | (pa & PTE_PPN_MASK);
 
 	__asm __volatile("mov cr.ifa=%0" :: "r"(va));
-	__asm __volatile("mov cr.itir=%0" :: "r"(shft << 2));
+	__asm __volatile("mov cr.itir=%0" :: "r"(pgshft << 2));
 	__asm __volatile("srlz.d;;");
 
-	__asm __volatile("ptr.d %0,%1" :: "r"(va), "r"(shft << 2));
+	__asm __volatile("ptr.d %0,%1" :: "r"(va), "r"(pgshft << 2));
 	__asm __volatile("srlz.d;;");
-	__asm __volatile("itr.d dtr[%0]=%1" :: "r"(didx), "r"(pte));
+	__asm __volatile("itr.d dtr[%0]=%1" :: "r"(dtr_idx), "r"(pte));
 	__asm __volatile("srlz.d;;");
-	didx++;
+	dtr_idx++;
 
-	if (acc == PTE_AR_RWX) {
-		__asm __volatile("ptr.i %0,%1;;" :: "r"(va), "r"(shft << 2));
+	if (acc == PTE_AR_RWX || acc == PTE_AR_RX) {
+		__asm __volatile("ptr.i %0,%1;;" :: "r"(va), "r"(pgshft << 2));
 		__asm __volatile("srlz.i;;");
-		__asm __volatile("itr.i itr[%0]=%1;;" :: "r"(iidx), "r"(pte));
+		__asm __volatile("itr.i itr[%0]=%1;;" :: "r"(itr_idx), "r"(pte));
 		__asm __volatile("srlz.i;;");
-		iidx++;
+		itr_idx++;
 	}
+
+	return (pgshft);
 }
 
 static void
@@ -143,28 +164,43 @@ mmu_setup_legacy(uint64_t entry)
 	ia64_set_rr(IA64_RR_BASE(7), (7 << 8) | (28 << 2));
 	__asm __volatile("srlz.i;;");
 
-	mmu_wire(entry, IA64_RR_MASK(entry), 1UL << 28, PTE_AR_RWX);
+	mmu_wire(entry, IA64_RR_MASK(entry), 28, PTE_AR_RWX);
 }
 
 static void
-mmu_setup_paged(vm_offset_t pbvm_top)
+mmu_setup_paged(struct bootinfo *bi)
 {
-	vm_size_t sz;
+	void *pa;
+	size_t sz;
+	u_int shft;
 
 	ia64_set_rr(IA64_RR_BASE(IA64_PBVM_RR),
 	    (IA64_PBVM_RR << 8) | (IA64_PBVM_PAGE_SHIFT << 2));
 	__asm __volatile("srlz.i;;");
 
 	/* Wire the PBVM page table. */
-	mmu_wire(IA64_PBVM_PGTBL, (uintptr_t)ia64_pgtbl, ia64_pgtblsz,
-	    PTE_AR_RW);
+	mmu_wire(IA64_PBVM_PGTBL, (uintptr_t)ia64_pgtbl,
+	    sz2shft(IA64_PBVM_PGTBL, ia64_pgtblsz), PTE_AR_RW);
 
-	/* Wire as much of the PBVM we can. This must be a power of 2. */
-	sz = pbvm_top - IA64_PBVM_BASE;
-	sz = (sz + IA64_PBVM_PAGE_MASK) & ~IA64_PBVM_PAGE_MASK;
-	while (sz & (sz - 1))
-		sz -= IA64_PBVM_PAGE_SIZE;
-	mmu_wire(IA64_PBVM_BASE, ia64_pgtbl[0], sz, PTE_AR_RWX);
+	/* Wire as much of the text segment as we can. */
+	sz = ia64_text_size;	/* XXX */
+	pa = ia64_va2pa(ia64_text_start, &ia64_text_size);
+	ia64_text_size = sz;	/* XXX */
+	shft = sz2shft(ia64_text_start, ia64_text_size);
+	shft = mmu_wire(ia64_text_start, (uintptr_t)pa, shft, PTE_AR_RX);
+	ia64_copyin(&shft, (uintptr_t)&bi->bi_text_mapped, 4);
+
+	/* Wire as much of the data segment as well. */
+	sz = ia64_data_size;	/* XXX */
+	pa = ia64_va2pa(ia64_data_start, &ia64_data_size);
+	ia64_data_size = sz;	/* XXX */
+	shft = sz2shft(ia64_data_start, ia64_data_size);
+	shft = mmu_wire(ia64_data_start, (uintptr_t)pa, shft, PTE_AR_RW);
+	ia64_copyin(&shft, (uintptr_t)&bi->bi_data_mapped, 4);
+
+	/* Update the bootinfo with the number of TRs used. */
+	ia64_copyin(&itr_idx, (uintptr_t)&bi->bi_itr_used, 4);
+	ia64_copyin(&dtr_idx, (uintptr_t)&bi->bi_dtr_used, 4);
 }
 
 static int
@@ -196,7 +232,7 @@ elf64_exec(struct preloaded_file *fp)
 	if (IS_LEGACY_KERNEL())
 		mmu_setup_legacy(hdr->e_entry);
 	else
-		mmu_setup_paged((uintptr_t)(bi + 1));
+		mmu_setup_paged(bi);
 
 	enter_kernel(hdr->e_entry, bi);
 	/* NOTREACHED */
@@ -211,3 +247,20 @@ elf64_obj_exec(struct preloaded_file *fp
 	    fp->f_name);
 	return (ENOSYS);
 }
+
+void
+ia64_loadseg(Elf_Ehdr *eh, Elf_Phdr *ph, uint64_t delta)
+{
+
+	if (eh->e_type != ET_EXEC)
+		return;
+
+	if (ph->p_flags & PF_X) {
+		ia64_text_start = ph->p_vaddr + delta;
+		ia64_text_size = ph->p_memsz;
+	} else {
+		ia64_data_start = ph->p_vaddr + delta;
+		ia64_data_size = ph->p_memsz;
+	}
+}
+

Modified: head/sys/boot/ia64/common/libia64.h
==============================================================================
--- head/sys/boot/ia64/common/libia64.h	Sun Apr  3 22:36:40 2011	(r220312)
+++ head/sys/boot/ia64/common/libia64.h	Sun Apr  3 23:49:20 2011	(r220313)
@@ -31,9 +31,9 @@
 
 #include 
 #include 
-#include 
+#include 
 
-#define	IS_LEGACY_KERNEL()	(ia64_pgtbl == NULL || ia64_pgtblsz == 0)
+#define	IS_LEGACY_KERNEL()	(ia64_legacy_kernel)
 
 /*
  * Portability functions provided by the loader
@@ -48,15 +48,24 @@ int ia64_platform_enter(const char *);
  * Functions and variables provided by the ia64 common code
  * and shared by all loader implementations.
  */
+extern u_int ia64_legacy_kernel;
+
 extern uint64_t *ia64_pgtbl;
 extern uint32_t ia64_pgtblsz;
 
 int ia64_autoload(void);
 int ia64_bootinfo(struct preloaded_file *, struct bootinfo **);
+uint64_t ia64_loadaddr(u_int, void *, uint64_t);
+#ifdef __elfN
+void ia64_loadseg(Elf_Ehdr *, Elf_Phdr *, uint64_t);
+#else
+void ia64_loadseg(void *, void *, uint64_t);
+#endif
 
 ssize_t ia64_copyin(const void *, vm_offset_t, size_t);
 ssize_t ia64_copyout(vm_offset_t, void *, size_t);
 ssize_t ia64_readin(int, vm_offset_t, size_t);
+void *ia64_va2pa(vm_offset_t, size_t *);
 
 char *ia64_fmtdev(struct devdesc *);
 int ia64_getdev(void **, const char *, const char **);

Modified: head/sys/boot/ia64/efi/main.c
==============================================================================
--- head/sys/boot/ia64/efi/main.c	Sun Apr  3 22:36:40 2011	(r220312)
+++ head/sys/boot/ia64/efi/main.c	Sun Apr  3 23:49:20 2011	(r220313)
@@ -196,9 +196,11 @@ main(int argc, CHAR16 *argv[])
 	setenv("LINES", "24", 1);	/* optional */
 
 	archsw.arch_autoload = ia64_autoload;
-	archsw.arch_getdev = ia64_getdev;
 	archsw.arch_copyin = ia64_copyin;
 	archsw.arch_copyout = ia64_copyout;
+	archsw.arch_getdev = ia64_getdev;
+	archsw.arch_loadaddr = ia64_loadaddr;
+	archsw.arch_loadseg = ia64_loadseg;
 	archsw.arch_readin = ia64_readin;
 
 	interact();			/* doesn't return */

Modified: head/sys/boot/ia64/ski/efi_stub.c
==============================================================================
--- head/sys/boot/ia64/ski/efi_stub.c	Sun Apr  3 22:36:40 2011	(r220312)
+++ head/sys/boot/ia64/ski/efi_stub.c	Sun Apr  3 23:49:20 2011	(r220313)
@@ -28,8 +28,8 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 #include 
-#include 
 #include 
 #include "libski.h"
 

Modified: head/sys/boot/ia64/ski/main.c
==============================================================================
--- head/sys/boot/ia64/ski/main.c	Sun Apr  3 22:36:40 2011	(r220312)
+++ head/sys/boot/ia64/ski/main.c	Sun Apr  3 23:49:20 2011	(r220313)
@@ -97,11 +97,13 @@ ski_main(void)
 	    env_nounset);
 
 	setenv("LINES", "24", 1);	/* optional */
-    
+
 	archsw.arch_autoload = ia64_autoload;
-	archsw.arch_getdev = ia64_getdev;
 	archsw.arch_copyin = ia64_copyin;
 	archsw.arch_copyout = ia64_copyout;
+	archsw.arch_getdev = ia64_getdev;
+	archsw.arch_loadaddr = ia64_loadaddr;
+	archsw.arch_loadseg = ia64_loadseg;
 	archsw.arch_readin = ia64_readin;
 
 	interact();			/* doesn't return */

Modified: head/sys/ia64/include/bootinfo.h
==============================================================================
--- head/sys/ia64/include/bootinfo.h	Sun Apr  3 22:36:40 2011	(r220312)
+++ head/sys/ia64/include/bootinfo.h	Sun Apr  3 23:49:20 2011	(r220313)
@@ -30,7 +30,11 @@ struct bootinfo {
 	uint64_t	bi_magic;		/* BOOTINFO_MAGIC */
 #define	BOOTINFO_MAGIC		0xdeadbeeffeedface
 	uint64_t	bi_version;		/* version 1 */
-	uint64_t	bi_spare[5];		/* was: name of booted kernel */
+	uint64_t	bi_spare[3];		/* was: name of booted kernel */
+	uint32_t	bi_itr_used;		/* Number of ITR and DTR ... */
+	uint32_t	bi_dtr_used;		/* ... entries used. */
+	uint32_t	bi_text_mapped;		/* Size of text mapped. */
+	uint32_t	bi_data_mapped;		/* Size of data mapped. */
 	uint64_t	bi_pbvm_pgtbl;		/* PA of PBVM page table. */
 	uint64_t	bi_hcdp;		/* DIG64 HCDP table */
 	uint64_t	bi_fpswa;		/* FPSWA interface */

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 02:57:19 2011
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 B7CEA1065673;
	Mon,  4 Apr 2011 02:57:19 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A50288FC08;
	Mon,  4 Apr 2011 02:57:19 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p342vJlm068595;
	Mon, 4 Apr 2011 02:57:19 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p342vJCF068593;
	Mon, 4 Apr 2011 02:57:19 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <201104040257.p342vJCF068593@svn.freebsd.org>
From: Andrew Thompson 
Date: Mon, 4 Apr 2011 02:57: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: r220314 - head/usr.sbin/usbdump
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, 04 Apr 2011 02:57:19 -0000

Author: thompsa
Date: Mon Apr  4 02:57:19 2011
New Revision: 220314
URL: http://svn.freebsd.org/changeset/base/220314

Log:
  fix printing of tv_usec

Modified:
  head/usr.sbin/usbdump/usbdump.c

Modified: head/usr.sbin/usbdump/usbdump.c
==============================================================================
--- head/usr.sbin/usbdump/usbdump.c	Sun Apr  3 23:49:20 2011	(r220313)
+++ head/usr.sbin/usbdump/usbdump.c	Mon Apr  4 02:57:19 2011	(r220314)
@@ -323,7 +323,7 @@ print_apacket(const struct bpf_xhdr *hdr
 
 	len = strftime(buf, sizeof(buf), "%H:%M:%S", tm);
 
-	printf("%.*s.%06ju usbus%d.%d %s-%s-EP=%08x,SPD=%s,NFR=%d,SLEN=%d,IVAL=%d%s%s\n",
+	printf("%.*s.%06ld usbus%d.%d %s-%s-EP=%08x,SPD=%s,NFR=%d,SLEN=%d,IVAL=%d%s%s\n",
 	    (int)len, buf, tv.tv_usec,
 	    (int)up->up_busunit, (int)up->up_address,
 	    (up->up_type == USBPF_XFERTAP_SUBMIT) ? "SUBM" : "DONE",

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 03:43:14 2011
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 06C6C1065670;
	Mon,  4 Apr 2011 03:43:14 +0000 (UTC)
	(envelope-from thompsa@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id CD7048FC23;
	Mon,  4 Apr 2011 03:43:13 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p343hDYq069887;
	Mon, 4 Apr 2011 03:43:13 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p343hD0d069885;
	Mon, 4 Apr 2011 03:43:13 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <201104040343.p343hD0d069885@svn.freebsd.org>
From: Andrew Thompson 
Date: Mon, 4 Apr 2011 03:43: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: r220316 - head/usr.sbin/usbdump
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, 04 Apr 2011 03:43:14 -0000

Author: thompsa
Date: Mon Apr  4 03:43:13 2011
New Revision: 220316
URL: http://svn.freebsd.org/changeset/base/220316

Log:
  Lower WARNS to unbreak the build, some archs may have alignment issues.

Modified:
  head/usr.sbin/usbdump/Makefile

Modified: head/usr.sbin/usbdump/Makefile
==============================================================================
--- head/usr.sbin/usbdump/Makefile	Mon Apr  4 03:41:18 2011	(r220315)
+++ head/usr.sbin/usbdump/Makefile	Mon Apr  4 03:43:13 2011	(r220316)
@@ -3,6 +3,6 @@
 PROG=	usbdump
 SRCS=	usbdump.c
 MAN=	usbdump.8
-WARNS?=	4
+WARNS?=	3
 
 .include 

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 07:45:09 2011
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 6024D1065674;
	Mon,  4 Apr 2011 07:45:09 +0000 (UTC)
	(envelope-from glebius@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 314BA8FC1D;
	Mon,  4 Apr 2011 07:45:09 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p347j9N7074922;
	Mon, 4 Apr 2011 07:45:09 GMT (envelope-from glebius@svn.freebsd.org)
Received: (from glebius@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p347j9IW074920;
	Mon, 4 Apr 2011 07:45:09 GMT (envelope-from glebius@svn.freebsd.org)
Message-Id: <201104040745.p347j9IW074920@svn.freebsd.org>
From: Gleb Smirnoff 
Date: Mon, 4 Apr 2011 07:45: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: r220317 - head/sys/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: Mon, 04 Apr 2011 07:45:09 -0000

Author: glebius
Date: Mon Apr  4 07:45:08 2011
New Revision: 220317
URL: http://svn.freebsd.org/changeset/base/220317

Log:
  When removing ifnets, we should first remove the reference to ifnet
  from the interface index, then decrease refcount, not vice versa.
  
  Otherwise there is a race (reproducible) when if_free_internal()
  contests on IFNET_WLOCK(), and we got a zero-refed ifnet in the
  index for a long time. It may be picked by some other thread,
  that runs ifnet_byindex_ref(), who takes the ifnet from index,
  and bumps refcount. When reader drops the lock, if_free_internal()
  proceeds with free. Then reader tries to free it a second time.

Modified:
  head/sys/net/if.c

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c	Mon Apr  4 03:43:13 2011	(r220316)
+++ head/sys/net/if.c	Mon Apr  4 07:45:08 2011	(r220317)
@@ -465,8 +465,8 @@ if_alloc(u_char type)
 }
 
 /*
- * Do the actual work of freeing a struct ifnet, associated index, and layer
- * 2 common structure.  This call is made when the last reference to an
+ * Do the actual work of freeing a struct ifnet, and layer 2 common
+ * structure.  This call is made when the last reference to an
  * interface is released.
  */
 static void
@@ -476,13 +476,6 @@ if_free_internal(struct ifnet *ifp)
 	KASSERT((ifp->if_flags & IFF_DYING),
 	    ("if_free_internal: interface not dying"));
 
-	IFNET_WLOCK();
-	KASSERT(ifp == ifnet_byindex_locked(ifp->if_index),
-	    ("%s: freeing unallocated ifnet", ifp->if_xname));
-
-	ifindex_free_locked(ifp->if_index);
-	IFNET_WUNLOCK();
-
 	if (if_com_free[ifp->if_alloctype] != NULL)
 		if_com_free[ifp->if_alloctype](ifp->if_l2com,
 		    ifp->if_alloctype);
@@ -513,6 +506,14 @@ if_free_type(struct ifnet *ifp, u_char t
 	    ifp->if_alloctype));
 
 	ifp->if_flags |= IFF_DYING;			/* XXX: Locking */
+
+	IFNET_WLOCK();
+	KASSERT(ifp == ifnet_byindex_locked(ifp->if_index),
+	    ("%s: freeing unallocated ifnet", ifp->if_xname));
+
+	ifindex_free_locked(ifp->if_index);
+	IFNET_WUNLOCK();
+
 	if (!refcount_release(&ifp->if_refcount))
 		return;
 	if_free_internal(ifp);

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 09:25:28 2011
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 42A05106566C;
	Mon,  4 Apr 2011 09:25:28 +0000 (UTC)
	(envelope-from pluknet@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2EDC68FC1A;
	Mon,  4 Apr 2011 09:25:28 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p349PSkb077621;
	Mon, 4 Apr 2011 09:25:28 GMT (envelope-from pluknet@svn.freebsd.org)
Received: (from pluknet@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p349PSt0077619;
	Mon, 4 Apr 2011 09:25:28 GMT (envelope-from pluknet@svn.freebsd.org)
Message-Id: <201104040925.p349PSt0077619@svn.freebsd.org>
From: Sergey Kandaurov 
Date: Mon, 4 Apr 2011 09:25: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: r220319 - head/lib/libdevstat
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, 04 Apr 2011 09:25:28 -0000

Author: pluknet
Date: Mon Apr  4 09:25:27 2011
New Revision: 220319
URL: http://svn.freebsd.org/changeset/base/220319

Log:
  Do not increment num_args if strsep(3) returned an empty field.
  That fixes devstat_buildmatch(3) crashes with certain strings.
  
  Reported by:	arundel
  MFC after:	2 weeks

Modified:
  head/lib/libdevstat/devstat.c

Modified: head/lib/libdevstat/devstat.c
==============================================================================
--- head/lib/libdevstat/devstat.c	Mon Apr  4 08:04:32 2011	(r220318)
+++ head/lib/libdevstat/devstat.c	Mon Apr  4 09:25:27 2011	(r220319)
@@ -1014,11 +1014,12 @@ devstat_buildmatch(char *match_str, stru
 	 * Break the (comma delimited) input string out into separate strings.
 	 */
 	for (tempstr = tstr, num_args  = 0; 
-	     (*tempstr = strsep(&match_str, ",")) != NULL && (num_args < 5); 
-	     num_args++)
-		if (**tempstr != '\0')
+	     (*tempstr = strsep(&match_str, ",")) != NULL && (num_args < 5);)
+		if (**tempstr != '\0') {
+			num_args++;
 			if (++tempstr >= &tstr[5])
 				break;
+		}
 
 	/* The user gave us too many type arguments */
 	if (num_args > 3) {

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 11:01:53 2011
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 9A208106564A;
	Mon,  4 Apr 2011 11:01:53 +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 86D8B8FC0A;
	Mon,  4 Apr 2011 11:01:53 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p34B1rqD081516;
	Mon, 4 Apr 2011 11:01:53 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p34B1rN0081514;
	Mon, 4 Apr 2011 11:01:53 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104041101.p34B1rN0081514@svn.freebsd.org>
From: Adrian Chadd 
Date: Mon, 4 Apr 2011 11:01: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: r220323 - head/sys/dev/ath/ath_hal/ar5416
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, 04 Apr 2011 11:01:53 -0000

Author: adrian
Date: Mon Apr  4 11:01:53 2011
New Revision: 220323
URL: http://svn.freebsd.org/changeset/base/220323

Log:
  At least set the coverage class value here; worry about populating the
  register values at a later date.

Modified:
  head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c	Mon Apr  4 09:56:10 2011	(r220322)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c	Mon Apr  4 11:01:53 2011	(r220323)
@@ -124,6 +124,7 @@ ar5416SetDecompMask(struct ath_hal *ah, 
 void
 ar5416SetCoverageClass(struct ath_hal *ah, uint8_t coverageclass, int now)
 {
+	AH_PRIVATE(ah)->ah_coverageClass = coverageclass;
 }
 
 /*

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 14:52:32 2011
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 764641065680;
	Mon,  4 Apr 2011 14:52:32 +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 638ED8FC19;
	Mon,  4 Apr 2011 14:52:32 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p34EqWKa086540;
	Mon, 4 Apr 2011 14:52:32 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p34EqW5w086530;
	Mon, 4 Apr 2011 14:52:32 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104041452.p34EqW5w086530@svn.freebsd.org>
From: Adrian Chadd 
Date: Mon, 4 Apr 2011 14:52: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: r220324 - in head/sys/dev/ath: . ath_hal ath_hal/ar5210
	ath_hal/ar5211 ath_hal/ar5212 ath_hal/ar5416
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, 04 Apr 2011 14:52:32 -0000

Author: adrian
Date: Mon Apr  4 14:52:31 2011
New Revision: 220324
URL: http://svn.freebsd.org/changeset/base/220324

Log:
  Add a HAL capability bit for supporting self-linked RX descriptors and disable it for the 11n chipsets.
  
  From the ath9k source:
  
  ==
  
  11N: we can no longer afford to self link the last descriptor.
  MAC acknowledges BA status as long as it copies frames to host
  buffer (or rx fifo). This can incorrectly acknowledge packets
  to a sender if last desc is self-linked.
  
  ==
  
  Since this is useful for pre-AR5416 chips that communicate PHY errors
  via error frames rather than by on-chip counters, leave the support
  in there, but disable it for AR5416 and later.

Modified:
  head/sys/dev/ath/ath_hal/ah.c
  head/sys/dev/ath/ath_hal/ah.h
  head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c
  head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c
  head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c
  head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c
  head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c
  head/sys/dev/ath/if_ath.c
  head/sys/dev/ath/if_athvar.h

Modified: head/sys/dev/ath/ath_hal/ah.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.c	Mon Apr  4 11:01:53 2011	(r220323)
+++ head/sys/dev/ath/ath_hal/ah.c	Mon Apr  4 14:52:31 2011	(r220324)
@@ -616,6 +616,8 @@ ath_hal_getcapability(struct ath_hal *ah
 		return pCap->hal4kbSplitTransSupport ? HAL_OK : HAL_ENOTSUPP;
 	case HAL_CAP_HAS_PSPOLL:	/* hardware has ps-poll support */
 		return pCap->halHasPsPollSupport ? HAL_OK : HAL_ENOTSUPP;
+	case HAL_CAP_RXDESC_SELFLINK:	/* hardware supports self-linked final RX descriptors correctly */
+		return pCap->halHasRxSelfLinkedTail ? HAL_OK : HAL_ENOTSUPP;
 	default:
 		return HAL_EINVAL;
 	}

Modified: head/sys/dev/ath/ath_hal/ah.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.h	Mon Apr  4 11:01:53 2011	(r220323)
+++ head/sys/dev/ath/ath_hal/ah.h	Mon Apr  4 14:52:31 2011	(r220324)
@@ -114,6 +114,7 @@ typedef enum {
 	HAL_CAP_STREAMS		= 39,	/* how many 802.11n spatial streams are available */
 	HAL_CAP_SPLIT_4KB_TRANS	= 40,	/* hardware supports descriptors straddling a 4k page boundary */
 	HAL_CAP_HAS_PSPOLL	= 41,	/* hardware has ps-poll support */
+	HAL_CAP_RXDESC_SELFLINK	= 42,	/* support a self-linked tail RX descriptor */
 } HAL_CAPABILITY_TYPE;
 
 /* 

Modified: head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c	Mon Apr  4 11:01:53 2011	(r220323)
+++ head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c	Mon Apr  4 14:52:31 2011	(r220324)
@@ -378,6 +378,7 @@ ar5210FillCapabilityInfo(struct ath_hal 
 			;
 
 	pCap->hal4kbSplitTransSupport = AH_TRUE;
+	pCap->halHasRxSelfLinkedTail = AH_TRUE;
 
 	ahpriv->ah_rxornIsFatal = AH_TRUE;
 	return AH_TRUE;

Modified: head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c	Mon Apr  4 11:01:53 2011	(r220323)
+++ head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c	Mon Apr  4 14:52:31 2011	(r220324)
@@ -510,6 +510,7 @@ ar5211FillCapabilityInfo(struct ath_hal 
 			;
 
 	pCap->hal4kbSplitTransSupport = AH_TRUE;
+	pCap->halHasRxSelfLinkedTail = AH_TRUE;
 
 	/* XXX might be ok w/ some chip revs */
 	ahpriv->ah_rxornIsFatal = AH_TRUE;

Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c	Mon Apr  4 11:01:53 2011	(r220323)
+++ head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c	Mon Apr  4 14:52:31 2011	(r220324)
@@ -861,6 +861,7 @@ ar5212FillCapabilityInfo(struct ath_hal 
 		pCap->halIntrMask &= ~HAL_INT_TBTT;
 
 	pCap->hal4kbSplitTransSupport = AH_TRUE;
+	pCap->halHasRxSelfLinkedTail = AH_TRUE;
 
 	return AH_TRUE;
 #undef IS_COBRA

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c	Mon Apr  4 11:01:53 2011	(r220323)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c	Mon Apr  4 14:52:31 2011	(r220324)
@@ -843,6 +843,8 @@ ar5416FillCapabilityInfo(struct ath_hal 
 	pCap->halBtCoexSupport = AH_FALSE;	/* XXX need support */
 	pCap->halAutoSleepSupport = AH_FALSE;
 	pCap->hal4kbSplitTransSupport = AH_TRUE;
+	/* Disable this so Block-ACK works correctly */
+	pCap->halHasRxSelfLinkedTail = AH_FALSE;
 #if 0	/* XXX not yet */
 	pCap->halNumAntCfg2GHz = ar5416GetNumAntConfig(ahp, HAL_FREQ_BAND_2GHZ);
 	pCap->halNumAntCfg5GHz = ar5416GetNumAntConfig(ahp, HAL_FREQ_BAND_5GHZ);

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c	Mon Apr  4 11:01:53 2011	(r220323)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c	Mon Apr  4 14:52:31 2011	(r220324)
@@ -99,18 +99,9 @@ ar5416ProcRxDesc(struct ath_hal *ah, str
     struct ath_rx_status *rs)
 {
 	struct ar5416_desc *ads = AR5416DESC(ds);
-	struct ar5416_desc *ands = AR5416DESC(nds);
 
 	if ((ads->ds_rxstatus8 & AR_RxDone) == 0)
 		return HAL_EINPROGRESS;
-	/*
-	 * Given the use of a self-linked tail be very sure that the hw is
-	 * done with this descriptor; the hw may have done this descriptor
-	 * once and picked it up again...make sure the hw has moved on.
-	 */
-	if ((ands->ds_rxstatus8 & AR_RxDone) == 0
-	    && OS_REG_READ(ah, AR_RXDP) == pa)
-		return HAL_EINPROGRESS;
 
 	rs->rs_status = 0;
 	rs->rs_flags = 0;

Modified: head/sys/dev/ath/if_ath.c
==============================================================================
--- head/sys/dev/ath/if_ath.c	Mon Apr  4 11:01:53 2011	(r220323)
+++ head/sys/dev/ath/if_ath.c	Mon Apr  4 14:52:31 2011	(r220324)
@@ -595,6 +595,7 @@ ath_attach(u_int16_t devid, struct ath_s
 	sc->sc_hasbmask = ath_hal_hasbssidmask(ah);
 	sc->sc_hasbmatch = ath_hal_hasbssidmatch(ah);
 	sc->sc_hastsfadd = ath_hal_hastsfadjust(ah);
+	sc->sc_rxslink = ath_hal_self_linked_final_rxdesc(ah);
 	if (ath_hal_hasfastframes(ah))
 		ic->ic_caps |= IEEE80211_C_FF;
 	wmodes = ath_hal_getwirelessmodes(ah);
@@ -3135,8 +3136,17 @@ ath_rxbuf_init(struct ath_softc *sc, str
 	 * descriptor list.  This insures the hardware always has
 	 * someplace to write a new frame.
 	 */
+	/*
+	 * 11N: we can no longer afford to self link the last descriptor.
+	 * MAC acknowledges BA status as long as it copies frames to host
+	 * buffer (or rx fifo). This can incorrectly acknowledge packets
+	 * to a sender if last desc is self-linked.
+	 */
 	ds = bf->bf_desc;
-	ds->ds_link = bf->bf_daddr;	/* link to self */
+	if (sc->sc_rxslink)
+		ds->ds_link = bf->bf_daddr;	/* link to self */
+	else
+		ds->ds_link = 0;		/* terminate the list */
 	ds->ds_data = bf->bf_segs[0].ds_addr;
 	ath_hal_setuprxdesc(ah, ds
 		, m->m_len		/* buffer size */
@@ -3321,9 +3331,16 @@ ath_rx_proc(void *arg, int npending)
 	tsf = ath_hal_gettsf64(ah);
 	do {
 		bf = STAILQ_FIRST(&sc->sc_rxbuf);
-		if (bf == NULL) {		/* NB: shouldn't happen */
+		if (sc->sc_rxslink && bf == NULL) {	/* NB: shouldn't happen */
 			if_printf(ifp, "%s: no buffer!\n", __func__);
 			break;
+		} else if (bf == NULL) {
+			/*
+			 * End of List:
+			 * this can happen for non-self-linked RX chains
+			 */
+			sc->sc_stats.ast_rx_hitqueueend++;
+			break;
 		}
 		m = bf->bf_m;
 		if (m == NULL) {		/* NB: shouldn't happen */

Modified: head/sys/dev/ath/if_athvar.h
==============================================================================
--- head/sys/dev/ath/if_athvar.h	Mon Apr  4 11:01:53 2011	(r220323)
+++ head/sys/dev/ath/if_athvar.h	Mon Apr  4 14:52:31 2011	(r220324)
@@ -253,7 +253,8 @@ struct ath_softc {
 				sc_resume_up: 1,/* on resume, start all vaps */
 				sc_tdma	    : 1,/* TDMA in use */
 				sc_setcca   : 1,/* set/clr CCA with TDMA */
-				sc_resetcal : 1;/* reset cal state next trip */
+				sc_resetcal : 1,/* reset cal state next trip */
+				sc_rxslink  : 1;/* do self-linked final descriptor */
 	uint32_t		sc_eerd;	/* regdomain from EEPROM */
 	uint32_t		sc_eecc;	/* country code from EEPROM */
 						/* rate tables */
@@ -646,6 +647,8 @@ void	ath_intr(void *);
 	(ath_hal_getcapability(_ah, HAL_CAP_TX_CHAINMASK, 0, _ptxchainmask))
 #define	ath_hal_split4ktrans(_ah) \
 	(ath_hal_getcapability(_ah, HAP_CAP_SPLIT_4KB_TRANS, 0, NULL) == HAL_OK)
+#define	ath_hal_self_linked_final_rxdesc(_ah) \
+	(ath_hal_getcapability(_ah, HAL_CAP_RXDESC_SELFLINK, 0, NULL) == HAL_OK)
 
 #define	ath_hal_setuprxdesc(_ah, _ds, _size, _intreq) \
 	((*(_ah)->ah_setupRxDesc)((_ah), (_ds), (_size), (_intreq)))

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 14:53:37 2011
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 23B7E1065676;
	Mon,  4 Apr 2011 14:53:37 +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 EE55F8FC1C;
	Mon,  4 Apr 2011 14:53:36 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p34EraBL086599;
	Mon, 4 Apr 2011 14:53:36 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p34Era4q086595;
	Mon, 4 Apr 2011 14:53:36 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104041453.p34Era4q086595@svn.freebsd.org>
From: Adrian Chadd 
Date: Mon, 4 Apr 2011 14: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: r220325 - 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: Mon, 04 Apr 2011 14:53:37 -0000

Author: adrian
Date: Mon Apr  4 14:53:36 2011
New Revision: 220325
URL: http://svn.freebsd.org/changeset/base/220325

Log:
  Commit missing bits from the last commit:
  
  * add the hal capability flag
  * make sure its disabled for the ar9280/ar9285.

Modified:
  head/sys/dev/ath/ath_hal/ah_internal.h
  head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c
  head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c

Modified: head/sys/dev/ath/ath_hal/ah_internal.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_internal.h	Mon Apr  4 14:52:31 2011	(r220324)
+++ head/sys/dev/ath/ath_hal/ah_internal.h	Mon Apr  4 14:53:36 2011	(r220325)
@@ -197,7 +197,8 @@ typedef struct {
 			halMbssidAggrSupport		: 1,
 			halBssidMatchSupport		: 1,
 			hal4kbSplitTransSupport		: 1,
-			halHasPsPollSupport		: 1;
+			halHasPsPollSupport		: 1,
+			halHasRxSelfLinkedTail		: 1;
 	uint32_t	halWirelessModes;
 	uint16_t	halTotalQueues;
 	uint16_t	halKeyCacheSize;

Modified: head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c	Mon Apr  4 14:52:31 2011	(r220324)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c	Mon Apr  4 14:53:36 2011	(r220325)
@@ -780,6 +780,8 @@ ar9280FillCapabilityInfo(struct ath_hal 
 #endif
 	pCap->halAutoSleepSupport = AH_FALSE;	/* XXX? */
 	pCap->hal4kbSplitTransSupport = AH_FALSE;
+	/* Disable this so Block-ACK works correctly */
+	pCap->halHasRxSelfLinkedTail = AH_FALSE;
 	if (AR_SREV_MERLIN_20_OR_LATER(ah))
 		pCap->halHasPsPollSupport = AH_TRUE;
 	pCap->halRxStbcSupport = 1;

Modified: head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c	Mon Apr  4 14:52:31 2011	(r220324)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c	Mon Apr  4 14:53:36 2011	(r220325)
@@ -380,6 +380,8 @@ ar9285FillCapabilityInfo(struct ath_hal 
 #endif
 	pCap->halAutoSleepSupport = AH_FALSE;	/* XXX? */
 	pCap->hal4kbSplitTransSupport = AH_FALSE;
+	/* Disable this so Block-ACK works correctly */
+	pCap->halHasRxSelfLinkedTail = AH_FALSE;
 	if (AR_SREV_KITE_12_OR_LATER(ah))
 		pCap->halHasPsPollSupport = AH_TRUE;
 

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 16:23:01 2011
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 A9A70106566C;
	Mon,  4 Apr 2011 16:23:01 +0000 (UTC)
	(envelope-from pluknet@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9A6228FC15;
	Mon,  4 Apr 2011 16:23:01 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p34GN1Vh088748;
	Mon, 4 Apr 2011 16:23:01 GMT (envelope-from pluknet@svn.freebsd.org)
Received: (from pluknet@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p34GN1Zj088746;
	Mon, 4 Apr 2011 16:23:01 GMT (envelope-from pluknet@svn.freebsd.org)
Message-Id: <201104041623.p34GN1Zj088746@svn.freebsd.org>
From: Sergey Kandaurov 
Date: Mon, 4 Apr 2011 16:23: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: r220328 - 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, 04 Apr 2011 16:23:01 -0000

Author: pluknet
Date: Mon Apr  4 16:23:01 2011
New Revision: 220328
URL: http://svn.freebsd.org/changeset/base/220328

Log:
  Remove malloc type M_NETADDR unused since splitting into vfs_subr.c
  and vfs_export.c.
  
  MFC after:	1 week

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==============================================================================
--- head/sys/kern/vfs_subr.c	Mon Apr  4 14:57:28 2011	(r220327)
+++ head/sys/kern/vfs_subr.c	Mon Apr  4 16:23:01 2011	(r220328)
@@ -93,8 +93,6 @@ __FBSDID("$FreeBSD$");
 #define	WI_MPSAFEQ	0
 #define	WI_GIANTQ	1
 
-static MALLOC_DEFINE(M_NETADDR, "subr_export_host", "Export host address structure");
-
 static void	delmntque(struct vnode *vp);
 static int	flushbuflist(struct bufv *bufv, int flags, struct bufobj *bo,
 		    int slpflag, int slptimeo);

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 16:47:43 2011
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 1D4F4106564A;
	Mon,  4 Apr 2011 16:47:43 +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 0E71F8FC0C;
	Mon,  4 Apr 2011 16:47:43 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p34GlgrY089450;
	Mon, 4 Apr 2011 16:47:42 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p34Glgli089448;
	Mon, 4 Apr 2011 16:47:42 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104041647.p34Glgli089448@svn.freebsd.org>
From: Jung-uk Kim 
Date: Mon, 4 Apr 2011 16:47: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: r220331 - 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: Mon, 04 Apr 2011 16:47:43 -0000

Author: jkim
Date: Mon Apr  4 16:47:42 2011
New Revision: 220331
URL: http://svn.freebsd.org/changeset/base/220331

Log:
  Add inline to acpi_timer_read() to reduce unnecessary jumps and calls.

Modified:
  head/sys/dev/acpica/acpi_timer.c

Modified: head/sys/dev/acpica/acpi_timer.c
==============================================================================
--- head/sys/dev/acpica/acpi_timer.c	Mon Apr  4 16:24:05 2011	(r220330)
+++ head/sys/dev/acpica/acpi_timer.c	Mon Apr  4 16:47:42 2011	(r220331)
@@ -71,7 +71,6 @@ static u_int	acpi_timer_get_timecount_sa
 static int	acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS);
 static void	acpi_timer_boot_test(void);
 
-static u_int	acpi_timer_read(void);
 static int	acpi_timer_test(void);
 
 static device_method_t acpi_timer_methods[] = {
@@ -101,9 +100,10 @@ static struct timecounter acpi_timer_tim
 	-1				/* quality (chosen later) */
 };
 
-static u_int
-acpi_timer_read()
+static __inline uint32_t
+acpi_timer_read(void)
 {
+
     return (bus_space_read_4(acpi_timer_bst, acpi_timer_bsh, 0));
 }
 

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 16:59:46 2011
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 C16ED1065670;
	Mon,  4 Apr 2011 16:59:46 +0000 (UTC)
	(envelope-from marcel@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B28878FC12;
	Mon,  4 Apr 2011 16:59:46 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p34GxkT1089798;
	Mon, 4 Apr 2011 16:59:46 GMT (envelope-from marcel@svn.freebsd.org)
Received: (from marcel@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p34Gxkwd089796;
	Mon, 4 Apr 2011 16:59:46 GMT (envelope-from marcel@svn.freebsd.org)
Message-Id: <201104041659.p34Gxkwd089796@svn.freebsd.org>
From: Marcel Moolenaar 
Date: Mon, 4 Apr 2011 16:59:46 +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: r220332 - 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: Mon, 04 Apr 2011 16:59:46 -0000

Author: marcel
Date: Mon Apr  4 16:59:46 2011
New Revision: 220332
URL: http://svn.freebsd.org/changeset/base/220332

Log:
  Fix a long standing bug where file_load() passes down the global loadaddr
  to the l_load() method in the file_formats structure, while being passed
  an address as an argument (dest). With file_load() calling arch_loadaddr()
  now, this bug is a little bit more significant.
  
  Spotted by: nyan@ (nice catch!)

Modified:
  head/sys/boot/common/module.c

Modified: head/sys/boot/common/module.c
==============================================================================
--- head/sys/boot/common/module.c	Mon Apr  4 16:47:42 2011	(r220331)
+++ head/sys/boot/common/module.c	Mon Apr  4 16:59:46 2011	(r220332)
@@ -280,7 +280,7 @@ file_load(char *filename, vm_offset_t de
 
     error = EFTYPE;
     for (i = 0, fp = NULL; file_formats[i] && fp == NULL; i++) {
-	error = (file_formats[i]->l_load)(filename, loadaddr, &fp);
+	error = (file_formats[i]->l_load)(filename, dest, &fp);
 	if (error == 0) {
 	    fp->f_loader = i;		/* remember the loader */
 	    *result = fp;

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 17:00:50 2011
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 82864106564A;
	Mon,  4 Apr 2011 17:00:50 +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 73A5A8FC14;
	Mon,  4 Apr 2011 17:00:50 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p34H0oOh089939;
	Mon, 4 Apr 2011 17:00:50 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p34H0oS8089937;
	Mon, 4 Apr 2011 17:00:50 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104041700.p34H0oS8089937@svn.freebsd.org>
From: Jung-uk Kim 
Date: Mon, 4 Apr 2011 17:00: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: r220333 - 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: Mon, 04 Apr 2011 17:00:50 -0000

Author: jkim
Date: Mon Apr  4 17:00:50 2011
New Revision: 220333
URL: http://svn.freebsd.org/changeset/base/220333

Log:
  Lower the bar for ACPI-fast on virtual machines.  The current logic depends
  on the fact that real hardware has almost fixed cost to read the ACPI timer.
  It is virtually always false for hardware emulation and it makes no sense to
  read it multiple times, which is already quite expensive for full emulation.

Modified:
  head/sys/dev/acpica/acpi_timer.c

Modified: head/sys/dev/acpica/acpi_timer.c
==============================================================================
--- head/sys/dev/acpica/acpi_timer.c	Mon Apr  4 16:59:46 2011	(r220332)
+++ head/sys/dev/acpica/acpi_timer.c	Mon Apr  4 17:00:50 2011	(r220333)
@@ -327,14 +327,15 @@ acpi_timer_test()
     }
     intr_restore(s);
 
-    if (max - min > 2)
+    delta = max - min;
+    if (delta > 2 && vm_guest == VM_GUEST_NO)
 	n = 0;
     else if (min < 0 || max == 0)
 	n = 0;
     else
 	n = 1;
     if (bootverbose)
-	printf(" %d/%d", n, max-min);
+	printf(" %d/%d", n, delta);
 
     return (n);
 }

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 17:30:33 2011
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 B5A6E1065670;
	Mon,  4 Apr 2011 17:30:33 +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 A6B9A8FC12;
	Mon,  4 Apr 2011 17:30:33 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p34HUX94090544;
	Mon, 4 Apr 2011 17:30:33 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p34HUXrJ090542;
	Mon, 4 Apr 2011 17:30:33 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104041730.p34HUXrJ090542@svn.freebsd.org>
From: Jung-uk Kim 
Date: Mon, 4 Apr 2011 17:30: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: r220334 - 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: Mon, 04 Apr 2011 17:30:33 -0000

Author: jkim
Date: Mon Apr  4 17:30:33 2011
New Revision: 220334
URL: http://svn.freebsd.org/changeset/base/220334

Log:
  Fix bogus logic to calculate delta between two values from ACPI timers.

Modified:
  head/sys/dev/acpica/acpi.c

Modified: head/sys/dev/acpica/acpi.c
==============================================================================
--- head/sys/dev/acpica/acpi.c	Mon Apr  4 17:00:50 2011	(r220333)
+++ head/sys/dev/acpica/acpi.c	Mon Apr  4 17:30:33 2011	(r220334)
@@ -2088,15 +2088,10 @@ acpi_GetHandleInScope(ACPI_HANDLE parent
 uint32_t
 acpi_TimerDelta(uint32_t end, uint32_t start)
 {
-    uint32_t delta;
 
-    if (end >= start)
-	delta = end - start;
-    else if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER)
-	delta = ((0xFFFFFFFF - start) + end + 1);
-    else
-	delta = ((0x00FFFFFF - start) + end + 1) & 0x00FFFFFF;
-    return (delta);
+	if (end < start && (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0)
+		end |= 0x01000000;
+	return (end - start);
 }
 
 /*

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 17:39:30 2011
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 B51A21065679;
	Mon,  4 Apr 2011 17:39:30 +0000 (UTC) (envelope-from avg@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A62508FC1C;
	Mon,  4 Apr 2011 17:39:30 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p34HdUwN090735;
	Mon, 4 Apr 2011 17:39:30 GMT (envelope-from avg@svn.freebsd.org)
Received: (from avg@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p34HdUc9090733;
	Mon, 4 Apr 2011 17:39:30 GMT (envelope-from avg@svn.freebsd.org)
Message-Id: <201104041739.p34HdUc9090733@svn.freebsd.org>
From: Andriy Gapon 
Date: Mon, 4 Apr 2011 17:39: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: r220335 - 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: Mon, 04 Apr 2011 17:39:30 -0000

Author: avg
Date: Mon Apr  4 17:39:30 2011
New Revision: 220335
URL: http://svn.freebsd.org/changeset/base/220335

Log:
  errno.h: fix couple of whitespace nits
  
  Submitted by:	bde (a half of the changes)
  MFC after:	1 week

Modified:
  head/sys/sys/errno.h

Modified: head/sys/sys/errno.h
==============================================================================
--- head/sys/sys/errno.h	Mon Apr  4 17:30:33 2011	(r220334)
+++ head/sys/sys/errno.h	Mon Apr  4 17:39:30 2011	(r220335)
@@ -165,7 +165,7 @@ __END_DECLS
 #define	EILSEQ		86		/* Illegal byte sequence */
 #define	ENOATTR		87		/* Attribute not found */
 
-#define EDOOFUS		88		/* Programming error */
+#define	EDOOFUS		88		/* Programming error */
 #endif /* _POSIX_SOURCE */
 
 #define	EBADMSG		89		/* Bad message */
@@ -175,7 +175,7 @@ __END_DECLS
 
 #ifndef _POSIX_SOURCE
 #define	ENOTCAPABLE	93		/* Capabilities insufficient */
-#define	ECAPMODE		94		/* Not permitted in capability mode */
+#define	ECAPMODE	94		/* Not permitted in capability mode */
 #endif /* _POSIX_SOURCE */
 
 #ifndef _POSIX_SOURCE

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 17:44:26 2011
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 E36191065673;
	Mon,  4 Apr 2011 17:44:26 +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 D486F8FC23;
	Mon,  4 Apr 2011 17:44:26 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p34HiQEJ090868;
	Mon, 4 Apr 2011 17:44:26 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p34HiQoY090866;
	Mon, 4 Apr 2011 17:44:26 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104041744.p34HiQoY090866@svn.freebsd.org>
From: Jung-uk Kim 
Date: Mon, 4 Apr 2011 17:44: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: r220336 - 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: Mon, 04 Apr 2011 17:44:27 -0000

Author: jkim
Date: Mon Apr  4 17:44:26 2011
New Revision: 220336
URL: http://svn.freebsd.org/changeset/base/220336

Log:
  Always check the current minimum value to make the test more predictable.
  Use INT32_MAX instead of an arbitrary big number for the initial minimum.

Modified:
  head/sys/dev/acpica/acpi_timer.c

Modified: head/sys/dev/acpica/acpi_timer.c
==============================================================================
--- head/sys/dev/acpica/acpi_timer.c	Mon Apr  4 17:39:30 2011	(r220335)
+++ head/sys/dev/acpica/acpi_timer.c	Mon Apr  4 17:44:26 2011	(r220336)
@@ -310,7 +310,7 @@ acpi_timer_test()
     int		min, max, n, delta;
     register_t	s;
 
-    min = 10000000;
+    min = INT32_MAX;
     max = 0;
 
     /* Test the timer with interrupts disabled to get accurate results. */
@@ -321,7 +321,7 @@ acpi_timer_test()
 	delta = acpi_TimerDelta(this, last);
 	if (delta > max)
 	    max = delta;
-	else if (delta < min)
+	if (delta < min)
 	    min = delta;
 	last = this;
     }

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 18:23:56 2011
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 63497106566B;
	Mon,  4 Apr 2011 18:23:56 +0000 (UTC)
	(envelope-from rdivacky@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 497A18FC14;
	Mon,  4 Apr 2011 18:23:56 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p34INuFF091843;
	Mon, 4 Apr 2011 18:23:56 GMT (envelope-from rdivacky@svn.freebsd.org)
Received: (from rdivacky@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p34INubM091839;
	Mon, 4 Apr 2011 18:23:56 GMT (envelope-from rdivacky@svn.freebsd.org)
Message-Id: <201104041823.p34INubM091839@svn.freebsd.org>
From: Roman Divacky 
Date: Mon, 4 Apr 2011 18:23: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: r220337 - head/sys/boot/i386/boot2
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, 04 Apr 2011 18:23:56 -0000

Author: rdivacky
Date: Mon Apr  4 18:23:55 2011
New Revision: 220337
URL: http://svn.freebsd.org/changeset/base/220337

Log:
  Build boot2 with -mregparm=3, ie. pass upto 3 arguments via registers.
  This modifies CFLAGS and tweaks sio.S to use the new calling convention.
  The sio_init() and sio_putc() prototypes are modified so that other
  users of this code know the correct calling convention.
  
  This makes the code smaller when compiled with clang.
  
  Reviewed by:    jhb
  Tested by:      me and Freddie Cash 

Modified:
  head/sys/boot/i386/boot2/Makefile
  head/sys/boot/i386/boot2/lib.h
  head/sys/boot/i386/boot2/sio.S

Modified: head/sys/boot/i386/boot2/Makefile
==============================================================================
--- head/sys/boot/i386/boot2/Makefile	Mon Apr  4 17:44:26 2011	(r220336)
+++ head/sys/boot/i386/boot2/Makefile	Mon Apr  4 18:23:55 2011	(r220337)
@@ -31,6 +31,7 @@ CFLAGS=	-Os \
 	-fno-unit-at-a-time \
 	-mno-align-long-strings \
 	-mrtd \
+	-mregparm=3 \
 	-D${BOOT2_UFS} \
 	-DFLAGS=${BOOT_BOOT1_FLAGS} \
 	-DSIOPRT=${BOOT_COMCONSOLE_PORT} \

Modified: head/sys/boot/i386/boot2/lib.h
==============================================================================
--- head/sys/boot/i386/boot2/lib.h	Mon Apr  4 17:44:26 2011	(r220336)
+++ head/sys/boot/i386/boot2/lib.h	Mon Apr  4 18:23:55 2011	(r220337)
@@ -17,8 +17,8 @@
  * $FreeBSD$
  */
 
-void sio_init(int);
+void sio_init(int) __attribute__((regparm (3)));
 void sio_flush(void);
-void sio_putc(int);
+void sio_putc(int) __attribute__((regparm (3)));
 int sio_getc(void);
 int sio_ischar(void);

Modified: head/sys/boot/i386/boot2/sio.S
==============================================================================
--- head/sys/boot/i386/boot2/sio.S	Mon Apr  4 17:44:26 2011	(r220336)
+++ head/sys/boot/i386/boot2/sio.S	Mon Apr  4 18:23:55 2011	(r220337)
@@ -26,14 +26,14 @@
 
 /* void sio_init(int div) */
 
-sio_init:	movw $SIO_PRT+0x3,%dx		# Data format reg
+sio_init:	pushl %eax
+		movw $SIO_PRT+0x3,%dx		# Data format reg
 		movb $SIO_FMT|0x80,%al		# Set format
 		outb %al,(%dx)			#  and DLAB
-		pushl %edx			# Save
 		subb $0x3,%dl			# Divisor latch reg
-		movl 0x8(%esp),%eax		# Set
+		popl %eax
 		outw %ax,(%dx)			#  BPS
-		popl %edx			# Restore
+		movw $SIO_PRT+0x3,%dx		# Data format reg
 		movb $SIO_FMT,%al		# Clear
 		outb %al,(%dx)			#  DLAB
 		incl %edx			# Modem control reg
@@ -41,7 +41,7 @@ sio_init:	movw $SIO_PRT+0x3,%dx		# Data 
 		outb %al,(%dx)			#  DTR
 		incl %edx			# Line status reg
 		call sio_flush
-		ret $0x4
+		ret
 
 /* void sio_flush(void) */
 
@@ -52,17 +52,18 @@ sio_flush:	call sio_ischar 		# Check for
 
 /* void sio_putc(int c) */
 
-sio_putc:	movw $SIO_PRT+0x5,%dx		# Line status reg
+sio_putc:	pushl %eax
+		movw $SIO_PRT+0x5,%dx		# Line status reg
 		xor %ecx,%ecx			# Timeout
 		movb $0x40,%ch			#  counter
 sio_putc.1:	inb (%dx),%al			# Transmitter
 		testb $0x20,%al 		#  buffer empty?
 		loopz sio_putc.1		# No
 		jz sio_putc.2			# If timeout
-		movb 0x4(%esp,1),%al		# Get character
+		popl %eax                       # Get the character
 		subb $0x5,%dl			# Transmitter hold reg
 		outb %al,(%dx)			# Write character
-sio_putc.2:	ret $0x4			# To caller
+sio_putc.2:	ret				# To caller
 
 /* int sio_getc(void) */
 

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 18:39:04 2011
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 6D300106566B;
	Mon,  4 Apr 2011 18:39:04 +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 5D9348FC1A;
	Mon,  4 Apr 2011 18:39:04 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p34Id4nB092169;
	Mon, 4 Apr 2011 18:39:04 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p34Id4Ka092166;
	Mon, 4 Apr 2011 18:39:04 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104041839.p34Id4Ka092166@svn.freebsd.org>
From: Jung-uk Kim 
Date: Mon, 4 Apr 2011 18:39: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: r220338 - 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: Mon, 04 Apr 2011 18:39:04 -0000

Author: jkim
Date: Mon Apr  4 18:39:04 2011
New Revision: 220338
URL: http://svn.freebsd.org/changeset/base/220338

Log:
  Move a trivial acpi_TimerDelta() to acpivar.h to make it inlineable.

Modified:
  head/sys/dev/acpica/acpi.c
  head/sys/dev/acpica/acpivar.h

Modified: head/sys/dev/acpica/acpi.c
==============================================================================
--- head/sys/dev/acpica/acpi.c	Mon Apr  4 18:23:55 2011	(r220337)
+++ head/sys/dev/acpica/acpi.c	Mon Apr  4 18:39:04 2011	(r220338)
@@ -2084,16 +2084,6 @@ acpi_GetHandleInScope(ACPI_HANDLE parent
     }
 }
 
-/* Find the difference between two PM tick counts. */
-uint32_t
-acpi_TimerDelta(uint32_t end, uint32_t start)
-{
-
-	if (end < start && (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0)
-		end |= 0x01000000;
-	return (end - start);
-}
-
 /*
  * Allocate a buffer with a preset data size.
  */

Modified: head/sys/dev/acpica/acpivar.h
==============================================================================
--- head/sys/dev/acpica/acpivar.h	Mon Apr  4 18:23:55 2011	(r220337)
+++ head/sys/dev/acpica/acpivar.h	Mon Apr  4 18:39:04 2011	(r220338)
@@ -273,6 +273,16 @@ acpi_get_type(device_t dev)
     return (t);
 }
 
+/* Find the difference between two PM tick counts. */
+static __inline uint32_t
+acpi_TimerDelta(uint32_t end, uint32_t start)
+{
+
+	if (end < start && (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0)
+		end |= 0x01000000;
+	return (end - start);
+}
+
 #ifdef ACPI_DEBUGGER
 void		acpi_EnterDebugger(void);
 #endif
@@ -311,7 +321,6 @@ BOOLEAN		acpi_DeviceIsPresent(device_t d
 BOOLEAN		acpi_BatteryIsPresent(device_t dev);
 ACPI_STATUS	acpi_GetHandleInScope(ACPI_HANDLE parent, char *path,
 		    ACPI_HANDLE *result);
-uint32_t	acpi_TimerDelta(uint32_t end, uint32_t start);
 ACPI_BUFFER	*acpi_AllocBuffer(int size);
 ACPI_STATUS	acpi_ConvertBufferToInteger(ACPI_BUFFER *bufp,
 		    UINT32 *number);

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 22:30:13 2011
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 00FE4106564A;
	Mon,  4 Apr 2011 22:30:13 +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 E274A8FC16;
	Mon,  4 Apr 2011 22:30:12 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p34MUC8A097493;
	Mon, 4 Apr 2011 22:30:12 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p34MUCeG097490;
	Mon, 4 Apr 2011 22:30:12 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104042230.p34MUCeG097490@svn.freebsd.org>
From: Adrian Chadd 
Date: Mon, 4 Apr 2011 22:30:12 +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: r220346 - 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, 04 Apr 2011 22:30:13 -0000

Author: adrian
Date: Mon Apr  4 22:30:12 2011
New Revision: 220346
URL: http://svn.freebsd.org/changeset/base/220346

Log:
  Add a manpage for the nvram2env driver.

Added:
  head/share/man/man4/nvram2env.4   (contents, props changed)
Modified:
  head/share/man/man4/Makefile

Modified: head/share/man/man4/Makefile
==============================================================================
--- head/share/man/man4/Makefile	Mon Apr  4 20:45:39 2011	(r220345)
+++ head/share/man/man4/Makefile	Mon Apr  4 22:30:12 2011	(r220346)
@@ -317,6 +317,7 @@ MAN=	aac.4 \
 	null.4 \
 	${_nve.4} \
 	${_nvram.4} \
+	${_nvram2env.4} \
 	${_nxge.4} \
 	ohci.4 \
 	orm.4 \
@@ -710,6 +711,9 @@ MLINKS+=lindev.4 full.4
 .if ${MACHINE_CPUARCH} == "powerpc"
 _atp.4=		atp.4
 .endif
+.if ${MACHINE_CPUARCH} == "mips"
+_nvram2env.4=	nvram2env.4
+.endif
 
 .if exists(${.CURDIR}/man4.${MACHINE_CPUARCH})
 SUBDIR=	man4.${MACHINE_CPUARCH}

Added: head/share/man/man4/nvram2env.4
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/share/man/man4/nvram2env.4	Mon Apr  4 22:30:12 2011	(r220346)
@@ -0,0 +1,119 @@
+.\" Copyright (c) 2011 Aleksandr Rybalko
+.\" 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 April 3, 2011
+.Dt nvram2env 4
+.Os
+.Sh NAME
+.Nm nvram2env
+.Nd "copy nvram-like data into kernel environment"
+.Sh SYNOPSIS
+.Cd "device	nvram2env"
+.Sh DESCRIPTION
+.Nm
+implements a simple method of reading the NVRAM-like data and information
+stored in flash and storing it in the kernel environment.  It can then be
+used by various device drivers at boot-time.
+.Pp
+The NVRAM-like data is an array of zero terminated strings.  Each string contains
+the string name, "=" delimiter and the string value.
+.Pp
+.Nm
+copies the environment values into kernel environment using the kernel setenv call.
+.Pp
+Configuration of 
+.Nm
+is done in
+.Xr device.hints 5
+defining the NVRAM base address, fallback base address, maxsize and flags.
+.Pp
+.Nm
+is currently MIPS-specific.
+.Ss base
+base - physical address where data block is stored.
+.Ss fallbackbase
+fallbackbase - physical address where data block is stored, but only
+if not found at base.
+.Ss maxsize
+maxsize - maximum size of data block.
+.Ss flags
+flags - control flags, used to select nvram type and enable/disable CRC check.
+.Bl -tag -width indent
+.It Fa 0x0001
+Avoid CRC checking. Currently CRC checking is not implemented, so to be future
+compatible, please set it to "1".
+.It Fa 0x0002
+Use format "Generic", skip uint32_t field, then zero terminating array of
+strings.
+.It Fa 0x0004
+Use Broadcom CFE format. uint32_t signature "FLSH", uint32_t size, 
+three unused fields uint32_t, then data.
+.It Fa 0x0008
+Use U-Boot format, uint32_t crc, then zero terminating array of strings.
+.El
+.Sh EXAMPLES
+Usage in U-Boot case:
+.Bd -literal -offset indent
+hint.nvram.0.base=0x1f030000
+hint.nvram.0.maxsize=0x2000
+hint.nvram.0.flags=3 # 1 = No check, 2 = Format Generic
+hint.nvram.1.base=0x1f032000
+hint.nvram.1.maxsize=0x4000
+hint.nvram.1.flags=3 # 1 = No check, 2 = Format Generic
+.Ed
+.Pp
+CFE nvram with fallback:
+.Bd -literal -offset indent
+hint.nvram.0.base=0x1fff8000
+hint.nvram.0.fallbackbase=0x1fc00400
+hint.nvram.0.flags=4 # 4 = Format Broadcom
+.Ed
+.Pp
+but seems for CFE nvram preferred to read both blocks:
+.Pp
+NVRAM partition: Static, CFE internal
+.Bd -literal -offset indent
+hint.nvram.0.flags=0x05 # Broadcom + nocheck
+hint.nvram.0.base=0x1fc00400
+.Ed
+.Pp
+Dynamic, editable form CFE, override values from first
+.Pp
+.Bd -literal -offset indent
+hint.nvram.1.flags=0x05 # Broadcom + nocheck
+hint.nvram.1.base=0x1cff8000
+.Ed
+.Sh SEE ALSO
+.Xr kenv 1 ,
+.Xr kenv 2 .
+.Sh HISTORY
+.Nm
+first appeared in
+.Fx 9.0 .
+.Sh AUTHORS
+.An -nosplit
+.Nm
+.An Aleksandr Rybalko Aq ray@ddteam.net .

From owner-svn-src-head@FreeBSD.ORG  Mon Apr  4 22:56:33 2011
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 9D300106564A;
	Mon,  4 Apr 2011 22:56:33 +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 8C0E78FC19;
	Mon,  4 Apr 2011 22:56:33 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p34MuXTS098073;
	Mon, 4 Apr 2011 22:56:33 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p34MuXtU098071;
	Mon, 4 Apr 2011 22:56:33 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104042256.p34MuXtU098071@svn.freebsd.org>
From: Jung-uk Kim 
Date: Mon, 4 Apr 2011 22:56: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: r220347 - head/sys/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: Mon, 04 Apr 2011 22:56:33 -0000

Author: jkim
Date: Mon Apr  4 22:56:33 2011
New Revision: 220347
URL: http://svn.freebsd.org/changeset/base/220347

Log:
  Use cpu_ticks() for get_cyclecount(9) rather than checking existence of TSC
  at run-time on i386.  cpu_ticks() is set to use RDTSC early enough on i386
  where it is available.  Otherwise, cpu_ticks() is driven by the current
  timecounter hardware as binuptime(9) does.  This also avoids unnecessary
  namespace pollution from .

Modified:
  head/sys/i386/include/cpu.h

Modified: head/sys/i386/include/cpu.h
==============================================================================
--- head/sys/i386/include/cpu.h	Mon Apr  4 22:30:12 2011	(r220346)
+++ head/sys/i386/include/cpu.h	Mon Apr  4 22:56:33 2011	(r220347)
@@ -39,7 +39,6 @@
 /*
  * Definitions unique to i386 cpu support.
  */
-#include 
 #include 
 #include 
 #include 
@@ -70,13 +69,8 @@ void	swi_vm(void *);
 static __inline uint64_t
 get_cyclecount(void)
 {
-	struct bintime bt;
 
-	if (cpu_class == CPUCLASS_486) {
-		binuptime(&bt);
-		return ((uint64_t)bt.sec << 56 | bt.frac >> 8);
-	}
-	return (rdtsc());
+	return (cpu_ticks());
 }
 
 #endif

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 03:09:44 2011
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 93D721065673;
	Tue,  5 Apr 2011 03:09:44 +0000 (UTC)
	(envelope-from nwhitehorn@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 82EC68FC0A;
	Tue,  5 Apr 2011 03:09:44 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3539ilw003686;
	Tue, 5 Apr 2011 03:09:44 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Received: (from nwhitehorn@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3539i4u003684;
	Tue, 5 Apr 2011 03:09:44 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Message-Id: <201104050309.p3539i4u003684@svn.freebsd.org>
From: Nathan Whitehorn 
Date: Tue, 5 Apr 2011 03:09: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: r220350 - head/usr.sbin/bsdinstall
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, 05 Apr 2011 03:09:44 -0000

Author: nwhitehorn
Date: Tue Apr  5 03:09:44 2011
New Revision: 220350
URL: http://svn.freebsd.org/changeset/base/220350

Log:
  Improve logging by always sending stderr to the installation log file.
  Reduce warnings by making sure the temporary etc directory exists.

Modified:
  head/usr.sbin/bsdinstall/bsdinstall

Modified: head/usr.sbin/bsdinstall/bsdinstall
==============================================================================
--- head/usr.sbin/bsdinstall/bsdinstall	Tue Apr  5 01:51:30 2011	(r220349)
+++ head/usr.sbin/bsdinstall/bsdinstall	Tue Apr  5 03:09:44 2011	(r220350)
@@ -38,5 +38,7 @@ if [ -z $VERB ]; then
 	VERB=auto
 fi
 
-exec /usr/libexec/bsdinstall/$VERB $@
+test -d "$BSDINSTALL_TMPETC" || mkdir "$BSDINSTALL_TMPETC"
+echo Running installation step: $VERB $@ >> "$BSDINSTALL_LOG"
+exec /usr/libexec/bsdinstall/$VERB $@ 2>>"$BSDINSTALL_LOG"
 

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 03:11:22 2011
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 37E69106566B;
	Tue,  5 Apr 2011 03:11:22 +0000 (UTC)
	(envelope-from nwhitehorn@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 26E5B8FC0A;
	Tue,  5 Apr 2011 03:11:22 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p353BMSA003775;
	Tue, 5 Apr 2011 03:11:22 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Received: (from nwhitehorn@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p353BMBg003773;
	Tue, 5 Apr 2011 03:11:22 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Message-Id: <201104050311.p353BMBg003773@svn.freebsd.org>
From: Nathan Whitehorn 
Date: Tue, 5 Apr 2011 03:11: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: r220351 - head/usr.sbin/bsdinstall/scripts
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, 05 Apr 2011 03:11:22 -0000

Author: nwhitehorn
Date: Tue Apr  5 03:11:21 2011
New Revision: 220351
URL: http://svn.freebsd.org/changeset/base/220351

Log:
  Check correctly for whether there are any available wireless networks. This
  was tested on a train in the middle of an upstate New York swamp.

Modified:
  head/usr.sbin/bsdinstall/scripts/wlanconfig

Modified: head/usr.sbin/bsdinstall/scripts/wlanconfig
==============================================================================
--- head/usr.sbin/bsdinstall/scripts/wlanconfig	Tue Apr  5 03:09:44 2011	(r220350)
+++ head/usr.sbin/bsdinstall/scripts/wlanconfig	Tue Apr  5 03:11:21 2011	(r220351)
@@ -60,7 +60,7 @@ NETWORKS=`echo "$SCAN_RESULTS" | awk -F 
    '/..:..:..:..:..:../ {if (length($5) > 0) printf("\"%s\"\t%s\n", $5, $4);}' |
    sort | uniq`
 
-if [ -z $SCAN_RESULTS ]; then
+if [ -z $NETWORKS ]; then
 	dialog --backtitle "FreeBSD Installer" --title "Error" \
 	    --yesno "No wireless networks were found. Rescan?" 0 0 && \
 	    exec $0 $@

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 05:15:49 2011
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 3FD0D106566B;
	Tue,  5 Apr 2011 05:15:49 +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 2D8CF8FC12;
	Tue,  5 Apr 2011 05:15:49 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p355FnKE006449;
	Tue, 5 Apr 2011 05:15:49 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p355FnOg006447;
	Tue, 5 Apr 2011 05:15:49 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104050515.p355FnOg006447@svn.freebsd.org>
From: Adrian Chadd 
Date: Tue, 5 Apr 2011 05:15: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: r220354 - head/sys/mips/atheros
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, 05 Apr 2011 05:15:49 -0000

Author: adrian
Date: Tue Apr  5 05:15:48 2011
New Revision: 220354
URL: http://svn.freebsd.org/changeset/base/220354

Log:
  Begin fleshing out a functioning debugging setup for if_arge.
  
  I'm seeing TX hangs when doing large amounts of TX traffic;
  an interface reset fixes it. This will hopefully help me identify
  why.

Modified:
  head/sys/mips/atheros/if_arge.c

Modified: head/sys/mips/atheros/if_arge.c
==============================================================================
--- head/sys/mips/atheros/if_arge.c	Tue Apr  5 04:23:08 2011	(r220353)
+++ head/sys/mips/atheros/if_arge.c	Tue Apr  5 05:15:48 2011	(r220354)
@@ -82,11 +82,20 @@ MODULE_DEPEND(arge, miibus, 1, 1, 1);
 #include 
 #include 
 
+typedef enum {
+	ARGE_DBG_MII 	=	0x00000001,
+	ARGE_DBG_INTR	=	0x00000002
+} arge_debug_flags;
+
 #undef ARGE_DEBUG
 #ifdef ARGE_DEBUG
-#define dprintf printf
+#define	ARGEDEBUG(_sc, _m, ...) 					\
+	do {								\
+		if ((_m) & (_sc)->arge_debug)				\
+			device_printf((_sc)->arge_dev, __VA_ARGS__);	\
+	} while (0)
 #else
-#define dprintf(x, arg...)
+#define	ARGEDEBUG(_sc, _m, ...)
 #endif
 
 static int arge_attach(device_t);
@@ -215,6 +224,10 @@ arge_attach_sysctl(device_t dev)
 	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
 		"tx_pkts_unaligned", CTLFLAG_RW, &sc->stats.tx_pkts_unaligned, 0,
 		"number of TX unaligned packets");
+
+	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "tx_prod", CTLFLAG_RW, &sc->arge_cdata.arge_tx_prod, 0, "");
+	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "tx_cons", CTLFLAG_RW, &sc->arge_cdata.arge_tx_cons, 0, "");
+	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "tx_cnt", CTLFLAG_RW, &sc->arge_cdata.arge_tx_cnt, 0, "");
 }
 
 static int
@@ -598,7 +611,7 @@ arge_miibus_readreg(device_t dev, int ph
 
 	if (i < 0) {
 		mtx_unlock(&miibus_mtx);
-		dprintf("%s timedout\n", __func__);
+		ARGEDEBUG(sc, ARGE_DBG_MII, "%s timedout\n", __func__);
 		/* XXX: return ERRNO istead? */
 		return (-1);
 	}
@@ -607,7 +620,7 @@ arge_miibus_readreg(device_t dev, int ph
 	ARGE_MII_WRITE(AR71XX_MAC_MII_CMD, MAC_MII_CMD_WRITE);
 	mtx_unlock(&miibus_mtx);
 
-	dprintf("%s: phy=%d, reg=%02x, value[%08x]=%04x\n", __func__, 
+	ARGEDEBUG(sc, ARGE_DBG_MII, "%s: phy=%d, reg=%02x, value[%08x]=%04x\n", __func__, 
 		 phy, reg, addr, result);
 
 	return (result);
@@ -625,7 +638,7 @@ arge_miibus_writereg(device_t dev, int p
 	if ((sc->arge_phymask  & (1 << phy)) == 0)
 		return (-1);
 
-	dprintf("%s: phy=%d, reg=%02x, value=%04x\n", __func__, 
+	ARGEDEBUG(sc, ARGE_DBG_MII, "%s: phy=%d, reg=%02x, value=%04x\n", __func__, 
 	    phy, reg, data);
 
 	mtx_lock(&miibus_mtx);
@@ -640,7 +653,7 @@ arge_miibus_writereg(device_t dev, int p
 	mtx_unlock(&miibus_mtx);
 
 	if (i < 0) {
-		dprintf("%s timedout\n", __func__);
+		ARGEDEBUG(sc, ARGE_DBG_MII, "%s timedout\n", __func__);
 		/* XXX: return ERRNO istead? */
 		return (-1);
 	}
@@ -1730,14 +1743,12 @@ arge_intr_filter(void *arg)
 	status = ARGE_READ(sc, AR71XX_DMA_INTR_STATUS);
 	ints = ARGE_READ(sc, AR71XX_DMA_INTR);
 
-#if 0
-	dprintf("int mask(filter) = %b\n", ints,
+	ARGEDEBUG(sc, ARGE_DBG_INTR, "int mask(filter) = %b\n", ints,
 	    "\20\10RX_BUS_ERROR\7RX_OVERFLOW\5RX_PKT_RCVD"
 	    "\4TX_BUS_ERROR\2TX_UNDERRUN\1TX_PKT_SENT");
-	dprintf("status(filter) = %b\n", status, 
+	ARGEDEBUG(sc, ARGE_DBG_INTR, "status(filter) = %b\n", status, 
 	    "\20\10RX_BUS_ERROR\7RX_OVERFLOW\5RX_PKT_RCVD"
 	    "\4TX_BUS_ERROR\2TX_UNDERRUN\1TX_PKT_SENT");
-#endif
 
 	if (status & DMA_INTR_ALL) {
 		sc->arge_intr_status |= status;
@@ -1758,11 +1769,9 @@ arge_intr(void *arg)
 	status = ARGE_READ(sc, AR71XX_DMA_INTR_STATUS);
 	status |= sc->arge_intr_status;
 
-#if 0
-	dprintf("int status(intr) = %b\n", status, 
+	ARGEDEBUG(sc, ARGE_DBG_INTR, "int status(intr) = %b\n", status, 
 	    "\20\10\7RX_OVERFLOW\5RX_PKT_RCVD"
 	    "\4TX_BUS_ERROR\2TX_UNDERRUN\1TX_PKT_SENT");
-#endif
 
 	/* 
 	 * Is it our interrupt at all? 

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 05:29:11 2011
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 572EB106566B;
	Tue,  5 Apr 2011 05:29:11 +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 2A8A78FC0A;
	Tue,  5 Apr 2011 05:29:11 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p355TBTQ006741;
	Tue, 5 Apr 2011 05:29:11 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p355TBhF006738;
	Tue, 5 Apr 2011 05:29:11 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104050529.p355TBhF006738@svn.freebsd.org>
From: Adrian Chadd 
Date: Tue, 5 Apr 2011 05:29: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: r220355 - in head/sys: conf mips/atheros
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, 05 Apr 2011 05:29:11 -0000

Author: adrian
Date: Tue Apr  5 05:29:10 2011
New Revision: 220355
URL: http://svn.freebsd.org/changeset/base/220355

Log:
  Put the ARGE_DEBUG behind a kernel config option.

Modified:
  head/sys/conf/options.mips
  head/sys/mips/atheros/if_arge.c

Modified: head/sys/conf/options.mips
==============================================================================
--- head/sys/conf/options.mips	Tue Apr  5 05:15:48 2011	(r220354)
+++ head/sys/conf/options.mips	Tue Apr  5 05:29:10 2011	(r220355)
@@ -65,3 +65,8 @@ MAXMEM			opt_global.h
 #
 OCTEON_VENDOR_LANNER		opt_cvmx.h
 OCTEON_BOARD_CAPK_0100ND	opt_cvmx.h
+
+#
+# Options that control the Atheros SoC peripherals
+#
+ARGE_DEBUG			opt_global.h

Modified: head/sys/mips/atheros/if_arge.c
==============================================================================
--- head/sys/mips/atheros/if_arge.c	Tue Apr  5 05:15:48 2011	(r220354)
+++ head/sys/mips/atheros/if_arge.c	Tue Apr  5 05:29:10 2011	(r220355)
@@ -87,7 +87,6 @@ typedef enum {
 	ARGE_DBG_INTR	=	0x00000002
 } arge_debug_flags;
 
-#undef ARGE_DEBUG
 #ifdef ARGE_DEBUG
 #define	ARGEDEBUG(_sc, _m, ...) 					\
 	do {								\
@@ -213,9 +212,11 @@ arge_attach_sysctl(device_t dev)
 	struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(dev);
 	struct sysctl_oid *tree = device_get_sysctl_tree(dev);
 
+#ifdef	ARGE_DEBUG
 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
 		"debug", CTLFLAG_RW, &sc->arge_debug, 0,
 		"arge interface debugging flags");
+#endif
 
 	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
 		"tx_pkts_aligned", CTLFLAG_RW, &sc->stats.tx_pkts_aligned, 0,
@@ -225,9 +226,14 @@ arge_attach_sysctl(device_t dev)
 		"tx_pkts_unaligned", CTLFLAG_RW, &sc->stats.tx_pkts_unaligned, 0,
 		"number of TX unaligned packets");
 
-	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "tx_prod", CTLFLAG_RW, &sc->arge_cdata.arge_tx_prod, 0, "");
-	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "tx_cons", CTLFLAG_RW, &sc->arge_cdata.arge_tx_cons, 0, "");
-	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "tx_cnt", CTLFLAG_RW, &sc->arge_cdata.arge_tx_cnt, 0, "");
+#ifdef	ARGE_DEBUG
+	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "tx_prod",
+	    CTLFLAG_RW, &sc->arge_cdata.arge_tx_prod, 0, "");
+	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "tx_cons",
+	    CTLFLAG_RW, &sc->arge_cdata.arge_tx_cons, 0, "");
+	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "tx_cnt",
+	    CTLFLAG_RW, &sc->arge_cdata.arge_tx_cnt, 0, "");
+#endif
 }
 
 static int

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 06:33:36 2011
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 2945C106564A;
	Tue,  5 Apr 2011 06:33:36 +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 16D998FC12;
	Tue,  5 Apr 2011 06:33:36 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p356XZK7008053;
	Tue, 5 Apr 2011 06:33:35 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p356XZSY008050;
	Tue, 5 Apr 2011 06:33:35 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104050633.p356XZSY008050@svn.freebsd.org>
From: Adrian Chadd 
Date: Tue, 5 Apr 2011 06:33: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: r220356 - head/sys/mips/atheros
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, 05 Apr 2011 06:33:36 -0000

Author: adrian
Date: Tue Apr  5 06:33:35 2011
New Revision: 220356
URL: http://svn.freebsd.org/changeset/base/220356

Log:
  * Add some more debugging to if_arge
  * Make doubly sure that IFF_DRV_OACTIVE is set if the hardware TX queue is full

Modified:
  head/sys/mips/atheros/if_arge.c
  head/sys/mips/atheros/if_argevar.h

Modified: head/sys/mips/atheros/if_arge.c
==============================================================================
--- head/sys/mips/atheros/if_arge.c	Tue Apr  5 05:29:10 2011	(r220355)
+++ head/sys/mips/atheros/if_arge.c	Tue Apr  5 06:33:35 2011	(r220356)
@@ -84,7 +84,11 @@ MODULE_DEPEND(arge, miibus, 1, 1, 1);
 
 typedef enum {
 	ARGE_DBG_MII 	=	0x00000001,
-	ARGE_DBG_INTR	=	0x00000002
+	ARGE_DBG_INTR	=	0x00000002,
+	ARGE_DBG_TX	=	0x00000004,
+	ARGE_DBG_RX	=	0x00000008,
+	ARGE_DBG_ERR	=	0x00000010,
+	ARGE_DBG_RESET	=	0x00000020,
 } arge_debug_flags;
 
 #ifdef ARGE_DEBUG
@@ -985,6 +989,7 @@ arge_encap(struct arge_softc *sc, struct
 	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
 	/* Start transmitting */
+	ARGEDEBUG(sc, ARGE_DBG_TX, "%s: setting DMA_TX_CONTROL_EN\n", __func__);
 	ARGE_WRITE(sc, AR71XX_DMA_TX_CONTROL, DMA_TX_CONTROL_EN);
 	return (0);
 }
@@ -1006,16 +1011,32 @@ arge_start_locked(struct ifnet *ifp)
 {
 	struct arge_softc	*sc;
 	struct mbuf		*m_head;
-	int			enq;
+	int			enq = 0;
 
 	sc = ifp->if_softc;
 
 	ARGE_LOCK_ASSERT(sc);
 
+	ARGEDEBUG(sc, ARGE_DBG_TX, "%s: beginning\n", __func__);
+
 	if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
 	    IFF_DRV_RUNNING || sc->arge_link_status == 0 )
 		return;
 
+	/*
+	 * Before we go any further, check whether we're already full.
+	 * The below check errors out immediately if the ring is full
+	 * and never gets a chance to set this flag. Although it's
+	 * likely never needed, this at least avoids an unexpected
+	 * situation.
+	 */
+	if (sc->arge_cdata.arge_tx_cnt >= ARGE_TX_RING_COUNT - 2) {
+		ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+		ARGEDEBUG(sc, ARGE_DBG_ERR, "%s: tx_cnt %d >= max %d; setting IFF_DRV_OACTIVE\n",
+		    __func__, sc->arge_cdata.arge_tx_cnt, ARGE_TX_RING_COUNT - 2);
+		return;
+	}
+
 	arge_flush_ddr(sc);
 
 	for (enq = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd) &&
@@ -1043,6 +1064,7 @@ arge_start_locked(struct ifnet *ifp)
 		 */
 		ETHER_BPF_MTAP(ifp, m_head);
 	}
+	ARGEDEBUG(sc, ARGE_DBG_TX, "%s: finished; queued %d packets\n", __func__, enq);
 }
 
 static void
@@ -1621,6 +1643,9 @@ arge_tx_locked(struct arge_softc *sc)
 
 	cons = sc->arge_cdata.arge_tx_cons;
 	prod = sc->arge_cdata.arge_tx_prod;
+
+	ARGEDEBUG(sc, ARGE_DBG_TX, "%s: cons=%d, prod=%d\n", __func__, cons, prod);
+
 	if (cons == prod)
 		return;
 
@@ -1771,6 +1796,7 @@ arge_intr(void *arg)
 {
 	struct arge_softc	*sc = arg;
 	uint32_t		status;
+	struct ifnet		*ifp = sc->arge_ifp;
 
 	status = ARGE_READ(sc, AR71XX_DMA_INTR_STATUS);
 	status |= sc->arge_intr_status;
@@ -1809,6 +1835,7 @@ arge_intr(void *arg)
 	if ( status & DMA_INTR_RX_OVERFLOW) {
 		ARGE_WRITE(sc, AR71XX_DMA_RX_STATUS, DMA_RX_STATUS_OVERFLOW);
 		ARGE_WRITE(sc, AR71XX_DMA_RX_CONTROL, DMA_RX_CONTROL_EN);
+		sc->stats.rx_overflow++;
 	}
 
 	if (status & DMA_INTR_TX_PKT_SENT)
@@ -1819,6 +1846,8 @@ arge_intr(void *arg)
 	 */
 	if (status & DMA_INTR_TX_UNDERRUN) {
 		ARGE_WRITE(sc, AR71XX_DMA_TX_STATUS, DMA_TX_STATUS_UNDERRUN);
+		sc->stats.tx_underflow++;
+		ARGEDEBUG(sc, ARGE_DBG_TX, "%s: TX underrun; tx_cnt=%d\n", __func__, sc->arge_cdata.arge_tx_cnt);
 		if (sc->arge_cdata.arge_tx_cnt > 0 ) {
 			ARGE_WRITE(sc, AR71XX_DMA_TX_CONTROL, 
 			    DMA_TX_CONTROL_EN);

Modified: head/sys/mips/atheros/if_argevar.h
==============================================================================
--- head/sys/mips/atheros/if_argevar.h	Tue Apr  5 05:29:10 2011	(r220355)
+++ head/sys/mips/atheros/if_argevar.h	Tue Apr  5 06:33:35 2011	(r220356)
@@ -154,6 +154,8 @@ struct arge_softc {
 	struct {
 		uint32_t	tx_pkts_unaligned;
 		uint32_t	tx_pkts_aligned;
+		uint32_t	rx_overflow;
+		uint32_t	tx_underflow;
 	} stats;
 };
 

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 06:46:08 2011
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 51B90106564A;
	Tue,  5 Apr 2011 06:46:08 +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 3F6D08FC12;
	Tue,  5 Apr 2011 06:46:08 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p356k88R008409;
	Tue, 5 Apr 2011 06:46:08 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p356k8Oh008407;
	Tue, 5 Apr 2011 06:46:08 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104050646.p356k8Oh008407@svn.freebsd.org>
From: Adrian Chadd 
Date: Tue, 5 Apr 2011 06:46: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: r220357 - head/sys/mips/atheros
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, 05 Apr 2011 06:46:08 -0000

Author: adrian
Date: Tue Apr  5 06:46:07 2011
New Revision: 220357
URL: http://svn.freebsd.org/changeset/base/220357

Log:
  if_arge has had a strange bug that only appears during high traffic
  levels. TX would hang, RX wouldn't. A bit of digging showed the interface
  send queue was full, but IFF_DRV_OACTIVE was clear and the hardware TX
  queue was empty.
  
  It turns out that there wasn't a check to drain the interface send
  queue once hardware TX had completed, so if the interface send queue
  had filled up in the meantime, subsequent packets would be dropped
  by the higher layers and if_start (and thus arge_start()) would never
  be called.
  
  The fix is simple - call arge_start_locked() in the software interrupt
  handler after the hardware TX queue has been handled or a TX underrun
  occured. This way the interface send queue gets drained.

Modified:
  head/sys/mips/atheros/if_arge.c

Modified: head/sys/mips/atheros/if_arge.c
==============================================================================
--- head/sys/mips/atheros/if_arge.c	Tue Apr  5 06:33:35 2011	(r220356)
+++ head/sys/mips/atheros/if_arge.c	Tue Apr  5 06:46:07 2011	(r220357)
@@ -1855,6 +1855,27 @@ arge_intr(void *arg)
 	}
 
 	/*
+	 * If we've finished TXing and there's space for more packets
+	 * to be queued for TX, do so. Otherwise we may end up in a
+	 * situation where the interface send queue was filled
+	 * whilst the hardware queue was full, then the hardware
+	 * queue was drained by the interface send queue wasn't,
+	 * and thus if_start() is never called to kick-start
+	 * the send process (and all subsequent packets are simply
+	 * discarded.
+	 *
+	 * XXX TODO: make sure that the hardware deals nicely
+	 * with the possibility of the queue being enabled above
+	 * after a TX underrun, then having the hardware queue added
+	 * to below.
+	 */
+	if (status & (DMA_INTR_TX_PKT_SENT | DMA_INTR_TX_UNDERRUN) &&
+	    (ifp->if_drv_flags & IFF_DRV_OACTIVE) == 0) {
+		if (!IFQ_IS_EMPTY(&ifp->if_snd))
+			arge_start_locked(ifp);
+	}
+
+	/*
 	 * We handled all bits, clear status
 	 */
 	sc->arge_intr_status = 0;

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 07:56:41 2011
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 32C5F1065675;
	Tue,  5 Apr 2011 07:56:41 +0000 (UTC)
	(envelope-from pluknet@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 20A178FC0A;
	Tue,  5 Apr 2011 07:56:41 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p357ufN0009875;
	Tue, 5 Apr 2011 07:56:41 GMT (envelope-from pluknet@svn.freebsd.org)
Received: (from pluknet@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p357ufB0009873;
	Tue, 5 Apr 2011 07:56:41 GMT (envelope-from pluknet@svn.freebsd.org)
Message-Id: <201104050756.p357ufB0009873@svn.freebsd.org>
From: Sergey Kandaurov 
Date: Tue, 5 Apr 2011 07:56: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: r220358 - head/usr.bin/limits
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, 05 Apr 2011 07:56:41 -0000

Author: pluknet
Date: Tue Apr  5 07:56:40 2011
New Revision: 220358
URL: http://svn.freebsd.org/changeset/base/220358

Log:
  Document -w for swapuse.
  
  PR:		docs/156089
  Submitted by:	Andrey Ignatov 
  MFC after:	1 week

Modified:
  head/usr.bin/limits/limits.1

Modified: head/usr.bin/limits/limits.1
==============================================================================
--- head/usr.bin/limits/limits.1	Tue Apr  5 06:46:07 2011	(r220357)
+++ head/usr.bin/limits/limits.1	Tue Apr  5 07:56:40 2011	(r220358)
@@ -19,7 +19,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 18, 2002
+.Dd April 5, 2011
 .Dt LIMITS 1
 .Os
 .Sh NAME
@@ -30,11 +30,11 @@
 .Op Fl C Ar class | Fl U Ar user
 .Op Fl SHB
 .Op Fl ea
-.Op Fl bcdflmnstuvp Op Ar val
+.Op Fl bcdflmnstuvpw Op Ar val
 .Nm
 .Op Fl C Ar class | Fl U Ar user
 .Op Fl SHB
-.Op Fl bcdflmnstuvp Op Ar val
+.Op Fl bcdflmnstuvpw Op Ar val
 .Op Fl E
 .Oo
 .Op Ar name Ns = Ns Ar value ...
@@ -266,6 +266,10 @@ space.
 Select or set the
 .Va pseudoterminals
 resource limit.
+.It Fl w Op Ar val
+Select or set the
+.Va swapuse
+resource limit.
 .El
 .Pp
 Valid values for

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 08:49:48 2011
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 58E31106564A;
	Tue,  5 Apr 2011 08:49:48 +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 468D48FC13;
	Tue,  5 Apr 2011 08:49:48 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p358nmZ0011084;
	Tue, 5 Apr 2011 08:49:48 GMT (envelope-from imp@svn.freebsd.org)
Received: (from imp@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p358nmes011081;
	Tue, 5 Apr 2011 08:49:48 GMT (envelope-from imp@svn.freebsd.org)
Message-Id: <201104050849.p358nmes011081@svn.freebsd.org>
From: Warner Losh 
Date: Tue, 5 Apr 2011 08:49: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: r220359 - in head: . share/mk
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, 05 Apr 2011 08:49:48 -0000

Author: imp
Date: Tue Apr  5 08:49:47 2011
New Revision: 220359
URL: http://svn.freebsd.org/changeset/base/220359

Log:
  Make clang default on x86 and powerpc, but not on other architectures.
  Make fdt default on arm and powerpc.
  
  This now includes cross compiled targets, where before we tried to
  make it host-based.
  
  Also, move the lists of default yes and no options to a variable.
  
  In general, only build tools should get this treatment in bsd.own.mk.
  Also, the use of TARGET* in the bsd.*mk files is discouraged, but
  necessary here due to the ordering of things in buildworld.  We make
  the native case work by testing MACHINE_ARCH after TARGET_ARCH.

Modified:
  head/Makefile.inc1
  head/share/mk/bsd.own.mk

Modified: head/Makefile.inc1
==============================================================================
--- head/Makefile.inc1	Tue Apr  5 07:56:40 2011	(r220358)
+++ head/Makefile.inc1	Tue Apr  5 08:49:47 2011	(r220359)
@@ -1019,11 +1019,11 @@ _gensnmptree=	usr.sbin/bsnmpd/gensnmptre
 _crunchgen=	usr.sbin/crunch/crunchgen
 .endif
 
-# XXX: There is no way to specify bootstrap tools depending on MK-flags
-# with different per-architecture default values. Always build tblgen.
+.if ${MK_CLANG} != "no"
 _clang_tblgen= \
 	lib/clang/libllvmsupport \
 	usr.bin/clang/tblgen
+.endif
 
 .if ${MK_CDDL} != "no"
 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \

Modified: head/share/mk/bsd.own.mk
==============================================================================
--- head/share/mk/bsd.own.mk	Tue Apr  5 07:56:40 2011	(r220358)
+++ head/share/mk/bsd.own.mk	Tue Apr  5 08:49:47 2011	(r220359)
@@ -281,22 +281,7 @@ WITH_HESIOD=
 WITH_IDEA=
 .endif
 
-#
-# Default behaviour of MK_CLANG depends on the architecture.
-#
-.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" || \
-    ${MACHINE_ARCH} == "powerpc"
-_clang_yes=CLANG
-_clang_no=
-.else
-_clang_yes=
-_clang_no=CLANG
-.endif
-
-#
-# MK_* options which default to "yes".
-#
-.for var in \
+__DEFAULT_YES_OPTIONS = \
     ACCT \
     ACPI \
     AMD \
@@ -321,7 +306,6 @@ _clang_no=CLANG
     BZIP2 \
     CALENDAR \
     CDDL \
-    ${_clang_yes} \
     CPP \
     CRYPT \
     CTM \
@@ -330,7 +314,6 @@ _clang_no=CLANG
     DICT \
     DYNAMICROOT \
     EXAMPLES \
-    FDT \
     FLOPPY \
     FORTH \
     FP_LIBC \
@@ -341,6 +324,7 @@ _clang_no=CLANG
     GDB \
     GNU \
     GPIB \
+    GPIO \
     GROFF \
     HTML \
     INET6 \
@@ -403,6 +387,51 @@ _clang_no=CLANG
     WPA_SUPPLICANT_EAPOL \
     ZFS \
     ZONEINFO
+
+__DEFAULT_NO_OPTIONS = \
+    BSD_GREP \
+    BIND_IDN \
+    BIND_LARGE_FILE \
+    BIND_LIBS \
+    BIND_SIGCHASE \
+    BIND_XML \
+    GNU_CPIO \
+    HESIOD \
+    ICONV \
+    IDEA \
+    OFED
+
+#
+# Default behaviour of some options depends on the architecture.  Unfortunately
+# this means that we have to test TARGET_ARCH (the buildworld case) as well
+# as MACHINE_ARCH (the non-buildworld case).  Normally TARGET_ARCH is not
+# used at all in bsd.*.mk, but we have to make an exception here if we want
+# to allow defaults for some things like clang and ftd to vary by target
+# architecture.
+#
+.if defined(TARGET_ARCH)
+__T=${TARGET_ARCH}
+.else
+__T=${MACHINE_ARCH}
+.endif
+# Clang is only for x86 and 32-bit powerpc right now, by default.
+.if ${__T} == "amd64" || ${__T} == "i386" || ${__T} == "powerpc"
+__DEFAULT_YES_OPTIONS+=CLANG
+.else
+__DEFAULT_NO_OPTIONS+=CLANG
+.endif
+# FDT is needed only for arm and powerpc (and not powerpc64)
+.if ${__T} == "arm" || ${__T} == "armeb" || ${__T} == "powerpc"
+__DEFAULT_YES_OPTIONS+=FDT
+.else
+__DEFAULT_NO_OPTIONS+=FDT
+.endif
+.undef __T
+
+#
+# MK_* options which default to "yes".
+#
+.for var in ${__DEFAULT_YES_OPTIONS}
 .if defined(WITH_${var}) && defined(WITHOUT_${var})
 .error WITH_${var} and WITHOUT_${var} can't both be set.
 .endif
@@ -415,23 +444,12 @@ MK_${var}:=	no
 MK_${var}:=	yes
 .endif
 .endfor
+.undef __DEFAULT_YES_OPTIONS
 
 #
 # MK_* options which default to "no".
 #
-.for var in \
-    BIND_IDN \
-    BIND_LARGE_FILE \
-    BIND_LIBS \
-    BIND_SIGCHASE \
-    BIND_XML \
-    BSD_GREP \
-    ${_clang_no} \
-    GPIO \
-    HESIOD \
-    ICONV \
-    IDEA \
-    OFED
+.for var in ${__DEFAULT_NO_OPTIONS}
 .if defined(WITH_${var}) && defined(WITHOUT_${var})
 .error WITH_${var} and WITHOUT_${var} can't both be set.
 .endif
@@ -444,6 +462,7 @@ MK_${var}:=	yes
 MK_${var}:=	no
 .endif
 .endfor
+.undef __DEFAULT_NO_OPTIONS
 
 #
 # Force some options off if their dependencies are off.

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 13:14:18 2011
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 455D5106566B;
	Tue,  5 Apr 2011 13:14:18 +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 351188FC14;
	Tue,  5 Apr 2011 13:14:18 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35DEIQh019176;
	Tue, 5 Apr 2011 13:14:18 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35DEINg019174;
	Tue, 5 Apr 2011 13:14:18 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104051314.p35DEINg019174@svn.freebsd.org>
From: Adrian Chadd 
Date: Tue, 5 Apr 2011 13:14:18 +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: r220360 - head/sys/dev/ath/ath_hal
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, 05 Apr 2011 13:14:18 -0000

Author: adrian
Date: Tue Apr  5 13:14:17 2011
New Revision: 220360
URL: http://svn.freebsd.org/changeset/base/220360

Log:
  The xpaBiasLvlFreq[] fields in the modal header also need swapping
  when the EEPROM contents are byte-swapped.

Modified:
  head/sys/dev/ath/ath_hal/ah_eeprom_v14.c

Modified: head/sys/dev/ath/ath_hal/ah_eeprom_v14.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_eeprom_v14.c	Tue Apr  5 08:49:47 2011	(r220359)
+++ head/sys/dev/ath/ath_hal/ah_eeprom_v14.c	Tue Apr  5 13:14:17 2011	(r220360)
@@ -224,7 +224,10 @@ eepromSwap(struct ar5416eeprom *ee)
 			integer = __bswap32(pModal->antCtrlChain[i]);
 			pModal->antCtrlChain[i] = integer;
 		}
-
+		for (i = 0; i < 3; i++) {
+			word = __bswap16(pModal->xpaBiasLvlFreq[i]);
+			pModal->xpaBiasLvlFreq[i] = word;
+		}
 		for (i = 0; i < AR5416_EEPROM_MODAL_SPURS; i++) {
 			word = __bswap16(pModal->spurChans[i].spurChan);
 			pModal->spurChans[i].spurChan = word;

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 13:48:53 2011
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 5932D106566B;
	Tue,  5 Apr 2011 13:48:53 +0000 (UTC)
	(envelope-from nyan@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 494838FC0A;
	Tue,  5 Apr 2011 13:48:53 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35Dmri5019959;
	Tue, 5 Apr 2011 13:48:53 GMT (envelope-from nyan@svn.freebsd.org)
Received: (from nyan@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35DmrI1019957;
	Tue, 5 Apr 2011 13:48:53 GMT (envelope-from nyan@svn.freebsd.org)
Message-Id: <201104051348.p35DmrI1019957@svn.freebsd.org>
From: Takahashi Yoshihiro 
Date: Tue, 5 Apr 2011 13:48: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: r220361 - head/sys/boot/pc98/boot2
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, 05 Apr 2011 13:48:53 -0000

Author: nyan
Date: Tue Apr  5 13:48:53 2011
New Revision: 220361
URL: http://svn.freebsd.org/changeset/base/220361

Log:
  MFi386: revision 220337
  
    Build boot2 with -mregparm=3.

Modified:
  head/sys/boot/pc98/boot2/Makefile

Modified: head/sys/boot/pc98/boot2/Makefile
==============================================================================
--- head/sys/boot/pc98/boot2/Makefile	Tue Apr  5 13:14:17 2011	(r220360)
+++ head/sys/boot/pc98/boot2/Makefile	Tue Apr  5 13:48:53 2011	(r220361)
@@ -28,6 +28,7 @@ CFLAGS=	-Os \
 	-fno-unit-at-a-time \
 	-mno-align-long-strings \
 	-mrtd \
+	-mregparm=3 \
 	-D${BOOT2_UFS} \
 	-DFLAGS=${BOOT_BOOT1_FLAGS} \
 	-DSIOPRT=${BOOT_COMCONSOLE_PORT} \

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 14:15:58 2011
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 AE30E106564A;
	Tue,  5 Apr 2011 14:15:58 +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 846768FC19;
	Tue,  5 Apr 2011 14:15:58 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35EFwHP020587;
	Tue, 5 Apr 2011 14:15:58 GMT (envelope-from attilio@svn.freebsd.org)
Received: (from attilio@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35EFw4V020585;
	Tue, 5 Apr 2011 14:15:58 GMT (envelope-from attilio@svn.freebsd.org)
Message-Id: <201104051415.p35EFw4V020585@svn.freebsd.org>
From: Attilio Rao 
Date: Tue, 5 Apr 2011 14:15:58 +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: r220362 - head/sys/ddb
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, 05 Apr 2011 14:15:58 -0000

Author: attilio
Date: Tue Apr  5 14:15:58 2011
New Revision: 220362
URL: http://svn.freebsd.org/changeset/base/220362

Log:
  Extend the DDB command "watchdog" with the ability to specify a timeout
  value.
  
  The timeout is expressed in the form T(N) = (2^N * nanoseconds) and can
  be easilly extracted from the watchdog interface as a WD_TO_* macro.
  That new functionality is supposed to fix re-entering the kernel from DDB
  re-enabling the watchdog again (previously disabled) and also offer the
  possibility to break for deadlocked DDB commands.
  
  Please note that retro-compatibility is retained.
  
  Sponsored by:	Sandvine Incorporated
  Approved by:	des
  MFC after:	10 days

Modified:
  head/sys/ddb/db_command.c

Modified: head/sys/ddb/db_command.c
==============================================================================
--- head/sys/ddb/db_command.c	Tue Apr  5 13:48:53 2011	(r220361)
+++ head/sys/ddb/db_command.c	Tue Apr  5 14:15:58 2011	(r220362)
@@ -129,7 +129,7 @@ static struct command db_cmds[] = {
 	{ "reboot",	db_reset,		0,	0 },
 	{ "reset",	db_reset,		0,	0 },
 	{ "kill",	db_kill,		CS_OWN,	0 },
-	{ "watchdog",	db_watchdog,		0,	0 },
+	{ "watchdog",	db_watchdog,		CS_OWN,	0 },
 	{ "thread",	db_set_thread,		CS_OWN,	0 },
 	{ "run",	db_run_cmd,		CS_OWN,	0 },
 	{ "script",	db_script_cmd,		CS_OWN,	0 },
@@ -708,15 +708,32 @@ db_watchdog(dummy1, dummy2, dummy3, dumm
 	db_expr_t	dummy3;
 	char *		dummy4;
 {
-	int i;
+	db_expr_t old_radix, tout;
+	int err, i;
 
-	/*
-	 * XXX: It might make sense to be able to set the watchdog to a
-	 * XXX: timeout here so that failure or hang as a result of subsequent
-	 * XXX: ddb commands could be recovered by a reset.
-	 */
+	old_radix = db_radix;
+	db_radix = 10;
+	err = db_expression(&tout);
+	db_skip_to_eol();
+	db_radix = old_radix;
 
-	EVENTHANDLER_INVOKE(watchdog_list, 0, &i);
+	/* If no argument is provided the watchdog will just be disabled. */
+	if (err == 0) {
+		db_printf("No argument provided, disabling watchdog\n");
+		tout = 0;
+	} else if ((tout & WD_INTERVAL) == WD_TO_NEVER) {
+		db_error("Out of range watchdog interval\n");
+		return;
+	} else {
+
+		/*
+		 * XXX: Right now we only support WD_ACTIVE, in the future we
+		 * may be possibly needing a more convoluted function for
+		 * dealing with different cases.
+		 */
+		tout |= WD_ACTIVE;
+	}
+	EVENTHANDLER_INVOKE(watchdog_list, tout, &i);
 }
 
 static void

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 14:19:05 2011
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 5B3E1106566C;
	Tue,  5 Apr 2011 14:19:05 +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 4B7828FC18;
	Tue,  5 Apr 2011 14:19:05 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35EJ5Qs020683;
	Tue, 5 Apr 2011 14:19:05 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35EJ5i1020680;
	Tue, 5 Apr 2011 14:19:05 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201104051419.p35EJ5i1020680@svn.freebsd.org>
From: John Baldwin 
Date: Tue, 5 Apr 2011 14:19:05 +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: r220363 - 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, 05 Apr 2011 14:19:05 -0000

Author: jhb
Date: Tue Apr  5 14:19:05 2011
New Revision: 220363
URL: http://svn.freebsd.org/changeset/base/220363

Log:
  Add the ability to manage the state of write caching when the battery
  back-up is missing or dead.  The current state of this field is reported
  in 'mfiutil cache ' and can be adjusted via
  'mfiutil cache  bad-bbu-write-cache '.  This
  setting should generally be disabled to avoid data loss.
  
  MFC after:	1 week

Modified:
  head/usr.sbin/mfiutil/mfi_volume.c
  head/usr.sbin/mfiutil/mfiutil.8

Modified: head/usr.sbin/mfiutil/mfi_volume.c
==============================================================================
--- head/usr.sbin/mfiutil/mfi_volume.c	Tue Apr  5 14:15:58 2011	(r220362)
+++ head/usr.sbin/mfiutil/mfi_volume.c	Tue Apr  5 14:19:05 2011	(r220363)
@@ -138,6 +138,10 @@ update_cache_policy(int fd, struct mfi_l
 		    policy & MR_LD_CACHE_READ_AHEAD ?
 		    (policy & MR_LD_CACHE_READ_ADAPTIVE ?
 		    "adaptive" : "always") : "none");
+	if (changes & MR_LD_CACHE_WRITE_CACHE_BAD_BBU)
+		printf("%s write caching with bad BBU\n",
+		    policy & MR_LD_CACHE_WRITE_CACHE_BAD_BBU ? "Enabling" :
+		    "Disabling");
 
 	props->default_cache_policy = policy;
 	if (mfi_ld_set_props(fd, props) < 0) {
@@ -182,7 +186,7 @@ volume_cache(int ac, char **av)
 	if (ac == 2) {
 		printf("mfi%u volume %s cache settings:\n", mfi_unit,
 		    mfi_volume_name(fd, target_id));
-		printf("      I/O caching: ");
+		printf("             I/O caching: ");
 		switch (props.default_cache_policy &
 		    (MR_LD_CACHE_ALLOW_WRITE_CACHE |
 		    MR_LD_CACHE_ALLOW_READ_CACHE)) {
@@ -200,14 +204,17 @@ volume_cache(int ac, char **av)
 			printf("writes and reads\n");
 			break;
 		}
-		printf("    write caching: %s\n",
+		printf("           write caching: %s\n",
 		    props.default_cache_policy & MR_LD_CACHE_WRITE_BACK ?
 		    "write-back" : "write-through");
-		printf("       read ahead: %s\n",
+		printf("write cache with bad BBU: %s\n",
+		    props.default_cache_policy &
+		    MR_LD_CACHE_WRITE_CACHE_BAD_BBU ? "enabled" : "disabled");
+		printf("              read ahead: %s\n",
 		    props.default_cache_policy & MR_LD_CACHE_READ_AHEAD ?
 		    (props.default_cache_policy & MR_LD_CACHE_READ_ADAPTIVE ?
 		    "adaptive" : "always") : "none");
-		printf("drive write cache: ");
+		printf("       drive write cache: ");
 		switch (props.disk_cache_policy) {
 		case MR_PD_CACHE_UNCHANGED:
 			printf("default\n");
@@ -273,6 +280,21 @@ volume_cache(int ac, char **av)
 			error = update_cache_policy(fd, &props, policy,
 			    MR_LD_CACHE_READ_AHEAD |
 			    MR_LD_CACHE_READ_ADAPTIVE);
+		} else if (strcmp(av[2], "bad-bbu-write-cache") == 0) {
+			if (ac < 4) {
+				warnx("cache: bad BBU setting required");
+				return (EINVAL);
+			}
+			if (strcmp(av[3], "enable") == 0)
+				policy = MR_LD_CACHE_WRITE_CACHE_BAD_BBU;
+			else if (strcmp(av[3], "disable") == 0)
+				policy = 0;
+			else {
+				warnx("cache: invalid bad BBU setting");
+				return (EINVAL);
+			}
+			error = update_cache_policy(fd, &props, policy,
+			    MR_LD_CACHE_WRITE_CACHE_BAD_BBU);
 		} else if (strcmp(av[2], "write-cache") == 0) {
 			if (ac < 4) {
 				warnx("cache: write-cache setting required");

Modified: head/usr.sbin/mfiutil/mfiutil.8
==============================================================================
--- head/usr.sbin/mfiutil/mfiutil.8	Tue Apr  5 14:15:58 2011	(r220362)
+++ head/usr.sbin/mfiutil/mfiutil.8	Tue Apr  5 14:19:05 2011	(r220363)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 16, 2009
+.Dd April 5, 2011
 .Dt MFIUTIL 8
 .Os
 .Sh NAME
@@ -367,7 +367,7 @@ Enable caching only for write I/O operat
 Use write-back policy for cached writes.
 .It Cm write-through
 Use write-through policy for cached writes.
-.It Cm read-ahead Op Ar value
+.It Cm read-ahead Ar value
 Set the read ahead policy for cached reads.
 The
 .Ar value
@@ -376,7 +376,18 @@ argument can be set to either
 .Dq adaptive ,
 or
 .Dq always .
-.It Cm write-cache Op Ar value
+.It Cm bad-bbu-write-cache Ar value
+Control the behavior of I/O write caching if the battery is dead or
+missing.
+The
+.Ar value
+argument can be set to either
+.Dq disable
+or
+.Dq enable .
+In general this setting should be left disabled to avoid data loss when
+the system loses power.
+.It Cm write-cache Ar value
 Control the write caches on the physical drives backing
 .Ar volume .
 The

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 15:11:09 2011
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 D953C1065672;
	Tue,  5 Apr 2011 15:11:09 +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 C90708FC0C;
	Tue,  5 Apr 2011 15:11:09 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35FB97F021901;
	Tue, 5 Apr 2011 15:11:09 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35FB9RB021897;
	Tue, 5 Apr 2011 15:11:09 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104051511.p35FB9RB021897@svn.freebsd.org>
From: Adrian Chadd 
Date: Tue, 5 Apr 2011 15:11: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: r220364 - in head/tools/tools/ath: . arcode
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, 05 Apr 2011 15:11:09 -0000

Author: adrian
Date: Tue Apr  5 15:11:09 2011
New Revision: 220364
URL: http://svn.freebsd.org/changeset/base/220364

Log:
  Flesh out a simple tool to print the ALQ dump generated by the HAL.

Added:
  head/tools/tools/ath/arcode/
  head/tools/tools/ath/arcode/Makefile   (contents, props changed)
  head/tools/tools/ath/arcode/arcode.c   (contents, props changed)
Modified:
  head/tools/tools/ath/Makefile

Modified: head/tools/tools/ath/Makefile
==============================================================================
--- head/tools/tools/ath/Makefile	Tue Apr  5 14:19:05 2011	(r220363)
+++ head/tools/tools/ath/Makefile	Tue Apr  5 15:11:09 2011	(r220364)
@@ -1,5 +1,6 @@
 #	$FreeBSD$
 
-SUBDIR=	athdebug athdecode athkey athpoke athprom athrd athregs athstats ath_ee_v14_print ath_prom_read ath_ee_v4k_print
+SUBDIR=	arcode athdebug athdecode athkey athpoke athprom athrd athregs
+SUBDIR+=	athstats ath_ee_v14_print ath_prom_read ath_ee_v4k_print
 
 .include 

Added: head/tools/tools/ath/arcode/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/tools/ath/arcode/Makefile	Tue Apr  5 15:11:09 2011	(r220364)
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+PROG=	arcode
+NOMAN=	yes
+
+.include <../Makefile.inc>
+
+.include 

Added: head/tools/tools/ath/arcode/arcode.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/tools/ath/arcode/arcode.c	Tue Apr  5 15:11:09 2011	(r220364)
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2011 Adrian Chadd, Xenion Pty Ltd.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "ah_decode.h"
+
+#define	MAX_MARKERS	9
+
+const char *markers[] = {  
+        "AH_MARK_RESET",                  /* ar*Reset entry, bChannelChange */
+        "AH_MARK_RESET_LINE",             /* ar*_reset.c, line %d */
+        "AH_MARK_RESET_DONE",             /* ar*Reset exit, error code */
+        "AH_MARK_CHIPRESET",              /* ar*ChipReset, channel num */
+        "AH_MARK_PERCAL",                 /* ar*PerCalibration, channel num */
+        "AH_MARK_SETCHANNEL",             /* ar*SetChannel, channel num */
+        "AH_MARK_ANI_RESET",              /* ar*AniReset, opmode */
+        "AH_MARK_ANI_POLL",               /* ar*AniReset, listen time */
+        "AH_MARK_ANI_CONTROL",            /* ar*AniReset, cmd */
+};
+
+static void
+op_read(struct athregrec *a)
+{
+        printf("read\t%.8x = %.8x\n", a->reg, a->val);
+}
+
+static void
+op_write(struct athregrec *a)
+{
+        printf("write\t%.8x = %.8x\n", a->reg, a->val);
+}
+
+static void
+op_device(struct athregrec *a)
+{
+        printf("device\t0x%x/0x%x\n", a->reg, a->val);
+}
+
+static void
+op_mark(struct athregrec *a)
+{
+        const char *s = "UNKNOWN";
+#if 0
+        if (a->reg <= MAX_MARKERS)
+                s = markers[a->reg];
+#endif
+
+	printf("mark\t%d (%d): %d\n", s, a->reg, a->val);
+}
+
+int
+main(int argc, const char *argv[])
+{
+	const char *file = argv[1];
+	int fd;
+	struct athregrec a;
+	int r;
+
+	if (argc < 1) {
+		printf("usage: %s \n", argv[0]);
+		exit(127);
+	}
+
+	fd = open(file, O_RDONLY);
+	if (fd < 0) {
+		perror("open"); 
+		exit(127);
+	}
+
+	while (1) {
+		r = read(fd, &a, sizeof(a));
+		if (r != sizeof(a))
+			break;
+		switch (a.op) {
+			case OP_READ:
+				op_read(&a);
+				break;
+			case OP_WRITE:
+				op_write(&a);
+				break;
+			case OP_DEVICE:
+				op_device(&a);
+				break;
+			case OP_MARK:
+				op_mark(&a);
+				break;
+			default:
+				printf("op: %s; reg: %x; val: %x\n",
+				    a.op, a.reg, a.val);
+		}
+	}
+	close(fd);
+}

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 16:12:38 2011
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 C457C1065670;
	Tue,  5 Apr 2011 16:12:38 +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 B482C8FC12;
	Tue,  5 Apr 2011 16:12:38 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35GCcG6023477;
	Tue, 5 Apr 2011 16:12:38 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35GCcS5023475;
	Tue, 5 Apr 2011 16:12:38 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104051612.p35GCcS5023475@svn.freebsd.org>
From: Adrian Chadd 
Date: Tue, 5 Apr 2011 16:12: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: r220366 - head/tools/tools/ath/arcode
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, 05 Apr 2011 16:12:38 -0000

Author: adrian
Date: Tue Apr  5 16:12:38 2011
New Revision: 220366
URL: http://svn.freebsd.org/changeset/base/220366

Log:
  * re-enable marker stuff, I accidentally disabled it during debugging
  * correct arg check

Modified:
  head/tools/tools/ath/arcode/arcode.c

Modified: head/tools/tools/ath/arcode/arcode.c
==============================================================================
--- head/tools/tools/ath/arcode/arcode.c	Tue Apr  5 15:33:12 2011	(r220365)
+++ head/tools/tools/ath/arcode/arcode.c	Tue Apr  5 16:12:38 2011	(r220366)
@@ -63,12 +63,10 @@ static void
 op_mark(struct athregrec *a)
 {
         const char *s = "UNKNOWN";
-#if 0
         if (a->reg <= MAX_MARKERS)
                 s = markers[a->reg];
-#endif
 
-	printf("mark\t%d (%d): %d\n", s, a->reg, a->val);
+	printf("mark\t%s (%d): %d\n", s, a->reg, a->val);
 }
 
 int
@@ -79,7 +77,7 @@ main(int argc, const char *argv[])
 	struct athregrec a;
 	int r;
 
-	if (argc < 1) {
+	if (argc < 2) {
 		printf("usage: %s \n", argv[0]);
 		exit(127);
 	}

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 16:14:55 2011
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 2F077106564A;
	Tue,  5 Apr 2011 16:14:55 +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 1F6CE8FC20;
	Tue,  5 Apr 2011 16:14:55 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35GEtri023563;
	Tue, 5 Apr 2011 16:14:55 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35GEton023561;
	Tue, 5 Apr 2011 16:14:55 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104051614.p35GEton023561@svn.freebsd.org>
From: Adrian Chadd 
Date: Tue, 5 Apr 2011 16:14:54 +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: r220367 - 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: Tue, 05 Apr 2011 16:14:55 -0000

Author: adrian
Date: Tue Apr  5 16:14:54 2011
New Revision: 220367
URL: http://svn.freebsd.org/changeset/base/220367

Log:
  Make the alq log path tunable

Modified:
  head/sys/dev/ath/ah_osdep.c

Modified: head/sys/dev/ath/ah_osdep.c
==============================================================================
--- head/sys/dev/ath/ah_osdep.c	Tue Apr  5 16:12:38 2011	(r220366)
+++ head/sys/dev/ath/ah_osdep.c	Tue Apr  5 16:14:54 2011	(r220367)
@@ -173,7 +173,11 @@ DO_HALDEBUG(struct ath_hal *ah, u_int ma
 static	struct alq *ath_hal_alq;
 static	int ath_hal_alq_emitdev;	/* need to emit DEVICE record */
 static	u_int ath_hal_alq_lost;		/* count of lost records */
-static	const char *ath_hal_logfile = "/tmp/ath_hal.log";
+static	char ath_hal_logfile[MAXPATHLEN] = "/tmp/ath_hal.log";
+
+SYSCTL_STRING(_hw_ath_hal, OID_AUTO, alq_logfile, CTLFLAG_RW,
+    &ath_hal_logfile, sizeof(kernelname), "Name of ALQ logfile");
+
 static	u_int ath_hal_alq_qsize = 64*1024;
 
 static int

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 17:41:54 2011
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 C9C0E106566B;
	Tue,  5 Apr 2011 17:41:54 +0000 (UTC)
	(envelope-from yongari@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id AD17E8FC18;
	Tue,  5 Apr 2011 17:41:54 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35HfsqE025659;
	Tue, 5 Apr 2011 17:41:54 GMT (envelope-from yongari@svn.freebsd.org)
Received: (from yongari@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35HfsKf025656;
	Tue, 5 Apr 2011 17:41:54 GMT (envelope-from yongari@svn.freebsd.org)
Message-Id: <201104051741.p35HfsKf025656@svn.freebsd.org>
From: Pyun YongHyeon 
Date: Tue, 5 Apr 2011 17:41:54 +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: r220368 - head/sys/dev/bge
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, 05 Apr 2011 17:41:54 -0000

Author: yongari
Date: Tue Apr  5 17:41:54 2011
New Revision: 220368
URL: http://svn.freebsd.org/changeset/base/220368

Log:
  Add initial jumbo frame support for BCM5714/BCM5715 and BCM5780.
  Unlike other controllers which have more advanced jumbo support,
  these controllers have one send ring, one standard receive producer
  ring and one receive return ring. In order to receive jumbo frames
  on the controllers, driver now will increase Rx buffer size to 9k.
  Two Rx modes are supported on these controllers and I chose
  standard Rx BDs over extended Rx BDs. The extended Rx BD mode
  allows up to 4 segmentations for each Rx BDs such that kernel does
  not have to allocate large buffer of contiguous memory for
  receiving. The extended Rx BD mode is already used on controllers
  that have separate jumbo receive ring. However, using extended Rx
  BDs on BCM5714/BCM5715/BCM5780 reduces the number of Rx BDs to 256
  entries which in turn may reduce the performance.  Also UMA backed
  page allocator for jumbo frame returns contiguous memory so using
  extended Rx BD has no advantage on FreeBSD unless highly customized
  local allocator implemented in driver is used.
  To use jumbo buffers in standard receive ring, Rx buffer allocation
  handler was changed to allocate MJUM9BYTES sized mbuf.
  
  PR:		kern/155192
  Tested by:	Vijay Singh  gmail dot com>
  Submitted by:	mjacob (initial version)

Modified:
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bge.c
==============================================================================
--- head/sys/dev/bge/if_bge.c	Tue Apr  5 16:14:54 2011	(r220367)
+++ head/sys/dev/bge/if_bge.c	Tue Apr  5 17:41:54 2011	(r220368)
@@ -943,10 +943,19 @@ bge_newbuf_std(struct bge_softc *sc, int
 	bus_dmamap_t map;
 	int error, nsegs;
 
-	m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
-	if (m == NULL)
-		return (ENOBUFS);
-	m->m_len = m->m_pkthdr.len = MCLBYTES;
+	if (sc->bge_flags & BGE_FLAG_JUMBO_STD &&
+	    (sc->bge_ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN +
+	    ETHER_VLAN_ENCAP_LEN > (MCLBYTES - ETHER_ALIGN))) {
+		m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES);
+		if (m == NULL)
+			return (ENOBUFS);
+		m->m_len = m->m_pkthdr.len = MJUM9BYTES;
+	} else {
+		m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
+		if (m == NULL)
+			return (ENOBUFS);
+		m->m_len = m->m_pkthdr.len = MCLBYTES;
+	}
 	if ((sc->bge_flags & BGE_FLAG_RX_ALIGNBUG) == 0)
 		m_adj(m, ETHER_ALIGN);
 
@@ -2385,7 +2394,7 @@ static int
 bge_dma_alloc(struct bge_softc *sc)
 {
 	bus_addr_t lowaddr;
-	bus_size_t boundary, sbsz, txsegsz, txmaxsegsz;
+	bus_size_t boundary, sbsz, rxmaxsegsz, txsegsz, txmaxsegsz;
 	int i, error;
 
 	lowaddr = BUS_SPACE_MAXADDR;
@@ -2513,9 +2522,13 @@ bge_dma_alloc(struct bge_softc *sc)
 	}
 
 	/* Create tag for Rx mbufs. */
+	if (sc->bge_flags & BGE_FLAG_JUMBO_STD)
+		rxmaxsegsz = MJUM9BYTES;
+	else
+		rxmaxsegsz = MCLBYTES;
 	error = bus_dma_tag_create(sc->bge_cdata.bge_buffer_tag, 1, 0,
-	    BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, 1,
-	    MCLBYTES, 0, NULL, NULL, &sc->bge_cdata.bge_rx_mtag);
+	    BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, rxmaxsegsz, 1,
+	    rxmaxsegsz, 0, NULL, NULL, &sc->bge_cdata.bge_rx_mtag);
 
 	if (error) {
 		device_printf(sc->bge_dev, "could not allocate RX dma tag\n");
@@ -2759,7 +2772,7 @@ bge_attach(device_t dev)
 	case BGE_ASICREV_BCM5714_A0:
 	case BGE_ASICREV_BCM5780:
 	case BGE_ASICREV_BCM5714:
-		sc->bge_flags |= BGE_FLAG_5714_FAMILY /* | BGE_FLAG_JUMBO */;
+		sc->bge_flags |= BGE_FLAG_5714_FAMILY | BGE_FLAG_JUMBO_STD;
 		/* FALLTHROUGH */
 	case BGE_ASICREV_BCM5750:
 	case BGE_ASICREV_BCM5752:
@@ -3560,7 +3573,8 @@ bge_rxeof(struct bge_softc *sc, uint16_t
 	    sc->bge_cdata.bge_rx_return_ring_map, BUS_DMASYNC_POSTREAD);
 	bus_dmamap_sync(sc->bge_cdata.bge_rx_std_ring_tag,
 	    sc->bge_cdata.bge_rx_std_ring_map, BUS_DMASYNC_POSTWRITE);
-	if (ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
+	if (BGE_IS_JUMBO_CAPABLE(sc) &&
+	    ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
 	    (MCLBYTES - ETHER_ALIGN))
 		bus_dmamap_sync(sc->bge_cdata.bge_rx_jumbo_ring_tag,
 		    sc->bge_cdata.bge_rx_jumbo_ring_map, BUS_DMASYNC_POSTWRITE);
@@ -4689,7 +4703,8 @@ bge_init_locked(struct bge_softc *sc)
 	}
 
 	/* Init jumbo RX ring. */
-	if (ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
+	if (BGE_IS_JUMBO_CAPABLE(sc) &&
+	    ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
 	    (MCLBYTES - ETHER_ALIGN)) {
 		if (bge_init_rx_ring_jumbo(sc) != 0) {
 			device_printf(sc->bge_dev,
@@ -4914,14 +4929,19 @@ bge_ioctl(struct ifnet *ifp, u_long comm
 
 	switch (command) {
 	case SIOCSIFMTU:
+		if (BGE_IS_JUMBO_CAPABLE(sc) ||
+		    (sc->bge_flags & BGE_FLAG_JUMBO_STD)) {
+			if (ifr->ifr_mtu < ETHERMIN ||
+			    ifr->ifr_mtu > BGE_JUMBO_MTU) {
+				error = EINVAL;
+				break;
+			}
+		} else if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ETHERMTU) {
+			error = EINVAL; 
+			break;
+		}
 		BGE_LOCK(sc);
-		if (ifr->ifr_mtu < ETHERMIN ||
-		    ((BGE_IS_JUMBO_CAPABLE(sc)) &&
-		    ifr->ifr_mtu > BGE_JUMBO_MTU) ||
-		    ((!BGE_IS_JUMBO_CAPABLE(sc)) &&
-		    ifr->ifr_mtu > ETHERMTU))
-			error = EINVAL;
-		else if (ifp->if_mtu != ifr->ifr_mtu) {
+		if (ifp->if_mtu != ifr->ifr_mtu) {
 			ifp->if_mtu = ifr->ifr_mtu;
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
 				ifp->if_drv_flags &= ~IFF_DRV_RUNNING;

Modified: head/sys/dev/bge/if_bgereg.h
==============================================================================
--- head/sys/dev/bge/if_bgereg.h	Tue Apr  5 16:14:54 2011	(r220367)
+++ head/sys/dev/bge/if_bgereg.h	Tue Apr  5 17:41:54 2011	(r220368)
@@ -2748,6 +2748,7 @@ struct bge_softc {
 	uint32_t		bge_flags;
 #define	BGE_FLAG_TBI		0x00000001
 #define	BGE_FLAG_JUMBO		0x00000002
+#define	BGE_FLAG_JUMBO_STD	0x00000004
 #define	BGE_FLAG_EADDR		0x00000008
 #define	BGE_FLAG_MII_SERDES	0x00000010
 #define	BGE_FLAG_CPMU_PRESENT	0x00000020

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 18:40:19 2011
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 DCFF4106568D;
	Tue,  5 Apr 2011 18:40:19 +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 CAE6C8FC19;
	Tue,  5 Apr 2011 18:40:19 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35IeJ08027038;
	Tue, 5 Apr 2011 18:40:19 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35IeJM6027036;
	Tue, 5 Apr 2011 18:40:19 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104051840.p35IeJM6027036@svn.freebsd.org>
From: Jung-uk Kim 
Date: Tue, 5 Apr 2011 18:40: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: r220369 - 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: Tue, 05 Apr 2011 18:40:20 -0000

Author: jkim
Date: Tue Apr  5 18:40:19 2011
New Revision: 220369
URL: http://svn.freebsd.org/changeset/base/220369

Log:
  Lower the bar for ACPI-fast on real machines slightly.  Empirical evidences
  show that there are perfectly working PM timers with occasional "hiccups",
  probably because of an SMI.  Now we ignore the maximum if it happens once in
  the test loop and the width is small enough.  Also, relax normal width a bit
  to count in a boundary case.

Modified:
  head/sys/dev/acpica/acpi_timer.c

Modified: head/sys/dev/acpica/acpi_timer.c
==============================================================================
--- head/sys/dev/acpica/acpi_timer.c	Tue Apr  5 17:41:54 2011	(r220368)
+++ head/sys/dev/acpica/acpi_timer.c	Tue Apr  5 18:40:19 2011	(r220369)
@@ -306,12 +306,12 @@ SYSCTL_PROC(_machdep, OID_AUTO, acpi_tim
 static int
 acpi_timer_test()
 {
-    uint32_t	last, this;
-    int		min, max, n, delta;
-    register_t	s;
+    uint32_t last, this;
+    int delta, max, max2, min, n;
+    register_t s;
 
     min = INT32_MAX;
-    max = 0;
+    max = max2 = 0;
 
     /* Test the timer with interrupts disabled to get accurate results. */
     s = intr_disable();
@@ -319,18 +319,21 @@ acpi_timer_test()
     for (n = 0; n < N; n++) {
 	this = acpi_timer_read();
 	delta = acpi_TimerDelta(this, last);
-	if (delta > max)
+	if (delta > max) {
+	    max2 = max;
 	    max = delta;
+	} else if (delta > max2)
+	    max2 = delta;
 	if (delta < min)
 	    min = delta;
 	last = this;
     }
     intr_restore(s);
 
-    delta = max - min;
-    if (delta > 2 && vm_guest == VM_GUEST_NO)
+    delta = max2 - min;
+    if ((max - min > 8 || delta > 3) && vm_guest == VM_GUEST_NO)
 	n = 0;
-    else if (min < 0 || max == 0)
+    else if (min < 0 || max == 0 || max2 == 0)
 	n = 0;
     else
 	n = 1;

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 18:41:01 2011
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 79E91106566C;
	Tue,  5 Apr 2011 18:41: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 609A98FC1A;
	Tue,  5 Apr 2011 18:41:01 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35If121027100;
	Tue, 5 Apr 2011 18:41:01 GMT (envelope-from obrien@svn.freebsd.org)
Received: (from obrien@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35If1DX027085;
	Tue, 5 Apr 2011 18:41:01 GMT (envelope-from obrien@svn.freebsd.org)
Message-Id: <201104051841.p35If1DX027085@svn.freebsd.org>
From: "David E. O'Brien" 
Date: Tue, 5 Apr 2011 18:41: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: r220370 - in head: etc/mtree include lib/libedit
	lib/libedit/edit lib/libedit/edit/readline sbin/gvinum
	usr.sbin/ntp/ntpdc usr.sbin/ntp/ntpq usr.sbin/wpa/wpa_cli
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, 05 Apr 2011 18:41:01 -0000

Author: obrien
Date: Tue Apr  5 18:41:01 2011
New Revision: 220370
URL: http://svn.freebsd.org/changeset/base/220370

Log:
  * Add the readline(3) API to libedit.  The libedit versions of
    {readline,history}.h are in /usr/include/edit so as to not conflict with
    the GNU libreadline versions.  To use the libedit readline(3) one should
    add "-I/usr/include/edit" to their Makefile
    (spelled "-I${DESTDIR}/${INCLUDEDIR}/edit" within the FreeBSD source tree).
  
  * Enable its use in the BSD licensed utilities that support readline(3).
  
  * To make it easier to sync libedit development with NetBSD, histedit.h
    is moved into libedit's directory as history shows shown we keep merging
    it into that location.
  
  Obtained from:	NetBSD
  Sponsored by:	Juniper Networks

Added:
  head/lib/libedit/chartype.h
     - copied unchanged from r220331, vendor/NetBSD/libedit/dist/chartype.h
  head/lib/libedit/edit/
  head/lib/libedit/edit/readline/
     - copied from r220330, vendor/NetBSD/libedit/dist/readline/
  head/lib/libedit/edit/readline/history.h   (contents, props changed)
  head/lib/libedit/histedit.h
     - copied, changed from r220247, head/include/histedit.h
  head/lib/libedit/readline.c
     - copied, changed from r220331, vendor/NetBSD/libedit/dist/readline.c
Deleted:
  head/include/histedit.h
Modified:
  head/etc/mtree/BSD.include.dist
  head/include/Makefile
  head/lib/libedit/Makefile
  head/lib/libedit/edit/readline/Makefile
  head/lib/libedit/read.c
  head/sbin/gvinum/Makefile
  head/sbin/gvinum/gvinum.c
  head/usr.sbin/ntp/ntpdc/Makefile
  head/usr.sbin/ntp/ntpq/Makefile
  head/usr.sbin/wpa/wpa_cli/Makefile

Modified: head/etc/mtree/BSD.include.dist
==============================================================================
--- head/etc/mtree/BSD.include.dist	Tue Apr  5 18:40:19 2011	(r220369)
+++ head/etc/mtree/BSD.include.dist	Tue Apr  5 18:41:01 2011	(r220370)
@@ -137,6 +137,10 @@
         wi
         ..
     ..
+    edit
+        readline
+        ..
+    ..
     fs
         devfs
         ..

Modified: head/include/Makefile
==============================================================================
--- head/include/Makefile	Tue Apr  5 18:40:19 2011	(r220369)
+++ head/include/Makefile	Tue Apr  5 18:41:01 2011	(r220370)
@@ -11,7 +11,7 @@ INCS=	a.out.h ar.h assert.h bitstring.h 
 	db.h \
 	dirent.h dlfcn.h elf.h elf-hints.h err.h fmtmsg.h fnmatch.h fstab.h \
 	fts.h ftw.h getopt.h glob.h grp.h gssapi.h \
-	histedit.h ieeefp.h ifaddrs.h \
+	ieeefp.h ifaddrs.h \
 	inttypes.h iso646.h kenv.h langinfo.h libgen.h limits.h link.h \
 	locale.h malloc.h malloc_np.h memory.h monetary.h mpool.h mqueue.h \
 	ndbm.h netconfig.h \

Modified: head/lib/libedit/Makefile
==============================================================================
--- head/lib/libedit/Makefile	Tue Apr  5 18:40:19 2011	(r220369)
+++ head/lib/libedit/Makefile	Tue Apr  5 18:41:01 2011	(r220370)
@@ -26,18 +26,23 @@ MLINKS=	editline.3 el_deletestr.3 editli
 	editline.3 tok_line.3 editline.3 tok_str.3
 
 # For speed and debugging
-#SRCS=   ${OSRCS} tokenizer.c history.c
+#SRCS=   ${OSRCS}
 # For protection
-SRCS=	editline.c tokenizer.c history.c
+SRCS=	editline.c
+SRCS+=	tokenizer.c history.c readline.c
 SRCS+=	common.h emacs.h fcns.h help.h vi.h
 CLEANFILES+= common.h editline.c emacs.h fcns.c fcns.h help.c help.h vi.h
 
-CFLAGS+= -I. -I${.CURDIR}
+INCS=	histedit.h
+
+CFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/edit
 CFLAGS+= #-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH
 CFLAGS+= #-DDEBUG_PASTE -DDEBUG_EDIT
 
 WARNS?=	1
 
+SUBDIR= edit/readline
+
 AHDR=	vi.h emacs.h common.h
 ASRC=	${.CURDIR}/vi.c ${.CURDIR}/emacs.c ${.CURDIR}/common.c
 

Copied: head/lib/libedit/chartype.h (from r220331, vendor/NetBSD/libedit/dist/chartype.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lib/libedit/chartype.h	Tue Apr  5 18:41:01 2011	(r220370, copy of r220331, vendor/NetBSD/libedit/dist/chartype.h)
@@ -0,0 +1,245 @@
+/*	$NetBSD: chartype.h,v 1.6 2010/04/20 02:01:13 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * 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.
+ */
+
+#ifndef _h_chartype_f
+#define _h_chartype_f
+
+
+
+#ifdef WIDECHAR
+
+/* Ideally we should also test the value of the define to see if it
+ * supports non-BMP code points without requiring UTF-16, but nothing
+ * seems to actually advertise this properly, despite Unicode 3.1 having
+ * been around since 2001... */
+#if !defined(__NetBSD__) && !defined(__sun) && !(defined(__APPLE__) && defined(__MACH__))
+#ifndef __STDC_ISO_10646__
+/* In many places it is assumed that the first 127 code points are ASCII
+ * compatible, so ensure wchar_t indeed does ISO 10646 and not some other
+ * funky encoding that could break us in weird and wonderful ways. */
+	#error wchar_t must store ISO 10646 characters
+#endif
+#endif
+
+/* Oh for a  with char32_t and __STDC_UTF_32__ in it...
+ * ref: ISO/IEC DTR 19769
+ */
+#if WCHAR_MAX < INT32_MAX
+#warning Build environment does not support non-BMP characters
+#endif
+
+#define ct_mbtowc            mbtowc
+#define ct_mbtowc_reset      mbtowc(0,0,0)
+#define ct_wctomb            wctomb
+#define ct_wctomb_reset      wctomb(0,0)
+#define ct_wcstombs          wcstombs
+#define ct_mbstowcs          mbstowcs
+
+#define Char			wchar_t
+#define Int			wint_t
+#define FUN(prefix,rest)	prefix ## _w ## rest
+#define FUNW(type)		type ## _w
+#define TYPE(type)		type ## W
+#define FSTR			"%ls"
+#define STR(x) 			L ## x
+#define UC(c)			c
+#define Isalpha(x)  iswalpha(x)
+#define Isalnum(x)  iswalnum(x)
+#define Isgraph(x)  iswgraph(x)
+#define Isspace(x)  iswspace(x)
+#define Isdigit(x)  iswdigit(x)
+#define Iscntrl(x)  iswcntrl(x)
+#define Isprint(x)  iswprint(x)
+
+#define Isupper(x)  iswupper(x)
+#define Islower(x)  iswlower(x)
+#define Toupper(x)  towupper(x)
+#define Tolower(x)  towlower(x)
+
+#define IsASCII(x)  (x < 0x100)
+
+#define Strlen(x)       wcslen(x)
+#define Strchr(s,c)     wcschr(s,c)
+#define Strrchr(s,c)    wcsrchr(s,c)
+#define Strstr(s,v)     wcsstr(s,v)
+#define Strdup(x)       wcsdup(x)
+#define Strcpy(d,s)     wcscpy(d,s)
+#define Strncpy(d,s,n)  wcsncpy(d,s,n)
+#define Strncat(d,s,n)  wcsncat(d,s,n)
+
+#define Strcmp(s,v)     wcscmp(s,v)
+#define Strncmp(s,v,n)  wcsncmp(s,v,n)
+#define Strcspn(s,r)    wcscspn(s,r)
+
+#define Strtol(p,e,b)   wcstol(p,e,b)
+
+#define Width(c)	wcwidth(c)
+
+#else /* NARROW */
+
+#define ct_mbtowc            error
+#define ct_mbtowc_reset      
+#define ct_wctomb            error
+#define ct_wctomb_reset      
+#define ct_wcstombs(a, b, c)    (strncpy(a, b, c), strlen(a))
+#define ct_mbstowcs(a, b, c)    (strncpy(a, b, c), strlen(a))
+
+#define Char			char
+#define Int			int
+#define FUN(prefix,rest)	prefix ## _ ## rest
+#define FUNW(type)		type
+#define TYPE(type)		type
+#define FSTR			"%s"
+#define STR(x) 			x
+#define UC(c)			(unsigned char)(c)
+
+#define Isalpha(x)  isalpha((unsigned char)x)
+#define Isalnum(x)  isalnum((unsigned char)x)
+#define Isgraph(x)  isgraph((unsigned char)x)
+#define Isspace(x)  isspace((unsigned char)x)
+#define Isdigit(x)  isdigit((unsigned char)x)
+#define Iscntrl(x)  iscntrl((unsigned char)x)
+#define Isprint(x)  isprint((unsigned char)x)
+
+#define Isupper(x)  isupper((unsigned char)x)
+#define Islower(x)  islower((unsigned char)x)
+#define Toupper(x)  toupper((unsigned char)x)
+#define Tolower(x)  tolower((unsigned char)x)
+
+#define IsASCII(x)  isascii((unsigned char)x)
+
+#define Strlen(x)       strlen(x)
+#define Strchr(s,c)     strchr(s,c)
+#define Strrchr(s,c)    strrchr(s,c)
+#define Strstr(s,v)     strstr(s,v)
+#define Strdup(x)       strdup(x)
+#define Strcpy(d,s)     strcpy(d,s)
+#define Strncpy(d,s,n)  strncpy(d,s,n)
+#define Strncat(d,s,n)  strncat(d,s,n)
+
+#define Strcmp(s,v)     strcmp(s,v)
+#define Strncmp(s,v,n)  strncmp(s,v,n)
+#define Strcspn(s,r)    strcspn(s,r)
+
+#define Strtol(p,e,b)   strtol(p,e,b)
+
+#define Width(c)	1
+
+#endif
+
+
+#ifdef WIDECHAR
+/*
+ * Conversion buffer
+ */
+typedef struct ct_buffer_t {
+        char    *cbuff;
+        size_t  csize;
+        Char *wbuff;
+        size_t  wsize;
+} ct_buffer_t;
+
+#define ct_encode_string __ct_encode_string
+/* Encode a wide character string and return the UTF-8 encoded result. */
+public char *ct_encode_string(const Char *, ct_buffer_t *);
+
+#define ct_decode_string __ct_decode_string
+/* Decode a (multi)?byte string and return the wide character string result. */
+public Char *ct_decode_string(const char *, ct_buffer_t *);
+
+/* Decode a (multi)?byte argv string array.
+ * The pointer returned must be free()d when done. */
+protected Char **ct_decode_argv(int, const char *[],  ct_buffer_t *);
+
+/* Resizes the conversion buffer(s) if needed. */
+protected void ct_conv_buff_resize(ct_buffer_t *, size_t, size_t);
+protected ssize_t ct_encode_char(char *, size_t, Char);
+protected size_t ct_enc_width(Char);
+
+#define ct_free_argv(s)	el_free(s)
+
+#else
+#define	ct_encode_string(s, b)	(s)
+#define ct_decode_string(s, b)	(s)
+#define ct_decode_argv(l, s, b)	(s)
+#define ct_conv_buff_resize(b, os, ns)
+#define ct_encode_char(d, l, s)	(*d = s, 1)
+#define ct_free_argv(s)
+#endif
+
+#ifndef NARROWCHAR
+/* Encode a characted into the destination buffer, provided there is sufficent
+ * buffer space available. Returns the number of bytes used up (zero if the
+ * character cannot be encoded, -1 if there was not enough space available). */
+
+/* The maximum buffer size to hold the most unwieldly visual representation,
+ * in this case \U+nnnnn. */
+#define VISUAL_WIDTH_MAX 8
+
+/* The terminal is thought of in terms of X columns by Y lines. In the cases
+ * where a wide character takes up more than one column, the adjacent 
+ * occupied column entries will contain this faux character. */
+#define MB_FILL_CHAR ((Char)-1)
+
+/* Visual width of character c, taking into account ^? , \0177 and \U+nnnnn
+ * style visual expansions. */
+protected int ct_visual_width(Char);
+
+/* Turn the given character into the appropriate visual format, matching
+ * the width given by ct_visual_width(). Returns the number of characters used
+ * up, or -1 if insufficient space. Buffer length is in count of Char's. */
+protected ssize_t ct_visual_char(Char *, size_t, Char);
+
+/* Convert the given string into visual format, using the ct_visual_char()
+ * function. Uses a static buffer, so not threadsafe. */
+protected const Char *ct_visual_string(const Char *);
+
+
+/* printable character, use ct_visual_width() to find out display width */
+#define CHTYPE_PRINT        ( 0)
+/* control character found inside the ASCII portion of the charset */
+#define CHTYPE_ASCIICTL     (-1)
+/* a \t */
+#define CHTYPE_TAB          (-2)
+/* a \n */
+#define CHTYPE_NL           (-3)
+/* non-printable character */
+#define CHTYPE_NONPRINT     (-4)
+/* classification of character c, as one of the above defines */
+protected int ct_chr_class(Char c);
+#endif
+
+
+#endif /* _chartype_f */

Modified: head/lib/libedit/edit/readline/Makefile
==============================================================================
--- vendor/NetBSD/libedit/dist/readline/Makefile	Mon Apr  4 16:24:05 2011	(r220330)
+++ head/lib/libedit/edit/readline/Makefile	Tue Apr  5 18:41:01 2011	(r220370)
@@ -1,13 +1,8 @@
-#	$NetBSD: Makefile,v 1.7 2003/08/03 09:23:15 lukem Exp $	
+# Copyright (c) 2011 David E O'Brien
+# $FreeBSD$
 
-NOOBJ=		# defined
+INCS=	readline.h history.h
 
-.include 
+INCSDIR= ${INCLUDEDIR}/edit/readline
 
-.PATH:	${NETBSDSRCDIR}/lib/libedit
-
-INCS=		readline.h
-INCSDIR=	/usr/include/readline
-INCSYMLINKS=	readline.h ${INCSDIR}/history.h
-
-.include 
+.include 

Added: head/lib/libedit/edit/readline/history.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lib/libedit/edit/readline/history.h	Tue Apr  5 18:41:01 2011	(r220370)
@@ -0,0 +1,32 @@
+/*-
+ * Copyright (c) 2011 David E. O'Brien
+ * 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.
+ * 3. Neither the name of the author nor the names of contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * 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 REGENTS 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$
+ */
+
+#include 

Copied and modified: head/lib/libedit/histedit.h (from r220247, head/include/histedit.h)
==============================================================================
--- head/include/histedit.h	Fri Apr  1 14:13:49 2011	(r220247, copy source)
+++ head/lib/libedit/histedit.h	Tue Apr  5 18:41:01 2011	(r220370)
@@ -44,6 +44,9 @@
 #include 
 
 __BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /*
  * ==== Editing ====
@@ -87,7 +90,7 @@ void		 el_reset(EditLine *);
  */
 const char	*el_gets(EditLine *, int *);
 int		 el_getc(EditLine *, char *);
-void		 el_push(EditLine *, char *);
+void		 el_push(EditLine *, const char *);
 
 /*
  * Beep!
@@ -132,6 +135,10 @@ unsigned char	_el_fn_sh_complete(EditLin
 #define	EL_GETTC	17	/* , const char *, ..., NULL);	*/
 #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 */
+#define	EL_RESIZE	23	/* , el_zfunc_t, void *);	      set     */
 
 #define	EL_BUILTIN_GETCFN	(NULL)
 
@@ -205,6 +212,9 @@ int		history(History *, HistEvent *, int
 #define	H_SETUNIQUE	20	/* , int);		*/
 #define	H_GETUNIQUE	21	/* , void);		*/
 #define	H_DEL		22	/* , int);		*/
+#define	H_NEXT_EVDATA	23	/* , const int, histdata_t *);	*/
+#define	H_DELDATA	24	/* , int, histdata_t *);*/
+#define	H_REPLACE	25	/* , const char *, histdata_t);	*/
 
 
 /*
@@ -225,5 +235,8 @@ int		 tok_str(Tokenizer *, const char *,
 		    int *, const char ***);
 
 __END_DECLS
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _HISTEDIT_H_ */

Modified: head/lib/libedit/read.c
==============================================================================
--- head/lib/libedit/read.c	Tue Apr  5 18:40:19 2011	(r220369)
+++ head/lib/libedit/read.c	Tue Apr  5 18:41:01 2011	(r220370)
@@ -211,7 +211,7 @@ read_preread(EditLine *el)
  *	Push a macro
  */
 public void
-el_push(EditLine *el, char *str)
+el_push(EditLine *el, const char *str)
 {
 	c_macro_t *ma = &el->el_chared.c_macro;
 

Copied and modified: head/lib/libedit/readline.c (from r220331, vendor/NetBSD/libedit/dist/readline.c)
==============================================================================
--- vendor/NetBSD/libedit/dist/readline.c	Mon Apr  4 16:47:42 2011	(r220331, copy source)
+++ head/lib/libedit/readline.c	Tue Apr  5 18:41:01 2011	(r220370)
@@ -29,10 +29,9 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
-#if !defined(lint) && !defined(SCCSID)
+#include 
 __RCSID("$NetBSD: readline.c,v 1.90 2010/08/04 20:29:18 christos Exp $");
-#endif /* not lint && not SCCSID */
+__FBSDID("$FreeBSD$");
 
 #include 
 #include 
@@ -47,12 +46,10 @@ __RCSID("$NetBSD: readline.c,v 1.90 2010
 #include 
 #include 
 #include 
-#ifdef HAVE_VIS_H
 #include 
-#else
-#include "np/vis.h"
-#endif
+#include "sys.h"
 #include "readline/readline.h"
+#include "chartype.h"
 #include "el.h"
 #include "fcns.h"		/* for EL_NUM_FCNS */
 #include "histedit.h"
@@ -1769,7 +1766,7 @@ rl_complete(int ignore __attribute__((__
 	    _rl_completion_append_character_function,
 	    (size_t)rl_completion_query_items,
 	    &rl_completion_type, &rl_attempted_completion_over,
-	    &rl_point, &rl_end);
+	    &rl_point, &rl_end, NULL, NULL, NULL);
 }
 
 

Modified: head/sbin/gvinum/Makefile
==============================================================================
--- head/sbin/gvinum/Makefile	Tue Apr  5 18:40:19 2011	(r220369)
+++ head/sbin/gvinum/Makefile	Tue Apr  5 18:41:01 2011	(r220370)
@@ -5,10 +5,10 @@ SRCS=	gvinum.c gvinum.h geom_vinum_share
 MAN=	gvinum.8
 
 WARNS?=	2
-CFLAGS+=	-I${.CURDIR}/../../sys
+CFLAGS=	-I${.CURDIR}/../../sys -I${DESTDIR}/${INCLUDEDIR}/edit
 
-DPADD=	${LIBREADLINE} ${LIBTERMCAP} ${LIBDEVSTAT} ${LIBKVM} ${LIBGEOM}
-LDADD=	-lreadline -ltermcap -ldevstat -lkvm -lgeom
+DPADD=	${LIBEDIT} ${LIBTERMCAP} ${LIBDEVSTAT} ${LIBKVM} ${LIBGEOM}
+LDADD=	-ledit -ltermcap -ldevstat -lkvm -lgeom
 
 .PATH: ${.CURDIR}/../../sys/geom/vinum
 

Modified: head/sbin/gvinum/gvinum.c
==============================================================================
--- head/sbin/gvinum/gvinum.c	Tue Apr  5 18:40:19 2011	(r220369)
+++ head/sbin/gvinum/gvinum.c	Tue Apr  5 18:41:01 2011	(r220370)
@@ -50,6 +50,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/usr.sbin/ntp/ntpdc/Makefile
==============================================================================
--- head/usr.sbin/ntp/ntpdc/Makefile	Tue Apr  5 18:40:19 2011	(r220369)
+++ head/usr.sbin/ntp/ntpdc/Makefile	Tue Apr  5 18:41:01 2011	(r220370)
@@ -15,16 +15,14 @@ CFLAGS+= -I${.CURDIR}/../../../contrib/n
 DPADD=	${LIBNTP} ${LIBM} ${LIBMD} ${LIBOPTS}
 LDADD=	${LIBNTP} -lm -lmd ${LIBOPTS}
 
-.if ${MK_GNU_SUPPORT} != "no"
-DPADD+=		${LIBREADLINE} ${LIBTERMCAP}
-LDADD+=		-lreadline -ltermcap
-CFLAGS+=	-DHAVE_LIBREADLINE -DHAVE_READLINE_HISTORY_H \
-		-DHAVE_READLINE_READLINE_H
-.endif
+DPADD+=		${LIBEDIT} ${LIBTERMCAP}
+LDADD+=		-ledit -ltermcap
+CFLAGS+=	-DHAVE_LIBEDIT -DHAVE_READLINE_READLINE_H \
+		-I${DESTDIR}/${INCLUDEDIR}/edit
 
 CLEANFILES+= .version version.c
 
-version.c: 
+version.c:
 	sh -e ${.CURDIR}/../scripts/mkver ntpdc
 
 afterinstall:

Modified: head/usr.sbin/ntp/ntpq/Makefile
==============================================================================
--- head/usr.sbin/ntp/ntpq/Makefile	Tue Apr  5 18:40:19 2011	(r220369)
+++ head/usr.sbin/ntp/ntpq/Makefile	Tue Apr  5 18:41:01 2011	(r220370)
@@ -17,16 +17,14 @@ CFLAGS+= -I${.CURDIR}/../../../contrib/n
 DPADD=	${LIBNTP} ${LIBM} ${LIBMD} ${LIBOPTS}
 LDADD=	${LIBNTP} -lm -lmd ${LIBOPTS}
 
-.if ${MK_GNU_SUPPORT} != "no"
-DPADD+=		${LIBREADLINE} ${LIBTERMCAP}
-LDADD+=		-lreadline -ltermcap
-CFLAGS+=	-DHAVE_LIBREADLINE -DHAVE_READLINE_HISTORY_H \
-		-DHAVE_READLINE_READLINE_H
-.endif
+DPADD+=		${LIBEDIT} ${LIBTERMCAP}
+LDADD+=		-ledit -ltermcap
+CFLAGS+=	-DHAVE_LIBEDIT -DHAVE_READLINE_READLINE_H \
+		-I${DESTDIR}/${INCLUDEDIR}/edit
 
 CLEANFILES+= .version version.c
 
-version.c: 
+version.c:
 	sh -e ${.CURDIR}/../scripts/mkver ntpq
 
 .include 

Modified: head/usr.sbin/wpa/wpa_cli/Makefile
==============================================================================
--- head/usr.sbin/wpa/wpa_cli/Makefile	Tue Apr  5 18:40:19 2011	(r220369)
+++ head/usr.sbin/wpa/wpa_cli/Makefile	Tue Apr  5 18:41:01 2011	(r220370)
@@ -14,8 +14,8 @@ CFLAGS+= -DCONFIG_CTRL_IFACE_UNIX
 # enable use of d_type to identify unix domain sockets
 CFLAGS+= -D_DIRENT_HAVE_D_TYPE
 
-#CFLAGS+= -DCONFIG_READLINE
-#LDADD+= -ledit -ltermcap
-#DPADD+= ${LIBEDIT} ${LIBTERMCAP}
+CFLAGS+= -DCONFIG_READLINE -I${DESTDIR}/${INCLUDEDIR}/edit
+LDADD+= -ledit -ltermcap
+DPADD+= ${LIBEDIT} ${LIBTERMCAP}
 
 .include 

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 19:41:18 2011
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 74B5D1065673;
	Tue,  5 Apr 2011 19:41:18 +0000 (UTC) (envelope-from uqs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 65A8C8FC18;
	Tue,  5 Apr 2011 19:41:18 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35JfIZd028583;
	Tue, 5 Apr 2011 19:41:18 GMT (envelope-from uqs@svn.freebsd.org)
Received: (from uqs@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35JfI3r028581;
	Tue, 5 Apr 2011 19:41:18 GMT (envelope-from uqs@svn.freebsd.org)
Message-Id: <201104051941.p35JfI3r028581@svn.freebsd.org>
From: Ulrich Spoerlein 
Date: Tue, 5 Apr 2011 19:41:18 +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: r220371 - head/sys/modules/firewire/fwip
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, 05 Apr 2011 19:41:18 -0000

Author: uqs
Date: Tue Apr  5 19:41:18 2011
New Revision: 220371
URL: http://svn.freebsd.org/changeset/base/220371

Log:
  Fix buildworld -DMODULES_WITH_WORLD

Modified:
  head/sys/modules/firewire/fwip/Makefile

Modified: head/sys/modules/firewire/fwip/Makefile
==============================================================================
--- head/sys/modules/firewire/fwip/Makefile	Tue Apr  5 18:41:01 2011	(r220370)
+++ head/sys/modules/firewire/fwip/Makefile	Tue Apr  5 19:41:18 2011	(r220371)
@@ -6,7 +6,7 @@
 
 KMOD    = if_fwip
 SRCS    = bus_if.h device_if.h \
-          opt_inet.h opt_inet6.h \
+          opt_inet.h opt_inet6.h opt_ofed.h \
           if_fwip.c if_fwipvar.h \
           firewire.h firewirereg.h \
           if_fwsubr.c

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 19:50:16 2011
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 0FDE81065675;
	Tue,  5 Apr 2011 19:50:16 +0000 (UTC) (envelope-from jhb@freebsd.org)
Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42])
	by mx1.freebsd.org (Postfix) with ESMTP id D9F538FC12;
	Tue,  5 Apr 2011 19:50:15 +0000 (UTC)
Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net
	[66.111.2.69])
	by cyrus.watson.org (Postfix) with ESMTPSA id 8E3B346B0D;
	Tue,  5 Apr 2011 15:50:15 -0400 (EDT)
Received: from jhbbsd.localnet (unknown [209.249.190.124])
	by bigwig.baldwin.cx (Postfix) with ESMTPSA id 20B7F8A027;
	Tue,  5 Apr 2011 15:50:15 -0400 (EDT)
From: John Baldwin 
To: "David E. O'Brien" 
Date: Tue, 5 Apr 2011 15:47:56 -0400
User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; )
References: <201104051841.p35If1DX027085@svn.freebsd.org>
In-Reply-To: <201104051841.p35If1DX027085@svn.freebsd.org>
MIME-Version: 1.0
Content-Type: Text/Plain;
  charset="utf-8"
Content-Transfer-Encoding: 7bit
Message-Id: <201104051547.56623.jhb@freebsd.org>
X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6
	(bigwig.baldwin.cx); Tue, 05 Apr 2011 15:50:15 -0400 (EDT)
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220370 - in head: etc/mtree include lib/libedit
	lib/libedit/edit lib/libedit/edit/readline sbin/gvinum
	usr.sbin/ntp/ntpdc usr.sbin/ntp/ntpq usr.sbin/wpa/wpa_cli
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, 05 Apr 2011 19:50:16 -0000

On Tuesday, April 05, 2011 2:41:01 pm David E. O'Brien wrote:
> Author: obrien
> Date: Tue Apr  5 18:41:01 2011
> New Revision: 220370
> URL: http://svn.freebsd.org/changeset/base/220370
> 
> Log:
>   * Add the readline(3) API to libedit.  The libedit versions of
>     {readline,history}.h are in /usr/include/edit so as to not conflict with
>     the GNU libreadline versions.  To use the libedit readline(3) one should
>     add "-I/usr/include/edit" to their Makefile
>     (spelled "-I${DESTDIR}/${INCLUDEDIR}/edit" within the FreeBSD source tree).
>   
>   * Enable its use in the BSD licensed utilities that support readline(3).
>   
>   * To make it easier to sync libedit development with NetBSD, histedit.h
>     is moved into libedit's directory as history shows shown we keep merging
>     it into that location.
>   
>   Obtained from:	NetBSD
>   Sponsored by:	Juniper Networks

Should libedit move to contrib?

-- 
John Baldwin

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 19:50:34 2011
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 EFB9B1065785;
	Tue,  5 Apr 2011 19:50:34 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E0E008FC17;
	Tue,  5 Apr 2011 19:50:34 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35JoYiu028832;
	Tue, 5 Apr 2011 19:50:34 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35JoYcn028830;
	Tue, 5 Apr 2011 19:50:34 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <201104051950.p35JoYcn028830@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Tue, 5 Apr 2011 19:50: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: r220372 - 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, 05 Apr 2011 19:50:35 -0000

Author: trasz
Date: Tue Apr  5 19:50:34 2011
New Revision: 220372
URL: http://svn.freebsd.org/changeset/base/220372

Log:
  Add missing stubs.

Modified:
  head/sys/kern/kern_racct.c

Modified: head/sys/kern/kern_racct.c
==============================================================================
--- head/sys/kern/kern_racct.c	Tue Apr  5 19:41:18 2011	(r220371)
+++ head/sys/kern/kern_racct.c	Tue Apr  5 19:50:34 2011	(r220372)
@@ -777,6 +777,11 @@ racct_set(struct proc *p, int resource, 
 }
 
 void
+racct_set_force(struct proc *p, int resource, uint64_t amount)
+{
+}
+
+void
 racct_sub(struct proc *p, int resource, uint64_t amount)
 {
 }
@@ -793,6 +798,13 @@ racct_get_limit(struct proc *p, int reso
 	return (UINT64_MAX);
 }
 
+uint64_t
+racct_get_available(struct proc *p, int resource)
+{
+
+	return (UINT64_MAX);
+}
+
 void
 racct_create(struct racct **racctp)
 {

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 20:23:59 2011
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 7F2E61065670;
	Tue,  5 Apr 2011 20:23:59 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6EF148FC19;
	Tue,  5 Apr 2011 20:23:59 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35KNxR9029600;
	Tue, 5 Apr 2011 20:23:59 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35KNxYY029588;
	Tue, 5 Apr 2011 20:23:59 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <201104052023.p35KNxYY029588@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Tue, 5 Apr 2011 20: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: r220373 - in head/sys: compat/linux compat/svr4
	i386/linux kern 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: Tue, 05 Apr 2011 20:23:59 -0000

Author: trasz
Date: Tue Apr  5 20:23:59 2011
New Revision: 220373
URL: http://svn.freebsd.org/changeset/base/220373

Log:
  Add accounting for most of the memory-related resources.
  
  Sponsored by:	The FreeBSD Foundation
  Reviewed by:	kib (earlier version)

Modified:
  head/sys/compat/linux/linux_misc.c
  head/sys/compat/svr4/imgact_svr4.c
  head/sys/i386/linux/imgact_linux.c
  head/sys/kern/imgact_aout.c
  head/sys/kern/imgact_elf.c
  head/sys/kern/imgact_gzip.c
  head/sys/vm/swap_pager.c
  head/sys/vm/vm_glue.c
  head/sys/vm/vm_map.c
  head/sys/vm/vm_mmap.c
  head/sys/vm/vm_unix.c

Modified: head/sys/compat/linux/linux_misc.c
==============================================================================
--- head/sys/compat/linux/linux_misc.c	Tue Apr  5 19:50:34 2011	(r220372)
+++ head/sys/compat/linux/linux_misc.c	Tue Apr  5 20:23:59 2011	(r220373)
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -357,7 +358,9 @@ linux_uselib(struct thread *td, struct l
 	 */
 	PROC_LOCK(td->td_proc);
 	if (a_out->a_text > maxtsiz ||
-	    a_out->a_data + bss_size > lim_cur(td->td_proc, RLIMIT_DATA)) {
+	    a_out->a_data + bss_size > lim_cur(td->td_proc, RLIMIT_DATA) ||
+	    racct_set(td->td_proc, RACCT_DATA, a_out->a_data +
+	    bss_size) != 0) {
 		PROC_UNLOCK(td->td_proc);
 		error = ENOMEM;
 		goto cleanup;

Modified: head/sys/compat/svr4/imgact_svr4.c
==============================================================================
--- head/sys/compat/svr4/imgact_svr4.c	Tue Apr  5 19:50:34 2011	(r220372)
+++ head/sys/compat/svr4/imgact_svr4.c	Tue Apr  5 20:23:59 2011	(r220373)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -108,7 +109,8 @@ exec_svr4_imgact(imgp)
      */
     PROC_LOCK(imgp->proc);
     if (a_out->a_text > maxtsiz ||
-	a_out->a_data + bss_size > lim_cur(imgp->proc, RLIMIT_DATA)) {
+	a_out->a_data + bss_size > lim_cur(imgp->proc, RLIMIT_DATA) ||
+	racct_set(imgp->proc, RACCT_DATA, a_out->a_data + bss_size) != 0) {;
     	PROC_UNLOCK(imgp->proc);
 	return (ENOMEM);
     }

Modified: head/sys/i386/linux/imgact_linux.c
==============================================================================
--- head/sys/i386/linux/imgact_linux.c	Tue Apr  5 19:50:34 2011	(r220372)
+++ head/sys/i386/linux/imgact_linux.c	Tue Apr  5 20:23:59 2011	(r220373)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -107,7 +108,8 @@ exec_linux_imgact(struct image_params *i
      */
     PROC_LOCK(imgp->proc);
     if (a_out->a_text > maxtsiz ||
-	a_out->a_data + bss_size > lim_cur(imgp->proc, RLIMIT_DATA)) {
+	a_out->a_data + bss_size > lim_cur(imgp->proc, RLIMIT_DATA) ||
+	racct_set(imgp->proc, RACCT_DATA, a_out->a_data + bss_size) != 0) {
 	PROC_UNLOCK(imgp->proc);
 	return (ENOMEM);
     }

Modified: head/sys/kern/imgact_aout.c
==============================================================================
--- head/sys/kern/imgact_aout.c	Tue Apr  5 19:50:34 2011	(r220372)
+++ head/sys/kern/imgact_aout.c	Tue Apr  5 20:23:59 2011	(r220373)
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -245,7 +246,8 @@ exec_aout_imgact(struct image_params *im
 	    a_out->a_text > maxtsiz ||
 
 	    /* data + bss can't exceed rlimit */
-	    a_out->a_data + bss_size > lim_cur(imgp->proc, RLIMIT_DATA)) {
+	    a_out->a_data + bss_size > lim_cur(imgp->proc, RLIMIT_DATA) ||
+	    racct_set(imgp->proc, RACCT_DATA, a_out->a_data + bss_size) != 0) {
 			PROC_UNLOCK(imgp->proc);
 			return (ENOMEM);
 	}

Modified: head/sys/kern/imgact_elf.c
==============================================================================
--- head/sys/kern/imgact_elf.c	Tue Apr  5 19:50:34 2011	(r220372)
+++ head/sys/kern/imgact_elf.c	Tue Apr  5 20:23:59 2011	(r220373)
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -874,7 +875,9 @@ __CONCAT(exec_, __elfN(imgact))(struct i
 	PROC_LOCK(imgp->proc);
 	if (data_size > lim_cur(imgp->proc, RLIMIT_DATA) ||
 	    text_size > maxtsiz ||
-	    total_size > lim_cur(imgp->proc, RLIMIT_VMEM)) {
+	    total_size > lim_cur(imgp->proc, RLIMIT_VMEM) ||
+	    racct_set(imgp->proc, RACCT_DATA, data_size) != 0 ||
+	    racct_set(imgp->proc, RACCT_VMEM, total_size) != 0) {
 		PROC_UNLOCK(imgp->proc);
 		return (ENOMEM);
 	}
@@ -1101,6 +1104,13 @@ __elfN(coredump)(struct thread *td, stru
 	hdrsize = 0;
 	__elfN(puthdr)(td, (void *)NULL, &hdrsize, seginfo.count);
 
+	PROC_LOCK(td->td_proc);
+	error = racct_add(td->td_proc, RACCT_CORE, hdrsize + seginfo.size);
+	PROC_UNLOCK(td->td_proc);
+	if (error != 0) {
+		error = EFAULT;
+		goto done;
+	}
 	if (hdrsize + seginfo.size >= limit) {
 		error = EFAULT;
 		goto done;

Modified: head/sys/kern/imgact_gzip.c
==============================================================================
--- head/sys/kern/imgact_gzip.c	Tue Apr  5 19:50:34 2011	(r220372)
+++ head/sys/kern/imgact_gzip.c	Tue Apr  5 20:23:59 2011	(r220373)
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -216,7 +217,9 @@ do_aout_hdr(struct imgact_gzip * gz)
 
 	/* data + bss can't exceed rlimit */
 	    gz->a_out.a_data + gz->bss_size >
-	    lim_cur(gz->ip->proc, RLIMIT_DATA)) {
+	    lim_cur(gz->ip->proc, RLIMIT_DATA) ||
+	    racct_set(gz->ip->proc, RACCT_DATA,
+	    gz->a_out.a_data + gz->bss_size) != 0) {
 		PROC_UNLOCK(gz->ip->proc);
 		gz->where = __LINE__;
 		return (ENOMEM);

Modified: head/sys/vm/swap_pager.c
==============================================================================
--- head/sys/vm/swap_pager.c	Tue Apr  5 19:50:34 2011	(r220372)
+++ head/sys/vm/swap_pager.c	Tue Apr  5 20:23:59 2011	(r220373)
@@ -86,6 +86,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -192,6 +193,12 @@ swap_reserve_by_cred(vm_ooffset_t incr, 
 	if (incr & PAGE_MASK)
 		panic("swap_reserve: & PAGE_MASK");
 
+	PROC_LOCK(curproc);
+	error = racct_add(curproc, RACCT_SWAP, incr);
+	PROC_UNLOCK(curproc);
+	if (error != 0)
+		return (0);
+
 	res = 0;
 	mtx_lock(&sw_dev_mtx);
 	r = swap_reserved + incr;
@@ -230,6 +237,12 @@ swap_reserve_by_cred(vm_ooffset_t incr, 
 		    curproc->p_pid, uip->ui_uid, incr);
 	}
 
+	if (!res) {
+		PROC_LOCK(curproc);
+		racct_sub(curproc, RACCT_SWAP, incr);
+		PROC_UNLOCK(curproc);
+	}
+
 	return (res);
 }
 
@@ -242,6 +255,10 @@ swap_reserve_force(vm_ooffset_t incr)
 	swap_reserved += incr;
 	mtx_unlock(&sw_dev_mtx);
 
+	PROC_LOCK(curproc);
+	racct_add_force(curproc, RACCT_SWAP, incr);
+	PROC_UNLOCK(curproc);
+
 	uip = curthread->td_ucred->cr_ruidinfo;
 	PROC_LOCK(curproc);
 	UIDINFO_VMSIZE_LOCK(uip);
@@ -282,6 +299,8 @@ swap_release_by_cred(vm_ooffset_t decr, 
 		printf("negative vmsize for uid = %d\n", uip->ui_uid);
 	uip->ui_vmsize -= decr;
 	UIDINFO_VMSIZE_UNLOCK(uip);
+
+	racct_sub_cred(cred, RACCT_SWAP, decr);
 }
 
 static void swapdev_strategy(struct buf *, struct swdevt *sw);

Modified: head/sys/vm/vm_glue.c
==============================================================================
--- head/sys/vm/vm_glue.c	Tue Apr  5 19:50:34 2011	(r220372)
+++ head/sys/vm/vm_glue.c	Tue Apr  5 20:23:59 2011	(r220373)
@@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -182,6 +183,7 @@ int
 vslock(void *addr, size_t len)
 {
 	vm_offset_t end, last, start;
+	unsigned long nsize;
 	vm_size_t npages;
 	int error;
 
@@ -194,9 +196,13 @@ vslock(void *addr, size_t len)
 	if (npages > vm_page_max_wired)
 		return (ENOMEM);
 	PROC_LOCK(curproc);
-	if (ptoa(npages +
-	    pmap_wired_count(vm_map_pmap(&curproc->p_vmspace->vm_map))) >
-	    lim_cur(curproc, RLIMIT_MEMLOCK)) {
+	nsize = ptoa(npages +
+	    pmap_wired_count(vm_map_pmap(&curproc->p_vmspace->vm_map)));
+	if (nsize > lim_cur(curproc, RLIMIT_MEMLOCK)) {
+		PROC_UNLOCK(curproc);
+		return (ENOMEM);
+	}
+	if (racct_set(curproc, RACCT_MEMLOCK, nsize)) {
 		PROC_UNLOCK(curproc);
 		return (ENOMEM);
 	}
@@ -216,6 +222,12 @@ vslock(void *addr, size_t len)
 #endif
 	error = vm_map_wire(&curproc->p_vmspace->vm_map, start, end,
 	    VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES);
+	if (error != KERN_SUCCESS) {
+		PROC_LOCK(curproc);
+		racct_set(curproc, RACCT_MEMLOCK, 
+		    ptoa(pmap_wired_count(vm_map_pmap(&curproc->p_vmspace->vm_map))));
+		PROC_UNLOCK(curproc);
+	}
 	/*
 	 * Return EFAULT on error to match copy{in,out}() behaviour
 	 * rather than returning ENOMEM like mlock() would.
@@ -231,6 +243,11 @@ vsunlock(void *addr, size_t len)
 	(void)vm_map_unwire(&curproc->p_vmspace->vm_map,
 	    trunc_page((vm_offset_t)addr), round_page((vm_offset_t)addr + len),
 	    VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES);
+
+	PROC_LOCK(curproc);
+	racct_set(curproc, RACCT_MEMLOCK,
+	    ptoa(pmap_wired_count(vm_map_pmap(&curproc->p_vmspace->vm_map))));
+	PROC_UNLOCK(curproc);
 }
 
 /*

Modified: head/sys/vm/vm_map.c
==============================================================================
--- head/sys/vm/vm_map.c	Tue Apr  5 19:50:34 2011	(r220372)
+++ head/sys/vm/vm_map.c	Tue Apr  5 20:23:59 2011	(r220373)
@@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -313,6 +314,19 @@ vm_init2(void)
 	    vmspace_zinit, vmspace_zfini, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
 }
 
+static void
+vmspace_container_reset(struct proc *p)
+{
+
+	PROC_LOCK(p);
+	racct_set(p, RACCT_DATA, 0);
+	racct_set(p, RACCT_STACK, 0);
+	racct_set(p, RACCT_RSS, 0);
+	racct_set(p, RACCT_MEMLOCK, 0);
+	racct_set(p, RACCT_VMEM, 0);
+	PROC_UNLOCK(p);
+}
+
 static inline void
 vmspace_dofree(struct vmspace *vm)
 {
@@ -410,6 +424,7 @@ vmspace_exit(struct thread *td)
 		pmap_activate(td);
 		vmspace_dofree(vm);
 	}
+	vmspace_container_reset(p);
 }
 
 /* Acquire reference to vmspace owned by another process. */
@@ -3279,6 +3294,10 @@ vm_map_growstack(struct proc *p, vm_offs
 	rlim_t stacklim, vmemlim;
 	int is_procstack, rv;
 	struct ucred *cred;
+#ifdef notyet
+	uint64_t limit;
+#endif
+	int error;
 
 Retry:
 	PROC_LOCK(p);
@@ -3377,6 +3396,14 @@ Retry:
 		vm_map_unlock_read(map);
 		return (KERN_NO_SPACE);
 	}
+	PROC_LOCK(p);
+	if (is_procstack &&
+	    racct_set(p, RACCT_STACK, ctob(vm->vm_ssize) + grow_amount)) {
+		PROC_UNLOCK(p);
+		vm_map_unlock_read(map);
+		return (KERN_NO_SPACE);
+	}
+	PROC_UNLOCK(p);
 
 	/* Round up the grow amount modulo SGROWSIZ */
 	grow_amount = roundup (grow_amount, sgrowsiz);
@@ -3386,12 +3413,28 @@ Retry:
 		grow_amount = trunc_page((vm_size_t)stacklim) -
 		    ctob(vm->vm_ssize);
 	}
+#ifdef notyet
+	PROC_LOCK(p);
+	limit = racct_get_available(p, RACCT_STACK);
+	PROC_UNLOCK(p);
+	if (is_procstack && (ctob(vm->vm_ssize) + grow_amount > limit))
+		grow_amount = limit - ctob(vm->vm_ssize);
+#endif
 
 	/* If we would blow our VMEM resource limit, no go */
 	if (map->size + grow_amount > vmemlim) {
 		vm_map_unlock_read(map);
-		return (KERN_NO_SPACE);
+		rv = KERN_NO_SPACE;
+		goto out;
 	}
+	PROC_LOCK(p);
+	if (racct_set(p, RACCT_VMEM, map->size + grow_amount)) {
+		PROC_UNLOCK(p);
+		vm_map_unlock_read(map);
+		rv = KERN_NO_SPACE;
+		goto out;
+	}
+	PROC_UNLOCK(p);
 
 	if (vm_map_lock_upgrade(map))
 		goto Retry;
@@ -3490,6 +3533,16 @@ Retry:
 		    : VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
 	}
 
+out:
+	if (rv != KERN_SUCCESS) {
+		PROC_LOCK(p);
+		error = racct_set(p, RACCT_VMEM, map->size);
+		KASSERT(error == 0, ("decreasing RACCT_VMEM failed"));
+	    	error = racct_set(p, RACCT_STACK, ctob(vm->vm_ssize));
+		KASSERT(error == 0, ("decreasing RACCT_STACK failed"));
+		PROC_UNLOCK(p);
+	}
+
 	return (rv);
 }
 

Modified: head/sys/vm/vm_mmap.c
==============================================================================
--- head/sys/vm/vm_mmap.c	Tue Apr  5 19:50:34 2011	(r220372)
+++ head/sys/vm/vm_mmap.c	Tue Apr  5 20:23:59 2011	(r220373)
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -991,6 +992,7 @@ mlock(td, uap)
 	struct proc *proc;
 	vm_offset_t addr, end, last, start;
 	vm_size_t npages, size;
+	unsigned long nsize;
 	int error;
 
 	error = priv_check(td, PRIV_VM_MLOCK);
@@ -1008,17 +1010,28 @@ mlock(td, uap)
 		return (ENOMEM);
 	proc = td->td_proc;
 	PROC_LOCK(proc);
-	if (ptoa(npages +
-	    pmap_wired_count(vm_map_pmap(&proc->p_vmspace->vm_map))) >
-	    lim_cur(proc, RLIMIT_MEMLOCK)) {
+	nsize = ptoa(npages +
+	    pmap_wired_count(vm_map_pmap(&proc->p_vmspace->vm_map)));
+	if (nsize > lim_cur(proc, RLIMIT_MEMLOCK)) {
 		PROC_UNLOCK(proc);
 		return (ENOMEM);
 	}
 	PROC_UNLOCK(proc);
 	if (npages + cnt.v_wire_count > vm_page_max_wired)
 		return (EAGAIN);
+	PROC_LOCK(proc);
+	error = racct_set(proc, RACCT_MEMLOCK, nsize);
+	PROC_UNLOCK(proc);
+	if (error != 0)
+		return (ENOMEM);
 	error = vm_map_wire(&proc->p_vmspace->vm_map, start, end,
 	    VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
+	if (error != KERN_SUCCESS) {
+		PROC_LOCK(proc);
+		racct_set(proc, RACCT_MEMLOCK,
+		    ptoa(pmap_wired_count(vm_map_pmap(&proc->p_vmspace->vm_map))));
+		PROC_UNLOCK(proc);
+	}
 	return (error == KERN_SUCCESS ? 0 : ENOMEM);
 }
 
@@ -1061,6 +1074,11 @@ mlockall(td, uap)
 	if (error)
 		return (error);
 #endif
+	PROC_LOCK(td->td_proc);
+	error = racct_set(td->td_proc, RACCT_MEMLOCK, map->size);
+	PROC_UNLOCK(td->td_proc);
+	if (error != 0)
+		return (ENOMEM);
 
 	if (uap->how & MCL_FUTURE) {
 		vm_map_lock(map);
@@ -1080,6 +1098,12 @@ mlockall(td, uap)
 		    VM_MAP_WIRE_USER|VM_MAP_WIRE_HOLESOK);
 		error = (error == KERN_SUCCESS ? 0 : EAGAIN);
 	}
+	if (error != KERN_SUCCESS) {
+		PROC_LOCK(td->td_proc);
+		racct_set(td->td_proc, RACCT_MEMLOCK,
+		    ptoa(pmap_wired_count(vm_map_pmap(&td->td_proc->p_vmspace->vm_map))));
+		PROC_UNLOCK(td->td_proc);
+	}
 
 	return (error);
 }
@@ -1114,6 +1138,11 @@ munlockall(td, uap)
 	/* Forcibly unwire all pages. */
 	error = vm_map_unwire(map, vm_map_min(map), vm_map_max(map),
 	    VM_MAP_WIRE_USER|VM_MAP_WIRE_HOLESOK);
+	if (error == KERN_SUCCESS) {
+		PROC_LOCK(td->td_proc);
+		racct_set(td->td_proc, RACCT_MEMLOCK, 0);
+		PROC_UNLOCK(td->td_proc);
+	}
 
 	return (error);
 }
@@ -1148,6 +1177,11 @@ munlock(td, uap)
 		return (EINVAL);
 	error = vm_map_unwire(&td->td_proc->p_vmspace->vm_map, start, end,
 	    VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
+	if (error == KERN_SUCCESS) {
+		PROC_LOCK(td->td_proc);
+		racct_sub(td->td_proc, RACCT_MEMLOCK, ptoa(end - start));
+		PROC_UNLOCK(td->td_proc);
+	}
 	return (error == KERN_SUCCESS ? 0 : ENOMEM);
 }
 
@@ -1380,6 +1414,11 @@ vm_mmap(vm_map_t map, vm_offset_t *addr,
 		PROC_UNLOCK(td->td_proc);
 		return(ENOMEM);
 	}
+	if (racct_set(td->td_proc, RACCT_VMEM,
+	    td->td_proc->p_vmspace->vm_map.size + size)) {
+		PROC_UNLOCK(td->td_proc);
+		return (ENOMEM);
+	}
 	PROC_UNLOCK(td->td_proc);
 
 	/*

Modified: head/sys/vm/vm_unix.c
==============================================================================
--- head/sys/vm/vm_unix.c	Tue Apr  5 19:50:34 2011	(r220372)
+++ head/sys/vm/vm_unix.c	Tue Apr  5 20:23:59 2011	(r220373)
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -116,9 +117,29 @@ obreak(td, uap)
 			error = ENOMEM;
 			goto done;
 		}
+		PROC_LOCK(td->td_proc);
+		error = racct_set(td->td_proc, RACCT_DATA, new - base);
+		if (error != 0) {
+			PROC_UNLOCK(td->td_proc);
+			error = ENOMEM;
+			goto done;
+		}
+		error = racct_set(td->td_proc, RACCT_VMEM,
+		    vm->vm_map.size + (new - old));
+		if (error != 0) {
+			racct_set_force(td->td_proc, RACCT_DATA, old - base);
+			PROC_UNLOCK(td->td_proc);
+			error = ENOMEM;
+			goto done;
+		}
+		PROC_UNLOCK(td->td_proc);
 		rv = vm_map_insert(&vm->vm_map, NULL, 0, old, new,
 		    VM_PROT_RW, VM_PROT_ALL, 0);
 		if (rv != KERN_SUCCESS) {
+			PROC_LOCK(td->td_proc);
+			racct_set_force(td->td_proc, RACCT_DATA, old - base);
+			racct_set_force(td->td_proc, RACCT_VMEM, vm->vm_map.size);
+			PROC_UNLOCK(td->td_proc);
 			error = ENOMEM;
 			goto done;
 		}
@@ -144,6 +165,10 @@ obreak(td, uap)
 			goto done;
 		}
 		vm->vm_dsize -= btoc(old - new);
+		PROC_LOCK(td->td_proc);
+		racct_set_force(td->td_proc, RACCT_DATA, new - base);
+		racct_set_force(td->td_proc, RACCT_VMEM, vm->vm_map.size);
+		PROC_UNLOCK(td->td_proc);
 	}
 done:
 	vm_map_unlock(&vm->vm_map);

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 21:26:05 2011
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 B62AC1065670;
	Tue,  5 Apr 2011 21:26:05 +0000 (UTC)
	(envelope-from mckusick@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A59DA8FC1B;
	Tue,  5 Apr 2011 21:26:05 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35LQ5Tg031071;
	Tue, 5 Apr 2011 21:26:05 GMT (envelope-from mckusick@svn.freebsd.org)
Received: (from mckusick@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35LQ592031067;
	Tue, 5 Apr 2011 21:26:05 GMT (envelope-from mckusick@svn.freebsd.org)
Message-Id: <201104052126.p35LQ592031067@svn.freebsd.org>
From: Kirk McKusick 
Date: Tue, 5 Apr 2011 21:26:05 +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: r220374 - 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: Tue, 05 Apr 2011 21:26:05 -0000

Author: mckusick
Date: Tue Apr  5 21:26:05 2011
New Revision: 220374
URL: http://svn.freebsd.org/changeset/base/220374

Log:
  Be far more persistent in reclaiming blocks and inodes before giving
  up and declaring a filesystem out of space. Especially necessary when
  running on a small filesystem. With this improvement, it should be
  possible to use soft updates on a small root filesystem.
  
  Kudos to: Peter Holm
  Testing by: Peter Holm
  MFC: 2 weeks

Modified:
  head/sys/ufs/ffs/ffs_alloc.c
  head/sys/ufs/ffs/ffs_extern.h
  head/sys/ufs/ffs/ffs_softdep.c

Modified: head/sys/ufs/ffs/ffs_alloc.c
==============================================================================
--- head/sys/ufs/ffs/ffs_alloc.c	Tue Apr  5 20:23:59 2011	(r220373)
+++ head/sys/ufs/ffs/ffs_alloc.c	Tue Apr  5 21:26:05 2011	(r220374)
@@ -217,9 +217,9 @@ nospace:
 	(void) chkdq(ip, -btodb(size), cred, FORCE);
 	UFS_LOCK(ump);
 #endif
-	if (fs->fs_pendingblocks > 0 && reclaimed == 0) {
+	if (reclaimed == 0) {
 		reclaimed = 1;
-		softdep_request_cleanup(fs, ITOV(ip), FLUSH_BLOCKS_WAIT);
+		softdep_request_cleanup(fs, ITOV(ip), cred, FLUSH_BLOCKS_WAIT);
 		goto retry;
 	}
 	UFS_UNLOCK(ump);
@@ -418,9 +418,9 @@ nospace:
 	/*
 	 * no space available
 	 */
-	if (fs->fs_pendingblocks > 0 && reclaimed == 0) {
+	if (reclaimed == 0) {
 		reclaimed = 1;
-		softdep_request_cleanup(fs, vp, FLUSH_BLOCKS_WAIT);
+		softdep_request_cleanup(fs, vp, cred, FLUSH_BLOCKS_WAIT);
 		UFS_UNLOCK(ump);
 		if (bp) {
 			brelse(bp);
@@ -1023,7 +1023,7 @@ dup_alloc:
 noinodes:
 	if (fs->fs_pendinginodes > 0 && reclaimed == 0) {
 		reclaimed = 1;
-		softdep_request_cleanup(fs, pvp, FLUSH_INODES_WAIT);
+		softdep_request_cleanup(fs, pvp, cred, FLUSH_INODES_WAIT);
 		goto retry;
 	}
 	UFS_UNLOCK(ump);

Modified: head/sys/ufs/ffs/ffs_extern.h
==============================================================================
--- head/sys/ufs/ffs/ffs_extern.h	Tue Apr  5 20:23:59 2011	(r220373)
+++ head/sys/ufs/ffs/ffs_extern.h	Tue Apr  5 21:26:05 2011	(r220374)
@@ -120,7 +120,8 @@ int	softdep_flushfiles(struct mount *, i
 void	softdep_update_inodeblock(struct inode *, struct buf *, int);
 void	softdep_load_inodeblock(struct inode *);
 void	softdep_freefile(struct vnode *, ino_t, int);
-int	softdep_request_cleanup(struct fs *, struct vnode *, int);
+int	softdep_request_cleanup(struct fs *, struct vnode *,
+	    struct ucred *, int);
 void	softdep_setup_freeblocks(struct inode *, off_t, int);
 void	softdep_setup_inomapdep(struct buf *, struct inode *, ino_t);
 void	softdep_setup_blkmapdep(struct buf *, struct mount *, ufs2_daddr_t,

Modified: head/sys/ufs/ffs/ffs_softdep.c
==============================================================================
--- head/sys/ufs/ffs/ffs_softdep.c	Tue Apr  5 20:23:59 2011	(r220373)
+++ head/sys/ufs/ffs/ffs_softdep.c	Tue Apr  5 21:26:05 2011	(r220374)
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -514,9 +515,10 @@ softdep_releasefile(ip)
 }
 
 int
-softdep_request_cleanup(fs, vp, resource)
+softdep_request_cleanup(fs, vp, cred, resource)
 	struct fs *fs;
 	struct vnode *vp;
+	struct ucred *cred;
 	int resource;
 {
 
@@ -1131,6 +1133,11 @@ static int stat_jwait_filepage;	/* Times
 static int stat_jwait_freeblks;	/* Times blocked in jwait() for freeblks. */
 static int stat_jwait_inode;	/* Times blocked in jwait() for inodes. */
 static int stat_jwait_newblk;	/* Times blocked in jwait() for newblks. */
+static int stat_cleanup_high_delay; /* Maximum cleanup delay (in ticks) */
+static int stat_cleanup_blkrequests; /* Number of block cleanup requests */
+static int stat_cleanup_inorequests; /* Number of inode cleanup requests */
+static int stat_cleanup_retries; /* Number of cleanups that needed to flush */
+static int stat_cleanup_failures; /* Number of cleanup requests that failed */
 
 SYSCTL_INT(_debug_softdep, OID_AUTO, max_softdeps, CTLFLAG_RW,
     &max_softdeps, 0, "");
@@ -1176,6 +1183,16 @@ SYSCTL_INT(_debug_softdep, OID_AUTO, jwa
     &stat_jwait_inode, 0, "");
 SYSCTL_INT(_debug_softdep, OID_AUTO, jwait_newblk, CTLFLAG_RW,
     &stat_jwait_newblk, 0, "");
+SYSCTL_INT(_debug_softdep, OID_AUTO, cleanup_blkrequests, CTLFLAG_RW,
+    &stat_cleanup_blkrequests, 0, "");
+SYSCTL_INT(_debug_softdep, OID_AUTO, cleanup_inorequests, CTLFLAG_RW,
+    &stat_cleanup_inorequests, 0, "");
+SYSCTL_INT(_debug_softdep, OID_AUTO, cleanup_high_delay, CTLFLAG_RW,
+    &stat_cleanup_high_delay, 0, "");
+SYSCTL_INT(_debug_softdep, OID_AUTO, cleanup_retries, CTLFLAG_RW,
+    &stat_cleanup_retries, 0, "");
+SYSCTL_INT(_debug_softdep, OID_AUTO, cleanup_failures, CTLFLAG_RW,
+    &stat_cleanup_failures, 0, "");
 
 SYSCTL_DECL(_vfs_ffs);
 
@@ -10879,29 +10896,29 @@ softdep_slowdown(vp)
  * Because this process holds inodes locked, we cannot handle any remove
  * requests that might block on a locked inode as that could lead to
  * deadlock. If the worklist yields none of the requested resource,
- * encourage the syncer daemon to help us. In no event will we try for
- * longer than tickdelay seconds.
+ * start syncing out vnodes to free up the needed space.
  */
 int
-softdep_request_cleanup(fs, vp, resource)
+softdep_request_cleanup(fs, vp, cred, resource)
 	struct fs *fs;
 	struct vnode *vp;
+	struct ucred *cred;
 	int resource;
 {
 	struct ufsmount *ump;
+	struct mount *mp;
+	struct vnode *lvp, *mvp;
 	long starttime;
 	ufs2_daddr_t needed;
 	int error;
 
+	mp = vp->v_mount;
 	ump = VTOI(vp)->i_ump;
 	mtx_assert(UFS_MTX(ump), MA_OWNED);
 	if (resource == FLUSH_BLOCKS_WAIT)
-		needed = fs->fs_cstotal.cs_nbfree + fs->fs_contigsumsize;
-	else if (resource == FLUSH_INODES_WAIT)
-		needed = fs->fs_cstotal.cs_nifree + 2;
+		stat_cleanup_blkrequests += 1;
 	else
-		return (0);
-	starttime = time_second + tickdelay;
+		stat_cleanup_inorequests += 1;
 	/*
 	 * If we are being called because of a process doing a
 	 * copy-on-write, then it is not safe to update the vnode
@@ -10914,12 +10931,56 @@ softdep_request_cleanup(fs, vp, resource
 		if (error != 0)
 			return (0);
 	}
-	while ((resource == FLUSH_BLOCKS_WAIT && fs->fs_pendingblocks > 0 &&
+	/*
+	 * If we are in need of resources, consider pausing for
+	 * tickdelay to give ourselves some breathing room.
+	 */
+	UFS_UNLOCK(ump);
+	ACQUIRE_LOCK(&lk);
+	request_cleanup(UFSTOVFS(ump), resource);
+	FREE_LOCK(&lk);
+	UFS_LOCK(ump);
+	/*
+	 * Now clean up at least as many resources as we will need.
+	 *
+	 * When requested to clean up inodes, the number that are needed
+	 * is set by the number of simultaneous writers (mnt_writeopcount)
+	 * plus a bit of slop (2) in case some more writers show up while
+	 * we are cleaning.
+	 *
+	 * When requested to free up space, the amount of space that
+	 * we need is enough blocks to allocate a full-sized segment
+	 * (fs_contigsumsize). The number of such segments that will
+	 * be needed is set by the number of simultaneous writers
+	 * (mnt_writeopcount) plus a bit of slop (2) in case some more
+	 * writers show up while we are cleaning.
+	 *
+	 * Additionally, if we are unpriviledged and allocating space,
+	 * we need to ensure that we clean up enough blocks to get the
+	 * needed number of blocks over the threshhold of the minimum
+	 * number of blocks required to be kept free by the filesystem
+	 * (fs_minfree).
+	 */
+	if (resource == FLUSH_INODES_WAIT) {
+		needed = vp->v_mount->mnt_writeopcount + 2;
+	} else if (resource == FLUSH_BLOCKS_WAIT) {
+		needed = (vp->v_mount->mnt_writeopcount + 2) *
+		    fs->fs_contigsumsize;
+		if (priv_check_cred(cred, PRIV_VFS_BLOCKRESERVE, 0))
+			needed += fragstoblks(fs,
+			    roundup((fs->fs_dsize * fs->fs_minfree / 100) -
+			    fs->fs_cstotal.cs_nffree, fs->fs_frag));
+	} else {
+		printf("softdep_request_cleanup: Unknown resource type %d\n",
+		    resource);
+		return (0);
+	}
+	starttime = time_second;
+retry:
+	while ((resource == FLUSH_BLOCKS_WAIT && ump->softdep_on_worklist > 0 &&
 		fs->fs_cstotal.cs_nbfree <= needed) ||
 	       (resource == FLUSH_INODES_WAIT && fs->fs_pendinginodes > 0 &&
 		fs->fs_cstotal.cs_nifree <= needed)) {
-		if (time_second > starttime)
-			return (0);
 		UFS_UNLOCK(ump);
 		ACQUIRE_LOCK(&lk);
 		process_removes(vp);
@@ -10930,10 +10991,60 @@ softdep_request_cleanup(fs, vp, resource
 			UFS_LOCK(ump);
 			continue;
 		}
-		request_cleanup(UFSTOVFS(ump), resource);
 		FREE_LOCK(&lk);
 		UFS_LOCK(ump);
 	}
+	/*
+	 * If we still need resources and there are no more worklist
+	 * entries to process to obtain them, we have to start flushing
+	 * the dirty vnodes to force the release of additional requests
+	 * to the worklist that we can then process to reap addition
+	 * resources. We walk the vnodes associated with the mount point
+	 * until we get the needed worklist requests that we can reap.
+	 */
+	if ((resource == FLUSH_BLOCKS_WAIT && 
+	     fs->fs_cstotal.cs_nbfree <= needed) ||
+	    (resource == FLUSH_INODES_WAIT && fs->fs_pendinginodes > 0 &&
+	     fs->fs_cstotal.cs_nifree <= needed)) {
+		UFS_UNLOCK(ump);
+		MNT_ILOCK(mp);
+		MNT_VNODE_FOREACH(lvp, mp, mvp) {
+			UFS_LOCK(ump);
+			if (ump->softdep_on_worklist > 0) {
+				UFS_UNLOCK(ump);
+				MNT_VNODE_FOREACH_ABORT_ILOCKED(mp, mvp);
+				MNT_IUNLOCK(mp);
+				UFS_LOCK(ump);
+				stat_cleanup_retries += 1;
+				goto retry;
+			}
+			UFS_UNLOCK(ump);
+			VI_LOCK(lvp);
+			if (TAILQ_FIRST(&lvp->v_bufobj.bo_dirty.bv_hd) == 0 ||
+			    VOP_ISLOCKED(lvp) != 0) {
+				VI_UNLOCK(lvp);
+				continue;
+			}
+			MNT_IUNLOCK(mp);
+			if (vget(lvp, LK_EXCLUSIVE | LK_INTERLOCK, curthread)) {
+				MNT_ILOCK(mp);
+				continue;
+			}
+			if (lvp->v_vflag & VV_NOSYNC) {	/* unlinked */
+				vput(lvp);
+				MNT_ILOCK(mp);
+				continue;
+			}
+			(void) ffs_syncvnode(lvp, MNT_WAIT);
+			vput(lvp);
+			MNT_ILOCK(mp);
+		}
+		MNT_IUNLOCK(mp);
+		stat_cleanup_failures += 1;
+		UFS_LOCK(ump);
+	}
+	if (time_second - starttime > stat_cleanup_high_delay)
+		stat_cleanup_high_delay = time_second - starttime;
 	return (1);
 }
 

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 21:55:43 2011
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 96B4F106564A;
	Tue,  5 Apr 2011 21:55:43 +0000 (UTC) (envelope-from jfv@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 860D68FC0A;
	Tue,  5 Apr 2011 21:55:43 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35LthEO031770;
	Tue, 5 Apr 2011 21:55:43 GMT (envelope-from jfv@svn.freebsd.org)
Received: (from jfv@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35Lthob031767;
	Tue, 5 Apr 2011 21:55:43 GMT (envelope-from jfv@svn.freebsd.org)
Message-Id: <201104052155.p35Lthob031767@svn.freebsd.org>
From: Jack F Vogel 
Date: Tue, 5 Apr 2011 21:55: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: r220375 - head/sys/dev/e1000
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, 05 Apr 2011 21:55:43 -0000

Author: jfv
Date: Tue Apr  5 21:55:43 2011
New Revision: 220375
URL: http://svn.freebsd.org/changeset/base/220375

Log:
  Important update for the igb driver:
    - Add the change made in em to the actual unrefreshed number
      of descriptors is used as a basis in rxeof on the way out
      to determine if more refresh is needed. NOTE: there is a
      difference in the ring setup in igb, this is not accidental,
      it is necessitated by hardware behavior, when you reset the
      newer adapters it will not let you write RDH, it ALWAYS sets
      it to 0. Thus the way em does it is not possible.
    - Change the sysctl handling of flow control, it will now make
      the change dynamically when the variable setting changes rather
      than requiring a reset.
    - Change the eee sysctl naming, validation found the old unintuitive :)
    - Last but not least, some important performance tweaks in the TX
      path, I found that UDP behavior could be drastically hindered or
      improved with just small changes in the start loop. What I have
      here is what testing has shown to be the best overall. Its interesting
      to note that changing the clean threshold to start at a full half of
      the ring, made a BIG difference in performance.  I hope that this
      will prove to be advantageous for most workloads.
  
  MFC in a week.

Modified:
  head/sys/dev/e1000/if_igb.c
  head/sys/dev/e1000/if_igb.h

Modified: head/sys/dev/e1000/if_igb.c
==============================================================================
--- head/sys/dev/e1000/if_igb.c	Tue Apr  5 21:26:05 2011	(r220374)
+++ head/sys/dev/e1000/if_igb.c	Tue Apr  5 21:55:43 2011	(r220375)
@@ -1,6 +1,6 @@
 /******************************************************************************
 
-  Copyright (c) 2001-2010, Intel Corporation 
+  Copyright (c) 2001-2011, Intel Corporation 
   All rights reserved.
   
   Redistribution and use in source and binary forms, with or without 
@@ -99,7 +99,7 @@ int	igb_display_debug_stats = 0;
 /*********************************************************************
  *  Driver version:
  *********************************************************************/
-char igb_driver_version[] = "version - 2.1.7";
+char igb_driver_version[] = "version - 2.2.3";
 
 
 /*********************************************************************
@@ -262,6 +262,7 @@ static void	igb_handle_link(void *contex
 
 static void	igb_set_sysctl_value(struct adapter *, const char *,
 		    const char *, int *, int);
+static int	igb_set_flowcntl(SYSCTL_HANDLER_ARGS);
 
 #ifdef DEVICE_POLLING
 static poll_handler_t igb_poll;
@@ -350,8 +351,8 @@ static int igb_fc_setting = e1000_fc_ful
 TUNABLE_INT("hw.igb.fc_setting", &igb_fc_setting);
 
 /* Energy Efficient Ethernet - default to off */
-static int igb_eee_setting = FALSE;
-TUNABLE_INT("hw.igb.ee_setting", &igb_eee_setting);
+static int igb_eee_disabled = TRUE;
+TUNABLE_INT("hw.igb.eee_disabled", &igb_eee_disabled);
 
 /*
 ** DMA Coalescing, only for i350 - default to off,
@@ -445,6 +446,11 @@ igb_attach(device_t dev)
 	    OID_AUTO, "enable_aim", CTLTYPE_INT|CTLFLAG_RW,
 	    &igb_enable_aim, 1, "Interrupt Moderation");
 
+	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
+	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+	    OID_AUTO, "flow_control", CTLTYPE_INT|CTLFLAG_RW,
+	    adapter, 0, igb_set_flowcntl, "I", "Flow Control");
+
 	callout_init_mtx(&adapter->timer, &adapter->core_mtx, 0);
 
 	/* Determine hardware and mac info */
@@ -471,11 +477,6 @@ igb_attach(device_t dev)
 	    "max number of rx packets to process", &adapter->rx_process_limit,
 	    igb_rx_process_limit);
 
-       /* Sysctl for setting the interface flow control */
-	igb_set_sysctl_value(adapter, "flow_control",
-	    "configure flow control",
-	    &adapter->fc_setting, igb_fc_setting);
-
 	/*
 	 * Validate number of transmit and receive descriptors. It
 	 * must not exceed hardware maximum, and must be multiple
@@ -552,10 +553,10 @@ igb_attach(device_t dev)
 		igb_set_sysctl_value(adapter, "dma_coalesce",
 		    "configure dma coalesce",
 		    &adapter->dma_coalesce, igb_dma_coalesce);
-		igb_set_sysctl_value(adapter, "eee_control",
+		igb_set_sysctl_value(adapter, "eee_disabled",
 		    "enable Energy Efficient Ethernet",
 		    &adapter->hw.dev_spec._82575.eee_disable,
-		    igb_eee_setting);
+		    igb_eee_disabled);
 		e1000_set_eee_i350(&adapter->hw);
 	}
 
@@ -822,11 +823,12 @@ igb_start_locked(struct tx_ring *txr, st
 	if (!adapter->link_active)
 		return;
 
+	/* Call cleanup if number of TX descriptors low */
+	if (txr->tx_avail <= IGB_TX_CLEANUP_THRESHOLD)
+		igb_txeof(txr);
+
 	while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) {
-		/* Cleanup if TX descriptors are low */
-		if (txr->tx_avail <= IGB_TX_CLEANUP_THRESHOLD)
-			igb_txeof(txr);
-		if (txr->tx_avail <= IGB_TX_OP_THRESHOLD) {
+		if (txr->tx_avail <= IGB_MAX_SCATTER) {
 			ifp->if_drv_flags |= IFF_DRV_OACTIVE;
 			break;
 		}
@@ -932,13 +934,6 @@ igb_mq_start_locked(struct ifnet *ifp, s
 
 	/* Process the queue */
 	while (next != NULL) {
-		/* Call cleanup if number of TX descriptors low */
-		if (txr->tx_avail <= IGB_TX_CLEANUP_THRESHOLD)
-			igb_txeof(txr);
-		if (txr->tx_avail <= IGB_TX_OP_THRESHOLD) {
-			ifp->if_drv_flags |= IFF_DRV_OACTIVE;
-			break;
-		}
 		if ((err = igb_xmit(txr, &next)) != 0) {
 			if (next != NULL)
 				err = drbr_enqueue(ifp, txr->br, next);
@@ -949,6 +944,12 @@ igb_mq_start_locked(struct ifnet *ifp, s
 		ETHER_BPF_MTAP(ifp, next);
 		if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
 			break;
+		if (txr->tx_avail <= IGB_TX_CLEANUP_THRESHOLD)
+			igb_txeof(txr);
+		if (txr->tx_avail <= IGB_MAX_SCATTER) {
+			ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+			break;
+		}
 		next = drbr_dequeue(ifp, txr->br);
 	}
 	if (enq > 0) {
@@ -1266,10 +1267,13 @@ igb_init_locked(struct adapter *adapter)
 	else
 #endif /* DEVICE_POLLING */
 	{
-	igb_enable_intr(adapter);
-	E1000_WRITE_REG(&adapter->hw, E1000_ICS, E1000_ICS_LSC);
+		igb_enable_intr(adapter);
+		E1000_WRITE_REG(&adapter->hw, E1000_ICS, E1000_ICS_LSC);
 	}
 
+	/* Set Energy Efficient Ethernet */
+	e1000_set_eee_i350(&adapter->hw);
+
 	/* Don't reset the phy next time init gets called */
 	adapter->hw.phy.reset_disable = TRUE;
 }
@@ -1458,10 +1462,6 @@ igb_msix_que(void *arg)
 	more_tx = igb_txeof(txr);
 	IGB_TX_UNLOCK(txr);
 
-	/* If RX ring is depleted do refresh first */
-	if (rxr->next_to_check == rxr->next_to_refresh)
-		igb_refresh_mbufs(rxr, rxr->next_to_check);
-
 	more_rx = igb_rxeof(que, adapter->rx_process_limit, NULL);
 
 	if (igb_enable_aim == FALSE)
@@ -2670,14 +2670,6 @@ igb_reset(struct adapter *adapter)
 	fc->pause_time = IGB_FC_PAUSE_TIME;
 	fc->send_xon = TRUE;
 
-	/* Set Flow control, use the tunable location if sane */
-	if ((igb_fc_setting >= 0) && (igb_fc_setting < 4))
-		fc->requested_mode = adapter->fc_setting;
-	else
-		fc->requested_mode = e1000_fc_none;
-
-	fc->current_mode = fc->requested_mode;
-
 	/* Issue a global reset */
 	e1000_reset_hw(hw);
 	E1000_WRITE_REG(hw, E1000_WUC, 0);
@@ -2864,7 +2856,7 @@ igb_dma_malloc(struct adapter *adapter, 
 	}
 
 	error = bus_dmamem_alloc(dma->dma_tag, (void**) &dma->dma_vaddr,
-	    BUS_DMA_NOWAIT, &dma->dma_map);
+	    BUS_DMA_NOWAIT | BUS_DMA_COHERENT, &dma->dma_map);
 	if (error) {
 		device_printf(adapter->dev,
 		    "%s: bus_dmamem_alloc(%ju) failed: %d\n",
@@ -3631,19 +3623,17 @@ igb_txeof(struct tx_ring *txr)
          * If we have a minimum free, clear IFF_DRV_OACTIVE
          * to tell the stack that it is OK to send packets.
          */
-        if (txr->tx_avail > IGB_TX_OP_THRESHOLD)               
+        if (txr->tx_avail > IGB_TX_CLEANUP_THRESHOLD) {                
                 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
-
-	/* All clean, turn off the watchdog */
-	if (txr->tx_avail == adapter->num_tx_desc) {
-		txr->queue_status = IGB_QUEUE_IDLE;
-		return (FALSE);
-	}
-
+		/* All clean, turn off the watchdog */
+                if (txr->tx_avail == adapter->num_tx_desc) {
+			txr->queue_status = IGB_QUEUE_IDLE;
+			return (FALSE);
+		}
+        }
 	return (TRUE);
 }
 
-
 /*********************************************************************
  *
  *  Refresh mbuf buffers for RX descriptor rings
@@ -3830,13 +3820,11 @@ fail:
 static void
 igb_free_receive_ring(struct rx_ring *rxr)
 {
-	struct	adapter		*adapter;
+	struct	adapter		*adapter = rxr->adapter;
 	struct igb_rx_buf	*rxbuf;
-	int i;
 
-	adapter = rxr->adapter;
-	i = rxr->next_to_check;
-	while (i != rxr->next_to_refresh) {
+
+	for (int i = 0; i < adapter->num_rx_desc; i++) {
 		rxbuf = &rxr->rx_buffers[i];
 		if (rxbuf->m_head != NULL) {
 			bus_dmamap_sync(rxr->htag, rxbuf->hmap,
@@ -3854,12 +3842,7 @@ igb_free_receive_ring(struct rx_ring *rx
 		}
 		rxbuf->m_head = NULL;
 		rxbuf->m_pack = NULL;
-
-		if (++i == adapter->num_rx_desc)
-			i = 0;
 	}
-	rxr->next_to_check = 0;
-	rxr->next_to_refresh = 0;
 }
 
 
@@ -3877,33 +3860,32 @@ igb_setup_receive_ring(struct rx_ring *r
 	struct igb_rx_buf	*rxbuf;
 	bus_dma_segment_t	pseg[1], hseg[1];
 	struct lro_ctrl		*lro = &rxr->lro;
-	int			i, j, nsegs, error = 0;
+	int			rsize, nsegs, error = 0;
 
 	adapter = rxr->adapter;
 	dev = adapter->dev;
 	ifp = adapter->ifp;
 
+	/* Clear the ring contents */
 	IGB_RX_LOCK(rxr);
-	/* Invalidate all descriptors */
-	for (i = 0; i < adapter->num_rx_desc; i++) {
-		union e1000_adv_rx_desc* cur;
-		cur = &rxr->rx_base[i];
-		cur->wb.upper.status_error = 0;
-        }
+	rsize = roundup2(adapter->num_rx_desc *
+	    sizeof(union e1000_adv_rx_desc), IGB_DBA_ALIGN);
+	bzero((void *)rxr->rx_base, rsize);
+
+	/*
+	** Free current RX buffer structures and their mbufs
+	*/
+	igb_free_receive_ring(rxr);
 
 	/* Configure for header split? */
 	if (igb_header_split)
 		rxr->hdr_split = TRUE;
 
-        /* Get our indices */
-	i = j = rxr->next_to_refresh;
-	if (++j == adapter->num_rx_desc)
-		j = 0;
         /* Now replenish the ring mbufs */
-	while (j != rxr->next_to_check) {
+	for (int j = 0; j < adapter->num_rx_desc; ++j) {
 		struct mbuf	*mh, *mp;
 
-		rxbuf = &rxr->rx_buffers[i];
+		rxbuf = &rxr->rx_buffers[j];
 		if (rxr->hdr_split == FALSE)
 			goto skip_head;
 
@@ -3926,7 +3908,7 @@ igb_setup_receive_ring(struct rx_ring *r
 		bus_dmamap_sync(rxr->htag,
 		    rxbuf->hmap, BUS_DMASYNC_PREREAD);
 		/* Update descriptor */
-		rxr->rx_base[i].read.hdr_addr = htole64(hseg[0].ds_addr);
+		rxr->rx_base[j].read.hdr_addr = htole64(hseg[0].ds_addr);
 
 skip_head:
 		/* Now the payload cluster */
@@ -3947,16 +3929,12 @@ skip_head:
 		bus_dmamap_sync(rxr->ptag,
 		    rxbuf->pmap, BUS_DMASYNC_PREREAD);
 		/* Update descriptor */
-		rxr->rx_base[i].read.pkt_addr = htole64(pseg[0].ds_addr);
-
-		/* Setup for next loop */
-		i = j;
-		if (++j == adapter->num_rx_desc)
-			j = 0;
+		rxr->rx_base[j].read.pkt_addr = htole64(pseg[0].ds_addr);
         }
 
 	/* Setup our descriptor indices */
-	rxr->next_to_refresh = i;
+	rxr->next_to_check = 0;
+	rxr->next_to_refresh = adapter->num_rx_desc - 1;
 	rxr->lro_enabled = FALSE;
 	rxr->rx_split_packets = 0;
 	rxr->rx_bytes = 0;
@@ -3989,12 +3967,12 @@ skip_head:
 	return (0);
 
 fail:
-	rxr->next_to_refresh = i;
 	igb_free_receive_ring(rxr);
 	IGB_RX_UNLOCK(rxr);
 	return (error);
 }
 
+
 /*********************************************************************
  *
  *  Initialize all receive rings.
@@ -4528,7 +4506,7 @@ next_desc:
 	}
 
 	/* Catch any remainders */
-	if (processed != 0 || i == rxr->next_to_refresh)
+	if (igb_rx_unrefreshed(rxr))
 		igb_refresh_mbufs(rxr, i);
 
 	rxr->next_to_check = i;
@@ -5552,3 +5530,38 @@ igb_set_sysctl_value(struct adapter *ada
 	    OID_AUTO, name, CTLTYPE_INT|CTLFLAG_RW, limit, value, description);
 }
 
+/*
+** Set flow control using sysctl:
+** Flow control values:
+** 	0 - off
+**	1 - rx pause
+**	2 - tx pause
+**	3 - full
+*/
+static int
+igb_set_flowcntl(SYSCTL_HANDLER_ARGS)
+{
+	int error;
+	struct adapter *adapter;
+
+	error = sysctl_handle_int(oidp, &igb_fc_setting, 0, req);
+
+	if (error)
+		return (error);
+
+	adapter = (struct adapter *) arg1;
+	switch (igb_fc_setting) {
+		case e1000_fc_rx_pause:
+		case e1000_fc_tx_pause:
+		case e1000_fc_full:
+			adapter->hw.fc.requested_mode = igb_fc_setting;
+			break;
+		case e1000_fc_none:
+		default:
+			adapter->hw.fc.requested_mode = e1000_fc_none;
+	}
+
+	adapter->hw.fc.current_mode = adapter->hw.fc.requested_mode;
+	e1000_force_mac_fc(&adapter->hw);
+	return error;
+}

Modified: head/sys/dev/e1000/if_igb.h
==============================================================================
--- head/sys/dev/e1000/if_igb.h	Tue Apr  5 21:26:05 2011	(r220374)
+++ head/sys/dev/e1000/if_igb.h	Tue Apr  5 21:55:43 2011	(r220375)
@@ -1,6 +1,6 @@
 /******************************************************************************
 
-  Copyright (c) 2001-2010, Intel Corporation 
+  Copyright (c) 2001-2011, Intel Corporation 
   All rights reserved.
   
   Redistribution and use in source and binary forms, with or without 
@@ -132,10 +132,9 @@
 
 /*
  * This parameter controls when the driver calls the routine to reclaim
- * transmit descriptors.
+ * transmit descriptors. Cleaning earlier seems a win.
  */
-#define IGB_TX_CLEANUP_THRESHOLD	(adapter->num_tx_desc / 8)
-#define IGB_TX_OP_THRESHOLD	(adapter->num_tx_desc / 32)
+#define IGB_TX_CLEANUP_THRESHOLD	(adapter->num_tx_desc / 2)
 
 /*
  * This parameter controls whether or not autonegotation is enabled.
@@ -400,7 +399,6 @@ struct adapter {
 	u16		link_speed;
 	u16		link_duplex;
 	u32		smartspeed;
-	u32		fc_setting;
 	u32		dma_coalesce;
 
 	/* Interface queues */
@@ -483,6 +481,21 @@ struct igb_rx_buf {
 	bus_dmamap_t	pmap;	/* bus_dma map for packet */
 };
 
+/*
+** Find the number of unrefreshed RX descriptors
+*/
+static inline u16
+igb_rx_unrefreshed(struct rx_ring *rxr)
+{
+	struct adapter  *adapter = rxr->adapter;
+ 
+	if (rxr->next_to_check > rxr->next_to_refresh)
+		return (rxr->next_to_check - rxr->next_to_refresh - 1);
+	else
+		return ((adapter->num_rx_desc + rxr->next_to_check) -
+		    rxr->next_to_refresh - 1);
+}
+
 #define	IGB_CORE_LOCK_INIT(_sc, _name) \
 	mtx_init(&(_sc)->core_mtx, _name, "IGB Core Lock", MTX_DEF)
 #define	IGB_CORE_LOCK_DESTROY(_sc)	mtx_destroy(&(_sc)->core_mtx)

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 21:56:05 2011
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 C992B1065676;
	Tue,  5 Apr 2011 21:56:05 +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 B88198FC18;
	Tue,  5 Apr 2011 21:56:05 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35Lu5dx031819;
	Tue, 5 Apr 2011 21:56:05 GMT (envelope-from jilles@svn.freebsd.org)
Received: (from jilles@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35Lu5uN031814;
	Tue, 5 Apr 2011 21:56:05 GMT (envelope-from jilles@svn.freebsd.org)
Message-Id: <201104052156.p35Lu5uN031814@svn.freebsd.org>
From: Jilles Tjoelker 
Date: Tue, 5 Apr 2011 21:56:05 +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: r220376 - in head: lib/libc/gen lib/libc/string
	tools/regression/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: Tue, 05 Apr 2011 21:56:06 -0000

Author: jilles
Date: Tue Apr  5 21:56:05 2011
New Revision: 220376
URL: http://svn.freebsd.org/changeset/base/220376

Log:
  Allow strerror(0) and strerror_r(0, ...).
  
  Of course, strerror_r() may still fail with ERANGE.
  
  Although the POSIX specification said this could fail with EINVAL and
  doing this likely indicates invalid use of errno, most other
  implementations permitted it, various POSIX testsuites require it to
  work (matching the older sys_errlist array) and apparently some
  applications depend on it.
  
  PR:		standards/151316
  MFC after:	1 week

Modified:
  head/lib/libc/gen/errlst.c
  head/lib/libc/string/strerror.3
  head/lib/libc/string/strerror.c
  head/tools/regression/lib/libc/string/test-strerror.c

Modified: head/lib/libc/gen/errlst.c
==============================================================================
--- head/lib/libc/gen/errlst.c	Tue Apr  5 21:55:43 2011	(r220375)
+++ head/lib/libc/gen/errlst.c	Tue Apr  5 21:56:05 2011	(r220376)
@@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 const char *const sys_errlist[] = {
-	"Undefined error: 0",			/*  0 - ENOERROR */
+	"No error: 0",				/*  0 - ENOERROR */
 	"Operation not permitted",		/*  1 - EPERM */
 	"No such file or directory",		/*  2 - ENOENT */
 	"No such process",			/*  3 - ESRCH */

Modified: head/lib/libc/string/strerror.3
==============================================================================
--- head/lib/libc/string/strerror.3	Tue Apr  5 21:55:43 2011	(r220375)
+++ head/lib/libc/string/strerror.3	Tue Apr  5 21:56:05 2011	(r220376)
@@ -32,7 +32,7 @@
 .\"     @(#)strerror.3	8.1 (Berkeley) 6/9/93
 .\" $FreeBSD$
 .\"
-.Dd October 12, 2004
+.Dd April 5, 2011
 .Dt STRERROR 3
 .Os
 .Sh NAME
@@ -114,6 +114,9 @@ the range 0 <
 .Fa errnum
 <
 .Fa sys_nerr .
+The number 0 is also recognized, although applications that take advantage of
+this are likely to use unspecified values of
+.Va errno .
 .Pp
 If insufficient storage is provided in
 .Fa strerrbuf

Modified: head/lib/libc/string/strerror.c
==============================================================================
--- head/lib/libc/string/strerror.c	Tue Apr  5 21:55:43 2011	(r220375)
+++ head/lib/libc/string/strerror.c	Tue Apr  5 21:56:05 2011	(r220376)
@@ -87,7 +87,7 @@ strerror_r(int errnum, char *strerrbuf, 
 	catd = catopen("libc", NL_CAT_LOCALE);
 #endif
 
-	if (errnum < 1 || errnum >= sys_nerr) {
+	if (errnum < 0 || errnum >= sys_nerr) {
 		errstr(errnum,
 #if defined(NLS)
 			catgets(catd, 1, 0xffff, UPREFIX),

Modified: head/tools/regression/lib/libc/string/test-strerror.c
==============================================================================
--- head/tools/regression/lib/libc/string/test-strerror.c	Tue Apr  5 21:55:43 2011	(r220375)
+++ head/tools/regression/lib/libc/string/test-strerror.c	Tue Apr  5 21:56:05 2011	(r220376)
@@ -42,17 +42,12 @@ main(void)
 	char *sret;
 	int iret;
 
-	plan_tests(25);
+	plan_tests(27);
 
 	/*
 	 * strerror() failure tests.
 	 */
 	errno = 0;
-	sret = strerror(0);
-	ok1(strcmp(sret, "Unknown error: 0") == 0);
-	ok1(errno == EINVAL);
-
-	errno = 0;
 	sret = strerror(INT_MAX);
 	snprintf(buf, sizeof(buf), "Unknown error: %d", INT_MAX);
 	ok1(strcmp(sret, buf) == 0);
@@ -62,6 +57,11 @@ main(void)
 	 * strerror() success tests.
 	 */
 	errno = 0;
+	sret = strerror(0);
+	ok1(strcmp(sret, "No error: 0") == 0);
+	ok1(errno == 0);
+
+	errno = 0;
 	sret = strerror(EPERM);
 	ok1(strcmp(sret, "Operation not permitted") == 0);
 	ok1(errno == 0);
@@ -79,8 +79,8 @@ main(void)
 	 * strerror_r() failure tests.
 	 */
 	memset(buf, '*', sizeof(buf));
-	iret = strerror_r(0, buf, sizeof(buf));
-	ok1(strcmp(buf, "Unknown error: 0") == 0);
+	iret = strerror_r(-1, buf, sizeof(buf));
+	ok1(strcmp(buf, "Unknown error: -1") == 0);
 	ok1(iret == EINVAL);
 
 	memset(buf, '*', sizeof(buf));
@@ -117,6 +117,11 @@ main(void)
 	 * strerror_r() success tests.
 	 */
 	memset(buf, '*', sizeof(buf));
+	iret = strerror_r(0, buf, sizeof(buf));
+	ok1(strcmp(buf, "No error: 0") == 0);
+	ok1(iret == 0);
+
+	memset(buf, '*', sizeof(buf));
 	iret = strerror_r(EDEADLK, buf, sizeof(buf));
 	ok1(strcmp(buf, "Resource deadlock avoided") == 0);
 	ok1(iret == 0);

From owner-svn-src-head@FreeBSD.ORG  Tue Apr  5 22:13:33 2011
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 C7574106564A;
	Tue,  5 Apr 2011 22:13:33 +0000 (UTC)
	(envelope-from davidch@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B64958FC0A;
	Tue,  5 Apr 2011 22:13:33 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p35MDX34032224;
	Tue, 5 Apr 2011 22:13:33 GMT (envelope-from davidch@svn.freebsd.org)
Received: (from davidch@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p35MDXX7032221;
	Tue, 5 Apr 2011 22:13:33 GMT (envelope-from davidch@svn.freebsd.org)
Message-Id: <201104052213.p35MDXX7032221@svn.freebsd.org>
From: David Christensen 
Date: Tue, 5 Apr 2011 22:13: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: r220377 - head/sys/dev/bxe
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, 05 Apr 2011 22:13:33 -0000

Author: davidch
Date: Tue Apr  5 22:13:33 2011
New Revision: 220377
URL: http://svn.freebsd.org/changeset/base/220377

Log:
  - Removed multiple console error messages and replaced with statistic
    counters to reduce spew.
  - Fixed a TSO problem when an mbuf contains both header and payload in
    the same cluster.
  
  MFC after:	One week.

Modified:
  head/sys/dev/bxe/if_bxe.c
  head/sys/dev/bxe/if_bxe.h

Modified: head/sys/dev/bxe/if_bxe.c
==============================================================================
--- head/sys/dev/bxe/if_bxe.c	Tue Apr  5 21:56:05 2011	(r220376)
+++ head/sys/dev/bxe/if_bxe.c	Tue Apr  5 22:13:33 2011	(r220377)
@@ -1674,7 +1674,8 @@ bxe_init_firmware(struct bxe_softc *sc)
 	else if (CHIP_IS_E1H(sc))
 		bxe_init_e1h_firmware(sc);
 	else {
-		BXE_PRINTF("Unsupported chip revision\n");
+		BXE_PRINTF("%s(%d): Unsupported chip revision\n",
+		    __FILE__, __LINE__);
 		return (ENXIO);
 	}
 	return (0);
@@ -1840,7 +1841,8 @@ bxe_attach(device_t dev)
 	sc->grcdump_buffer = malloc(BXE_GRCDUMP_BUF_SIZE, M_TEMP, M_NOWAIT);
 	if (sc->grcdump_buffer == NULL) {
 		/* Failure is OK, just print a message and continue attach. */
-		BXE_PRINTF("Failed to allocate grcdump memory buffer!\n");
+		BXE_PRINTF("%s(%d): Failed to allocate grcdump memory "
+		    "buffer!\n", __FILE__, __LINE__);
 	}
 #endif
 
@@ -1867,7 +1869,8 @@ bxe_attach(device_t dev)
 	/* If bootcode is not running only initialize port 0. */
 	if (nomcp && BP_PORT(sc)) {
 		BXE_PRINTF(
-		    "Second device disabled (no bootcode), exiting...\n");
+		    "%s(%d): Second device disabled (no bootcode), "
+		    "exiting...\n", __FILE__, __LINE__);
 		rc = ENODEV;
 		goto bxe_attach_fail;
 	}
@@ -1907,7 +1910,7 @@ bxe_attach(device_t dev)
 
 	/* Allocate DMA memory resources. */
 	if (bxe_dma_alloc(sc->bxe_dev)) {
-		BXE_PRINTF("%s(%d): DMA allocation failed!\n",
+		BXE_PRINTF("%s(%d): DMA memory allocation failed!\n",
 		    __FILE__, __LINE__);
 		rc = ENOMEM;
 		goto bxe_attach_fail;
@@ -2041,8 +2044,8 @@ bxe_link_settings_supported(struct bxe_s
 
 		default:
 			BXE_PRINTF(
-			    "%s(%d): BAD External PHY NVRAM config data "
-			    "(0x%08X).\n",
+			    "%s(%d): Bad NVRAM 1Gb PHY configuration data "
+			    "(ext_phy_config=0x%08X).\n",
 			    __FILE__, __LINE__,
 			    sc->link_params.ext_phy_config);
 			goto bxe_link_settings_supported_exit;
@@ -2199,10 +2202,10 @@ bxe_link_settings_supported(struct bxe_s
 			    __FUNCTION__);
 			break;
 
-		default:
 			BXE_PRINTF(
-			    "%s(%d): BAD External PHY NVRAM config data "
-			    "(0x%08X).\n", __FILE__, __LINE__,
+			    "%s(%d): Bad NVRAM 10Gb PHY configuration data "
+			    "(ext_phy_config=0x%08X).\n",
+			    __FILE__, __LINE__,
 			    sc->link_params.ext_phy_config);
 			goto bxe_link_settings_supported_exit;
 		}
@@ -2501,7 +2504,7 @@ bxe_get_function_hwinfo(struct bxe_softc
 
 		if ((mac_lo == 0) && (mac_hi == 0)) {
 			BXE_PRINTF("%s(%d): Invalid Ethernet address!\n",
-				__FILE__, __LINE__);
+			    __FILE__, __LINE__);
 		} else {
 			sc->link_params.mac_addr[0] = (u_char)(mac_hi >> 8);
 			sc->link_params.mac_addr[1] = (u_char)(mac_hi);
@@ -2671,7 +2674,8 @@ bxe_get_common_hwinfo(struct bxe_softc *
 	val = SHMEM_RD(sc, validity_map[BP_PORT(sc)]);
 	if ((val & (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB)) !=
 	    (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB)) {
-		BXE_PRINTF("Invalid NVRAM-Bad validity signature!\n");
+		BXE_PRINTF("%s(%d): Invalid NVRAM! Bad validity "
+		    "signature.\n", __FILE__, __LINE__);
 		goto bxe_get_common_hwinfo_exit;
 	}
 
@@ -2705,9 +2709,9 @@ bxe_get_common_hwinfo(struct bxe_softc *
 	/* Check bootcode version */
 	sc->common.bc_ver = ((SHMEM_RD(sc, dev_info.bc_rev)) >> 8);
 	if (sc->common.bc_ver < MIN_BXE_BC_VER) {
-		BXE_PRINTF("Warning: This driver needs bootcode 0x%08X "
-			"but found 0x%08X, please upgrade!\n", MIN_BXE_BC_VER,
-			sc->common.bc_ver);
+		BXE_PRINTF("%s(%d): Warning: This driver needs bootcode "
+		    "0x%08X but found 0x%08X, please upgrade!\n",
+		    __FILE__, __LINE__,	MIN_BXE_BC_VER, sc->common.bc_ver);
 		goto bxe_get_common_hwinfo_exit;
 	}
 
@@ -2850,7 +2854,8 @@ bxe_detach(device_t dev)
 
 	ifp = sc->bxe_ifp;
 	if (ifp != NULL && ifp->if_vlantrunk != NULL) {
-		BXE_PRINTF("Cannot detach while VLANs are in use.\n");
+		BXE_PRINTF("%s(%d): Cannot detach while VLANs are in use.\n",
+		    __FILE__, __LINE__);
 		return(EBUSY);
 	}
 
@@ -3041,7 +3046,8 @@ bxe_stop_multi(struct bxe_softc *sc, int
 	/* Wait for the ramrod completion. */
 	rc = bxe_wait_ramrod(sc, BXE_FP_STATE_HALTED, index, &(fp->state), 1);
 	if (rc){
-	BXE_PRINTF("halted failed \n");
+		BXE_PRINTF("%s(%d): fp[%02d] client ramrod halt failed!\n",
+		    __FILE__, __LINE__, index);
 		goto bxe_stop_multi_exit;
 	}
 	/* Delete the CFC entry. */
@@ -3185,7 +3191,7 @@ bxe_stop_locked(struct bxe_softc *sc, in
 
 			if (count == 0) {
 				BXE_PRINTF(
-			"%s(%d): Timeout wating for fp[%d] to complete.\n",
+		"%s(%d): Timeout wating for fp[%d] transmits to complete!\n",
 				    __FILE__, __LINE__, i);
 				break;
 			}
@@ -3252,7 +3258,6 @@ bxe_stop_locked(struct bxe_softc *sc, in
 	/* Stop all non-leading client connections. */
 	for (i = 1; i < sc->num_queues; i++) {
 		if (bxe_stop_multi(sc, i)){
-			BXE_PRINTF("multi failed \n");
 			goto bxe_stop_locked_exit;
 		}
 	}
@@ -3262,9 +3267,8 @@ bxe_stop_locked(struct bxe_softc *sc, in
 #ifdef BXE_DEBUG
 		if ((sc->state != BXE_STATE_CLOSING_WAIT4_UNLOAD) ||
 		    (sc->fp[0].state != BXE_FP_STATE_CLOSED)) {
-			BXE_PRINTF(
-			    "%s(): Failed to close leading connection!\n",
-			    __FUNCTION__);
+			BXE_PRINTF("%s(%d): Failed to close leading "
+			    "client connection!\n", __FILE__, __LINE__);
 		}
 #endif
 	}
@@ -3368,7 +3372,9 @@ bxe_link_report(struct bxe_softc *sc)
 		/* Report the link status change to OS. */
 		if (sc->state == BXE_STATE_OPEN)
 			if_link_state_change(sc->bxe_ifp, LINK_STATE_UP);
+
 		line_speed = sc->link_vars.line_speed;
+
 		if (IS_E1HMF(sc)){
 			vn_max_rate = ((sc->mf_config[BP_E1HVN(sc)] &
 			    FUNC_MF_CFG_MAX_BW_MASK) >>
@@ -3383,6 +3389,7 @@ bxe_link_report(struct bxe_softc *sc)
 			printf("full duplex");
 		else
 			printf("half duplex");
+
 		if (sc->link_vars.flow_ctrl) {
 			if (sc->link_vars.flow_ctrl & FLOW_CTRL_RX) {
 				printf(", receive ");
@@ -3395,7 +3402,7 @@ bxe_link_report(struct bxe_softc *sc)
 		printf("\n");
 	} else {
 		/* Report the link down */
-		BXE_PRINTF("Link is down.\n");
+		BXE_PRINTF("Link is down\n");
 		if_link_state_change(sc->bxe_ifp, LINK_STATE_DOWN);
 	}
 
@@ -3611,7 +3618,8 @@ bxe_init_locked(struct bxe_softc *sc, in
 
 	/* Initialize hardware. */
 	if (bxe_init_hw(sc, load_code)){
-		BXE_PRINTF("HW init failed, aborting\n");
+		BXE_PRINTF("%s(%d): Hardware initialization failed, "
+		    "aborting!\n", __FILE__, __LINE__);
 		goto bxe_init_locked_failed1;
 	}
 
@@ -3628,8 +3636,8 @@ bxe_init_locked(struct bxe_softc *sc, in
 		sc->mbuf_alloc_size = MJUM9BYTES;
 
 
-	DBPRINT(sc, BXE_INFO,
-	    "%s(): mbuf_alloc_size = %d, max_frame_size = %d\n", __FUNCTION__,
+	DBPRINT(sc, BXE_INFO, "%s(): mbuf_alloc_size = %d, "
+	    "max_frame_size = %d\n", __FUNCTION__,
 	    sc->mbuf_alloc_size, sc->port.ether_mtu);
 
 	/* Setup NIC internals and enable interrupts. */
@@ -3638,7 +3646,7 @@ bxe_init_locked(struct bxe_softc *sc, in
 	if ((load_code == FW_MSG_CODE_DRV_LOAD_COMMON) &&
 	    (sc->common.shmem2_base)){
 		if (bxe_dcc_enable) {
-			BXE_PRINTF(" setting dcc support\n");
+			BXE_PRINTF("Enabing DCC support\n");
 			SHMEM2_WR(sc, dcc_support,
 			    (SHMEM_DCC_SUPPORT_DISABLE_ENABLE_PF_TLV |
 			     SHMEM_DCC_SUPPORT_BANDWIDTH_ALLOCATION_TLV));
@@ -3675,8 +3683,8 @@ bxe_init_locked(struct bxe_softc *sc, in
 		if (sc->state == BXE_STATE_OPEN) {
 			for (i = 1; i < sc->num_queues; i++) {
 				if (bxe_setup_multi(sc, i)) {
-					DBPRINT(sc, 1,
-		"%s(): fp[%d] CLIENT_SETUP ramrod failed! State not OPEN!\n",
+					DBPRINT(sc, BXE_FATAL,
+		"%s(): fp[%02d] CLIENT_SETUP ramrod failed! State not OPEN!\n",
 					    __FUNCTION__, i);
 					goto bxe_init_locked_failed4;
 				}
@@ -4067,9 +4075,9 @@ static void
 bxe_init_wr_zp(struct bxe_softc *sc, uint32_t addr, uint32_t len,
     uint32_t blob_off)
 {
-	BXE_PRINTF("%s(): Compressed FW is not supported yet. "
-	    "ERROR: address:0x%x len:0x%x bloboffset:0x%x\n", __FUNCTION__,
-	    addr, len, blob_off);
+	BXE_PRINTF("%s(%d): Compressed FW is not supported yet. "
+	    "ERROR: address:0x%x len:0x%x blob_offset:0x%x\n",
+	    __FILE__, __LINE__,	addr, len, blob_off);
 }
 
 /*
@@ -4720,8 +4728,10 @@ bxe_panic_dump(struct bxe_softc *sc)
 	BXE_PRINTF("---------- Begin crash dump ----------\n");
 
 	/* Idle	check is run twice to verify the controller has	stopped. */
-	bxe_idle_chk(sc); bxe_idle_chk(sc);
+	bxe_idle_chk(sc);
+	bxe_idle_chk(sc);
 	bxe_mc_assert(sc);
+
 #ifdef BXE_DEBUG
 	bxe_breakpoint(sc);
 #endif
@@ -5677,7 +5687,8 @@ bxe_get_gpio(struct bxe_softc *sc, int g
 	gpio_mask = 1 << gpio_shift;
 
 	if (gpio_num > MISC_REGISTERS_GPIO_3) {
-		BXE_PRINTF("Invalid GPIO %d\n", gpio_num);
+		DBPRINT(sc, BXE_WARN, "%s(): Invalid GPIO %d\n",
+		    __FUNCTION__, gpio_num);
 		return (-EINVAL);
 	}
 
@@ -5785,7 +5796,8 @@ bxe_set_gpio_int(struct bxe_softc *sc, i
 	    (gpio_port ? MISC_REGISTERS_GPIO_PORT_SHIFT : 0);
 	gpio_mask = (1 << gpio_shift);
 	if (gpio_num > MISC_REGISTERS_GPIO_3) {
-		BXE_PRINTF("Invalid GPIO %d\n", gpio_num);
+		DBPRINT(sc, BXE_WARN, "%s(): Invalid GPIO %d\n",
+		    __FUNCTION__, gpio_num);
 		return (-EINVAL);
 	}
 
@@ -6180,8 +6192,8 @@ bxe_sp_post(struct bxe_softc *sc, int co
 
 	/* We are limited to 8 slowpath commands. */
 	if (!sc->spq_left) {
-		BXE_PRINTF("%s(%d): Slowpath queue is full!\n", __FILE__,
-		    __LINE__);
+		BXE_PRINTF("%s(%d): Slowpath queue is full!\n",
+		    __FILE__, __LINE__);
 		bxe_panic_dump(sc);
 		rc = EBUSY;
 		goto bxe_sp_post_exit;
@@ -6363,7 +6375,8 @@ bxe_attn_int_asserted(struct bxe_softc *
 	nig_mask = 0;
 
 	if (sc->attn_state & asserted)
-		BXE_PRINTF("%s(%d): IGU ERROR!\n", __FILE__, __LINE__);
+		BXE_PRINTF("%s(%d): IGU attention ERROR!\n",
+		    __FILE__, __LINE__);
 
 	rc = bxe_acquire_hw_lock(sc,
 		HW_LOCK_RESOURCE_PORT0_ATT_MASK + port);
@@ -6551,8 +6564,8 @@ bxe_attn_int_deasserted0(struct bxe_soft
 		SHMEM_WR(sc, dev_info.port_hw_config[port].external_phy_config,
 		    sc->link_params.ext_phy_config);
 		/* Log the failure */
-		BXE_PRINTF("A fan failure has caused the driver to shutdown "
-		    "the device to prevent permanent damage.\n");
+		BXE_PRINTF("A fan failure has caused the driver to "
+		    "shutdown the device to prevent permanent damage.\n");
 	}
 
 	if (attn & (AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_0 |
@@ -6568,9 +6581,8 @@ bxe_attn_int_deasserted0(struct bxe_soft
 		val &= ~(attn & HW_INTERRUT_ASSERT_SET_0);
 		REG_WR(sc, reg_offset, val);
 
-		BXE_PRINTF(
-		    "%s(%d): FATAL hardware block attention (set0 = 0x%08X)!\n",
-		    __FILE__, __LINE__,
+		BXE_PRINTF("%s(%d): FATAL hardware block attention "
+		    "(set0 = 0x%08X)!\n", __FILE__, __LINE__,
 		    (attn & (uint32_t)HW_INTERRUT_ASSERT_SET_0));
 
 		bxe_panic_dump(sc);
@@ -6616,9 +6628,8 @@ bxe_attn_int_deasserted1(struct bxe_soft
 		val &= ~(attn & HW_INTERRUT_ASSERT_SET_1);
 		REG_WR(sc, reg_offset, val);
 
-		BXE_PRINTF(
-		    "%s(%d): FATAL hardware block attention (set1 = 0x%08X)!\n",
-		    __FILE__, __LINE__,
+		BXE_PRINTF("%s(%d): FATAL hardware block attention "
+		    "(set1 = 0x%08X)!\n", __FILE__, __LINE__,
 		    (attn & (uint32_t)HW_INTERRUT_ASSERT_SET_1));
 
 		bxe_panic_dump(sc);
@@ -7098,7 +7109,8 @@ bxe_stats_port_base_init(struct bxe_soft
 	struct dmae_command *dmae;
 
 	if (!sc->port.pmf || !sc->port.port_stx) {
-		BXE_PRINTF("%s(%d): Bug!\n", __FILE__, __LINE__);
+		BXE_PRINTF("%s(%d): Invalid statistcs port setup!\n",
+		    __FILE__, __LINE__);
 		return;
 	}
 
@@ -7445,7 +7457,8 @@ bxe_stats_port_init(struct bxe_softc *sc
 
 	/* Sanity check. */
 	if (!sc->link_vars.link_up || !sc->port.pmf) {
-		BXE_PRINTF("%s(%d): Bug!\n", __FILE__, __LINE__);
+		BXE_PRINTF("%s(%d): Invalid statistics port setup!\n",
+		    __FILE__, __LINE__);
 		goto bxe_stats_port_init_exit;
 	}
 
@@ -7664,7 +7677,8 @@ bxe_stats_func_init(struct bxe_softc *sc
 	stats_comp = BXE_SP(sc, stats_comp);
 
 	if (!sc->func_stx) {
-		BXE_PRINTF("%s(%d): Bug!\n", __FILE__, __LINE__);
+		BXE_PRINTF("%s(%d): Invalid statistics function setup!\n",
+		     __FILE__, __LINE__);
 		goto bxe_stats_func_init_exit;
 	}
 
@@ -8006,27 +8020,33 @@ bxe_stats_storm_update(struct bxe_softc 
 		/* Are STORM statistics valid? */
 		if ((uint16_t)(le16toh(tclient->stats_counter) + 1) !=
 		    sc->stats_counter) {
+#if 0
 			DBPRINT(sc, BXE_WARN, "%s(): Stats not updated by TSTORM "
 			    "(tstorm counter (%d) != stats_counter (%d))!\n",
 			    __FUNCTION__, tclient->stats_counter, sc->stats_counter);
+#endif
 			rc = 1;
 			goto bxe_stats_storm_update_exit;
 		}
 
 		if ((uint16_t)(le16toh(uclient->stats_counter) + 1) !=
 		    sc->stats_counter) {
+#if 0
 			DBPRINT(sc, BXE_WARN, "%s(): Stats not updated by USTORM "
 			    "(ustorm counter (%d) != stats_counter (%d))!\n",
 			    __FUNCTION__, uclient->stats_counter, sc->stats_counter);
+#endif
 			rc = 2;
 			goto bxe_stats_storm_update_exit;
 		}
 
 		if ((uint16_t)(le16toh(xclient->stats_counter) + 1) !=
 			sc->stats_counter) {
+#if 0
 			DBPRINT(sc, BXE_WARN, "%s(): Stats not updated by XSTORM "
 			    "(xstorm counter (%d) != stats_counter (%d))!\n",
 			    __FUNCTION__, xclient->stats_counter, sc->stats_counter);
+#endif
 			rc = 3;
 			goto bxe_stats_storm_update_exit;
 		}
@@ -8498,7 +8518,9 @@ bxe_stats_handle(struct bxe_softc *sc, e
  * Check that (13 total bds - 3bds) = 10 bd window >= MSS.
  * The window: 3 bds are = 1 (for headers BD) + 2 (for PBD and last BD)
  * The headers comes in a seperate bd in FreeBSD. So 13-3=10.
- * returns 1 to defrag, 0 if OK.
+ *
+ * Returns:
+ *   0 if OK to send, 1 if packet needs further defragmentation.
  */
 static int
 bxe_chktso_window(struct bxe_softc* sc, int nsegs, bus_dma_segment_t *segs,
@@ -8573,11 +8595,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 	sc = fp->sc;
 	DBENTER(BXE_VERBOSE_SEND);
 
-	rc = 0;
-	nbds = 0;
-	ovlan = 0;
-	vlan_off = 0;
-	total_pkt_size = 0;
+	rc = nbds = ovlan = vlan_off = total_pkt_size = 0;
 
 	m0 = *m_head;
 
@@ -8600,122 +8618,116 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 	map = fp->tx_mbuf_map[TX_BD(pkt_prod)];
 	error = bus_dmamap_load_mbuf_sg(fp->tx_mbuf_tag, map, m0,
 	    segs, &nsegs, BUS_DMA_NOWAIT);
+
 	do{
 		/* Handle any mapping errors. */
 		if(__predict_false(error)){
+			fp->tx_dma_mapping_failure++;
 			if (error == ENOMEM) {
-				/* Temporary OS resource issue. */
+				/* Resource issue, try again later. */
 				rc = ENOMEM;
 			}else if (error == EFBIG) {
 				/* Possibly recoverable. */
-				DBRUN(fp->mbuf_defrag_attempts++);
+				fp->mbuf_defrag_attempts++;
 				m0 = m_defrag(*m_head, M_DONTWAIT);
 				if (m0 == NULL) {
-					BXE_PRINTF("%s(%d): Can't defrag TX frame!\n",
-					    __FILE__, __LINE__);
+					fp->mbuf_defrag_failures++;
 					rc = ENOBUFS;
 				} else {
 				/* Defrag was successful, try mapping again.*/
-					DBRUN(fp->mbuf_defrag_successes++);
+					fp->mbuf_defrag_successes++;
 					*m_head = m0;
 					error =
 					    bus_dmamap_load_mbuf_sg(
 						fp->tx_mbuf_tag, map, m0,
 						segs, &nsegs, BUS_DMA_NOWAIT);
+					if (error) {
+						fp->tx_dma_mapping_failure++;
+						rc = error;
+					}
 				}
 			}else {
 				/* Unrecoverable. */
-				BXE_PRINTF("%s(%d): Unknown TX mapping error! "
-				    "rc = %d.\n", __FILE__, __LINE__, error);
+				DBPRINT(sc, BXE_WARN_SEND,
+				    "%s(): Unknown TX mapping error! "
+				    "rc = %d.\n", __FUNCTION__, error);
 				DBRUN(bxe_dump_mbuf(sc, m0));
 				rc = error;
 			}
+
 			break;
 		}
 
-		/*
-		 * Now that we know how many buffer descriptors	are required to
-		 * send the frame, check whether we have enough transmit BD's
-		 * to do the job.  Make sure we have enough room for a parsing
-		 * BD too.
-		 */
+		/* Make sure this enough room in the send queue. */
 		if (__predict_false((nsegs + 2) >
 		    (USABLE_TX_BD - fp->used_tx_bd))) {
+			fp->tx_queue_too_full++;
 			bus_dmamap_unload(fp->tx_mbuf_tag, map);
-			BXE_PRINTF("%s(%d): Insufficient TX queue space!\n",
-				   __FILE__, __LINE__);
-			/* DRC - Should we drop a frame with this error? */
 			rc = ENOBUFS;
 			break;
 		}
 
 		/* Now make sure it fits in the pkt window */
 		if (__predict_false(nsegs > 12)) {
-			/* The mbuf has more segments than the controller can
-			 * handle. Try to defrag the mbuf if there are too many
-			 * segments.  If it can't be defragged then
-			 * drop the frame, log an error, and exit.
-			 * An alternative would be to use a bounce buffer.
+
+			/*
+			 * The mbuf may be to big for the controller
+			 * to handle.  If the frame is a TSO frame
+			 * we'll need to do an additional check.
 			 */
 			if(m0->m_pkthdr.csum_flags & CSUM_TSO){
-				if (! bxe_chktso_window(sc,nsegs,segs,m0))
-					/* Send it */
+				if (bxe_chktso_window(sc,nsegs,segs,m0) == 0)
+					/* OK to send. */
 					break;
-			}
+				else
+					fp->tso_window_violation++;
+			} else
+				fp->std_window_violation++;
 
-			/* Defrag for non tso and if tso needs it */
-			DBRUN(fp->mbuf_defrag_attempts++);
+			/*
+			 * If this is a standard frame then defrag is
+			 * required.  Unmap the mbuf, defrag it, then
+			 * try mapping it again.
+			 */
+			fp->mbuf_defrag_attempts++;
+			bus_dmamap_unload(fp->tx_mbuf_tag, map);
 			m0 = m_defrag(*m_head, M_DONTWAIT);
 			if (m0 == NULL) {
-				BXE_PRINTF("%s(%d): Can't defrag TX frame!\n",
-				    __FILE__, __LINE__);
+				fp->mbuf_defrag_failures++;
 				rc = ENOBUFS;
 				break;
 			}
 
 			/* Defrag was successful, try mapping again. */
-			DBRUN(fp->mbuf_defrag_successes++);
+			fp->mbuf_defrag_successes++;
 			*m_head = m0;
 			error =
 			    bus_dmamap_load_mbuf_sg(
 				fp->tx_mbuf_tag, map, m0,
 				segs, &nsegs, BUS_DMA_NOWAIT);
+
 			/* Handle any mapping errors. */
 			if (__predict_false(error)) {
-				if(error == ENOMEM) {
-					/* This is a recoverable error,
-					 * try again later.
-					 */
-					rc = ENOMEM;
-				} else {
-					/* The frame can't be defragged,
-					 *  drop it.
-					 */
-					BXE_PRINTF("%s(%d): Can't map TX frame!\n",
-					    __FILE__, __LINE__);
-					rc = error;
-				}
+				fp->tx_dma_mapping_failure++;
+				rc = error;
 				break;
 			}
 
 			/* Last try */
 			if (m0->m_pkthdr.csum_flags & CSUM_TSO){
-				if (bxe_chktso_window(sc,nsegs,segs,m0))
+				if (bxe_chktso_window(sc,nsegs,segs,m0) == 1)
 					rc = ENOBUFS;
 			} else if (nsegs > 12 ){
-				BXE_PRINTF("%s(%d): Too many fragments for a TSO "
-				    "frame!\n",	__FILE__, __LINE__);
 				rc = ENOBUFS;
-			}
+			} else
+				rc = 0;
 		}
 	}while (0);
 
-    /* Check for errors */
+	/* Check for errors */
 	if (rc){
 		if(rc == ENOMEM){
 			/* Recoverable try again later  */
-			BXE_PRINTF("%s(%d): Error mapping mbuf into TX chain, "
-			   "returning pkt to queue!\n",__FILE__, __LINE__);
 		}else{
 			fp->soft_tx_errors++;
 			DBRUN(fp->tx_mbuf_alloc--);
@@ -8729,10 +8741,10 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 	fp->tx_pkt_prod++;
 
 	/* set flag according to packet type (UNICAST_ADDRESS is default)*/
-		if (m0->m_flags & M_BCAST)
-			mac_type = BROADCAST_ADDRESS;
-		else if (m0->m_flags & M_MCAST)
-			mac_type = MULTICAST_ADDRESS;
+	if (m0->m_flags & M_BCAST)
+		mac_type = BROADCAST_ADDRESS;
+	else if (m0->m_flags & M_MCAST)
+		mac_type = MULTICAST_ADDRESS;
 
 	/* Prepare the first transmit BD for the mbuf(Get a link from the chain). */
 	tx_start_bd = &fp->tx_bd_chain[TX_PAGE(bd_prod)][TX_IDX(bd_prod)].start_bd;
@@ -8766,7 +8778,8 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 		 */
 		tx_start_bd->vlan = htole16(pkt_prod);
 
-	/* Add a parsing BD from the chain. The parsing bd is always added,
+	/*
+	 * Add a parsing BD from the chain. The parsing bd is always added,
 	 * however, it is only used for tso & chksum.
 	 */
 	bd_prod = TX_BD(NEXT_TX_BD(bd_prod));
@@ -8816,7 +8829,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 			if (m0->m_pkthdr.csum_flags & CSUM_IP) {
 				DBPRINT(sc, BXE_EXTREME_SEND, "%s(): IP checksum "
 					"enabled.\n", __FUNCTION__);
-				DBRUN(sc->debug_ip_csum_offload_frames++);
+				fp->ip_csum_offload_frames++;
 				flags |= ETH_TX_BD_FLAGS_IP_CSUM;
 			}
 
@@ -8833,7 +8846,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 
 				/* Add the TCP checksum offload flag. */
 				flags |= ETH_TX_BD_FLAGS_L4_CSUM;
-				DBRUN(sc->debug_tcp_csum_offload_frames++);
+				fp->tcp_csum_offload_frames++;
 
 				/* Update the enet + IP + TCP header length. */
 				tx_parse_bd->total_hlen += (uint16_t)(th->th_off << 1);
@@ -8866,7 +8879,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 
 				/* Add the TCP checksum offload flag for UDP frames too. */
 				flags |= ETH_TX_BD_FLAGS_L4_CSUM;
-				DBRUN(sc->debug_udp_csum_offload_frames++);
+				fp->udp_csum_offload_frames++;
 				tx_parse_bd->global_data |= ETH_TX_PARSE_BD_UDP_CS_FLG;
 
 				/* Get a pointer to the UDP header. */
@@ -8894,13 +8907,13 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 			break;
 		}
 		case ETHERTYPE_IPV6:
-			BXE_PRINTF("%s(%d): IPv6 checksum offload not "
-				"supported!.\n", __FILE__, __LINE__);
+			fp->unsupported_tso_ipv6_request++;
+			/* DRC - How to handle this error? */
 			break;
 
 		default:
-			BXE_PRINTF("%s(%d): TSO enabled for unsupported protocol!.\n",
-				__FILE__, __LINE__);
+			fp->unsupported_tso_protocol_request++;
+			/* DRC - How to handle this error? */
 		}
 
 		/* Setup the Parsing BD with TSO specific info */
@@ -8913,7 +8926,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 
 			tx_start_bd->bd_flags.as_bitfield |= ETH_TX_BD_FLAGS_SW_LSO;
 
-			DBRUN(sc->debug_tso_offload_frames++);
+			fp->tso_offload_frames++;
  			if (__predict_false(tx_start_bd->nbytes > hdr_len)) {
 				/*
 				 * Split the first BD into 2 BDs to make the
@@ -8932,6 +8945,8 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 				tx_data_bd->addr_hi = htole32(U64_HI(segs[0].ds_addr + hdr_len));
 				tx_data_bd->addr_lo = htole32(U64_LO(segs[0].ds_addr + hdr_len));
 				tx_data_bd->nbytes = htole16(segs[0].ds_len) - hdr_len;
+				if (tx_total_pkt_size_bd == NULL)
+					tx_total_pkt_size_bd = tx_data_bd;
 
 				/*
 				 * This indicates that the transmit BD
@@ -9015,8 +9030,6 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 */
 
 
-//pci_read_config(sc->bxe_dev, PCIR_REVID, 4);
-
 	/* Don't allow reordering of writes for nbd and packets. */
 	mb();
 /*
@@ -9028,22 +9041,21 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 //	BXE_PRINTF("doorbell: nbd %d  bd %u  index %d\n", nbds, bd_prod, fp->index);
 
 	fp->tx_db.data.prod += nbds;
+
 	/* Producer points to the next free tx_bd at this point. */
 	fp->tx_bd_prod = bd_prod;
 
 	DOORBELL(sc, fp->index, fp->tx_db.raw);
 
-
 	DBRUN(fp->tx_pkts++);
 
 	/* Prevent speculative reads from getting ahead of the status block. */
-	bus_space_barrier(sc->bxe_btag, sc->bxe_bhandle, 0, 0,
-		BUS_SPACE_BARRIER_READ);
+	bus_space_barrier(sc->bxe_btag, sc->bxe_bhandle,
+	    0, 0, BUS_SPACE_BARRIER_READ);
 
-	/* Prevent speculative reads from getting ahead of the status block. */
-	bus_space_barrier(sc->bxe_db_btag, sc->bxe_db_bhandle, 0, 0,
-		BUS_SPACE_BARRIER_READ);
-//pci_read_config(sc->bxe_dev, PCIR_REVID, 4);
+	/* Prevent speculative reads from getting ahead of the doorbell. */
+	bus_space_barrier(sc->bxe_db_btag, sc->bxe_db_bhandle,
+	    0, 0, BUS_SPACE_BARRIER_READ);
 
 	DBEXIT(BXE_VERBOSE_SEND);
 	return(rc);
@@ -9109,15 +9121,12 @@ static void
 bxe_tx_start_locked(struct ifnet *ifp, struct bxe_fastpath *fp)
 {
 	struct bxe_softc *sc;
-	struct mbuf *m;
-	int tx_count;
+	struct mbuf *m = NULL;
+	int tx_count = 0;
 
 	sc = fp->sc;
 	DBENTER(BXE_EXTREME_SEND);
 
-	m = NULL;
-	tx_count = 0;
-
  	/* Keep adding entries while there are frames to send. */
 	while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) {
 
@@ -9136,6 +9145,7 @@ bxe_tx_start_locked(struct ifnet *ifp, s
 		 * and wait for the NIC to drain the chain.
 		 */
 		if (__predict_false(bxe_tx_encap(fp, &m))) {
+			fp->tx_encap_failures++;
 			/* Very Bad Frames(tm) may have been dropped. */
 			if (m != NULL) {
 				/*
@@ -9162,17 +9172,12 @@ bxe_tx_start_locked(struct ifnet *ifp, s
 	}
 
 	/* No TX packets were dequeued. */
-	if (tx_count == 0) {
-		DBPRINT(sc, BXE_INFO_SEND,
-		    "%s(): No packets were dequeued on fp[%d].\n", __FUNCTION__,
-		    fp->index);
-		goto bxe_tx_start_locked_exit;
-	}
-
-	/* Reset the TX watchdog timeout timer. */
-	sc->watchdog_timer = BXE_TX_TIMEOUT;
+	if (tx_count > 0)
+		/* Reset the TX watchdog timeout timer. */
+		sc->watchdog_timer = BXE_TX_TIMEOUT;
+	else
+		fp->tx_start_called_on_empty_queue++;
 
-bxe_tx_start_locked_exit:
 	DBEXIT(BXE_EXTREME_SEND);
 }
 
@@ -9353,14 +9358,6 @@ bxe_ioctl(struct ifnet *ifp, u_long comm
 			error = EINVAL;
 		}
 
-		/* Handle any other capabilities. */
-		if (mask & ~(IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU |
-			IFCAP_RXCSUM | IFCAP_TXCSUM)) {
-			BXE_PRINTF("%s(%d): Unsupported capability!\n",
-				__FILE__, __LINE__);
-			error = EINVAL;
-		}
-
 		/* Restart the controller with the new capabilities. */
 		if (reinit) {
 			bxe_stop_locked(sc, UNLOAD_NORMAL);
@@ -10139,7 +10136,7 @@ bxe_alloc_mbuf(struct bxe_fastpath *fp, 
    	if (__predict_false(m_new == NULL)) {
 		DBPRINT(sc, BXE_WARN, "%s(): mbuf allocation failure!\n",
 		    __FUNCTION__);
-		DBRUN(fp->mbuf_alloc_failed++);
+		fp->mbuf_alloc_failed++;
 	    goto bxe_alloc_mbuf_exit;
    	}
 
@@ -10199,7 +10196,7 @@ bxe_map_mbuf(struct bxe_fastpath *fp, st
 		DBPRINT(sc, BXE_WARN, "%s(): mbuf mapping failure (%d)!\n",
 		    __FUNCTION__, rc);
 		m_freem(m);
-		DBRUN(fp->mbuf_alloc_failed++);
+		fp->mbuf_alloc_failed++;
 		goto bxe_map_mbuf_exit;
 	}
 
@@ -10324,24 +10321,23 @@ bxe_init_rx_chains(struct bxe_softc *sc)
 		for (i = 0; i < sc->num_queues; i++) {
 			fp = &sc->fp[i];
 			DBPRINT(sc, (BXE_INSANE_LOAD | BXE_INSANE_RESET),
-			    "%s(): Initializing fp[%d] TPA pool.\n",
+			    "%s(): Initializing fp[%02d] TPA pool.\n",
 			    __FUNCTION__, i);
 
 			for (j = 0; j < max_agg_queues; j++) {
 				DBPRINT(sc,
 				    (BXE_INSANE_LOAD | BXE_INSANE_RESET),
-				    "%s(): Initializing fp[%d] TPA pool[%d].\n",
-				    __FUNCTION__, i, j);
+				    "%s(): Initializing fp[%02d] TPA "
+				    "pool[%d].\n", __FUNCTION__, i, j);
 
 				fp->disable_tpa = 0;
 				fp->tpa_mbuf_ptr[j] = bxe_alloc_tpa_mbuf(fp, j,
 				    sc->mbuf_alloc_size);
 
 				if (fp->tpa_mbuf_ptr[j] == NULL) {
-					BXE_PRINTF(
-		"%s(%d): Failed to allocate TPA pool mbuf for fp[%d]! "
-		"Disabling TPA on this queue!\n",
-					    __FILE__, __LINE__, i);
+					fp->tpa_mbuf_alloc_failed++;
+					BXE_PRINTF("TPA disabled on "
+					    "fp[%02d]!\n", i);
 					bxe_free_tpa_pool(fp, j);
 					fp->disable_tpa = 1;
 					break;
@@ -10439,9 +10435,10 @@ bxe_init_rx_chains(struct bxe_softc *sc)
 
 			while (ring_prod < sc->rx_ring_size) {
 				if (bxe_alloc_rx_sge(sc, fp, ring_prod) != 0) {
+					fp->tpa_mbuf_alloc_failed++;
 					BXE_PRINTF(
 					    "%s(%d): Memory allocation failure! "
-					    "Disabling TPA for fp[%d].\n",
+					    "Disabling TPA for fp[%02d].\n",
 					    __FILE__, __LINE__, i);
 
 					/* Cleanup already allocated elements */
@@ -11307,8 +11304,8 @@ bxe_init_internal(struct bxe_softc *sc, 
 
 	default:
 		BXE_PRINTF(
-		    "%s(%d): Unknown load_code (0x%08X) from MCP!\n", __FILE__,
-		    __LINE__, load_code);
+		    "%s(%d): Unknown load_code (0x%08X) from MCP!\n",
+		    __FILE__, __LINE__, load_code);
 		break;
 	}
 
@@ -11434,7 +11431,7 @@ bxe_gunzip_init_nomem2:
 
 bxe_gunzip_init_nomem1:
 	BXE_PRINTF(
-	    "%s(%d): Cannot allocate firmware buffer for un-compression!\n",
+	    "%s(%d): Cannot allocate firmware buffer for decompression!\n",
 	    __FILE__, __LINE__);
 	rc = ENOMEM;
 
@@ -12229,22 +12226,24 @@ bxe_init_common(struct bxe_softc *sc)
 	/* Finish CFC initialization. */
 	val = bxe_reg_poll(sc, CFC_REG_LL_INIT_DONE, 1, 100, 10);
 	if (val != 1) {
-		BXE_PRINTF("%s(%d): CFC LL_INIT failed!\n", __FILE__, __LINE__);
+		BXE_PRINTF("%s(%d): CFC LL_INIT failed!\n",
+		    __FILE__, __LINE__);
 		rc = EBUSY;
 		goto bxe_init_common_exit;
 	}
 
 	val = bxe_reg_poll(sc, CFC_REG_AC_INIT_DONE, 1, 100, 10);
 	if (val != 1) {
-		BXE_PRINTF("%s(%d): CFC AC_INIT failed!\n", __FILE__, __LINE__);
+		BXE_PRINTF("%s(%d): CFC AC_INIT failed!\n",
+		     __FILE__, __LINE__);
 		rc = EBUSY;
 		goto bxe_init_common_exit;
 	}
 
 	val = bxe_reg_poll(sc, CFC_REG_CAM_INIT_DONE, 1, 100, 10);
 	if (val != 1) {
-		BXE_PRINTF("%s(%d): CFC CAM_INIT failed!\n", __FILE__,
-		   __LINE__);
+		BXE_PRINTF("%s(%d): CFC CAM_INIT failed!\n",
+		    __FILE__, __LINE__);
 		rc = EBUSY;
 		goto bxe_init_common_exit;
 	}
@@ -12713,8 +12712,8 @@ bxe_fw_command(struct bxe_softc *sc, uin
 	if (seq == (rc & FW_MSG_SEQ_NUMBER_MASK ))
 		rc &= FW_MSG_CODE_MASK;
 	else {
-		BXE_PRINTF("%s(%d): Bootcode failed to respond!\n", __FILE__,
-		    __LINE__);
+		BXE_PRINTF("%s(%d): Bootcode failed to respond!\n",
+		    __FILE__, __LINE__);
 		DBRUN(bxe_dump_fw(sc));
 		rc = 0;
 	}
@@ -13143,8 +13142,9 @@ bxe_dma_alloc(device_t dev)
 		    NULL,		/* lock f() */
 		    NULL,		/* lock f() arg */
 		    &fp->status_block_tag)) {
-			BXE_PRINTF("%s(%d): Could not allocate fp[%d] "
-			    "status block DMA tag!\n", __FILE__, __LINE__, i);
+			BXE_PRINTF(
+	"%s(%d): Could not allocate fp[%d] status block DMA tag!\n",
+			    __FILE__, __LINE__, i);
 			rc = ENOMEM;
 			goto bxe_dma_alloc_exit;
 		}
@@ -13153,8 +13153,8 @@ bxe_dma_alloc(device_t dev)
 		    (void **)&fp->status_block, BUS_DMA_NOWAIT,
 		    &fp->status_block_map)) {
 			BXE_PRINTF(
-			    "%s(%d): Could not allocate fp[%d] status block "
-			    "DMA memory!\n", __FILE__, __LINE__, i);
+	"%s(%d): Could not allocate fp[%d] status block	DMA memory!\n",
+			    __FILE__, __LINE__, i);
 			rc = ENOMEM;
 			goto bxe_dma_alloc_exit;
 		}
@@ -13166,8 +13166,9 @@ bxe_dma_alloc(device_t dev)
 		    bxe_dma_map_addr, &busaddr, BUS_DMA_NOWAIT);
 
 		if (error) {
-			BXE_PRINTF("%s(%d): Could not map fp[%d] status block "
-			    "DMA memory!\n", __FILE__, __LINE__, i);
+			BXE_PRINTF(
+		"%s(%d): Could not map fp[%d] status block DMA memory!\n",
+			    __FILE__, __LINE__, i);
 			rc = ENOMEM;
 			goto bxe_dma_alloc_exit;
 		}
@@ -13198,8 +13199,8 @@ bxe_dma_alloc(device_t dev)
 		    NULL,		/* lock f() arg */
 		    &fp->tx_bd_chain_tag)) {
 			BXE_PRINTF(
-			    "%s(%d): Could not allocate fp[%d] TX descriptor "
-			    "chain DMA tag!\n", __FILE__, __LINE__, i);
+	"%s(%d): Could not allocate fp[%d] TX descriptor chain DMA tag!\n",
+			    __FILE__, __LINE__, i);
 			rc = ENOMEM;
 			goto bxe_dma_alloc_exit;
 		}
@@ -13209,8 +13210,7 @@ bxe_dma_alloc(device_t dev)
 			    (void **)&fp->tx_bd_chain[j], BUS_DMA_NOWAIT,
 			    &fp->tx_bd_chain_map[j])) {
 				BXE_PRINTF(
-				    "%s(%d): Could not allocate fp[%d] TX "
-				    "descriptor chain DMA memory!\n",
+	"%s(%d): Could not allocate fp[%d] TX descriptor chain DMA memory!\n",
 				    __FILE__, __LINE__, i);
 				rc = ENOMEM;
 				goto bxe_dma_alloc_exit;
@@ -13224,8 +13224,8 @@ bxe_dma_alloc(device_t dev)
 			    &busaddr, BUS_DMA_NOWAIT);
 
 			if (error) {
-				BXE_PRINTF("%s(%d): Could not map fp[%d] "
-				    "TX descriptor chain DMA memory!\n",
+				BXE_PRINTF(
+	"%s(%d): Could not map fp[%d] TX descriptor chain DMA memory!\n",
 				    __FILE__, __LINE__, i);
 				rc = ENOMEM;
 				goto bxe_dma_alloc_exit;
@@ -13278,8 +13278,8 @@ bxe_dma_alloc(device_t dev)
 			if (bus_dmamap_create(fp->tx_mbuf_tag,
 			    BUS_DMA_NOWAIT,
 			    &(fp->tx_mbuf_map[j]))) {
-				BXE_PRINTF("%s(%d): Unable to create fp[%d] "
-				    "TX mbuf DMA map!\n",
+				BXE_PRINTF(
+		"%s(%d): Unable to create fp[%d] TX mbuf DMA map!\n",
 				    __FILE__, __LINE__, i);
 				rc = ENOMEM;
 				goto bxe_dma_alloc_exit;
@@ -13306,8 +13306,8 @@ bxe_dma_alloc(device_t dev)
 		    NULL,		/* lock f() */
 		    NULL,		/* lock f() arg */
 		    &fp->rx_bd_chain_tag)) {
-			BXE_PRINTF("%s(%d): Could not allocate fp[%d] "
-			    "RX BD chain DMA tag!\n",
+			BXE_PRINTF(
+	"%s(%d): Could not allocate fp[%d] RX BD chain DMA tag!\n",
 			    __FILE__, __LINE__, i);
 			rc = ENOMEM;
 			goto bxe_dma_alloc_exit;
@@ -14792,9 +14792,9 @@ bxe_rxeof(struct bxe_fastpath *fp)
 #endif
 
 		DBRUNIF((cqe_fp_flags == 0),
-		    BXE_PRINTF("%s(): CQE received with null "
-		    "type/error flags!\n", __FUNCTION__);
+		    fp->null_cqe_flags++;
 		    bxe_dump_cqe(fp, rx_cq_cons_idx, cqe));
+		/* DRC - ANything else to do here? */
 
 		/* Check the CQE type for slowpath or fastpath completion. */
 		if (__predict_false(CQE_TYPE(cqe_fp_flags) ==
@@ -15087,6 +15087,7 @@ bxe_txeof(struct bxe_fastpath *fp)
 		txbd = NULL;
 		sw_tx_chain_cons = TX_BD(sw_tx_bd_cons);
 		pkt_cons = TX_BD(sw_pkt_cons);
+
 #ifdef BXE_DEBUG
 		if (sw_tx_chain_cons > MAX_TX_BD) {
 			BXE_PRINTF(
@@ -15106,6 +15107,7 @@ bxe_txeof(struct bxe_fastpath *fp)
 			bxe_breakpoint(sc);
 		}
 #endif
+
 		/*
 		 * Find the number of BD's that were used in the completed pkt.
 		 */
@@ -15126,8 +15128,7 @@ bxe_txeof(struct bxe_fastpath *fp)
 			fp->tx_mbuf_ptr[pkt_cons] = NULL;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 01:38:34 2011
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 38C4B106564A;
	Wed,  6 Apr 2011 01:38:34 +0000 (UTC) (envelope-from obrien@NUXI.org)
Received: from dragon.nuxi.org (trang.nuxi.org [74.95.12.85])
	by mx1.freebsd.org (Postfix) with ESMTP id 17E708FC1E;
	Wed,  6 Apr 2011 01:38:33 +0000 (UTC)
Received: from dragon.nuxi.org (obrien@localhost [127.0.0.1])
	by dragon.nuxi.org (8.14.4/8.14.4) with ESMTP id p361R0l4002447;
	Tue, 5 Apr 2011 18:27:00 -0700 (PDT)
	(envelope-from obrien@dragon.nuxi.org)
Received: (from obrien@localhost)
	by dragon.nuxi.org (8.14.4/8.14.4/Submit) id p361R03P002446;
	Tue, 5 Apr 2011 18:27:00 -0700 (PDT) (envelope-from obrien)
Date: Tue, 5 Apr 2011 18:27:00 -0700
From: "David O'Brien" 
To: John Baldwin 
Message-ID: <20110406012700.GA2067@dragon.NUXI.org>
References: <201104051841.p35If1DX027085@svn.freebsd.org>
	<201104051547.56623.jhb@freebsd.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <201104051547.56623.jhb@freebsd.org>
X-Operating-System: FreeBSD 9.0-CURRENT
X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN?
User-Agent: Mutt/1.5.16 (2007-06-09)
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220370 - in head: etc/mtree include lib/libedit
	lib/libedit/edit lib/libedit/edit/readline sbin/gvinum
	usr.sbin/ntp/ntpdc usr.sbin/ntp/ntpq usr.sbin/wpa/wpa_cli
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: obrien@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: Wed, 06 Apr 2011 01:38:34 -0000

On Tue, Apr 05, 2011 at 03:47:56PM -0400, John Baldwin wrote:
> On Tuesday, April 05, 2011 2:41:01 pm David E. O'Brien wrote:
> > URL: http://svn.freebsd.org/changeset/base/220370
> > Log:
> >   * Add the readline(3) API to libedit.  The libedit versions of
[..]
> >   Obtained from:	NetBSD
> >   Sponsored by:	Juniper Networks
> 
> Should libedit move to contrib?

Possibly -- it would make sense as Christos Zoulas is the original author
and has been actively maintaining it since conception.  Other than the
jilles added in the past year, we haven't really made much creative
changes to it since 4.4BSD.

But we have made a lot of changes to it over the years.  Many of our
"syncs" just took snippets from NetBSD -- right now
'svn diff ^/vendor/NetBSD/libedit/dist ^/head/lib/libedit | wc -l'
reports 12717 lines; or "51 files changed, 871 insertions, 2113
deletions, 3382 modifications" according to diffstat(1).

So maybe hold the question until the diff is smaller??

-- 
-- David  (obrien@FreeBSD.org)

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 11:20:55 2011
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 1C632106564A;
	Wed,  6 Apr 2011 11:20:55 +0000 (UTC) (envelope-from gjb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0E4A18FC0C;
	Wed,  6 Apr 2011 11:20:55 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p36BKsZs086678;
	Wed, 6 Apr 2011 11:20:54 GMT (envelope-from gjb@svn.freebsd.org)
Received: (from gjb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p36BKsh6086676;
	Wed, 6 Apr 2011 11:20:54 GMT (envelope-from gjb@svn.freebsd.org)
Message-Id: <201104061120.p36BKsh6086676@svn.freebsd.org>
From: Glen Barber 
Date: Wed, 6 Apr 2011 11:20:54 +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: r220382 - head/sbin/ifconfig
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, 06 Apr 2011 11:20:55 -0000

Author: gjb (doc committer)
Date: Wed Apr  6 11:20:54 2011
New Revision: 220382
URL: http://svn.freebsd.org/changeset/base/220382

Log:
  Correct 'list scan' description in the examples.  The previous description
  was incorrect - 'list scan' does not actually do a scan, but instead lists
  the results of the background 'scan' cache.
  
  Submitted by:	Fabian Keil (freebsd-listen of fabiankeil de) (via email)
  Discussed with:	bschmidt
  MFC after:	3 days

Modified:
  head/sbin/ifconfig/ifconfig.8

Modified: head/sbin/ifconfig/ifconfig.8
==============================================================================
--- head/sbin/ifconfig/ifconfig.8	Wed Apr  6 11:14:42 2011	(r220381)
+++ head/sbin/ifconfig/ifconfig.8	Wed Apr  6 11:20:54 2011	(r220382)
@@ -2537,7 +2537,7 @@ Destroy the software network interface
 .Li gif1 :
 .Dl # ifconfig gif1 destroy
 .Pp
-Scan for wireless networks using
+Display available wireless networks using
 .Li wlan0 :
 .Dl # ifconfig wlan0 list scan
 .Sh DIAGNOSTICS

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 15:45:33 2011
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 28E381065672;
	Wed,  6 Apr 2011 15:45:33 +0000 (UTC)
	(envelope-from gallatin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1A3E18FC15;
	Wed,  6 Apr 2011 15:45:33 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p36FjWik096064;
	Wed, 6 Apr 2011 15:45:32 GMT (envelope-from gallatin@svn.freebsd.org)
Received: (from gallatin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p36FjWXr096062;
	Wed, 6 Apr 2011 15:45:32 GMT (envelope-from gallatin@svn.freebsd.org)
Message-Id: <201104061545.p36FjWXr096062@svn.freebsd.org>
From: Andrew Gallatin 
Date: Wed, 6 Apr 2011 15: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: r220385 - head/sys/dev/mxge
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, 06 Apr 2011 15:45:33 -0000

Author: gallatin
Date: Wed Apr  6 15:45:32 2011
New Revision: 220385
URL: http://svn.freebsd.org/changeset/base/220385

Log:
  Implement mxge_init()
  
  This fixes a long standing bug in mxge(4) where "ifconfig mxge0 $IP"
  did not bring the interface into a RUNNING state, like it does on
  most (all?) other FreeBSD NIC drivers.
  
  Thanks to gnn for mentioning the bug, and yongari for pointing out that
  ether_ioctl() invokes ifp->if_init() in SIOCSIFADDR.
  
  MFC after: 7 days

Modified:
  head/sys/dev/mxge/if_mxge.c

Modified: head/sys/dev/mxge/if_mxge.c
==============================================================================
--- head/sys/dev/mxge/if_mxge.c	Wed Apr  6 15:36:19 2011	(r220384)
+++ head/sys/dev/mxge/if_mxge.c	Wed Apr  6 15:45:32 2011	(r220385)
@@ -3054,6 +3054,14 @@ mxge_intr(void *arg)
 static void
 mxge_init(void *arg)
 {
+	mxge_softc_t *sc = arg;
+	struct ifnet *ifp = sc->ifp;
+
+
+	mtx_lock(&sc->driver_mtx);
+	if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+		(void) mxge_open(sc);
+	mtx_unlock(&sc->driver_mtx);
 }
 
 

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 16:24:25 2011
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 4C7A1106566B;
	Wed,  6 Apr 2011 16:24:25 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2321A8FC17;
	Wed,  6 Apr 2011 16:24:25 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p36GOPrZ097116;
	Wed, 6 Apr 2011 16:24:25 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p36GOO8o097114;
	Wed, 6 Apr 2011 16:24:24 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <201104061624.p36GOO8o097114@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Wed, 6 Apr 2011 16:24: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: r220386 - 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, 06 Apr 2011 16:24:25 -0000

Author: trasz
Date: Wed Apr  6 16:24:24 2011
New Revision: 220386
URL: http://svn.freebsd.org/changeset/base/220386

Log:
  Add RACCT_RSS.
  
  Sponsored by:	The FreeBSD Foundation
  Reviewed by:	kib (earlier version)

Modified:
  head/sys/vm/vm_pageout.c

Modified: head/sys/vm/vm_pageout.c
==============================================================================
--- head/sys/vm/vm_pageout.c	Wed Apr  6 15:45:32 2011	(r220385)
+++ head/sys/vm/vm_pageout.c	Wed Apr  6 16:24:24 2011	(r220386)
@@ -86,6 +86,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1631,11 +1632,16 @@ vm_daemon()
 	struct proc *p;
 	struct thread *td;
 	struct vmspace *vm;
-	int breakout, swapout_flags;
+	int breakout, swapout_flags, tryagain, attempts;
+	uint64_t rsize, ravailable;
 
 	while (TRUE) {
 		mtx_lock(&vm_daemon_mtx);
+#ifdef RACCT
+		msleep(&vm_daemon_needed, &vm_daemon_mtx, PPAUSE, "psleep", hz);
+#else
 		msleep(&vm_daemon_needed, &vm_daemon_mtx, PPAUSE, "psleep", 0);
+#endif
 		swapout_flags = vm_pageout_req_swapout;
 		vm_pageout_req_swapout = 0;
 		mtx_unlock(&vm_daemon_mtx);
@@ -1646,6 +1652,10 @@ vm_daemon()
 		 * scan the processes for exceeding their rlimits or if
 		 * process is swapped out -- deactivate pages
 		 */
+		tryagain = 0;
+		attempts = 0;
+again:
+		attempts++;
 		sx_slock(&allproc_lock);
 		FOREACH_PROC_IN_SYSTEM(p) {
 			vm_pindex_t limit, size;
@@ -1704,9 +1714,39 @@ vm_daemon()
 				vm_pageout_map_deactivate_pages(
 				    &vm->vm_map, limit);
 			}
+			rsize = IDX_TO_OFF(size);
+			PROC_LOCK(p);
+			racct_set(p, RACCT_RSS, rsize);
+			ravailable = racct_get_available(p, RACCT_RSS);
+			PROC_UNLOCK(p);
+			if (rsize > ravailable) {
+				/*
+				 * Don't be overly aggressive; this might be
+				 * an innocent process, and the limit could've
+				 * been exceeded by some memory hog.  Don't
+				 * try to deactivate more than 1/4th of process'
+				 * resident set size.
+				 */
+				if (attempts <= 8) {
+					if (ravailable < rsize - (rsize / 4))
+						ravailable = rsize - (rsize / 4);
+				}
+				vm_pageout_map_deactivate_pages(
+				    &vm->vm_map, OFF_TO_IDX(ravailable));
+				/* Update RSS usage after paging out. */
+				size = vmspace_resident_count(vm);
+				rsize = IDX_TO_OFF(size);
+				PROC_LOCK(p);
+				racct_set(p, RACCT_RSS, rsize);
+				PROC_UNLOCK(p);
+				if (rsize > ravailable)
+					tryagain = 1;
+			}
 			vmspace_free(vm);
 		}
 		sx_sunlock(&allproc_lock);
+		if (tryagain != 0 && attempts <= 10)
+			goto again;
 	}
 }
 #endif			/* !defined(NO_SWAPPING) */

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 16:27:05 2011
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 41A0E1065676;
	Wed,  6 Apr 2011 16:27:05 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 32EF18FC12;
	Wed,  6 Apr 2011 16:27:05 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p36GR59a097283;
	Wed, 6 Apr 2011 16:27:05 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p36GR4Vx097282;
	Wed, 6 Apr 2011 16:27:04 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <201104061627.p36GR4Vx097282@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Wed, 6 Apr 2011 16:27: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: r220387 - 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, 06 Apr 2011 16:27:05 -0000

Author: trasz
Date: Wed Apr  6 16:27:04 2011
New Revision: 220387
URL: http://svn.freebsd.org/changeset/base/220387

Log:
  In vm_daemon(), do not skip processes stopped with SIGSTOP.

Modified:
  head/sys/vm/vm_pageout.c

Modified: head/sys/vm/vm_pageout.c
==============================================================================
--- head/sys/vm/vm_pageout.c	Wed Apr  6 16:24:24 2011	(r220386)
+++ head/sys/vm/vm_pageout.c	Wed Apr  6 16:27:04 2011	(r220387)
@@ -1303,7 +1303,8 @@ vm_pageout_oom(int shortage)
 			thread_lock(td);
 			if (!TD_ON_RUNQ(td) &&
 			    !TD_IS_RUNNING(td) &&
-			    !TD_IS_SLEEPING(td)) {
+			    !TD_IS_SLEEPING(td) &&
+			    !TD_IS_SUSPENDED(td)) {
 				thread_unlock(td);
 				breakout = 1;
 				break;
@@ -1679,7 +1680,8 @@ again:
 				thread_lock(td);
 				if (!TD_ON_RUNQ(td) &&
 				    !TD_IS_RUNNING(td) &&
-				    !TD_IS_SLEEPING(td)) {
+				    !TD_IS_SLEEPING(td) &&
+				    !TD_IS_SUSPENDED(td)) {
 					thread_unlock(td);
 					breakout = 1;
 					break;

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 16:57:02 2011
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 BFBDE106566B;
	Wed,  6 Apr 2011 16:57:02 +0000 (UTC)
	(envelope-from yanegomi@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 3423B8FC13;
	Wed,  6 Apr 2011 16:57:02 +0000 (UTC)
Received: by pzk27 with SMTP id 27so769616pzk.13
	for ; Wed, 06 Apr 2011 09:57:02 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:in-reply-to:references:date
	:message-id:subject:from:to:cc:content-type
	:content-transfer-encoding;
	bh=yydos7FSiiAFsOTmbsh4d9EUcDKkayAIyTRSFibm2wE=;
	b=oEZGllzWsXYKrqCeXLd/ISeskkgRTnBNaWiVIiR9z+CeIFjelQGSkaH/FBrZYBarBn
	7zQqN00ZGlm/JZaElC3KcAGu08KkY9+CblIr0MWjngcIjNujNPGPNSbXT1iENH2ez9c1
	/hN76AJxKqCNuLinlwAVcve0A4fMoTfMnvDF0=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type:content-transfer-encoding;
	b=eoYCftXNf5rR9gj+8wIMXtiF95BH4tuHCcF1nLVlhSBsYeKPbc4ymhxk5pDLe6ru+Y
	hAgaEGLDqfTpSxIRFNxBihkYepnVFCckNVdTkHuHXvgejnXytWHlbDfDxNM8jnGoJLeY
	Lh1Bf1JqwUCx0B9XFo6UxDygXu29h1FB7VMkY=
MIME-Version: 1.0
Received: by 10.143.39.17 with SMTP id r17mr1061709wfj.113.1302109021883; Wed,
	06 Apr 2011 09:57:01 -0700 (PDT)
Received: by 10.68.42.3 with HTTP; Wed, 6 Apr 2011 09:57:01 -0700 (PDT)
In-Reply-To: <201104061627.p36GR4Vx097282@svn.freebsd.org>
References: <201104061627.p36GR4Vx097282@svn.freebsd.org>
Date: Wed, 6 Apr 2011 09:57:01 -0700
Message-ID: 
From: Garrett Cooper 
To: Edward Tomasz Napierala 
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: r220387 - 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, 06 Apr 2011 16:57:02 -0000

On Wed, Apr 6, 2011 at 9:27 AM, Edward Tomasz Napierala
 wrote:
> Author: trasz
> Date: Wed Apr =A06 16:27:04 2011
> New Revision: 220387
> URL: http://svn.freebsd.org/changeset/base/220387
>
> Log:
> =A0In vm_daemon(), do not skip processes stopped with SIGSTOP.

    Did you run this by anyone else before you committed the change?
Thanks,
-Garrett

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 16:59:55 2011
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 D2705106566C;
	Wed,  6 Apr 2011 16:59:55 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C24FA8FC24;
	Wed,  6 Apr 2011 16:59:55 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p36GxtvM099017;
	Wed, 6 Apr 2011 16:59:55 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p36GxtjJ099011;
	Wed, 6 Apr 2011 16:59:55 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <201104061659.p36GxtjJ099011@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Wed, 6 Apr 2011 16:59: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: r220388 - 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: Wed, 06 Apr 2011 16:59:55 -0000

Author: trasz
Date: Wed Apr  6 16:59:54 2011
New Revision: 220388
URL: http://svn.freebsd.org/changeset/base/220388

Log:
  Add ucred pointer to the SysV-related memory structures.  This is required
  for racct.
  
  Note that after this commit, ipcs(1) needs to be rebuilt.  Otherwise, it will
  fail with "ipcs: sysctlbyname: kern.ipc.msqids: Cannot allocate memory".
  
  Sponsored by:	The FreeBSD Foundation
  Reviewed by:	kib (earlier version)

Modified:
  head/sys/kern/sysv_msg.c
  head/sys/kern/sysv_sem.c
  head/sys/kern/sysv_shm.c
  head/sys/sys/msg.h
  head/sys/sys/sem.h
  head/sys/sys/shm.h

Modified: head/sys/kern/sysv_msg.c
==============================================================================
--- head/sys/kern/sysv_msg.c	Wed Apr  6 16:27:04 2011	(r220387)
+++ head/sys/kern/sysv_msg.c	Wed Apr  6 16:59:54 2011	(r220388)
@@ -466,6 +466,9 @@ kern_msgctl(td, msqid, cmd, msqbuf)
 		}
 #endif
 
+		crfree(msqkptr->cred);
+		msqkptr->cred = NULL;
+
 		/* Free the message headers */
 		msghdr = msqkptr->u.msg_first;
 		while (msghdr != NULL) {
@@ -620,6 +623,8 @@ msgget(td, uap)
 		msqkptr->u.msg_perm.cgid = cred->cr_gid;
 		msqkptr->u.msg_perm.gid = cred->cr_gid;
 		msqkptr->u.msg_perm.mode = (msgflg & 0777);
+		crhold(cred);
+		msqkptr->cred = cred;
 		/* Make sure that the returned msqid is unique */
 		msqkptr->u.msg_perm.seq = (msqkptr->u.msg_perm.seq + 1) & 0x7fff;
 		msqkptr->u.msg_first = NULL;

Modified: head/sys/kern/sysv_sem.c
==============================================================================
--- head/sys/kern/sysv_sem.c	Wed Apr  6 16:27:04 2011	(r220387)
+++ head/sys/kern/sysv_sem.c	Wed Apr  6 16:59:54 2011	(r220388)
@@ -656,6 +656,8 @@ kern_semctl(struct thread *td, int semid
 		semakptr->u.sem_perm.cuid = cred->cr_uid;
 		semakptr->u.sem_perm.uid = cred->cr_uid;
 		semakptr->u.sem_perm.mode = 0;
+		crfree(semakptr->cred);
+		semakptr->cred = NULL;
 		SEMUNDO_LOCK();
 		semundo_clear(semidx, -1);
 		SEMUNDO_UNLOCK();
@@ -937,6 +939,8 @@ semget(struct thread *td, struct semget_
 		sema[semid].u.sem_perm.cgid = cred->cr_gid;
 		sema[semid].u.sem_perm.gid = cred->cr_gid;
 		sema[semid].u.sem_perm.mode = (semflg & 0777) | SEM_ALLOC;
+		crhold(cred);
+		sema[semid].cred = cred;
 		sema[semid].u.sem_perm.seq =
 		    (sema[semid].u.sem_perm.seq + 1) & 0x7fff;
 		sema[semid].u.sem_nsems = nsems;

Modified: head/sys/kern/sysv_shm.c
==============================================================================
--- head/sys/kern/sysv_shm.c	Wed Apr  6 16:27:04 2011	(r220387)
+++ head/sys/kern/sysv_shm.c	Wed Apr  6 16:59:54 2011	(r220388)
@@ -246,6 +246,8 @@ shm_deallocate_segment(shmseg)
 #ifdef MAC
 	mac_sysvshm_cleanup(shmseg);
 #endif
+	crfree(shmseg->cred);
+	shmseg->cred = NULL;
 }
 
 static int
@@ -694,6 +696,8 @@ shmget_allocate_segment(td, uap, mode)
 	shmseg->u.shm_perm.cgid = shmseg->u.shm_perm.gid = cred->cr_gid;
 	shmseg->u.shm_perm.mode = (shmseg->u.shm_perm.mode & SHMSEG_WANTED) |
 	    (mode & ACCESSPERMS) | SHMSEG_ALLOCATED;
+	crhold(cred);
+	shmseg->cred = cred;
 	shmseg->u.shm_segsz = uap->size;
 	shmseg->u.shm_cpid = td->td_proc->p_pid;
 	shmseg->u.shm_lpid = shmseg->u.shm_nattch = 0;

Modified: head/sys/sys/msg.h
==============================================================================
--- head/sys/sys/msg.h	Wed Apr  6 16:27:04 2011	(r220387)
+++ head/sys/sys/msg.h	Wed Apr  6 16:59:54 2011	(r220388)
@@ -160,6 +160,7 @@ struct msqid_kernel {
 	 * Kernel-private components of the message queue.
 	 */
 	struct	label *label;	/* MAC label */
+	struct	ucred *cred;	/* creator's credentials */
 };
 
 #else /* !_KERNEL */

Modified: head/sys/sys/sem.h
==============================================================================
--- head/sys/sys/sem.h	Wed Apr  6 16:27:04 2011	(r220387)
+++ head/sys/sys/sem.h	Wed Apr  6 16:59:54 2011	(r220388)
@@ -126,6 +126,7 @@ extern struct seminfo	seminfo;
 struct semid_kernel {
 	struct	semid_ds u;
 	struct	label *label;	/* MAC framework label */
+	struct	ucred *cred;	/* creator's credentials */
 };
 
 /* internal "mode" bits */

Modified: head/sys/sys/shm.h
==============================================================================
--- head/sys/sys/shm.h	Wed Apr  6 16:27:04 2011	(r220387)
+++ head/sys/sys/shm.h	Wed Apr  6 16:59:54 2011	(r220388)
@@ -124,6 +124,7 @@ struct shmid_kernel {
 	struct shmid_ds u;
 	vm_object_t object;
 	struct label *label;	/* MAC label */
+	struct ucred *cred;	/* creator's credendials */
 };
 
 extern struct shminfo	shminfo;

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 17:04:53 2011
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 A570B106566B;
	Wed,  6 Apr 2011 17:04:53 +0000 (UTC)
	(envelope-from etnapierala@googlemail.com)
Received: from mail-ey0-f182.google.com (mail-ey0-f182.google.com
	[209.85.215.182])
	by mx1.freebsd.org (Postfix) with ESMTP id D690B8FC1C;
	Wed,  6 Apr 2011 17:04:52 +0000 (UTC)
Received: by eyg7 with SMTP id 7so569090eyg.13
	for ; Wed, 06 Apr 2011 10:04:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=googlemail.com; s=gamma;
	h=domainkey-signature:sender:subject:mime-version:content-type:from
	:in-reply-to:date:cc:content-transfer-encoding:message-id:references
	:to:x-mailer; bh=9A+9v3ipQFbDovcuD3cUE1RP9HLaULMfQYZqK9nTd8w=;
	b=v4G303euF9K7FN9AfY53toFJ/WE9chXUQ89dLracv8jum/a9YR0zZ4Z+oVthdXyNTB
	DzE8uJM6RQk4Fu7E8vGrzEYyOZmMtad4p8Gsp5tiRLbOxV5BHh8UB6AVuw0HPCeBtCGX
	xns2hpK5z9PTeD1d74aYAMJtti/hjysw2xp9I=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma;
	h=sender:subject:mime-version:content-type:from:in-reply-to:date:cc
	:content-transfer-encoding:message-id:references:to:x-mailer;
	b=M2kOJUmHFYVwNFlo8qUuz1OhFwlXzHj4XWfdTUXux5R3x88j3ySr7FG20+/jGv3pmW
	J7ortnSfcUNU0bQaRReNHp9meT5uIWct8pgiAppK4k9fa853PKcPy/SUt4GQkl6EOcos
	VLC+WpvD4accAOHJOBbki6NSndxMSrhnIhg5o=
Received: by 10.213.25.220 with SMTP id a28mr927628ebc.137.1302109491615;
	Wed, 06 Apr 2011 10:04:51 -0700 (PDT)
Received: from [192.168.1.104] (45.81.datacomsa.pl [195.34.81.45])
	by mx.google.com with ESMTPS id r48sm487936eei.9.2011.04.06.10.04.49
	(version=TLSv1/SSLv3 cipher=OTHER);
	Wed, 06 Apr 2011 10:04:50 -0700 (PDT)
Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= 
Mime-Version: 1.0 (Apple Message framework v1084)
Content-Type: text/plain; charset=iso-8859-2
From: =?iso-8859-2?Q?Edward_Tomasz_Napiera=B3a?= 
In-Reply-To: 
Date: Wed, 6 Apr 2011 19:04:47 +0200
Content-Transfer-Encoding: quoted-printable
Message-Id: <28CBF3B2-105E-4B0F-A1B1-4FA772BAB06A@freebsd.org>
References: <201104061627.p36GR4Vx097282@svn.freebsd.org>
	
To: Garrett Cooper 
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: r220387 - 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, 06 Apr 2011 17:04:53 -0000

Wiadomo=B6=E6 napisana przez Garrett Cooper w dniu 2011-04-06, o godz. =
18:57:
> On Wed, Apr 6, 2011 at 9:27 AM, Edward Tomasz Napierala
>  wrote:
>> Author: trasz
>> Date: Wed Apr  6 16:27:04 2011
>> New Revision: 220387
>> URL: http://svn.freebsd.org/changeset/base/220387
>>=20
>> Log:
>>  In vm_daemon(), do not skip processes stopped with SIGSTOP.
>=20
>    Did you run this by anyone else before you committed the change?

The whole racct patchset was reviewed by kib@, and I seem to remember
that he said this might cause problems.  However, I didn't encounter
any problems with this, neither did any person testing the patchset.

So, what's wrong with this?

--
If you cut off my head, what would I say?  Me and my head, or me and my =
body?


From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 17:22:33 2011
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 5462A106564A;
	Wed,  6 Apr 2011 17:22:33 +0000 (UTC)
	(envelope-from yanegomi@gmail.com)
Received: from mail-pv0-f182.google.com (mail-pv0-f182.google.com
	[74.125.83.182])
	by mx1.freebsd.org (Postfix) with ESMTP id D49378FC18;
	Wed,  6 Apr 2011 17:22:32 +0000 (UTC)
Received: by pvg11 with SMTP id 11so782026pvg.13
	for ; Wed, 06 Apr 2011 10:22:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:in-reply-to:references:date
	:message-id:subject:from:to:cc:content-type
	:content-transfer-encoding;
	bh=tBTsYf//+nloVl2Qf/OjCWh4OCh+qfP4hVUZnNKStZg=;
	b=xTApuBkrIq7B0tak0h6dP76ewiWeFB93Bl8Mgitmp7PQLBOhKACf0kirX7xqn19n0r
	hpapHuYMGgVMoADaDzfAa8uGdrlMRrkFeGoP4L7Gii70pVyfgxq8QLeRP4ZBHmoGzfAs
	FLIIiQ5F5J6v7PAv+WAhxMhoEIxb3kULcO+Ro=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type:content-transfer-encoding;
	b=P07j4+eRY4OoYz2zobW2valqsqD9gQaU0bc9wQj9zSTYGoODX3NwjywdtxmIEaBUKH
	yWhBAQd3DYkD6vocme8xe2CaJxa3sxdTx3n1et86I04KTzISNoFgN61rN/Cv48s0nz5a
	bPG/yVOpK2kE5NzzkaiNlFsQdUPqjF9hfemMQ=
MIME-Version: 1.0
Received: by 10.142.248.21 with SMTP id v21mr1097882wfh.56.1302110552611; Wed,
	06 Apr 2011 10:22:32 -0700 (PDT)
Received: by 10.68.42.3 with HTTP; Wed, 6 Apr 2011 10:22:32 -0700 (PDT)
In-Reply-To: <28CBF3B2-105E-4B0F-A1B1-4FA772BAB06A@freebsd.org>
References: <201104061627.p36GR4Vx097282@svn.freebsd.org>
	
	<28CBF3B2-105E-4B0F-A1B1-4FA772BAB06A@freebsd.org>
Date: Wed, 6 Apr 2011 10:22:32 -0700
Message-ID: 
From: Garrett Cooper 
To: =?ISO-8859-2?Q?Edward_Tomasz_Napiera=B3a?= 
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220387 - 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, 06 Apr 2011 17:22:33 -0000

2011/4/6 Edward Tomasz Napiera=B3a :
> Wiadomo=B6=E6 napisana przez Garrett Cooper w dniu 2011-04-06, o godz. 18=
:57:
>> On Wed, Apr 6, 2011 at 9:27 AM, Edward Tomasz Napierala
>>  wrote:
>>> Author: trasz
>>> Date: Wed Apr =A06 16:27:04 2011
>>> New Revision: 220387
>>> URL: http://svn.freebsd.org/changeset/base/220387
>>>
>>> Log:
>>> =A0In vm_daemon(), do not skip processes stopped with SIGSTOP.
>>
>> =A0 =A0Did you run this by anyone else before you committed the change?
>
> The whole racct patchset was reviewed by kib@, and I seem to remember
> that he said this might cause problems. =A0However, I didn't encounter
> any problems with this, neither did any person testing the patchset.
>
> So, what's wrong with this?

My concern was just that "Reviewed by" was missing and that this might
introduce some unexpected functional issues (then again it's now going
to kill stopped processes, right?).
-Garrett

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 17:29:41 2011
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 EF5661065673;
	Wed,  6 Apr 2011 17:29:41 +0000 (UTC)
	(envelope-from rdivacky@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DEAA28FC0A;
	Wed,  6 Apr 2011 17:29:41 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p36HTfNW003068;
	Wed, 6 Apr 2011 17:29:41 GMT (envelope-from rdivacky@svn.freebsd.org)
Received: (from rdivacky@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p36HTfiO003066;
	Wed, 6 Apr 2011 17:29:41 GMT (envelope-from rdivacky@svn.freebsd.org)
Message-Id: <201104061729.p36HTfiO003066@svn.freebsd.org>
From: Roman Divacky 
Date: Wed, 6 Apr 2011 17:29: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: r220389 - head/sys/boot/i386/boot2
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, 06 Apr 2011 17:29:42 -0000

Author: rdivacky
Date: Wed Apr  6 17:29:40 2011
New Revision: 220389
URL: http://svn.freebsd.org/changeset/base/220389

Log:
  Mark getc() as inline, this has no effect on gcc but helps clang.
  
  Approved by:    jhb

Modified:
  head/sys/boot/i386/boot2/boot2.c

Modified: head/sys/boot/i386/boot2/boot2.c
==============================================================================
--- head/sys/boot/i386/boot2/boot2.c	Wed Apr  6 16:59:54 2011	(r220388)
+++ head/sys/boot/i386/boot2/boot2.c	Wed Apr  6 17:29:40 2011	(r220389)
@@ -148,7 +148,7 @@ static int drvread(void *, unsigned, uns
 static int keyhit(unsigned);
 static int xputc(int);
 static int xgetc(int);
-static int getc(int);
+static inline int getc(int);
 
 static void memcpy(void *, const void *, int);
 static void

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 17:29:52 2011
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 E6371106564A;
	Wed,  6 Apr 2011 17:29:52 +0000 (UTC) (envelope-from jhb@freebsd.org)
Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42])
	by mx1.freebsd.org (Postfix) with ESMTP id BC0D38FC19;
	Wed,  6 Apr 2011 17:29:52 +0000 (UTC)
Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net
	[66.111.2.69])
	by cyrus.watson.org (Postfix) with ESMTPSA id 4420B46B97;
	Wed,  6 Apr 2011 13:29:52 -0400 (EDT)
Received: from jhbbsd.localnet (unknown [209.249.190.124])
	by bigwig.baldwin.cx (Postfix) with ESMTPSA id C47388A01B;
	Wed,  6 Apr 2011 13:29:51 -0400 (EDT)
From: John Baldwin 
To: Edward Tomasz Napierala 
Date: Wed, 6 Apr 2011 13:26:22 -0400
User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; )
References: <201104061659.p36GxtjJ099011@svn.freebsd.org>
In-Reply-To: <201104061659.p36GxtjJ099011@svn.freebsd.org>
MIME-Version: 1.0
Content-Type: Text/Plain;
  charset="utf-8"
Content-Transfer-Encoding: 7bit
Message-Id: <201104061326.22743.jhb@freebsd.org>
X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6
	(bigwig.baldwin.cx); Wed, 06 Apr 2011 13:29:51 -0400 (EDT)
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220388 - 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: Wed, 06 Apr 2011 17:29:53 -0000

On Wednesday, April 06, 2011 12:59:55 pm Edward Tomasz Napierala wrote:
> Author: trasz
> Date: Wed Apr  6 16:59:54 2011
> New Revision: 220388
> URL: http://svn.freebsd.org/changeset/base/220388
> 
> Log:
>   Add ucred pointer to the SysV-related memory structures.  This is required
>   for racct.
>   
>   Note that after this commit, ipcs(1) needs to be rebuilt.  Otherwise, it will
>   fail with "ipcs: sysctlbyname: kern.ipc.msqids: Cannot allocate memory".
>   
>   Sponsored by:	The FreeBSD Foundation
>   Reviewed by:	kib (earlier version)

Please use this idiom:

	foo->cred = crhold(bar->cred);

instead of:

	crhold(bar->cred);
	foo->cred = bar->cred;

I think this cleaner in terms of readability and semantics.

-- 
John Baldwin

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 17:47:22 2011
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 C2888106566C;
	Wed,  6 Apr 2011 17:47:22 +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 B1E6C8FC17;
	Wed,  6 Apr 2011 17:47:22 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p36HlMCs006800;
	Wed, 6 Apr 2011 17:47:22 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p36HlMK1006792;
	Wed, 6 Apr 2011 17:47:22 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201104061747.p36HlMK1006792@svn.freebsd.org>
From: John Baldwin 
Date: Wed, 6 Apr 2011 17:47: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: r220390 - in head/sys: kern 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, 06 Apr 2011 17:47:23 -0000

Author: jhb
Date: Wed Apr  6 17:47:22 2011
New Revision: 220390
URL: http://svn.freebsd.org/changeset/base/220390

Log:
  Fix several places to ignore processes that are not yet fully constructed.
  
  MFC after:	1 week

Modified:
  head/sys/kern/kern_clock.c
  head/sys/kern/kern_ktrace.c
  head/sys/kern/kern_resource.c
  head/sys/kern/kern_sig.c
  head/sys/kern/sched_4bsd.c
  head/sys/vm/vm_glue.c

Modified: head/sys/kern/kern_clock.c
==============================================================================
--- head/sys/kern/kern_clock.c	Wed Apr  6 17:29:40 2011	(r220389)
+++ head/sys/kern/kern_clock.c	Wed Apr  6 17:47:22 2011	(r220390)
@@ -201,6 +201,10 @@ deadlkres(void)
 		tryl = 0;
 		FOREACH_PROC_IN_SYSTEM(p) {
 			PROC_LOCK(p);
+			if (p->p_state == PRS_NEW) {
+				PROC_UNLOCK(p);
+				continue;
+			}
 			FOREACH_THREAD_IN_PROC(p, td) {
 
 				/*

Modified: head/sys/kern/kern_ktrace.c
==============================================================================
--- head/sys/kern/kern_ktrace.c	Wed Apr  6 17:29:40 2011	(r220389)
+++ head/sys/kern/kern_ktrace.c	Wed Apr  6 17:47:22 2011	(r220390)
@@ -882,7 +882,8 @@ ktrace(td, uap)
 		nfound = 0;
 		LIST_FOREACH(p, &pg->pg_members, p_pglist) {
 			PROC_LOCK(p);
-			if (p_cansee(td, p) != 0) {
+			if (p->p_state == PRS_NEW ||
+			    p_cansee(td, p) != 0) {
 				PROC_UNLOCK(p); 
 				continue;
 			}

Modified: head/sys/kern/kern_resource.c
==============================================================================
--- head/sys/kern/kern_resource.c	Wed Apr  6 17:29:40 2011	(r220389)
+++ head/sys/kern/kern_resource.c	Wed Apr  6 17:47:22 2011	(r220390)
@@ -129,7 +129,8 @@ getpriority(td, uap)
 		sx_sunlock(&proctree_lock);
 		LIST_FOREACH(p, &pg->pg_members, p_pglist) {
 			PROC_LOCK(p);
-			if (p_cansee(td, p) == 0) {
+			if (p->p_state == PRS_NORMAL &&
+			    p_cansee(td, p) == 0) {
 				if (p->p_nice < low)
 					low = p->p_nice;
 			}
@@ -215,7 +216,8 @@ setpriority(td, uap)
 		sx_sunlock(&proctree_lock);
 		LIST_FOREACH(p, &pg->pg_members, p_pglist) {
 			PROC_LOCK(p);
-			if (p_cansee(td, p) == 0) {
+			if (p->p_state == PRS_NORMAL &&
+			    p_cansee(td, p) == 0) {
 				error = donice(td, p, uap->prio);
 				found++;
 			}
@@ -230,7 +232,8 @@ setpriority(td, uap)
 		sx_slock(&allproc_lock);
 		FOREACH_PROC_IN_SYSTEM(p) {
 			PROC_LOCK(p);
-			if (p->p_ucred->cr_uid == uap->who &&
+			if (p->p_state == PRS_NORMAL &&
+			    p->p_ucred->cr_uid == uap->who &&
 			    p_cansee(td, p) == 0) {
 				error = donice(td, p, uap->prio);
 				found++;

Modified: head/sys/kern/kern_sig.c
==============================================================================
--- head/sys/kern/kern_sig.c	Wed Apr  6 17:29:40 2011	(r220389)
+++ head/sys/kern/kern_sig.c	Wed Apr  6 17:47:22 2011	(r220390)
@@ -1799,7 +1799,8 @@ pgsignal(struct pgrp *pgrp, int sig, int
 		PGRP_LOCK_ASSERT(pgrp, MA_OWNED);
 		LIST_FOREACH(p, &pgrp->pg_members, p_pglist) {
 			PROC_LOCK(p);
-			if (checkctty == 0 || p->p_flag & P_CONTROLT)
+			if (p->p_state == PRS_NORMAL &&
+			    (checkctty == 0 || p->p_flag & P_CONTROLT))
 				pksignal(p, sig, ksi);
 			PROC_UNLOCK(p);
 		}
@@ -3313,7 +3314,8 @@ pgsigio(sigiop, sig, checkctty)
 		PGRP_LOCK(sigio->sio_pgrp);
 		LIST_FOREACH(p, &sigio->sio_pgrp->pg_members, p_pglist) {
 			PROC_LOCK(p);
-			if (CANSIGIO(sigio->sio_ucred, p->p_ucred) &&
+			if (p->p_state == PRS_NORMAL &&
+			    CANSIGIO(sigio->sio_ucred, p->p_ucred) &&
 			    (checkctty == 0 || (p->p_flag & P_CONTROLT)))
 				psignal(p, sig);
 			PROC_UNLOCK(p);

Modified: head/sys/kern/sched_4bsd.c
==============================================================================
--- head/sys/kern/sched_4bsd.c	Wed Apr  6 17:29:40 2011	(r220389)
+++ head/sys/kern/sched_4bsd.c	Wed Apr  6 17:47:22 2011	(r220390)
@@ -463,6 +463,10 @@ schedcpu(void)
 	sx_slock(&allproc_lock);
 	FOREACH_PROC_IN_SYSTEM(p) {
 		PROC_LOCK(p);
+		if (p->p_state == PRS_NEW) {
+			PROC_UNLOCK(p);
+			continue;
+		}
 		FOREACH_THREAD_IN_PROC(p, td) {
 			awake = 0;
 			thread_lock(td);

Modified: head/sys/vm/vm_glue.c
==============================================================================
--- head/sys/vm/vm_glue.c	Wed Apr  6 17:29:40 2011	(r220389)
+++ head/sys/vm/vm_glue.c	Wed Apr  6 17:47:22 2011	(r220390)
@@ -747,7 +747,8 @@ loop:
 	sx_slock(&allproc_lock);
 	FOREACH_PROC_IN_SYSTEM(p) {
 		PROC_LOCK(p);
-		if (p->p_flag & (P_SWAPPINGOUT | P_SWAPPINGIN | P_INMEM)) {
+		if (p->p_state == PRS_NEW ||
+		    p->p_flag & (P_SWAPPINGOUT | P_SWAPPINGIN | P_INMEM)) {
 			PROC_UNLOCK(p);
 			continue;
 		}

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 17:54:12 2011
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 D4943106566C;
	Wed,  6 Apr 2011 17:54:12 +0000 (UTC)
	(envelope-from rdivacky@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C443C8FC19;
	Wed,  6 Apr 2011 17:54:12 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p36HsCUl007718;
	Wed, 6 Apr 2011 17:54:12 GMT (envelope-from rdivacky@svn.freebsd.org)
Received: (from rdivacky@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p36HsCuj007716;
	Wed, 6 Apr 2011 17:54:12 GMT (envelope-from rdivacky@svn.freebsd.org)
Message-Id: <201104061754.p36HsCuj007716@svn.freebsd.org>
From: Roman Divacky 
Date: Wed, 6 Apr 2011 17:54:12 +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: r220392 - head/sys/boot/i386/boot2
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, 06 Apr 2011 17:54:12 -0000

Author: rdivacky
Date: Wed Apr  6 17:54:12 2011
New Revision: 220392
URL: http://svn.freebsd.org/changeset/base/220392

Log:
  Move getc() body before xgetc() so gcc does not emit a warning about function
  having no body.
  
  Approved by:    jhb

Modified:
  head/sys/boot/i386/boot2/boot2.c

Modified: head/sys/boot/i386/boot2/boot2.c
==============================================================================
--- head/sys/boot/i386/boot2/boot2.c	Wed Apr  6 17:54:10 2011	(r220391)
+++ head/sys/boot/i386/boot2/boot2.c	Wed Apr  6 17:54:12 2011	(r220392)
@@ -627,6 +627,15 @@ xputc(int c)
 }
 
 static int
+getc(int fn)
+{
+    v86.addr = 0x16;
+    v86.eax = fn << 8;
+    v86int();
+    return fn == 0 ? v86.eax & 0xff : !V86_ZR(v86.efl);
+}
+
+static int
 xgetc(int fn)
 {
     if (OPT_CHECK(RBX_NOINTR))
@@ -640,12 +649,3 @@ xgetc(int fn)
 	    return 0;
     }
 }
-
-static int
-getc(int fn)
-{
-    v86.addr = 0x16;
-    v86.eax = fn << 8;
-    v86int();
-    return fn == 0 ? v86.eax & 0xff : !V86_ZR(v86.efl);
-}

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 18:11:25 2011
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 B9821106566C;
	Wed,  6 Apr 2011 18:11:25 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A79C08FC14;
	Wed,  6 Apr 2011 18:11:25 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p36IBPCO009930;
	Wed, 6 Apr 2011 18:11:25 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p36IBPrg009926;
	Wed, 6 Apr 2011 18:11:25 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <201104061811.p36IBPrg009926@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Wed, 6 Apr 2011 18:11: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: r220398 - 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: Wed, 06 Apr 2011 18:11:25 -0000

Author: trasz
Date: Wed Apr  6 18:11:24 2011
New Revision: 220398
URL: http://svn.freebsd.org/changeset/base/220398

Log:
  Add accounting for SysV-related resources.
  
  Sponsored by:	The FreeBSD Foundation
  Reviewed by:	kib (earlier version)

Modified:
  head/sys/kern/sysv_msg.c
  head/sys/kern/sysv_sem.c
  head/sys/kern/sysv_shm.c

Modified: head/sys/kern/sysv_msg.c
==============================================================================
--- head/sys/kern/sysv_msg.c	Wed Apr  6 18:03:49 2011	(r220397)
+++ head/sys/kern/sysv_msg.c	Wed Apr  6 18:11:24 2011	(r220398)
@@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -466,6 +467,9 @@ kern_msgctl(td, msqid, cmd, msqbuf)
 		}
 #endif
 
+		racct_sub_cred(msqkptr->cred, RACCT_NMSGQ, 1);
+		racct_sub_cred(msqkptr->cred, RACCT_MSGQQUEUED, msqkptr->u.msg_qnum);
+		racct_sub_cred(msqkptr->cred, RACCT_MSGQSIZE, msqkptr->u.msg_cbytes);
 		crfree(msqkptr->cred);
 		msqkptr->cred = NULL;
 
@@ -616,6 +620,13 @@ msgget(td, uap)
 			error = ENOSPC;
 			goto done2;
 		}
+		PROC_LOCK(td->td_proc);
+		error = racct_add(td->td_proc, RACCT_NMSGQ, 1);
+		PROC_UNLOCK(td->td_proc);
+		if (error != 0) {
+			error = ENOSPC;
+			goto done2;
+		}
 		DPRINTF(("msqid %d is available\n", msqid));
 		msqkptr->u.msg_perm.key = key;
 		msqkptr->u.msg_perm.cuid = cred->cr_uid;
@@ -675,6 +686,7 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgf
 	register struct msqid_kernel *msqkptr;
 	register struct msg *msghdr;
 	short next;
+	size_t saved_msgsz;
 
 	if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC))
 		return (ENOSYS);
@@ -712,6 +724,21 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgf
 		goto done2;
 #endif
 
+	PROC_LOCK(td->td_proc);
+	if (racct_add(td->td_proc, RACCT_MSGQQUEUED, 1)) {
+		PROC_UNLOCK(td->td_proc);
+		error = EAGAIN;
+		goto done2;
+	}
+	saved_msgsz = msgsz;
+	if (racct_add(td->td_proc, RACCT_MSGQSIZE, msgsz)) {
+		racct_sub(td->td_proc, RACCT_MSGQQUEUED, 1);
+		PROC_UNLOCK(td->td_proc);
+		error = EAGAIN;
+		goto done2;
+	}
+	PROC_UNLOCK(td->td_proc);
+
 	segs_needed = (msgsz + msginfo.msgssz - 1) / msginfo.msgssz;
 	DPRINTF(("msgsz=%zu, msgssz=%d, segs_needed=%d\n", msgsz,
 	    msginfo.msgssz, segs_needed));
@@ -726,7 +753,7 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgf
 		if (msgsz > msqkptr->u.msg_qbytes) {
 			DPRINTF(("msgsz > msqkptr->u.msg_qbytes\n"));
 			error = EINVAL;
-			goto done2;
+			goto done3;
 		}
 
 		if (msqkptr->u.msg_perm.mode & MSG_LOCKED) {
@@ -753,7 +780,7 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgf
 				DPRINTF(("need more resources but caller "
 				    "doesn't want to wait\n"));
 				error = EAGAIN;
-				goto done2;
+				goto done3;
 			}
 
 			if ((msqkptr->u.msg_perm.mode & MSG_LOCKED) != 0) {
@@ -779,7 +806,7 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgf
 			if (error != 0) {
 				DPRINTF(("msgsnd:  interrupted system call\n"));
 				error = EINTR;
-				goto done2;
+				goto done3;
 			}
 
 			/*
@@ -789,7 +816,7 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgf
 			if (msqkptr->u.msg_qbytes == 0) {
 				DPRINTF(("msqid deleted\n"));
 				error = EIDRM;
-				goto done2;
+				goto done3;
 			}
 
 		} else {
@@ -871,7 +898,7 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgf
 		wakeup(msqkptr);
 		DPRINTF(("mtype (%ld) < 1\n", msghdr->msg_type));
 		error = EINVAL;
-		goto done2;
+		goto done3;
 	}
 
 	/*
@@ -898,7 +925,7 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgf
 			msg_freehdr(msghdr);
 			msqkptr->u.msg_perm.mode &= ~MSG_LOCKED;
 			wakeup(msqkptr);
-			goto done2;
+			goto done3;
 		}
 		mtx_lock(&msq_mtx);
 		msgsz -= tlen;
@@ -922,7 +949,7 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgf
 		msg_freehdr(msghdr);
 		wakeup(msqkptr);
 		error = EIDRM;
-		goto done2;
+		goto done3;
 	}
 
 #ifdef MAC
@@ -941,7 +968,7 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgf
 	if (error != 0) {
 		msg_freehdr(msghdr);
 		wakeup(msqkptr);
-		goto done2;
+		goto done3;
 	}
 #endif
 
@@ -964,6 +991,13 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgf
 
 	wakeup(msqkptr);
 	td->td_retval[0] = 0;
+done3:
+	if (error != 0) {
+		PROC_LOCK(td->td_proc);
+		racct_sub(td->td_proc, RACCT_MSGQQUEUED, 1);
+		racct_sub(td->td_proc, RACCT_MSGQSIZE, saved_msgsz);
+		PROC_UNLOCK(td->td_proc);
+	}
 done2:
 	mtx_unlock(&msq_mtx);
 	return (error);
@@ -1197,6 +1231,9 @@ kern_msgrcv(td, msqid, msgp, msgsz, msgt
 	msqkptr->u.msg_lrpid = td->td_proc->p_pid;
 	msqkptr->u.msg_rtime = time_second;
 
+	racct_sub_cred(msqkptr->cred, RACCT_MSGQQUEUED, 1);
+	racct_sub_cred(msqkptr->cred, RACCT_MSGQSIZE, msghdr->msg_ts);
+
 	/*
 	 * Make msgsz the actual amount that we'll be returning.
 	 * Note that this effectively truncates the message if it is too long

Modified: head/sys/kern/sysv_sem.c
==============================================================================
--- head/sys/kern/sysv_sem.c	Wed Apr  6 18:03:49 2011	(r220397)
+++ head/sys/kern/sysv_sem.c	Wed Apr  6 18:11:24 2011	(r220398)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -656,6 +657,7 @@ kern_semctl(struct thread *td, int semid
 		semakptr->u.sem_perm.cuid = cred->cr_uid;
 		semakptr->u.sem_perm.uid = cred->cr_uid;
 		semakptr->u.sem_perm.mode = 0;
+		racct_sub_cred(semakptr->cred, RACCT_NSEM, semakptr->u.sem_nsems);
 		crfree(semakptr->cred);
 		semakptr->cred = NULL;
 		SEMUNDO_LOCK();
@@ -929,6 +931,13 @@ semget(struct thread *td, struct semget_
 			error = ENOSPC;
 			goto done2;
 		}
+		PROC_LOCK(td->td_proc);
+		error = racct_add(td->td_proc, RACCT_NSEM, nsems);
+		PROC_UNLOCK(td->td_proc);
+		if (error != 0) {
+			error = ENOSPC;
+			goto done2;
+		}
 		DPRINTF(("semid %d is available\n", semid));
 		mtx_lock(&sema_mtx[semid]);
 		KASSERT((sema[semid].u.sem_perm.mode & SEM_ALLOC) == 0,
@@ -1010,12 +1019,19 @@ semop(struct thread *td, struct semop_ar
 	/* Allocate memory for sem_ops */
 	if (nsops <= SMALL_SOPS)
 		sops = small_sops;
-	else if (nsops <= seminfo.semopm)
-		sops = malloc(nsops * sizeof(*sops), M_TEMP, M_WAITOK);
-	else {
+	else if (nsops > seminfo.semopm) {
 		DPRINTF(("too many sops (max=%d, nsops=%d)\n", seminfo.semopm,
 		    nsops));
 		return (E2BIG);
+	} else {
+		PROC_LOCK(td->td_proc);
+		if (nsops > racct_get_available(td->td_proc, RACCT_NSEMOP)) {
+			PROC_UNLOCK(td->td_proc);
+			return (E2BIG);
+		}
+		PROC_UNLOCK(td->td_proc);
+
+		sops = malloc(nsops * sizeof(*sops), M_TEMP, M_WAITOK);
 	}
 	if ((error = copyin(uap->sops, sops, nsops * sizeof(sops[0]))) != 0) {
 		DPRINTF(("error = %d from copyin(%p, %p, %d)\n", error,

Modified: head/sys/kern/sysv_shm.c
==============================================================================
--- head/sys/kern/sysv_shm.c	Wed Apr  6 18:03:49 2011	(r220397)
+++ head/sys/kern/sysv_shm.c	Wed Apr  6 18:11:24 2011	(r220398)
@@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -246,6 +247,8 @@ shm_deallocate_segment(shmseg)
 #ifdef MAC
 	mac_sysvshm_cleanup(shmseg);
 #endif
+	racct_sub_cred(shmseg->cred, RACCT_NSHM, 1);
+	racct_sub_cred(shmseg->cred, RACCT_SHMSIZE, size);
 	crfree(shmseg->cred);
 	shmseg->cred = NULL;
 }
@@ -669,6 +672,17 @@ shmget_allocate_segment(td, uap, mode)
 		shm_last_free = -1;
 	}
 	shmseg = &shmsegs[segnum];
+	PROC_LOCK(td->td_proc);
+	if (racct_add(td->td_proc, RACCT_NSHM, 1)) {
+		PROC_UNLOCK(td->td_proc);
+		return (ENOSPC);
+	}
+	if (racct_add(td->td_proc, RACCT_SHMSIZE, size)) {
+		racct_sub(td->td_proc, RACCT_NSHM, 1);
+		PROC_UNLOCK(td->td_proc);
+		return (ENOMEM);
+	}
+	PROC_UNLOCK(td->td_proc);
 	/*
 	 * In case we sleep in malloc(), mark the segment present but deleted
 	 * so that noone else tries to create the same key.
@@ -684,8 +698,13 @@ shmget_allocate_segment(td, uap, mode)
 	 */
 	shm_object = vm_pager_allocate(shm_use_phys ? OBJT_PHYS : OBJT_SWAP,
 	    0, size, VM_PROT_DEFAULT, 0, cred);
-	if (shm_object == NULL)
+	if (shm_object == NULL) {
+		PROC_LOCK(td->td_proc);
+		racct_sub(td->td_proc, RACCT_NSHM, 1);
+		racct_sub(td->td_proc, RACCT_SHMSIZE, size);
+		PROC_UNLOCK(td->td_proc);
 		return (ENOMEM);
+	}
 	VM_OBJECT_LOCK(shm_object);
 	vm_object_clear_flag(shm_object, OBJ_ONEMAPPING);
 	vm_object_set_flag(shm_object, OBJ_NOSPLIT);

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 19:08:51 2011
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 5CD28106566C;
	Wed,  6 Apr 2011 19:08:51 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 310928FC19;
	Wed,  6 Apr 2011 19:08:51 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p36J8pjC014108;
	Wed, 6 Apr 2011 19:08:51 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p36J8puc014104;
	Wed, 6 Apr 2011 19:08:51 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <201104061908.p36J8puc014104@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Wed, 6 Apr 2011 19:08: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: r220399 - 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: Wed, 06 Apr 2011 19:08:51 -0000

Author: trasz
Date: Wed Apr  6 19:08:50 2011
New Revision: 220399
URL: http://svn.freebsd.org/changeset/base/220399

Log:
  Style fix.
  
  Submitted by:	jhb@

Modified:
  head/sys/kern/sysv_msg.c
  head/sys/kern/sysv_sem.c
  head/sys/kern/sysv_shm.c

Modified: head/sys/kern/sysv_msg.c
==============================================================================
--- head/sys/kern/sysv_msg.c	Wed Apr  6 18:11:24 2011	(r220398)
+++ head/sys/kern/sysv_msg.c	Wed Apr  6 19:08:50 2011	(r220399)
@@ -634,8 +634,7 @@ msgget(td, uap)
 		msqkptr->u.msg_perm.cgid = cred->cr_gid;
 		msqkptr->u.msg_perm.gid = cred->cr_gid;
 		msqkptr->u.msg_perm.mode = (msgflg & 0777);
-		crhold(cred);
-		msqkptr->cred = cred;
+		msqkptr->cred = crhold(cred);
 		/* Make sure that the returned msqid is unique */
 		msqkptr->u.msg_perm.seq = (msqkptr->u.msg_perm.seq + 1) & 0x7fff;
 		msqkptr->u.msg_first = NULL;

Modified: head/sys/kern/sysv_sem.c
==============================================================================
--- head/sys/kern/sysv_sem.c	Wed Apr  6 18:11:24 2011	(r220398)
+++ head/sys/kern/sysv_sem.c	Wed Apr  6 19:08:50 2011	(r220399)
@@ -948,8 +948,7 @@ semget(struct thread *td, struct semget_
 		sema[semid].u.sem_perm.cgid = cred->cr_gid;
 		sema[semid].u.sem_perm.gid = cred->cr_gid;
 		sema[semid].u.sem_perm.mode = (semflg & 0777) | SEM_ALLOC;
-		crhold(cred);
-		sema[semid].cred = cred;
+		sema[semid].cred = crhold(cred);
 		sema[semid].u.sem_perm.seq =
 		    (sema[semid].u.sem_perm.seq + 1) & 0x7fff;
 		sema[semid].u.sem_nsems = nsems;

Modified: head/sys/kern/sysv_shm.c
==============================================================================
--- head/sys/kern/sysv_shm.c	Wed Apr  6 18:11:24 2011	(r220398)
+++ head/sys/kern/sysv_shm.c	Wed Apr  6 19:08:50 2011	(r220399)
@@ -715,8 +715,7 @@ shmget_allocate_segment(td, uap, mode)
 	shmseg->u.shm_perm.cgid = shmseg->u.shm_perm.gid = cred->cr_gid;
 	shmseg->u.shm_perm.mode = (shmseg->u.shm_perm.mode & SHMSEG_WANTED) |
 	    (mode & ACCESSPERMS) | SHMSEG_ALLOCATED;
-	crhold(cred);
-	shmseg->cred = cred;
+	shmseg->cred = crhold(cred);
 	shmseg->u.shm_segsz = uap->size;
 	shmseg->u.shm_cpid = td->td_proc->p_pid;
 	shmseg->u.shm_lpid = shmseg->u.shm_nattch = 0;

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 19:13:04 2011
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 AB3F11065670;
	Wed,  6 Apr 2011 19:13:04 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 992868FC08;
	Wed,  6 Apr 2011 19:13:04 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p36JD4vB014242;
	Wed, 6 Apr 2011 19:13:04 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p36JD4Xb014239;
	Wed, 6 Apr 2011 19:13:04 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <201104061913.p36JD4Xb014239@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Wed, 6 Apr 2011 19:13: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: r220400 - in head/sys: fs/fdescfs 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: Wed, 06 Apr 2011 19:13:04 -0000

Author: trasz
Date: Wed Apr  6 19:13:04 2011
New Revision: 220400
URL: http://svn.freebsd.org/changeset/base/220400

Log:
  Add RACCT_NOFILE accounting.
  
  Sponsored by:	The FreeBSD Foundation
  Reviewed by:	kib (earlier version)

Modified:
  head/sys/fs/fdescfs/fdesc_vfsops.c
  head/sys/kern/kern_descrip.c

Modified: head/sys/fs/fdescfs/fdesc_vfsops.c
==============================================================================
--- head/sys/fs/fdescfs/fdesc_vfsops.c	Wed Apr  6 19:08:50 2011	(r220399)
+++ head/sys/fs/fdescfs/fdesc_vfsops.c	Wed Apr  6 19:13:04 2011	(r220400)
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -186,6 +187,7 @@ fdesc_statfs(mp, sbp)
 	int i;
 	int last;
 	int freefd;
+	uint64_t limit;
 
 	td = curthread;
 
@@ -200,6 +202,9 @@ fdesc_statfs(mp, sbp)
 	PROC_UNLOCK(td->td_proc);
 	fdp = td->td_proc->p_fd;
 	FILEDESC_SLOCK(fdp);
+	limit = racct_get_limit(td->td_proc, RACCT_NOFILE);
+	if (lim > limit)
+		lim = limit;
 	last = min(fdp->fd_nfiles, lim);
 	freefd = 0;
 	for (i = fdp->fd_freefile; i < last; i++)

Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c	Wed Apr  6 19:08:50 2011	(r220399)
+++ head/sys/kern/kern_descrip.c	Wed Apr  6 19:13:04 2011	(r220400)
@@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -276,11 +277,15 @@ int
 getdtablesize(struct thread *td, struct getdtablesize_args *uap)
 {
 	struct proc *p = td->td_proc;
+	uint64_t lim;
 
 	PROC_LOCK(p);
 	td->td_retval[0] =
 	    min((int)lim_cur(p, RLIMIT_NOFILE), maxfilesperproc);
+	lim = racct_get_limit(td->td_proc, RACCT_NOFILE);
 	PROC_UNLOCK(p);
+	if (lim < td->td_retval[0])
+		td->td_retval[0] = lim;
 	return (0);
 }
 
@@ -793,8 +798,25 @@ do_dup(struct thread *td, int flags, int
 	 * out for a race.
 	 */
 	if (flags & DUP_FIXED) {
-		if (new >= fdp->fd_nfiles)
+		if (new >= fdp->fd_nfiles) {
+			/*
+			 * The resource limits are here instead of e.g. fdalloc(),
+			 * because the file descriptor table may be shared between
+			 * processes, so we can't really use racct_add()/racct_sub().
+			 * Instead of counting the number of actually allocated
+			 * descriptors, just put the limit on the size of the file
+			 * descriptor table.
+			 */
+			PROC_LOCK(p);
+			error = racct_set(p, RACCT_NOFILE, new + 1);
+			PROC_UNLOCK(p);
+			if (error != 0) {
+				FILEDESC_XUNLOCK(fdp);
+				fdrop(fp, td);
+				return (EMFILE);
+			}
 			fdgrowtable(fdp, new + 1);
+		}
 		if (fdp->fd_ofiles[new] == NULL)
 			fdused(fdp, new);
 	} else {
@@ -1440,7 +1462,7 @@ fdalloc(struct thread *td, int minfd, in
 {
 	struct proc *p = td->td_proc;
 	struct filedesc *fdp = p->p_fd;
-	int fd = -1, maxfd;
+	int fd = -1, maxfd, error;
 
 	FILEDESC_XLOCK_ASSERT(fdp);
 
@@ -1463,6 +1485,11 @@ fdalloc(struct thread *td, int minfd, in
 			return (EMFILE);
 		if (fd < fdp->fd_nfiles)
 			break;
+		PROC_LOCK(p);
+		error = racct_set(p, RACCT_NOFILE, min(fdp->fd_nfiles * 2, maxfd));
+		PROC_UNLOCK(p);
+		if (error != 0)
+			return (EMFILE);
 		fdgrowtable(fdp, min(fdp->fd_nfiles * 2, maxfd));
 	}
 
@@ -1494,6 +1521,11 @@ fdavail(struct thread *td, int n)
 
 	FILEDESC_LOCK_ASSERT(fdp);
 
+	/*
+	 * XXX: This is only called from uipc_usrreq.c:unp_externalize();
+	 *      call racct_add() from there instead of dealing with containers
+	 *      here.
+	 */
 	PROC_LOCK(p);
 	lim = min((int)lim_cur(p, RLIMIT_NOFILE), maxfilesperproc);
 	PROC_UNLOCK(p);
@@ -1742,6 +1774,10 @@ fdfree(struct thread *td)
 	if (fdp == NULL)
 		return;
 
+	PROC_LOCK(td->td_proc);
+	racct_set(td->td_proc, RACCT_NOFILE, 0);
+	PROC_UNLOCK(td->td_proc);
+
 	/* Check for special need to clear POSIX style locks */
 	fdtol = td->td_proc->p_fdtol;
 	if (fdtol != NULL) {

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 19:27:34 2011
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 BAE07106564A;
	Wed,  6 Apr 2011 19:27:34 +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 DD7C28FC08;
	Wed,  6 Apr 2011 19:27:33 +0000 (UTC)
Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua
	[10.1.1.148])
	by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p36JRSfs087338
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Wed, 6 Apr 2011 22:27: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.4/8.14.4) with ESMTP id
	p36JRSMg089395; Wed, 6 Apr 2011 22:27:28 +0300 (EEST)
	(envelope-from kostikbel@gmail.com)
Received: (from kostik@localhost)
	by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p36JRSli089394; 
	Wed, 6 Apr 2011 22:27:28 +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: Wed, 6 Apr 2011 22:27:28 +0300
From: Kostik Belousov 
To: Edward Tomasz Napiera?a 
Message-ID: <20110406192728.GH78089@deviant.kiev.zoral.com.ua>
References: <201104061627.p36GR4Vx097282@svn.freebsd.org>
	
	<28CBF3B2-105E-4B0F-A1B1-4FA772BAB06A@freebsd.org>
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="j1YqbDUuPtLpE4Xo"
Content-Disposition: inline
In-Reply-To: <28CBF3B2-105E-4B0F-A1B1-4FA772BAB06A@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=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,
	DNS_FROM_OPENWHOIS autolearn=no version=3.2.5
X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on
	skuns.kiev.zoral.com.ua
Cc: Garrett Cooper , svn-src-head@freebsd.org,
	svn-src-all@freebsd.org, src-committers@freebsd.org
Subject: Re: svn commit: r220387 - 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, 06 Apr 2011 19:27:34 -0000


--j1YqbDUuPtLpE4Xo
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Apr 06, 2011 at 07:04:47PM +0200, Edward Tomasz Napiera?a wrote:
> Wiadomo?? napisana przez Garrett Cooper w dniu 2011-04-06, o godz. 18:57:
> > On Wed, Apr 6, 2011 at 9:27 AM, Edward Tomasz Napierala
> >  wrote:
> >> Author: trasz
> >> Date: Wed Apr  6 16:27:04 2011
> >> New Revision: 220387
> >> URL: http://svn.freebsd.org/changeset/base/220387
> >>=20
> >> Log:
> >>  In vm_daemon(), do not skip processes stopped with SIGSTOP.
> >=20
> >    Did you run this by anyone else before you committed the change?
>=20
> The whole racct patchset was reviewed by kib@, and I seem to remember
> that he said this might cause problems.  However, I didn't encounter
> any problems with this, neither did any person testing the patchset.
>=20
> So, what's wrong with this?
I remember that I disliked the whole approach of handling RSS limits,
and still hold the same opinion.
I said something about honoring the limit at the time of page allocation
or page-in, and not `offline' as it is committed, by periodic scans
by daemon.

I do not think that r220387 is much problematic. It performs forced
pageout of usermode pages, that it. On the other hand, a commit message
is not very accurate, thread inhibitor TDI_SUSPENDED might be set e.g.
due to single-threading event, and then we could end up swapping out
the vmspace that is going to be destroyed due to exec(2).

--j1YqbDUuPtLpE4Xo
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)

iEYEARECAAYFAk2cvp8ACgkQC3+MBN1Mb4hIBQCfbwu/kIo4K8vCTfkVLNiWCdOm
WW8AnA6hIo2pEQ1b9Utf61kewAlm3VPa
=dxtr
-----END PGP SIGNATURE-----

--j1YqbDUuPtLpE4Xo--

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 20:08:24 2011
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 0C2FB106564A;
	Wed,  6 Apr 2011 20:08:24 +0000 (UTC) (envelope-from uqs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id EC9C68FC08;
	Wed,  6 Apr 2011 20:08:23 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p36K8NdY015692;
	Wed, 6 Apr 2011 20:08:23 GMT (envelope-from uqs@svn.freebsd.org)
Received: (from uqs@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p36K8NR0015687;
	Wed, 6 Apr 2011 20:08:23 GMT (envelope-from uqs@svn.freebsd.org)
Message-Id: <201104062008.p36K8NR0015687@svn.freebsd.org>
From: Ulrich Spoerlein 
Date: Wed, 6 Apr 2011 20:08: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: r220401 - in head: . share/mk tools/build/mk
	tools/build/options
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, 06 Apr 2011 20:08:24 -0000

Author: uqs
Date: Wed Apr  6 20:08:23 2011
New Revision: 220401
URL: http://svn.freebsd.org/changeset/base/220401

Log:
  Complete WITHOUT_CXX support. It implies WITHOUT_GROFF and
  WITHOUT_CLANG.
  
  Don't build clang bootstrap/build-tools depending on this flag. We also
  keep gperf, devd and libstdc++ around to prevent foot-shooting and to
  make this a two-way street.

Modified:
  head/Makefile.inc1
  head/share/mk/bsd.own.mk
  head/tools/build/mk/OptionalObsoleteFiles.inc
  head/tools/build/options/WITHOUT_CXX

Modified: head/Makefile.inc1
==============================================================================
--- head/Makefile.inc1	Wed Apr  6 19:13:04 2011	(r220400)
+++ head/Makefile.inc1	Wed Apr  6 20:08:23 2011	(r220401)
@@ -1127,10 +1127,12 @@ _kgzip=		usr.sbin/kgzip
 .endif
 .endif
 
+.if ${MK_CLANG} != "no"
 .if ${CC:T:Mclang} == "clang"
 _clang=		usr.bin/clang
 _clang_libs=	lib/clang
 .endif
+.endif
 
 cross-tools:
 .for _tool in \

Modified: head/share/mk/bsd.own.mk
==============================================================================
--- head/share/mk/bsd.own.mk	Wed Apr  6 19:13:04 2011	(r220400)
+++ head/share/mk/bsd.own.mk	Wed Apr  6 20:08:23 2011	(r220401)
@@ -500,6 +500,11 @@ MK_OPENSSH:=	no
 MK_KERBEROS:=	no
 .endif
 
+.if ${MK_CXX} == "no"
+MK_CLANG:=	no
+MK_GROFF:=	no
+.endif
+
 .if ${MK_IPX} == "no"
 MK_NCP:=	no
 .endif

Modified: head/tools/build/mk/OptionalObsoleteFiles.inc
==============================================================================
--- head/tools/build/mk/OptionalObsoleteFiles.inc	Wed Apr  6 19:13:04 2011	(r220400)
+++ head/tools/build/mk/OptionalObsoleteFiles.inc	Wed Apr  6 20:08:23 2011	(r220401)
@@ -689,9 +689,575 @@ OLD_FILES+=usr/share/man/man5/cvs.5.gz
 OLD_FILES+=usr/share/man/man8/cvsbug.8.gz
 .endif
 
-#.if ${MK_CXX} == no
-# to be filled in
-#.endif
+# devd(8) and gperf(1) not listed here on purpose
+.if ${MK_CXX} == no
+OLD_FILES+=usr/bin/CC
+OLD_FILES+=usr/bin/c++
+OLD_FILES+=usr/bin/c++filt
+OLD_FILES+=usr/bin/g++
+OLD_FILES+=usr/include/c++/4.2/algorithm
+OLD_FILES+=usr/include/c++/4.2/backward/algo.h
+OLD_FILES+=usr/include/c++/4.2/backward/algobase.h
+OLD_FILES+=usr/include/c++/4.2/backward/alloc.h
+OLD_FILES+=usr/include/c++/4.2/backward/backward_warning.h
+OLD_FILES+=usr/include/c++/4.2/backward/bvector.h
+OLD_FILES+=usr/include/c++/4.2/backward/complex.h
+OLD_FILES+=usr/include/c++/4.2/backward/defalloc.h
+OLD_FILES+=usr/include/c++/4.2/backward/deque.h
+OLD_FILES+=usr/include/c++/4.2/backward/fstream.h
+OLD_FILES+=usr/include/c++/4.2/backward/function.h
+OLD_FILES+=usr/include/c++/4.2/backward/hash_map.h
+OLD_FILES+=usr/include/c++/4.2/backward/hash_set.h
+OLD_FILES+=usr/include/c++/4.2/backward/hashtable.h
+OLD_FILES+=usr/include/c++/4.2/backward/heap.h
+OLD_FILES+=usr/include/c++/4.2/backward/iomanip.h
+OLD_FILES+=usr/include/c++/4.2/backward/iostream.h
+OLD_FILES+=usr/include/c++/4.2/backward/istream.h
+OLD_FILES+=usr/include/c++/4.2/backward/iterator.h
+OLD_FILES+=usr/include/c++/4.2/backward/list.h
+OLD_FILES+=usr/include/c++/4.2/backward/map.h
+OLD_FILES+=usr/include/c++/4.2/backward/multimap.h
+OLD_FILES+=usr/include/c++/4.2/backward/multiset.h
+OLD_FILES+=usr/include/c++/4.2/backward/new.h
+OLD_FILES+=usr/include/c++/4.2/backward/ostream.h
+OLD_FILES+=usr/include/c++/4.2/backward/pair.h
+OLD_FILES+=usr/include/c++/4.2/backward/queue.h
+OLD_FILES+=usr/include/c++/4.2/backward/rope.h
+OLD_FILES+=usr/include/c++/4.2/backward/set.h
+OLD_FILES+=usr/include/c++/4.2/backward/slist.h
+OLD_FILES+=usr/include/c++/4.2/backward/stack.h
+OLD_FILES+=usr/include/c++/4.2/backward/stream.h
+OLD_FILES+=usr/include/c++/4.2/backward/streambuf.h
+OLD_FILES+=usr/include/c++/4.2/backward/strstream
+OLD_FILES+=usr/include/c++/4.2/backward/tempbuf.h
+OLD_FILES+=usr/include/c++/4.2/backward/tree.h
+OLD_FILES+=usr/include/c++/4.2/backward/vector.h
+OLD_FILES+=usr/include/c++/4.2/bits/allocator.h
+OLD_FILES+=usr/include/c++/4.2/bits/atomic_word.h
+OLD_FILES+=usr/include/c++/4.2/bits/basic_file.h
+OLD_FILES+=usr/include/c++/4.2/bits/basic_ios.h
+OLD_FILES+=usr/include/c++/4.2/bits/basic_ios.tcc
+OLD_FILES+=usr/include/c++/4.2/bits/basic_string.h
+OLD_FILES+=usr/include/c++/4.2/bits/basic_string.tcc
+OLD_FILES+=usr/include/c++/4.2/bits/boost_concept_check.h
+OLD_FILES+=usr/include/c++/4.2/bits/c++allocator.h
+OLD_FILES+=usr/include/c++/4.2/bits/c++config.h
+OLD_FILES+=usr/include/c++/4.2/bits/c++io.h
+OLD_FILES+=usr/include/c++/4.2/bits/c++locale.h
+OLD_FILES+=usr/include/c++/4.2/bits/c++locale_internal.h
+OLD_FILES+=usr/include/c++/4.2/bits/char_traits.h
+OLD_FILES+=usr/include/c++/4.2/bits/cmath.tcc
+OLD_FILES+=usr/include/c++/4.2/bits/codecvt.h
+OLD_FILES+=usr/include/c++/4.2/bits/compatibility.h
+OLD_FILES+=usr/include/c++/4.2/bits/concept_check.h
+OLD_FILES+=usr/include/c++/4.2/bits/cpp_type_traits.h
+OLD_FILES+=usr/include/c++/4.2/bits/cpu_defines.h
+OLD_FILES+=usr/include/c++/4.2/bits/ctype_base.h
+OLD_FILES+=usr/include/c++/4.2/bits/ctype_inline.h
+OLD_FILES+=usr/include/c++/4.2/bits/ctype_noninline.h
+OLD_FILES+=usr/include/c++/4.2/bits/cxxabi_tweaks.h
+OLD_FILES+=usr/include/c++/4.2/bits/deque.tcc
+OLD_FILES+=usr/include/c++/4.2/bits/fstream.tcc
+OLD_FILES+=usr/include/c++/4.2/bits/functexcept.h
+OLD_FILES+=usr/include/c++/4.2/bits/gslice.h
+OLD_FILES+=usr/include/c++/4.2/bits/gslice_array.h
+OLD_FILES+=usr/include/c++/4.2/bits/gthr-default.h
+OLD_FILES+=usr/include/c++/4.2/bits/gthr-posix.h
+OLD_FILES+=usr/include/c++/4.2/bits/gthr-single.h
+OLD_FILES+=usr/include/c++/4.2/bits/gthr-tpf.h
+OLD_FILES+=usr/include/c++/4.2/bits/gthr.h
+OLD_FILES+=usr/include/c++/4.2/bits/indirect_array.h
+OLD_FILES+=usr/include/c++/4.2/bits/ios_base.h
+OLD_FILES+=usr/include/c++/4.2/bits/istream.tcc
+OLD_FILES+=usr/include/c++/4.2/bits/list.tcc
+OLD_FILES+=usr/include/c++/4.2/bits/locale_classes.h
+OLD_FILES+=usr/include/c++/4.2/bits/locale_facets.h
+OLD_FILES+=usr/include/c++/4.2/bits/locale_facets.tcc
+OLD_FILES+=usr/include/c++/4.2/bits/localefwd.h
+OLD_FILES+=usr/include/c++/4.2/bits/mask_array.h
+OLD_FILES+=usr/include/c++/4.2/bits/messages_members.h
+OLD_FILES+=usr/include/c++/4.2/bits/os_defines.h
+OLD_FILES+=usr/include/c++/4.2/bits/ostream.tcc
+OLD_FILES+=usr/include/c++/4.2/bits/ostream_insert.h
+OLD_FILES+=usr/include/c++/4.2/bits/postypes.h
+OLD_FILES+=usr/include/c++/4.2/bits/slice_array.h
+OLD_FILES+=usr/include/c++/4.2/bits/sstream.tcc
+OLD_FILES+=usr/include/c++/4.2/bits/stl_algo.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_algobase.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_bvector.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_construct.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_deque.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_function.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_heap.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_iterator.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_iterator_base_funcs.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_iterator_base_types.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_list.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_map.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_multimap.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_multiset.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_numeric.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_pair.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_queue.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_raw_storage_iter.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_relops.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_set.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_stack.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_tempbuf.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_tree.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_uninitialized.h
+OLD_FILES+=usr/include/c++/4.2/bits/stl_vector.h
+OLD_FILES+=usr/include/c++/4.2/bits/stream_iterator.h
+OLD_FILES+=usr/include/c++/4.2/bits/streambuf.tcc
+OLD_FILES+=usr/include/c++/4.2/bits/streambuf_iterator.h
+OLD_FILES+=usr/include/c++/4.2/bits/stringfwd.h
+OLD_FILES+=usr/include/c++/4.2/bits/time_members.h
+OLD_FILES+=usr/include/c++/4.2/bits/valarray_after.h
+OLD_FILES+=usr/include/c++/4.2/bits/valarray_array.h
+OLD_FILES+=usr/include/c++/4.2/bits/valarray_array.tcc
+OLD_FILES+=usr/include/c++/4.2/bits/valarray_before.h
+OLD_FILES+=usr/include/c++/4.2/bits/vector.tcc
+OLD_FILES+=usr/include/c++/4.2/bitset
+OLD_FILES+=usr/include/c++/4.2/cassert
+OLD_FILES+=usr/include/c++/4.2/cctype
+OLD_FILES+=usr/include/c++/4.2/cerrno
+OLD_FILES+=usr/include/c++/4.2/cfloat
+OLD_FILES+=usr/include/c++/4.2/ciso646
+OLD_FILES+=usr/include/c++/4.2/climits
+OLD_FILES+=usr/include/c++/4.2/clocale
+OLD_FILES+=usr/include/c++/4.2/cmath
+OLD_FILES+=usr/include/c++/4.2/complex
+OLD_FILES+=usr/include/c++/4.2/csetjmp
+OLD_FILES+=usr/include/c++/4.2/csignal
+OLD_FILES+=usr/include/c++/4.2/cstdarg
+OLD_FILES+=usr/include/c++/4.2/cstddef
+OLD_FILES+=usr/include/c++/4.2/cstdio
+OLD_FILES+=usr/include/c++/4.2/cstdlib
+OLD_FILES+=usr/include/c++/4.2/cstring
+OLD_FILES+=usr/include/c++/4.2/ctime
+OLD_FILES+=usr/include/c++/4.2/cwchar
+OLD_FILES+=usr/include/c++/4.2/cwctype
+OLD_FILES+=usr/include/c++/4.2/cxxabi.h
+OLD_FILES+=usr/include/c++/4.2/debug/bitset
+OLD_FILES+=usr/include/c++/4.2/debug/debug.h
+OLD_FILES+=usr/include/c++/4.2/debug/deque
+OLD_FILES+=usr/include/c++/4.2/debug/formatter.h
+OLD_FILES+=usr/include/c++/4.2/debug/functions.h
+OLD_FILES+=usr/include/c++/4.2/debug/hash_map
+OLD_FILES+=usr/include/c++/4.2/debug/hash_map.h
+OLD_FILES+=usr/include/c++/4.2/debug/hash_multimap.h
+OLD_FILES+=usr/include/c++/4.2/debug/hash_multiset.h
+OLD_FILES+=usr/include/c++/4.2/debug/hash_set
+OLD_FILES+=usr/include/c++/4.2/debug/hash_set.h
+OLD_FILES+=usr/include/c++/4.2/debug/list
+OLD_FILES+=usr/include/c++/4.2/debug/macros.h
+OLD_FILES+=usr/include/c++/4.2/debug/map
+OLD_FILES+=usr/include/c++/4.2/debug/map.h
+OLD_FILES+=usr/include/c++/4.2/debug/multimap.h
+OLD_FILES+=usr/include/c++/4.2/debug/multiset.h
+OLD_FILES+=usr/include/c++/4.2/debug/safe_base.h
+OLD_FILES+=usr/include/c++/4.2/debug/safe_iterator.h
+OLD_FILES+=usr/include/c++/4.2/debug/safe_iterator.tcc
+OLD_FILES+=usr/include/c++/4.2/debug/safe_sequence.h
+OLD_FILES+=usr/include/c++/4.2/debug/set
+OLD_FILES+=usr/include/c++/4.2/debug/set.h
+OLD_FILES+=usr/include/c++/4.2/debug/string
+OLD_FILES+=usr/include/c++/4.2/debug/vector
+OLD_FILES+=usr/include/c++/4.2/deque
+OLD_FILES+=usr/include/c++/4.2/exception
+OLD_FILES+=usr/include/c++/4.2/exception_defines.h
+OLD_FILES+=usr/include/c++/4.2/ext/algorithm
+OLD_FILES+=usr/include/c++/4.2/ext/array_allocator.h
+OLD_FILES+=usr/include/c++/4.2/ext/atomicity.h
+OLD_FILES+=usr/include/c++/4.2/ext/bitmap_allocator.h
+OLD_FILES+=usr/include/c++/4.2/ext/codecvt_specializations.h
+OLD_FILES+=usr/include/c++/4.2/ext/concurrence.h
+OLD_FILES+=usr/include/c++/4.2/ext/debug_allocator.h
+OLD_FILES+=usr/include/c++/4.2/ext/functional
+OLD_FILES+=usr/include/c++/4.2/ext/hash_fun.h
+OLD_FILES+=usr/include/c++/4.2/ext/hash_map
+OLD_FILES+=usr/include/c++/4.2/ext/hash_set
+OLD_FILES+=usr/include/c++/4.2/ext/hashtable.h
+OLD_FILES+=usr/include/c++/4.2/ext/iterator
+OLD_FILES+=usr/include/c++/4.2/ext/malloc_allocator.h
+OLD_FILES+=usr/include/c++/4.2/ext/memory
+OLD_FILES+=usr/include/c++/4.2/ext/mt_allocator.h
+OLD_FILES+=usr/include/c++/4.2/ext/new_allocator.h
+OLD_FILES+=usr/include/c++/4.2/ext/numeric
+OLD_FILES+=usr/include/c++/4.2/ext/numeric_traits.h
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/assoc_container.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/basic_tree_policy/basic_tree_policy_base.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/basic_tree_policy/traits.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/basic_types.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/cond_dtor_entry_dealtor.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/cond_key_dtor_entry_dealtor.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/info_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/traits.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/const_iterator.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/entry_cmp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/entry_pred.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/resize_policy.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/trace_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/find_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/iterators_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/policy_access_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/standard_policies.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cond_dealtor.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/constructors_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/container_base_dispatch.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/eq_fn/eq_by_less.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/find_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/iterator_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/policy_access_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/standard_policies.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/direct_mask_range_hashing_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/direct_mod_range_hashing_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/linear_probe_fn_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/mask_based_range_hashing.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/mod_based_range_hashing.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/quadratic_probe_fn_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/sample_probe_fn.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/sample_range_hashing.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/sample_ranged_hash_fn.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/sample_ranged_probe_fn.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/const_point_iterator.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/node.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/null_metadata.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/entry_metadata_base.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/lu_map_.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_policy/counter_lu_metadata.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_policy/counter_lu_policy_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_policy/mtf_lu_policy_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/map_debug_base.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/policy_access_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/traits.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/child_iterator.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/cond_dtor_entry_dealtor.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/const_child_iterator.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/head.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/internal_node.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/leaf.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/node_base.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/node_iterators.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/node_metadata_base.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/point_iterators.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/synth_e_access_traits.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/traits.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/priority_queue_base_dispatch.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/find_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/node.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/traits.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/trace_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/hash_exponential_size_policy_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/hash_standard_resize_policy_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/sample_resize_policy.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/sample_resize_trigger.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/sample_size_policy.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/info_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/node.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/traits.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/standard_policies.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/tree_policy/null_node_update_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/tree_policy/sample_tree_node_update.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/tree_trace_base.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/null_node_update_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/sample_trie_e_access_traits.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/sample_trie_node_update.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/string_trie_e_access_traits_imp.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/trie_policy_base.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/type_utils.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/types_traits.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/unordered_iterator/const_iterator.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/unordered_iterator/const_point_iterator.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/unordered_iterator/iterator.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/exception.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/hash_policy.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/list_update_policy.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/priority_queue.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/tag_and_trait.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/tree_policy.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/trie_policy.hpp
+OLD_FILES+=usr/include/c++/4.2/ext/pod_char_traits.h
+OLD_FILES+=usr/include/c++/4.2/ext/pool_allocator.h
+OLD_FILES+=usr/include/c++/4.2/ext/rb_tree
+OLD_FILES+=usr/include/c++/4.2/ext/rc_string_base.h
+OLD_FILES+=usr/include/c++/4.2/ext/rope
+OLD_FILES+=usr/include/c++/4.2/ext/ropeimpl.h
+OLD_FILES+=usr/include/c++/4.2/ext/slist
+OLD_FILES+=usr/include/c++/4.2/ext/sso_string_base.h
+OLD_FILES+=usr/include/c++/4.2/ext/stdio_filebuf.h
+OLD_FILES+=usr/include/c++/4.2/ext/stdio_sync_filebuf.h
+OLD_FILES+=usr/include/c++/4.2/ext/throw_allocator.h
+OLD_FILES+=usr/include/c++/4.2/ext/type_traits.h
+OLD_FILES+=usr/include/c++/4.2/ext/typelist.h
+OLD_FILES+=usr/include/c++/4.2/ext/vstring.h
+OLD_FILES+=usr/include/c++/4.2/ext/vstring.tcc
+OLD_FILES+=usr/include/c++/4.2/ext/vstring_fwd.h
+OLD_FILES+=usr/include/c++/4.2/ext/vstring_util.h
+OLD_FILES+=usr/include/c++/4.2/fstream
+OLD_FILES+=usr/include/c++/4.2/functional
+OLD_FILES+=usr/include/c++/4.2/iomanip
+OLD_FILES+=usr/include/c++/4.2/ios
+OLD_FILES+=usr/include/c++/4.2/iosfwd
+OLD_FILES+=usr/include/c++/4.2/iostream
+OLD_FILES+=usr/include/c++/4.2/istream
+OLD_FILES+=usr/include/c++/4.2/iterator
+OLD_FILES+=usr/include/c++/4.2/limits
+OLD_FILES+=usr/include/c++/4.2/list
+OLD_FILES+=usr/include/c++/4.2/locale
+OLD_FILES+=usr/include/c++/4.2/map
+OLD_FILES+=usr/include/c++/4.2/memory
+OLD_FILES+=usr/include/c++/4.2/new
+OLD_FILES+=usr/include/c++/4.2/numeric
+OLD_FILES+=usr/include/c++/4.2/ostream
+OLD_FILES+=usr/include/c++/4.2/queue
+OLD_FILES+=usr/include/c++/4.2/set
+OLD_FILES+=usr/include/c++/4.2/sstream
+OLD_FILES+=usr/include/c++/4.2/stack
+OLD_FILES+=usr/include/c++/4.2/stdexcept
+OLD_FILES+=usr/include/c++/4.2/streambuf
+OLD_FILES+=usr/include/c++/4.2/string
+OLD_FILES+=usr/include/c++/4.2/tr1/array
+OLD_FILES+=usr/include/c++/4.2/tr1/bind_iterate.h
+OLD_FILES+=usr/include/c++/4.2/tr1/bind_repeat.h
+OLD_FILES+=usr/include/c++/4.2/tr1/boost_shared_ptr.h
+OLD_FILES+=usr/include/c++/4.2/tr1/cctype
+OLD_FILES+=usr/include/c++/4.2/tr1/cfenv
+OLD_FILES+=usr/include/c++/4.2/tr1/cfloat
+OLD_FILES+=usr/include/c++/4.2/tr1/cinttypes
+OLD_FILES+=usr/include/c++/4.2/tr1/climits
+OLD_FILES+=usr/include/c++/4.2/tr1/cmath
+OLD_FILES+=usr/include/c++/4.2/tr1/common.h
+OLD_FILES+=usr/include/c++/4.2/tr1/complex
+OLD_FILES+=usr/include/c++/4.2/tr1/cstdarg
+OLD_FILES+=usr/include/c++/4.2/tr1/cstdbool
+OLD_FILES+=usr/include/c++/4.2/tr1/cstdint
+OLD_FILES+=usr/include/c++/4.2/tr1/cstdio
+OLD_FILES+=usr/include/c++/4.2/tr1/cstdlib
+OLD_FILES+=usr/include/c++/4.2/tr1/ctgmath
+OLD_FILES+=usr/include/c++/4.2/tr1/ctime
+OLD_FILES+=usr/include/c++/4.2/tr1/ctype.h
+OLD_FILES+=usr/include/c++/4.2/tr1/cwchar
+OLD_FILES+=usr/include/c++/4.2/tr1/cwctype
+OLD_FILES+=usr/include/c++/4.2/tr1/fenv.h
+OLD_FILES+=usr/include/c++/4.2/tr1/float.h
+OLD_FILES+=usr/include/c++/4.2/tr1/functional
+OLD_FILES+=usr/include/c++/4.2/tr1/functional_hash.h
+OLD_FILES+=usr/include/c++/4.2/tr1/functional_iterate.h
+OLD_FILES+=usr/include/c++/4.2/tr1/hashtable
+OLD_FILES+=usr/include/c++/4.2/tr1/hashtable_policy.h
+OLD_FILES+=usr/include/c++/4.2/tr1/inttypes.h
+OLD_FILES+=usr/include/c++/4.2/tr1/limits.h
+OLD_FILES+=usr/include/c++/4.2/tr1/math.h
+OLD_FILES+=usr/include/c++/4.2/tr1/memory
+OLD_FILES+=usr/include/c++/4.2/tr1/mu_iterate.h
+OLD_FILES+=usr/include/c++/4.2/tr1/random
+OLD_FILES+=usr/include/c++/4.2/tr1/random.tcc
+OLD_FILES+=usr/include/c++/4.2/tr1/ref_fwd.h
+OLD_FILES+=usr/include/c++/4.2/tr1/ref_wrap_iterate.h
+OLD_FILES+=usr/include/c++/4.2/tr1/repeat.h
+OLD_FILES+=usr/include/c++/4.2/tr1/stdarg.h
+OLD_FILES+=usr/include/c++/4.2/tr1/stdbool.h
+OLD_FILES+=usr/include/c++/4.2/tr1/stdint.h
+OLD_FILES+=usr/include/c++/4.2/tr1/stdio.h
+OLD_FILES+=usr/include/c++/4.2/tr1/stdlib.h
+OLD_FILES+=usr/include/c++/4.2/tr1/tgmath.h
+OLD_FILES+=usr/include/c++/4.2/tr1/tuple
+OLD_FILES+=usr/include/c++/4.2/tr1/tuple_defs.h
+OLD_FILES+=usr/include/c++/4.2/tr1/tuple_iterate.h
+OLD_FILES+=usr/include/c++/4.2/tr1/type_traits
+OLD_FILES+=usr/include/c++/4.2/tr1/type_traits_fwd.h
+OLD_FILES+=usr/include/c++/4.2/tr1/unordered_map
+OLD_FILES+=usr/include/c++/4.2/tr1/unordered_set
+OLD_FILES+=usr/include/c++/4.2/tr1/utility
+OLD_FILES+=usr/include/c++/4.2/tr1/wchar.h
+OLD_FILES+=usr/include/c++/4.2/tr1/wctype.h
+OLD_FILES+=usr/include/c++/4.2/typeinfo
+OLD_FILES+=usr/include/c++/4.2/utility
+OLD_FILES+=usr/include/c++/4.2/valarray
+OLD_FILES+=usr/include/c++/4.2/vector
+OLD_FILES+=usr/lib/libstdc++.a
+# Keep libs to allow bootstrapping g++(1) with gperf(1)
+#OLD_LIBS+=usr/lib/libstdc++.so
+#OLD_LIBS+=usr/lib/libstdc++.so.6
+OLD_FILES+=usr/lib/libstdc++_p.a
+OLD_FILES+=usr/lib/libsupc++.a
+OLD_FILES+=usr/lib/libsupc++_p.a
+OLD_FILES+=usr/libexec/cc1plus
+.endif
 
 .if ${MK_DICT} == no
 OLD_FILES+=usr/share/dict/README

Modified: head/tools/build/options/WITHOUT_CXX
==============================================================================
--- head/tools/build/options/WITHOUT_CXX	Wed Apr  6 19:13:04 2011	(r220400)
+++ head/tools/build/options/WITHOUT_CXX	Wed Apr  6 20:08:23 2011	(r220401)
@@ -2,3 +2,11 @@
 Set to not build
 .Xr g++ 1
 and related libraries.
+Implies
+.Dv WITHOUT_CLANG
+and
+.Dv WITHOUT_GROFF
+and will also prevent building of
+.Xr gperf 1
+and
+.Xr devd 8 .

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 20:19:07 2011
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 8FC30106564A;
	Wed,  6 Apr 2011 20:19:07 +0000 (UTC) (envelope-from uqs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 63AED8FC14;
	Wed,  6 Apr 2011 20:19:07 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p36KJ70k015969;
	Wed, 6 Apr 2011 20:19:07 GMT (envelope-from uqs@svn.freebsd.org)
Received: (from uqs@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p36KJ7Vj015966;
	Wed, 6 Apr 2011 20:19:07 GMT (envelope-from uqs@svn.freebsd.org)
Message-Id: <201104062019.p36KJ7Vj015966@svn.freebsd.org>
From: Ulrich Spoerlein 
Date: Wed, 6 Apr 2011 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: r220402 - in head: share/man/man5 tools/build/options
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, 06 Apr 2011 20:19:07 -0000

Author: uqs
Date: Wed Apr  6 20:19:07 2011
New Revision: 220402
URL: http://svn.freebsd.org/changeset/base/220402

Log:
  Regenerate after r220401. It turns out makeman is clever about implied
  flags, so remove that part from WITHOUT_CXX again.
  
  This is only partially regenerated, as the entries for FDT and GPIO seem to
  have switched their default state, too.

Modified:
  head/share/man/man5/src.conf.5
  head/tools/build/options/WITHOUT_CXX

Modified: head/share/man/man5/src.conf.5
==============================================================================
--- head/share/man/man5/src.conf.5	Wed Apr  6 20:08:23 2011	(r220401)
+++ head/share/man/man5/src.conf.5	Wed Apr  6 20:19:07 2011	(r220402)
@@ -1,7 +1,7 @@
 .\" DO NOT EDIT-- this file is automatically generated.
 .\" from FreeBSD: head/tools/build/options/makeman 188848 2009-02-20 11:09:55Z mtm
 .\" $FreeBSD$
-.Dd February 22, 2011
+.Dd April  6, 2011
 .Dt SRC.CONF 5
 .Os
 .Sh NAME
@@ -285,10 +285,22 @@ and related utilities.
 .\" from FreeBSD: head/tools/build/options/WITHOUT_CVS 156932 2006-03-21 07:50:50Z ru
 Set to not build CVS.
 .It Va WITHOUT_CXX
-.\" from FreeBSD: head/tools/build/options/WITHOUT_CXX 156932 2006-03-21 07:50:50Z ru
+.\" from FreeBSD: head/tools/build/options/WITHOUT_CXX 220401 2011-04-06 20:08:23Z uqs
 Set to not build
 .Xr g++ 1
 and related libraries.
+It will also prevent building of
+.Xr gperf 1
+and
+.Xr devd 8 .
+When set, it also enforces the following options:
+.Pp
+.Bl -item -compact
+.It
+.Va WITHOUT_CLANG
+.It
+.Va WITHOUT_GROFF
+.El
 .It Va WITHOUT_DICT
 .\" from FreeBSD: head/tools/build/options/WITHOUT_DICT 156932 2006-03-21 07:50:50Z ru
 Set to not build the Webster dictionary files.
@@ -375,6 +387,9 @@ Set to build Hesiod support.
 .It Va WITHOUT_HTML
 .\" from FreeBSD: head/tools/build/options/WITHOUT_HTML 156932 2006-03-21 07:50:50Z ru
 Set to not build HTML docs.
+.It Va WITH_ICONV
+.\" from FreeBSD: head/tools/build/options/WITH_ICONV 219020 2011-02-25 00:10:26Z gabor
+Set to build iconv as part of libc.
 .It Va WITH_IDEA
 .\" from FreeBSD: head/tools/build/options/WITH_IDEA 156932 2006-03-21 07:50:50Z ru
 Set to build the IDEA encryption code.

Modified: head/tools/build/options/WITHOUT_CXX
==============================================================================
--- head/tools/build/options/WITHOUT_CXX	Wed Apr  6 20:08:23 2011	(r220401)
+++ head/tools/build/options/WITHOUT_CXX	Wed Apr  6 20:19:07 2011	(r220402)
@@ -2,11 +2,7 @@
 Set to not build
 .Xr g++ 1
 and related libraries.
-Implies
-.Dv WITHOUT_CLANG
-and
-.Dv WITHOUT_GROFF
-and will also prevent building of
+It will also prevent building of
 .Xr gperf 1
 and
 .Xr devd 8 .

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 20:54:26 2011
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 B4B0A106566C;
	Wed,  6 Apr 2011 20:54:26 +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 A148B8FC08;
	Wed,  6 Apr 2011 20:54:26 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p36KsQvR017126;
	Wed, 6 Apr 2011 20:54:26 GMT (envelope-from delphij@svn.freebsd.org)
Received: (from delphij@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p36KsQjf017123;
	Wed, 6 Apr 2011 20:54:26 GMT (envelope-from delphij@svn.freebsd.org)
Message-Id: <201104062054.p36KsQjf017123@svn.freebsd.org>
From: Xin LI 
Date: Wed, 6 Apr 2011 20:54: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: r220403 - head/sys/dev/arcmsr
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, 06 Apr 2011 20:54:26 -0000

Author: delphij
Date: Wed Apr  6 20:54:26 2011
New Revision: 220403
URL: http://svn.freebsd.org/changeset/base/220403

Log:
  Update arcmsr(4) to vendor version 1.20.00.21.  This release primarily
  improves command timeout handling.
  
  Many thanks to Areca for continuing to support FreeBSD.
  
  Submitted by:	Ching-Lung Huang 
  MFC after:	2 months

Modified:
  head/sys/dev/arcmsr/arcmsr.c
  head/sys/dev/arcmsr/arcmsr.h

Modified: head/sys/dev/arcmsr/arcmsr.c
==============================================================================
--- head/sys/dev/arcmsr/arcmsr.c	Wed Apr  6 20:19:07 2011	(r220402)
+++ head/sys/dev/arcmsr/arcmsr.c	Wed Apr  6 20:54:26 2011	(r220403)
@@ -38,35 +38,42 @@
 ** History
 **
 **        REV#         DATE	            NAME	         DESCRIPTION
-**     1.00.00.00    3/31/2004		Erich Chen			 First release
-**     1.20.00.02   11/29/2004		Erich Chen			 bug fix with arcmsr_bus_reset when PHY error
-**     1.20.00.03    4/19/2005		Erich Chen			 add SATA 24 Ports adapter type support
+**     1.00.00.00	03/31/2004		Erich Chen			 First release
+**     1.20.00.02	11/29/2004		Erich Chen			 bug fix with arcmsr_bus_reset when PHY error
+**     1.20.00.03	04/19/2005		Erich Chen			 add SATA 24 Ports adapter type support
 **                                                       clean unused function
-**     1.20.00.12    9/12/2005		Erich Chen        	 bug fix with abort command handling, 
+**     1.20.00.12	09/12/2005		Erich Chen        	 bug fix with abort command handling, 
 **                                                       firmware version check 
 **                                                       and firmware update notify for hardware bug fix
 **                                                       handling if none zero high part physical address 
 **                                                       of srb resource 
-**     1.20.00.13    8/18/2006		Erich Chen			 remove pending srb and report busy
+**     1.20.00.13	08/18/2006		Erich Chen			 remove pending srb and report busy
 **                                                       add iop message xfer 
 **                                                       with scsi pass-through command
 **                                                       add new device id of sas raid adapters 
 **                                                       code fit for SPARC64 & PPC 
-**     1.20.00.14   02/05/2007		Erich Chen			 bug fix for incorrect ccb_h.status report
+**     1.20.00.14	02/05/2007		Erich Chen			 bug fix for incorrect ccb_h.status report
 **                                                       and cause g_vfs_done() read write error
-**     1.20.00.15   10/10/2007		Erich Chen			 support new RAID adapter type ARC120x
-**     1.20.00.16   10/10/2009		Erich Chen			 Bug fix for RAID adapter type ARC120x
+**     1.20.00.15	10/10/2007		Erich Chen			 support new RAID adapter type ARC120x
+**     1.20.00.16	10/10/2009		Erich Chen			 Bug fix for RAID adapter type ARC120x
 **                                                       bus_dmamem_alloc() with BUS_DMA_ZERO
 **     1.20.00.17	07/15/2010		Ching Huang			 Added support ARC1880
 **														 report CAM_DEV_NOT_THERE instead of CAM_SEL_TIMEOUT when device failed,
 **														 prevent cam_periph_error removing all LUN devices of one Target id
 **														 for any one LUN device failed
-**	   1.20.00.18	10/14/2010		Ching Huang			 Fixed "inquiry data fails comparion at DV1 step"
-**	   				10/25/2010		Ching Huang			 Fixed bad range input in bus_alloc_resource for ADAPTER_TYPE_B
-**	   1.20.00.19	11/11/2010		Ching Huang			 Fixed arcmsr driver prevent arcsas support for Areca SAS HBA ARC13x0
+**     1.20.00.18	10/14/2010		Ching Huang			 Fixed "inquiry data fails comparion at DV1 step"
+**               	10/25/2010		Ching Huang			 Fixed bad range input in bus_alloc_resource for ADAPTER_TYPE_B
+**     1.20.00.19	11/11/2010		Ching Huang			 Fixed arcmsr driver prevent arcsas support for Areca SAS HBA ARC13x0
+**     1.20.00.20	12/08/2010		Ching Huang			 Avoid calling atomic_set_int function
+**     1.20.00.21	02/08/2011		Ching Huang			 Implement I/O request timeout
+**               	02/14/2011		Ching Huang			 Modified pktRequestCount
+**     1.20.00.21	03/03/2011		Ching Huang			 if a command timeout, then wait its ccb back before free it
 ******************************************************************************************
 * $FreeBSD$
 */
+#if 0
+#define ARCMSR_DEBUG1			1
+#endif
 #include 
 #include 
 #include 
@@ -137,9 +144,16 @@
 #define	CAM_NEW_TRAN_CODE	1
 #endif
 
-#define ARCMSR_DRIVER_VERSION			"Driver Version 1.20.00.19 2010-11-11"
+#if __FreeBSD_version > 500000
+#define arcmsr_callout_init(a)	callout_init(a, /*mpsafe*/1);
+#else
+#define arcmsr_callout_init(a)	callout_init(a);
+#endif
+
+#define ARCMSR_DRIVER_VERSION			"Driver Version 1.20.00.21 2010-03-03"
 #include 
-#define ARCMSR_SRBS_POOL_SIZE           ((sizeof(struct CommandControlBlock) * ARCMSR_MAX_FREESRB_NUM))
+#define	SRB_SIZE						((sizeof(struct CommandControlBlock)+0x1f) & 0xffe0)
+#define ARCMSR_SRBS_POOL_SIZE           (SRB_SIZE * ARCMSR_MAX_FREESRB_NUM)
 /*
 **************************************************************************
 **************************************************************************
@@ -150,6 +164,7 @@
 **************************************************************************
 **************************************************************************
 */
+static void arcmsr_free_srb(struct CommandControlBlock *srb);
 static struct CommandControlBlock * arcmsr_get_freesrb(struct AdapterControlBlock *acb);
 static u_int8_t arcmsr_seek_cmd2abort(union ccb * abortccb);
 static int arcmsr_probe(device_t dev);
@@ -177,6 +192,10 @@ static int arcmsr_resume(device_t dev);
 static int arcmsr_suspend(device_t dev);
 static void arcmsr_rescanLun_cb(struct cam_periph *periph, union ccb *ccb);
 static void	arcmsr_polling_devmap(void* arg);
+static void	arcmsr_srb_timeout(void* arg);
+#ifdef ARCMSR_DEBUG1
+static void arcmsr_dump_data(struct AdapterControlBlock *acb);
+#endif
 /*
 **************************************************************************
 **************************************************************************
@@ -220,17 +239,13 @@ MODULE_DEPEND(arcmsr, cam, 1, 1, 1);
 	#define	BUS_DMA_COHERENT	0x04	/* hint: map memory in a coherent way */
 #endif
 #if __FreeBSD_version >= 501000
-	#ifndef D_NEEDGIANT
-		#define D_NEEDGIANT	0x00400000	/* driver want Giant */
-	#endif
-	#ifndef D_VERSION
-		#define D_VERSION	0x20011966
-	#endif
 static struct cdevsw arcmsr_cdevsw={
-	#if __FreeBSD_version > 502010
+	#if __FreeBSD_version >= 503000
 		.d_version = D_VERSION, 
 	#endif
+	#if (__FreeBSD_version>=503000 && __FreeBSD_version<600034)
 		.d_flags   = D_NEEDGIANT, 
+	#endif
 		.d_open    = arcmsr_open, 	/* open     */
 		.d_close   = arcmsr_close, 	/* close    */
 		.d_ioctl   = arcmsr_ioctl, 	/* ioctl    */
@@ -671,6 +686,8 @@ static void arcmsr_srb_complete(struct C
 	struct AdapterControlBlock *acb=srb->acb;
 	union ccb * pccb=srb->pccb;
 	
+	if(srb->srb_flags & SRB_FLAG_TIMER_START)
+		callout_stop(&srb->ccb_callout);
 	if((pccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
 		bus_dmasync_op_t op;
 	
@@ -690,11 +707,11 @@ static void arcmsr_srb_complete(struct C
 			pccb->ccb_h.status |= CAM_RELEASE_SIMQ;
 		}
 	}
-	srb->startdone=ARCMSR_SRB_DONE;
-	srb->srb_flags=0;
-	acb->srbworkingQ[acb->workingsrb_doneindex]=srb;
-	acb->workingsrb_doneindex++;
-	acb->workingsrb_doneindex %= ARCMSR_MAX_FREESRB_NUM;
+	if(srb->srb_state != ARCMSR_SRB_TIMEOUT)
+		arcmsr_free_srb(srb);
+#ifdef ARCMSR_DEBUG1
+	acb->pktReturnCount++;
+#endif
 	xpt_done(pccb);
 	return;
 }
@@ -761,7 +778,7 @@ static void arcmsr_drain_donequeue(struc
 	/* check if command done with no error*/
 	switch (acb->adapter_type) {
 	case ACB_ADAPTER_TYPE_C:
-		srb = (struct CommandControlBlock *)(acb->vir2phy_offset+(flag_srb & 0xFFFFFFF0));/*frame must be 32 bytes aligned*/
+		srb = (struct CommandControlBlock *)(acb->vir2phy_offset+(flag_srb & 0xFFFFFFE0));/*frame must be 32 bytes aligned*/
 		break;
 	case ACB_ADAPTER_TYPE_A:
 	case ACB_ADAPTER_TYPE_B:
@@ -769,22 +786,51 @@ static void arcmsr_drain_donequeue(struc
 		srb = (struct CommandControlBlock *)(acb->vir2phy_offset+(flag_srb << 5));/*frame must be 32 bytes aligned*/
 		break;
 	}
-	if((srb->acb!=acb) || (srb->startdone!=ARCMSR_SRB_START)) {
-		if(srb->startdone==ARCMSR_SRB_ABORTED) {
-			printf("arcmsr%d: srb='%p' isr got aborted command \n", acb->pci_unit, srb);
-			srb->pccb->ccb_h.status |= CAM_REQ_ABORTED;
-			arcmsr_srb_complete(srb, 1);
+	if((srb->acb!=acb) || (srb->srb_state!=ARCMSR_SRB_START)) {
+		if(srb->srb_state == ARCMSR_SRB_TIMEOUT) {
+			arcmsr_free_srb(srb);
+			printf("arcmsr%d: srb='%p' return srb has been timeouted\n", acb->pci_unit, srb);
 			return;
 		}
-		printf("arcmsr%d: isr get an illegal srb command done"
-			"acb='%p' srb='%p' srbacb='%p' startdone=0x%xsrboutstandingcount=%d \n",
-			acb->pci_unit, acb, srb, srb->acb,srb->startdone, acb->srboutstandingcount);
+		printf("arcmsr%d: return srb has been completed\n"
+			"srb='%p' srb_state=0x%x outstanding srb count=%d \n",
+			acb->pci_unit, srb, srb->srb_state, acb->srboutstandingcount);
 		return;
 	}
 	arcmsr_report_srb_state(acb, srb, error);
 	return;
 }
 /*
+**************************************************************************
+**************************************************************************
+*/
+static void	arcmsr_srb_timeout(void* arg)
+{
+	struct CommandControlBlock *srb = (struct CommandControlBlock *)arg;
+	struct AdapterControlBlock *acb;
+	int target, lun;
+	u_int8_t cmd;
+	
+	target=srb->pccb->ccb_h.target_id;
+	lun=srb->pccb->ccb_h.target_lun;
+	acb = srb->acb;
+	ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock);
+	if(srb->srb_state == ARCMSR_SRB_START)
+	{
+		cmd = srb->pccb->csio.cdb_io.cdb_bytes[0];
+		srb->srb_state = ARCMSR_SRB_TIMEOUT;
+		srb->pccb->ccb_h.status |= CAM_CMD_TIMEOUT;
+		arcmsr_srb_complete(srb, 1);
+		printf("arcmsr%d: scsi id %d lun %d cmd=0x%x srb='%p' ccb command time out!\n",
+				 acb->pci_unit, target, lun, cmd, srb);
+	}
+	ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock);
+#ifdef ARCMSR_DEBUG1
+    	arcmsr_dump_data(acb);
+#endif
+}
+
+/*
 **********************************************************************
 **********************************************************************
 */
@@ -855,18 +901,25 @@ static void arcmsr_iop_reset(struct Adap
 		arcmsr_abort_allcmd(acb);
 		for(i=0;ipsrb_pool[i];
-			if(srb->startdone==ARCMSR_SRB_START) {
-				srb->startdone=ARCMSR_SRB_ABORTED;
+			if(srb->srb_state==ARCMSR_SRB_START) {
+				srb->srb_state=ARCMSR_SRB_ABORTED;
 				srb->pccb->ccb_h.status |= CAM_REQ_ABORTED;
 				arcmsr_srb_complete(srb, 1);
+				printf("arcmsr%d: scsi id=%d lun=%d srb='%p' aborted\n"
+						, acb->pci_unit, srb->pccb->ccb_h.target_id
+						, srb->pccb->ccb_h.target_lun, srb);
 			}
 		}
 		/* enable all outbound interrupt */
 		arcmsr_enable_allintr(acb, intmask_org);
 	}
-	atomic_set_int(&acb->srboutstandingcount, 0);
+	acb->srboutstandingcount=0;
 	acb->workingsrb_doneindex=0;
 	acb->workingsrb_startindex=0;
+#ifdef ARCMSR_DEBUG1
+	acb->pktRequestCount = 0;
+	acb->pktReturnCount = 0;
+#endif
 	return;
 }
 /*
@@ -968,7 +1021,7 @@ static void arcmsr_post_srb(struct Adapt
 	
 	bus_dmamap_sync(acb->srb_dmat, acb->srb_dmamap, (srb->srb_flags & SRB_FLAG_WRITE) ? BUS_DMASYNC_POSTWRITE:BUS_DMASYNC_POSTREAD);
 	atomic_add_int(&acb->srboutstandingcount, 1);
-	srb->startdone=ARCMSR_SRB_START;
+	srb->srb_state=ARCMSR_SRB_START;
 
 	switch (acb->adapter_type) {
 	case ACB_ADAPTER_TYPE_A: {
@@ -1242,13 +1295,9 @@ static void arcmsr_poll(struct cam_sim *
 	struct AdapterControlBlock *acb;
 
 	acb = (struct AdapterControlBlock *)cam_sim_softc(psim);
-#if __FreeBSD_version < 700025
 	ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock);
-#endif
 	arcmsr_interrupt(acb);
-#if __FreeBSD_version < 700025
 	ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock);
-#endif
 	return;
 }
 /*
@@ -1377,13 +1426,14 @@ static void arcmsr_abort_dr_ccbs(struct 
 	for (i = 0; i < ARCMSR_MAX_FREESRB_NUM; i++)
 	{
 		srb = acb->psrb_pool[i];
-		if (srb->startdone == ARCMSR_SRB_START)
+		if (srb->srb_state == ARCMSR_SRB_START)
 		{
            	if((target == srb->pccb->ccb_h.target_id) && (lun == srb->pccb->ccb_h.target_lun))
             {
-		    	srb->startdone = ARCMSR_SRB_ABORTED;
+		    	srb->srb_state = ARCMSR_SRB_ABORTED;
 				srb->pccb->ccb_h.status |= CAM_REQ_ABORTED;
 		    	arcmsr_srb_complete(srb, 1);
+				printf("arcmsr%d: abort scsi id %d lun %d srb=%p \n", acb->pci_unit, target, lun, srb);
        		}
 		}
 	}
@@ -1461,7 +1511,7 @@ static void arcmsr_dr_handle(struct Adap
                         }
                         else
                         {/* unit arrived */
-							printf("arcmsr_dr_handle: Target=%x, lun=%x, ARRIVING!!!\n",target,lun);
+							printf("arcmsr_dr_handle: Target=%x, lun=%x, Plug-IN!!!\n",target,lun);
                         	arcmsr_rescan_lun(acb, target, lun);
         					acb->devstate[target][lun] = ARECA_RAID_GOOD;
                         }
@@ -2014,14 +2064,33 @@ u_int32_t arcmsr_iop_ioctlcmd(struct Ada
 **************************************************************************
 **************************************************************************
 */
+static void arcmsr_free_srb(struct CommandControlBlock *srb)
+{
+	struct AdapterControlBlock	*acb;
+	int	mutex;
+	
+	acb = srb->acb;
+	mutex = mtx_owned(&acb->qbuffer_lock);
+	if( mutex == 0 )
+		ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock);
+	srb->srb_state=ARCMSR_SRB_DONE;
+	srb->srb_flags=0;
+	acb->srbworkingQ[acb->workingsrb_doneindex]=srb;
+	acb->workingsrb_doneindex++;
+	acb->workingsrb_doneindex %= ARCMSR_MAX_FREESRB_NUM;
+	if( mutex == 0 )
+		ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock);
+}
+/*
+**************************************************************************
+**************************************************************************
+*/
 struct CommandControlBlock * arcmsr_get_freesrb(struct AdapterControlBlock *acb)
 {
 	struct CommandControlBlock *srb=NULL;
 	u_int32_t workingsrb_startindex, workingsrb_doneindex;
 
-#if __FreeBSD_version < 700025
 	ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock);
-#endif
 	workingsrb_doneindex=acb->workingsrb_doneindex;
 	workingsrb_startindex=acb->workingsrb_startindex;
 	srb=acb->srbworkingQ[workingsrb_startindex];
@@ -2032,9 +2101,7 @@ struct CommandControlBlock * arcmsr_get_
 	} else {
 		srb=NULL;
 	}
-#if __FreeBSD_version < 700025
 	ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock);
-#endif
 	return(srb);
 }
 /*
@@ -2250,6 +2317,9 @@ static void arcmsr_execute_srb(void *arg
 	pccb=srb->pccb;
 	target=pccb->ccb_h.target_id;
 	lun=pccb->ccb_h.target_lun;
+#ifdef ARCMSR_DEBUG1
+	acb->pktRequestCount++;
+#endif
 	if(error != 0) {
 		if(error != EFBIG) {
 			printf("arcmsr%d: unexpected error %x"
@@ -2274,13 +2344,14 @@ static void arcmsr_execute_srb(void *arg
 		return;
 	}
 	if(acb->devstate[target][lun]==ARECA_RAID_GONE) {
-		u_int8_t block_cmd;
+		u_int8_t block_cmd, cmd;
 
-		block_cmd=pccb->csio.cdb_io.cdb_bytes[0] & 0x0f;
+		cmd = pccb->csio.cdb_io.cdb_bytes[0];
+		block_cmd= cmd & 0x0f;
 		if(block_cmd==0x08 || block_cmd==0x0a) {
 			printf("arcmsr%d:block 'read/write' command "
-				"with gone raid volume Cmd=%2x, TargetId=%d, Lun=%d \n"
-				, acb->pci_unit, block_cmd, target, lun);
+				"with gone raid volume Cmd=0x%2x, TargetId=%d, Lun=%d \n"
+				, acb->pci_unit, cmd, target, lun);
 			pccb->ccb_h.status |= CAM_DEV_NOT_THERE;
 			arcmsr_srb_complete(srb, 0);
 			return;
@@ -2302,10 +2373,13 @@ static void arcmsr_execute_srb(void *arg
 	}
 	pccb->ccb_h.status |= CAM_SIM_QUEUED;
 	arcmsr_build_srb(srb, dm_segs, nseg);
-/*	if (pccb->ccb_h.timeout != CAM_TIME_INFINITY)
-		callout_reset(&srb->ccb_callout, (pccb->ccb_h.timeout * hz) / 1000, arcmsr_srb_timeout, srb);
-*/
 	arcmsr_post_srb(acb, srb);
+	if (pccb->ccb_h.timeout != CAM_TIME_INFINITY)
+	{
+		arcmsr_callout_init(&srb->ccb_callout);
+		callout_reset(&srb->ccb_callout, (pccb->ccb_h.timeout * hz ) / 1000, arcmsr_srb_timeout, srb);
+		srb->srb_flags |= SRB_FLAG_TIMER_START;
+	}
 	return;
 }
 /*
@@ -2330,28 +2404,28 @@ static u_int8_t arcmsr_seek_cmd2abort(un
 	***************************************************************************
 	*/
 	if(acb->srboutstandingcount!=0) {
+		/* disable all outbound interrupt */
+		intmask_org=arcmsr_disable_allintr(acb);
 		for(i=0;ipsrb_pool[i];
-			if(srb->startdone==ARCMSR_SRB_START) {
+			if(srb->srb_state==ARCMSR_SRB_START) {
 				if(srb->pccb==abortccb) {
-					srb->startdone=ARCMSR_SRB_ABORTED;
+					srb->srb_state=ARCMSR_SRB_ABORTED;
 					printf("arcmsr%d:scsi id=%d lun=%d abort srb '%p'"
 						"outstanding command \n"
 						, acb->pci_unit, abortccb->ccb_h.target_id
 						, abortccb->ccb_h.target_lun, srb);
-					goto abort_outstanding_cmd;
+					arcmsr_polling_srbdone(acb, srb);
+					/* enable outbound Post Queue, outbound doorbell Interrupt */
+					arcmsr_enable_allintr(acb, intmask_org);
+					return (TRUE);
 				}
 			}
 		}
+		/* enable outbound Post Queue, outbound doorbell Interrupt */
+		arcmsr_enable_allintr(acb, intmask_org);
 	}
 	return(FALSE);
-abort_outstanding_cmd:
-	/* disable all outbound interrupt */
-	intmask_org=arcmsr_disable_allintr(acb);
-	arcmsr_polling_srbdone(acb, srb);
-	/* enable outbound Post Queue, outbound doorbell Interrupt */
-	arcmsr_enable_allintr(acb, intmask_org);
-	return (TRUE);
 }
 /*
 ****************************************************************************
@@ -2764,8 +2838,8 @@ polling_ccb_retry:
 			(acb->vir2phy_offset+(flag_srb << 5));/*frame must be 32 bytes aligned*/
         error=(flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE0)?TRUE:FALSE;
 		poll_srb_done = (srb==poll_srb) ? 1:0;
-		if((srb->acb!=acb) || (srb->startdone!=ARCMSR_SRB_START)) {
-			if(srb->startdone==ARCMSR_SRB_ABORTED) {
+		if((srb->acb!=acb) || (srb->srb_state!=ARCMSR_SRB_START)) {
+			if(srb->srb_state==ARCMSR_SRB_ABORTED) {
 				printf("arcmsr%d: scsi id=%d lun=%d srb='%p'"
 					"poll command abort successfully \n"
 					, acb->pci_unit
@@ -2825,8 +2899,8 @@ polling_ccb_retry:
 			(acb->vir2phy_offset+(flag_srb << 5));/*frame must be 32 bytes aligned*/
         error=(flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE0)?TRUE:FALSE;
 		poll_srb_done = (srb==poll_srb) ? 1:0;
-		if((srb->acb!=acb) || (srb->startdone!=ARCMSR_SRB_START)) {
-			if(srb->startdone==ARCMSR_SRB_ABORTED) {
+		if((srb->acb!=acb) || (srb->srb_state!=ARCMSR_SRB_START)) {
+			if(srb->srb_state==ARCMSR_SRB_ABORTED) {
 				printf("arcmsr%d: scsi id=%d lun=%d srb='%p'"
 					"poll command abort successfully \n"
 					, acb->pci_unit
@@ -2877,12 +2951,12 @@ polling_ccb_retry:
 		}
 		flag_srb = CHIP_REG_READ32(HBC_MessageUnit, 0, outbound_queueport_low);
 		/* check if command done with no error*/
-		srb=(struct CommandControlBlock *)(acb->vir2phy_offset+(flag_srb & 0xFFFFFFF0));/*frame must be 32 bytes aligned*/
+		srb=(struct CommandControlBlock *)(acb->vir2phy_offset+(flag_srb & 0xFFFFFFE0));/*frame must be 32 bytes aligned*/
         error=(flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE1)?TRUE:FALSE;
 		if (poll_srb != NULL)
 			poll_srb_done = (srb==poll_srb) ? 1:0;
-		if((srb->acb!=acb) || (srb->startdone!=ARCMSR_SRB_START)) {
-			if(srb->startdone==ARCMSR_SRB_ABORTED) {
+		if((srb->acb!=acb) || (srb->srb_state!=ARCMSR_SRB_START)) {
+			if(srb->srb_state==ARCMSR_SRB_ABORTED) {
 				printf("arcmsr%d: scsi id=%d lun=%d srb='%p'poll command abort successfully \n"
 						, acb->pci_unit, srb->pccb->ccb_h.target_id, srb->pccb->ccb_h.target_lun, srb);
 				srb->pccb->ccb_h.status |= CAM_REQ_ABORTED;
@@ -3213,7 +3287,7 @@ static u_int32_t arcmsr_iop_confirm(stru
 				printf( "arcmsr%d: 'set window of post command Q' timeout\n", acb->pci_unit);
 				return FALSE;
 			}
-			post_queue_phyaddr = srb_phyaddr + ARCMSR_MAX_FREESRB_NUM*sizeof(struct CommandControlBlock) 
+			post_queue_phyaddr = srb_phyaddr + ARCMSR_SRBS_POOL_SIZE 
 								+ offsetof(struct HBB_MessageUnit, post_qbuffer);
 			CHIP_REG_WRITE32(HBB_RWBUFFER, 1, msgcode_rwbuffer[0], ARCMSR_SIGNATURE_SET_CONFIG); /* driver "set config" signature */
 			CHIP_REG_WRITE32(HBB_RWBUFFER, 1, msgcode_rwbuffer[1], srb_phyaddr_hi32); /* normal should be zero */
@@ -3320,8 +3394,8 @@ static void arcmsr_map_free_srb(void *ar
 		srb_tmp->cdb_shifted_phyaddr=(acb->adapter_type==ACB_ADAPTER_TYPE_C)?srb_phyaddr:(srb_phyaddr >> 5);
 		srb_tmp->acb=acb;
 		acb->srbworkingQ[i]=acb->psrb_pool[i]=srb_tmp;
-		srb_phyaddr=srb_phyaddr+sizeof(struct CommandControlBlock);
-		srb_tmp++;
+		srb_phyaddr=srb_phyaddr+SRB_SIZE;
+		srb_tmp = (struct CommandControlBlock *)((unsigned long)srb_tmp+SRB_SIZE);
 	}
 	acb->vir2phy_offset=(unsigned long)srb_tmp-(unsigned long)srb_phyaddr;
 	return;
@@ -3407,7 +3481,7 @@ static u_int32_t arcmsr_initialize(devic
 							/*nsegments*/	BUS_SPACE_UNRESTRICTED,
 							/*maxsegsz*/	BUS_SPACE_MAXSIZE_32BIT,
 							/*flags*/		0,
-#if __FreeBSD_version >= 502010
+#if __FreeBSD_version >= 501102
 							/*lockfunc*/	NULL,
 							/*lockarg*/		NULL,
 #endif
@@ -3421,7 +3495,11 @@ static u_int32_t arcmsr_initialize(devic
 	if(bus_dma_tag_create(  /*parent_dmat*/	acb->parent_dmat,
 							/*alignment*/	1,
 							/*boundary*/	0,
+#ifdef PAE
+							/*lowaddr*/		BUS_SPACE_MAXADDR_32BIT,
+#else
 							/*lowaddr*/		BUS_SPACE_MAXADDR,
+#endif
 							/*highaddr*/	BUS_SPACE_MAXADDR,
 							/*filter*/		NULL,
 							/*filterarg*/	NULL,
@@ -3429,13 +3507,9 @@ static u_int32_t arcmsr_initialize(devic
 							/*nsegments*/	ARCMSR_MAX_SG_ENTRIES,
 							/*maxsegsz*/	BUS_SPACE_MAXSIZE_32BIT,
 							/*flags*/		0,
-#if __FreeBSD_version >= 502010
+#if __FreeBSD_version >= 501102
 							/*lockfunc*/	busdma_lock_mutex,
-	#if __FreeBSD_version >= 700025
 							/*lockarg*/		&acb->qbuffer_lock,
-	#else
-							/*lockarg*/		&Giant,
-	#endif
 #endif
 						&acb->dm_segs_dmat) != 0)
 	{
@@ -3456,7 +3530,7 @@ static u_int32_t arcmsr_initialize(devic
 							/*nsegments*/	1,
 							/*maxsegsz*/	BUS_SPACE_MAXSIZE_32BIT,
 							/*flags*/		0,
-#if __FreeBSD_version >= 502010
+#if __FreeBSD_version >= 501102
 							/*lockfunc*/	NULL,
 							/*lockarg*/		NULL,
 #endif
@@ -3550,7 +3624,8 @@ static u_int32_t arcmsr_initialize(devic
 				acb->bhandle[i]=rman_get_bushandle(acb->sys_res_arcmsr[i]);
 			}
 			freesrb=(struct CommandControlBlock *)acb->uncacheptr;
-			acb->pmu=(struct MessageUnit_UNION *)&freesrb[ARCMSR_MAX_FREESRB_NUM];
+//			acb->pmu=(struct MessageUnit_UNION *)&freesrb[ARCMSR_MAX_FREESRB_NUM];
+			acb->pmu=(struct MessageUnit_UNION *)((unsigned long)freesrb+ARCMSR_SRBS_POOL_SIZE);
 			phbbmu=(struct HBB_MessageUnit *)acb->pmu;
 			phbbmu->hbb_doorbell=(struct HBB_DOORBELL *)mem_base[0];
 			phbbmu->hbb_rwbuffer=(struct HBB_RWBUFFER *)mem_base[1];
@@ -3711,14 +3786,11 @@ static int arcmsr_attach(device_t dev)
 #if __FreeBSD_version > 500005
 	(void)make_dev_alias(acb->ioctl_dev, "arc%d", unit);
 #endif
-#if __FreeBSD_version > 500000
-	callout_init(&acb->devmap_callout, /*mpsafe*/1);
-#else
-	callout_init(&acb->devmap_callout);
-#endif
+	arcmsr_callout_init(&acb->devmap_callout);
 	callout_reset(&acb->devmap_callout, 60 * hz, arcmsr_polling_devmap, acb);
 	return 0;
 }
+
 /*
 ************************************************************************
 ************************************************************************
@@ -3802,16 +3874,20 @@ static int arcmsr_shutdown(device_t dev)
 		arcmsr_abort_allcmd(acb);
 		for(i=0;ipsrb_pool[i];
-			if(srb->startdone==ARCMSR_SRB_START) {
-				srb->startdone=ARCMSR_SRB_ABORTED;
+			if(srb->srb_state==ARCMSR_SRB_START) {
+				srb->srb_state=ARCMSR_SRB_ABORTED;
 				srb->pccb->ccb_h.status |= CAM_REQ_ABORTED;
 				arcmsr_srb_complete(srb, 1);
 			}
 		}
 	}
-	atomic_set_int(&acb->srboutstandingcount, 0);
+	acb->srboutstandingcount=0;
 	acb->workingsrb_doneindex=0;
 	acb->workingsrb_startindex=0;
+#ifdef ARCMSR_DEBUG1
+	acb->pktRequestCount = 0;
+	acb->pktReturnCount = 0;
+#endif
 	ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock);
 	return (0);
 }
@@ -3842,4 +3918,15 @@ static int arcmsr_detach(device_t dev)
 	return (0);
 }
 
+#ifdef ARCMSR_DEBUG1
+static void arcmsr_dump_data(struct AdapterControlBlock *acb)
+{
+	if((acb->pktRequestCount - acb->pktReturnCount) == 0)
+		return;
+	printf("Command Request Count   =0x%x\n",acb->pktRequestCount);
+	printf("Command Return Count    =0x%x\n",acb->pktReturnCount);
+	printf("Command (Req-Rtn) Count =0x%x\n",(acb->pktRequestCount - acb->pktReturnCount));
+	printf("Queued Command Count    =0x%x\n",acb->srboutstandingcount);
+}
+#endif
 

Modified: head/sys/dev/arcmsr/arcmsr.h
==============================================================================
--- head/sys/dev/arcmsr/arcmsr.h	Wed Apr  6 20:19:07 2011	(r220402)
+++ head/sys/dev/arcmsr/arcmsr.h	Wed Apr  6 20:54:26 2011	(r220403)
@@ -46,7 +46,7 @@
 #define ARCMSR_MAX_OUTSTANDING_CMD			256
 #define ARCMSR_MAX_START_JOB				257
 #define ARCMSR_MAX_CMD_PERLUN				ARCMSR_MAX_OUTSTANDING_CMD
-#define ARCMSR_MAX_FREESRB_NUM				320
+#define ARCMSR_MAX_FREESRB_NUM				384
 #define ARCMSR_MAX_QBUFFER					4096 /* ioctl QBUFFER */
 #define ARCMSR_MAX_SG_ENTRIES				38 /* max 38*/
 #define ARCMSR_MAX_ADAPTER					4
@@ -714,23 +714,13 @@ struct CommandControlBlock {
 	u_int32_t					cdb_shifted_phyaddr;	/* 504-507 */
 	u_int32_t					arc_cdb_size;			/* 508-511 */
 	/*  ======================512+32 bytes============================  */
-#if defined(__x86_64__) || defined(__amd64__) || defined(__ia64__) || defined(__sparc64__) || defined(__powerpc__)
 	union ccb					*pccb;					/* 512-515 516-519 pointer of freebsd scsi command */
 	struct AdapterControlBlock	*acb;					/* 520-523 524-527 */
 	bus_dmamap_t				dm_segs_dmamap;			/* 528-531 532-535 */
 	u_int16_t   				srb_flags;				/* 536-537 */
-	u_int16_t					startdone;                /* 538-539 */
-	u_int32_t					reserved2;                /* 540-543 */
-#else
-	union ccb					*pccb;                    /* 512-515 pointer of freebsd scsi command */
-	struct AdapterControlBlock	*acb;                     /* 516-519 */
-	bus_dmamap_t				dm_segs_dmamap;           /* 520-523 */
-	u_int16_t   				srb_flags;                /* 524-525 */
-	u_int16_t					startdone;                /* 526-527 */
-	u_int32_t					reserved2[4];             /* 528-531 532-535 536-539 540-543 */
-#endif
+	u_int16_t					srb_state;                /* 538-539 */
+	struct	callout				ccb_callout;
     /*  ==========================================================  */
-/*	struct	callout				ccb_callout; */
 };
 /*	srb_flags */
 #define		SRB_FLAG_READ				0x0000
@@ -742,7 +732,8 @@ struct CommandControlBlock {
 #define		SRB_FLAG_DMACONSISTENT  	0x0020
 #define		SRB_FLAG_DMAWRITE			0x0040
 #define		SRB_FLAG_PKTBIND			0x0080
-/*	startdone */
+#define		SRB_FLAG_TIMER_START		0x0080
+/*	srb_state */
 #define		ARCMSR_SRB_DONE   			0x0000
 #define		ARCMSR_SRB_UNBUILD 			0x0000
 #define		ARCMSR_SRB_TIMEOUT 			0x1111
@@ -775,18 +766,18 @@ struct AdapterControlBlock {
 #if __FreeBSD_version < 503000
 	dev_t						ioctl_dev;
 #else
-	struct cdev *				ioctl_dev;
+	struct cdev					*ioctl_dev;
 #endif
 	int							pci_unit;
 	
-	struct resource *			sys_res_arcmsr[2];
-	struct resource *			irqres;
-	void *						ih;                         /* interrupt handle */
+	struct resource				*sys_res_arcmsr[2];
+	struct resource				*irqres;
+	void						*ih;                         /* interrupt handle */
 	
 	/* Hooks into the CAM XPT */
 	struct						cam_sim *psim;
 	struct						cam_path *ppath;
-	u_int8_t *					uncacheptr;
+	u_int8_t					*uncacheptr;
 	unsigned long				vir2phy_offset;
 	union	{
 		unsigned long			phyaddr;
@@ -799,14 +790,14 @@ struct AdapterControlBlock {
 	/* Offset is used in making arc cdb physical to virtual calculations */
 	u_int32_t					outbound_int_enable;
 	
-	struct MessageUnit_UNION *	pmu;                        /* message unit ATU inbound base address0 */
+	struct MessageUnit_UNION	*pmu;                        /* message unit ATU inbound base address0 */
 	
 	u_int8_t					adapter_index;              /*  */
 	u_int8_t					irq;
 	u_int16_t					acb_flags;                  /*  */
 	
-	struct CommandControlBlock *	psrb_pool[ARCMSR_MAX_FREESRB_NUM];     /* serial srb pointer array */
-	struct CommandControlBlock *	srbworkingQ[ARCMSR_MAX_FREESRB_NUM];   /* working srb pointer array */
+	struct CommandControlBlock *psrb_pool[ARCMSR_MAX_FREESRB_NUM];     /* serial srb pointer array */
+	struct CommandControlBlock *srbworkingQ[ARCMSR_MAX_FREESRB_NUM];   /* working srb pointer array */
 	int32_t						workingsrb_doneindex;                  /* done srb array index */
 	int32_t						workingsrb_startindex;                 /* start srb array index  */
 	int32_t						srboutstandingcount;
@@ -835,6 +826,10 @@ struct AdapterControlBlock {
 	char						firm_version[20];           /*17,68-83*/
 	char						device_map[20];				/*21,84-99 */
 	struct	callout				devmap_callout;
+#ifdef ARCMSR_DEBUG1
+	u_int32_t					pktRequestCount;
+	u_int32_t					pktReturnCount;
+#endif	
 };/* HW_DEVICE_EXTENSION */
 /* acb_flags */
 #define ACB_F_SCSISTOPADAPTER           0x0001

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 21:04:16 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: by hub.freebsd.org (Postfix, from userid 1233)
	id 9D8311065740; Wed,  6 Apr 2011 21:04:16 +0000 (UTC)
Date: Wed, 6 Apr 2011 21:04:16 +0000
From: Alexander Best 
To: Ulrich Spoerlein 
Message-ID: <20110406210416.GA62173@freebsd.org>
References: <201104062008.p36K8NR0015687@svn.freebsd.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <201104062008.p36K8NR0015687@svn.freebsd.org>
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220401 - in head: . share/mk tools/build/mk
	tools/build/options
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, 06 Apr 2011 21:04:16 -0000

On Wed Apr  6 11, Ulrich Spoerlein wrote:
> Author: uqs
> Date: Wed Apr  6 20:08:23 2011
> New Revision: 220401
> URL: http://svn.freebsd.org/changeset/base/220401
> 
> Log:
>   Complete WITHOUT_CXX support. It implies WITHOUT_GROFF and
>   WITHOUT_CLANG.

is there no way to build clang/llvm without CXX support?

cheers.
alex

>   
>   Don't build clang bootstrap/build-tools depending on this flag. We also
>   keep gperf, devd and libstdc++ around to prevent foot-shooting and to
>   make this a two-way street.
> 
> Modified:
>   head/Makefile.inc1
>   head/share/mk/bsd.own.mk
>   head/tools/build/mk/OptionalObsoleteFiles.inc
>   head/tools/build/options/WITHOUT_CXX
> 
> Modified: head/Makefile.inc1
> ==============================================================================
> --- head/Makefile.inc1	Wed Apr  6 19:13:04 2011	(r220400)
> +++ head/Makefile.inc1	Wed Apr  6 20:08:23 2011	(r220401)
> @@ -1127,10 +1127,12 @@ _kgzip=		usr.sbin/kgzip
>  .endif
>  .endif
>  
> +.if ${MK_CLANG} != "no"
>  .if ${CC:T:Mclang} == "clang"
>  _clang=		usr.bin/clang
>  _clang_libs=	lib/clang
>  .endif
> +.endif
>  
>  cross-tools:
>  .for _tool in \
> 
> Modified: head/share/mk/bsd.own.mk
> ==============================================================================
> --- head/share/mk/bsd.own.mk	Wed Apr  6 19:13:04 2011	(r220400)
> +++ head/share/mk/bsd.own.mk	Wed Apr  6 20:08:23 2011	(r220401)
> @@ -500,6 +500,11 @@ MK_OPENSSH:=	no
>  MK_KERBEROS:=	no
>  .endif
>  
> +.if ${MK_CXX} == "no"
> +MK_CLANG:=	no
> +MK_GROFF:=	no
> +.endif
> +
>  .if ${MK_IPX} == "no"
>  MK_NCP:=	no
>  .endif
> 
> Modified: head/tools/build/mk/OptionalObsoleteFiles.inc
> ==============================================================================
> --- head/tools/build/mk/OptionalObsoleteFiles.inc	Wed Apr  6 19:13:04 2011	(r220400)
> +++ head/tools/build/mk/OptionalObsoleteFiles.inc	Wed Apr  6 20:08:23 2011	(r220401)
> @@ -689,9 +689,575 @@ OLD_FILES+=usr/share/man/man5/cvs.5.gz
>  OLD_FILES+=usr/share/man/man8/cvsbug.8.gz
>  .endif
>  
> -#.if ${MK_CXX} == no
> -# to be filled in
> -#.endif
> +# devd(8) and gperf(1) not listed here on purpose
> +.if ${MK_CXX} == no
> +OLD_FILES+=usr/bin/CC
> +OLD_FILES+=usr/bin/c++
> +OLD_FILES+=usr/bin/c++filt
> +OLD_FILES+=usr/bin/g++
> +OLD_FILES+=usr/include/c++/4.2/algorithm
> +OLD_FILES+=usr/include/c++/4.2/backward/algo.h
> +OLD_FILES+=usr/include/c++/4.2/backward/algobase.h
> +OLD_FILES+=usr/include/c++/4.2/backward/alloc.h
> +OLD_FILES+=usr/include/c++/4.2/backward/backward_warning.h
> +OLD_FILES+=usr/include/c++/4.2/backward/bvector.h
> +OLD_FILES+=usr/include/c++/4.2/backward/complex.h
> +OLD_FILES+=usr/include/c++/4.2/backward/defalloc.h
> +OLD_FILES+=usr/include/c++/4.2/backward/deque.h
> +OLD_FILES+=usr/include/c++/4.2/backward/fstream.h
> +OLD_FILES+=usr/include/c++/4.2/backward/function.h
> +OLD_FILES+=usr/include/c++/4.2/backward/hash_map.h
> +OLD_FILES+=usr/include/c++/4.2/backward/hash_set.h
> +OLD_FILES+=usr/include/c++/4.2/backward/hashtable.h
> +OLD_FILES+=usr/include/c++/4.2/backward/heap.h
> +OLD_FILES+=usr/include/c++/4.2/backward/iomanip.h
> +OLD_FILES+=usr/include/c++/4.2/backward/iostream.h
> +OLD_FILES+=usr/include/c++/4.2/backward/istream.h
> +OLD_FILES+=usr/include/c++/4.2/backward/iterator.h
> +OLD_FILES+=usr/include/c++/4.2/backward/list.h
> +OLD_FILES+=usr/include/c++/4.2/backward/map.h
> +OLD_FILES+=usr/include/c++/4.2/backward/multimap.h
> +OLD_FILES+=usr/include/c++/4.2/backward/multiset.h
> +OLD_FILES+=usr/include/c++/4.2/backward/new.h
> +OLD_FILES+=usr/include/c++/4.2/backward/ostream.h
> +OLD_FILES+=usr/include/c++/4.2/backward/pair.h
> +OLD_FILES+=usr/include/c++/4.2/backward/queue.h
> +OLD_FILES+=usr/include/c++/4.2/backward/rope.h
> +OLD_FILES+=usr/include/c++/4.2/backward/set.h
> +OLD_FILES+=usr/include/c++/4.2/backward/slist.h
> +OLD_FILES+=usr/include/c++/4.2/backward/stack.h
> +OLD_FILES+=usr/include/c++/4.2/backward/stream.h
> +OLD_FILES+=usr/include/c++/4.2/backward/streambuf.h
> +OLD_FILES+=usr/include/c++/4.2/backward/strstream
> +OLD_FILES+=usr/include/c++/4.2/backward/tempbuf.h
> +OLD_FILES+=usr/include/c++/4.2/backward/tree.h
> +OLD_FILES+=usr/include/c++/4.2/backward/vector.h
> +OLD_FILES+=usr/include/c++/4.2/bits/allocator.h
> +OLD_FILES+=usr/include/c++/4.2/bits/atomic_word.h
> +OLD_FILES+=usr/include/c++/4.2/bits/basic_file.h
> +OLD_FILES+=usr/include/c++/4.2/bits/basic_ios.h
> +OLD_FILES+=usr/include/c++/4.2/bits/basic_ios.tcc
> +OLD_FILES+=usr/include/c++/4.2/bits/basic_string.h
> +OLD_FILES+=usr/include/c++/4.2/bits/basic_string.tcc
> +OLD_FILES+=usr/include/c++/4.2/bits/boost_concept_check.h
> +OLD_FILES+=usr/include/c++/4.2/bits/c++allocator.h
> +OLD_FILES+=usr/include/c++/4.2/bits/c++config.h
> +OLD_FILES+=usr/include/c++/4.2/bits/c++io.h
> +OLD_FILES+=usr/include/c++/4.2/bits/c++locale.h
> +OLD_FILES+=usr/include/c++/4.2/bits/c++locale_internal.h
> +OLD_FILES+=usr/include/c++/4.2/bits/char_traits.h
> +OLD_FILES+=usr/include/c++/4.2/bits/cmath.tcc
> +OLD_FILES+=usr/include/c++/4.2/bits/codecvt.h
> +OLD_FILES+=usr/include/c++/4.2/bits/compatibility.h
> +OLD_FILES+=usr/include/c++/4.2/bits/concept_check.h
> +OLD_FILES+=usr/include/c++/4.2/bits/cpp_type_traits.h
> +OLD_FILES+=usr/include/c++/4.2/bits/cpu_defines.h
> +OLD_FILES+=usr/include/c++/4.2/bits/ctype_base.h
> +OLD_FILES+=usr/include/c++/4.2/bits/ctype_inline.h
> +OLD_FILES+=usr/include/c++/4.2/bits/ctype_noninline.h
> +OLD_FILES+=usr/include/c++/4.2/bits/cxxabi_tweaks.h
> +OLD_FILES+=usr/include/c++/4.2/bits/deque.tcc
> +OLD_FILES+=usr/include/c++/4.2/bits/fstream.tcc
> +OLD_FILES+=usr/include/c++/4.2/bits/functexcept.h
> +OLD_FILES+=usr/include/c++/4.2/bits/gslice.h
> +OLD_FILES+=usr/include/c++/4.2/bits/gslice_array.h
> +OLD_FILES+=usr/include/c++/4.2/bits/gthr-default.h
> +OLD_FILES+=usr/include/c++/4.2/bits/gthr-posix.h
> +OLD_FILES+=usr/include/c++/4.2/bits/gthr-single.h
> +OLD_FILES+=usr/include/c++/4.2/bits/gthr-tpf.h
> +OLD_FILES+=usr/include/c++/4.2/bits/gthr.h
> +OLD_FILES+=usr/include/c++/4.2/bits/indirect_array.h
> +OLD_FILES+=usr/include/c++/4.2/bits/ios_base.h
> +OLD_FILES+=usr/include/c++/4.2/bits/istream.tcc
> +OLD_FILES+=usr/include/c++/4.2/bits/list.tcc
> +OLD_FILES+=usr/include/c++/4.2/bits/locale_classes.h
> +OLD_FILES+=usr/include/c++/4.2/bits/locale_facets.h
> +OLD_FILES+=usr/include/c++/4.2/bits/locale_facets.tcc
> +OLD_FILES+=usr/include/c++/4.2/bits/localefwd.h
> +OLD_FILES+=usr/include/c++/4.2/bits/mask_array.h
> +OLD_FILES+=usr/include/c++/4.2/bits/messages_members.h
> +OLD_FILES+=usr/include/c++/4.2/bits/os_defines.h
> +OLD_FILES+=usr/include/c++/4.2/bits/ostream.tcc
> +OLD_FILES+=usr/include/c++/4.2/bits/ostream_insert.h
> +OLD_FILES+=usr/include/c++/4.2/bits/postypes.h
> +OLD_FILES+=usr/include/c++/4.2/bits/slice_array.h
> +OLD_FILES+=usr/include/c++/4.2/bits/sstream.tcc
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_algo.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_algobase.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_bvector.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_construct.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_deque.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_function.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_heap.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_iterator.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_iterator_base_funcs.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_iterator_base_types.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_list.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_map.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_multimap.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_multiset.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_numeric.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_pair.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_queue.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_raw_storage_iter.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_relops.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_set.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_stack.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_tempbuf.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_tree.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_uninitialized.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stl_vector.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stream_iterator.h
> +OLD_FILES+=usr/include/c++/4.2/bits/streambuf.tcc
> +OLD_FILES+=usr/include/c++/4.2/bits/streambuf_iterator.h
> +OLD_FILES+=usr/include/c++/4.2/bits/stringfwd.h
> +OLD_FILES+=usr/include/c++/4.2/bits/time_members.h
> +OLD_FILES+=usr/include/c++/4.2/bits/valarray_after.h
> +OLD_FILES+=usr/include/c++/4.2/bits/valarray_array.h
> +OLD_FILES+=usr/include/c++/4.2/bits/valarray_array.tcc
> +OLD_FILES+=usr/include/c++/4.2/bits/valarray_before.h
> +OLD_FILES+=usr/include/c++/4.2/bits/vector.tcc
> +OLD_FILES+=usr/include/c++/4.2/bitset
> +OLD_FILES+=usr/include/c++/4.2/cassert
> +OLD_FILES+=usr/include/c++/4.2/cctype
> +OLD_FILES+=usr/include/c++/4.2/cerrno
> +OLD_FILES+=usr/include/c++/4.2/cfloat
> +OLD_FILES+=usr/include/c++/4.2/ciso646
> +OLD_FILES+=usr/include/c++/4.2/climits
> +OLD_FILES+=usr/include/c++/4.2/clocale
> +OLD_FILES+=usr/include/c++/4.2/cmath
> +OLD_FILES+=usr/include/c++/4.2/complex
> +OLD_FILES+=usr/include/c++/4.2/csetjmp
> +OLD_FILES+=usr/include/c++/4.2/csignal
> +OLD_FILES+=usr/include/c++/4.2/cstdarg
> +OLD_FILES+=usr/include/c++/4.2/cstddef
> +OLD_FILES+=usr/include/c++/4.2/cstdio
> +OLD_FILES+=usr/include/c++/4.2/cstdlib
> +OLD_FILES+=usr/include/c++/4.2/cstring
> +OLD_FILES+=usr/include/c++/4.2/ctime
> +OLD_FILES+=usr/include/c++/4.2/cwchar
> +OLD_FILES+=usr/include/c++/4.2/cwctype
> +OLD_FILES+=usr/include/c++/4.2/cxxabi.h
> +OLD_FILES+=usr/include/c++/4.2/debug/bitset
> +OLD_FILES+=usr/include/c++/4.2/debug/debug.h
> +OLD_FILES+=usr/include/c++/4.2/debug/deque
> +OLD_FILES+=usr/include/c++/4.2/debug/formatter.h
> +OLD_FILES+=usr/include/c++/4.2/debug/functions.h
> +OLD_FILES+=usr/include/c++/4.2/debug/hash_map
> +OLD_FILES+=usr/include/c++/4.2/debug/hash_map.h
> +OLD_FILES+=usr/include/c++/4.2/debug/hash_multimap.h
> +OLD_FILES+=usr/include/c++/4.2/debug/hash_multiset.h
> +OLD_FILES+=usr/include/c++/4.2/debug/hash_set
> +OLD_FILES+=usr/include/c++/4.2/debug/hash_set.h
> +OLD_FILES+=usr/include/c++/4.2/debug/list
> +OLD_FILES+=usr/include/c++/4.2/debug/macros.h
> +OLD_FILES+=usr/include/c++/4.2/debug/map
> +OLD_FILES+=usr/include/c++/4.2/debug/map.h
> +OLD_FILES+=usr/include/c++/4.2/debug/multimap.h
> +OLD_FILES+=usr/include/c++/4.2/debug/multiset.h
> +OLD_FILES+=usr/include/c++/4.2/debug/safe_base.h
> +OLD_FILES+=usr/include/c++/4.2/debug/safe_iterator.h
> +OLD_FILES+=usr/include/c++/4.2/debug/safe_iterator.tcc
> +OLD_FILES+=usr/include/c++/4.2/debug/safe_sequence.h
> +OLD_FILES+=usr/include/c++/4.2/debug/set
> +OLD_FILES+=usr/include/c++/4.2/debug/set.h
> +OLD_FILES+=usr/include/c++/4.2/debug/string
> +OLD_FILES+=usr/include/c++/4.2/debug/vector
> +OLD_FILES+=usr/include/c++/4.2/deque
> +OLD_FILES+=usr/include/c++/4.2/exception
> +OLD_FILES+=usr/include/c++/4.2/exception_defines.h
> +OLD_FILES+=usr/include/c++/4.2/ext/algorithm
> +OLD_FILES+=usr/include/c++/4.2/ext/array_allocator.h
> +OLD_FILES+=usr/include/c++/4.2/ext/atomicity.h
> +OLD_FILES+=usr/include/c++/4.2/ext/bitmap_allocator.h
> +OLD_FILES+=usr/include/c++/4.2/ext/codecvt_specializations.h
> +OLD_FILES+=usr/include/c++/4.2/ext/concurrence.h
> +OLD_FILES+=usr/include/c++/4.2/ext/debug_allocator.h
> +OLD_FILES+=usr/include/c++/4.2/ext/functional
> +OLD_FILES+=usr/include/c++/4.2/ext/hash_fun.h
> +OLD_FILES+=usr/include/c++/4.2/ext/hash_map
> +OLD_FILES+=usr/include/c++/4.2/ext/hash_set
> +OLD_FILES+=usr/include/c++/4.2/ext/hashtable.h
> +OLD_FILES+=usr/include/c++/4.2/ext/iterator
> +OLD_FILES+=usr/include/c++/4.2/ext/malloc_allocator.h
> +OLD_FILES+=usr/include/c++/4.2/ext/memory
> +OLD_FILES+=usr/include/c++/4.2/ext/mt_allocator.h
> +OLD_FILES+=usr/include/c++/4.2/ext/new_allocator.h
> +OLD_FILES+=usr/include/c++/4.2/ext/numeric
> +OLD_FILES+=usr/include/c++/4.2/ext/numeric_traits.h
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/assoc_container.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/basic_tree_policy/basic_tree_policy_base.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/basic_tree_policy/traits.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/basic_types.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/cond_dtor_entry_dealtor.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/cond_key_dtor_entry_dealtor.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/info_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/bin_search_tree_/traits.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/const_iterator.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/entry_cmp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/entry_pred.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/resize_policy.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binary_heap_/trace_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/find_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/iterators_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/policy_access_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/standard_policies.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/cond_dealtor.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/constructors_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/container_base_dispatch.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/eq_fn/eq_by_less.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/find_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/iterator_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/policy_access_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/standard_policies.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/direct_mask_range_hashing_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/direct_mod_range_hashing_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/linear_probe_fn_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/mask_based_range_hashing.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/mod_based_range_hashing.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/quadratic_probe_fn_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/sample_probe_fn.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/sample_range_hashing.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/sample_ranged_hash_fn.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/hash_fn/sample_ranged_probe_fn.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/const_point_iterator.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/node.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/null_metadata.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/entry_metadata_base.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/lu_map_.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_policy/counter_lu_metadata.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_policy/counter_lu_policy_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_policy/mtf_lu_policy_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/map_debug_base.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/policy_access_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/ov_tree_map_/traits.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/child_iterator.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/cond_dtor_entry_dealtor.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/const_child_iterator.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/head.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/internal_node.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/leaf.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/node_base.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/node_iterators.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/node_metadata_base.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/point_iterators.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/synth_e_access_traits.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/traits.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/priority_queue_base_dispatch.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/find_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/node.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rb_tree_map_/traits.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/rc_binomial_heap_/trace_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/hash_exponential_size_policy_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/hash_standard_resize_policy_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/sample_resize_policy.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/sample_resize_trigger.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/resize_policy/sample_size_policy.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/info_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/node.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/splay_tree_/traits.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/standard_policies.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/tree_policy/null_node_update_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/tree_policy/sample_tree_node_update.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/tree_trace_base.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/null_node_update_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/sample_trie_e_access_traits.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/sample_trie_node_update.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/string_trie_e_access_traits_imp.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/trie_policy/trie_policy_base.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/type_utils.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/types_traits.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/unordered_iterator/const_iterator.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/unordered_iterator/const_point_iterator.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/unordered_iterator/iterator.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/exception.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/hash_policy.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/list_update_policy.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/priority_queue.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/tag_and_trait.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/tree_policy.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pb_ds/trie_policy.hpp
> +OLD_FILES+=usr/include/c++/4.2/ext/pod_char_traits.h
> +OLD_FILES+=usr/include/c++/4.2/ext/pool_allocator.h
> +OLD_FILES+=usr/include/c++/4.2/ext/rb_tree
> +OLD_FILES+=usr/include/c++/4.2/ext/rc_string_base.h
> +OLD_FILES+=usr/include/c++/4.2/ext/rope
> +OLD_FILES+=usr/include/c++/4.2/ext/ropeimpl.h
> +OLD_FILES+=usr/include/c++/4.2/ext/slist
> +OLD_FILES+=usr/include/c++/4.2/ext/sso_string_base.h
> +OLD_FILES+=usr/include/c++/4.2/ext/stdio_filebuf.h
> +OLD_FILES+=usr/include/c++/4.2/ext/stdio_sync_filebuf.h
> +OLD_FILES+=usr/include/c++/4.2/ext/throw_allocator.h
> +OLD_FILES+=usr/include/c++/4.2/ext/type_traits.h
> +OLD_FILES+=usr/include/c++/4.2/ext/typelist.h
> +OLD_FILES+=usr/include/c++/4.2/ext/vstring.h
> +OLD_FILES+=usr/include/c++/4.2/ext/vstring.tcc
> +OLD_FILES+=usr/include/c++/4.2/ext/vstring_fwd.h
> +OLD_FILES+=usr/include/c++/4.2/ext/vstring_util.h
> +OLD_FILES+=usr/include/c++/4.2/fstream
> +OLD_FILES+=usr/include/c++/4.2/functional
> +OLD_FILES+=usr/include/c++/4.2/iomanip
> +OLD_FILES+=usr/include/c++/4.2/ios
> +OLD_FILES+=usr/include/c++/4.2/iosfwd
> +OLD_FILES+=usr/include/c++/4.2/iostream
> +OLD_FILES+=usr/include/c++/4.2/istream
> +OLD_FILES+=usr/include/c++/4.2/iterator
> +OLD_FILES+=usr/include/c++/4.2/limits
> +OLD_FILES+=usr/include/c++/4.2/list
> +OLD_FILES+=usr/include/c++/4.2/locale
> +OLD_FILES+=usr/include/c++/4.2/map
> +OLD_FILES+=usr/include/c++/4.2/memory
> +OLD_FILES+=usr/include/c++/4.2/new
> +OLD_FILES+=usr/include/c++/4.2/numeric
> +OLD_FILES+=usr/include/c++/4.2/ostream
> +OLD_FILES+=usr/include/c++/4.2/queue
> +OLD_FILES+=usr/include/c++/4.2/set
> +OLD_FILES+=usr/include/c++/4.2/sstream
> +OLD_FILES+=usr/include/c++/4.2/stack
> +OLD_FILES+=usr/include/c++/4.2/stdexcept
> +OLD_FILES+=usr/include/c++/4.2/streambuf
> +OLD_FILES+=usr/include/c++/4.2/string
> +OLD_FILES+=usr/include/c++/4.2/tr1/array
> +OLD_FILES+=usr/include/c++/4.2/tr1/bind_iterate.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/bind_repeat.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/boost_shared_ptr.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/cctype
> +OLD_FILES+=usr/include/c++/4.2/tr1/cfenv
> +OLD_FILES+=usr/include/c++/4.2/tr1/cfloat
> +OLD_FILES+=usr/include/c++/4.2/tr1/cinttypes
> +OLD_FILES+=usr/include/c++/4.2/tr1/climits
> +OLD_FILES+=usr/include/c++/4.2/tr1/cmath
> +OLD_FILES+=usr/include/c++/4.2/tr1/common.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/complex
> +OLD_FILES+=usr/include/c++/4.2/tr1/cstdarg
> +OLD_FILES+=usr/include/c++/4.2/tr1/cstdbool
> +OLD_FILES+=usr/include/c++/4.2/tr1/cstdint
> +OLD_FILES+=usr/include/c++/4.2/tr1/cstdio
> +OLD_FILES+=usr/include/c++/4.2/tr1/cstdlib
> +OLD_FILES+=usr/include/c++/4.2/tr1/ctgmath
> +OLD_FILES+=usr/include/c++/4.2/tr1/ctime
> +OLD_FILES+=usr/include/c++/4.2/tr1/ctype.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/cwchar
> +OLD_FILES+=usr/include/c++/4.2/tr1/cwctype
> +OLD_FILES+=usr/include/c++/4.2/tr1/fenv.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/float.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/functional
> +OLD_FILES+=usr/include/c++/4.2/tr1/functional_hash.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/functional_iterate.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/hashtable
> +OLD_FILES+=usr/include/c++/4.2/tr1/hashtable_policy.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/inttypes.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/limits.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/math.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/memory
> +OLD_FILES+=usr/include/c++/4.2/tr1/mu_iterate.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/random
> +OLD_FILES+=usr/include/c++/4.2/tr1/random.tcc
> +OLD_FILES+=usr/include/c++/4.2/tr1/ref_fwd.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/ref_wrap_iterate.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/repeat.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/stdarg.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/stdbool.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/stdint.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/stdio.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/stdlib.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/tgmath.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/tuple
> +OLD_FILES+=usr/include/c++/4.2/tr1/tuple_defs.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/tuple_iterate.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/type_traits
> +OLD_FILES+=usr/include/c++/4.2/tr1/type_traits_fwd.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/unordered_map
> +OLD_FILES+=usr/include/c++/4.2/tr1/unordered_set
> +OLD_FILES+=usr/include/c++/4.2/tr1/utility
> +OLD_FILES+=usr/include/c++/4.2/tr1/wchar.h
> +OLD_FILES+=usr/include/c++/4.2/tr1/wctype.h
> +OLD_FILES+=usr/include/c++/4.2/typeinfo
> +OLD_FILES+=usr/include/c++/4.2/utility
> +OLD_FILES+=usr/include/c++/4.2/valarray
> +OLD_FILES+=usr/include/c++/4.2/vector
> +OLD_FILES+=usr/lib/libstdc++.a
> +# Keep libs to allow bootstrapping g++(1) with gperf(1)
> +#OLD_LIBS+=usr/lib/libstdc++.so
> +#OLD_LIBS+=usr/lib/libstdc++.so.6
> +OLD_FILES+=usr/lib/libstdc++_p.a
> +OLD_FILES+=usr/lib/libsupc++.a
> +OLD_FILES+=usr/lib/libsupc++_p.a
> +OLD_FILES+=usr/libexec/cc1plus
> +.endif
>  
>  .if ${MK_DICT} == no
>  OLD_FILES+=usr/share/dict/README
> 
> Modified: head/tools/build/options/WITHOUT_CXX
> ==============================================================================
> --- head/tools/build/options/WITHOUT_CXX	Wed Apr  6 19:13:04 2011	(r220400)
> +++ head/tools/build/options/WITHOUT_CXX	Wed Apr  6 20:08:23 2011	(r220401)
> @@ -2,3 +2,11 @@
>  Set to not build
>  .Xr g++ 1
>  and related libraries.
> +Implies
> +.Dv WITHOUT_CLANG
> +and
> +.Dv WITHOUT_GROFF
> +and will also prevent building of
> +.Xr gperf 1
> +and
> +.Xr devd 8 .

-- 
a13x

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 21:07:59 2011
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 107C5106564A;
	Wed,  6 Apr 2011 21:07:59 +0000 (UTC)
	(envelope-from juli@clockworksquid.com)
Received: from mail-gx0-f182.google.com (mail-gx0-f182.google.com
	[209.85.161.182])
	by mx1.freebsd.org (Postfix) with ESMTP id 8CB2D8FC15;
	Wed,  6 Apr 2011 21:07:58 +0000 (UTC)
Received: by gxk28 with SMTP id 28so842304gxk.13
	for ; Wed, 06 Apr 2011 14:07:57 -0700 (PDT)
Received: by 10.151.27.16 with SMTP id e16mr84165ybj.356.1302124077089; Wed,
	06 Apr 2011 14:07:57 -0700 (PDT)
MIME-Version: 1.0
Sender: juli@clockworksquid.com
Received: by 10.151.13.12 with HTTP; Wed, 6 Apr 2011 14:07:37 -0700 (PDT)
In-Reply-To: <20110406210416.GA62173@freebsd.org>
References: <201104062008.p36K8NR0015687@svn.freebsd.org>
	<20110406210416.GA62173@freebsd.org>
From: Juli Mallett 
Date: Wed, 6 Apr 2011 14:07:37 -0700
X-Google-Sender-Auth: FeR-8U-7HKujZCCXsqpt4ZBDx1Y
Message-ID: 
To: Alexander Best 
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, Ulrich Spoerlein 
Subject: Re: svn commit: r220401 - in head: . share/mk tools/build/mk
	tools/build/options
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, 06 Apr 2011 21:07:59 -0000

On Wed, Apr 6, 2011 at 14:04, Alexander Best  wrote:
> On Wed Apr =A06 11, Ulrich Spoerlein wrote:
>> Author: uqs
>> Date: Wed Apr =A06 20:08:23 2011
>> New Revision: 220401
>> URL: http://svn.freebsd.org/changeset/base/220401
>>
>> Log:
>> =A0 Complete WITHOUT_CXX support. It implies WITHOUT_GROFF and
>> =A0 WITHOUT_CLANG.
>
> is there no way to build clang/llvm without CXX support?

Clang and LLVM are written in C++.  Even if their support for
compiling C++ could be disabled, you'd still need a C++ cross-compiler
to build them, which ought to be disabled by WITHOUT_CXX, right?

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 21:29:38 2011
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 49802106566B;
	Wed,  6 Apr 2011 21:29:38 +0000 (UTC) (envelope-from jhb@freebsd.org)
Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42])
	by mx1.freebsd.org (Postfix) with ESMTP id 1AFDE8FC15;
	Wed,  6 Apr 2011 21:29:38 +0000 (UTC)
Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net
	[66.111.2.69])
	by cyrus.watson.org (Postfix) with ESMTPSA id C634946B97;
	Wed,  6 Apr 2011 17:29:37 -0400 (EDT)
Received: from jhbbsd.localnet (unknown [209.249.190.124])
	by bigwig.baldwin.cx (Postfix) with ESMTPSA id 46F6B8A01B;
	Wed,  6 Apr 2011 17:29:37 -0400 (EDT)
From: John Baldwin 
To: Kostik Belousov 
Date: Wed, 6 Apr 2011 16:03:43 -0400
User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; )
References: <201104061627.p36GR4Vx097282@svn.freebsd.org>
	<28CBF3B2-105E-4B0F-A1B1-4FA772BAB06A@freebsd.org>
	<20110406192728.GH78089@deviant.kiev.zoral.com.ua>
In-Reply-To: <20110406192728.GH78089@deviant.kiev.zoral.com.ua>
MIME-Version: 1.0
Content-Type: Text/Plain;
  charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
Message-Id: <201104061603.43636.jhb@freebsd.org>
X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6
	(bigwig.baldwin.cx); Wed, 06 Apr 2011 17:29:37 -0400 (EDT)
Cc: Garrett Cooper , svn-src-head@freebsd.org,
	svn-src-all@freebsd.org, src-committers@freebsd.org,
	Edward Tomasz Napiera?a 
Subject: Re: svn commit: r220387 - 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, 06 Apr 2011 21:29:38 -0000

On Wednesday, April 06, 2011 3:27:28 pm Kostik Belousov wrote:
> On Wed, Apr 06, 2011 at 07:04:47PM +0200, Edward Tomasz Napiera?a wrote:
> > Wiadomo?? napisana przez Garrett Cooper w dniu 2011-04-06, o godz. 18:57:
> > > On Wed, Apr 6, 2011 at 9:27 AM, Edward Tomasz Napierala
> > >  wrote:
> > >> Author: trasz
> > >> Date: Wed Apr  6 16:27:04 2011
> > >> New Revision: 220387
> > >> URL: http://svn.freebsd.org/changeset/base/220387
> > >> 
> > >> Log:
> > >>  In vm_daemon(), do not skip processes stopped with SIGSTOP.
> > > 
> > >    Did you run this by anyone else before you committed the change?
> > 
> > The whole racct patchset was reviewed by kib@, and I seem to remember
> > that he said this might cause problems.  However, I didn't encounter
> > any problems with this, neither did any person testing the patchset.
> > 
> > So, what's wrong with this?
> I remember that I disliked the whole approach of handling RSS limits,
> and still hold the same opinion.
> I said something about honoring the limit at the time of page allocation
> or page-in, and not `offline' as it is committed, by periodic scans
> by daemon.

Yes, to be truly useful the limit has to prevent excessive page allocation
at the time the allocation is performed (by blocking until another page
is swapped out or failing, etc.).

-- 
John Baldwin

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 21:41:33 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: by hub.freebsd.org (Postfix, from userid 1233)
	id 1B8EB106566B; Wed,  6 Apr 2011 21:41:33 +0000 (UTC)
Date: Wed, 6 Apr 2011 21:41:33 +0000
From: Alexander Best 
To: Juli Mallett 
Message-ID: <20110406214133.GA66860@freebsd.org>
References: <201104062008.p36K8NR0015687@svn.freebsd.org>
	<20110406210416.GA62173@freebsd.org>
	
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: 
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org, Ulrich Spoerlein 
Subject: Re: svn commit: r220401 - in head: . share/mk tools/build/mk
	tools/build/options
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, 06 Apr 2011 21:41:33 -0000

On Wed Apr  6 11, Juli Mallett wrote:
> On Wed, Apr 6, 2011 at 14:04, Alexander Best  wrote:
> > On Wed Apr  6 11, Ulrich Spoerlein wrote:
> >> Author: uqs
> >> Date: Wed Apr  6 20:08:23 2011
> >> New Revision: 220401
> >> URL: http://svn.freebsd.org/changeset/base/220401
> >>
> >> Log:
> >>   Complete WITHOUT_CXX support. It implies WITHOUT_GROFF and
> >>   WITHOUT_CLANG.
> >
> > is there no way to build clang/llvm without CXX support?
> 
> Clang and LLVM are written in C++.  Even if their support for
> compiling C++ could be disabled, you'd still need a C++ cross-compiler
> to build them, which ought to be disabled by WITHOUT_CXX, right?

good point. is it even possible to build a world *with* C++ support, if the
installed world *doesn't* have C++ support? is the C++ part of gcc written in
C? if that's the case it's possible.

couldn't we install clang *without* C++ support and then do the following to
build it *with* C++ support:

1) use gcc to build a bootstrap gcc *with* C++ support
2) use the bootstrap gcc to build clang

cheers.
alex

-- 
a13x

From owner-svn-src-head@FreeBSD.ORG  Wed Apr  6 23:59:59 2011
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 912D0106566C;
	Wed,  6 Apr 2011 23:59:59 +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 81B1C8FC12;
	Wed,  6 Apr 2011 23:59:59 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p36Nxx5P022812;
	Wed, 6 Apr 2011 23:59:59 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p36NxxxT022808;
	Wed, 6 Apr 2011 23:59:59 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104062359.p36NxxxT022808@svn.freebsd.org>
From: Jung-uk Kim 
Date: Wed, 6 Apr 2011 23:59: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: r220404 - in head/sys: i386/i386 i386/include pc98/pc98
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, 06 Apr 2011 23:59:59 -0000

Author: jkim
Date: Wed Apr  6 23:59:59 2011
New Revision: 220404
URL: http://svn.freebsd.org/changeset/base/220404

Log:
  Implement atomic_load_acq_64(9) and atomic_store_rel_64(9) for i386.  These
  functions are implemented with CMPXCHG8B instruction where it is available,
  i. e., all Pentium-class and later processors.  Note this instruction is
  also used for atomic_store_rel_64() because a simple XCHG-like instruction
  for 64-bit memory access does not exist, unfortunately.  If the processor
  lacks the instruction, i. e., 80486-class CPUs, two 32-bit load/store are
  performed with interrupt temporarily disabled, assuming it does not support
  SMP.  Although this assumption may be little naive, it is true in reality.
  This implementation is inspired by Linux.

Modified:
  head/sys/i386/i386/machdep.c
  head/sys/i386/include/atomic.h
  head/sys/pc98/pc98/machdep.c

Modified: head/sys/i386/i386/machdep.c
==============================================================================
--- head/sys/i386/i386/machdep.c	Wed Apr  6 20:54:26 2011	(r220403)
+++ head/sys/i386/i386/machdep.c	Wed Apr  6 23:59:59 2011	(r220404)
@@ -1497,6 +1497,22 @@ idle_sysctl(SYSCTL_HANDLER_ARGS)
 SYSCTL_PROC(_machdep, OID_AUTO, idle, CTLTYPE_STRING | CTLFLAG_RW, 0, 0,
     idle_sysctl, "A", "currently selected idle function");
 
+uint64_t (*atomic_load_acq_64)(volatile uint64_t *) =
+    atomic_load_acq_64_i386;
+void (*atomic_store_rel_64)(volatile uint64_t *, uint64_t) =
+    atomic_store_rel_64_i386;
+
+static void
+cpu_probe_cmpxchg8b(void)
+{
+
+	if ((cpu_feature & CPUID_CX8) != 0 ||
+	    cpu_vendor_id == CPU_VENDOR_RISE) {
+		atomic_load_acq_64 = atomic_load_acq_64_i586;
+		atomic_store_rel_64 = atomic_store_rel_64_i586;
+	}
+}
+
 /*
  * Reset registers to default values on exec.
  */
@@ -2730,6 +2746,7 @@ init386(first)
 	thread0.td_pcb->pcb_gsd = PCPU_GET(fsgs_gdt)[1];
 
 	cpu_probe_amdc1e();
+	cpu_probe_cmpxchg8b();
 }
 
 #else
@@ -3006,6 +3023,7 @@ init386(first)
 	thread0.td_frame = &proc0_tf;
 
 	cpu_probe_amdc1e();
+	cpu_probe_cmpxchg8b();
 }
 #endif
 

Modified: head/sys/i386/include/atomic.h
==============================================================================
--- head/sys/i386/include/atomic.h	Wed Apr  6 20:54:26 2011	(r220403)
+++ head/sys/i386/include/atomic.h	Wed Apr  6 23:59:59 2011	(r220404)
@@ -120,6 +120,87 @@ atomic_##NAME##_barr_##TYPE(volatile u_#
 }							\
 struct __hack
 
+#if defined(_KERNEL) && !defined(WANT_FUNCTIONS)
+
+/* I486 does not support SMP or CMPXCHG8B. */
+static __inline uint64_t
+atomic_load_acq_64_i386(volatile uint64_t *p)
+{
+	volatile uint32_t *high, *low;
+	uint64_t res;
+
+	low = (volatile uint32_t *)p;
+	high = (volatile uint32_t *)p + 1;
+	__asm __volatile(
+	"	pushfl ;		"
+	"	cli ;			"
+	"	movl %1,%%eax ;		"
+	"	movl %2,%%edx ;		"
+	"	popfl"
+	: "=&A" (res)			/* 0 */
+	: "m" (*low),			/* 1 */
+	  "m" (*high)			/* 2 */
+	: "memory");
+
+	return (res);
+}
+
+static __inline void
+atomic_store_rel_64_i386(volatile uint64_t *p, uint64_t v)
+{
+	volatile uint32_t *high, *low;
+
+	low = (volatile uint32_t *)p;
+	high = (volatile uint32_t *)p + 1;
+	__asm __volatile(
+	"	pushfl ;		"
+	"	cli ;			"
+	"	movl %%eax,%0 ;		"
+	"	movl %%edx,%1 ;		"
+	"	popfl"
+	: "=m" (*low),			/* 0 */
+	  "=m" (*high)			/* 1 */
+	: "A" (v)			/* 2 */
+	: "memory");
+}
+
+static __inline uint64_t
+atomic_load_acq_64_i586(volatile uint64_t *p)
+{
+	uint64_t res;
+
+	__asm __volatile(
+	"	movl %%ebx,%%eax ;	"
+	"	movl %%ecx,%%edx ;	"
+	"	" MPLOCKED "		"
+	"	cmpxchg8b %2"
+	: "=&A" (res),			/* 0 */
+	  "=m" (*p)			/* 1 */
+	: "m" (*p)			/* 2 */
+	: "memory", "cc");
+
+	return (res);
+}
+
+static __inline void
+atomic_store_rel_64_i586(volatile uint64_t *p, uint64_t v)
+{
+
+	__asm __volatile(
+	"	movl %%eax,%%ebx ;	"
+	"	movl %%edx,%%ecx ;	"
+	"1:				"
+	"	" MPLOCKED "		"
+	"	cmpxchg8b %2 ;		"
+	"	jne 1b"
+	: "=m" (*p),			/* 0 */
+	  "+A" (v)			/* 1 */
+	: "m" (*p)			/* 2 */
+	: "ebx", "ecx", "memory", "cc");
+}
+
+#endif /* _KERNEL && !WANT_FUNCTIONS */
+
 /*
  * Atomic compare and set, used by the mutex functions
  *
@@ -292,6 +373,11 @@ ATOMIC_STORE_LOAD(long,	"cmpxchgl %0,%1"
 
 #ifndef WANT_FUNCTIONS
 
+#ifdef _KERNEL
+extern uint64_t (*atomic_load_acq_64)(volatile uint64_t *);
+extern void (*atomic_store_rel_64)(volatile uint64_t *, uint64_t);
+#endif
+
 static __inline int
 atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src)
 {

Modified: head/sys/pc98/pc98/machdep.c
==============================================================================
--- head/sys/pc98/pc98/machdep.c	Wed Apr  6 20:54:26 2011	(r220403)
+++ head/sys/pc98/pc98/machdep.c	Wed Apr  6 23:59:59 2011	(r220404)
@@ -1330,6 +1330,21 @@ idle_sysctl(SYSCTL_HANDLER_ARGS)
 SYSCTL_PROC(_machdep, OID_AUTO, idle, CTLTYPE_STRING | CTLFLAG_RW, 0, 0,
     idle_sysctl, "A", "currently selected idle function");
 
+uint64_t (*atomic_load_acq_64)(volatile uint64_t *) =
+    atomic_load_acq_64_i386;
+void (*atomic_store_rel_64)(volatile uint64_t *, uint64_t) =
+    atomic_store_rel_64_i386;
+
+static void
+cpu_probe_cmpxchg8b(void)
+{
+
+	if ((cpu_feature & CPUID_CX8) != 0) {
+		atomic_load_acq_64 = atomic_load_acq_64_i586;
+		atomic_store_rel_64 = atomic_store_rel_64_i586;
+	}
+}
+
 /*
  * Reset registers to default values on exec.
  */
@@ -2344,6 +2359,8 @@ init386(first)
 	thread0.td_pcb->pcb_cr3 = (int)IdlePTD;
 	thread0.td_pcb->pcb_ext = 0;
 	thread0.td_frame = &proc0_tf;
+
+	cpu_probe_cmpxchg8b();
 }
 
 void

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 02:17:45 2011
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 6A8C8106564A;
	Thu,  7 Apr 2011 02:17:45 +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 E24288FC16;
	Thu,  7 Apr 2011 02:17:44 +0000 (UTC)
Received: from 63.imp.bsdimp.com (63.imp.bsdimp.com [10.0.0.63])
	(authenticated bits=0)
	by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id p372F4ga009854
	(version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO);
	Wed, 6 Apr 2011 20:15:05 -0600 (MDT) (envelope-from imp@bsdimp.com)
Mime-Version: 1.0 (Apple Message framework v1082)
Content-Type: text/plain; charset=us-ascii
From: Warner Losh 
In-Reply-To: <20110406214133.GA66860@freebsd.org>
Date: Wed, 6 Apr 2011 20:15:03 -0600
Content-Transfer-Encoding: quoted-printable
Message-Id: 
References: <201104062008.p36K8NR0015687@svn.freebsd.org>
	<20110406210416.GA62173@freebsd.org>
	
	<20110406214133.GA66860@freebsd.org>
To: Alexander Best 
X-Mailer: Apple Mail (2.1082)
X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1
	(harmony.bsdimp.com [10.0.0.6]);
	Wed, 06 Apr 2011 20:15:06 -0600 (MDT)
Cc: Juli Mallett , svn-src-head@FreeBSD.org,
	svn-src-all@FreeBSD.org, src-committers@FreeBSD.org,
	Ulrich Spoerlein 
Subject: Re: svn commit: r220401 - in head: . share/mk tools/build/mk
	tools/build/options
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, 07 Apr 2011 02:17:45 -0000


On Apr 6, 2011, at 3:41 PM, Alexander Best wrote:

> On Wed Apr  6 11, Juli Mallett wrote:
>> On Wed, Apr 6, 2011 at 14:04, Alexander Best  =
wrote:
>>> On Wed Apr  6 11, Ulrich Spoerlein wrote:
>>>> Author: uqs
>>>> Date: Wed Apr  6 20:08:23 2011
>>>> New Revision: 220401
>>>> URL: http://svn.freebsd.org/changeset/base/220401
>>>>=20
>>>> Log:
>>>>   Complete WITHOUT_CXX support. It implies WITHOUT_GROFF and
>>>>   WITHOUT_CLANG.
>>>=20
>>> is there no way to build clang/llvm without CXX support?
>>=20
>> Clang and LLVM are written in C++.  Even if their support for
>> compiling C++ could be disabled, you'd still need a C++ =
cross-compiler
>> to build them, which ought to be disabled by WITHOUT_CXX, right?
>=20
> good point. is it even possible to build a world *with* C++ support, =
if the
> installed world *doesn't* have C++ support? is the C++ part of gcc =
written in
> C? if that's the case it's possible.

Yes.  We don't need c++ to bootstrap g++ or anything else in the base =
system.  Once we build the compilers, we can build the c++ that's in the =
tree.

> couldn't we install clang *without* C++ support and then do the =
following to
> build it *with* C++ support:
>=20
> 1) use gcc to build a bootstrap gcc *with* C++ support
> 2) use the bootstrap gcc to build clang

I suppose you could do that, but I'm unsure how much that buys you...

Warner=

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 03:19:11 2011
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 00BB3106566C;
	Thu,  7 Apr 2011 03:19:11 +0000 (UTC)
	(envelope-from jeff@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E3A9D8FC19;
	Thu,  7 Apr 2011 03:19:10 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p373JAQb027116;
	Thu, 7 Apr 2011 03:19:10 GMT (envelope-from jeff@svn.freebsd.org)
Received: (from jeff@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p373JAH8027113;
	Thu, 7 Apr 2011 03:19:10 GMT (envelope-from jeff@svn.freebsd.org)
Message-Id: <201104070319.p373JAH8027113@svn.freebsd.org>
From: Jeff Roberson 
Date: Thu, 7 Apr 2011 03:19: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: r220406 - 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, 07 Apr 2011 03:19:11 -0000

Author: jeff
Date: Thu Apr  7 03:19:10 2011
New Revision: 220406
URL: http://svn.freebsd.org/changeset/base/220406

Log:
   - Don't invalidate jnewblks immediately upon discovering that the block
     will be removed.  Permit the journal to proceed so that we don't leave
     a rollback in a cg for a very long time as this can cause terrible perf
     problems in low memory situations.
  
  Tested by:      pho

Modified:
  head/sys/ufs/ffs/ffs_softdep.c
  head/sys/ufs/ffs/softdep.h

Modified: head/sys/ufs/ffs/ffs_softdep.c
==============================================================================
--- head/sys/ufs/ffs/ffs_softdep.c	Thu Apr  7 00:30:32 2011	(r220405)
+++ head/sys/ufs/ffs/ffs_softdep.c	Thu Apr  7 03:19:10 2011	(r220406)
@@ -766,7 +766,8 @@ static	inline void inoref_write(struct i
 	    struct jrefrec *);
 static	void handle_allocdirect_partdone(struct allocdirect *,
 	    struct workhead *);
-static	void cancel_newblk(struct newblk *, struct workhead *);
+static	struct jnewblk *cancel_newblk(struct newblk *, struct worklist *,
+	    struct workhead *);
 static	void indirdep_complete(struct indirdep *);
 static	void handle_allocindir_partdone(struct allocindir *);
 static	void initiate_write_filepage(struct pagedep *, struct buf *);
@@ -826,6 +827,8 @@ static	void handle_complete_freeblocks(s
 static	void handle_workitem_indirblk(struct freework *);
 static	void handle_written_freework(struct freework *);
 static	void merge_inode_lists(struct allocdirectlst *,struct allocdirectlst *);
+static	struct worklist *jnewblk_merge(struct worklist *, struct worklist *,
+	    struct workhead *);
 static	void setup_allocindir_phase2(struct buf *, struct inode *,
 	    struct inodedep *, struct allocindir *, ufs_lbn_t);
 static	struct allocindir *newallocindir(struct inode *, int, ufs2_daddr_t,
@@ -3125,33 +3128,72 @@ handle_written_jaddref(jaddref)
 
 /*
  * Called once a jnewblk journal is written.  The allocdirect or allocindir
- * is placed in the bmsafemap to await notification of a written bitmap.
+ * is placed in the bmsafemap to await notification of a written bitmap.  If
+ * the operation was canceled we add the segdep to the appropriate
+ * dependency to free the journal space once the canceling operation
+ * completes.
  */
 static void
 handle_written_jnewblk(jnewblk)
 	struct jnewblk *jnewblk;
 {
 	struct bmsafemap *bmsafemap;
+	struct freefrag *freefrag;
 	struct jsegdep *jsegdep;
 	struct newblk *newblk;
+	struct freework *freework;
+	struct indirdep *indirdep;
 
 	/* Grab the jsegdep. */
 	jsegdep = jnewblk->jn_jsegdep;
 	jnewblk->jn_jsegdep = NULL;
-	/*
-	 * Add the written block to the bmsafemap so it can be notified when
-	 * the bitmap is on disk.
-	 */
-	newblk = jnewblk->jn_newblk;
-	jnewblk->jn_newblk = NULL;
-	if (newblk == NULL) 
+	if (jnewblk->jn_dep == NULL) 
 		panic("handle_written_jnewblk: No dependency for the segdep.");
-
-	newblk->nb_jnewblk = NULL;
-	bmsafemap = newblk->nb_bmsafemap;
-	WORKLIST_INSERT(&newblk->nb_jwork, &jsegdep->jd_list);
-	newblk->nb_state |= ONDEPLIST;
-	LIST_INSERT_HEAD(&bmsafemap->sm_newblkhd, newblk, nb_deps);
+	switch (jnewblk->jn_dep->wk_type) {
+	case D_NEWBLK:
+	case D_ALLOCDIRECT:
+	case D_ALLOCINDIR:
+		/*
+		 * Add the written block to the bmsafemap so it can
+		 * be notified when the bitmap is on disk.
+		 */
+		newblk = WK_NEWBLK(jnewblk->jn_dep);
+		newblk->nb_jnewblk = NULL;
+		bmsafemap = newblk->nb_bmsafemap;
+		newblk->nb_state |= ONDEPLIST;
+		LIST_INSERT_HEAD(&bmsafemap->sm_newblkhd, newblk, nb_deps);
+		WORKLIST_INSERT(&newblk->nb_jwork, &jsegdep->jd_list);
+		break;
+	case D_FREEFRAG:
+		/*
+		 * A newblock being removed by a freefrag when replaced by
+		 * frag extension.
+		 */
+		freefrag = WK_FREEFRAG(jnewblk->jn_dep);
+		freefrag->ff_jdep = NULL;
+		WORKLIST_INSERT(&freefrag->ff_jwork, &jsegdep->jd_list);
+		break;
+	case D_FREEWORK:
+		/*
+		 * A direct block was removed by truncate.
+		 */
+		freework = WK_FREEWORK(jnewblk->jn_dep);
+		freework->fw_jnewblk = NULL;
+		WORKLIST_INSERT(&freework->fw_jwork, &jsegdep->jd_list);
+		break;
+	case D_INDIRDEP:
+		/*
+		 * An indirect block was removed by truncate.
+		 */
+		indirdep = WK_INDIRDEP(jnewblk->jn_dep);
+		LIST_REMOVE(jnewblk, jn_indirdeps);
+		WORKLIST_INSERT(&indirdep->ir_jwork, &jsegdep->jd_list);
+		break;
+	default:
+		panic("handle_written_jnewblk: Unknown type %d.",
+		    jnewblk->jn_dep->wk_type);
+	}
+	jnewblk->jn_dep = NULL;
 	free_jnewblk(jnewblk);
 }
 
@@ -3173,7 +3215,6 @@ cancel_jfreefrag(jfreefrag)
 	}
 	freefrag = jfreefrag->fr_freefrag;
 	jfreefrag->fr_freefrag = NULL;
-	freefrag->ff_jfreefrag = NULL;
 	free_jfreefrag(jfreefrag);
 	freefrag->ff_state |= DEPCOMPLETE;
 }
@@ -3213,7 +3254,7 @@ handle_written_jfreefrag(jfreefrag)
 	if (freefrag == NULL)
 		panic("handle_written_jfreefrag: No freefrag.");
 	freefrag->ff_state |= DEPCOMPLETE;
-	freefrag->ff_jfreefrag = NULL;
+	freefrag->ff_jdep = NULL;
 	WORKLIST_INSERT(&freefrag->ff_jwork, &jsegdep->jd_list);
 	if ((freefrag->ff_state & ALLCOMPLETE) == ALLCOMPLETE)
 		add_to_worklist(&freefrag->ff_list, 0);
@@ -3399,6 +3440,7 @@ newfreework(ump, freeblks, parent, lbn, 
 
 	freework = malloc(sizeof(*freework), M_FREEWORK, M_SOFTDEP_FLAGS);
 	workitem_alloc(&freework->fw_list, D_FREEWORK, freeblks->fb_list.wk_mp);
+	freework->fw_jnewblk = NULL;
 	freework->fw_freeblks = freeblks;
 	freework->fw_parent = parent;
 	freework->fw_lbn = lbn;
@@ -3620,7 +3662,7 @@ free_jnewblk(jnewblk)
 	if ((jnewblk->jn_state & ALLCOMPLETE) != ALLCOMPLETE)
 		return;
 	LIST_REMOVE(jnewblk, jn_deps);
-	if (jnewblk->jn_newblk != NULL)
+	if (jnewblk->jn_dep != NULL)
 		panic("free_jnewblk: Dependency still attached.");
 	WORKITEM_FREE(jnewblk, D_JNEWBLK);
 }
@@ -3641,26 +3683,21 @@ cancel_jnewblk(jnewblk, wkhd)
 
 	jsegdep = jnewblk->jn_jsegdep;
 	jnewblk->jn_jsegdep  = NULL;
-	free_jsegdep(jsegdep);
-	jnewblk->jn_newblk = NULL;
+	jnewblk->jn_dep = NULL;
 	jnewblk->jn_state |= GOINGAWAY;
 	if (jnewblk->jn_state & IOSTARTED) {
 		jnewblk->jn_state &= ~IOSTARTED;
 		WORKLIST_REMOVE(&jnewblk->jn_list);
-	} else
+		WORKLIST_INSERT(wkhd, &jsegdep->jd_list);
+	} else {
+		free_jsegdep(jsegdep);
 		remove_from_journal(&jnewblk->jn_list);
-	/*
-	 * Leave the head of the list for jsegdeps for fast merging.
-	 */
-	if (LIST_FIRST(wkhd) != NULL) {
-		jnewblk->jn_state |= ONWORKLIST;
-		LIST_INSERT_AFTER(LIST_FIRST(wkhd), &jnewblk->jn_list, wk_list);
-	} else
-		WORKLIST_INSERT(wkhd, &jnewblk->jn_list);
+	}
 	if (jnewblk->jn_state & IOWAITING) {
 		jnewblk->jn_state &= ~IOWAITING;
 		wakeup(&jnewblk->jn_list);
 	}
+	WORKLIST_INSERT(wkhd, &jnewblk->jn_list);
 }
 
 static void
@@ -4272,7 +4309,7 @@ softdep_setup_blkmapdep(bp, mp, newblkno
 					    jnewblk->jn_oldfrags,
 					    jnewblk->jn_frags,
 					    jnewblk->jn_state,
-					    jnewblk->jn_newblk);
+					    jnewblk->jn_dep);
 			}
 		}
 #endif
@@ -4283,7 +4320,7 @@ softdep_setup_blkmapdep(bp, mp, newblkno
 	newblk->nb_bmsafemap = bmsafemap = bmsafemap_lookup(mp, bp,
 	    dtog(fs, newblkno));
 	if (jnewblk) {
-		jnewblk->jn_newblk = newblk;
+		jnewblk->jn_dep = (struct worklist *)newblk;
 		LIST_INSERT_HEAD(&bmsafemap->sm_jnewblkhd, jnewblk, jn_deps);
 	} else {
 		newblk->nb_state |= ONDEPLIST;
@@ -4469,8 +4506,9 @@ softdep_setup_allocdirect(ip, off, newbl
 		jnewblk->jn_lbn = lbn;
 		add_to_journal(&jnewblk->jn_list);
 	}
-	if (freefrag && freefrag->ff_jfreefrag != NULL)
-		add_to_journal(&freefrag->ff_jfreefrag->fr_list);
+	if (freefrag && freefrag->ff_jdep != NULL &&
+	    freefrag->ff_jdep->wk_type == D_JFREEFRAG)
+		add_to_journal(freefrag->ff_jdep);
 	inodedep_lookup(mp, ip->i_number, DEPALLOC | NODELAY, &inodedep);
 	adp->ad_inodedep = inodedep;
 
@@ -4512,6 +4550,65 @@ softdep_setup_allocdirect(ip, off, newbl
 }
 
 /*
+ * Merge a newer and older journal record to be stored either in a
+ * newblock or freefrag.  This handles aggregating journal records for
+ * fragment allocation into a second record as well as replacing a
+ * journal free with an aborted journal allocation.  A segment for the
+ * oldest record will be placed on wkhd if it has been written.  If not
+ * the segment for the newer record will suffice.
+ */
+static struct worklist *
+jnewblk_merge(new, old, wkhd)
+	struct worklist *new;
+	struct worklist *old;
+	struct workhead *wkhd;
+{
+	struct jnewblk *njnewblk;
+	struct jnewblk *jnewblk;
+
+	/* Handle NULLs to simplify callers. */
+	if (new == NULL)
+		return (old);
+	if (old == NULL)
+		return (new);
+	/* Replace a jfreefrag with a jnewblk. */
+	if (new->wk_type == D_JFREEFRAG) {
+		cancel_jfreefrag(WK_JFREEFRAG(new));
+		return (old);
+	}
+	/*
+	 * Handle merging of two jnewblk records that describe
+	 * different sets of fragments in the same block.
+	 */
+	jnewblk = WK_JNEWBLK(old);
+	njnewblk = WK_JNEWBLK(new);
+	if (jnewblk->jn_blkno != njnewblk->jn_blkno)
+		panic("jnewblk_merge: Merging disparate blocks.");
+	/*
+	 * The record may be rolled back in the cg update bits
+	 * appropriately.  NEWBLOCK here alerts the cg rollback code
+	 * that the frag bits have changed.
+	 */
+	if (jnewblk->jn_state & UNDONE) {
+		njnewblk->jn_state |= UNDONE | NEWBLOCK;
+		njnewblk->jn_state &= ~ATTACHED;
+		jnewblk->jn_state &= ~UNDONE;
+	}
+	/*
+	 * We modify the newer addref and free the older so that if neither
+	 * has been written the most up-to-date copy will be on disk.  If
+	 * both have been written but rolled back we only temporarily need
+	 * one of them to fix the bits when the cg write completes.
+	 */
+	jnewblk->jn_state |= ATTACHED | COMPLETE;
+	njnewblk->jn_oldfrags = jnewblk->jn_oldfrags;
+	cancel_jnewblk(jnewblk, wkhd);
+	WORKLIST_REMOVE(&jnewblk->jn_list);
+	free_jnewblk(jnewblk);
+	return (new);
+}
+
+/*
  * Replace an old allocdirect dependency with a newer one.
  * This routine must be called with splbio interrupts blocked.
  */
@@ -4578,43 +4675,22 @@ allocdirect_merge(adphead, newadp, oldad
 	 * new journal to cover this old space as well.
 	 */
 	if (freefrag == NULL) {
-		struct jnewblk *jnewblk;
-		struct jnewblk *njnewblk;
-
 		if (oldadp->ad_newblkno != newadp->ad_newblkno)
 			panic("allocdirect_merge: %jd != %jd",
 			    oldadp->ad_newblkno, newadp->ad_newblkno);
-		jnewblk = oldadp->ad_block.nb_jnewblk;
-		cancel_newblk(&oldadp->ad_block, &newadp->ad_block.nb_jwork);
-		/*
-		 * We have an unwritten jnewblk, we need to merge the
-		 * frag bits with our own.  The newer adp's journal can not
-		 * be written prior to the old one so no need to check for
-		 * it here.
-		 */
-		if (jnewblk) {
-			njnewblk = newadp->ad_block.nb_jnewblk;
-			if (njnewblk == NULL)
-				panic("allocdirect_merge: No jnewblk");
-			if (jnewblk->jn_state & UNDONE) {
-				njnewblk->jn_state |= UNDONE | NEWBLOCK;
-				njnewblk->jn_state &= ~ATTACHED;
-				jnewblk->jn_state &= ~UNDONE;
-			}
-			njnewblk->jn_oldfrags = jnewblk->jn_oldfrags;
-			WORKLIST_REMOVE(&jnewblk->jn_list);
-			jnewblk->jn_state |= ATTACHED | COMPLETE;
-			free_jnewblk(jnewblk);
-		}
+		newadp->ad_block.nb_jnewblk = (struct jnewblk *)
+		    jnewblk_merge(&newadp->ad_block.nb_jnewblk->jn_list, 
+		    &oldadp->ad_block.nb_jnewblk->jn_list,
+		    &newadp->ad_block.nb_jwork);
+		oldadp->ad_block.nb_jnewblk = NULL;
+		if (cancel_newblk(&oldadp->ad_block, NULL,
+		    &newadp->ad_block.nb_jwork))
+			panic("allocdirect_merge: Unexpected dependency.");
 	} else {
-		/*
-		 * We can skip journaling for this freefrag and just complete
-		 * any pending journal work for the allocdirect that is being
-		 * removed after the freefrag completes.
-		 */
-		if (freefrag->ff_jfreefrag)
-			cancel_jfreefrag(freefrag->ff_jfreefrag);
-		cancel_newblk(&oldadp->ad_block, &freefrag->ff_jwork);
+		wk = (struct worklist *) cancel_newblk(&oldadp->ad_block,
+		    &freefrag->ff_list, &freefrag->ff_jwork);
+		freefrag->ff_jdep = jnewblk_merge(freefrag->ff_jdep, wk,
+		    &freefrag->ff_jwork);
 	}
 	free_newblk(&oldadp->ad_block);
 }
@@ -4674,11 +4750,11 @@ newfreefrag(ip, blkno, size, lbn)
 	freefrag->ff_fragsize = size;
 
 	if (fs->fs_flags & FS_SUJ) {
-		freefrag->ff_jfreefrag =
+		freefrag->ff_jdep = (struct worklist *)
 		    newjfreefrag(freefrag, ip, blkno, size, lbn);
 	} else {
 		freefrag->ff_state |= DEPCOMPLETE;
-		freefrag->ff_jfreefrag = NULL;
+		freefrag->ff_jdep = NULL;
 	}
 
 	return (freefrag);
@@ -4701,7 +4777,18 @@ handle_workitem_freefrag(freefrag)
 	 * safe to modify the list head here.
 	 */
 	LIST_INIT(&wkhd);
+	ACQUIRE_LOCK(&lk);
 	LIST_SWAP(&freefrag->ff_jwork, &wkhd, worklist, wk_list);
+	/*
+	 * If the journal has not been written we must cancel it here.
+	 */
+	if (freefrag->ff_jdep) {
+		if (freefrag->ff_jdep->wk_type != D_JNEWBLK)
+			panic("handle_workitem_freefrag: Unexpected type %d\n",
+			    freefrag->ff_jdep->wk_type);
+		cancel_jnewblk(WK_JNEWBLK(freefrag->ff_jdep), &wkhd);
+	}
+	FREE_LOCK(&lk);
 	ffs_blkfree(ump, ump->um_fs, ump->um_devvp, freefrag->ff_blkno,
 	    freefrag->ff_fragsize, freefrag->ff_inum, &wkhd);
 	ACQUIRE_LOCK(&lk);
@@ -4769,8 +4856,9 @@ softdep_setup_allocext(ip, off, newblkno
 		jnewblk->jn_lbn = lbn;
 		add_to_journal(&jnewblk->jn_list);
 	}
-	if (freefrag && freefrag->ff_jfreefrag != NULL)
-		add_to_journal(&freefrag->ff_jfreefrag->fr_list);
+	if (freefrag && freefrag->ff_jdep != NULL &&
+	    freefrag->ff_jdep->wk_type == D_JFREEFRAG)
+		add_to_journal(freefrag->ff_jdep);
 	inodedep_lookup(mp, ip->i_number, DEPALLOC | NODELAY, &inodedep);
 	adp->ad_inodedep = inodedep;
 
@@ -4870,8 +4958,9 @@ newallocindir(ip, ptrno, newblkno, oldbl
 		jnewblk->jn_lbn = lbn;
 		add_to_journal(&jnewblk->jn_list);
 	}
-	if (freefrag && freefrag->ff_jfreefrag != NULL)
-		add_to_journal(&freefrag->ff_jfreefrag->fr_list);
+	if (freefrag && freefrag->ff_jdep != NULL &&
+	    freefrag->ff_jdep->wk_type == D_JFREEFRAG)
+		add_to_journal(freefrag->ff_jdep);
 	return (aip);
 }
 
@@ -5067,6 +5156,7 @@ setup_allocindir_phase2(bp, ip, inodedep
 		LIST_INIT(&newindirdep->ir_writehd);
 		LIST_INIT(&newindirdep->ir_completehd);
 		LIST_INIT(&newindirdep->ir_jwork);
+		LIST_INIT(&newindirdep->ir_jnewblkhd);
 		if (bp->b_blkno == bp->b_lblkno) {
 			ufs_bmaparray(bp->b_vp, bp->b_lblkno, &blkno, bp,
 			    NULL, NULL);
@@ -5116,10 +5206,11 @@ allocindir_merge(aip, oldaip)
 	 * any pending journal work for the allocindir that is being
 	 * removed after the freefrag completes.
 	 */
-	if (freefrag->ff_jfreefrag)
-		cancel_jfreefrag(freefrag->ff_jfreefrag);
+	if (freefrag->ff_jdep)
+		cancel_jfreefrag(WK_JFREEFRAG(freefrag->ff_jdep));
 	LIST_REMOVE(oldaip, ai_next);
-	cancel_newblk(&oldaip->ai_block, &freefrag->ff_jwork);
+	freefrag->ff_jdep = (struct worklist *)cancel_newblk(&oldaip->ai_block,
+	    &freefrag->ff_list, &freefrag->ff_jwork);
 	free_newblk(&oldaip->ai_block);
 
 	return (freefrag);
@@ -5532,7 +5623,8 @@ cancel_allocdirect(adphead, adp, freeblk
 	 * freeblks work is complete.
 	 */
 	if (newblk->nb_jnewblk == NULL) {
-		cancel_newblk(newblk, &freeblks->fb_jwork);
+		if (cancel_newblk(newblk, NULL, &freeblks->fb_jwork) != NULL)
+			panic("cancel_allocdirect: Unexpected dependency");
 		goto found;
 	}
 	lbn = newblk->nb_jnewblk->jn_lbn;
@@ -5545,7 +5637,8 @@ cancel_allocdirect(adphead, adp, freeblk
 		freework = WK_FREEWORK(wk);
 		if (freework->fw_lbn != lbn)
 			continue;
-		cancel_newblk(newblk, &freework->fw_jwork);
+		freework->fw_jnewblk = cancel_newblk(newblk, &freework->fw_list,
+		    &freework->fw_jwork);
 		goto found;
 	}
 	panic("cancel_allocdirect: Freework not found for lbn %jd\n", lbn);
@@ -5559,13 +5652,23 @@ found:
 }
 
 
-static void
-cancel_newblk(newblk, wkhd)
+/*
+ * Cancel a new block allocation.  May be an indirect or direct block.  We
+ * remove it from various lists and return any journal record that needs to
+ * be resolved by the caller.
+ *
+ * A special consideration is made for indirects which were never pointed
+ * at on disk and will never be found once this block is released.
+ */
+static struct jnewblk *
+cancel_newblk(newblk, wk, wkhd)
 	struct newblk *newblk;
+	struct worklist *wk;
 	struct workhead *wkhd;
 {
 	struct indirdep *indirdep;
 	struct allocindir *aip;
+	struct jnewblk *jnewblk;
 
 	while ((indirdep = LIST_FIRST(&newblk->nb_indirdeps)) != NULL) {
 		indirdep->ir_state &= ~ONDEPLIST;
@@ -5578,7 +5681,8 @@ cancel_newblk(newblk, wkhd)
 		 */
 		while ((aip = LIST_FIRST(&indirdep->ir_completehd)) != NULL) {
 			LIST_REMOVE(aip, ai_next);
-			cancel_newblk(&aip->ai_block, wkhd);
+			if (cancel_newblk(&aip->ai_block, NULL, wkhd) != NULL)
+				panic("cancel_newblk: aip has journal entry");
 			free_newblk(&aip->ai_block);
 		}
 		/*
@@ -5596,15 +5700,19 @@ cancel_newblk(newblk, wkhd)
 	if (newblk->nb_state & ONWORKLIST)
 		WORKLIST_REMOVE(&newblk->nb_list);
 	/*
-	 * If the journal entry hasn't been written we hold onto the dep
-	 * until it is safe to free along with the other journal work.
+	 * If the journal entry hasn't been written we save a pointer to
+	 * the dependency that frees it until it is written or the
+	 * superseding operation completes.
 	 */
-	if (newblk->nb_jnewblk != NULL) {
-		cancel_jnewblk(newblk->nb_jnewblk, wkhd);
+	jnewblk = newblk->nb_jnewblk;
+	if (jnewblk != NULL) {
 		newblk->nb_jnewblk = NULL;
+		jnewblk->jn_dep = wk;
 	}
 	if (!LIST_EMPTY(&newblk->nb_jwork))
 		jwork_move(wkhd, &newblk->nb_jwork);
+
+	return (jnewblk);
 }
 
 /*
@@ -5871,10 +5979,10 @@ freework_freeblock(freework)
 	struct freework *freework;
 {
 	struct freeblks *freeblks;
+	struct jnewblk *jnewblk;
 	struct ufsmount *ump;
 	struct workhead wkhd;
 	struct fs *fs;
-	int complete;
 	int pending;
 	int bsize;
 	int needj;
@@ -5883,7 +5991,8 @@ freework_freeblock(freework)
 	ump = VFSTOUFS(freeblks->fb_list.wk_mp);
 	fs = ump->um_fs;
 	needj = freeblks->fb_list.wk_mp->mnt_kern_flag & MNTK_SUJ;
-	complete = 0;
+	bsize = lfragtosize(fs, freework->fw_frags);
+	pending = btodb(bsize);
 	LIST_INIT(&wkhd);
 	/*
 	 * If we are canceling an existing jnewblk pass it to the free
@@ -5891,14 +6000,14 @@ freework_freeblock(freework)
 	 * release the freeblks.  If we're not journaling, we can just
 	 * free the freeblks immediately.
 	 */
-	if (!LIST_EMPTY(&freework->fw_jwork)) {
-		LIST_SWAP(&wkhd, &freework->fw_jwork, worklist, wk_list);
-		complete = 1;
-	} else if (needj)
-		WORKLIST_INSERT_UNLOCKED(&wkhd, &freework->fw_list);
-	bsize = lfragtosize(fs, freework->fw_frags);
-	pending = btodb(bsize);
 	ACQUIRE_LOCK(&lk);
+	LIST_SWAP(&wkhd, &freework->fw_jwork, worklist, wk_list);
+	jnewblk = freework->fw_jnewblk;
+	if (jnewblk != NULL) {
+		cancel_jnewblk(jnewblk, &wkhd);
+		needj = 0;
+	} else if (needj)
+		WORKLIST_INSERT(&wkhd, &freework->fw_list);
 	freeblks->fb_chkcnt -= pending;
 	FREE_LOCK(&lk);
 	/*
@@ -5911,7 +6020,7 @@ freework_freeblock(freework)
 	}
 	ffs_blkfree(ump, fs, freeblks->fb_devvp, freework->fw_blkno,
 	    bsize, freeblks->fb_previousinum, &wkhd);
-	if (complete == 0 && needj)
+	if (needj)
 		return;
 	/*
 	 * The jnewblk will be discarded and the bits in the map never
@@ -6085,6 +6194,7 @@ indir_trunc(freework, dbn, lbn)
 {
 	struct freework *nfreework;
 	struct workhead wkhd;
+	struct jnewblk *jnewblkn;
 	struct jnewblk *jnewblk;
 	struct freeblks *freeblks;
 	struct buf *bp;
@@ -6139,6 +6249,12 @@ indir_trunc(freework, dbn, lbn)
 			panic("indir_trunc: lost indirdep %p", wk);
 		indirdep = WK_INDIRDEP(wk);
 		LIST_SWAP(&wkhd, &indirdep->ir_jwork, worklist, wk_list);
+		LIST_FOREACH_SAFE(jnewblk, &indirdep->ir_jnewblkhd,
+		    jn_indirdeps, jnewblkn) {
+			LIST_REMOVE(jnewblk, jn_indirdeps);
+			cancel_jnewblk(jnewblk, &wkhd);
+		}
+
 		free_indirdep(indirdep);
 		if (!LIST_EMPTY(&bp->b_dep))
 			panic("indir_trunc: dangling dep %p",
@@ -6175,6 +6291,7 @@ indir_trunc(freework, dbn, lbn)
 	LIST_FOREACH_SAFE(wk, &wkhd, wk_list, wkn) {
 		if (wk->wk_type != D_JNEWBLK)
 			continue;
+		/* XXX Is the lock necessary here for more than an assert? */
 		ACQUIRE_LOCK(&lk);
 		WORKLIST_REMOVE(wk);
 		FREE_LOCK(&lk);
@@ -6204,7 +6321,7 @@ indir_trunc(freework, dbn, lbn)
 			nlbn = (lbn + 1) - (i * lbnadd);
 			nfreework = newfreework(ump, freeblks, freework,
 			    nlbn, nb, fs->fs_frag, 0);
-			WORKLIST_INSERT_UNLOCKED(&nfreework->fw_jwork, wk);
+			nfreework->fw_jnewblk = jnewblk;
 			freedeps++;
 			indir_trunc(nfreework, fsbtodb(fs, nb), nlbn);
 		} else {
@@ -6322,6 +6439,7 @@ cancel_allocindir(aip, inodedep, freeblk
 	struct inodedep *inodedep;
 	struct freeblks *freeblks;
 {
+	struct jnewblk *jnewblk;
 	struct newblk *newblk;
 
 	/*
@@ -6334,10 +6452,16 @@ cancel_allocindir(aip, inodedep, freeblk
 	 */
 	LIST_REMOVE(aip, ai_next);
 	newblk = (struct newblk *)aip;
-	if (newblk->nb_jnewblk == NULL)
-		cancel_newblk(newblk, &freeblks->fb_jwork);
-	else
-		cancel_newblk(newblk, &aip->ai_indirdep->ir_jwork);
+	if (newblk->nb_jnewblk == NULL) {
+		if (cancel_newblk(newblk, NULL, &freeblks->fb_jwork))
+			panic("cancel_allocindir: Unexpected dependency.");
+	} else {
+		jnewblk = cancel_newblk(newblk, &aip->ai_indirdep->ir_list,
+		    &aip->ai_indirdep->ir_jwork);
+		if (jnewblk)
+			LIST_INSERT_HEAD(&aip->ai_indirdep->ir_jnewblkhd,
+			    jnewblk, jn_indirdeps);
+	}
 	if (inodedep && inodedep->id_state & DEPCOMPLETE)
 		WORKLIST_INSERT(&inodedep->id_bufwait, &newblk->nb_list);
 	else
@@ -8033,6 +8157,7 @@ softdep_disk_io_initiation(bp)
 			if (jfreeblk != NULL) {
 				LIST_REMOVE(&marker, wk_list);
 				LIST_INSERT_BEFORE(wk, &marker, wk_list);
+				stat_jwait_freeblks++;
 				jwait(&jfreeblk->jf_list);
 			}
 			continue;
@@ -8049,6 +8174,7 @@ softdep_disk_io_initiation(bp)
 			if (newblk->nb_jnewblk != NULL) {
 				LIST_REMOVE(&marker, wk_list);
 				LIST_INSERT_BEFORE(wk, &marker, wk_list);
+				stat_jwait_newblk++;
 				jwait(&newblk->nb_jnewblk->jn_list);
 			}
 			continue;
@@ -8602,6 +8728,8 @@ free_indirdep(indirdep)
 
 	KASSERT(LIST_EMPTY(&indirdep->ir_jwork),
 	    ("free_indirdep: Journal work not empty."));
+	KASSERT(LIST_EMPTY(&indirdep->ir_jnewblkhd),
+	    ("free_indirdep: Journal new block list not empty."));
 	KASSERT(LIST_EMPTY(&indirdep->ir_completehd),
 	    ("free_indirdep: Complete head not empty."));
 	KASSERT(LIST_EMPTY(&indirdep->ir_writehd),
@@ -8794,7 +8922,7 @@ softdep_setup_blkfree(mp, bp, blkno, fra
 			printf("state 0x%X %jd - %d %d dep %p\n",
 			    jnewblk->jn_state, jnewblk->jn_blkno,
 			    jnewblk->jn_oldfrags, jnewblk->jn_frags,
-			    jnewblk->jn_newblk);
+			    jnewblk->jn_dep);
 			panic("softdep_setup_blkfree: "
 			    "%jd-%jd(%d) overlaps with %jd-%jd",
 			    blkno, end, frags, jstart, jend);

Modified: head/sys/ufs/ffs/softdep.h
==============================================================================
--- head/sys/ufs/ffs/softdep.h	Thu Apr  7 00:30:32 2011	(r220405)
+++ head/sys/ufs/ffs/softdep.h	Thu Apr  7 03:19:10 2011	(r220406)
@@ -448,6 +448,7 @@ struct indirdep {
 	struct	allocindirhd ir_writehd; /* Waiting for the pointer write. */
 	struct	allocindirhd ir_donehd;	/* done waiting to update safecopy */
 	struct	allocindirhd ir_deplisthd; /* allocindir deps for this block */
+	struct	jnewblkhd ir_jnewblkhd;	/* Canceled block allocations. */
 	struct	workhead ir_jwork;	/* Journal work pending. */
 };
 
@@ -496,7 +497,7 @@ union allblk {
 struct freefrag {
 	struct	worklist ff_list;	/* id_inowait or delayed worklist */
 #	define	ff_state ff_list.wk_state
-	struct	jfreefrag *ff_jfreefrag; /* Associated journal entry. */
+	struct	worklist *ff_jdep;	/* Associated journal entry. */
 	struct	workhead ff_jwork;	/* Journal work pending. */
 	ufs2_daddr_t ff_blkno;		/* fragment physical block number */
 	long	ff_fragsize;		/* size of fragment being deleted */
@@ -538,6 +539,7 @@ struct freework {
 	struct	worklist fw_list;		/* Delayed worklist. */
 #	define	fw_state fw_list.wk_state
 	LIST_ENTRY(freework) fw_next;		/* Queue for freeblk list. */
+	struct	jnewblk  *fw_jnewblk;		/* Journal entry to cancel. */
 	struct	freeblks *fw_freeblks;		/* Root of operation. */
 	struct	freework *fw_parent;		/* Parent indirect. */
 	ufs2_daddr_t	 fw_blkno;		/* Our block #. */
@@ -805,7 +807,8 @@ struct jnewblk {
 #	define	jn_state jn_list.wk_state
 	struct	jsegdep	*jn_jsegdep;	/* Will track our journal record. */
 	LIST_ENTRY(jnewblk) jn_deps;	/* Jnewblks on sm_jnewblkhd. */
-	struct	newblk	*jn_newblk;	/* Back pointer to newblk. */
+	LIST_ENTRY(jnewblk) jn_indirdeps; /* Jnewblks on ir_jnewblkhd. */
+	struct	worklist *jn_dep;	/* Dependency to ref completed seg. */
 	ino_t		jn_ino;		/* Ino to which allocated. */
 	ufs_lbn_t	jn_lbn;		/* Lbn to which allocated. */
 	ufs2_daddr_t	jn_blkno;	/* Blkno allocated */

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 07:10:42 2011
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 DA3EB106564A;
	Thu,  7 Apr 2011 07:10:42 +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 B080D8FC14;
	Thu,  7 Apr 2011 07:10:42 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p377Ag9I031955;
	Thu, 7 Apr 2011 07:10:42 GMT (envelope-from np@svn.freebsd.org)
Received: (from np@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p377Ag4k031952;
	Thu, 7 Apr 2011 07:10:42 GMT (envelope-from np@svn.freebsd.org)
Message-Id: <201104070710.p377Ag4k031952@svn.freebsd.org>
From: Navdeep Parhar 
Date: Thu, 7 Apr 2011 07:10: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: r220410 - 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: Thu, 07 Apr 2011 07:10:42 -0000

Author: np
Date: Thu Apr  7 07:10:42 2011
New Revision: 220410
URL: http://svn.freebsd.org/changeset/base/220410

Log:
  Modify read/write ioctls to work with 64 bit registers too.
  
  MFC after:	3 days

Modified:
  head/sys/dev/cxgbe/t4_ioctl.h
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/t4_ioctl.h
==============================================================================
--- head/sys/dev/cxgbe/t4_ioctl.h	Thu Apr  7 06:02:21 2011	(r220409)
+++ head/sys/dev/cxgbe/t4_ioctl.h	Thu Apr  7 07:10:42 2011	(r220410)
@@ -35,24 +35,25 @@
  * Ioctl commands specific to this driver.
  */
 enum {
-	T4_GET32 = 0x40,		/* read 32 bit register */
-	T4_SET32,			/* write 32 bit register */
+	T4_GETREG = 0x40,		/* read register */
+	T4_SETREG,			/* write register */
 	T4_REGDUMP,			/* dump of all registers */
 };
 
-struct t4_reg32 {
+struct t4_reg {
 	uint32_t addr;
-	uint32_t val;
+	uint32_t size;
+	uint64_t val;
 };
 
 #define T4_REGDUMP_SIZE  (160 * 1024)
 struct t4_regdump {
-	uint32_t  version;
-	uint32_t  len; /* bytes */
-	uint8_t   *data;
+	uint32_t version;
+	uint32_t len; /* bytes */
+	uint32_t *data;
 };
 
-#define CHELSIO_T4_GETREG32	_IOWR('f', T4_GET32, struct t4_reg32)
-#define CHELSIO_T4_SETREG32	_IOW('f', T4_SET32, struct t4_reg32)
+#define CHELSIO_T4_GETREG	_IOWR('f', T4_GETREG, struct t4_reg)
+#define CHELSIO_T4_SETREG	_IOW('f', T4_SETREG, struct t4_reg)
 #define CHELSIO_T4_REGDUMP	_IOWR('f', T4_REGDUMP, struct t4_regdump)
 #endif

Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c	Thu Apr  7 06:02:21 2011	(r220409)
+++ head/sys/dev/cxgbe/t4_main.c	Thu Apr  7 07:10:42 2011	(r220410)
@@ -2803,18 +2803,35 @@ t4_ioctl(struct cdev *dev, unsigned long
 		return (rc);
 
 	switch (cmd) {
-	case CHELSIO_T4_GETREG32: {
-		struct t4_reg32 *edata = (struct t4_reg32 *)data;
+	case CHELSIO_T4_GETREG: {
+		struct t4_reg *edata = (struct t4_reg *)data;
+
 		if ((edata->addr & 0x3) != 0 || edata->addr >= sc->mmio_len)
 			return (EFAULT);
-		edata->val = t4_read_reg(sc, edata->addr);
+
+		if (edata->size == 4)
+			edata->val = t4_read_reg(sc, edata->addr);
+		else if (edata->size == 8)
+			edata->val = t4_read_reg64(sc, edata->addr);
+		else
+			return (EINVAL);
+
 		break;
 	}
-	case CHELSIO_T4_SETREG32: {
-		struct t4_reg32 *edata = (struct t4_reg32 *)data;
+	case CHELSIO_T4_SETREG: {
+		struct t4_reg *edata = (struct t4_reg *)data;
+
 		if ((edata->addr & 0x3) != 0 || edata->addr >= sc->mmio_len)
 			return (EFAULT);
-		t4_write_reg(sc, edata->addr, edata->val);
+
+		if (edata->size == 4) {
+			if (edata->val & 0xffffffff00000000)
+				return (EINVAL);
+			t4_write_reg(sc, edata->addr, (uint32_t) edata->val);
+		} else if (edata->size == 8)
+			t4_write_reg64(sc, edata->addr, edata->val);
+		else
+			return (EINVAL);
 		break;
 	}
 	case CHELSIO_T4_REGDUMP: {

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 07:31:14 2011
Return-Path: 
Delivered-To: svn-src-head@FreeBSD.org
Received: by hub.freebsd.org (Postfix, from userid 1233)
	id 2CD82106566C; Thu,  7 Apr 2011 07:31:14 +0000 (UTC)
Date: Thu, 7 Apr 2011 07:31:14 +0000
From: Alexander Best 
To: Warner Losh 
Message-ID: <20110407073114.GA15050@freebsd.org>
References: <201104062008.p36K8NR0015687@svn.freebsd.org>
	<20110406210416.GA62173@freebsd.org>
	
	<20110406214133.GA66860@freebsd.org>
	
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: 
Cc: Juli Mallett , svn-src-head@FreeBSD.org,
	svn-src-all@FreeBSD.org, src-committers@FreeBSD.org,
	Ulrich Spoerlein 
Subject: Re: svn commit: r220401 - in head: . share/mk tools/build/mk
	tools/build/options
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, 07 Apr 2011 07:31:14 -0000

On Wed Apr  6 11, Warner Losh wrote:
> 
> On Apr 6, 2011, at 3:41 PM, Alexander Best wrote:
> 
> > On Wed Apr  6 11, Juli Mallett wrote:
> >> On Wed, Apr 6, 2011 at 14:04, Alexander Best  wrote:
> >>> On Wed Apr  6 11, Ulrich Spoerlein wrote:
> >>>> Author: uqs
> >>>> Date: Wed Apr  6 20:08:23 2011
> >>>> New Revision: 220401
> >>>> URL: http://svn.freebsd.org/changeset/base/220401
> >>>> 
> >>>> Log:
> >>>>   Complete WITHOUT_CXX support. It implies WITHOUT_GROFF and
> >>>>   WITHOUT_CLANG.
> >>> 
> >>> is there no way to build clang/llvm without CXX support?
> >> 
> >> Clang and LLVM are written in C++.  Even if their support for
> >> compiling C++ could be disabled, you'd still need a C++ cross-compiler
> >> to build them, which ought to be disabled by WITHOUT_CXX, right?
> > 
> > good point. is it even possible to build a world *with* C++ support, if the
> > installed world *doesn't* have C++ support? is the C++ part of gcc written in
> > C? if that's the case it's possible.
> 
> Yes.  We don't need c++ to bootstrap g++ or anything else in the base system.  Once we build the compilers, we can build the c++ that's in the tree.

however that means that FreeBSD can never get rid of gcc. so clang can never
become the main and only base compiler.

> 
> > couldn't we install clang *without* C++ support and then do the following to
> > build it *with* C++ support:
> > 
> > 1) use gcc to build a bootstrap gcc *with* C++ support
> > 2) use the bootstrap gcc to build clang
> 
> I suppose you could do that, but I'm unsure how much that buys you...
> 
> Warner
-- 
a13x

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 08:17:53 2011
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 B92FC106566B;
	Thu,  7 Apr 2011 08:17:53 +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 A89C18FC16;
	Thu,  7 Apr 2011 08:17:53 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p378Hrvk033574;
	Thu, 7 Apr 2011 08:17:53 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p378HrHc033571;
	Thu, 7 Apr 2011 08:17:53 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104070817.p378HrHc033571@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 7 Apr 2011 08:17: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: r220412 - in head: share/man/man4 sys/cam/ata
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, 07 Apr 2011 08:17:53 -0000

Author: mav
Date: Thu Apr  7 08:17:53 2011
New Revision: 220412
URL: http://svn.freebsd.org/changeset/base/220412

Log:
  Make ada(4) driver to control device write cache, same as ata(4) does.
  Add kern.cam.ada.write_cache sysctl/tunable to control it alike hw.ata.wc.

Modified:
  head/share/man/man4/ada.4
  head/sys/cam/ata/ata_da.c

Modified: head/share/man/man4/ada.4
==============================================================================
--- head/share/man/man4/ada.4	Thu Apr  7 07:34:01 2011	(r220411)
+++ head/share/man/man4/ada.4	Thu Apr  7 08:17:53 2011	(r220412)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 24, 2010
+.Dd April 7, 2011
 .Dt ADA 4
 .Os
 .Sh NAME
@@ -123,6 +123,11 @@ seconds.
 This variable determines whether to spin-down disks when shutting down.
 Set to 1 to enable spin-down, 0 to disable.  
 The default is currently enabled.
+.It kern.cam.ada.write_cache
+.Pp
+This variable determines whether device write cache should be enabled or not.
+Set to 1 to enable write cache, 0 to disable, -1 to left it as-is.
+The default is currently enabled.
 .El
 .Sh FILES
 .Bl -tag -width ".Pa /dev/ada*" -compact

Modified: head/sys/cam/ata/ata_da.c
==============================================================================
--- head/sys/cam/ata/ata_da.c	Thu Apr  7 07:34:01 2011	(r220411)
+++ head/sys/cam/ata/ata_da.c	Thu Apr  7 08:17:53 2011	(r220412)
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
 #define ATA_MAX_28BIT_LBA               268435455UL
 
 typedef enum {
+	ADA_STATE_WCACHE,
 	ADA_STATE_NORMAL
 } ada_state;
 
@@ -89,6 +90,7 @@ typedef enum {
 } ada_quirks;
 
 typedef enum {
+	ADA_CCB_WCACHE		= 0x01,
 	ADA_CCB_BUFFER_IO	= 0x03,
 	ADA_CCB_WAITING		= 0x04,
 	ADA_CCB_DUMP		= 0x05,
@@ -186,6 +188,10 @@ static void		adashutdown(void *arg, int 
 #define	ADA_DEFAULT_SPINDOWN_SHUTDOWN	1
 #endif
 
+#ifndef	ADA_DEFAULT_WRITE_CACHE
+#define	ADA_DEFAULT_WRITE_CACHE	1
+#endif
+
 /*
  * Most platforms map firmware geometry to actual, but some don't.  If
  * not overridden, default to nothing.
@@ -198,6 +204,7 @@ static int ada_retry_count = ADA_DEFAULT
 static int ada_default_timeout = ADA_DEFAULT_TIMEOUT;
 static int ada_send_ordered = ADA_DEFAULT_SEND_ORDERED;
 static int ada_spindown_shutdown = ADA_DEFAULT_SPINDOWN_SHUTDOWN;
+static int ada_write_cache = ADA_DEFAULT_WRITE_CACHE;
 
 SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD, 0,
             "CAM Direct Access Disk driver");
@@ -213,6 +220,9 @@ TUNABLE_INT("kern.cam.ada.ada_send_order
 SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_shutdown, CTLFLAG_RW,
            &ada_spindown_shutdown, 0, "Spin down upon shutdown");
 TUNABLE_INT("kern.cam.ada.spindown_shutdown", &ada_spindown_shutdown);
+SYSCTL_INT(_kern_cam_ada, OID_AUTO, write_cache, CTLFLAG_RW,
+           &ada_write_cache, 0, "Enable disk write cache");
+TUNABLE_INT("kern.cam.ada.write_cache", &ada_write_cache);
 
 /*
  * ADA_ORDEREDTAG_INTERVAL determines how often, relative
@@ -568,6 +578,7 @@ adaasync(void *callback_arg, u_int32_t c
 	struct cam_path *path, void *arg)
 {
 	struct cam_periph *periph;
+	struct ada_softc *softc;
 
 	periph = (struct cam_periph *)callback_arg;
 	switch (code) {
@@ -600,6 +611,28 @@ adaasync(void *callback_arg, u_int32_t c
 				"due to status 0x%x\n", status);
 		break;
 	}
+	case AC_SENT_BDR:
+	case AC_BUS_RESET:
+	{
+		struct ccb_getdev cgd;
+
+		softc = (struct ada_softc *)periph->softc;
+		cam_periph_async(periph, code, path, arg);
+		if (ada_write_cache < 0)
+			break;
+		if (softc->state != ADA_STATE_NORMAL)
+			break;
+		xpt_setup_ccb(&cgd.ccb_h, path, CAM_PRIORITY_NORMAL);
+		cgd.ccb_h.func_code = XPT_GDEV_TYPE;
+		xpt_action((union ccb *)&cgd);
+		if ((cgd.ident_data.support.command1 & ATA_SUPPORT_WRITECACHE) == 0)
+			break;
+		softc->state = ADA_STATE_WCACHE;
+		cam_periph_acquire(periph);
+		cam_freeze_devq_arg(periph->path,
+		    RELSIM_RELEASE_RUNLEVEL, CAM_RL_DEV + 1);
+		xpt_schedule(periph, CAM_PRIORITY_DEV);
+	}
 	default:
 		cam_periph_async(periph, code, path, arg);
 		break;
@@ -691,7 +724,6 @@ adaregister(struct cam_periph *periph, v
 	}
 	if (cgd->ident_data.support.command2 & ATA_SUPPORT_CFA)
 		softc->flags |= ADA_FLAG_CAN_CFA;
-	softc->state = ADA_STATE_NORMAL;
 
 	periph->softc = softc;
 
@@ -788,7 +820,7 @@ adaregister(struct cam_periph *periph, v
 	 * them and the only alternative would be to
 	 * not attach the device on failure.
 	 */
-	xpt_register_async(AC_LOST_DEVICE,
+	xpt_register_async(AC_SENT_BDR | AC_BUS_RESET | AC_LOST_DEVICE,
 			   adaasync, periph, periph->path);
 
 	/*
@@ -800,6 +832,16 @@ adaregister(struct cam_periph *periph, v
 	    (ADA_DEFAULT_TIMEOUT * hz) / ADA_ORDEREDTAG_INTERVAL,
 	    adasendorderedtag, softc);
 
+	if (ada_write_cache >= 0 &&
+	    cgd->ident_data.support.command1 & ATA_SUPPORT_WRITECACHE) {
+		softc->state = ADA_STATE_WCACHE;
+		cam_periph_acquire(periph);
+		cam_freeze_devq_arg(periph->path,
+		    RELSIM_RELEASE_RUNLEVEL, CAM_RL_DEV + 1);
+		xpt_schedule(periph, CAM_PRIORITY_DEV);
+	} else
+		softc->state = ADA_STATE_NORMAL;
+
 	return(CAM_REQ_CMP);
 }
 
@@ -1009,6 +1051,23 @@ out:
 		adaschedule(periph);
 		break;
 	}
+	case ADA_STATE_WCACHE:
+	{
+		cam_fill_ataio(ataio,
+		    1,
+		    adadone,
+		    CAM_DIR_NONE,
+		    0,
+		    NULL,
+		    0,
+		    ada_default_timeout*1000);
+
+		ata_28bit_cmd(ataio, ATA_SETFEATURES, ada_write_cache ?
+		    ATA_SF_ENAB_WCACHE : ATA_SF_DIS_WCACHE, 0, 0);
+		start_ccb->ccb_h.ccb_state = ADA_CCB_WCACHE;
+		xpt_action(start_ccb);
+		break;
+	}
 	}
 }
 
@@ -1097,6 +1156,36 @@ adadone(struct cam_periph *periph, union
 			biodone(bp);
 		break;
 	}
+	case ADA_CCB_WCACHE:
+	{
+		if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
+			if (adaerror(done_ccb, 0, 0) == ERESTART) {
+				return;
+			} else if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) {
+				cam_release_devq(done_ccb->ccb_h.path,
+				    /*relsim_flags*/0,
+				    /*reduction*/0,
+				    /*timeout*/0,
+				    /*getcount_only*/0);
+			}
+		}
+
+		softc->state = ADA_STATE_NORMAL;
+		/*
+		 * Since our peripheral may be invalidated by an error
+		 * above or an external event, we must release our CCB
+		 * before releasing the reference on the peripheral.
+		 * The peripheral will only go away once the last reference
+		 * is removed, and we need it around for the CCB release
+		 * operation.
+		 */
+		xpt_release_ccb(done_ccb);
+		cam_release_devq(periph->path,
+		    RELSIM_RELEASE_RUNLEVEL, 0, CAM_RL_DEV + 1, FALSE);
+		adaschedule(periph);
+		cam_periph_release_locked(periph);
+		return;
+	}
 	case ADA_CCB_WAITING:
 	{
 		/* Caller will release the CCB */

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 08:24:59 2011
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 ECFB5106566B;
	Thu,  7 Apr 2011 08:24:59 +0000 (UTC)
	(envelope-from bruce@cran.org.uk)
Received: from muon.cran.org.uk (muon.cran.org.uk
	[IPv6:2a01:348:0:15:5d59:5c40:0:1])
	by mx1.freebsd.org (Postfix) with ESMTP id 83D7B8FC16;
	Thu,  7 Apr 2011 08:24:59 +0000 (UTC)
Received: from muon.cran.org.uk (localhost [127.0.0.1])
	by muon.cran.org.uk (Postfix) with ESMTP id B8147E6179;
	Thu,  7 Apr 2011 09:24:58 +0100 (BST)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cran.org.uk; h=from:to
	:subject:date:cc:references:in-reply-to:mime-version
	:content-type:content-transfer-encoding:message-id; s=mail; bh=g
	pJPkBsz+utofpLRMjMGWR5mMIU=; b=Z4Y/NkG+sbPCVK3SGKNbOnnAWOCyvYWAC
	en3ZAk2LtHDdsefqYILgIpaVUO0NQX+8I9nWkB6+EFRFi+/7vYvzkCQokKdjpKdL
	J61aVZOQNzQx2TqjdxSOCc2uvaZGAJJErMy0ke0onX737aNZfyg176VXDpDb2tBg
	pUX1U8Uy9c=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=cran.org.uk; h=from:to
	:subject:date:cc:references:in-reply-to:mime-version
	:content-type:content-transfer-encoding:message-id; q=dns; s=
	mail; b=BheE6TpJVWUeGJv4YFwsu0nXeLX+wRTCKszH7yVTmKmEeQ+MiPBkF67q
	NU6I9H6hmZLvsLNG0nFskEWPu8rXSPp399CbkdIS9dbxXVYwxmjzXxmRtxr/zhSb
	g/pRa6uYEZIPwHzcgLASQw1ldusqwtqDUcnlkhsVaMta1tHSjlM=
Received: from core.localnet (188-222-18-231.zone13.bethere.co.uk
	[188.222.18.231])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by muon.cran.org.uk (Postfix) with ESMTPSA id A6302E6178;
	Thu,  7 Apr 2011 09:24:58 +0100 (BST)
From: Bruce Cran 
To: Alexander Motin 
Date: Thu, 7 Apr 2011 09:24:59 +0100
User-Agent: KMail/1.13.5 (Linux/2.6.35-28-generic; KDE/4.5.1; x86_64; ; )
References: <201104070817.p378HrHc033571@svn.freebsd.org>
In-Reply-To: <201104070817.p378HrHc033571@svn.freebsd.org>
MIME-Version: 1.0
Content-Type: Text/Plain;
  charset="utf-8"
Content-Transfer-Encoding: 7bit
Message-Id: <201104070924.59180.bruce@cran.org.uk>
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220412 - in head: share/man/man4 sys/cam/ata
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, 07 Apr 2011 08:25:00 -0000

On Thursday 07 Apr 2011 09:17:53 Alexander Motin wrote:

> +This variable determines whether device write cache should be enabled or
> not. +Set to 1 to enable write cache, 0 to disable, -1 to left it as-is.

"left" should probably be "leave".

-- 
Bruce Cran

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 08:28:53 2011
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 A3820106566B;
	Thu,  7 Apr 2011 08:28:53 +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 942D08FC1C;
	Thu,  7 Apr 2011 08:28:53 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p378Srxr033807;
	Thu, 7 Apr 2011 08:28:53 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p378SrUo033805;
	Thu, 7 Apr 2011 08:28:53 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104070828.p378SrUo033805@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 7 Apr 2011 08:28: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: r220413 - head/sys/dev/ahci
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, 07 Apr 2011 08:28:53 -0000

Author: mav
Date: Thu Apr  7 08:28:53 2011
New Revision: 220413
URL: http://svn.freebsd.org/changeset/base/220413

Log:
  Add one more ID for Marvell 88SE912x chip found on Asus U3S6 card.
  
  Submitted by:	Jonas Jonsson 

Modified:
  head/sys/dev/ahci/ahci.c

Modified: head/sys/dev/ahci/ahci.c
==============================================================================
--- head/sys/dev/ahci/ahci.c	Thu Apr  7 08:17:53 2011	(r220412)
+++ head/sys/dev/ahci/ahci.c	Thu Apr  7 08:28:53 2011	(r220413)
@@ -179,6 +179,7 @@ static struct {
 	    AHCI_Q_EDGEIS | AHCI_Q_NONCQ | AHCI_Q_NOCOUNT},
 	{0x614511ab, 0x00, "Marvell 88SX6145",	AHCI_Q_NOFORCE | AHCI_Q_4CH |
 	    AHCI_Q_EDGEIS | AHCI_Q_NONCQ | AHCI_Q_NOCOUNT},
+	{0x91201b4b, 0x00, "Marvell 88SE912x",	AHCI_Q_EDGEIS|AHCI_Q_NOBSYRES},
 	{0x91231b4b, 0x11, "Marvell 88SE912x",	AHCI_Q_NOBSYRES},
 	{0x91231b4b, 0x00, "Marvell 88SE912x",	AHCI_Q_EDGEIS|AHCI_Q_SATA2|AHCI_Q_NOBSYRES},
 	{0x06201103, 0x00, "HighPoint RocketRAID 620",	AHCI_Q_NOBSYRES},

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 08:32:53 2011
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 C88E7106566B;
	Thu,  7 Apr 2011 08:32:53 +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 B92F88FC0C;
	Thu,  7 Apr 2011 08:32:53 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p378Wril033981;
	Thu, 7 Apr 2011 08:32:53 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p378WrGP033979;
	Thu, 7 Apr 2011 08:32:53 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104070832.p378WrGP033979@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 7 Apr 2011 08: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: r220414 - 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: Thu, 07 Apr 2011 08:32:53 -0000

Author: mav
Date: Thu Apr  7 08:32:53 2011
New Revision: 220414
URL: http://svn.freebsd.org/changeset/base/220414

Log:
  Fix spelling.

Modified:
  head/share/man/man4/ada.4

Modified: head/share/man/man4/ada.4
==============================================================================
--- head/share/man/man4/ada.4	Thu Apr  7 08:28:53 2011	(r220413)
+++ head/share/man/man4/ada.4	Thu Apr  7 08:32:53 2011	(r220414)
@@ -126,7 +126,7 @@ The default is currently enabled.
 .It kern.cam.ada.write_cache
 .Pp
 This variable determines whether device write cache should be enabled or not.
-Set to 1 to enable write cache, 0 to disable, -1 to left it as-is.
+Set to 1 to enable write cache, 0 to disable, -1 to leave it as-is.
 The default is currently enabled.
 .El
 .Sh FILES

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 11:40:10 2011
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 857CD1065670;
	Thu,  7 Apr 2011 11:40:10 +0000 (UTC) (envelope-from zec@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 777068FC26;
	Thu,  7 Apr 2011 11:40:10 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p37BeAg9039250;
	Thu, 7 Apr 2011 11:40:10 GMT (envelope-from zec@svn.freebsd.org)
Received: (from zec@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p37BeAlE039248;
	Thu, 7 Apr 2011 11:40:10 GMT (envelope-from zec@svn.freebsd.org)
Message-Id: <201104071140.p37BeAlE039248@svn.freebsd.org>
From: Marko Zec 
Date: Thu, 7 Apr 2011 11:40: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: r220416 - head/sys/netgraph
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, 07 Apr 2011 11:40:10 -0000

Author: zec
Date: Thu Apr  7 11:40:10 2011
New Revision: 220416
URL: http://svn.freebsd.org/changeset/base/220416

Log:
  Properly unref ng_hub nodes on shutdown, so that we don't leak them.
  
  MFC after:	3 days

Modified:
  head/sys/netgraph/ng_hub.c

Modified: head/sys/netgraph/ng_hub.c
==============================================================================
--- head/sys/netgraph/ng_hub.c	Thu Apr  7 11:13:50 2011	(r220415)
+++ head/sys/netgraph/ng_hub.c	Thu Apr  7 11:40:10 2011	(r220416)
@@ -157,6 +157,8 @@ ng_hub_shutdown(node_p node)
 	const priv_p priv = NG_NODE_PRIVATE(node);
 
 	free(priv, M_NETGRAPH_HUB);
+	NG_NODE_SET_PRIVATE(node, NULL);
+	NG_NODE_UNREF(node);
 	return (0);
 }
 

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 12:52:47 2011
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 1F37E106564A;
	Thu,  7 Apr 2011 12:52:47 +0000 (UTC)
	(envelope-from gabor@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0FF5B8FC0C;
	Thu,  7 Apr 2011 12:52:47 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p37CqkVW041025;
	Thu, 7 Apr 2011 12:52:46 GMT (envelope-from gabor@svn.freebsd.org)
Received: (from gabor@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p37CqkN0041023;
	Thu, 7 Apr 2011 12:52:46 GMT (envelope-from gabor@svn.freebsd.org)
Message-Id: <201104071252.p37CqkN0041023@svn.freebsd.org>
From: Gabor Kovesdan 
Date: Thu, 7 Apr 2011 12:52:46 +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: r220420 - head/usr.bin/grep
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, 07 Apr 2011 12:52:47 -0000

Author: gabor
Date: Thu Apr  7 12:52:46 2011
New Revision: 220420
URL: http://svn.freebsd.org/changeset/base/220420

Log:
  - Replace some strcpy()-family functions with memcpy() ones. It has been
    discussed earlier that the extra safeness is not required in these
    cases and we can avoid the overhead by using the more general
    memory copy functions.
  
  Approved by:	delphij (mentor)
  Obtained from:	The NetBSD Project

Modified:
  head/usr.bin/grep/fastgrep.c

Modified: head/usr.bin/grep/fastgrep.c
==============================================================================
--- head/usr.bin/grep/fastgrep.c	Thu Apr  7 11:47:27 2011	(r220419)
+++ head/usr.bin/grep/fastgrep.c	Thu Apr  7 12:52:46 2011	(r220420)
@@ -60,8 +60,7 @@ fgrepcomp(fastgrep_t *fg, const char *pa
 	fg->eol = false;
 	fg->reversed = false;
 
-	fg->pattern = grep_malloc(strlen(pat) + 1);
-	strcpy(fg->pattern, pat);
+	fg->pattern = (unsigned char *)grep_strdup(pat);
 
 	/* Preprocess pattern. */
 	for (i = 0; i <= UCHAR_MAX; i++)
@@ -106,9 +105,10 @@ fastcomp(fastgrep_t *fg, const char *pat
 	}
 
 	if (fg->len >= 14 &&
-	    strncmp(pat + (fg->bol ? 1 : 0), "[[:<:]]", 7) == 0 &&
-	    strncmp(pat + (fg->bol ? 1 : 0) + fg->len - 7, "[[:>:]]", 7) == 0) {
+	    memcmp(pat, "[[:<:]]", 7) == 0 &&
+	    memcmp(pat + fg->len - 7, "[[:>:]]", 7) == 0) {
 		fg->len -= 14;
+		pat += 7;
 		/* Word boundary is handled separately in util.c */
 		wflag = true;
 	}
@@ -119,7 +119,8 @@ fastcomp(fastgrep_t *fg, const char *pat
 	 * string respectively.
 	 */
 	fg->pattern = grep_malloc(fg->len + 1);
-	strlcpy(fg->pattern, pat + (bol ? 1 : 0) + wflag, fg->len + 1);
+	memcpy(fg->pattern, pat, fg->len);
+	fg->pattern[fg->len] = '\0';
 
 	/* Look for ways to cheat...er...avoid the full regex engine. */
 	for (i = 0; i < fg->len; i++) {

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 13:01:04 2011
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 4FF2D106564A;
	Thu,  7 Apr 2011 13:01:04 +0000 (UTC)
	(envelope-from gabor@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 406798FC13;
	Thu,  7 Apr 2011 13:01:04 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p37D14PY041257;
	Thu, 7 Apr 2011 13:01:04 GMT (envelope-from gabor@svn.freebsd.org)
Received: (from gabor@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p37D14UA041253;
	Thu, 7 Apr 2011 13:01:04 GMT (envelope-from gabor@svn.freebsd.org)
Message-Id: <201104071301.p37D14UA041253@svn.freebsd.org>
From: Gabor Kovesdan 
Date: Thu, 7 Apr 2011 13:01: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: r220421 - head/usr.bin/grep
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, 07 Apr 2011 13:01:04 -0000

Author: gabor
Date: Thu Apr  7 13:01:03 2011
New Revision: 220421
URL: http://svn.freebsd.org/changeset/base/220421

Log:
  - Simplify the fixed string pattern preprocessing code
  - Improve readability
  
  Approved by:	delphij (mentor)
  Obtained from:	The NetBSD Project

Modified:
  head/usr.bin/grep/fastgrep.c
  head/usr.bin/grep/grep.h
  head/usr.bin/grep/util.c

Modified: head/usr.bin/grep/fastgrep.c
==============================================================================
--- head/usr.bin/grep/fastgrep.c	Thu Apr  7 12:52:46 2011	(r220420)
+++ head/usr.bin/grep/fastgrep.c	Thu Apr  7 13:01:03 2011	(r220421)
@@ -81,27 +81,25 @@ fastcomp(fastgrep_t *fg, const char *pat
 	int hasDot = 0;
 	int lastHalfDot = 0;
 	int shiftPatternLen;
-	bool bol = false;
-	bool eol = false;
 
 	/* Initialize. */
 	fg->len = strlen(pat);
 	fg->bol = false;
 	fg->eol = false;
 	fg->reversed = false;
+	fg->word = wflag;
 
 	/* Remove end-of-line character ('$'). */
 	if (fg->len > 0 && pat[fg->len - 1] == '$') {
-		eol = true;
 		fg->eol = true;
 		fg->len--;
 	}
 
 	/* Remove beginning-of-line character ('^'). */
 	if (pat[0] == '^') {
-		bol = true;
 		fg->bol = true;
 		fg->len--;
+		pat++;
 	}
 
 	if (fg->len >= 14 &&
@@ -110,7 +108,7 @@ fastcomp(fastgrep_t *fg, const char *pat
 		fg->len -= 14;
 		pat += 7;
 		/* Word boundary is handled separately in util.c */
-		wflag = true;
+		fg->word = true;
 	}
 
 	/*
@@ -149,7 +147,7 @@ fastcomp(fastgrep_t *fg, const char *pat
 	 * Determine if a reverse search would be faster based on the placement
 	 * of the dots.
 	 */
-	if ((!(lflag || cflag)) && ((!(bol || eol)) &&
+	if ((!(lflag || cflag)) && ((!(fg->bol || fg->eol)) &&
 	    ((lastHalfDot) && ((firstHalfDot < 0) ||
 	    ((fg->len - (lastHalfDot + 1)) < (size_t)firstHalfDot)))) &&
 	    !oflag && !color) {

Modified: head/usr.bin/grep/grep.h
==============================================================================
--- head/usr.bin/grep/grep.h	Thu Apr  7 12:52:46 2011	(r220420)
+++ head/usr.bin/grep/grep.h	Thu Apr  7 13:01:03 2011	(r220421)
@@ -102,6 +102,7 @@ typedef struct {
 	bool		 bol;
 	bool		 eol;
 	bool		 reversed;
+	bool		 word;
 } fastgrep_t;
 
 /* Flags passed to regcomp() and regexec() */

Modified: head/usr.bin/grep/util.c
==============================================================================
--- head/usr.bin/grep/util.c	Thu Apr  7 12:52:46 2011	(r220420)
+++ head/usr.bin/grep/util.c	Thu Apr  7 13:01:03 2011	(r220421)
@@ -55,14 +55,15 @@ static int	 procline(struct str *l, int)
 bool
 file_matching(const char *fname)
 {
+	char *fname_base;
 	bool ret;
 
 	ret = finclude ? false : true;
+	fname_base = basename(fname);
 
 	for (unsigned int i = 0; i < fpatterns; ++i) {
-		if (fnmatch(fpattern[i].pat,
-		    fname, 0) == 0 || fnmatch(fpattern[i].pat,
-		    basename(fname), 0) == 0) {
+		if (fnmatch(fpattern[i].pat, fname, 0) == 0 ||
+		    fnmatch(fpattern[i].pat, fname_base, 0) == 0) {
 			if (fpattern[i].mode == EXCL_PAT)
 				return (false);
 			else
@@ -277,7 +278,7 @@ procfile(const char *fn)
  * matches.  The matching lines are passed to printline() to display the
  * appropriate output.
  */
-static inline int
+static int
 procline(struct str *l, int nottext)
 {
 	regmatch_t matches[MAX_LINE_MATCHES];
@@ -318,7 +319,8 @@ procline(struct str *l, int nottext)
 					    (size_t)pmatch.rm_eo != l->len)
 						r = REG_NOMATCH;
 				/* Check for whole word match */
-				if (r == 0 && wflag && pmatch.rm_so != 0) {
+				if (r == 0 && fg_pattern[i].word &&
+				    pmatch.rm_so != 0) {
 					wint_t wbegin, wend;
 
 					wbegin = wend = L' ';

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 13:03:35 2011
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 73ECF106564A;
	Thu,  7 Apr 2011 13:03:35 +0000 (UTC)
	(envelope-from gabor@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 640CD8FC1A;
	Thu,  7 Apr 2011 13:03:35 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p37D3ZWe041355;
	Thu, 7 Apr 2011 13:03:35 GMT (envelope-from gabor@svn.freebsd.org)
Received: (from gabor@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p37D3ZGV041346;
	Thu, 7 Apr 2011 13:03:35 GMT (envelope-from gabor@svn.freebsd.org)
Message-Id: <201104071303.p37D3ZGV041346@svn.freebsd.org>
From: Gabor Kovesdan 
Date: Thu, 7 Apr 2011 13:03: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: r220422 - head/usr.bin/grep
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, 07 Apr 2011 13:03:35 -0000

Author: gabor
Date: Thu Apr  7 13:03:35 2011
New Revision: 220422
URL: http://svn.freebsd.org/changeset/base/220422

Log:
  - Adjust a comment to actual behaviour
  - Makefile nit
  - Add more CVS/SVN keywords to make it easier to track changes from NetBSD
    in case they add further improvements
  
  Approved by:	delphij (mentor)
  Obtained from:	The NetBSD Project

Modified:
  head/usr.bin/grep/Makefile
  head/usr.bin/grep/fastgrep.c
  head/usr.bin/grep/file.c
  head/usr.bin/grep/grep.1
  head/usr.bin/grep/grep.c
  head/usr.bin/grep/grep.h
  head/usr.bin/grep/queue.c
  head/usr.bin/grep/util.c

Modified: head/usr.bin/grep/Makefile
==============================================================================
--- head/usr.bin/grep/Makefile	Thu Apr  7 13:01:03 2011	(r220421)
+++ head/usr.bin/grep/Makefile	Thu Apr  7 13:03:35 2011	(r220422)
@@ -1,13 +1,15 @@
+#	$NetBSD: Makefile,v 1.4 2011/02/16 01:31:33 joerg Exp $
 #	$FreeBSD$
 #	$OpenBSD: Makefile,v 1.6 2003/06/25 15:00:04 millert Exp $
 
 PROG=	grep
 SRCS=	fastgrep.c file.c grep.c queue.c util.c
+
 LINKS=	${BINDIR}/grep ${BINDIR}/egrep \
 	${BINDIR}/grep ${BINDIR}/fgrep \
 	${BINDIR}/grep ${BINDIR}/zgrep \
 	${BINDIR}/grep ${BINDIR}/zegrep \
-	${BINDIR}/grep ${BINDIR}/zfgrep \
+	${BINDIR}/grep ${BINDIR}/zfgrep
 
 MLINKS= grep.1 egrep.1 \
 	grep.1 fgrep.1 \

Modified: head/usr.bin/grep/fastgrep.c
==============================================================================
--- head/usr.bin/grep/fastgrep.c	Thu Apr  7 13:01:03 2011	(r220421)
+++ head/usr.bin/grep/fastgrep.c	Thu Apr  7 13:03:35 2011	(r220422)
@@ -1,4 +1,6 @@
 /*	$OpenBSD: util.c,v 1.36 2007/10/02 17:59:18 otto Exp $	*/
+/*	$NetBSD: fastgrep.c,v 1.4 2011/02/27 17:33:37 joerg Exp $	*/
+/*	$FreeBSD$ */
 
 /*-
  * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
@@ -112,9 +114,9 @@ fastcomp(fastgrep_t *fg, const char *pat
 	}
 
 	/*
-	 * Copy pattern minus '^' and '$' characters as well as word
-	 * match character classes at the beginning and ending of the
-	 * string respectively.
+	 * pat has been adjusted earlier to not include '^', '$' or
+	 * the word match character classes at the beginning and ending
+	 * of the string respectively.
 	 */
 	fg->pattern = grep_malloc(fg->len + 1);
 	memcpy(fg->pattern, pat, fg->len);

Modified: head/usr.bin/grep/file.c
==============================================================================
--- head/usr.bin/grep/file.c	Thu Apr  7 13:01:03 2011	(r220421)
+++ head/usr.bin/grep/file.c	Thu Apr  7 13:03:35 2011	(r220422)
@@ -1,3 +1,5 @@
+/*	$NetBSD: file.c,v 1.5 2011/02/16 18:35:39 joerg Exp $	*/
+/*	$FreeBSD$	*/
 /*	$OpenBSD: file.c,v 1.11 2010/07/02 20:48:48 nicm Exp $	*/
 
 /*-

Modified: head/usr.bin/grep/grep.1
==============================================================================
--- head/usr.bin/grep/grep.1	Thu Apr  7 13:01:03 2011	(r220421)
+++ head/usr.bin/grep/grep.1	Thu Apr  7 13:03:35 2011	(r220422)
@@ -1,3 +1,4 @@
+.\"	$NetBSD: grep.1,v 1.2 2011/02/16 01:31:33 joerg Exp $
 .\"	$FreeBSD$
 .\"	$OpenBSD: grep.1,v 1.38 2010/04/05 06:30:59 jmc Exp $
 .\" Copyright (c) 1980, 1990, 1993

Modified: head/usr.bin/grep/grep.c
==============================================================================
--- head/usr.bin/grep/grep.c	Thu Apr  7 13:01:03 2011	(r220421)
+++ head/usr.bin/grep/grep.c	Thu Apr  7 13:03:35 2011	(r220422)
@@ -1,3 +1,5 @@
+/*	$NetBSD: grep.c,v 1.4 2011/02/16 01:31:33 joerg Exp $	*/
+/* 	$FreeBSD$	*/
 /*	$OpenBSD: grep.c,v 1.42 2010/07/02 22:18:03 tedu Exp $	*/
 
 /*-

Modified: head/usr.bin/grep/grep.h
==============================================================================
--- head/usr.bin/grep/grep.h	Thu Apr  7 13:01:03 2011	(r220421)
+++ head/usr.bin/grep/grep.h	Thu Apr  7 13:03:35 2011	(r220422)
@@ -1,3 +1,4 @@
+/*	$NetBSD: grep.h,v 1.5 2011/02/27 17:33:37 joerg Exp $	*/
 /*	$OpenBSD: grep.h,v 1.15 2010/04/05 03:03:55 tedu Exp $	*/
 /*	$FreeBSD$	*/
 

Modified: head/usr.bin/grep/queue.c
==============================================================================
--- head/usr.bin/grep/queue.c	Thu Apr  7 13:01:03 2011	(r220421)
+++ head/usr.bin/grep/queue.c	Thu Apr  7 13:03:35 2011	(r220422)
@@ -1,3 +1,6 @@
+/*	$NetBSD: queue.c,v 1.2 2011/02/16 01:31:33 joerg Exp $	*/
+/*	$FreeBSD$	*/
+
 /*-
  * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
  * All rights reserved.

Modified: head/usr.bin/grep/util.c
==============================================================================
--- head/usr.bin/grep/util.c	Thu Apr  7 13:01:03 2011	(r220421)
+++ head/usr.bin/grep/util.c	Thu Apr  7 13:03:35 2011	(r220422)
@@ -1,3 +1,5 @@
+/*	$NetBSD: util.c,v 1.9 2011/02/27 17:33:37 joerg Exp $	*/
+/*	$FreeBSD$	*/
 /*	$OpenBSD: util.c,v 1.39 2010/07/02 22:18:03 tedu Exp $	*/
 
 /*-

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 13:14:52 2011
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 02259106564A;
	Thu,  7 Apr 2011 13:14:52 +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 CBCE38FC18;
	Thu,  7 Apr 2011 13:14:51 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p37DEpft041608;
	Thu, 7 Apr 2011 13:14:51 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p37DEpEP041605;
	Thu, 7 Apr 2011 13:14:51 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104071314.p37DEpEP041605@svn.freebsd.org>
From: Adrian Chadd 
Date: Thu, 7 Apr 2011 13: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: r220423 - in head/sys/dev/ath/ath_hal: . ar5212
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, 07 Apr 2011 13:14:52 -0000

Author: adrian
Date: Thu Apr  7 13:14:51 2011
New Revision: 220423
URL: http://svn.freebsd.org/changeset/base/220423

Log:
  Add some more OS_MARK probes to the RX DMA setup/teardown code path.
  
  I'm trying to debug the RX DMA path and help the ath9k guys with
  "RX dma abort stuck" issue that both our drivers have.

Modified:
  head/sys/dev/ath/ath_hal/ah_decode.h
  head/sys/dev/ath/ath_hal/ar5212/ar5212_recv.c

Modified: head/sys/dev/ath/ath_hal/ah_decode.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_decode.h	Thu Apr  7 13:03:35 2011	(r220422)
+++ head/sys/dev/ath/ath_hal/ah_decode.h	Thu Apr  7 13:14:51 2011	(r220423)
@@ -51,5 +51,15 @@ enum {
 	AH_MARK_ANI_RESET,		/* ar*AniReset, opmode */
 	AH_MARK_ANI_POLL,		/* ar*AniReset, listen time */
 	AH_MARK_ANI_CONTROL,		/* ar*AniReset, cmd */
+	AH_MARK_RX_CTL,			/* RX DMA control */
 };
+
+enum {
+	AH_MARK_RX_CTL_PCU_START,
+	AH_MARK_RX_CTL_PCU_STOP,
+	AH_MARK_RX_CTL_DMA_START,
+	AH_MARK_RX_CTL_DMA_STOP,
+	AH_MARK_RX_CTL_DMA_STOP_ERR,
+};
+
 #endif /* _ATH_AH_DECODE_H_ */

Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_recv.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5212/ar5212_recv.c	Thu Apr  7 13:03:35 2011	(r220422)
+++ head/sys/dev/ath/ath_hal/ar5212/ar5212_recv.c	Thu Apr  7 13:14:51 2011	(r220423)
@@ -59,8 +59,10 @@ ar5212EnableReceive(struct ath_hal *ah)
 HAL_BOOL
 ar5212StopDmaReceive(struct ath_hal *ah)
 {
+	OS_MARK(ah, AH_MARK_RX_CTL, AH_MARK_RX_CTL_DMA_STOP);
 	OS_REG_WRITE(ah, AR_CR, AR_CR_RXD);	/* Set receive disable bit */
 	if (!ath_hal_wait(ah, AR_CR, AR_CR_RXE, 0)) {
+		OS_MARK(ah, AH_MARK_RX_CTL, AH_MARK_RX_CTL_DMA_STOP_ERR);
 #ifdef AH_DEBUG
 		ath_hal_printf(ah, "%s: dma failed to stop in 10ms\n"
 			"AR_CR=0x%08x\nAR_DIAG_SW=0x%08x\n",
@@ -82,6 +84,7 @@ ar5212StartPcuReceive(struct ath_hal *ah
 {
 	struct ath_hal_private *ahp = AH_PRIVATE(ah);
 
+	OS_MARK(ah, AH_MARK_RX_CTL, AH_MARK_RX_CTL_PCU_START);
 	OS_REG_WRITE(ah, AR_DIAG_SW,
 		OS_REG_READ(ah, AR_DIAG_SW) &~ AR_DIAG_RX_DIS);
 	ar5212EnableMibCounters(ah);
@@ -95,6 +98,7 @@ ar5212StartPcuReceive(struct ath_hal *ah
 void
 ar5212StopPcuReceive(struct ath_hal *ah)
 {
+	OS_MARK(ah, AH_MARK_RX_CTL, AH_MARK_RX_CTL_PCU_STOP);
 	OS_REG_WRITE(ah, AR_DIAG_SW,
 		OS_REG_READ(ah, AR_DIAG_SW) | AR_DIAG_RX_DIS);
 	ar5212DisableMibCounters(ah);

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 13:49:45 2011
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 006281065672;
	Thu,  7 Apr 2011 13:49:44 +0000 (UTC)
	(envelope-from gallatin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E390B8FC16;
	Thu,  7 Apr 2011 13:49:44 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p37DniZ7042353;
	Thu, 7 Apr 2011 13:49:44 GMT (envelope-from gallatin@svn.freebsd.org)
Received: (from gallatin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p37DniKc042351;
	Thu, 7 Apr 2011 13:49:44 GMT (envelope-from gallatin@svn.freebsd.org)
Message-Id: <201104071349.p37DniKc042351@svn.freebsd.org>
From: Andrew Gallatin 
Date: Thu, 7 Apr 2011 13:49: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: r220424 - head/sys/dev/mxge
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, 07 Apr 2011 13:49:45 -0000

Author: gallatin
Date: Thu Apr  7 13:49:44 2011
New Revision: 220424
URL: http://svn.freebsd.org/changeset/base/220424

Log:
  Fix a bug in mxge's LRO which can cause dup acks to
  get aggregated & hence prevent TCP from entering
  fast retransmit.
  
  Pointed out by: jeff
  Reviewed by: gnn
  MFC after:	7 days

Modified:
  head/sys/dev/mxge/mxge_lro.c

Modified: head/sys/dev/mxge/mxge_lro.c
==============================================================================
--- head/sys/dev/mxge/mxge_lro.c	Thu Apr  7 13:14:51 2011	(r220423)
+++ head/sys/dev/mxge/mxge_lro.c	Thu Apr  7 13:49:44 2011	(r220424)
@@ -237,8 +237,10 @@ mxge_lro_rx(struct mxge_slice_state *ss,
 		    lro->dest_ip == ip->ip_dst.s_addr) {
 			/* Try to append it */
 
-			if (__predict_false(seq != lro->next_seq)) {
-				/* out of order packet */
+			if (__predict_false(seq != lro->next_seq ||
+				    (tcp_data_len == 0 &&
+				     lro->ack_seq == tcp->th_ack))) {
+				/* out of order packet or dup ack */
 				SLIST_REMOVE(&ss->lro_active, lro,
 					     lro_entry, next);
 				mxge_lro_flush(ss, lro);

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 13:54:43 2011
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 0EBD3106566C;
	Thu,  7 Apr 2011 13:54:43 +0000 (UTC)
	(envelope-from glebius@FreeBSD.org)
Received: from cell.glebius.int.ru (glebius.int.ru [81.19.64.117])
	by mx1.freebsd.org (Postfix) with ESMTP id 8E8B58FC08;
	Thu,  7 Apr 2011 13:54:42 +0000 (UTC)
Received: from cell.glebius.int.ru (localhost [127.0.0.1])
	by cell.glebius.int.ru (8.14.4/8.14.4) with ESMTP id p37DseRI026904;
	Thu, 7 Apr 2011 17:54:40 +0400 (MSD)
	(envelope-from glebius@FreeBSD.org)
Received: (from glebius@localhost)
	by cell.glebius.int.ru (8.14.4/8.14.4/Submit) id p37Dseth026903;
	Thu, 7 Apr 2011 17:54:40 +0400 (MSD)
	(envelope-from glebius@FreeBSD.org)
X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to
	glebius@FreeBSD.org using -f
Date: Thu, 7 Apr 2011 17:54:40 +0400
From: Gleb Smirnoff 
To: Marko Zec 
Message-ID: <20110407135440.GX84445@FreeBSD.org>
References: <201104071140.p37BeAlE039248@svn.freebsd.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline
In-Reply-To: <201104071140.p37BeAlE039248@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: r220416 - head/sys/netgraph
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, 07 Apr 2011 13:54:43 -0000

On Thu, Apr 07, 2011 at 11:40:10AM +0000, Marko Zec wrote:
M> Author: zec
M> Date: Thu Apr  7 11:40:10 2011
M> New Revision: 220416
M> URL: http://svn.freebsd.org/changeset/base/220416
M> 
M> Log:
M>   Properly unref ng_hub nodes on shutdown, so that we don't leak them.
M>   
M>   MFC after:	3 days
M> 
M> Modified:
M>   head/sys/netgraph/ng_hub.c
M> 
M> Modified: head/sys/netgraph/ng_hub.c
M> ==============================================================================
M> --- head/sys/netgraph/ng_hub.c	Thu Apr  7 11:13:50 2011	(r220415)
M> +++ head/sys/netgraph/ng_hub.c	Thu Apr  7 11:40:10 2011	(r220416)
M> @@ -157,6 +157,8 @@ ng_hub_shutdown(node_p node)
M>  	const priv_p priv = NG_NODE_PRIVATE(node);
M>  
M>  	free(priv, M_NETGRAPH_HUB);
M> +	NG_NODE_SET_PRIVATE(node, NULL);
M> +	NG_NODE_UNREF(node);
M>  	return (0);
M>  }

Do we really need NG_NODE_SET_PRIVATE()?

-- 
Totus tuus, Glebius.

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 14:27:59 2011
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 A4ADA1065672;
	Thu,  7 Apr 2011 14:27:59 +0000 (UTC) (envelope-from zec@freebsd.org)
Received: from munja.zvne.fer.hr (munja.zvne.fer.hr [161.53.66.248])
	by mx1.freebsd.org (Postfix) with ESMTP id 007308FC15;
	Thu,  7 Apr 2011 14:27:58 +0000 (UTC)
Received: from sluga.fer.hr ([161.53.66.244]) by munja.zvne.fer.hr with
	Microsoft SMTPSVC(6.0.3790.4675); Thu, 7 Apr 2011 16:15:54 +0200
Received: from localhost ([161.53.19.8]) by sluga.fer.hr with Microsoft
	SMTPSVC(6.0.3790.4675); Thu, 7 Apr 2011 16:15:53 +0200
From: Marko Zec 
To: Gleb Smirnoff 
Date: Thu, 7 Apr 2011 16:15:49 +0200
User-Agent: KMail/1.9.10
References: <201104071140.p37BeAlE039248@svn.freebsd.org>
	<20110407135440.GX84445@FreeBSD.org>
In-Reply-To: <20110407135440.GX84445@FreeBSD.org>
MIME-Version: 1.0
Content-Type: text/plain;
  charset="koi8-r"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <201104071615.49994.zec@freebsd.org>
X-OriginalArrivalTime: 07 Apr 2011 14:15:53.0828 (UTC)
	FILETIME=[4E210A40:01CBF52E]
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220416 - head/sys/netgraph
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, 07 Apr 2011 14:27:59 -0000

On Thursday 07 April 2011 15:54:40 Gleb Smirnoff wrote:
> On Thu, Apr 07, 2011 at 11:40:10AM +0000, Marko Zec wrote:
> M> Author: zec
> M> Date: Thu Apr  7 11:40:10 2011
> M> New Revision: 220416
> M> URL: http://svn.freebsd.org/changeset/base/220416
> M>
> M> Log:
> M>   Properly unref ng_hub nodes on shutdown, so that we don't leak them.
> M>
> M>   MFC after:	3 days
> M>
> M> Modified:
> M>   head/sys/netgraph/ng_hub.c
> M>
> M> Modified: head/sys/netgraph/ng_hub.c
> M>
> ===========================================================================
>=== M> --- head/sys/netgraph/ng_hub.c	Thu Apr  7 11:13:50 2011	(r220415) M>
> +++ head/sys/netgraph/ng_hub.c	Thu Apr  7 11:40:10 2011	(r220416) M> @@
> -157,6 +157,8 @@ ng_hub_shutdown(node_p node)
> M>  	const priv_p priv = NG_NODE_PRIVATE(node);
> M>
> M>  	free(priv, M_NETGRAPH_HUB);
> M> +	NG_NODE_SET_PRIVATE(node, NULL);
> M> +	NG_NODE_UNREF(node);
> M>  	return (0);
> M>  }
>
> Do we really need NG_NODE_SET_PRIVATE()?

Most probably not, though the majority of .shutdown method implementations in 
sys/netgraph do include a call to NG_NODE_SET_PRIVATE(node, NULL), so I did a 
C/P from one of those for consistency.  If there's a consensus that 
NG_NODE_SET_PRIVATE(node, NULL) in shutdown methods serves no useful purpose 
then we should do a sweep across all the existing nodes...

Marko

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 19:03:18 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: by hub.freebsd.org (Postfix, from userid 1233)
	id E6B21106566B; Thu,  7 Apr 2011 19:03:18 +0000 (UTC)
Date: Thu, 7 Apr 2011 19:03:18 +0000
From: Alexander Best 
To: Alexander Motin 
Message-ID: <20110407190318.GA97508@freebsd.org>
References: <201104070817.p378HrHc033571@svn.freebsd.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <201104070817.p378HrHc033571@svn.freebsd.org>
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220412 - in head: share/man/man4 sys/cam/ata
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, 07 Apr 2011 19:03:19 -0000

On Thu Apr  7 11, Alexander Motin wrote:
> Author: mav
> Date: Thu Apr  7 08:17:53 2011
> New Revision: 220412
> URL: http://svn.freebsd.org/changeset/base/220412
> 
> Log:
>   Make ada(4) driver to control device write cache, same as ata(4) does.
>   Add kern.cam.ada.write_cache sysctl/tunable to control it alike hw.ata.wc.

how hard would it be to support per device sysctls/tunables? i'd really like to
do:

kern.cam.ada.0.write_cache=0 (root fs)
kern.cam.ada.1.write_cache=1 (/usr, /var, etc.)

cheers.
alex

> 
> Modified:
>   head/share/man/man4/ada.4
>   head/sys/cam/ata/ata_da.c
> 
> Modified: head/share/man/man4/ada.4
> ==============================================================================
> --- head/share/man/man4/ada.4	Thu Apr  7 07:34:01 2011	(r220411)
> +++ head/share/man/man4/ada.4	Thu Apr  7 08:17:53 2011	(r220412)
> @@ -25,7 +25,7 @@
>  .\"
>  .\" $FreeBSD$
>  .\"
> -.Dd October 24, 2010
> +.Dd April 7, 2011
>  .Dt ADA 4
>  .Os
>  .Sh NAME
> @@ -123,6 +123,11 @@ seconds.
>  This variable determines whether to spin-down disks when shutting down.
>  Set to 1 to enable spin-down, 0 to disable.  
>  The default is currently enabled.
> +.It kern.cam.ada.write_cache
> +.Pp
> +This variable determines whether device write cache should be enabled or not.
> +Set to 1 to enable write cache, 0 to disable, -1 to left it as-is.
> +The default is currently enabled.
>  .El
>  .Sh FILES
>  .Bl -tag -width ".Pa /dev/ada*" -compact
> 
> Modified: head/sys/cam/ata/ata_da.c
> ==============================================================================
> --- head/sys/cam/ata/ata_da.c	Thu Apr  7 07:34:01 2011	(r220411)
> +++ head/sys/cam/ata/ata_da.c	Thu Apr  7 08:17:53 2011	(r220412)
> @@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
>  #define ATA_MAX_28BIT_LBA               268435455UL
>  
>  typedef enum {
> +	ADA_STATE_WCACHE,
>  	ADA_STATE_NORMAL
>  } ada_state;
>  
> @@ -89,6 +90,7 @@ typedef enum {
>  } ada_quirks;
>  
>  typedef enum {
> +	ADA_CCB_WCACHE		= 0x01,
>  	ADA_CCB_BUFFER_IO	= 0x03,
>  	ADA_CCB_WAITING		= 0x04,
>  	ADA_CCB_DUMP		= 0x05,
> @@ -186,6 +188,10 @@ static void		adashutdown(void *arg, int 
>  #define	ADA_DEFAULT_SPINDOWN_SHUTDOWN	1
>  #endif
>  
> +#ifndef	ADA_DEFAULT_WRITE_CACHE
> +#define	ADA_DEFAULT_WRITE_CACHE	1
> +#endif
> +
>  /*
>   * Most platforms map firmware geometry to actual, but some don't.  If
>   * not overridden, default to nothing.
> @@ -198,6 +204,7 @@ static int ada_retry_count = ADA_DEFAULT
>  static int ada_default_timeout = ADA_DEFAULT_TIMEOUT;
>  static int ada_send_ordered = ADA_DEFAULT_SEND_ORDERED;
>  static int ada_spindown_shutdown = ADA_DEFAULT_SPINDOWN_SHUTDOWN;
> +static int ada_write_cache = ADA_DEFAULT_WRITE_CACHE;
>  
>  SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD, 0,
>              "CAM Direct Access Disk driver");
> @@ -213,6 +220,9 @@ TUNABLE_INT("kern.cam.ada.ada_send_order
>  SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_shutdown, CTLFLAG_RW,
>             &ada_spindown_shutdown, 0, "Spin down upon shutdown");
>  TUNABLE_INT("kern.cam.ada.spindown_shutdown", &ada_spindown_shutdown);
> +SYSCTL_INT(_kern_cam_ada, OID_AUTO, write_cache, CTLFLAG_RW,
> +           &ada_write_cache, 0, "Enable disk write cache");
> +TUNABLE_INT("kern.cam.ada.write_cache", &ada_write_cache);
>  
>  /*
>   * ADA_ORDEREDTAG_INTERVAL determines how often, relative
> @@ -568,6 +578,7 @@ adaasync(void *callback_arg, u_int32_t c
>  	struct cam_path *path, void *arg)
>  {
>  	struct cam_periph *periph;
> +	struct ada_softc *softc;
>  
>  	periph = (struct cam_periph *)callback_arg;
>  	switch (code) {
> @@ -600,6 +611,28 @@ adaasync(void *callback_arg, u_int32_t c
>  				"due to status 0x%x\n", status);
>  		break;
>  	}
> +	case AC_SENT_BDR:
> +	case AC_BUS_RESET:
> +	{
> +		struct ccb_getdev cgd;
> +
> +		softc = (struct ada_softc *)periph->softc;
> +		cam_periph_async(periph, code, path, arg);
> +		if (ada_write_cache < 0)
> +			break;
> +		if (softc->state != ADA_STATE_NORMAL)
> +			break;
> +		xpt_setup_ccb(&cgd.ccb_h, path, CAM_PRIORITY_NORMAL);
> +		cgd.ccb_h.func_code = XPT_GDEV_TYPE;
> +		xpt_action((union ccb *)&cgd);
> +		if ((cgd.ident_data.support.command1 & ATA_SUPPORT_WRITECACHE) == 0)
> +			break;
> +		softc->state = ADA_STATE_WCACHE;
> +		cam_periph_acquire(periph);
> +		cam_freeze_devq_arg(periph->path,
> +		    RELSIM_RELEASE_RUNLEVEL, CAM_RL_DEV + 1);
> +		xpt_schedule(periph, CAM_PRIORITY_DEV);
> +	}
>  	default:
>  		cam_periph_async(periph, code, path, arg);
>  		break;
> @@ -691,7 +724,6 @@ adaregister(struct cam_periph *periph, v
>  	}
>  	if (cgd->ident_data.support.command2 & ATA_SUPPORT_CFA)
>  		softc->flags |= ADA_FLAG_CAN_CFA;
> -	softc->state = ADA_STATE_NORMAL;
>  
>  	periph->softc = softc;
>  
> @@ -788,7 +820,7 @@ adaregister(struct cam_periph *periph, v
>  	 * them and the only alternative would be to
>  	 * not attach the device on failure.
>  	 */
> -	xpt_register_async(AC_LOST_DEVICE,
> +	xpt_register_async(AC_SENT_BDR | AC_BUS_RESET | AC_LOST_DEVICE,
>  			   adaasync, periph, periph->path);
>  
>  	/*
> @@ -800,6 +832,16 @@ adaregister(struct cam_periph *periph, v
>  	    (ADA_DEFAULT_TIMEOUT * hz) / ADA_ORDEREDTAG_INTERVAL,
>  	    adasendorderedtag, softc);
>  
> +	if (ada_write_cache >= 0 &&
> +	    cgd->ident_data.support.command1 & ATA_SUPPORT_WRITECACHE) {
> +		softc->state = ADA_STATE_WCACHE;
> +		cam_periph_acquire(periph);
> +		cam_freeze_devq_arg(periph->path,
> +		    RELSIM_RELEASE_RUNLEVEL, CAM_RL_DEV + 1);
> +		xpt_schedule(periph, CAM_PRIORITY_DEV);
> +	} else
> +		softc->state = ADA_STATE_NORMAL;
> +
>  	return(CAM_REQ_CMP);
>  }
>  
> @@ -1009,6 +1051,23 @@ out:
>  		adaschedule(periph);
>  		break;
>  	}
> +	case ADA_STATE_WCACHE:
> +	{
> +		cam_fill_ataio(ataio,
> +		    1,
> +		    adadone,
> +		    CAM_DIR_NONE,
> +		    0,
> +		    NULL,
> +		    0,
> +		    ada_default_timeout*1000);
> +
> +		ata_28bit_cmd(ataio, ATA_SETFEATURES, ada_write_cache ?
> +		    ATA_SF_ENAB_WCACHE : ATA_SF_DIS_WCACHE, 0, 0);
> +		start_ccb->ccb_h.ccb_state = ADA_CCB_WCACHE;
> +		xpt_action(start_ccb);
> +		break;
> +	}
>  	}
>  }
>  
> @@ -1097,6 +1156,36 @@ adadone(struct cam_periph *periph, union
>  			biodone(bp);
>  		break;
>  	}
> +	case ADA_CCB_WCACHE:
> +	{
> +		if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
> +			if (adaerror(done_ccb, 0, 0) == ERESTART) {
> +				return;
> +			} else if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) {
> +				cam_release_devq(done_ccb->ccb_h.path,
> +				    /*relsim_flags*/0,
> +				    /*reduction*/0,
> +				    /*timeout*/0,
> +				    /*getcount_only*/0);
> +			}
> +		}
> +
> +		softc->state = ADA_STATE_NORMAL;
> +		/*
> +		 * Since our peripheral may be invalidated by an error
> +		 * above or an external event, we must release our CCB
> +		 * before releasing the reference on the peripheral.
> +		 * The peripheral will only go away once the last reference
> +		 * is removed, and we need it around for the CCB release
> +		 * operation.
> +		 */
> +		xpt_release_ccb(done_ccb);
> +		cam_release_devq(periph->path,
> +		    RELSIM_RELEASE_RUNLEVEL, 0, CAM_RL_DEV + 1, FALSE);
> +		adaschedule(periph);
> +		cam_periph_release_locked(periph);
> +		return;
> +	}
>  	case ADA_CCB_WAITING:
>  	{
>  		/* Caller will release the CCB */

-- 
a13x

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 19:45:44 2011
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 95AAD106564A;
	Thu,  7 Apr 2011 19:45:44 +0000 (UTC)
	(envelope-from glebius@FreeBSD.org)
Received: from cell.glebius.int.ru (glebius.int.ru [81.19.64.117])
	by mx1.freebsd.org (Postfix) with ESMTP id 1AF998FC14;
	Thu,  7 Apr 2011 19:45:43 +0000 (UTC)
Received: from cell.glebius.int.ru (localhost [127.0.0.1])
	by cell.glebius.int.ru (8.14.4/8.14.4) with ESMTP id p37Jjg7v029510;
	Thu, 7 Apr 2011 23:45:42 +0400 (MSD)
	(envelope-from glebius@FreeBSD.org)
Received: (from glebius@localhost)
	by cell.glebius.int.ru (8.14.4/8.14.4/Submit) id p37Jjgsg029509;
	Thu, 7 Apr 2011 23:45:42 +0400 (MSD)
	(envelope-from glebius@FreeBSD.org)
X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to
	glebius@FreeBSD.org using -f
Date: Thu, 7 Apr 2011 23:45:42 +0400
From: Gleb Smirnoff 
To: Marko Zec , julian@FreeBSD.org
Message-ID: <20110407194542.GZ84445@FreeBSD.org>
References: <201104071140.p37BeAlE039248@svn.freebsd.org>
	<20110407135440.GX84445@FreeBSD.org>
	<201104071615.49994.zec@freebsd.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline
In-Reply-To: <201104071615.49994.zec@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: r220416 - head/sys/netgraph
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, 07 Apr 2011 19:45:44 -0000

On Thu, Apr 07, 2011 at 04:15:49PM +0200, Marko Zec wrote:
M> On Thursday 07 April 2011 15:54:40 Gleb Smirnoff wrote:
M> > On Thu, Apr 07, 2011 at 11:40:10AM +0000, Marko Zec wrote:
M> > M> Author: zec
M> > M> Date: Thu Apr  7 11:40:10 2011
M> > M> New Revision: 220416
M> > M> URL: http://svn.freebsd.org/changeset/base/220416
M> > M>
M> > M> Log:
M> > M>   Properly unref ng_hub nodes on shutdown, so that we don't leak them.
M> > M>
M> > M>   MFC after:	3 days
M> > M>
M> > M> Modified:
M> > M>   head/sys/netgraph/ng_hub.c
M> > M>
M> > M> Modified: head/sys/netgraph/ng_hub.c
M> > M>
M> > ===========================================================================
M> >=== M> --- head/sys/netgraph/ng_hub.c	Thu Apr  7 11:13:50 2011	(r220415) M>
M> > +++ head/sys/netgraph/ng_hub.c	Thu Apr  7 11:40:10 2011	(r220416) M> @@
M> > -157,6 +157,8 @@ ng_hub_shutdown(node_p node)
M> > M>  	const priv_p priv = NG_NODE_PRIVATE(node);
M> > M>
M> > M>  	free(priv, M_NETGRAPH_HUB);
M> > M> +	NG_NODE_SET_PRIVATE(node, NULL);
M> > M> +	NG_NODE_UNREF(node);
M> > M>  	return (0);
M> > M>  }
M> >
M> > Do we really need NG_NODE_SET_PRIVATE()?
M> 
M> Most probably not, though the majority of .shutdown method implementations in 
M> sys/netgraph do include a call to NG_NODE_SET_PRIVATE(node, NULL), so I did a 
M> C/P from one of those for consistency.  If there's a consensus that 
M> NG_NODE_SET_PRIVATE(node, NULL) in shutdown methods serves no useful purpose 
M> then we should do a sweep across all the existing nodes...

My humble opinion is that they should be swept. At least to avoid more c/p
in future.

Julian?

-- 
Totus tuus, Glebius.

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 19:53:00 2011
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 14BC0106566C;
	Thu,  7 Apr 2011 19:53:00 +0000 (UTC)
	(envelope-from julian@freebsd.org)
Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16])
	by mx1.freebsd.org (Postfix) with ESMTP id D79398FC08;
	Thu,  7 Apr 2011 19:52:59 +0000 (UTC)
Received: from julian-mac.elischer.org (home-nat.elischer.org [67.100.89.137])
	(authenticated bits=0)
	by vps1.elischer.org (8.14.4/8.14.4) with ESMTP id p37JqtJ1069901
	(version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO);
	Thu, 7 Apr 2011 12:52:58 -0700 (PDT)
	(envelope-from julian@freebsd.org)
Message-ID: <4D9E1637.1000200@freebsd.org>
Date: Thu, 07 Apr 2011 12:53:27 -0700
From: Julian Elischer 
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US;
	rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9
MIME-Version: 1.0
To: Marko Zec 
References: <201104071140.p37BeAlE039248@svn.freebsd.org>
	<20110407135440.GX84445@FreeBSD.org>
	<201104071615.49994.zec@freebsd.org>
In-Reply-To: <201104071615.49994.zec@freebsd.org>
Content-Type: text/plain; charset=KOI8-R; format=flowed
Content-Transfer-Encoding: 7bit
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	Gleb Smirnoff , src-committers@freebsd.org
Subject: Re: svn commit: r220416 - head/sys/netgraph
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, 07 Apr 2011 19:53:00 -0000

On 4/7/11 7:15 AM, Marko Zec wrote:
> On Thursday 07 April 2011 15:54:40 Gleb Smirnoff wrote:
>> On Thu, Apr 07, 2011 at 11:40:10AM +0000, Marko Zec wrote:
>> M>  Author: zec
>> M>  Date: Thu Apr  7 11:40:10 2011
>> M>  New Revision: 220416
>> M>  URL: http://svn.freebsd.org/changeset/base/220416
>> M>
>> M>  Log:
>> M>    Properly unref ng_hub nodes on shutdown, so that we don't leak them.
>> M>
>> M>    MFC after:	3 days
>> M>
>> M>  Modified:
>> M>    head/sys/netgraph/ng_hub.c
>> M>
>> M>  Modified: head/sys/netgraph/ng_hub.c
>> M>
>> ===========================================================================
>> === M>  --- head/sys/netgraph/ng_hub.c	Thu Apr  7 11:13:50 2011	(r220415) M>
>> +++ head/sys/netgraph/ng_hub.c	Thu Apr  7 11:40:10 2011	(r220416) M>  @@
>> -157,6 +157,8 @@ ng_hub_shutdown(node_p node)
>> M>   	const priv_p priv = NG_NODE_PRIVATE(node);
>> M>
>> M>   	free(priv, M_NETGRAPH_HUB);
>> M>  +	NG_NODE_SET_PRIVATE(node, NULL);
>> M>  +	NG_NODE_UNREF(node);
>> M>   	return (0);
>> M>   }
>>
>> Do we really need NG_NODE_SET_PRIVATE()?
> Most probably not, though the majority of .shutdown method implementations in
> sys/netgraph do include a call to NG_NODE_SET_PRIVATE(node, NULL), so I did a
> C/P from one of those for consistency.  If there's a consensus that
> NG_NODE_SET_PRIVATE(node, NULL) in shutdown methods serves no useful purpose
> then we should do a sweep across all the existing nodes...
I'd rather do it than not do it.

private data can refer to stuff that has been malloc'd and at one 
stage I had debug code that
checked for NULL there to catch leaks there's no speed advantage to 
shutting down faster.. :-)


> Marko
>


From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 19:54:11 2011
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 23B7C106564A;
	Thu,  7 Apr 2011 19:54:11 +0000 (UTC)
	(envelope-from julian@freebsd.org)
Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16])
	by mx1.freebsd.org (Postfix) with ESMTP id E89D08FC13;
	Thu,  7 Apr 2011 19:54:10 +0000 (UTC)
Received: from julian-mac.elischer.org (home-nat.elischer.org [67.100.89.137])
	(authenticated bits=0)
	by vps1.elischer.org (8.14.4/8.14.4) with ESMTP id p37Js9SE069914
	(version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO);
	Thu, 7 Apr 2011 12:54:09 -0700 (PDT)
	(envelope-from julian@freebsd.org)
Message-ID: <4D9E1681.30305@freebsd.org>
Date: Thu, 07 Apr 2011 12:54:41 -0700
From: Julian Elischer 
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US;
	rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9
MIME-Version: 1.0
To: Gleb Smirnoff 
References: <201104071140.p37BeAlE039248@svn.freebsd.org>
	<20110407135440.GX84445@FreeBSD.org>
	<201104071615.49994.zec@freebsd.org>
	<20110407194542.GZ84445@FreeBSD.org>
In-Reply-To: <20110407194542.GZ84445@FreeBSD.org>
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, Marko Zec 
Subject: Re: svn commit: r220416 - head/sys/netgraph
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, 07 Apr 2011 19:54:11 -0000

On 4/7/11 12:45 PM, Gleb Smirnoff wrote:
> On Thu, Apr 07, 2011 at 04:15:49PM +0200, Marko Zec wrote:
> M>  On Thursday 07 April 2011 15:54:40 Gleb Smirnoff wrote:
> M>  >  On Thu, Apr 07, 2011 at 11:40:10AM +0000, Marko Zec wrote:
> M>  >  M>  Author: zec
> M>  >  M>  Date: Thu Apr  7 11:40:10 2011
> M>  >  M>  New Revision: 220416
> M>  >  M>  URL: http://svn.freebsd.org/changeset/base/220416
> M>  >  M>
> M>  >  M>  Log:
> M>  >  M>    Properly unref ng_hub nodes on shutdown, so that we don't leak them.
> M>  >  M>
> M>  >  M>    MFC after:	3 days
> M>  >  M>
> M>  >  M>  Modified:
> M>  >  M>    head/sys/netgraph/ng_hub.c
> M>  >  M>
> M>  >  M>  Modified: head/sys/netgraph/ng_hub.c
> M>  >  M>
> M>  >  ===========================================================================
> M>  >=== M>  --- head/sys/netgraph/ng_hub.c	Thu Apr  7 11:13:50 2011	(r220415) M>
> M>  >  +++ head/sys/netgraph/ng_hub.c	Thu Apr  7 11:40:10 2011	(r220416) M>  @@
> M>  >  -157,6 +157,8 @@ ng_hub_shutdown(node_p node)
> M>  >  M>   	const priv_p priv = NG_NODE_PRIVATE(node);
> M>  >  M>
> M>  >  M>   	free(priv, M_NETGRAPH_HUB);
> M>  >  M>  +	NG_NODE_SET_PRIVATE(node, NULL);
> M>  >  M>  +	NG_NODE_UNREF(node);
> M>  >  M>   	return (0);
> M>  >  M>   }
> M>  >
> M>  >  Do we really need NG_NODE_SET_PRIVATE()?
> M>
> M>  Most probably not, though the majority of .shutdown method implementations in
> M>  sys/netgraph do include a call to NG_NODE_SET_PRIVATE(node, NULL), so I did a
> M>  C/P from one of those for consistency.  If there's a consensus that
> M>  NG_NODE_SET_PRIVATE(node, NULL) in shutdown methods serves no useful purpose
> M>  then we should do a sweep across all the existing nodes...
>
> My humble opinion is that they should be swept. At least to avoid more c/p
> in future.
>
> Julian?
>

my opinion goes with anyone who is willing to do the work :-)



From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 20:15:37 2011
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 01AEA106564A;
	Thu,  7 Apr 2011 20:15:37 +0000 (UTC)
	(envelope-from davidch@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E61438FC16;
	Thu,  7 Apr 2011 20:15:36 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p37KFaKJ050862;
	Thu, 7 Apr 2011 20:15:36 GMT (envelope-from davidch@svn.freebsd.org)
Received: (from davidch@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p37KFaAN050859;
	Thu, 7 Apr 2011 20:15:36 GMT (envelope-from davidch@svn.freebsd.org)
Message-Id: <201104072015.p37KFaAN050859@svn.freebsd.org>
From: David Christensen 
Date: Thu, 7 Apr 2011 20:15: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: r220427 - head/sys/dev/bxe
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, 07 Apr 2011 20:15:37 -0000

Author: davidch
Date: Thu Apr  7 20:15:36 2011
New Revision: 220427
URL: http://svn.freebsd.org/changeset/base/220427

Log:
  - Fixed a problem when multiqueue mode was enabled which caused the CQ
    chain to be corrupted.
  - Removed many console print warnings and replaced with driver maintained
    counters.
  - Several style(9) fixes.
  
  MFC after:      One week.

Modified:
  head/sys/dev/bxe/if_bxe.c
  head/sys/dev/bxe/if_bxe.h

Modified: head/sys/dev/bxe/if_bxe.c
==============================================================================
--- head/sys/dev/bxe/if_bxe.c	Thu Apr  7 16:06:39 2011	(r220426)
+++ head/sys/dev/bxe/if_bxe.c	Thu Apr  7 20:15:36 2011	(r220427)
@@ -481,16 +481,12 @@ SYSCTL_UINT(_hw_bxe, OID_AUTO, queue_cou
  * destination IP address and the source/destination TCP port).
  *
  */
+/* static int bxe_multi_mode = ETH_RSS_MODE_REGULAR; */
 static int bxe_multi_mode = ETH_RSS_MODE_DISABLED;
 TUNABLE_INT("hw.bxe.multi_mode", &bxe_multi_mode);
 SYSCTL_UINT(_hw_bxe, OID_AUTO, multi_mode, CTLFLAG_RDTUN, &bxe_multi_mode,
     0, "Multi-Queue Mode");
 
-static uint32_t bxe_pri_map = 0x0;
-TUNABLE_INT("hw.bxe.pri_map", &bxe_pri_map);
-SYSCTL_UINT(_hw_bxe, OID_AUTO, pri_map, CTLFLAG_RDTUN, &bxe_pri_map,
-    0, "Priority map");
-
 /*
  * Host interrupt coalescing is controller by these values.
  * The first frame always causes an interrupt but subsequent
@@ -521,6 +517,7 @@ TUNABLE_INT("hw.bxe.mrrs", &bxe_mrrs);
 SYSCTL_UINT(_hw_bxe, OID_AUTO, mrrs, CTLFLAG_RDTUN, &bxe_mrrs,
     0, "PCIe maximum read request size.");
 
+#if 0
 /*
  * Allows setting the maximum number of received frames to process
  * during an interrupt.
@@ -544,6 +541,7 @@ static int bxe_tx_limit = -1;
 TUNABLE_INT("hw.bxe.tx_limit", &bxe_tx_limit);
 SYSCTL_UINT(_hw_bxe, OID_AUTO, tx_limit, CTLFLAG_RDTUN, &bxe_tx_limit,
 	0, "Maximum transmit frames processed during an interrupt.");
+#endif
 
 /*
  * Global variables
@@ -1891,8 +1889,16 @@ bxe_attach(device_t dev)
 	else
 		sc->mrrs = bxe_mrrs;
 
-	/* Select the RX and TX ring sizes */
-	sc->tx_ring_size = USABLE_TX_BD;
+	/*
+	 * Select the RX and TX ring sizes.  The actual
+	 * ring size for TX is complicated by the fact
+	 * that a single TX frame may be broken up into
+	 * many buffer descriptors (tx_start_bd,
+	 * tx_parse_bd, tx_data_bd).  In the best case,
+	 * there are always at least two BD's required
+	 * so we'll assume the best case here.
+	 */
+	sc->tx_ring_size = (USABLE_TX_BD >> 1);
 	sc->rx_ring_size = USABLE_RX_BD;
 
 	/* Assume receive IP/TCP/UDP checksum is enabled. */
@@ -2907,7 +2913,7 @@ bxe_setup_leading(struct bxe_softc *sc)
 
 	DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET | BXE_VERBOSE_RAMROD);
 
-	DBPRINT(sc, BXE_INFO_LOAD, "%s(): Setup leading connection "
+	DBPRINT(sc, BXE_VERBOSE_LOAD, "%s(): Setup leading connection "
 	    "on fp[00].\n", __FUNCTION__);
 
 	/* Reset IGU state for the leading connection. */
@@ -2938,7 +2944,7 @@ bxe_stop_leading(struct bxe_softc *sc)
 
 	DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET | BXE_VERBOSE_RAMROD);
 
-	DBPRINT(sc, BXE_INFO_LOAD, "%s(): Stop client connection "
+	DBPRINT(sc, BXE_VERBOSE_LOAD, "%s(): Stop client connection "
 	    "on fp[00].\n", __FUNCTION__);
 
 	/* Send the ETH_HALT ramrod. */
@@ -2999,7 +3005,7 @@ bxe_setup_multi(struct bxe_softc *sc, in
 
 	DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET | BXE_VERBOSE_RAMROD);
 
-	DBPRINT(sc, BXE_INFO_LOAD, "%s(): Setup client connection "
+	DBPRINT(sc, BXE_VERBOSE_LOAD, "%s(): Setup client connection "
 	    "on fp[%02d].\n", __FUNCTION__, index);
 
 	fp = &sc->fp[index];
@@ -3034,7 +3040,7 @@ bxe_stop_multi(struct bxe_softc *sc, int
 
 	DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET | BXE_VERBOSE_RAMROD);
 
-	DBPRINT(sc, BXE_INFO_LOAD, "%s(): Stop client connection "
+	DBPRINT(sc, BXE_VERBOSE_LOAD, "%s(): Stop client connection "
 	    "on fp[%02d].\n", __FUNCTION__, index);
 
 	fp = &sc->fp[index];
@@ -3679,6 +3685,7 @@ bxe_init_locked(struct bxe_softc *sc, in
 			BXE_PRINTF("Multi-function mode is disabled\n");
 			/* sc->state = BXE_STATE_DISABLED; */
 		}
+
 		/* Setup additional client connections for RSS/multi-queue */
 		if (sc->state == BXE_STATE_OPEN) {
 			for (i = 1; i < sc->num_queues; i++) {
@@ -3794,9 +3801,9 @@ bxe_wait_ramrod(struct bxe_softc *sc, in
 
 	DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET | BXE_VERBOSE_RAMROD);
 
-	DBPRINT(sc, BXE_VERBOSE_RAMROD, "%s(): %s for state 0x%08X on fp[%d], "
-	    "currently 0x%08X.\n", __FUNCTION__, poll ? "Polling" : "Waiting",
-	    state, idx, *state_p);
+	DBPRINT(sc, BXE_VERBOSE_RAMROD, "%s(): %s for state 0x%08X on "
+	    "fp[%02d], currently 0x%08X.\n", __FUNCTION__,
+	    poll ? "Polling" : "Waiting", state, idx, *state_p);
 
 	rc = 0;
 	timeout = 5000;
@@ -8680,9 +8687,9 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 					/* OK to send. */
 					break;
 				else
-					fp->tso_window_violation++;
+					fp->window_violation_tso++;
 			} else
-				fp->std_window_violation++;
+				fp->window_violation_std++;
 
 			/*
 			 * If this is a standard frame then defrag is
@@ -8829,7 +8836,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 			if (m0->m_pkthdr.csum_flags & CSUM_IP) {
 				DBPRINT(sc, BXE_EXTREME_SEND, "%s(): IP checksum "
 					"enabled.\n", __FUNCTION__);
-				fp->ip_csum_offload_frames++;
+				fp->offload_frames_csum_ip++;
 				flags |= ETH_TX_BD_FLAGS_IP_CSUM;
 			}
 
@@ -8846,7 +8853,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 
 				/* Add the TCP checksum offload flag. */
 				flags |= ETH_TX_BD_FLAGS_L4_CSUM;
-				fp->tcp_csum_offload_frames++;
+				fp->offload_frames_csum_tcp++;
 
 				/* Update the enet + IP + TCP header length. */
 				tx_parse_bd->total_hlen += (uint16_t)(th->th_off << 1);
@@ -8879,7 +8886,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 
 				/* Add the TCP checksum offload flag for UDP frames too. */
 				flags |= ETH_TX_BD_FLAGS_L4_CSUM;
-				fp->udp_csum_offload_frames++;
+				fp->offload_frames_csum_udp++;
 				tx_parse_bd->global_data |= ETH_TX_PARSE_BD_UDP_CS_FLG;
 
 				/* Get a pointer to the UDP header. */
@@ -8907,12 +8914,12 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 			break;
 		}
 		case ETHERTYPE_IPV6:
-			fp->unsupported_tso_ipv6_request++;
+			fp->unsupported_tso_request_ipv6++;
 			/* DRC - How to handle this error? */
 			break;
 
 		default:
-			fp->unsupported_tso_protocol_request++;
+			fp->unsupported_tso_request_not_tcp++;
 			/* DRC - How to handle this error? */
 		}
 
@@ -8926,7 +8933,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 
 			tx_start_bd->bd_flags.as_bitfield |= ETH_TX_BD_FLAGS_SW_LSO;
 
-			fp->tso_offload_frames++;
+			fp->offload_frames_tso++;
  			if (__predict_false(tx_start_bd->nbytes > hdr_len)) {
 				/*
 				 * Split the first BD into 2 BDs to make the
@@ -9047,7 +9054,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 
 	DOORBELL(sc, fp->index, fp->tx_db.raw);
 
-	DBRUN(fp->tx_pkts++);
+	fp->tx_pkts++;
 
 	/* Prevent speculative reads from getting ahead of the status block. */
 	bus_space_barrier(sc->bxe_btag, sc->bxe_bhandle,
@@ -9076,13 +9083,10 @@ bxe_tx_start(struct ifnet *ifp)
 {
 	struct bxe_softc *sc;
 	struct bxe_fastpath *fp;
-	int fp_index;
 
 	sc = ifp->if_softc;
 	DBENTER(BXE_EXTREME_SEND);
 
-	fp_index = 0;
-
 	/* Exit if there's no link. */
 	if (!sc->link_vars.link_up) {
 		DBPRINT(sc, BXE_VERBOSE_SEND,
@@ -9101,7 +9105,7 @@ bxe_tx_start(struct ifnet *ifp)
 	}
 
 	/* Set the TX queue for the frame. */
-	fp = &sc->fp[fp_index];
+	fp = &sc->fp[0];
 
 	BXE_CORE_LOCK(sc);
 	bxe_tx_start_locked(ifp, fp);
@@ -9389,10 +9393,10 @@ bxe_ioctl(struct ifnet *ifp, u_long comm
 static __inline uint16_t
 bxe_rx_cq_cons(struct bxe_fastpath *fp)
 {
-	volatile uint16_t rx_cons_sb = 0;
+	volatile uint16_t rx_cq_cons_sb = 0;
 
 	rmb();
-	rx_cons_sb = (volatile uint16_t) le16toh(*fp->rx_cons_sb);
+	rx_cq_cons_sb = (volatile uint16_t) le16toh(*fp->rx_cq_cons_sb);
 
 	/*
 	 * It is valid for the hardware's copy of the completion
@@ -9401,11 +9405,11 @@ bxe_rx_cq_cons(struct bxe_fastpath *fp)
 	 * that it is pointing at the next available CQE so we
 	 * need to adjust the value accordingly.
 	 */
-	if ((rx_cons_sb & USABLE_RCQ_ENTRIES_PER_PAGE) ==
+	if ((rx_cq_cons_sb & USABLE_RCQ_ENTRIES_PER_PAGE) ==
 		USABLE_RCQ_ENTRIES_PER_PAGE)
-		rx_cons_sb++;
+		rx_cq_cons_sb++;
 
-	return (rx_cons_sb);
+	return (rx_cq_cons_sb);
 }
 
 static __inline int
@@ -10301,7 +10305,7 @@ bxe_init_rx_chains(struct bxe_softc *sc)
 	struct eth_rx_sge *sge;
 	struct eth_rx_bd *rx_bd;
 	struct eth_rx_cqe_next_page *nextpg;
-	uint16_t ring_prod, cqe_ring_prod;
+	uint16_t rx_bd_prod, rx_sge_prod;
 	int func, i, j, rcq_idx, rx_idx, rx_sge_idx, max_agg_queues;
 
 	DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET);
@@ -10347,15 +10351,17 @@ bxe_init_rx_chains(struct bxe_softc *sc)
 		}
 	}
 
+	/* Allocate memory for RX and CQ chains. */
 	for (i = 0; i < sc->num_queues; i++) {
 		fp = &sc->fp[i];
 		DBPRINT(sc, (BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET),
 		    "%s(): Initializing fp[%d] RX chain.\n", __FUNCTION__, i);
 
-		fp->rx_bd_cons = 0;
+		fp->rx_bd_cons = fp->rx_bd_prod = 0;
+		fp->rx_cq_cons = fp->rx_cq_prod = 0;
 
-		/* Pointer to status block's completion queue consumer index. */
-		fp->rx_cons_sb = &fp->status_block->
+		/* Status block's completion queue consumer index. */
+		fp->rx_cq_cons_sb = &fp->status_block->
 		    u_status_block.index_values[HC_INDEX_U_ETH_RX_CQ_CONS];
 
 		/* Pointer to status block's receive consumer index. */
@@ -10395,7 +10401,7 @@ bxe_init_rx_chains(struct bxe_softc *sc)
 			rx_idx = ((j + 1) % NUM_RX_PAGES);
 			rx_bd = &fp->rx_bd_chain[j][USABLE_RX_BD_PER_PAGE];
 
-			DBPRINT(sc, (BXE_INFO_LOAD),
+			DBPRINT(sc, (BXE_EXTREME_LOAD),
 			    "%s(): fp[%02d].rx_bd_chain[%02d][0x%04X]=0x%jX\n",
 			     __FUNCTION__, i, j,
 			    (uint16_t) USABLE_RX_BD_PER_PAGE,
@@ -10417,7 +10423,7 @@ bxe_init_rx_chains(struct bxe_softc *sc)
 			nextpg = (struct eth_rx_cqe_next_page *)
 			    &fp->rx_cq_chain[j][USABLE_RCQ_ENTRIES_PER_PAGE];
 
-			DBPRINT(sc, (BXE_INFO_LOAD),
+			DBPRINT(sc, (BXE_EXTREME_LOAD),
 			    "%s(): fp[%02d].rx_cq_chain[%02d][0x%04X]=0x%jX\n",
 			     __FUNCTION__, i, j,
 			    (uint16_t) USABLE_RCQ_ENTRIES_PER_PAGE,
@@ -10431,10 +10437,10 @@ bxe_init_rx_chains(struct bxe_softc *sc)
 
 		if (TPA_ENABLED(sc)) {
 			/* Allocate SGEs and initialize the ring elements. */
-			ring_prod = 0;
+			rx_sge_prod = 0;
 
-			while (ring_prod < sc->rx_ring_size) {
-				if (bxe_alloc_rx_sge(sc, fp, ring_prod) != 0) {
+			while (rx_sge_prod < sc->rx_ring_size) {
+				if (bxe_alloc_rx_sge(sc, fp, rx_sge_prod) != 0) {
 					fp->tpa_mbuf_alloc_failed++;
 					BXE_PRINTF(
 					    "%s(%d): Memory allocation failure! "
@@ -10443,48 +10449,48 @@ bxe_init_rx_chains(struct bxe_softc *sc)
 
 					/* Cleanup already allocated elements */
 					bxe_free_rx_sge_range(sc, fp,
-					    ring_prod);
+					    rx_sge_prod);
 					fp->disable_tpa = 1;
-					ring_prod = 0;
+					rx_sge_prod = 0;
 					break;
 				}
-				ring_prod = NEXT_SGE_IDX(ring_prod);
+				rx_sge_prod = NEXT_SGE_IDX(rx_sge_prod);
 			}
 
-			fp->rx_sge_prod = ring_prod;
+			fp->rx_sge_prod = rx_sge_prod;
 		}
 
 		/*
 		 * Allocate buffers for all the RX BDs in RX BD Chain.
-		 * Add completion queue entries at the same time.
 		 */
-		fp->rx_cq_cons = ring_prod = cqe_ring_prod = 0;
-		DBRUN(fp->free_rx_bd = USABLE_RX_BD);
+		rx_bd_prod = 0;
+		DBRUN(fp->free_rx_bd = sc->rx_ring_size);
 
-		while (ring_prod < sc->rx_ring_size) {
-			if (bxe_get_buf(fp, NULL, ring_prod)) {
+		for (j = 0; j < sc->rx_ring_size; j++) {
+			if (bxe_get_buf(fp, NULL, rx_bd_prod)) {
 				BXE_PRINTF(
 	"%s(%d): Memory allocation failure! Cannot fill fp[%d] RX chain.\n",
 				    __FILE__, __LINE__, i);
 				break;
 			}
-			ring_prod = NEXT_RX_BD(ring_prod);
-			cqe_ring_prod = NEXT_RCQ_IDX(cqe_ring_prod);
+			rx_bd_prod = NEXT_RX_BD(rx_bd_prod);
 		}
 
 		/* Update the driver's copy of the producer indices. */
-		fp->rx_bd_prod = ring_prod;
+		fp->rx_bd_prod = rx_bd_prod;
+		fp->rx_cq_prod = MAX_RCQ_ENTRIES;
+		fp->rx_pkts = fp->rx_calls = 0;
 
-		fp->rx_cq_prod = cqe_ring_prod;
-		/*
-		 * fp->rx_cq_prod =
-		 *     (uint16_t)min(NUM_RCQ_PAGES*TOTAL_RCQ_ENTRIES_PER_PAGE,
-		 *     cqe_ring_prod);
-		 */
+		DBPRINT(sc, (BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET),
+		    "%s(): USABLE_RX_BD=0x%04X, USABLE_RCQ_ENTRIES=0x%04X\n",
+		    __FUNCTION__, (uint16_t) USABLE_RX_BD,
+		    (uint16_t) USABLE_RCQ_ENTRIES);
+		DBPRINT(sc, (BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET),
+		    "%s(): fp[%02d]->rx_bd_prod=0x%04X, rx_cq_prod=0x%04X\n",
+		    __FUNCTION__, i, fp->rx_bd_prod, fp->rx_cq_prod);
 
-		DBRUN(fp->rx_pkts = fp->rx_calls = 0);
 
-		/* Prepare the CQ buffers for DMA access. */
+		/* Prepare the recevie BD and CQ buffers for DMA access. */
 		for (j = 0; j < NUM_RX_PAGES; j++)
 			bus_dmamap_sync(fp->rx_bd_chain_tag,
 			    fp->rx_bd_chain_map[j], BUS_DMASYNC_PREREAD |
@@ -10496,22 +10502,26 @@ bxe_init_rx_chains(struct bxe_softc *sc)
 			    BUS_DMASYNC_PREWRITE);
 
 		/*
-		 * Tell the controller that we have rx_bd's and CQE's available.
-		 * Warning! this will generate an interrupt (to the TSTORM).
-		 * This must only be done when the controller is initialized.
+		 * Tell the controller that we have rx_bd's and CQE's
+		 * available.  Warning! this will generate an interrupt
+		 * (to the TSTORM).  This must only be done when the
+		 * controller is initialized.
 		 */
-		bxe_update_rx_prod(sc, fp, ring_prod, fp->rx_cq_prod,
-		    fp->rx_sge_prod);
+		bxe_update_rx_prod(sc, fp, fp->rx_bd_prod,
+		    fp->rx_cq_prod, fp->rx_sge_prod);
 
-		if (i != 0)
-			continue;
-
-		REG_WR(sc, BAR_USTORM_INTMEM +
-		    USTORM_MEM_WORKAROUND_ADDRESS_OFFSET(func),
-		    U64_LO(fp->rx_cq_chain_paddr[0]));
-		REG_WR(sc, BAR_USTORM_INTMEM +
-		    USTORM_MEM_WORKAROUND_ADDRESS_OFFSET(func) + 4,
-		    U64_HI(fp->rx_cq_chain_paddr[0]));
+		/*
+		 * Tell controller where the receive CQ
+		 * chains start in physical memory.
+		 */
+		if (i == 0) {
+			REG_WR(sc, BAR_USTORM_INTMEM +
+			    USTORM_MEM_WORKAROUND_ADDRESS_OFFSET(func),
+			    U64_LO(fp->rx_cq_chain_paddr[0]));
+			REG_WR(sc, BAR_USTORM_INTMEM +
+			    USTORM_MEM_WORKAROUND_ADDRESS_OFFSET(func) + 4,
+			    U64_HI(fp->rx_cq_chain_paddr[0]));
+		}
 	}
 
 	DBEXIT(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET);
@@ -10570,7 +10580,7 @@ bxe_init_tx_chains(struct bxe_softc *sc)
 		fp->tx_cons_sb =
 		    &fp->status_block->c_status_block.index_values[C_SB_ETH_TX_CQ_INDEX];
 
-		DBRUN(fp->tx_pkts = 0);
+		fp->tx_pkts = 0;
 	}
 
 	DBEXIT(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET);
@@ -11196,7 +11206,8 @@ bxe_init_internal_func(struct bxe_softc 
 	for (i = 0; i < sc->num_queues; i++) {
 		fp = &sc->fp[i];
 		nextpg = (struct eth_rx_cqe_next_page *)
-		    &fp->rx_cq_chain[i][USABLE_RCQ_ENTRIES_PER_PAGE];
+		    &fp->rx_cq_chain[0][USABLE_RCQ_ENTRIES_PER_PAGE];
+
 		/* Program the completion queue address. */
 		REG_WR(sc, BAR_USTORM_INTMEM +
 		    USTORM_CQE_PAGE_BASE_OFFSET(port, fp->cl_id),
@@ -11205,15 +11216,18 @@ bxe_init_internal_func(struct bxe_softc 
 		    USTORM_CQE_PAGE_BASE_OFFSET(port, fp->cl_id) + 4,
 		    U64_HI(fp->rx_cq_chain_paddr[0]));
 
-		/* Next page */
-		REG_WR(sc, BAR_USTORM_INTMEM + USTORM_CQE_PAGE_NEXT_OFFSET(port,
-		    fp->cl_id), nextpg->addr_lo);
-		REG_WR(sc, BAR_USTORM_INTMEM + USTORM_CQE_PAGE_NEXT_OFFSET(port,
-		    fp->cl_id) + 4, nextpg->addr_hi);
+		/* Program the first CQ next page address. */
+		REG_WR(sc, BAR_USTORM_INTMEM +
+		    USTORM_CQE_PAGE_NEXT_OFFSET(port, fp->cl_id),
+		    nextpg->addr_lo);
+		REG_WR(sc, BAR_USTORM_INTMEM +
+		    USTORM_CQE_PAGE_NEXT_OFFSET(port, fp->cl_id) + 4,
+		    nextpg->addr_hi);
 
 		/* Set the maximum TPA aggregation size. */
 		REG_WR16(sc, BAR_USTORM_INTMEM +
-		    USTORM_MAX_AGG_SIZE_OFFSET(port, fp->cl_id), max_agg_size);
+		    USTORM_MAX_AGG_SIZE_OFFSET(port, fp->cl_id),
+		    max_agg_size);
 	}
 
 	/* Configure lossless flow control. */
@@ -11258,14 +11272,6 @@ bxe_init_internal_func(struct bxe_softc 
 			    "fairness will be disabled.\n", __FUNCTION__);
 	}
 
-	switch (sc->multi_mode) {
-	case ETH_RSS_MODE_DISABLED:
-	case ETH_RSS_MODE_REGULAR:
-		break;
-	default:
-		break;
-	}
-
 	/* Store it to internal memory */
 	if (sc->port.pmf) {
 		for (i = 0; i < sizeof(struct cmng_struct_per_port) / 4; i++)
@@ -11351,7 +11357,7 @@ bxe_init_nic(struct bxe_softc *sc, uint3
 		/* Set the status block ID for this fastpath instance. */
 		fp->sb_id = fp->cl_id;
 
-		DBPRINT(sc, (BXE_INFO_LOAD | BXE_INFO_RESET),
+		DBPRINT(sc, (BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET),
 		    "%s(): fp[%d]: cl_id = %d, sb_id = %d\n",
 		    __FUNCTION__, fp->index, fp->cl_id, fp->sb_id);
 
@@ -11872,24 +11878,27 @@ bxe_init_pxp_arb(struct bxe_softc *sc, i
 	uint32_t val, i;
 
 	if (r_order > MAX_RD_ORD) {
-		DBPRINT(sc, BXE_INFO,
-		    "read order of %d order adjusted to %d\n", r_order,
-		    MAX_RD_ORD);
+		DBPRINT(sc, (BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET),
+		    "%s(): Read order of %d order adjusted to %d\n",
+		    __FUNCTION__,  r_order, MAX_RD_ORD);
 		r_order = MAX_RD_ORD;
 	}
 	if (w_order > MAX_WR_ORD) {
-		DBPRINT(sc, BXE_INFO,
-		    "write order of %d order adjusted to %d\n", w_order,
-		    MAX_WR_ORD);
+		DBPRINT(sc, (BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET),
+		    "%s(): Write order of %d order adjusted to %d\n",
+		    __FUNCTION__, w_order, MAX_WR_ORD);
 		w_order = MAX_WR_ORD;
 	}
 
-	DBPRINT(sc, BXE_INFO, "read order %d write order %d\n", r_order,
-	    w_order);
+	DBPRINT(sc, (BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET),
+	    "%s(): Read order %d, write order %d\n",
+	    __FUNCTION__, r_order, w_order);
 
 	for (i = 0; i < NUM_RD_Q - 1; i++) {
-		REG_WR(sc, read_arb_addr[i].l, read_arb_data[i][r_order].l);
-		REG_WR(sc, read_arb_addr[i].add, read_arb_data[i][r_order].add);
+		REG_WR(sc, read_arb_addr[i].l,
+		    read_arb_data[i][r_order].l);
+		REG_WR(sc, read_arb_addr[i].add,
+		    read_arb_data[i][r_order].add);
 		REG_WR(sc, read_arb_addr[i].ubound,
 		    read_arb_data[i][r_order].ubound);
 	}
@@ -11969,13 +11978,17 @@ bxe_init_pxp(struct bxe_softc *sc)
 	uint16_t devctl;
 	int r_order, w_order;
 
-	devctl = pci_read_config(sc->bxe_dev, sc->pcie_cap + PCI_EXP_DEVCTL, 2);
-	DBPRINT(sc, BXE_INFO, "read 0x%x from devctl\n", devctl);
+	devctl = pci_read_config(sc->bxe_dev,
+	    sc->pcie_cap + PCI_EXP_DEVCTL, 2);
+	DBPRINT(sc, (BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET),
+	    "%s(): Read 0x%x from devctl\n", __FUNCTION__, devctl);
 	w_order = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5);
 	if (sc->mrrs == -1)
 		r_order = ((devctl & PCI_EXP_DEVCTL_READRQ) >> 12);
 	else {
-		DBPRINT(sc, BXE_INFO, "force read order to %d\n", sc->mrrs);
+		DBPRINT(sc, (BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET),
+		    "%s(): Force MRRS read order to %d\n",
+		    __FUNCTION__, sc->mrrs);
 		r_order = sc->mrrs;
 	}
 
@@ -13990,7 +14003,8 @@ bxe_set_rx_mode(struct bxe_softc *sc)
 	} else {
 		/* Enable selective multicast mode. */
 		DBPRINT(sc, BXE_INFO,
-		    "%s(): Enabling selective multicast mode.\n", __FUNCTION__);
+		    "%s(): Enabling selective multicast mode.\n",
+		    __FUNCTION__);
 
 		if (CHIP_IS_E1(sc)) {
 			i = 0;
@@ -14683,14 +14697,14 @@ bxe_tpa_stop_exit:
  */
 static __inline void
 bxe_update_rx_prod(struct bxe_softc *sc, struct bxe_fastpath *fp,
-    uint16_t bd_prod, uint16_t rx_cq_prod, uint16_t sge_prod)
+    uint16_t bd_prod, uint16_t cqe_prod, uint16_t sge_prod)
 {
 	volatile struct ustorm_eth_rx_producers rx_prods = {0};
 	int i;
 
 	/* Update producers. */
 	rx_prods.bd_prod =  bd_prod;
-	rx_prods.cqe_prod = rx_cq_prod;
+	rx_prods.cqe_prod = cqe_prod;
 	rx_prods.sge_prod = sge_prod;
 
 	wmb();
@@ -14702,8 +14716,8 @@ bxe_update_rx_prod(struct bxe_softc *sc,
 	}
 
 	DBPRINT(sc, BXE_EXTREME_RECV, "%s(%d): Wrote fp[%02d] bd_prod = 0x%04X, "
-	    "rx_cq_prod = 0x%04X, sge_prod = 0x%04X\n", __FUNCTION__, curcpu,
-	    fp->index, bd_prod, rx_cq_prod, sge_prod);
+	    "cqe_prod = 0x%04X, sge_prod = 0x%04X\n", __FUNCTION__, curcpu,
+	    fp->index, bd_prod, cqe_prod, sge_prod);
 }
 
 /*
@@ -14721,10 +14735,7 @@ bxe_rxeof(struct bxe_fastpath *fp)
 	uint16_t rx_bd_prod, rx_bd_prod_idx;
 	uint16_t rx_cq_cons, rx_cq_cons_idx;
 	uint16_t rx_cq_prod, rx_cq_cons_sb;
-
-#ifdef BXE_DEBUG
 	unsigned long rx_pkts = 0;
-#endif
 
 	sc = fp->sc;
 	ifp = sc->bxe_ifp;
@@ -15021,7 +15032,7 @@ bxe_rxeof(struct bxe_fastpath *fp)
 bxe_rxeof_next_rx:
 		rx_bd_prod = NEXT_RX_BD(rx_bd_prod);
 		rx_bd_cons = NEXT_RX_BD(rx_bd_cons);
-		DBRUN(rx_pkts++);
+		rx_pkts++;
 
 bxe_rxeof_next_cqe:
 		rx_cq_prod = NEXT_RCQ_IDX(rx_cq_prod);
@@ -15051,8 +15062,8 @@ bxe_rxeof_next_cqe:
 	bus_space_barrier(sc->bxe_btag, sc->bxe_bhandle, 0, 0,
 	    BUS_SPACE_BARRIER_READ);
 
-	DBRUN(fp->rx_pkts += rx_pkts);
-	DBRUN(fp->rx_calls++);
+	fp->rx_pkts += rx_pkts;
+	fp->rx_calls++;
 	DBEXIT(BXE_EXTREME_RECV);
 }
 
@@ -15713,6 +15724,16 @@ bxe_add_sysctls(struct bxe_softc *sc)
 	    CTLFLAG_RD, &estats->driver_xoff,
 	    0, "Driver transmit queue full count");
 
+	SYSCTL_ADD_ULONG(ctx, children, OID_AUTO,
+	    "tx_start_called_with_link_down",
+	    CTLFLAG_RD, &sc->tx_start_called_with_link_down,
+	    "TX start routine called while link down count");
+
+	SYSCTL_ADD_ULONG(ctx, children, OID_AUTO,
+	    "tx_start_called_with_queue_full",
+	    CTLFLAG_RD, &sc->tx_start_called_with_queue_full,
+	    "TX start routine called with queue full count");
+
 	/* ToDo: Add more statistics here. */
 
 #ifdef BXE_DEBUG
@@ -15736,6 +15757,16 @@ bxe_add_sysctls(struct bxe_softc *sc)
 			queue_list = SYSCTL_CHILDREN(queue_node);
 
 			SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO,
+			    "rx_pkts",
+			    CTLFLAG_RD, &fp->rx_pkts,
+			    "Received packets");
+
+			SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO,
+			    "tx_pkts",
+			    CTLFLAG_RD, &fp->tx_pkts,
+			    "Transmitted packets");
+
+			SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO,
 			    "mbuf_alloc_failed",
 			    CTLFLAG_RD, &fp->mbuf_alloc_failed,
 			    "Mbuf allocation failure count");
@@ -15761,23 +15792,23 @@ bxe_add_sysctls(struct bxe_softc *sc)
 			    "Mbuf defrag success count");
 
 			SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO,
-			    "ip_csum_offload_frames",
-			    CTLFLAG_RD, &fp->ip_csum_offload_frames,
+			    "offload_frames_csum_ip",
+			    CTLFLAG_RD, &fp->offload_frames_csum_ip,
 			    "IP checksum offload frame count");
 
 			SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO,
-			    "tcp_csum_offload_frames",
-			    CTLFLAG_RD, &fp->tcp_csum_offload_frames,
+			    "offload_frames_csum_tcp",
+			    CTLFLAG_RD, &fp->offload_frames_csum_tcp,
 			    "TCP checksum offload frame count");
 
 			SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO,
-			    "udp_csum_offload_frames",
-			    CTLFLAG_RD, &fp->udp_csum_offload_frames,
+			    "offload_frames_csum_udp",
+			    CTLFLAG_RD, &fp->offload_frames_csum_udp,
 			    "UDP checksum offload frame count");
 
 			SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO,
-			    "tso_offload_frames",
-			    CTLFLAG_RD, &fp->tso_offload_frames,
+			    "offload_frames_tso",
+			    CTLFLAG_RD, &fp->offload_frames_tso,
 			    "TSO offload frame count");
 
 			SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO,
@@ -15797,23 +15828,23 @@ bxe_add_sysctls(struct bxe_softc *sc)
 			    "TX queue too full to add a TX frame count");
 
 			SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO,
-			    "std_window_violation",
-			    CTLFLAG_RD, &fp->std_window_violation,
+			    "window_violation_std",
+			    CTLFLAG_RD, &fp->window_violation_std,
 			    "Standard frame TX BD window violation count");
 
 			SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO,
-			    "tso_window_violation",
-			    CTLFLAG_RD, &fp->tso_window_violation,
+			    "window_violation_tso",
+			    CTLFLAG_RD, &fp->window_violation_tso,
 			    "TSO frame TX BD window violation count");
 
 			SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO,
-			    "unsupported_tso_ipv6_request",
-			    CTLFLAG_RD, &fp->unsupported_tso_ipv6_request,
+			    "unsupported_tso_request_ipv6",
+			    CTLFLAG_RD, &fp->unsupported_tso_request_ipv6,
 			    "TSO frames with unsupported IPv6 protocol count");
 
 			SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO,
-			    "unsupported_tso_protocol_request",
-			    CTLFLAG_RD, &fp->unsupported_tso_protocol_request,
+			    "unsupported_tso_request_not_tcp",
+			    CTLFLAG_RD, &fp->unsupported_tso_request_not_tcp,
 			    "TSO frames with unsupported protocol count");
 
 			SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO,

Modified: head/sys/dev/bxe/if_bxe.h
==============================================================================
--- head/sys/dev/bxe/if_bxe.h	Thu Apr  7 16:06:39 2011	(r220426)
+++ head/sys/dev/bxe/if_bxe.h	Thu Apr  7 20:15:36 2011	(r220427)
@@ -290,7 +290,9 @@ struct bxe_type {
 #define	RX_SGE_MASK_LEN_MASK	(RX_SGE_MASK_LEN - 1)
 #define	NEXT_SGE_MASK_ELEM(el)	(((el) + 1) & RX_SGE_MASK_LEN_MASK)
 
-/* Transmit Buffer Descriptor (tx_bd) definitions. */
+/*
+ * Transmit Buffer Descriptor (tx_bd) definitions*
+ */
 
 /* ToDo: Tune this value based on multi-queue/RSS enable/disable. */
 #define	NUM_TX_PAGES		2
@@ -308,7 +310,9 @@ struct bxe_type {
 #define	TX_PAGE(x)		(((x) & ~USABLE_TX_BD_PER_PAGE) >> 8)
 #define	TX_IDX(x)		((x) & USABLE_TX_BD_PER_PAGE)
 
-/* Receive Buffer Descriptor (rx_bd) definitions. */
+/*
+ * Receive Buffer Descriptor (rx_bd) definitions*
+ */
 #define	NUM_RX_PAGES		2
 
 /* 512 (0x200) of 8 byte bds in 4096 byte page. */
@@ -337,14 +341,15 @@ struct bxe_type {
 #define	RX_PAGE(x)		(((x) & ~RX_DESC_MASK) >> 9)
 #define	RX_IDX(x)		((x) & RX_DESC_MASK)
 
-/* Receive Completion Queue definitions. */
+/*
+ * Receive Completion Queue definitions*
+ */
 
 /* CQEs (32 bytes) are 4 times larger than rx_bd's (8 bytes). */
 #define	NUM_RCQ_PAGES		(NUM_RX_PAGES * 4)
 
 /* 128 (0x80) */
-#define	TOTAL_RCQ_ENTRIES_PER_PAGE					\
-	(BCM_PAGE_SIZE / sizeof(union eth_rx_cqe))
+#define	TOTAL_RCQ_ENTRIES_PER_PAGE (BCM_PAGE_SIZE / sizeof(union eth_rx_cqe))
 
 /* 127 (0x7f)for the next page RCQ bd */
 #define	USABLE_RCQ_ENTRIES_PER_PAGE	(TOTAL_RCQ_ENTRIES_PER_PAGE - 1)
@@ -1027,7 +1032,7 @@ struct bxe_fastpath {
 	uint16_t		rx_cq_cons;
 
 	/* Pointer to the receive consumer index in the status block. */
-	uint16_t		*rx_cons_sb;
+	uint16_t		*rx_cq_cons_sb;
 
 	/*
 	 * Pointer to the receive buffer descriptor consumer in the
@@ -1086,11 +1091,7 @@ struct bxe_fastpath {
 	unsigned long		rx_pkts;
 	unsigned long		tx_pkts;
 	unsigned long		tpa_pkts;
-
-	/* Receive interrupt counter. */
 	unsigned long		rx_calls;
-
-	/* Memory buffer allocation failure counter. */
 	unsigned long		mbuf_alloc_failed;
 	unsigned long		mbuf_defrag_attempts;
 	unsigned long		mbuf_defrag_failures;
@@ -1105,18 +1106,18 @@ struct bxe_fastpath {
 	uint64_t		tpa_queue_used;
 
 	unsigned long		null_cqe_flags;
-	unsigned long		ip_csum_offload_frames;
-	unsigned long		tcp_csum_offload_frames;
-	unsigned long		udp_csum_offload_frames;
-	unsigned long		tso_offload_frames;
+	unsigned long		offload_frames_csum_ip;
+	unsigned long		offload_frames_csum_tcp;
+	unsigned long		offload_frames_csum_udp;
+	unsigned long		offload_frames_tso;
 	unsigned long		tx_encap_failures;
 	unsigned long		tx_start_called_on_empty_queue;
 	unsigned long		tx_queue_too_full;
 	unsigned long		tx_dma_mapping_failure;
-	unsigned long		tso_window_violation;
-	unsigned long		std_window_violation;
-	unsigned long		unsupported_tso_ipv6_request;
-	unsigned long		unsupported_tso_protocol_request;
+	unsigned long		window_violation_tso;
+	unsigned long		window_violation_std;
+	unsigned long		unsupported_tso_request_ipv6;
+	unsigned long		unsupported_tso_request_not_tcp;
 	unsigned long		tpa_mbuf_alloc_failed;
 	unsigned long		tx_chain_lost_mbuf;
 
@@ -1505,10 +1506,8 @@ struct bxe_softc {
 	uint32_t		*grcdump_buffer;
 #endif
 
-#ifdef EVST_STOP_ON_ERROR
-	uint32_t		next_free;
-	uint32_t		last_alloc;
-#endif
+	unsigned long 		tx_start_called_with_link_down;
+	unsigned long 		tx_start_called_with_queue_full;
 }; /* end of struct bxe_softc */
 
 #define	MDIO_AN_CL73_OR_37_COMPLETE					\

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 21:00:46 2011
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 B4FC1106564A;
	Thu,  7 Apr 2011 21:00:46 +0000 (UTC)
	(envelope-from yanegomi@gmail.com)
Received: from mail-pw0-f54.google.com (mail-pw0-f54.google.com
	[209.85.160.54])
	by mx1.freebsd.org (Postfix) with ESMTP id 6FFD68FC1B;
	Thu,  7 Apr 2011 21:00:46 +0000 (UTC)
Received: by pwj8 with SMTP id 8so1326553pwj.13
	for ; Thu, 07 Apr 2011 14:00:45 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:in-reply-to:references:date
	:message-id:subject:from:to:cc:content-type
	:content-transfer-encoding;
	bh=IoCYbJOoKZDYv4zO98pYiSwitHmCn6bsFHMTVYiyKmQ=;
	b=JsejeBOommhD5MHKm/wppCs7ycB4qvfLmUoIIHYa4VzmZUr+StxlCOkGgw8BJANtl2
	5oAC7WEg2+akBrOKTDjqc9ZKL2vcgvTsiwjwps+5VWdwEJRBiVgbaD1dTVPdp9Rvdw+s
	OCpOKmMOaWmM/hdBDEtYNrvVKvhOajfqM0gLo=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type:content-transfer-encoding;
	b=X55at5iAkDGrMUKzYLdwBxhsfYJ3sxb3aEc+ql0emM8VpW3HQhvKdb71VokwUA4GZ+
	KpBThdH7kPTCFeBBSd4plWxUNXLxZnskZX/gwye9cMk8FGSmrcsjJKm1n0iY2WquMvue
	cwhSWAODo9uzqHHktpDBtzz+vncSSr2twAg/g=
MIME-Version: 1.0
Received: by 10.142.248.21 with SMTP id v21mr1007890wfh.56.1302210045754; Thu,
	07 Apr 2011 14:00:45 -0700 (PDT)
Received: by 10.68.42.3 with HTTP; Thu, 7 Apr 2011 14:00:45 -0700 (PDT)
In-Reply-To: <20110407190318.GA97508@freebsd.org>
References: <201104070817.p378HrHc033571@svn.freebsd.org>
	<20110407190318.GA97508@freebsd.org>
Date: Thu, 7 Apr 2011 14:00:45 -0700
Message-ID: 
From: Garrett Cooper 
To: Alexander Best 
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Cc: svn-src-head@freebsd.org, Alexander Motin ,
	src-committers@freebsd.org, svn-src-all@freebsd.org
Subject: Re: svn commit: r220412 - in head: share/man/man4 sys/cam/ata
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, 07 Apr 2011 21:00:46 -0000

On Thu, Apr 7, 2011 at 12:03 PM, Alexander Best  wrote=
:
> On Thu Apr =A07 11, Alexander Motin wrote:
>> Author: mav
>> Date: Thu Apr =A07 08:17:53 2011
>> New Revision: 220412
>> URL: http://svn.freebsd.org/changeset/base/220412
>>
>> Log:
>> =A0 Make ada(4) driver to control device write cache, same as ata(4) doe=
s.
>> =A0 Add kern.cam.ada.write_cache sysctl/tunable to control it alike hw.a=
ta.wc.
>
> how hard would it be to support per device sysctls/tunables? i'd really l=
ike to
> do:
>
> kern.cam.ada.0.write_cache=3D0 (root fs)
> kern.cam.ada.1.write_cache=3D1 (/usr, /var, etc.)

Does it really make sense to turn on write caching for one drive and
not the other(s)?
Thanks,
-Garrett

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 21:20:26 2011
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 6CCAE1065680;
	Thu,  7 Apr 2011 21:20:26 +0000 (UTC) (envelope-from jfv@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 5DA388FC16;
	Thu,  7 Apr 2011 21:20:26 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p37LKQg6052229;
	Thu, 7 Apr 2011 21:20:26 GMT (envelope-from jfv@svn.freebsd.org)
Received: (from jfv@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p37LKQfi052227;
	Thu, 7 Apr 2011 21:20:26 GMT (envelope-from jfv@svn.freebsd.org)
Message-Id: <201104072120.p37LKQfi052227@svn.freebsd.org>
From: Jack F Vogel 
Date: Thu, 7 Apr 2011 21:20: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: r220428 - 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, 07 Apr 2011 21:20:26 -0000

Author: jfv
Date: Thu Apr  7 21:20:26 2011
New Revision: 220428
URL: http://svn.freebsd.org/changeset/base/220428

Log:
  Port of the LRO fix from mxge driver to the generic
  LRO code. Thanks to Andrew Gallatin for the change.
  
  MFC after:  7 days

Modified:
  head/sys/netinet/tcp_lro.c

Modified: head/sys/netinet/tcp_lro.c
==============================================================================
--- head/sys/netinet/tcp_lro.c	Thu Apr  7 20:15:36 2011	(r220427)
+++ head/sys/netinet/tcp_lro.c	Thu Apr  7 21:20:26 2011	(r220428)
@@ -279,8 +279,10 @@ tcp_lro_rx(struct lro_ctrl *cntl, struct
 		    lro->dest_ip == ip->ip_dst.s_addr) {
 			/* Try to append it */
 
-			if (__predict_false(seq != lro->next_seq)) {
-				/* out of order packet */
+			if (__predict_false(seq != lro->next_seq ||
+				    (tcp_data_len == 0 &&
+				    lro->ack_seq == tcp->th_ack))) {
+				/* out of order packet or dup ack */
 				SLIST_REMOVE(&cntl->lro_active, lro,
 					     lro_entry, next);
 				tcp_lro_flush(cntl, lro);

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 21:25:40 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: by hub.freebsd.org (Postfix, from userid 1233)
	id 6F7F31065673; Thu,  7 Apr 2011 21:25:40 +0000 (UTC)
Date: Thu, 7 Apr 2011 21:25:40 +0000
From: Alexander Best 
To: Garrett Cooper 
Message-ID: <20110407212540.GB17091@freebsd.org>
References: <201104070817.p378HrHc033571@svn.freebsd.org>
	<20110407190318.GA97508@freebsd.org>
	
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: 
Cc: svn-src-head@freebsd.org, Alexander Motin ,
	src-committers@freebsd.org, svn-src-all@freebsd.org
Subject: Re: svn commit: r220412 - in head: share/man/man4 sys/cam/ata
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, 07 Apr 2011 21:25:40 -0000

On Thu Apr  7 11, Garrett Cooper wrote:
> On Thu, Apr 7, 2011 at 12:03 PM, Alexander Best  wrote:
> > On Thu Apr  7 11, Alexander Motin wrote:
> >> Author: mav
> >> Date: Thu Apr  7 08:17:53 2011
> >> New Revision: 220412
> >> URL: http://svn.freebsd.org/changeset/base/220412
> >>
> >> Log:
> >>   Make ada(4) driver to control device write cache, same as ata(4) does.
> >>   Add kern.cam.ada.write_cache sysctl/tunable to control it alike hw.ata.wc.
> >
> > how hard would it be to support per device sysctls/tunables? i'd really like to
> > do:
> >
> > kern.cam.ada.0.write_cache=0 (root fs)
> > kern.cam.ada.1.write_cache=1 (/usr, /var, etc.)
> 
> Does it really make sense to turn on write caching for one drive and
> not the other(s)?

i think so. for "/" i want maximum safebelts. so i'd like to disable the write
cache and mount it with the "sync" option. for /usr/ and all the other mount
points i'd like maximum speed with write caching enabled and mounted with the
"noasync" and "noatime" options.

cheers.
alex

> Thanks,
> -Garrett

-- 
a13x

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 21:29:34 2011
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 BCF4E106564A;
	Thu,  7 Apr 2011 21:29:34 +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 92C138FC0A;
	Thu,  7 Apr 2011 21:29:34 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p37LTYJk052438;
	Thu, 7 Apr 2011 21:29:34 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p37LTYSK052436;
	Thu, 7 Apr 2011 21:29:34 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104072129.p37LTYSK052436@svn.freebsd.org>
From: Jung-uk Kim 
Date: Thu, 7 Apr 2011 21:29: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: r220429 - 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, 07 Apr 2011 21:29:34 -0000

Author: jkim
Date: Thu Apr  7 21:29:34 2011
New Revision: 220429
URL: http://svn.freebsd.org/changeset/base/220429

Log:
  Remove stale checks for RDTSC support.  amd64 must have TSC support anyway.

Modified:
  head/sys/amd64/amd64/prof_machdep.c

Modified: head/sys/amd64/amd64/prof_machdep.c
==============================================================================
--- head/sys/amd64/amd64/prof_machdep.c	Thu Apr  7 21:20:26 2011	(r220428)
+++ head/sys/amd64/amd64/prof_machdep.c	Thu Apr  7 21:29:34 2011	(r220429)
@@ -63,9 +63,7 @@ static u_int	cputime_clock_pmc_conf = I5
 static int	cputime_clock_pmc_init;
 static struct gmonparam saved_gmp;
 #endif
-#if defined(I586_CPU) || defined(I686_CPU)
 static int	cputime_prof_active;
-#endif
 #endif /* GUPROF */
 
 #ifdef __GNUCLIKE_ASM
@@ -200,14 +198,12 @@ cputime()
 {
 	u_int count;
 	int delta;
-#if (defined(I586_CPU) || defined(I686_CPU)) && !defined(SMP) && \
-    defined(PERFMON) && defined(I586_PMC_GUPROF)
+#if defined(PERFMON) && defined(I586_PMC_GUPROF) && !defined(SMP)
 	u_quad_t event_count;
 #endif
 	u_char high, low;
 	static u_int prev_count;
 
-#if defined(I586_CPU) || defined(I686_CPU)
 	if (cputime_clock == CPUTIME_CLOCK_TSC) {
 		/*
 		 * Scale the TSC a little to make cputime()'s frequency
@@ -236,7 +232,6 @@ cputime()
 		return (delta);
 	}
 #endif /* PERFMON && I586_PMC_GUPROF && !SMP */
-#endif /* I586_CPU || I686_CPU */
 
 	/*
 	 * Read the current value of the 8254 timer counter 0.
@@ -318,13 +313,10 @@ startguprof(gp)
 {
 	if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED) {
 		cputime_clock = CPUTIME_CLOCK_I8254;
-#if defined(I586_CPU) || defined(I686_CPU)
 		if (tsc_freq != 0 && mp_ncpus == 1)
 			cputime_clock = CPUTIME_CLOCK_TSC;
-#endif
 	}
 	gp->profrate = i8254_freq << CPUTIME_CLOCK_I8254_SHIFT;
-#if defined(I586_CPU) || defined(I686_CPU)
 	if (cputime_clock == CPUTIME_CLOCK_TSC) {
 		gp->profrate = tsc_freq >> 1;
 		cputime_prof_active = 1;
@@ -355,7 +347,6 @@ startguprof(gp)
 		}
 	}
 #endif /* PERFMON && I586_PMC_GUPROF */
-#endif /* I586_CPU || I686_CPU */
 	cputime_bias = 0;
 	cputime();
 }
@@ -371,13 +362,10 @@ stopguprof(gp)
 		cputime_clock_pmc_init = FALSE;
 	}
 #endif
-#if defined(I586_CPU) || defined(I686_CPU)
 	if (cputime_clock == CPUTIME_CLOCK_TSC)
 		cputime_prof_active = 0;
-#endif
 }
 
-#if defined(I586_CPU) || defined(I686_CPU)
 /* If the cpu frequency changed while profiling, report a warning. */
 static void
 tsc_freq_changed(void *arg, const struct cf_level *level, int status)
@@ -395,6 +383,5 @@ tsc_freq_changed(void *arg, const struct
 
 EVENTHANDLER_DEFINE(cpufreq_post_change, tsc_freq_changed, NULL,
     EVENTHANDLER_PRI_ANY);
-#endif /* I586_CPU || I686_CPU */
 
 #endif /* GUPROF */

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 21:31:07 2011
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 BC14E106564A;
	Thu,  7 Apr 2011 21:31:07 +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 73EA98FC12;
	Thu,  7 Apr 2011 21:31:07 +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 p37LNVtJ020745
	(version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO);
	Thu, 7 Apr 2011 15:23:32 -0600 (MDT) (envelope-from imp@bsdimp.com)
Mime-Version: 1.0 (Apple Message framework v1082)
Content-Type: text/plain; charset=us-ascii
From: Warner Losh 
In-Reply-To: 
Date: Thu, 7 Apr 2011 15:23:31 -0600
Content-Transfer-Encoding: quoted-printable
Message-Id: <17BA8DDF-54C9-4E1A-B7DC-A8935B42EC3E@bsdimp.com>
References: <201104070817.p378HrHc033571@svn.freebsd.org>
	<20110407190318.GA97508@freebsd.org>
	
To: Garrett Cooper 
X-Mailer: Apple Mail (2.1082)
X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1
	(harmony.bsdimp.com [10.0.0.6]);
	Thu, 07 Apr 2011 15:23:32 -0600 (MDT)
Cc: svn-src-head@freebsd.org, Alexander Best ,
	Alexander Motin , src-committers@freebsd.org,
	svn-src-all@freebsd.org
Subject: Re: svn commit: r220412 - in head: share/man/man4 sys/cam/ata
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, 07 Apr 2011 21:31:07 -0000


On Apr 7, 2011, at 3:00 PM, Garrett Cooper wrote:

> On Thu, Apr 7, 2011 at 12:03 PM, Alexander Best  =
wrote:
>> On Thu Apr  7 11, Alexander Motin wrote:
>>> Author: mav
>>> Date: Thu Apr  7 08:17:53 2011
>>> New Revision: 220412
>>> URL: http://svn.freebsd.org/changeset/base/220412
>>>=20
>>> Log:
>>>   Make ada(4) driver to control device write cache, same as ata(4) =
does.
>>>   Add kern.cam.ada.write_cache sysctl/tunable to control it alike =
hw.ata.wc.
>>=20
>> how hard would it be to support per device sysctls/tunables? i'd =
really like to
>> do:
>>=20
>> kern.cam.ada.0.write_cache=3D0 (root fs)
>> kern.cam.ada.1.write_cache=3D1 (/usr, /var, etc.)
>=20
> Does it really make sense to turn on write caching for one drive and
> not the other(s)?

Think about /usr/obj or /tmp and ask that question again.  Or any =
filesystem that's mounted that you don't really care about the contents =
of across a power cycle.  If you have to recreate it, that's OK.   In =
those cases, you may want the speed increase over safety that =
write_cache gives you.  Or maybe you have a drive that's doing write =
caching correctly and one that doesn't.

Warner


From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 21:32:25 2011
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 6EC35106564A;
	Thu,  7 Apr 2011 21:32: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 44E698FC14;
	Thu,  7 Apr 2011 21:32:25 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p37LWP6w052538;
	Thu, 7 Apr 2011 21:32:25 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p37LWPuu052536;
	Thu, 7 Apr 2011 21:32:25 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201104072132.p37LWPuu052536@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 7 Apr 2011 21:32: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: r220430 - 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, 07 Apr 2011 21:32:25 -0000

Author: jhb
Date: Thu Apr  7 21:32:25 2011
New Revision: 220430
URL: http://svn.freebsd.org/changeset/base/220430

Log:
  If a system call does not request a full interrupt return, use a fast
  path via the sysretq instruction to return from the system call.  This was
  removed in 190620 and not quite fully restored in 195486.  This resolves
  most of the performance regression in system call microbenchmarks between
  7 and 8 on amd64.
  
  Reviewed by:	kib
  MFC after:	1 week

Modified:
  head/sys/amd64/amd64/exception.S

Modified: head/sys/amd64/amd64/exception.S
==============================================================================
--- head/sys/amd64/amd64/exception.S	Thu Apr  7 21:29:34 2011	(r220429)
+++ head/sys/amd64/amd64/exception.S	Thu Apr  7 21:32:25 2011	(r220430)
@@ -339,6 +339,9 @@ IDTVEC(prot)
  * and the new privilige level.  We are still running on the old user stack
  * pointer.  We have to juggle a few things around to find our stack etc.
  * swapgs gives us access to our PCPU space only.
+ *
+ * We do not support invoking this from a custom %cs or %ss (e.g. using
+ * entries from an LDT).
  */
 IDTVEC(fast_syscall)
 	swapgs
@@ -380,6 +383,36 @@ IDTVEC(fast_syscall)
 	movq	%rsp,%rdi
 	call	syscall
 	movq	PCPU(CURPCB),%rax
+	testq	$PCB_FULL_IRET,PCB_FLAGS(%rax)
+	jne	3f
+1:	/* Check for and handle AST's on return to userland. */
+	cli
+	movq	PCPU(CURTHREAD),%rax
+	testl	$TDF_ASTPENDING | TDF_NEEDRESCHED,TD_FLAGS(%rax)
+	je	2f
+	sti
+	movq	%rsp, %rdi
+	call	ast
+	jmp	1b
+2:	/* Restore preserved registers. */
+	MEXITCOUNT
+	movq	TF_RDI(%rsp),%rdi	/* bonus; preserve arg 1 */
+	movq	TF_RSI(%rsp),%rsi	/* bonus: preserve arg 2 */
+	movq	TF_RDX(%rsp),%rdx	/* return value 2 */
+	movq	TF_RAX(%rsp),%rax	/* return value 1 */
+	movq	TF_RBX(%rsp),%rbx	/* C preserved */
+	movq	TF_RBP(%rsp),%rbp	/* C preserved */
+	movq	TF_R12(%rsp),%r12	/* C preserved */
+	movq	TF_R13(%rsp),%r13	/* C preserved */
+	movq	TF_R14(%rsp),%r14	/* C preserved */
+	movq	TF_R15(%rsp),%r15	/* C preserved */
+	movq	TF_RFLAGS(%rsp),%r11	/* original %rflags */
+	movq	TF_RIP(%rsp),%rcx	/* original %rip */
+	movq	TF_RSP(%rsp),%r9	/* user stack pointer */
+	movq	%r9,%rsp		/* original %rsp */
+	swapgs
+	sysretq
+3:	/* Requested full context restore, use doreti for that. */
 	MEXITCOUNT
 	jmp	doreti
 

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 21:52:09 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28])
	by hub.freebsd.org (Postfix) with ESMTP id 4567D106566B;
	Thu,  7 Apr 2011 21:52:08 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
From: Jung-uk Kim 
To: src-committers@FreeBSD.org
Date: Thu, 7 Apr 2011 17:51:58 -0400
User-Agent: KMail/1.6.2
References: <201104072132.p37LWPuu052536@svn.freebsd.org>
In-Reply-To: <201104072132.p37LWPuu052536@svn.freebsd.org>
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Message-Id: <201104071752.00349.jkim@FreeBSD.org>
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	John Baldwin 
Subject: Re: svn commit: r220430 - 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, 07 Apr 2011 21:52:09 -0000

On Thursday 07 April 2011 05:32 pm, John Baldwin wrote:
> Author: jhb
> Date: Thu Apr  7 21:32:25 2011
> New Revision: 220430
> URL: http://svn.freebsd.org/changeset/base/220430
>
> Log:
>   If a system call does not request a full interrupt return, use a
> fast path via the sysretq instruction to return from the system
> call.  This was removed in 190620 and not quite fully restored in
> 195486.  This resolves most of the performance regression in system
> call microbenchmarks between 7 and 8 on amd64.
>
>   Reviewed by:	kib
>   MFC after:	1 week
>
> Modified:
>   head/sys/amd64/amd64/exception.S
>
> Modified: head/sys/amd64/amd64/exception.S
> ===================================================================
>=========== --- head/sys/amd64/amd64/exception.S	Thu Apr  7 21:29:34
> 2011	(r220429) +++ head/sys/amd64/amd64/exception.S	Thu Apr  7
> 21:32:25 2011	(r220430) @@ -339,6 +339,9 @@ IDTVEC(prot)
>   * and the new privilige level.  We are still running on the old
> user stack * pointer.  We have to juggle a few things around to
> find our stack etc. * swapgs gives us access to our PCPU space
> only.
> + *
> + * We do not support invoking this from a custom %cs or %ss (e.g.
> using + * entries from an LDT).
>   */
>  IDTVEC(fast_syscall)
>  	swapgs
> @@ -380,6 +383,36 @@ IDTVEC(fast_syscall)
>  	movq	%rsp,%rdi
>  	call	syscall
>  	movq	PCPU(CURPCB),%rax
> +	testq	$PCB_FULL_IRET,PCB_FLAGS(%rax)

FYI, pcb_flags is u_int now, i.e., we need testl here.

Jung-uk Kim

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 21:58:30 2011
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 58A3910656D8;
	Thu,  7 Apr 2011 21:58:30 +0000 (UTC) (envelope-from uqs@FreeBSD.ORG)
Received: from acme.spoerlein.net (acme.spoerlein.net
	[IPv6:2a01:4f8:131:23c2::1])
	by mx1.freebsd.org (Postfix) with ESMTP id E1E6C8FC1C;
	Thu,  7 Apr 2011 21:58:29 +0000 (UTC)
Received: from localhost (acme.spoerlein.net [IPv6:2a01:4f8:131:23c2::1])
	by acme.spoerlein.net (8.14.4/8.14.4) with ESMTP id p37LwMrr034912
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Thu, 7 Apr 2011 23:58:22 +0200 (CEST) (envelope-from uqs@FreeBSD.ORG)
Date: Thu, 7 Apr 2011 23:58:21 +0200
From: Ulrich Spoerlein 
To: Alexander Best 
Message-ID: <20110407215821.GW85668@acme.spoerlein.net>
Mail-Followup-To: Ulrich Spoerlein ,
	Alexander Best , Warner Losh ,
	Juli Mallett , svn-src-head@FreeBSD.ORG,
	svn-src-all@FreeBSD.ORG, src-committers@FreeBSD.ORG
References: <201104062008.p36K8NR0015687@svn.freebsd.org>
	<20110406210416.GA62173@freebsd.org>
	
	<20110406214133.GA66860@freebsd.org>
	
	<20110407073114.GA15050@freebsd.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20110407073114.GA15050@freebsd.org>
User-Agent: Mutt/1.5.21 (2010-09-15)
Cc: Juli Mallett , svn-src-head@FreeBSD.ORG,
	svn-src-all@FreeBSD.ORG, src-committers@FreeBSD.ORG,
	Warner Losh 
Subject: Re: svn commit: r220401 - in head: . share/mk tools/build/mk
 tools/build/options
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, 07 Apr 2011 21:58:30 -0000

On Thu, 07.04.2011 at 07:31:14 +0000, Alexander Best wrote:
> On Wed Apr  6 11, Warner Losh wrote:
> > On Apr 6, 2011, at 3:41 PM, Alexander Best wrote:
> > > On Wed Apr  6 11, Juli Mallett wrote:
> > >> On Wed, Apr 6, 2011 at 14:04, Alexander Best  wrote:
> > >>> On Wed Apr  6 11, Ulrich Spoerlein wrote:
> > >>>> Author: uqs
> > >>>> Date: Wed Apr  6 20:08:23 2011
> > >>>> New Revision: 220401
> > >>>> URL: http://svn.freebsd.org/changeset/base/220401
> > >>>> 
> > >>>> Log:
> > >>>>   Complete WITHOUT_CXX support. It implies WITHOUT_GROFF and
> > >>>>   WITHOUT_CLANG.
> > >>> 
> > >>> is there no way to build clang/llvm without CXX support?
> > >> 
> > >> Clang and LLVM are written in C++.  Even if their support for
> > >> compiling C++ could be disabled, you'd still need a C++ cross-compiler
> > >> to build them, which ought to be disabled by WITHOUT_CXX, right?
> > > 
> > > good point. is it even possible to build a world *with* C++ support, if the
> > > installed world *doesn't* have C++ support? is the C++ part of gcc written in
> > > C? if that's the case it's possible.
> > 
> > Yes.  We don't need c++ to bootstrap g++ or anything else in the base system.  Once we build the compilers, we can build the c++ that's in the tree.

While technically true, that c++ (the binary) is not needed, our g++
requires gperf(1) to build, which is written in C++. So we need gperf +
C compiler to bootstrap. How the gperf binary comes into existence on
the host system is someone else's problem :)

> however that means that FreeBSD can never get rid of gcc. so clang can never
> become the main and only base compiler.

Not quite true, right now the host system (whatever that is) needs a
working C compiler plus a whole lot of other stuff. With clang the host
system needs a C++ compiler + lots of other stuff. I haven't tested any
other compilers, but gcc and/or clang might also build with the Sun
compilers, for example.

Cheers,
Uli

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 22:02:24 2011
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 4EC9A106566B;
	Thu,  7 Apr 2011 22:02:24 +0000 (UTC)
	(envelope-from yanegomi@gmail.com)
Received: from mail-pv0-f182.google.com (mail-pv0-f182.google.com
	[74.125.83.182])
	by mx1.freebsd.org (Postfix) with ESMTP id 054068FC0C;
	Thu,  7 Apr 2011 22:02:23 +0000 (UTC)
Received: by pvg11 with SMTP id 11so1327354pvg.13
	for ; Thu, 07 Apr 2011 15:02:23 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:in-reply-to:references:date
	:message-id:subject:from:to:cc:content-type
	:content-transfer-encoding;
	bh=N/1P5bMxprBM8FMJ/Kblqtnm7mAutmEfOd5q2pqyJkw=;
	b=lK2IRedSRpwBK4vaYJqyRplHrfZkEaMBY/vZLfGvBa2MvrUc+KBakct4DdU0Bwwse+
	RI463p4+J+2Ra3kXac/cE43WQhBRTR8VF5rsRheme+39n/R4QADOWJ9UKcHfej7csEHy
	YeHaqYGlh8rX9Z5Wjxow5ZxanVuPWFA18iy5w=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type:content-transfer-encoding;
	b=IO0tOH7ODrx4GwkpjugNGyZE3yVLlCbKFIJbtjcJChc3CbVlbZyv3HNT2lJPXN4OdT
	/wcb0lDzWNJcugIZxZnedLCYJ103QuVuTt9JjSDASncim/lAtTpXg9l/1leU3E1tyH6V
	a0oiE4LyV9cxvFS9vOcTkKPrIav64nV+pEblU=
MIME-Version: 1.0
Received: by 10.142.237.20 with SMTP id k20mr1103098wfh.170.1302213743216;
	Thu, 07 Apr 2011 15:02:23 -0700 (PDT)
Received: by 10.68.42.3 with HTTP; Thu, 7 Apr 2011 15:02:23 -0700 (PDT)
In-Reply-To: <17BA8DDF-54C9-4E1A-B7DC-A8935B42EC3E@bsdimp.com>
References: <201104070817.p378HrHc033571@svn.freebsd.org>
	<20110407190318.GA97508@freebsd.org>
	
	<17BA8DDF-54C9-4E1A-B7DC-A8935B42EC3E@bsdimp.com>
Date: Thu, 7 Apr 2011 15:02:23 -0700
Message-ID: 
From: Garrett Cooper 
To: Warner Losh 
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Cc: svn-src-head@freebsd.org, Alexander Best ,
	Alexander Motin , src-committers@freebsd.org,
	svn-src-all@freebsd.org
Subject: Re: svn commit: r220412 - in head: share/man/man4 sys/cam/ata
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, 07 Apr 2011 22:02:24 -0000

On Thu, Apr 7, 2011 at 2:23 PM, Warner Losh  wrote:
>
> On Apr 7, 2011, at 3:00 PM, Garrett Cooper wrote:
>
>> On Thu, Apr 7, 2011 at 12:03 PM, Alexander Best  wr=
ote:
>>> On Thu Apr =A07 11, Alexander Motin wrote:
>>>> Author: mav
>>>> Date: Thu Apr =A07 08:17:53 2011
>>>> New Revision: 220412
>>>> URL: http://svn.freebsd.org/changeset/base/220412
>>>>
>>>> Log:
>>>> =A0 Make ada(4) driver to control device write cache, same as ata(4) d=
oes.
>>>> =A0 Add kern.cam.ada.write_cache sysctl/tunable to control it alike hw=
.ata.wc.
>>>
>>> how hard would it be to support per device sysctls/tunables? i'd really=
 like to
>>> do:
>>>
>>> kern.cam.ada.0.write_cache=3D0 (root fs)
>>> kern.cam.ada.1.write_cache=3D1 (/usr, /var, etc.)
>>
>> Does it really make sense to turn on write caching for one drive and
>> not the other(s)?
>
> Think about /usr/obj or /tmp and ask that question again. =A0Or any files=
ystem that's mounted that you don't really care about the contents of acros=
s a power cycle. =A0If you have to recreate it, that's OK. =A0 In those cas=
es, you may want the speed increase over safety that write_cache gives you.=
 =A0Or maybe you have a drive that's doing write caching correctly and one =
that doesn't.

    Alex, Warner: thanks for the practical example; I hadn't really
considered that :).
Cheers!
-Garrett

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 23:13:23 2011
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 34F021065670;
	Thu,  7 Apr 2011 23:13:23 +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 249288FC19;
	Thu,  7 Apr 2011 23:13:23 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p37NDNdX054674;
	Thu, 7 Apr 2011 23:13:23 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p37NDNuF054672;
	Thu, 7 Apr 2011 23:13:23 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201104072313.p37NDNuF054672@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 7 Apr 2011 23:13: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: r220431 - 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, 07 Apr 2011 23:13:23 -0000

Author: jhb
Date: Thu Apr  7 23:13:22 2011
New Revision: 220431
URL: http://svn.freebsd.org/changeset/base/220431

Log:
  pcb_flags is an int, so use testl rather than testq.
  
  Pointy hat to:	jhb
  Submitted by:	jkim
  MFC after:	1 week

Modified:
  head/sys/amd64/amd64/exception.S

Modified: head/sys/amd64/amd64/exception.S
==============================================================================
--- head/sys/amd64/amd64/exception.S	Thu Apr  7 21:32:25 2011	(r220430)
+++ head/sys/amd64/amd64/exception.S	Thu Apr  7 23:13:22 2011	(r220431)
@@ -383,7 +383,7 @@ IDTVEC(fast_syscall)
 	movq	%rsp,%rdi
 	call	syscall
 	movq	PCPU(CURPCB),%rax
-	testq	$PCB_FULL_IRET,PCB_FLAGS(%rax)
+	testl	$PCB_FULL_IRET,PCB_FLAGS(%rax)
 	jne	3f
 1:	/* Check for and handle AST's on return to userland. */
 	cli

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 23:14:33 2011
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 7E298106566C;
	Thu,  7 Apr 2011 23:14:33 +0000 (UTC) (envelope-from gjb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6DE878FC12;
	Thu,  7 Apr 2011 23:14:33 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p37NEXB3054732;
	Thu, 7 Apr 2011 23:14:33 GMT (envelope-from gjb@svn.freebsd.org)
Received: (from gjb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p37NEXLm054729;
	Thu, 7 Apr 2011 23:14:33 GMT (envelope-from gjb@svn.freebsd.org)
Message-Id: <201104072314.p37NEXLm054729@svn.freebsd.org>
From: Glen Barber 
Date: Thu, 7 Apr 2011 23:14: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: r220432 - 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: Thu, 07 Apr 2011 23:14:33 -0000

Author: gjb (doc committer)
Date: Thu Apr  7 23:14:33 2011
New Revision: 220432
URL: http://svn.freebsd.org/changeset/base/220432

Log:
  u3g.4:
  - remove self-reference in SEE ALSO section (originally was to s/XR/Xr)
  
  cxgbe.4:
  - remove blank line
  - add closing .El
  
  Reported by:	manlint
  MFC after:	3 days

Modified:
  head/share/man/man4/cxgbe.4
  head/share/man/man4/u3g.4

Modified: head/share/man/man4/cxgbe.4
==============================================================================
--- head/share/man/man4/cxgbe.4	Thu Apr  7 23:13:22 2011	(r220431)
+++ head/share/man/man4/cxgbe.4	Thu Apr  7 23:14:33 2011	(r220432)
@@ -60,7 +60,6 @@ The driver supprts Jumbo Frames, Transmi
 TCP segmentation offload (TSO), Large Receive Offload (LRO), VLAN
 tag insertion/extraction, VLAN checksum offload, VLAN TSO, and
 Receive Side Steering (RSS).
-
 For further hardware information and questions related to hardware
 requirements, see
 .Pa http://www.chelsio.com/ .
@@ -139,6 +138,7 @@ The default value is 1024.
 The size, in number of entries, of the descriptor ring used for an
 rx queue.
 The default value is 1024.
+.El
 .Sh SUPPORT
 For general information and support,
 go to the Chelsio support website at:

Modified: head/share/man/man4/u3g.4
==============================================================================
--- head/share/man/man4/u3g.4	Thu Apr  7 23:13:22 2011	(r220431)
+++ head/share/man/man4/u3g.4	Thu Apr  7 23:14:33 2011	(r220432)
@@ -93,7 +93,6 @@ and
 .Sh SEE ALSO
 .Xr tty 4 ,
 .Xr ucom 4 ,
-.XR u3g 4 ,
 .Xr usb 4 ,
 .Xr usb_quirk 4 ,
 .Xr usbconfig 5

From owner-svn-src-head@FreeBSD.ORG  Thu Apr  7 23:28:28 2011
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 806681065670;
	Thu,  7 Apr 2011 23:28:28 +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 6C54A8FC12;
	Thu,  7 Apr 2011 23:28:28 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p37NSSue055118;
	Thu, 7 Apr 2011 23:28:28 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p37NSSsO055101;
	Thu, 7 Apr 2011 23:28:28 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104072328.p37NSSsO055101@svn.freebsd.org>
From: Jung-uk Kim 
Date: Thu, 7 Apr 2011 23:28: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: r220433 - in head/sys: amd64/amd64
	cddl/dev/dtrace/amd64 cddl/dev/dtrace/i386 compat/linprocfs
	contrib/altq/altq dev/acpica i386/i386 i386/isa pc98/pc98
	x86/cpufreq x86/isa 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: Thu, 07 Apr 2011 23:28:28 -0000

Author: jkim
Date: Thu Apr  7 23:28:28 2011
New Revision: 220433
URL: http://svn.freebsd.org/changeset/base/220433

Log:
  Use atomic load & store for TSC frequency.  It may be overkill for amd64 but
  safer for i386 because it can be easily over 4 GHz now.  More worse, it can
  be easily changed by user with 'machdep.tsc_freq' tunable (directly) or
  cpufreq(4) (indirectly).  Note it is intentionally not used in performance
  critical paths to avoid performance regression (but we should, in theory).
  Alternatively, we may add "virtual TSC" with lower frequency if maximum
  frequency overflows 32 bits (and ignore possible incoherency as we do now).

Modified:
  head/sys/amd64/amd64/legacy.c
  head/sys/amd64/amd64/machdep.c
  head/sys/amd64/amd64/prof_machdep.c
  head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
  head/sys/cddl/dev/dtrace/i386/dtrace_subr.c
  head/sys/compat/linprocfs/linprocfs.c
  head/sys/contrib/altq/altq/altq_subr.c
  head/sys/dev/acpica/acpi_cpu.c
  head/sys/i386/i386/legacy.c
  head/sys/i386/i386/machdep.c
  head/sys/i386/i386/perfmon.c
  head/sys/i386/isa/prof_machdep.c
  head/sys/pc98/pc98/machdep.c
  head/sys/x86/cpufreq/est.c
  head/sys/x86/isa/clock.c
  head/sys/x86/x86/tsc.c

Modified: head/sys/amd64/amd64/legacy.c
==============================================================================
--- head/sys/amd64/amd64/legacy.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/amd64/amd64/legacy.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -321,7 +321,8 @@ cpu_read_ivar(device_t dev, device_t chi
 		break;
 	case CPU_IVAR_NOMINAL_MHZ:
 		if (tsc_is_invariant) {
-			*result = (uintptr_t)(tsc_freq / 1000000);
+			*result = (uintptr_t)(atomic_load_acq_64(&tsc_freq) /
+			    1000000);
 			break;
 		}
 		/* FALLTHROUGH */

Modified: head/sys/amd64/amd64/machdep.c
==============================================================================
--- head/sys/amd64/amd64/machdep.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/amd64/amd64/machdep.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -546,18 +546,19 @@ int
 cpu_est_clockrate(int cpu_id, uint64_t *rate)
 {
 	register_t reg;
-	uint64_t tsc1, tsc2;
+	uint64_t freq, tsc1, tsc2;
 
 	if (pcpu_find(cpu_id) == NULL || rate == NULL)
 		return (EINVAL);
+	freq = atomic_load_acq_64(&tsc_freq);
 
 	/* If TSC is P-state invariant, DELAY(9) based logic fails. */
-	if (tsc_is_invariant && tsc_freq != 0)
+	if (tsc_is_invariant && freq != 0)
 		return (EOPNOTSUPP);
 
 	/* If we're booting, trust the rate calibrated moments ago. */
-	if (cold && tsc_freq != 0) {
-		*rate = tsc_freq;
+	if (cold && freq != 0) {
+		*rate = freq;
 		return (0);
 	}
 
@@ -586,7 +587,7 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 #endif
 
 	tsc2 -= tsc1;
-	if (tsc_freq != 0) {
+	if (freq != 0) {
 		*rate = tsc2 * 1000;
 		return (0);
 	}

Modified: head/sys/amd64/amd64/prof_machdep.c
==============================================================================
--- head/sys/amd64/amd64/prof_machdep.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/amd64/amd64/prof_machdep.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -311,18 +311,22 @@ void
 startguprof(gp)
 	struct gmonparam *gp;
 {
+	uint64_t freq;
+
+	freq = atomic_load_acq_64(&tsc_freq);
 	if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED) {
-		cputime_clock = CPUTIME_CLOCK_I8254;
-		if (tsc_freq != 0 && mp_ncpus == 1)
+		if (freq != 0 && mp_ncpus == 1)
 			cputime_clock = CPUTIME_CLOCK_TSC;
+		else
+			cputime_clock = CPUTIME_CLOCK_I8254;
 	}
-	gp->profrate = i8254_freq << CPUTIME_CLOCK_I8254_SHIFT;
 	if (cputime_clock == CPUTIME_CLOCK_TSC) {
-		gp->profrate = tsc_freq >> 1;
+		gp->profrate = freq >> 1;
 		cputime_prof_active = 1;
-	}
+	} else
+		gp->profrate = i8254_freq << CPUTIME_CLOCK_I8254_SHIFT;
 #if defined(PERFMON) && defined(I586_PMC_GUPROF)
-	else if (cputime_clock == CPUTIME_CLOCK_I586_PMC) {
+	if (cputime_clock == CPUTIME_CLOCK_I586_PMC) {
 		if (perfmon_avail() &&
 		    perfmon_setup(0, cputime_clock_pmc_conf) == 0) {
 			if (perfmon_start(0) != 0)

Modified: head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
==============================================================================
--- head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -403,7 +403,7 @@ dtrace_gethrtime_init(void *arg)
 	 * Otherwise tick->time conversion will be inaccurate, but
 	 * will preserve monotonic property of TSC.
 	 */
-	tsc_f = tsc_freq;
+	tsc_f = atomic_load_acq_64(&tsc_freq);
 
 	/*
 	 * The following line checks that nsec_scale calculated below

Modified: head/sys/cddl/dev/dtrace/i386/dtrace_subr.c
==============================================================================
--- head/sys/cddl/dev/dtrace/i386/dtrace_subr.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/cddl/dev/dtrace/i386/dtrace_subr.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -403,7 +403,7 @@ dtrace_gethrtime_init(void *arg)
 	 * Otherwise tick->time conversion will be inaccurate, but
 	 * will preserve monotonic property of TSC.
 	 */
-	tsc_f = tsc_freq;
+	tsc_f = atomic_load_acq_64(&tsc_freq);
 
 	/*
 	 * The following line checks that nsec_scale calculated below

Modified: head/sys/compat/linprocfs/linprocfs.c
==============================================================================
--- head/sys/compat/linprocfs/linprocfs.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/compat/linprocfs/linprocfs.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -221,6 +221,7 @@ linprocfs_docpuinfo(PFS_FILL_ARGS)
 {
 	int hw_model[2];
 	char model[128];
+	uint64_t freq;
 	size_t size;
 	int class, fqmhz, fqkhz;
 	int i;
@@ -303,9 +304,10 @@ linprocfs_docpuinfo(PFS_FILL_ARGS)
 		if (cpu_feature & (1 << i))
 			sbuf_printf(sb, " %s", flags[i]);
 	sbuf_cat(sb, "\n");
-	if (class >= 5) {
-		fqmhz = (tsc_freq + 4999) / 1000000;
-		fqkhz = ((tsc_freq + 4999) / 10000) % 100;
+	freq = atomic_load_acq_64(&tsc_freq);
+	if (freq != 0) {
+		fqmhz = (freq + 4999) / 1000000;
+		fqkhz = ((freq + 4999) / 10000) % 100;
 		sbuf_printf(sb,
 		    "cpu MHz\t\t: %d.%02d\n"
 		    "bogomips\t: %d.%02d\n",

Modified: head/sys/contrib/altq/altq/altq_subr.c
==============================================================================
--- head/sys/contrib/altq/altq/altq_subr.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/contrib/altq/altq/altq_subr.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -929,7 +929,8 @@ init_machclk_setup(void)
 #if defined(__amd64__) || defined(__i386__)
 	/* check if TSC is available */
 #ifdef __FreeBSD__
-	if ((cpu_feature & CPUID_TSC) == 0 || tsc_freq == 0)
+	if ((cpu_feature & CPUID_TSC) == 0 ||
+	    atomic_load_acq_64(&tsc_freq) == 0)
 #else
 	if ((cpu_feature & CPUID_TSC) == 0)
 #endif
@@ -964,7 +965,7 @@ init_machclk(void)
 	 */
 #if defined(__amd64__) || defined(__i386__)
 #ifdef __FreeBSD__
-	machclk_freq = tsc_freq;
+	machclk_freq = atomic_load_acq_64(&tsc_freq);
 #elif defined(__NetBSD__)
 	machclk_freq = (u_int32_t)cpu_tsc_freq;
 #elif defined(__OpenBSD__) && (defined(I586_CPU) || defined(I686_CPU))

Modified: head/sys/dev/acpica/acpi_cpu.c
==============================================================================
--- head/sys/dev/acpica/acpi_cpu.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/dev/acpica/acpi_cpu.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -516,7 +516,7 @@ acpi_cpu_read_ivar(device_t dev, device_
 #if defined(__amd64__) || defined(__i386__)
     case CPU_IVAR_NOMINAL_MHZ:
 	if (tsc_is_invariant) {
-	    *result = (uintptr_t)(tsc_freq / 1000000);
+	    *result = (uintptr_t)(atomic_load_acq_64(&tsc_freq) / 1000000);
 	    break;
 	}
 	/* FALLTHROUGH */

Modified: head/sys/i386/i386/legacy.c
==============================================================================
--- head/sys/i386/i386/legacy.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/i386/i386/legacy.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -342,7 +342,8 @@ cpu_read_ivar(device_t dev, device_t chi
 		break;
 	case CPU_IVAR_NOMINAL_MHZ:
 		if (tsc_is_invariant) {
-			*result = (uintptr_t)(tsc_freq / 1000000);
+			*result = (uintptr_t)(atomic_load_acq_64(&tsc_freq) /
+			    1000000);
 			break;
 		}
 		/* FALLTHROUGH */

Modified: head/sys/i386/i386/machdep.c
==============================================================================
--- head/sys/i386/i386/machdep.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/i386/i386/machdep.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -1137,20 +1137,21 @@ int
 cpu_est_clockrate(int cpu_id, uint64_t *rate)
 {
 	register_t reg;
-	uint64_t tsc1, tsc2;
+	uint64_t freq, tsc1, tsc2;
 
 	if (pcpu_find(cpu_id) == NULL || rate == NULL)
 		return (EINVAL);
 	if ((cpu_feature & CPUID_TSC) == 0)
 		return (EOPNOTSUPP);
+	freq = atomic_load_acq_64(&tsc_freq);
 
 	/* If TSC is P-state invariant, DELAY(9) based logic fails. */
-	if (tsc_is_invariant && tsc_freq != 0)
+	if (tsc_is_invariant && freq != 0)
 		return (EOPNOTSUPP);
 
 	/* If we're booting, trust the rate calibrated moments ago. */
-	if (cold && tsc_freq != 0) {
-		*rate = tsc_freq;
+	if (cold && freq != 0) {
+		*rate = freq;
 		return (0);
 	}
 
@@ -1179,7 +1180,7 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 #endif
 
 	tsc2 -= tsc1;
-	if (tsc_freq != 0) {
+	if (freq != 0) {
 		*rate = tsc2 * 1000;
 		return (0);
 	}

Modified: head/sys/i386/i386/perfmon.c
==============================================================================
--- head/sys/i386/i386/perfmon.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/i386/i386/perfmon.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -336,6 +336,7 @@ perfmon_ioctl(struct cdev *dev, u_long c
 	struct pmc *pmc;
 	struct pmc_data *pmcd;
 	struct pmc_tstamp *pmct;
+	uint64_t freq;
 	int *ip;
 	int rv;
 
@@ -386,13 +387,14 @@ perfmon_ioctl(struct cdev *dev, u_long c
 		break;
 
 	case PMIOTSTAMP:
-		if (!tsc_freq) {
+		freq = atomic_load_acq_64(&tsc_freq);
+		if (freq == 0) {
 			rv = ENOTTY;
 			break;
 		}
 		pmct = (struct pmc_tstamp *)param;
 		/* XXX interface loses precision. */
-		pmct->pmct_rate = tsc_freq / 1000000;
+		pmct->pmct_rate = freq / 1000000;
 		pmct->pmct_value = rdtsc();
 		rv = 0;
 		break;

Modified: head/sys/i386/isa/prof_machdep.c
==============================================================================
--- head/sys/i386/isa/prof_machdep.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/i386/isa/prof_machdep.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -170,8 +170,8 @@ cputime()
 {
 	u_int count;
 	int delta;
-#if (defined(I586_CPU) || defined(I686_CPU)) && !defined(SMP) && \
-    defined(PERFMON) && defined(I586_PMC_GUPROF)
+#if (defined(I586_CPU) || defined(I686_CPU)) && \
+    defined(PERFMON) && defined(I586_PMC_GUPROF) && !defined(SMP)
 	u_quad_t event_count;
 #endif
 	u_char high, low;
@@ -286,21 +286,23 @@ void
 startguprof(gp)
 	struct gmonparam *gp;
 {
-	if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED) {
-		cputime_clock = CPUTIME_CLOCK_I8254;
 #if defined(I586_CPU) || defined(I686_CPU)
-		if (tsc_freq != 0 && mp_ncpus == 1)
+	uint64_t freq;
+
+	freq = atomic_load_acq_64(&tsc_freq);
+	if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED) {
+		if (freq != 0 && mp_ncpus == 1)
 			cputime_clock = CPUTIME_CLOCK_TSC;
-#endif
+		else
+			cputime_clock = CPUTIME_CLOCK_I8254;
 	}
-	gp->profrate = i8254_freq << CPUTIME_CLOCK_I8254_SHIFT;
-#if defined(I586_CPU) || defined(I686_CPU)
 	if (cputime_clock == CPUTIME_CLOCK_TSC) {
-		gp->profrate = tsc_freq >> 1;
+		gp->profrate = freq >> 1;
 		cputime_prof_active = 1;
-	}
+	} else
+		gp->profrate = i8254_freq << CPUTIME_CLOCK_I8254_SHIFT;
 #if defined(PERFMON) && defined(I586_PMC_GUPROF)
-	else if (cputime_clock == CPUTIME_CLOCK_I586_PMC) {
+	if (cputime_clock == CPUTIME_CLOCK_I586_PMC) {
 		if (perfmon_avail() &&
 		    perfmon_setup(0, cputime_clock_pmc_conf) == 0) {
 			if (perfmon_start(0) != 0)
@@ -325,6 +327,10 @@ startguprof(gp)
 		}
 	}
 #endif /* PERFMON && I586_PMC_GUPROF */
+#else /* !(I586_CPU || I686_CPU) */
+	if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED)
+		cputime_clock = CPUTIME_CLOCK_I8254;
+	gp->profrate = i8254_freq << CPUTIME_CLOCK_I8254_SHIFT;
 #endif /* I586_CPU || I686_CPU */
 	cputime_bias = 0;
 	cputime();

Modified: head/sys/pc98/pc98/machdep.c
==============================================================================
--- head/sys/pc98/pc98/machdep.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/pc98/pc98/machdep.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -1072,16 +1072,17 @@ int
 cpu_est_clockrate(int cpu_id, uint64_t *rate)
 {
 	register_t reg;
-	uint64_t tsc1, tsc2;
+	uint64_t freq, tsc1, tsc2;
 
 	if (pcpu_find(cpu_id) == NULL || rate == NULL)
 		return (EINVAL);
 	if ((cpu_feature & CPUID_TSC) == 0)
 		return (EOPNOTSUPP);
+	freq = atomic_load_acq_64(&tsc_freq);
 
 	/* If we're booting, trust the rate calibrated moments ago. */
-	if (cold && tsc_freq != 0) {
-		*rate = tsc_freq;
+	if (cold && freq != 0) {
+		*rate = freq;
 		return (0);
 	}
 
@@ -1110,7 +1111,7 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 #endif
 
 	tsc2 -= tsc1;
-	if (tsc_freq != 0) {
+	if (freq != 0) {
 		*rate = tsc2 * 1000;
 		return (0);
 	}

Modified: head/sys/x86/cpufreq/est.c
==============================================================================
--- head/sys/x86/cpufreq/est.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/x86/cpufreq/est.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -1215,7 +1215,7 @@ est_msr_info(device_t dev, uint64_t msr,
 		return (EOPNOTSUPP);
 
 	/* Figure out the bus clock. */
-	freq = tsc_freq / 1000000;
+	freq = atomic_load_acq_64(&tsc_freq) / 1000000;
 	id = msr >> 32;
 	bus = freq / (id >> 8);
 	device_printf(dev, "Guessed bus clock (high) of %d MHz\n", bus);

Modified: head/sys/x86/isa/clock.c
==============================================================================
--- head/sys/x86/isa/clock.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/x86/isa/clock.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -246,13 +246,13 @@ getit(void)
 }
 
 static __inline void
-delay_tsc(int n)
+delay_tsc(int n, uint64_t freq)
 {
 	uint64_t start, end, now;
 
 	sched_pin();
 	start = rdtsc();
-	end = start + (tsc_freq * n) / 1000000;
+	end = start + (freq * n) / 1000000;
 	do {
 		cpu_spinwait();
 		now = rdtsc();
@@ -290,6 +290,7 @@ void
 DELAY(int n)
 {
 	struct timecounter *tc;
+	uint64_t freq;
 	int delta, prev_tick, tick, ticks_left;
 
 #ifdef DELAYDEBUG
@@ -298,8 +299,9 @@ DELAY(int n)
 	static int state = 0;
 #endif
 
-	if (tsc_freq != 0) {
-		delay_tsc(n);
+	freq = atomic_load_acq_64(&tsc_freq);
+	if (freq != 0) {
+		delay_tsc(n, freq);
 		return;
 	}
 	tc = timecounter;

Modified: head/sys/x86/x86/tsc.c
==============================================================================
--- head/sys/x86/x86/tsc.c	Thu Apr  7 23:14:33 2011	(r220432)
+++ head/sys/x86/x86/tsc.c	Thu Apr  7 23:28:28 2011	(r220433)
@@ -245,14 +245,16 @@ tsc_freq_changing(void *arg, const struc
 static void
 tsc_freq_changed(void *arg, const struct cf_level *level, int status)
 {
+	uint64_t freq;
 
 	/* If there was an error during the transition, don't do anything. */
 	if (tsc_disabled || status != 0)
 		return;
 
 	/* Total setting for this level gives the new frequency in MHz. */
-	tsc_freq = (uint64_t)level->total_set.freq * 1000000;
-	tsc_timecounter.tc_frequency = tsc_freq;
+	freq = (uint64_t)level->total_set.freq * 1000000;
+	atomic_store_rel_64(&tsc_freq, freq);
+	atomic_store_rel_64(&tsc_timecounter.tc_frequency, freq);
 }
 
 static int
@@ -261,13 +263,13 @@ sysctl_machdep_tsc_freq(SYSCTL_HANDLER_A
 	int error;
 	uint64_t freq;
 
-	if (tsc_timecounter.tc_frequency == 0)
+	freq = atomic_load_acq_64(&tsc_freq);
+	if (freq == 0)
 		return (EOPNOTSUPP);
-	freq = tsc_freq;
 	error = sysctl_handle_64(oidp, &freq, 0, req);
 	if (error == 0 && req->newptr != NULL) {
-		tsc_freq = freq;
-		tsc_timecounter.tc_frequency = tsc_freq;
+		atomic_store_rel_64(&tsc_freq, freq);
+		atomic_store_rel_64(&tsc_timecounter.tc_frequency, freq);
 	}
 	return (error);
 }

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 06:27:44 2011
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 343CF106564A;
	Fri,  8 Apr 2011 06:27:44 +0000 (UTC) (envelope-from art@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2432B8FC0C;
	Fri,  8 Apr 2011 06:27:44 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p386RimL066209;
	Fri, 8 Apr 2011 06:27:44 GMT (envelope-from art@svn.freebsd.org)
Received: (from art@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p386Riwn066206;
	Fri, 8 Apr 2011 06:27:44 GMT (envelope-from art@svn.freebsd.org)
Message-Id: <201104080627.p386Riwn066206@svn.freebsd.org>
From: Artem Belevich 
Date: Fri, 8 Apr 2011 06:27: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: r220437 - in head/sys: cddl/dev/systrace
	modules/dtrace/systrace_linux32
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, 08 Apr 2011 06:27:44 -0000

Author: art
Date: Fri Apr  8 06:27:43 2011
New Revision: 220437
URL: http://svn.freebsd.org/changeset/base/220437

Log:
  Stripped '32' suffix from linux systrace module name on i386.
  
  Approved by: avg

Modified:
  head/sys/cddl/dev/systrace/systrace.c
  head/sys/modules/dtrace/systrace_linux32/Makefile

Modified: head/sys/cddl/dev/systrace/systrace.c
==============================================================================
--- head/sys/cddl/dev/systrace/systrace.c	Fri Apr  8 06:20:43 2011	(r220436)
+++ head/sys/cddl/dev/systrace/systrace.c	Fri Apr  8 06:27:43 2011	(r220437)
@@ -64,16 +64,17 @@
 #include 
 #include 
 #include 
+#define	MODNAME		"linux32"
 #elif defined(__i386__)
 #include 
 #include 
 #include 
 #include 
+#define	MODNAME		"linux"
 #else
 #error Only i386 and amd64 are supported.
 #endif
 extern struct sysent linux_sysent[];
-#define	MODNAME		"linux32"
 #define	MAXSYSCALL	LINUX_SYS_MAXSYSCALL
 #define	SYSCALLNAMES	linux_syscallnames
 #define	SYSENT		linux_sysent
@@ -132,7 +133,7 @@ static struct cdevsw systrace_cdevsw = {
 	.d_version	= D_VERSION,
 	.d_open		= systrace_open,
 #ifdef LINUX_SYSTRACE
-	.d_name		= "linsystrace",
+	.d_name		= "systrace_" MODNAME,
 #else
 	.d_name		= "systrace",
 #endif

Modified: head/sys/modules/dtrace/systrace_linux32/Makefile
==============================================================================
--- head/sys/modules/dtrace/systrace_linux32/Makefile	Fri Apr  8 06:20:43 2011	(r220436)
+++ head/sys/modules/dtrace/systrace_linux32/Makefile	Fri Apr  8 06:27:43 2011	(r220437)
@@ -2,7 +2,12 @@
 
 .PATH: ${.CURDIR}/../../../cddl/dev/systrace
 
+.if ${MACHINE} == "amd64"
 KMOD=		systrace_linux32
+.else
+KMOD=		systrace_linux
+.endif
+
 SRCS=		systrace.c
 SRCS+=		vnode_if.h
 

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 06:29:41 2011
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 D04BA106566B;
	Fri,  8 Apr 2011 06:29:41 +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 C09DC8FC0A;
	Fri,  8 Apr 2011 06:29:41 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p386TfZT066283;
	Fri, 8 Apr 2011 06:29:41 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p386TfmZ066281;
	Fri, 8 Apr 2011 06:29:41 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104080629.p386TfmZ066281@svn.freebsd.org>
From: Adrian Chadd 
Date: Fri, 8 Apr 2011 06:29: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: r220438 - head/sys/dev/ath/ath_hal
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, 08 Apr 2011 06:29:41 -0000

Author: adrian
Date: Fri Apr  8 06:29:41 2011
New Revision: 220438
URL: http://svn.freebsd.org/changeset/base/220438

Log:
  Extend the RX descriptor block to include two more EVM words.
  
  This will be needed for later AR93xx/AR94xx 3-stream devices.

Modified:
  head/sys/dev/ath/ath_hal/ah_desc.h

Modified: head/sys/dev/ath/ath_hal/ah_desc.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_desc.h	Fri Apr  8 06:27:43 2011	(r220437)
+++ head/sys/dev/ath/ath_hal/ah_desc.h	Fri Apr  8 06:29:41 2011	(r220438)
@@ -113,6 +113,8 @@ struct ath_rx_status {
 	uint32_t	rs_evm0;	/* evm bytes */
 	uint32_t	rs_evm1;
 	uint32_t	rs_evm2;	
+	uint32_t	rs_evm3;	/* needed for ar9300 and later */
+	uint32_t	rs_evm4;	/* needed for ar9300 and later */
 #endif /* AH_SUPPORT_AR5416 */
 };
 

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 06:58:02 2011
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 441251065670;
	Fri,  8 Apr 2011 06:58:02 +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 340968FC0A;
	Fri,  8 Apr 2011 06:58:02 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p386w25q067124;
	Fri, 8 Apr 2011 06:58:02 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p386w211067120;
	Fri, 8 Apr 2011 06:58:02 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104080658.p386w211067120@svn.freebsd.org>
From: Adrian Chadd 
Date: Fri, 8 Apr 2011 06:58:02 +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: r220442 - in head/sys/dev/ath/ath_hal: . ar5416
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, 08 Apr 2011 06:58:02 -0000

Author: adrian
Date: Fri Apr  8 06:58:01 2011
New Revision: 220442
URL: http://svn.freebsd.org/changeset/base/220442

Log:
  Export the per-chain ctl/ext noise floor values, raw and uncut, to the
  upper-level HAL.
  
  Right now the per-chain noise floor values aren't used anywhere in
  the upper-level HAL, so the driver currently has no real reference
  to compare the per-chain RSSI values to.
  
  This is needed before per-chain RSSI values (for ctl and ext radios)
  are can be thrown upstairs to the net80211 code.

Modified:
  head/sys/dev/ath/ath_hal/ah.h
  head/sys/dev/ath/ath_hal/ah_internal.h
  head/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c

Modified: head/sys/dev/ath/ath_hal/ah.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.h	Fri Apr  8 06:55:25 2011	(r220441)
+++ head/sys/dev/ath/ath_hal/ah.h	Fri Apr  8 06:58:01 2011	(r220442)
@@ -31,6 +31,14 @@
 #include "ah_osdep.h"
 
 /*
+ * The maximum number of TX/RX chains supported.
+ * This is intended to be used by various statistics gathering operations
+ * (NF, RSSI, EVM).
+ */
+#define	AH_MIMO_MAX_CHAINS		3
+#define	AH_MIMO_MAX_EVM_PILOTS		6
+
+/*
  * __ahdecl is analogous to _cdecl; it defines the calling
  * convention used within the HAL.  For most systems this
  * can just default to be empty and the compiler will (should)

Modified: head/sys/dev/ath/ath_hal/ah_internal.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_internal.h	Fri Apr  8 06:55:25 2011	(r220441)
+++ head/sys/dev/ath/ath_hal/ah_internal.h	Fri Apr  8 06:58:01 2011	(r220442)
@@ -28,6 +28,7 @@
 #define	AH_MAX(a,b)	((a)>(b)?(a):(b))
 
 #include 
+#include "opt_ah.h"			/* needed for AH_SUPPORT_AR5416 */
 
 #ifndef NBBY
 #define	NBBY	8			/* number of bits/byte */
@@ -136,11 +137,16 @@ typedef struct {
 #define	CHANNEL_IQVALID		0x01	/* IQ calibration valid */
 #define	CHANNEL_ANI_INIT	0x02	/* ANI state initialized */
 #define	CHANNEL_ANI_SETUP	0x04	/* ANI state setup */
+#define	CHANNEL_MIMO_NF_VALID	0x04	/* Mimo NF values are valid */
 	uint8_t		calValid;	/* bitmask of cal types */
 	int8_t		iCoff;
 	int8_t		qCoff;
 	int16_t		rawNoiseFloor;
 	int16_t		noiseFloorAdjust;
+#ifdef	AH_SUPPORT_AR5416
+	uint8_t		noiseFloorCtl[AH_MIMO_MAX_CHAINS];
+	uint8_t		noiseFloorExt[AH_MIMO_MAX_CHAINS];
+#endif	/* AH_SUPPORT_AR5416 */
 	uint16_t	mainSpur;	/* cached spur value for this channel */
 } HAL_CHANNEL_INTERNAL;
 

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c	Fri Apr  8 06:55:25 2011	(r220441)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c	Fri Apr  8 06:58:01 2011	(r220442)
@@ -775,6 +775,7 @@ static int16_t
 ar5416GetNf(struct ath_hal *ah, struct ieee80211_channel *chan)
 {
 	int16_t nf, nfThresh;
+	int i;
 
 	if (ar5212IsNFCalInProgress(ah)) {
 		HALDEBUG(ah, HAL_DEBUG_ANY,
@@ -806,6 +807,13 @@ ar5416GetNf(struct ath_hal *ah, struct i
 		} else {
 			nf = 0;
 		}
+		/* Update MIMO channel statistics, regardless of validity or not (for now) */
+		for (i = 0; i < 3; i++) {
+			ichan->noiseFloorCtl[i] = nfarray[i];
+			ichan->noiseFloorExt[i] = nfarray[i + 3];
+		}
+		ichan->privFlags |= CHANNEL_MIMO_NF_VALID;
+
 		ar5416UpdateNFHistBuff(AH5416(ah)->ah_cal.nfCalHist, nfarray);
 		ichan->rawNoiseFloor = nf;
 	}

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 07:44:00 2011
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 5E725106564A;
	Fri,  8 Apr 2011 07:44:00 +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 4E0898FC17;
	Fri,  8 Apr 2011 07:44:00 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p387i09D068161;
	Fri, 8 Apr 2011 07:44:00 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p387i0Od068158;
	Fri, 8 Apr 2011 07:44:00 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104080744.p387i0Od068158@svn.freebsd.org>
From: Adrian Chadd 
Date: Fri, 8 Apr 2011 07:44: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: r220443 - head/sys/dev/ath/ath_hal
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, 08 Apr 2011 07:44:00 -0000

Author: adrian
Date: Fri Apr  8 07:44:00 2011
New Revision: 220443
URL: http://svn.freebsd.org/changeset/base/220443

Log:
  Begin fleshing out a public HAL routine to export the per-chain
  ctl/ext noise floor values.
  
  This routine doesn't check to see whether the radio is MIMO
  capable - instead, it simply returns either the raw values,
  the "nominal" values if the raw values aren't yet available
  or are invalid, or '0' values if there's no valid channel/
  no valid MIMO values.
  
  Callers are expected to verify the radio is a MIMO radio
  (which for now means it's an 11n chipset, there are non-11n
  MIMO chipsets out there but I don't think we support them,
  at least in MIMO mode) before exporting the MIMO values.

Modified:
  head/sys/dev/ath/ath_hal/ah.c
  head/sys/dev/ath/ath_hal/ah.h

Modified: head/sys/dev/ath/ath_hal/ah.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.c	Fri Apr  8 06:58:01 2011	(r220442)
+++ head/sys/dev/ath/ath_hal/ah.c	Fri Apr  8 07:44:00 2011	(r220443)
@@ -893,6 +893,76 @@ ath_hal_getChanNoise(struct ath_hal *ah,
 }
 
 /*
+ * Fetch the current setup of ctl/ext noise floor values.
+ *
+ * If the CHANNEL_MIMO_NF_VALID flag isn't set, the array is simply
+ * populated with values from NOISE_FLOOR[] + ath_hal_getNfAdjust().
+ *
+ * The caller must supply ctl/ext NF arrays which are at least
+ * AH_MIMO_MAX_CHAINS entries long.
+ */
+int
+ath_hal_get_mimo_chan_noise(struct ath_hal *ah,
+    const struct ieee80211_channel *chan, uint8_t *nf_ctl,
+    uint8_t *nf_ext)
+{
+	HAL_CHANNEL_INTERNAL *ichan;
+	int i;
+
+	ichan = ath_hal_checkchannel(ah, chan);
+	if (ichan == AH_NULL) {
+		HALDEBUG(ah, HAL_DEBUG_NFCAL,
+		    "%s: invalid channel %u/0x%x; no mapping\n",
+		    __func__, chan->ic_freq, chan->ic_flags);
+		for (i = 0; i < AH_MIMO_MAX_CHAINS; i++) {
+			nf_ctl[i] = nf_ext[i] = 0;
+		}
+		return 0;
+	}
+
+	/* Return 0 if there's no valid MIMO values (yet) */
+	if (! (ichan->privFlags & CHANNEL_MIMO_NF_VALID)) {
+		for (i = 0; i < AH_MIMO_MAX_CHAINS; i++) {
+			nf_ctl[i] = nf_ext[i] = 0;
+		}
+		return 0;
+	}
+	if (ichan->rawNoiseFloor == 0) {
+		WIRELESS_MODE mode = ath_hal_chan2wmode(ah, chan);
+		HALASSERT(mode < WIRELESS_MODE_MAX);
+		/*
+		 * See the comment below - this could cause issues for
+		 * stations which have a very low RSSI, below the
+		 * 'normalised' NF values in NOISE_FLOOR[].
+		 */
+		for (i = 0; i < AH_MIMO_MAX_CHAINS; i++) {
+			nf_ctl[i] = nf_ext[i] = NOISE_FLOOR[mode] +
+			    ath_hal_getNfAdjust(ah, ichan);
+		}
+		return 1;
+	} else {
+		/*
+		 * The value returned here from a MIMO radio is presumed to be
+		 * "good enough" as a NF calculation. As RSSI values are calculated
+		 * against this, an adjusted NF may be higher than the RSSI value
+		 * returned from a vary weak station, resulting in an obscenely
+		 * high signal strength calculation being returned.
+		 *
+		 * This should be re-evaluated at a later date, along with any
+		 * signal strength calculations which are made. Quite likely the
+		 * RSSI values will need to be adjusted to ensure the calculations
+		 * don't "wrap" when RSSI is less than the "adjusted" NF value.
+		 * ("Adjust" here is via ichan->noiseFloorAdjust.)
+		 */
+		for (i = 0; i < AH_MIMO_MAX_CHAINS; i++) {
+			nf_ctl[i] = ichan->noiseFloorCtl[i] + ath_hal_getNfAdjust(ah, ichan);
+			nf_ext[i] = ichan->noiseFloorExt[i] + ath_hal_getNfAdjust(ah, ichan);
+		}
+		return 1;
+	}
+}
+
+/*
  * Process all valid raw noise floors into the dBm noise floor values.
  * Though our device has no reference for a dBm noise floor, we perform
  * a relative minimization of NF's based on the lowest NF found across a

Modified: head/sys/dev/ath/ath_hal/ah.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.h	Fri Apr  8 06:58:01 2011	(r220442)
+++ head/sys/dev/ath/ath_hal/ah.h	Fri Apr  8 07:44:00 2011	(r220443)
@@ -951,6 +951,14 @@ extern	HAL_STATUS __ahdecl ath_hal_set_c
     HAL_CTRY_CODE cc, HAL_REG_DOMAIN regDmn);
 
 /*
+ * Fetch the ctl/ext noise floor values reported by a MIMO
+ * radio. Returns 1 for valid results, 0 for invalid channel.
+ */
+extern int __ahdecl ath_hal_get_mimo_chan_noise(struct ath_hal *ah,
+    const struct ieee80211_channel *chan, uint8_t *nf_ctl,
+    uint8_t *nf_ext);
+
+/*
  * Calibrate noise floor data following a channel scan or similar.
  * This must be called prior retrieving noise floor data.
  */

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 08:49:51 2011
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 7DC071065673;
	Fri,  8 Apr 2011 08:49:51 +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 532238FC19;
	Fri,  8 Apr 2011 08:49:51 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p388np2R069526;
	Fri, 8 Apr 2011 08:49:51 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p388npUA069522;
	Fri, 8 Apr 2011 08:49:51 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104080849.p388npUA069522@svn.freebsd.org>
From: Adrian Chadd 
Date: Fri, 8 Apr 2011 08:49: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: r220444 - head/sys/dev/ath/ath_hal
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, 08 Apr 2011 08:49:51 -0000

Author: adrian
Date: Fri Apr  8 08:49:50 2011
New Revision: 220444
URL: http://svn.freebsd.org/changeset/base/220444

Log:
  Fix the completely wrong types I used in the previous commit.

Modified:
  head/sys/dev/ath/ath_hal/ah.c
  head/sys/dev/ath/ath_hal/ah.h
  head/sys/dev/ath/ath_hal/ah_internal.h

Modified: head/sys/dev/ath/ath_hal/ah.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.c	Fri Apr  8 07:44:00 2011	(r220443)
+++ head/sys/dev/ath/ath_hal/ah.c	Fri Apr  8 08:49:50 2011	(r220444)
@@ -903,8 +903,8 @@ ath_hal_getChanNoise(struct ath_hal *ah,
  */
 int
 ath_hal_get_mimo_chan_noise(struct ath_hal *ah,
-    const struct ieee80211_channel *chan, uint8_t *nf_ctl,
-    uint8_t *nf_ext)
+    const struct ieee80211_channel *chan, int16_t *nf_ctl,
+    int16_t *nf_ext)
 {
 	HAL_CHANNEL_INTERNAL *ichan;
 	int i;

Modified: head/sys/dev/ath/ath_hal/ah.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.h	Fri Apr  8 07:44:00 2011	(r220443)
+++ head/sys/dev/ath/ath_hal/ah.h	Fri Apr  8 08:49:50 2011	(r220444)
@@ -955,8 +955,8 @@ extern	HAL_STATUS __ahdecl ath_hal_set_c
  * radio. Returns 1 for valid results, 0 for invalid channel.
  */
 extern int __ahdecl ath_hal_get_mimo_chan_noise(struct ath_hal *ah,
-    const struct ieee80211_channel *chan, uint8_t *nf_ctl,
-    uint8_t *nf_ext);
+    const struct ieee80211_channel *chan, int16_t *nf_ctl,
+    int16_t *nf_ext);
 
 /*
  * Calibrate noise floor data following a channel scan or similar.

Modified: head/sys/dev/ath/ath_hal/ah_internal.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_internal.h	Fri Apr  8 07:44:00 2011	(r220443)
+++ head/sys/dev/ath/ath_hal/ah_internal.h	Fri Apr  8 08:49:50 2011	(r220444)
@@ -144,8 +144,8 @@ typedef struct {
 	int16_t		rawNoiseFloor;
 	int16_t		noiseFloorAdjust;
 #ifdef	AH_SUPPORT_AR5416
-	uint8_t		noiseFloorCtl[AH_MIMO_MAX_CHAINS];
-	uint8_t		noiseFloorExt[AH_MIMO_MAX_CHAINS];
+	int16_t		noiseFloorCtl[AH_MIMO_MAX_CHAINS];
+	int16_t		noiseFloorExt[AH_MIMO_MAX_CHAINS];
 #endif	/* AH_SUPPORT_AR5416 */
 	uint16_t	mainSpur;	/* cached spur value for this channel */
 } HAL_CHANNEL_INTERNAL;

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 09:20:46 2011
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 4432E106566C;
	Fri,  8 Apr 2011 09:20:46 +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 28E148FC12;
	Fri,  8 Apr 2011 09:20:46 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p389Kkm1070212;
	Fri, 8 Apr 2011 09:20:46 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p389KjUY070206;
	Fri, 8 Apr 2011 09:20:45 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104080920.p389KjUY070206@svn.freebsd.org>
From: Adrian Chadd 
Date: Fri, 8 Apr 2011 09:20: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: r220445 - 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: Fri, 08 Apr 2011 09:20:46 -0000

Author: adrian
Date: Fri Apr  8 09:20:45 2011
New Revision: 220445
URL: http://svn.freebsd.org/changeset/base/220445

Log:
  Add initial support for MIMO statistics to net80211.
  
  This introduces struct ieee80211_rx_stats - which stores the various kinds
  of RX statistics which a MIMO and non-MIMO 802.11 device can export.
  
  It also fleshes out the mimo export to userland (node_getmimoinfo()).
  
  It assumes that MIMO radios (for now) export both ctl and ext channels.
  Non-11n MIMO radios are possible (and I believe Atheros made at least
  one), so if that chipset support is added, extra flags to the
  struct ieee80211_rx_stats can be added to extend this support.
  
  Two new input functions have been added - ieee80211_input_mimo() and
  ieee80211_input_mimo_all() - which MIMO-aware devices can call with
  MIMO specific statistics.
  
  802.11 devices calling the non-MIMO input functions will still function.

Modified:
  head/sys/net80211/_ieee80211.h
  head/sys/net80211/ieee80211_input.c
  head/sys/net80211/ieee80211_node.c
  head/sys/net80211/ieee80211_node.h
  head/sys/net80211/ieee80211_proto.h

Modified: head/sys/net80211/_ieee80211.h
==============================================================================
--- head/sys/net80211/_ieee80211.h	Fri Apr  8 08:49:50 2011	(r220444)
+++ head/sys/net80211/_ieee80211.h	Fri Apr  8 09:20:45 2011	(r220445)
@@ -387,10 +387,16 @@ struct ieee80211_regdomain {
 /*
  * MIMO antenna/radio state.
  */
+
+#define	IEEE80211_MAX_CHAINS		3
+#define	IEEE80211_MAX_EVM_PILOTS	6
+
+/*
+ * XXX This doesn't yet export both ctl/ext chain details
+ */
 struct ieee80211_mimo_info {
-	int8_t		rssi[3];	/* per-antenna rssi */
-	int8_t		noise[3];	/* per-antenna noise floor */
-	uint8_t		pad[2];
+	int8_t		rssi[IEEE80211_MAX_CHAINS];	/* per-antenna rssi */
+	int8_t		noise[IEEE80211_MAX_CHAINS];	/* per-antenna noise floor */
 	uint32_t	evm[3];		/* EVM data */
 };
 #endif /* _NET80211__IEEE80211_H_ */

Modified: head/sys/net80211/ieee80211_input.c
==============================================================================
--- head/sys/net80211/ieee80211_input.c	Fri Apr  8 08:49:50 2011	(r220444)
+++ head/sys/net80211/ieee80211_input.c	Fri Apr  8 09:20:45 2011	(r220445)
@@ -57,9 +57,54 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 
+static void
+ieee80211_process_mimo(struct ieee80211_node *ni, struct ieee80211_rx_stats *rx)
+{
+	int i;
+
+	/* Verify the required MIMO bits are set */
+	if ((rx->r_flags & (IEEE80211_R_C_CHAIN | IEEE80211_R_C_NF | IEEE80211_R_C_RSSI)) !=
+	    (IEEE80211_R_C_CHAIN | IEEE80211_R_C_NF | IEEE80211_R_C_RSSI))
+		return;
+
+	/* XXX This assumes the MIMO radios have both ctl and ext chains */
+	for (i = 0; i < MIN(rx->c_chain, IEEE80211_MAX_CHAINS); i++) {
+		IEEE80211_RSSI_LPF(ni->ni_mimo_rssi_ctl[i], rx->c_rssi_ctl[i]);
+		IEEE80211_RSSI_LPF(ni->ni_mimo_rssi_ext[i], rx->c_rssi_ext[i]);
+	}
+
+	/* XXX This also assumes the MIMO radios have both ctl and ext chains */
+	for(i = 0; i < MIN(rx->c_chain, IEEE80211_MAX_CHAINS); i++) {
+		ni->ni_mimo_noise_ctl[i] = rx->c_nf_ctl[i];
+		ni->ni_mimo_noise_ext[i] = rx->c_nf_ext[i];
+	}
+	ni->ni_mimo_chains = rx->c_chain;
+}
+
+int
+ieee80211_input_mimo(struct ieee80211_node *ni, struct mbuf *m,
+    struct ieee80211_rx_stats *rx)
+{
+	/* XXX should assert IEEE80211_R_NF and IEEE80211_R_RSSI are set */
+	ieee80211_process_mimo(ni, rx);
+	return ieee80211_input(ni, m, rx->rssi, rx->nf);
+}
+
 int
 ieee80211_input_all(struct ieee80211com *ic, struct mbuf *m, int rssi, int nf)
 {
+	struct ieee80211_rx_stats rx;
+
+	rx.r_flags = IEEE80211_R_NF | IEEE80211_R_RSSI;
+	rx.nf = nf;
+	rx.rssi = rssi;
+	return ieee80211_input_mimo_all(ic, m, &rx);
+}
+
+int
+ieee80211_input_mimo_all(struct ieee80211com *ic, struct mbuf *m,
+    struct ieee80211_rx_stats *rx)
+{
 	struct ieee80211vap *vap;
 	int type = -1;
 
@@ -96,7 +141,7 @@ ieee80211_input_all(struct ieee80211com 
 			m = NULL;
 		}
 		ni = ieee80211_ref_node(vap->iv_bss);
-		type = ieee80211_input(ni, mcopy, rssi, nf);
+		type = ieee80211_input_mimo(ni, mcopy, rx);
 		ieee80211_free_node(ni);
 	}
 	if (m != NULL)			/* no vaps, reclaim mbuf */

Modified: head/sys/net80211/ieee80211_node.c
==============================================================================
--- head/sys/net80211/ieee80211_node.c	Fri Apr  8 08:49:50 2011	(r220444)
+++ head/sys/net80211/ieee80211_node.c	Fri Apr  8 09:20:45 2011	(r220445)
@@ -1085,7 +1085,26 @@ static void
 node_getmimoinfo(const struct ieee80211_node *ni,
 	struct ieee80211_mimo_info *info)
 {
-	/* XXX zero data? */
+	int i;
+	uint32_t avgrssi;
+	int32_t rssi;
+
+	bzero(info, sizeof(*info));
+
+	for (i = 0; i < ni->ni_mimo_chains; i++) {
+		avgrssi = ni->ni_mimo_rssi_ctl[i];
+		if (avgrssi == IEEE80211_RSSI_DUMMY_MARKER) {
+			info->rssi[i] = 0;
+		} else {
+			rssi = IEEE80211_RSSI_GET(avgrssi);
+			info->rssi[i] = rssi < 0 ? 0 : rssi > 127 ? 127 : rssi;
+		}
+		info->noise[i] = ni->ni_mimo_noise_ctl[i];
+	}
+
+	/* XXX ext radios? */
+
+	/* XXX EVM? */
 }
 
 struct ieee80211_node *

Modified: head/sys/net80211/ieee80211_node.h
==============================================================================
--- head/sys/net80211/ieee80211_node.h	Fri Apr  8 08:49:50 2011	(r220444)
+++ head/sys/net80211/ieee80211_node.h	Fri Apr  8 09:20:45 2011	(r220445)
@@ -166,6 +166,13 @@ struct ieee80211_node {
 	uint32_t		ni_avgrssi;	/* recv ssi state */
 	int8_t			ni_noise;	/* noise floor */
 
+	/* mimo statistics */
+	uint32_t		ni_mimo_rssi_ctl[IEEE80211_MAX_CHAINS];
+	uint32_t		ni_mimo_rssi_ext[IEEE80211_MAX_CHAINS];
+	uint8_t			ni_mimo_noise_ctl[IEEE80211_MAX_CHAINS];
+	uint8_t			ni_mimo_noise_ext[IEEE80211_MAX_CHAINS];
+	uint8_t			ni_mimo_chains;
+
 	/* header */
 	uint8_t			ni_macaddr[IEEE80211_ADDR_LEN];
 	uint8_t			ni_bssid[IEEE80211_ADDR_LEN];

Modified: head/sys/net80211/ieee80211_proto.h
==============================================================================
--- head/sys/net80211/ieee80211_proto.h	Fri Apr  8 08:49:50 2011	(r220444)
+++ head/sys/net80211/ieee80211_proto.h	Fri Apr  8 09:20:45 2011	(r220445)
@@ -61,9 +61,36 @@ void	ieee80211_syncflag(struct ieee80211
 void	ieee80211_syncflag_ht(struct ieee80211vap *, int flag);
 void	ieee80211_syncflag_ext(struct ieee80211vap *, int flag);
 
+#define	IEEE80211_R_NF		0x0000001	/* global NF value valid */
+#define	IEEE80211_R_RSSI	0x0000002	/* global RSSI value valid */
+#define	IEEE80211_R_C_CHAIN	0x0000004	/* RX chain count valid */
+#define	IEEE80211_R_C_NF	0x0000008	/* per-chain NF value valid */
+#define	IEEE80211_R_C_RSSI	0x0000010	/* per-chain RSSI value valid */
+#define	IEEE80211_R_C_EVM	0x0000020	/* per-chain EVM valid */
+#define	IEEE80211_R_C_HT40	0x0000040	/* RX'ed packet is 40mhz, pilots 4,5 valid */
+
+struct ieee80211_rx_stats {
+	uint32_t r_flags;		/* IEEE80211_R_* flags */
+	uint8_t c_chain;		/* number of RX chains involved */
+	int16_t	c_nf_ctl[IEEE80211_MAX_CHAINS];	/* per-chain NF */
+	int16_t	c_nf_ext[IEEE80211_MAX_CHAINS];	/* per-chain NF */
+	int16_t	c_rssi_ctl[IEEE80211_MAX_CHAINS];	/* per-chain RSSI */
+	int16_t	c_rssi_ext[IEEE80211_MAX_CHAINS];	/* per-chain RSSI */
+	uint8_t nf;			/* global NF */
+	uint8_t rssi;			/* global RSSI */
+	uint8_t evm[IEEE80211_MAX_CHAINS][IEEE80211_MAX_EVM_PILOTS];
+					/* per-chain, per-pilot EVM values */
+};
+
 #define	ieee80211_input(ni, m, rssi, nf) \
 	((ni)->ni_vap->iv_input(ni, m, rssi, nf))
 int	ieee80211_input_all(struct ieee80211com *, struct mbuf *, int, int);
+
+int	ieee80211_input_mimo(struct ieee80211_node *, struct mbuf *,
+	    struct ieee80211_rx_stats *);
+int	ieee80211_input_mimo_all(struct ieee80211com *, struct mbuf *,
+	    struct ieee80211_rx_stats *);
+
 struct ieee80211_bpf_params;
 int	ieee80211_mgmt_output(struct ieee80211_node *, struct mbuf *, int,
 		struct ieee80211_bpf_params *);

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 09:56:31 2011
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 8E9901065673;
	Fri,  8 Apr 2011 09:56:31 +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 7D9E58FC12;
	Fri,  8 Apr 2011 09:56:31 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p389uV9x070991;
	Fri, 8 Apr 2011 09:56:31 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p389uV12070989;
	Fri, 8 Apr 2011 09:56:31 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104080956.p389uV12070989@svn.freebsd.org>
From: Adrian Chadd 
Date: Fri, 8 Apr 2011 09:56: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: r220446 - 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: Fri, 08 Apr 2011 09:56:31 -0000

Author: adrian
Date: Fri Apr  8 09:56:31 2011
New Revision: 220446
URL: http://svn.freebsd.org/changeset/base/220446

Log:
  Re-add the pad[2] I deleted by accident.

Modified:
  head/sys/net80211/_ieee80211.h

Modified: head/sys/net80211/_ieee80211.h
==============================================================================
--- head/sys/net80211/_ieee80211.h	Fri Apr  8 09:20:45 2011	(r220445)
+++ head/sys/net80211/_ieee80211.h	Fri Apr  8 09:56:31 2011	(r220446)
@@ -397,6 +397,7 @@ struct ieee80211_regdomain {
 struct ieee80211_mimo_info {
 	int8_t		rssi[IEEE80211_MAX_CHAINS];	/* per-antenna rssi */
 	int8_t		noise[IEEE80211_MAX_CHAINS];	/* per-antenna noise floor */
+	uint8_t		pad[2];
 	uint32_t	evm[3];		/* EVM data */
 };
 #endif /* _NET80211__IEEE80211_H_ */

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 10:23:34 2011
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 A036F106564A;
	Fri,  8 Apr 2011 10:23:34 +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 100838FC0A;
	Fri,  8 Apr 2011 10:23:32 +0000 (UTC)
Received: from porto.topspin.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 NAA04352;
	Fri, 08 Apr 2011 13:23:30 +0300 (EEST)
	(envelope-from avg@FreeBSD.org)
Received: from localhost.topspin.kiev.ua ([127.0.0.1])
	by porto.topspin.kiev.ua with esmtp (Exim 4.34 (FreeBSD))
	id 1Q88qg-000GRr-Hc; Fri, 08 Apr 2011 13:23:30 +0300
Message-ID: <4D9EE221.40200@FreeBSD.org>
Date: Fri, 08 Apr 2011 13:23:29 +0300
From: Andriy Gapon 
User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US;
	rv:1.9.2.15) Gecko/20110308 Lightning/1.0b2 Thunderbird/3.1.9
MIME-Version: 1.0
To: John Baldwin 
References: <201104072132.p37LWPuu052536@svn.freebsd.org>
In-Reply-To: <201104072132.p37LWPuu052536@svn.freebsd.org>
X-Enigmail-Version: 1.1.2
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Cc: svn-src-head@FreeBSD.org, FreeBSD-Current ,
	svn-src-all@FreeBSD.org, src-committers@FreeBSD.org
Subject: Re: svn commit: r220430 - 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, 08 Apr 2011 10:23:34 -0000

on 08/04/2011 00:32 John Baldwin said the following:
> Author: jhb
> Date: Thu Apr  7 21:32:25 2011
> New Revision: 220430
> URL: http://svn.freebsd.org/changeset/base/220430
> 
> Log:
>   If a system call does not request a full interrupt return, use a fast
>   path via the sysretq instruction to return from the system call.  This was
>   removed in 190620 and not quite fully restored in 195486.  This resolves
>   most of the performance regression in system call microbenchmarks between
>   7 and 8 on amd64.
>   
>   Reviewed by:	kib
>   MFC after:	1 week

I think that this commit (plus r220431) has broken something in my environment.
After updating to the most recent head I started to get semi-random problems in
various areas:
- named would consistently fail to start, but with different errors (assertions)
- ^Z and fg result in a process getting SIGSEGV
- X sometimes fails to start complaining about failed VT switch

Reverting just these two commits restores sanity.

Just in case, my processor is AMD (arch is obviously amd64).

> Modified:
>   head/sys/amd64/amd64/exception.S
> 
> Modified: head/sys/amd64/amd64/exception.S
> ==============================================================================
> --- head/sys/amd64/amd64/exception.S	Thu Apr  7 21:29:34 2011	(r220429)
> +++ head/sys/amd64/amd64/exception.S	Thu Apr  7 21:32:25 2011	(r220430)
> @@ -339,6 +339,9 @@ IDTVEC(prot)
>   * and the new privilige level.  We are still running on the old user stack
>   * pointer.  We have to juggle a few things around to find our stack etc.
>   * swapgs gives us access to our PCPU space only.
> + *
> + * We do not support invoking this from a custom %cs or %ss (e.g. using
> + * entries from an LDT).
>   */
>  IDTVEC(fast_syscall)
>  	swapgs
> @@ -380,6 +383,36 @@ IDTVEC(fast_syscall)
>  	movq	%rsp,%rdi
>  	call	syscall
>  	movq	PCPU(CURPCB),%rax
> +	testq	$PCB_FULL_IRET,PCB_FLAGS(%rax)
> +	jne	3f
> +1:	/* Check for and handle AST's on return to userland. */
> +	cli
> +	movq	PCPU(CURTHREAD),%rax
> +	testl	$TDF_ASTPENDING | TDF_NEEDRESCHED,TD_FLAGS(%rax)
> +	je	2f
> +	sti
> +	movq	%rsp, %rdi
> +	call	ast
> +	jmp	1b
> +2:	/* Restore preserved registers. */
> +	MEXITCOUNT
> +	movq	TF_RDI(%rsp),%rdi	/* bonus; preserve arg 1 */
> +	movq	TF_RSI(%rsp),%rsi	/* bonus: preserve arg 2 */
> +	movq	TF_RDX(%rsp),%rdx	/* return value 2 */
> +	movq	TF_RAX(%rsp),%rax	/* return value 1 */
> +	movq	TF_RBX(%rsp),%rbx	/* C preserved */
> +	movq	TF_RBP(%rsp),%rbp	/* C preserved */
> +	movq	TF_R12(%rsp),%r12	/* C preserved */
> +	movq	TF_R13(%rsp),%r13	/* C preserved */
> +	movq	TF_R14(%rsp),%r14	/* C preserved */
> +	movq	TF_R15(%rsp),%r15	/* C preserved */
> +	movq	TF_RFLAGS(%rsp),%r11	/* original %rflags */
> +	movq	TF_RIP(%rsp),%rcx	/* original %rip */
> +	movq	TF_RSP(%rsp),%r9	/* user stack pointer */
> +	movq	%r9,%rsp		/* original %rsp */
> +	swapgs
> +	sysretq
> +3:	/* Requested full context restore, use doreti for that. */
>  	MEXITCOUNT
>  	jmp	doreti
>  


-- 
Andriy Gapon

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 11:08:27 2011
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 1F1591065675;
	Fri,  8 Apr 2011 11:08:27 +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 0DA558FC13;
	Fri,  8 Apr 2011 11:08:27 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p38B8QeI078309;
	Fri, 8 Apr 2011 11:08:26 GMT (envelope-from mm@svn.freebsd.org)
Received: (from mm@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p38B8QS1078306;
	Fri, 8 Apr 2011 11:08:26 GMT (envelope-from mm@svn.freebsd.org)
Message-Id: <201104081108.p38B8QS1078306@svn.freebsd.org>
From: Martin Matuska 
Date: Fri, 8 Apr 2011 11:08: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: r220447 - in head/sys/cddl: compat/opensolaris/sys
	contrib/opensolaris/common/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, 08 Apr 2011 11:08:27 -0000

Author: mm
Date: Fri Apr  8 11:08:26 2011
New Revision: 220447
URL: http://svn.freebsd.org/changeset/base/220447

Log:
  Partially fix ZFS compat code for sparc64.
  Some endianess bugs still need to be resolved.
  
  Submitted by:	marius (parts of the fix)
  MFC after:	1 month

Modified:
  head/sys/cddl/compat/opensolaris/sys/sunddi.h
  head/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c

Modified: head/sys/cddl/compat/opensolaris/sys/sunddi.h
==============================================================================
--- head/sys/cddl/compat/opensolaris/sys/sunddi.h	Fri Apr  8 09:56:31 2011	(r220446)
+++ head/sys/cddl/compat/opensolaris/sys/sunddi.h	Fri Apr  8 11:08:26 2011	(r220447)
@@ -37,8 +37,10 @@
 
 #define	strdup(ptr)				strdup((ptr), M_SOLARIS)
 #define	ddi_driver_major(zfs_dip)		(0)
-#define	ddi_copyin(from, to, size, flag)	(bcopy((from), (to), (size)), 0)
-#define	ddi_copyout(from, to, size, flag)	(bcopy((from), (to), (size)), 0)
+#define	ddi_copyin(from, to, size, flag)				\
+	(copyin((from), (to), (size)), 0)
+#define	ddi_copyout(from, to, size, flag)				\
+	(copyout((from), (to), (size)), 0)
 int ddi_strtol(const char *str, char **nptr, int base, long *result);
 int ddi_strtoul(const char *str, char **nptr, int base, unsigned long *result);
 int ddi_strtoull(const char *str, char **nptr, int base,

Modified: head/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c	Fri Apr  8 09:56:31 2011	(r220446)
+++ head/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c	Fri Apr  8 11:08:26 2011	(r220447)
@@ -20,6 +20,8 @@
  */
 /*
  * Copyright 2010 Martin Matuska . All rights reserved.
+ * Portions Copyright 2005, 2010, Oracle and/or its affiliates.
+ * All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -151,17 +153,69 @@ zfs_cmd_compat_put(zfs_cmd_t *zc, caddr_
 }
 
 static int
-zfs_ioctl_compat_write_nvlist_dst(zfs_cmd_t *zc, nvlist_t *nvl, size_t nvsize)
+zfs_ioctl_compat_get_nvlist(uint64_t nvl, size_t size, int iflag,
+    nvlist_t **nvp)
 {
-	char *packed = (void *)(uintptr_t)zc->zc_nvlist_dst;
-	int err;
+	char *packed;
+	int error;
+	nvlist_t *list = NULL;
+
+	/*
+	 * Read in and unpack the user-supplied nvlist.
+	 */
+	if (size == 0)
+		return (EINVAL);
+
+#ifdef _KERNEL
+	packed = kmem_alloc(size, KM_SLEEP);
+	if ((error = ddi_copyin((void *)(uintptr_t)nvl, packed, size,
+	    iflag)) != 0) {
+		kmem_free(packed, size);
+		return (error);
+	}
+#else
+	packed = (void *)(uintptr_t)nvl;
+#endif
 
-	err = nvlist_pack(nvl, &packed, &nvsize,
-	    NV_ENCODE_NATIVE, 0);
-	if (err == 0)
-		zc->zc_nvlist_dst_size = nvsize;
+	error = nvlist_unpack(packed, size, &list, 0);
 
-	return (err);
+#ifdef _KERNEL
+	kmem_free(packed, size);
+#endif
+
+	if (error != 0)
+		return (error);
+
+	*nvp = list;
+	return (0);
+}
+
+static int
+zfs_ioctl_compat_put_nvlist(zfs_cmd_t *zc, nvlist_t *nvl)
+{
+	char *packed = NULL;
+	int error = 0;
+	size_t size;
+
+	VERIFY(nvlist_size(nvl, &size, NV_ENCODE_NATIVE) == 0);
+
+#ifdef _KERNEL
+	packed = kmem_alloc(size, KM_SLEEP);
+	VERIFY(nvlist_pack(nvl, &packed, &size, NV_ENCODE_NATIVE,
+	    KM_SLEEP) == 0);
+
+	if (ddi_copyout(packed,
+	    (void *)(uintptr_t)zc->zc_nvlist_dst, size, zc->zc_iflags) != 0)
+		error = EFAULT;
+	kmem_free(packed, size);
+#else
+	packed = (void *)(uintptr_t)zc->zc_nvlist_dst;
+	VERIFY(nvlist_pack(nvl, &packed, &size, NV_ENCODE_NATIVE,
+	    0) == 0);
+#endif
+
+	zc->zc_nvlist_dst_size = size;
+	return (error);
 }
 
 static void
@@ -205,17 +259,16 @@ zfs_ioctl_compat_fix_stats_nvlist(nvlist
 	}
 }
 
-static void
+static int
 zfs_ioctl_compat_fix_stats(zfs_cmd_t *zc, const int cflag)
 {
 	nvlist_t *nv, *nvp = NULL;
 	nvpair_t *elem;
-	size_t nvsize;
-	char *packed;
+	int error;
 
-	if (nvlist_unpack((void *)(uintptr_t)zc->zc_nvlist_dst,
-	    zc->zc_nvlist_dst_size, &nv, 0) != 0)
-		return;
+	if ((error = zfs_ioctl_compat_get_nvlist(zc->zc_nvlist_dst,
+	    zc->zc_nvlist_dst_size, zc->zc_iflags, &nv)) != 0)
+		return (error);
 
 	if (cflag == 5) { /* ZFS_IOC_POOL_STATS */
 		elem = NULL;
@@ -227,21 +280,22 @@ zfs_ioctl_compat_fix_stats(zfs_cmd_t *zc
 	} else
 		zfs_ioctl_compat_fix_stats_nvlist(nv);
 
-	VERIFY(nvlist_size(nv, &nvsize, NV_ENCODE_NATIVE) == 0);
-	zfs_ioctl_compat_write_nvlist_dst(zc, nv, nvsize);
+	error = zfs_ioctl_compat_put_nvlist(zc, nv);
 
 	nvlist_free(nv);
+
+	return (error);
 }
 
-static void
+static int
 zfs_ioctl_compat_pool_get_props(zfs_cmd_t *zc)
 {
 	nvlist_t *nv, *nva = NULL;
-	size_t nvsize;
+	int error;
 
-	if (nvlist_unpack((void *)(uintptr_t)zc->zc_nvlist_dst,
-	    zc->zc_nvlist_dst_size, &nv, 0) != 0)
-		return;
+	if ((error = zfs_ioctl_compat_get_nvlist(zc->zc_nvlist_dst,
+	    zc->zc_nvlist_dst_size, zc->zc_iflags, &nv)) != 0)
+		return (error);
 
 #ifdef _KERNEL
 	if (nvlist_lookup_nvlist(nv, "allocated", &nva) == 0) {
@@ -265,10 +319,11 @@ zfs_ioctl_compat_pool_get_props(zfs_cmd_
 	}
 #endif
 
-	VERIFY(nvlist_size(nv, &nvsize, NV_ENCODE_NATIVE) == 0);
-	zfs_ioctl_compat_write_nvlist_dst(zc, nv, nvsize);
+	error = zfs_ioctl_compat_put_nvlist(zc, nv);
 
 	nvlist_free(nv);
+
+	return (error);
 }
 
 #ifndef _KERNEL

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 11:22:54 2011
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 B20AC106564A
	for ; Fri,  8 Apr 2011 11:22:54 +0000 (UTC)
	(envelope-from mavbsd@gmail.com)
Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com
	[209.85.214.54])
	by mx1.freebsd.org (Postfix) with ESMTP id 39DF68FC0A
	for ; Fri,  8 Apr 2011 11:22:53 +0000 (UTC)
Received: by bwz12 with SMTP id 12so3479761bwz.13
	for ; Fri, 08 Apr 2011 04:22:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:sender:message-id:date:from:user-agent
	:mime-version:to:cc:subject:references:in-reply-to:content-type
	:content-transfer-encoding;
	bh=bp7RO4TX2y/zs2/QA13MN+YBJzJX5HSD4Rz/Y7iDamU=;
	b=kRLPr6y2c+k83aVOvR7RQpd8mDzcPcGlR5KfAyEQG03wZBb/TdjGUoMsqxRaCvuWfk
	LtbsmN0ifIN92wPNENIovhYjCR/Na6vTf2bC650gheaqlBQfsmx78OwDMof8Eg+wsuyW
	zJTD8sKE4da1bJqtAnsbySyQ15eTzgUwM1+Dg=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject
	:references:in-reply-to:content-type:content-transfer-encoding;
	b=DYvR7kRLmRfoCOy9uCmNFeU8C4hYMLFuoJP52OQYS7TKlFH69MEsHgqPdqMWQCzUPT
	EJwV5HeyOJ+C6ZsE/m3ZsilcVoS2lhMPdXrLtwlgxo1ssKSuzaOgHnutb4n4YGM/yCKY
	2ZlMCb8xpOb5B5vHyuCZrOiWyxpq3Bc5d1s9s=
Received: by 10.204.230.194 with SMTP id jn2mr1788008bkb.133.1302260042305;
	Fri, 08 Apr 2011 03:54:02 -0700 (PDT)
Received: from mavbook.mavhome.dp.ua (95-109-204-34.dialup.umc.net.ua
	[95.109.204.34])
	by mx.google.com with ESMTPS id c11sm1577301bkc.2.2011.04.08.03.53.57
	(version=SSLv3 cipher=OTHER); Fri, 08 Apr 2011 03:54:01 -0700 (PDT)
Sender: Alexander Motin 
Message-ID: <4D9EE942.6080003@FreeBSD.org>
Date: Fri, 08 Apr 2011 13:53:54 +0300
From: Alexander Motin 
User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US;
	rv:1.9.2.15) Gecko/20110310 Thunderbird/3.1.9
MIME-Version: 1.0
To: Alexander Best 
References: <201104070817.p378HrHc033571@svn.freebsd.org>
	<20110407190318.GA97508@freebsd.org>
In-Reply-To: <20110407190318.GA97508@freebsd.org>
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: r220412 - in head: share/man/man4 sys/cam/ata
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, 08 Apr 2011 11:22:54 -0000

On 07.04.2011 22:03, Alexander Best wrote:
> On Thu Apr  7 11, Alexander Motin wrote:
>> Author: mav
>> Date: Thu Apr  7 08:17:53 2011
>> New Revision: 220412
>> URL: http://svn.freebsd.org/changeset/base/220412
>>
>> Log:
>>    Make ada(4) driver to control device write cache, same as ata(4) does.
>>    Add kern.cam.ada.write_cache sysctl/tunable to control it alike hw.ata.wc.
>
> how hard would it be to support per device sysctls/tunables? i'd really like to
> do:
>
> kern.cam.ada.0.write_cache=0 (root fs)
> kern.cam.ada.1.write_cache=1 (/usr, /var, etc.)

Not really hard. I'll do it now.

-- 
Alexander Motin

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 12:33:07 2011
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 8E185106566C;
	Fri,  8 Apr 2011 12:33:07 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 741688FC0C;
	Fri,  8 Apr 2011 12:33:07 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p38CX7RN080134;
	Fri, 8 Apr 2011 12:33:07 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p38CX7YD080131;
	Fri, 8 Apr 2011 12:33:07 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <201104081233.p38CX7YD080131@svn.freebsd.org>
From: Edwin Groothuis 
Date: Fri, 8 Apr 2011 12:33: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: r220448 - head/usr.bin/logger
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, 08 Apr 2011 12:33:07 -0000

Author: edwin
Date: Fri Apr  8 12:33:07 2011
New Revision: 220448
URL: http://svn.freebsd.org/changeset/base/220448

Log:
  When specifying the -t option (send tag in front of message), this tag
  should also be forwarded to the remote logging host, not only when the
  logging is done locally.
  
  PR:		bin/154324
  Submitted by:	Callum Gibson 
  MFC after:	1 week

Modified:
  head/usr.bin/logger/logger.1
  head/usr.bin/logger/logger.c

Modified: head/usr.bin/logger/logger.1
==============================================================================
--- head/usr.bin/logger/logger.1	Fri Apr  8 11:08:26 2011	(r220447)
+++ head/usr.bin/logger/logger.1	Fri Apr  8 12:33:07 2011	(r220448)
@@ -102,7 +102,8 @@ facility.
 The default is ``user.notice.''
 .It Fl t Ar tag
 Mark every line in the log with the specified
-.Ar tag .
+.Ar tag
+rather than the default of current login name.
 .It Ar message
 Write the message to log; if not specified, and the
 .Fl f

Modified: head/usr.bin/logger/logger.c
==============================================================================
--- head/usr.bin/logger/logger.c	Fri Apr  8 11:08:26 2011	(r220447)
+++ head/usr.bin/logger/logger.c	Fri Apr  8 12:33:07 2011	(r220448)
@@ -59,7 +59,8 @@ __FBSDID("$FreeBSD$");
 
 int	decode(char *, CODE *);
 int	pencode(char *);
-static void	logmessage(int, const char *, const char *, const char *);
+static void	logmessage(int, const char *, const char *, const char *,
+			   const char *);
 static void	usage(void);
 
 struct socks {
@@ -137,8 +138,11 @@ main(int argc, char *argv[])
 	argc -= optind;
 	argv += optind;
 
+	if (tag == NULL)
+		tag = getlogin();
 	/* setup for logging */
-	openlog(tag ? tag : getlogin(), logflags, 0);
+	if (host == NULL)
+		openlog(tag, logflags, 0);
 	(void) fclose(stdout);
 
 	/* log input line if appropriate */
@@ -149,11 +153,11 @@ main(int argc, char *argv[])
 		for (p = buf, endp = buf + sizeof(buf) - 2; *argv;) {
 			len = strlen(*argv);
 			if (p + len > endp && p > buf) {
-				logmessage(pri, host, svcname, buf);
+				logmessage(pri, tag, host, svcname, buf);
 				p = buf;
 			}
 			if (len > sizeof(buf) - 1)
-				logmessage(pri, host, svcname, *argv++);
+				logmessage(pri, tag, host, svcname, *argv++);
 			else {
 				if (p != buf)
 					*p++ = ' ';
@@ -162,10 +166,10 @@ main(int argc, char *argv[])
 			}
 		}
 		if (p != buf)
-			logmessage(pri, host, svcname, buf);
+			logmessage(pri, tag, host, svcname, buf);
 	} else
 		while (fgets(buf, sizeof(buf), stdin) != NULL)
-			logmessage(pri, host, svcname, buf);
+			logmessage(pri, tag, host, svcname, buf);
 	exit(0);
 }
 
@@ -173,7 +177,8 @@ main(int argc, char *argv[])
  *  Send the message to syslog, either on the local host, or on a remote host
  */
 void
-logmessage(int pri, const char *host, const char *svcname, const char *buf)
+logmessage(int pri, const char *tag, const char *host, const char *svcname,
+	   const char *buf)
 {
 	static struct socks *socks;
 	static int nsock = 0;
@@ -217,7 +222,7 @@ logmessage(int pri, const char *host, co
 			errx(1, "socket");
 	}
 
-	if ((len = asprintf(&line, "<%d>%s", pri, buf)) == -1)
+	if ((len = asprintf(&line, "<%d>%s: %s", pri, tag, buf)) == -1)
 		errx(1, "asprintf");
 
 	lsent = -1;

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 12:46:47 2011
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 9825B106564A;
	Fri,  8 Apr 2011 12:46: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 8906E8FC0C;
	Fri,  8 Apr 2011 12:46:47 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p38CklM9080503;
	Fri, 8 Apr 2011 12:46:47 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p38Ckl4p080501;
	Fri, 8 Apr 2011 12:46:47 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104081246.p38Ckl4p080501@svn.freebsd.org>
From: Alexander Motin 
Date: Fri, 8 Apr 2011 12:46: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: r220449 - 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: Fri, 08 Apr 2011 12:46:47 -0000

Author: mav
Date: Fri Apr  8 12:46:47 2011
New Revision: 220449
URL: http://svn.freebsd.org/changeset/base/220449

Log:
  Add reference to led(4), supported now.
  Add some details about supported chips.

Modified:
  head/share/man/man4/siis.4

Modified: head/share/man/man4/siis.4
==============================================================================
--- head/share/man/man4/siis.4	Fri Apr  8 12:33:07 2011	(r220448)
+++ head/share/man/man4/siis.4	Fri Apr  8 12:46:47 2011	(r220449)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 18, 2009
+.Dd April 8, 2011
 .Dt SIIS 4
 .Os
 .Sh NAME
@@ -92,6 +92,12 @@ Port Multipliers (including FIS-based sw
 (31 command per port), Native Command Queuing, SATA interface Power Management,
 device hot-plug and Message Signaled Interrupts.
 .Pp
+The activity LEDs of the adapters supported by the
+.Nm
+driver can be controlled via the
+.Xr led 4
+API for localization or status reporting purposes.
+.Pp
 Same hardware is also supported by the atasiliconimage driver from
 .Xr ata 4
 subsystem.
@@ -100,14 +106,21 @@ given precedence as the more functional 
 .Sh HARDWARE
 The
 .Nm
-driver supports the following controllers:
+driver supports the following controller chips:
 .Bl -bullet -compact
 .It
-SiI3124
+SiI3124 (PCI-X 133MHz/64bit, 4 ports)
 .It
-SiI3132
+SiI3131 (PCIe 1.0 x1, 1 port)
 .It
-SiI3531
+SiI3132 (PCIe 1.0 x1, 2 ports)
+.It
+SiI3531 (PCIe 1.0 x1, 1 port)
+.El
+.Sh FILES
+.Bl -tag -width /dev/led/siisch*
+.It Pa /dev/led/siisch*
+identification LED device nodes
 .El
 .Sh SEE ALSO
 .Xr ada 4 ,
@@ -115,6 +128,7 @@ SiI3531
 .Xr cam 4 ,
 .Xr cd 4 ,
 .Xr da 4 ,
+.Xr led 4 ,
 .Xr sa 4
 .Sh HISTORY
 The

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 13:09:00 2011
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 328301065670;
	Fri,  8 Apr 2011 13:09:00 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42])
	by mx1.freebsd.org (Postfix) with ESMTP id DE30E8FC18;
	Fri,  8 Apr 2011 13:08:59 +0000 (UTC)
Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net
	[66.111.2.69])
	by cyrus.watson.org (Postfix) with ESMTPSA id 77E8646B49;
	Fri,  8 Apr 2011 09:08:59 -0400 (EDT)
Received: from jhbmac.hudson-trading.com (unknown [209.249.190.124])
	by bigwig.baldwin.cx (Postfix) with ESMTPSA id D09AC8A027;
	Fri,  8 Apr 2011 09:08:58 -0400 (EDT)
Message-ID: <4D9F08EA.9090209@FreeBSD.org>
Date: Fri, 08 Apr 2011 09:08:58 -0400
From: John Baldwin 
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US;
	rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9
MIME-Version: 1.0
To: Andriy Gapon 
References: <201104072132.p37LWPuu052536@svn.freebsd.org>
	<4D9EE221.40200@FreeBSD.org>
In-Reply-To: <4D9EE221.40200@FreeBSD.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6
	(bigwig.baldwin.cx); Fri, 08 Apr 2011 09:08:59 -0400 (EDT)
Cc: svn-src-head@FreeBSD.org, FreeBSD-Current ,
	svn-src-all@FreeBSD.org, src-committers@FreeBSD.org
Subject: Re: svn commit: r220430 - 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, 08 Apr 2011 13:09:00 -0000

On 4/8/11 6:23 AM, Andriy Gapon wrote:
> on 08/04/2011 00:32 John Baldwin said the following:
>> Author: jhb
>> Date: Thu Apr  7 21:32:25 2011
>> New Revision: 220430
>> URL: http://svn.freebsd.org/changeset/base/220430
>>
>> Log:
>>    If a system call does not request a full interrupt return, use a fast
>>    path via the sysretq instruction to return from the system call.  This was
>>    removed in 190620 and not quite fully restored in 195486.  This resolves
>>    most of the performance regression in system call microbenchmarks between
>>    7 and 8 on amd64.
>>
>>    Reviewed by:	kib
>>    MFC after:	1 week
>
> I think that this commit (plus r220431) has broken something in my environment.
> After updating to the most recent head I started to get semi-random problems in
> various areas:
> - named would consistently fail to start, but with different errors (assertions)
> - ^Z and fg result in a process getting SIGSEGV
> - X sometimes fails to start complaining about failed VT switch
>
> Reverting just these two commits restores sanity.
>
> Just in case, my processor is AMD (arch is obviously amd64).

I think I've found this (I got a bunch of weird core dumps overnight, 
too).  The problem is that ast() can context switch in which case 
PCB_FULL_IRET might get set, but this code would still do the fast path 
after ast() returned.  I fixed it to recheck the PCB_FULL_IRET flag 
after returning from ast() and that has fixed the core dumps I was 
seeing overnight.  I also fixed a bug where PCB_FULL_IRET wasn't updated 
in some of the ia32 compat code, a typo in a comment, and trimmed an 
extra mov from the doreti path:

Index: amd64/exception.S
===================================================================
--- amd64/exception.S	(revision 221092)
+++ amd64/exception.S	(working copy)
@@ -382,10 +382,10 @@
  	FAKE_MCOUNT(TF_RIP(%rsp))
  	movq	%rsp,%rdi
  	call	syscall
-	movq	PCPU(CURPCB),%rax
+1:	movq	PCPU(CURPCB),%rax
  	testl	$PCB_FULL_IRET,PCB_FLAGS(%rax)
-	jne	3f
-1:	/* Check for and handle AST's on return to userland. */
+	jnz	3f
+	/* Check for and handle AST's on return to userland. */
  	cli
  	movq	PCPU(CURTHREAD),%rax
  	testl	$TDF_ASTPENDING | TDF_NEEDRESCHED,TD_FLAGS(%rax)
@@ -661,7 +661,7 @@
  doreti_ast:
  	/*
  	 * Check for ASTs atomically with returning.  Disabling CPU
-	 * interrupts provides sufficient locking eve in the SMP case,
+	 * interrupts provides sufficient locking even in the SMP case,
  	 * since we will be informed of any new ASTs by an IPI.
  	 */
  	cli
@@ -682,8 +682,7 @@
  	 */
  doreti_exit:
  	MEXITCOUNT
-	movq	PCPU(CURTHREAD),%r8
-	movq	TD_PCB(%r8),%r8
+	movq	PCPU(CURPCB),%r8

  	/*
  	 * Do not reload segment registers for kernel.
Index: ia32/ia32_exception.S
===================================================================
--- ia32/ia32_exception.S	(revision 221079)
+++ ia32/ia32_exception.S	(working copy)
@@ -46,7 +46,7 @@
  	subq	$TF_ERR,%rsp		/* skip over tf_trapno */
  	movq	%rdi,TF_RDI(%rsp)
  	movq	PCPU(CURPCB),%rdi
-	movb	$0,PCB_FULL_IRET(%rdi)
+	andl	$~PCB_FULL_IRET,PCB_FLAGS(%rdi)
  	movw	%fs,TF_FS(%rsp)
  	movw	%gs,TF_GS(%rsp)
  	movw	%es,TF_ES(%rsp)

-- 
John Baldwin

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 13:30:48 2011
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 9CCA6106566B;
	Fri,  8 Apr 2011 13:30:48 +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 8F6E98FC0A;
	Fri,  8 Apr 2011 13:30:48 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p38DUm9J081507;
	Fri, 8 Apr 2011 13:30:48 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p38DUmsH081505;
	Fri, 8 Apr 2011 13:30:48 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201104081330.p38DUmsH081505@svn.freebsd.org>
From: John Baldwin 
Date: Fri, 8 Apr 2011 13:30: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: r220451 - head/sys/amd64/ia32
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, 08 Apr 2011 13:30:48 -0000

Author: jhb
Date: Fri Apr  8 13:30:48 2011
New Revision: 220451
URL: http://svn.freebsd.org/changeset/base/220451

Log:
  Catch up to PCB_FULL_IRET becoming a pcb flag rather than a full field.
  
  MFC after:	3 days

Modified:
  head/sys/amd64/ia32/ia32_exception.S

Modified: head/sys/amd64/ia32/ia32_exception.S
==============================================================================
--- head/sys/amd64/ia32/ia32_exception.S	Fri Apr  8 12:49:56 2011	(r220450)
+++ head/sys/amd64/ia32/ia32_exception.S	Fri Apr  8 13:30:48 2011	(r220451)
@@ -46,7 +46,7 @@ IDTVEC(int0x80_syscall)
 	subq	$TF_ERR,%rsp		/* skip over tf_trapno */
 	movq	%rdi,TF_RDI(%rsp)
 	movq	PCPU(CURPCB),%rdi
-	movb	$0,PCB_FULL_IRET(%rdi)
+	andl	$~PCB_FULL_IRET,PCB_FLAGS(%rdi)
 	movw	%fs,TF_FS(%rsp)
 	movw	%gs,TF_GS(%rsp)
 	movw	%es,TF_ES(%rsp)

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 13:33:57 2011
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 DEE22106564A;
	Fri,  8 Apr 2011 13:33:57 +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 D17B98FC0A;
	Fri,  8 Apr 2011 13:33:57 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p38DXvvG081612;
	Fri, 8 Apr 2011 13:33:57 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p38DXv4i081610;
	Fri, 8 Apr 2011 13:33:57 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201104081333.p38DXv4i081610@svn.freebsd.org>
From: John Baldwin 
Date: Fri, 8 Apr 2011 13:33: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: r220452 - 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, 08 Apr 2011 13:33:58 -0000

Author: jhb
Date: Fri Apr  8 13:33:57 2011
New Revision: 220452
URL: http://svn.freebsd.org/changeset/base/220452

Log:
  Fix a bug in the previous change to restore the fast path for syscall
  return.  The ast() function may cause a context switch in which case
  PCB_FULL_IRET would be set in the pcb.  However, the code was not
  rechecking the flag after ast() returned and would not properly restore
  the FSBASE and GSBASE MSRs.  To fix, recheck the PCB_FULL_IRET flag after
  ast() returns.
  
  While here, trim an instruction (and memory access) from the doreti path
  and fix a typo in a comment.
  
  MFC after:	1 week

Modified:
  head/sys/amd64/amd64/exception.S

Modified: head/sys/amd64/amd64/exception.S
==============================================================================
--- head/sys/amd64/amd64/exception.S	Fri Apr  8 13:30:48 2011	(r220451)
+++ head/sys/amd64/amd64/exception.S	Fri Apr  8 13:33:57 2011	(r220452)
@@ -382,10 +382,10 @@ IDTVEC(fast_syscall)
 	FAKE_MCOUNT(TF_RIP(%rsp))
 	movq	%rsp,%rdi
 	call	syscall
-	movq	PCPU(CURPCB),%rax
+1:	movq	PCPU(CURPCB),%rax
 	testl	$PCB_FULL_IRET,PCB_FLAGS(%rax)
-	jne	3f
-1:	/* Check for and handle AST's on return to userland. */
+	jnz	3f
+	/* Check for and handle AST's on return to userland. */
 	cli
 	movq	PCPU(CURTHREAD),%rax
 	testl	$TDF_ASTPENDING | TDF_NEEDRESCHED,TD_FLAGS(%rax)
@@ -661,7 +661,7 @@ doreti:
 doreti_ast:
 	/*
 	 * Check for ASTs atomically with returning.  Disabling CPU
-	 * interrupts provides sufficient locking eve in the SMP case,
+	 * interrupts provides sufficient locking even in the SMP case,
 	 * since we will be informed of any new ASTs by an IPI.
 	 */
 	cli
@@ -682,8 +682,7 @@ doreti_ast:
 	 */
 doreti_exit:
 	MEXITCOUNT
-	movq	PCPU(CURTHREAD),%r8
-	movq	TD_PCB(%r8),%r8
+	movq	PCPU(CURPCB),%r8
 
 	/*
 	 * Do not reload segment registers for kernel.

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 14:39:41 2011
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 97C6A1065673;
	Fri,  8 Apr 2011 14:39:41 +0000 (UTC)
	(envelope-from rstone@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6F8698FC14;
	Fri,  8 Apr 2011 14:39:41 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p38Edfvr083212;
	Fri, 8 Apr 2011 14:39:41 GMT (envelope-from rstone@svn.freebsd.org)
Received: (from rstone@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p38EdfxP083209;
	Fri, 8 Apr 2011 14:39:41 GMT (envelope-from rstone@svn.freebsd.org)
Message-Id: <201104081439.p38EdfxP083209@svn.freebsd.org>
From: Ryan Stone 
Date: Fri, 8 Apr 2011 14:39: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: r220453 - in head/sys: amd64/amd64 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, 08 Apr 2011 14:39:41 -0000

Author: rstone
Date: Fri Apr  8 14:39:41 2011
New Revision: 220453
URL: http://svn.freebsd.org/changeset/base/220453

Log:
  Add tunables that mirror the functionality of sysctls machdep.panic_on_nmi
  and machdep.kdb_on_nmi.
  
  Approved by:	emaste (mentor)
  MFC after:	1 week

Modified:
  head/sys/amd64/amd64/trap.c
  head/sys/i386/i386/trap.c

Modified: head/sys/amd64/amd64/trap.c
==============================================================================
--- head/sys/amd64/amd64/trap.c	Fri Apr  8 13:33:57 2011	(r220452)
+++ head/sys/amd64/amd64/trap.c	Fri Apr  8 14:39:41 2011	(r220453)
@@ -164,10 +164,12 @@ static char *trap_msg[] = {
 static int kdb_on_nmi = 1;
 SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RW,
 	&kdb_on_nmi, 0, "Go to KDB on NMI");
+TUNABLE_INT("machdep.kdb_on_nmi", &kdb_on_nmi);
 #endif
 static int panic_on_nmi = 1;
 SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RW,
 	&panic_on_nmi, 0, "Panic on NMI");
+TUNABLE_INT("machdep.panic_on_nmi", &panic_on_nmi);
 static int prot_fault_translation = 0;
 SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RW,
 	&prot_fault_translation, 0, "Select signal to deliver on protection fault");

Modified: head/sys/i386/i386/trap.c
==============================================================================
--- head/sys/i386/i386/trap.c	Fri Apr  8 13:33:57 2011	(r220452)
+++ head/sys/i386/i386/trap.c	Fri Apr  8 14:39:41 2011	(r220453)
@@ -179,10 +179,12 @@ extern int has_f00f_bug;
 static int kdb_on_nmi = 1;
 SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RW,
 	&kdb_on_nmi, 0, "Go to KDB on NMI");
+TUNABLE_INT("machdep.kdb_on_nmi", &kdb_on_nmi);
 #endif
 static int panic_on_nmi = 1;
 SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RW,
 	&panic_on_nmi, 0, "Panic on NMI");
+TUNABLE_INT("machdep.panic_on_nmi", &panic_on_nmi);
 static int prot_fault_translation = 0;
 SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RW,
 	&prot_fault_translation, 0, "Select signal to deliver on protection fault");

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 14:42:30 2011
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 678B3106564A;
	Fri,  8 Apr 2011 14:42:30 +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 4F6CC8FC0A;
	Fri,  8 Apr 2011 14:42:30 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p38EgUnV083326;
	Fri, 8 Apr 2011 14:42:30 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p38EgUhl083322;
	Fri, 8 Apr 2011 14:42:30 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104081442.p38EgUhl083322@svn.freebsd.org>
From: Alexander Motin 
Date: Fri, 8 Apr 2011 14:42: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: r220454 - in head: share/man/man4 sys/cam/ata 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: Fri, 08 Apr 2011 14:42:30 -0000

Author: mav
Date: Fri Apr  8 14:42:29 2011
New Revision: 220454
URL: http://svn.freebsd.org/changeset/base/220454

Log:
  - Add kern.cam.ada.X.write_cache tunables/sysctls to control write caching
  on per-device basis.
  - While adding support for per-device sysctls, merge from graid branch
  support for ADA_TEST_FAILURE kernel option, which opens few more sysctl,
  allowing to simulate read and write errors for testing purposes.

Modified:
  head/share/man/man4/ada.4
  head/sys/cam/ata/ata_da.c
  head/sys/conf/options

Modified: head/share/man/man4/ada.4
==============================================================================
--- head/share/man/man4/ada.4	Fri Apr  8 14:39:41 2011	(r220453)
+++ head/share/man/man4/ada.4	Fri Apr  8 14:42:29 2011	(r220454)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 7, 2011
+.Dd April 8, 2011
 .Dt ADA 4
 .Os
 .Sh NAME
@@ -101,7 +101,7 @@ variables and
 .Xr loader 8
 tunables:
 .Bl -tag -width 12
-.It kern.cam.ada.retry_count
+.It Va kern.cam.ada.retry_count
 .Pp
 This variable determines how many times the
 .Nm
@@ -111,23 +111,27 @@ the
 .Nm
 driver dump routine.
 This value currently defaults to 4.
-.It kern.cam.ada.default_timeout
+.It Va kern.cam.ada.default_timeout
 .Pp
 This variable determines how long the
 .Nm
 driver will wait before timing out an outstanding command.
 The units for this value are seconds, and the default is currently 30
 seconds.
-.It kern.cam.ada.spindown_shutdown
+.It Va kern.cam.ada.spindown_shutdown
 .Pp
 This variable determines whether to spin-down disks when shutting down.
 Set to 1 to enable spin-down, 0 to disable.  
 The default is currently enabled.
-.It kern.cam.ada.write_cache
+.It Va kern.cam.ada.write_cache
+.It Va kern.cam.ada. Ns Ar X Ns Va .write_cache
 .Pp
-This variable determines whether device write cache should be enabled or not.
+These variables determines whether device write cache should be enabled
+globally or per-device or disabled.
 Set to 1 to enable write cache, 0 to disable, -1 to leave it as-is.
-The default is currently enabled.
+Values modified in runtime take effect only after device reset.
+The global default is currently enabled.
+The per-device default is to leave it as-is (follow global setting).
 .El
 .Sh FILES
 .Bl -tag -width ".Pa /dev/ada*" -compact

Modified: head/sys/cam/ata/ata_da.c
==============================================================================
--- head/sys/cam/ata/ata_da.c	Fri Apr  8 14:39:41 2011	(r220453)
+++ head/sys/cam/ata/ata_da.c	Fri Apr  8 14:42:29 2011	(r220454)
@@ -27,6 +27,8 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include "opt_ada.h"
+
 #include 
 
 #ifdef _KERNEL
@@ -127,6 +129,13 @@ struct ada_softc {
 	int	 outstanding_cmds;
 	int	 trim_max_ranges;
 	int	 trim_running;
+	int	 write_cache;
+#ifdef ADA_TEST_FAILURE
+	int      force_read_error;
+	int      force_write_error;
+	int      periodic_read_error;
+	int      periodic_read_count;
+#endif
 	struct	 disk_params params;
 	struct	 disk *disk;
 	struct task		sysctl_task;
@@ -618,11 +627,11 @@ adaasync(void *callback_arg, u_int32_t c
 
 		softc = (struct ada_softc *)periph->softc;
 		cam_periph_async(periph, code, path, arg);
-		if (ada_write_cache < 0)
+		if (ada_write_cache < 0 && softc->write_cache < 0)
 			break;
 		if (softc->state != ADA_STATE_NORMAL)
 			break;
-		xpt_setup_ccb(&cgd.ccb_h, path, CAM_PRIORITY_NORMAL);
+		xpt_setup_ccb(&cgd.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
 		cgd.ccb_h.func_code = XPT_GDEV_TYPE;
 		xpt_action((union ccb *)&cgd);
 		if ((cgd.ident_data.support.command1 & ATA_SUPPORT_WRITECACHE) == 0)
@@ -647,8 +656,12 @@ adasysctlinit(void *context, int pending
 	char tmpstr[80], tmpstr2[80];
 
 	periph = (struct cam_periph *)context;
-	if (cam_periph_acquire(periph) != CAM_REQ_CMP)
+
+	/* periph was held for us when this task was enqueued */
+	if (periph->flags & CAM_PERIPH_INVALID) {
+		cam_periph_release(periph);
 		return;
+	}
 
 	softc = (struct ada_softc *)periph->softc;
 	snprintf(tmpstr, sizeof(tmpstr), "CAM ADA unit %d", periph->unit_number);
@@ -665,6 +678,28 @@ adasysctlinit(void *context, int pending
 		return;
 	}
 
+	SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
+		OID_AUTO, "write_cache", CTLFLAG_RW | CTLFLAG_MPSAFE,
+		&softc->write_cache, 0, "Enable disk write cache.");
+#ifdef ADA_TEST_FAILURE
+	/*
+	 * Add a 'door bell' sysctl which allows one to set it from userland
+	 * and cause something bad to happen.  For the moment, we only allow
+	 * whacking the next read or write.
+	 */
+	SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
+		OID_AUTO, "force_read_error", CTLFLAG_RW | CTLFLAG_MPSAFE,
+		&softc->force_read_error, 0,
+		"Force a read error for the next N reads.");
+	SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
+		OID_AUTO, "force_write_error", CTLFLAG_RW | CTLFLAG_MPSAFE,
+		&softc->force_write_error, 0,
+		"Force a write error for the next N writes.");
+	SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
+		OID_AUTO, "periodic_read_error", CTLFLAG_RW | CTLFLAG_MPSAFE,
+		&softc->periodic_read_error, 0,
+		"Force a read error every N reads (don't set too low).");
+#endif
 	cam_periph_release(periph);
 }
 
@@ -738,6 +773,10 @@ adaregister(struct cam_periph *periph, v
 		softc->quirks = ((struct ada_quirk_entry *)match)->quirks;
 	else
 		softc->quirks = ADA_Q_NONE;
+	softc->write_cache = -1;
+	snprintf(announce_buf, sizeof(announce_buf),
+	    "kern.cam.ada.%d.writa_cache", periph->unit_number);
+	TUNABLE_INT_FETCH(announce_buf, &softc->write_cache);
 
 	bzero(&cpi, sizeof(cpi));
 	xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NONE);
@@ -812,6 +851,14 @@ adaregister(struct cam_periph *periph, v
 		dp->secsize, dp->heads,
 		dp->secs_per_track, dp->cylinders);
 	xpt_announce_periph(periph, announce_buf);
+
+	/*
+	 * Create our sysctl variables, now that we know
+	 * we have successfully attached.
+	 */
+	cam_periph_acquire(periph);
+	taskqueue_enqueue(taskqueue_thread, &softc->sysctl_task);
+
 	/*
 	 * Add async callbacks for bus reset and
 	 * bus device reset calls.  I don't bother
@@ -832,7 +879,7 @@ adaregister(struct cam_periph *periph, v
 	    (ADA_DEFAULT_TIMEOUT * hz) / ADA_ORDEREDTAG_INTERVAL,
 	    adasendorderedtag, softc);
 
-	if (ada_write_cache >= 0 &&
+	if ((ada_write_cache >= 0 || softc->write_cache >= 0) &&
 	    cgd->ident_data.support.command1 & ATA_SUPPORT_WRITECACHE) {
 		softc->state = ADA_STATE_WCACHE;
 		cam_periph_acquire(periph);
@@ -944,7 +991,45 @@ adastart(struct cam_periph *periph, unio
 		{
 			uint64_t lba = bp->bio_pblkno;
 			uint16_t count = bp->bio_bcount / softc->params.secsize;
+#ifdef ADA_TEST_FAILURE
+			int fail = 0;
 
+			/*
+			 * Support the failure ioctls.  If the command is a
+			 * read, and there are pending forced read errors, or
+			 * if a write and pending write errors, then fail this
+			 * operation with EIO.  This is useful for testing
+			 * purposes.  Also, support having every Nth read fail.
+			 *
+			 * This is a rather blunt tool.
+			 */
+			if (bp->bio_cmd == BIO_READ) {
+				if (softc->force_read_error) {
+					softc->force_read_error--;
+					fail = 1;
+				}
+				if (softc->periodic_read_error > 0) {
+					if (++softc->periodic_read_count >=
+					    softc->periodic_read_error) {
+						softc->periodic_read_count = 0;
+						fail = 1;
+					}
+				}
+			} else {
+				if (softc->force_write_error) {
+					softc->force_write_error--;
+					fail = 1;
+				}
+			}
+			if (fail) {
+				bp->bio_error = EIO;
+				bp->bio_flags |= BIO_ERROR;
+				biodone(bp);
+				xpt_release_ccb(start_ccb);
+				adaschedule(periph);
+				return;
+			}
+#endif
 			cam_fill_ataio(ataio,
 			    ada_retry_count,
 			    adadone,
@@ -1062,7 +1147,8 @@ out:
 		    0,
 		    ada_default_timeout*1000);
 
-		ata_28bit_cmd(ataio, ATA_SETFEATURES, ada_write_cache ?
+		ata_28bit_cmd(ataio, ATA_SETFEATURES, (softc->write_cache > 0 ||
+		     (softc->write_cache < 0 && ada_write_cache)) ?
 		    ATA_SF_ENAB_WCACHE : ATA_SF_DIS_WCACHE, 0, 0);
 		start_ccb->ccb_h.ccb_state = ADA_CCB_WCACHE;
 		xpt_action(start_ccb);

Modified: head/sys/conf/options
==============================================================================
--- head/sys/conf/options	Fri Apr  8 14:39:41 2011	(r220453)
+++ head/sys/conf/options	Fri Apr  8 14:42:29 2011	(r220454)
@@ -305,6 +305,9 @@ SCSI_DELAY		opt_scsi.h
 SCSI_NO_SENSE_STRINGS	opt_scsi.h
 SCSI_NO_OP_STRINGS	opt_scsi.h
 
+# Options used only in cam/ata/ata_da.c
+ADA_TEST_FAILURE       opt_ada.h
+
 # Options used only in cam/scsi/scsi_cd.c
 CHANGER_MIN_BUSY_SECONDS	opt_cd.h
 CHANGER_MAX_BUSY_SECONDS	opt_cd.h

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 14:54:34 2011
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 3CBBF106566C;
	Fri,  8 Apr 2011 14:54:34 +0000 (UTC)
	(envelope-from brde@optusnet.com.au)
Received: from mail08.syd.optusnet.com.au (mail08.syd.optusnet.com.au
	[211.29.132.189])
	by mx1.freebsd.org (Postfix) with ESMTP id CC3488FC12;
	Fri,  8 Apr 2011 14:54:33 +0000 (UTC)
Received: from c122-106-155-58.carlnfd1.nsw.optusnet.com.au
	(c122-106-155-58.carlnfd1.nsw.optusnet.com.au [122.106.155.58])
	by mail08.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id
	p38EsVSi016581
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Sat, 9 Apr 2011 00:54:31 +1000
Date: Sat, 9 Apr 2011 00:54:31 +1000 (EST)
From: Bruce Evans 
X-X-Sender: bde@besplex.bde.org
To: Jung-uk Kim 
In-Reply-To: <201104072328.p37NSSsO055101@svn.freebsd.org>
Message-ID: <20110408224855.Y1390@besplex.bde.org>
References: <201104072328.p37NSSsO055101@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: r220433 - in head/sys: amd64/amd64
 cddl/dev/dtrace/amd64
 cddl/dev/dtrace/i386 compat/linprocfs contrib/altq/altq dev/acpica i386/i386
 i386/isa pc98/pc98 x86/cpufreq x86/isa 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, 08 Apr 2011 14:54:34 -0000

On Thu, 7 Apr 2011, Jung-uk Kim wrote:

> Log:
>  Use atomic load & store for TSC frequency.  It may be overkill for amd64 but
>  safer for i386 because it can be easily over 4 GHz now.  More worse, it can
>  be easily changed by user with 'machdep.tsc_freq' tunable (directly) or
>  cpufreq(4) (indirectly).  Note it is intentionally not used in performance
>  critical paths to avoid performance regression (but we should, in theory).
>  Alternatively, we may add "virtual TSC" with lower frequency if maximum
>  frequency overflows 32 bits (and ignore possible incoherency as we do now).

I disagree with this complexity and churn, and tried to avoid it -- see
previous mails for more details.

There are probably many 64-bit variables that need to be accessed more
atomically, and tsc_freq is one of the least in need of atomic accesses,
since the race windows are especially tiny for it.  Even when the race
is lost, this is harmless except for frequencies that are almost
exactly 2^32 Hz, since only sysctls that change the frequency from
above this to below, or vice versa, can give an inconsistent value.
Thus there is a race window of a few nsec which only matters with a
probability of about 1 in 2^32, only for user[s] of the sysctl to
change the TSC frequency.

The complexity of this shows that you should try hard not to use 64-bit
variables on 32-bit systems if accesses to them are not locked by a
mutex.  64-bit systems like amd64 don't need to do anything special,
any more than 32-bit systems accessing 32-bit variables.  We assume that
accesses of <= the bus width are atomic in a certain weak sense which
is enough for variables like tsc_freq.

I thought of the following KPI-transparent method that can be used for
any struct if updates need not be seen immediately.  It is a refined version
of timehands method used for timecounters:

 	#define	tsc_freq	_tsc_freq[_tsc_gen]

where the everything is updated sufficiently atomically and the object
data is guaranteed not to change for a suitably long time after the
generation that indexes it is read:

 	if ((new_tsc_freq >> 32) == (tsc_freq >> 32)) {
 		/*
 		 * Usual case.  Below 2**32, or upper bits just not
 		 * changing.  No need for complications.
 		 */
 		tsc_freq = new_tsc_freq;
 	else if ((new_tsc_freq & 0xFFFFFFFF) == (tsc_freq & 0xFFFFFFFF)) {
 		/*
 		 * Upper bits changing but lower bits not.  Very unusual,
 		 * and optimized here to give a place for this comment.
 		 * Again, no need for complications.
 		 */
 		tsc_freq = new_tsc_freq;
 	} else {
 		/*
 		 * Need a new generation.  Need locking here (but not for
 		 * readers).  Locking not shown.
 		 */
 		nextgen = (_tsc_gen + 1) % NGEN;
 		_tsc_freq[nextgen] = new_tsc_freq;
 		sfence();
 		_tsc_gen = nextgen;
 		sfence();
 		/*
 		 * Any new reader starting from a bit before now will use
 		 * the new generation.  (I think.  Can the memory ordering
 		 * be so weak that other CPUs don't see the fenced writes
 		 * here until they do some fenced operation?  Even if they
 		 * don't, then waiting a bit here will give them time to
 		 * catch up.)  We must keep the data for the old generation
 		 * stable until any readers of it (via the old generation
 		 * number) have completed.  We should wait a very long time,
 		 * in theory possibly forever, since the reader may be
 		 * preempted after it read the old generation number and
 		 * never run again.  In practice, we should be able to
 		 * bound this time to a few ticks, like timecounter code
 		 * does, by limiting uses to kernel threads in critical
 		 * regions or similar.  Even timecounter code cannot
 		 * guarantee any particular timing, since its running
 		 * may be delayed arbirarily long by sitting at the ddb
 		 * prompt.  The delay can be implemented as in timecounter
 		 * code, by using many generations spaced a tick or 2 apart,
 		 * or more simply by sleeping for a tick or 2 between each
 		 * generation change here.  It would even be OK to sleep a
 		 * minute or 2 here, since we only get here for changing
 		 * the 4/8/16... GHz bits.
 		 */
 		DELAY(1);
 	}

The necessary sfence()s are missing in timecounter code.  Timecounter
code also has explicit generation checks, which I think are not necessary
if enough care is taken keeping the old generation's data stable, but
which help if the generations cycle too fast or the timing is messed
up by ddb.

Another method that would work here (up to 8GHz; expand as necessary)
without changing the KPI is:

 	#define	tsc_freq	((uint64_t)_tsc_freq1 + _tsc_freq2)

where _tsc_freq[12] are 32 bits.  The components are kept below 2**32 so
that they never wrap.  Races may give components from different generations,
but this doesn't matter since adjustments only make small changes to
each component, so the result is just an average of the values of the old
and new generations.

Bruce

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 16:01:51 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28])
	by hub.freebsd.org (Postfix) with ESMTP id 9616E1065678;
	Fri,  8 Apr 2011 16:01:50 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
From: Jung-uk Kim 
To: src-committers@FreeBSD.org
Date: Fri, 8 Apr 2011 12:01:38 -0400
User-Agent: KMail/1.6.2
References: <201104081330.p38DUmsH081505@svn.freebsd.org>
In-Reply-To: <201104081330.p38DUmsH081505@svn.freebsd.org>
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Message-Id: <201104081201.41777.jkim@FreeBSD.org>
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	John Baldwin 
Subject: Re: svn commit: r220451 - head/sys/amd64/ia32
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, 08 Apr 2011 16:01:51 -0000

On Friday 08 April 2011 09:30 am, John Baldwin wrote:
> Author: jhb
> Date: Fri Apr  8 13:30:48 2011
> New Revision: 220451
> URL: http://svn.freebsd.org/changeset/base/220451
>
> Log:
>   Catch up to PCB_FULL_IRET becoming a pcb flag rather than a full
> field.
>
>   MFC after:	3 days
>
> Modified:
>   head/sys/amd64/ia32/ia32_exception.S
>
> Modified: head/sys/amd64/ia32/ia32_exception.S
> ===================================================================
>=========== --- head/sys/amd64/ia32/ia32_exception.S	Fri Apr  8
> 12:49:56 2011	(r220450) +++
> head/sys/amd64/ia32/ia32_exception.S	Fri Apr  8 13:30:48
> 2011	(r220451) @@ -46,7 +46,7 @@ IDTVEC(int0x80_syscall)
>  	subq	$TF_ERR,%rsp		/* skip over tf_trapno */
>  	movq	%rdi,TF_RDI(%rsp)
>  	movq	PCPU(CURPCB),%rdi
> -	movb	$0,PCB_FULL_IRET(%rdi)
> +	andl	$~PCB_FULL_IRET,PCB_FLAGS(%rdi)
>  	movw	%fs,TF_FS(%rsp)
>  	movw	%gs,TF_GS(%rsp)
>  	movw	%es,TF_ES(%rsp)

Oops, thanks for fixing this.

Pointyhat to:	jkim

Jung-uk Kim

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 17:17:49 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28])
	by hub.freebsd.org (Postfix) with ESMTP id 1BEFC106564A;
	Fri,  8 Apr 2011 17:17:49 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
From: Jung-uk Kim 
To: Bruce Evans 
Date: Fri, 8 Apr 2011 13:17:39 -0400
User-Agent: KMail/1.6.2
References: <201104072328.p37NSSsO055101@svn.freebsd.org>
	<20110408224855.Y1390@besplex.bde.org>
In-Reply-To: <20110408224855.Y1390@besplex.bde.org>
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Message-Id: <201104081317.41254.jkim@FreeBSD.org>
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220433 - in head/sys: amd64/amd64
	cddl/dev/dtrace/amd64 cddl/dev/dtrace/i386 compat/linprocfs
	contrib/altq/altq dev/acpica i386/i386 i386/isa pc98/pc98
	x86/cpufreq x86/isa 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, 08 Apr 2011 17:17:49 -0000

On Friday 08 April 2011 10:54 am, Bruce Evans wrote:
> On Thu, 7 Apr 2011, Jung-uk Kim wrote:
> > Log:
> >  Use atomic load & store for TSC frequency.  It may be overkill
> > for amd64 but safer for i386 because it can be easily over 4 GHz
> > now.  More worse, it can be easily changed by user with
> > 'machdep.tsc_freq' tunable (directly) or cpufreq(4) (indirectly).
> >  Note it is intentionally not used in performance critical paths
> > to avoid performance regression (but we should, in theory).
> > Alternatively, we may add "virtual TSC" with lower frequency if
> > maximum frequency overflows 32 bits (and ignore possible
> > incoherency as we do now).
>
> I disagree with this complexity and churn, and tried to avoid it --
> see previous mails for more details.

I don't like it myself.  It's sort of my way of expressing "do not use 
64-bit global variables on 32-bit platforms unless the architecture 
guarantees coherency". ;-)

Seriously, using variant TSC is strongly discouraged for timekeeping.  
Messing up with it from user land is worse.  If it is really 
necessary, it means kernel is broken and we need to fix it.

> There are probably many 64-bit variables that need to be accessed
> more atomically, and tsc_freq is one of the least in need of atomic
> accesses, since the race windows are especially tiny for it.  Even
> when the race is lost, this is harmless except for frequencies that
> are almost exactly 2^32 Hz, since only sysctls that change the
> frequency from above this to below, or vice versa, can give an
> inconsistent value. Thus there is a race window of a few nsec which
> only matters with a probability of about 1 in 2^32, only for
> user[s] of the sysctl to change the TSC frequency.

powerd(8) via cpufreq(4) can change tsc_freq frequently if the CPU is 
not P-state invariant.  Well, the chances of getting ~4.3GHz CPU 
without P-state invariant TSC is little low, I guess.

> The complexity of this shows that you should try hard not to use
> 64-bit variables on 32-bit systems if accesses to them are not
> locked by a mutex.  64-bit systems like amd64 don't need to do
> anything special, any more than 32-bit systems accessing 32-bit
> variables.  We assume that accesses of <= the bus width are atomic
> in a certain weak sense which is enough for variables like
> tsc_freq.

Actually, Pentium and above guarantees the "weak" atomic memory 
read/write when it is aligned to quad-word boundary.  CMPXCHG8B is 
the only one instruction (except for FPU) useful for that feature, 
though.  I considered implementing weaker version initially but I am 
not sure if it has any benefit.

> I thought of the following KPI-transparent method that can be used
> for any struct if updates need not be seen immediately.  It is a
> refined version of timehands method used for timecounters:
>
>  	#define	tsc_freq	_tsc_freq[_tsc_gen]

It just hides the implementation.  How about this, then?

#define	tsc_freq	atomic_load_acq_64(&_tsc_freq)

:-P

> where the everything is updated sufficiently atomically and the
> object data is guaranteed not to change for a suitably long time
> after the generation that indexes it is read:
>
>  	if ((new_tsc_freq >> 32) == (tsc_freq >> 32)) {
>  		/*
>  		 * Usual case.  Below 2**32, or upper bits just not
>  		 * changing.  No need for complications.
>  		 */
>  		tsc_freq = new_tsc_freq;
>  	else if ((new_tsc_freq & 0xFFFFFFFF) == (tsc_freq & 0xFFFFFFFF))
> { /*
>  		 * Upper bits changing but lower bits not.  Very unusual,
>  		 * and optimized here to give a place for this comment.
>  		 * Again, no need for complications.
>  		 */
>  		tsc_freq = new_tsc_freq;
>  	} else {
>  		/*
>  		 * Need a new generation.  Need locking here (but not for
>  		 * readers).  Locking not shown.
>  		 */
>  		nextgen = (_tsc_gen + 1) % NGEN;
>  		_tsc_freq[nextgen] = new_tsc_freq;
>  		sfence();
>  		_tsc_gen = nextgen;
>  		sfence();
>  		/*
>  		 * Any new reader starting from a bit before now will use
>  		 * the new generation.  (I think.  Can the memory ordering
>  		 * be so weak that other CPUs don't see the fenced writes
>  		 * here until they do some fenced operation?  Even if they
>  		 * don't, then waiting a bit here will give them time to
>  		 * catch up.)  We must keep the data for the old generation
>  		 * stable until any readers of it (via the old generation
>  		 * number) have completed.  We should wait a very long time,
>  		 * in theory possibly forever, since the reader may be
>  		 * preempted after it read the old generation number and
>  		 * never run again.  In practice, we should be able to
>  		 * bound this time to a few ticks, like timecounter code
>  		 * does, by limiting uses to kernel threads in critical
>  		 * regions or similar.  Even timecounter code cannot
>  		 * guarantee any particular timing, since its running
>  		 * may be delayed arbirarily long by sitting at the ddb
>  		 * prompt.  The delay can be implemented as in timecounter
>  		 * code, by using many generations spaced a tick or 2 apart,
>  		 * or more simply by sleeping for a tick or 2 between each
>  		 * generation change here.  It would even be OK to sleep a
>  		 * minute or 2 here, since we only get here for changing
>  		 * the 4/8/16... GHz bits.
>  		 */
>  		DELAY(1);
>  	}
>
> The necessary sfence()s are missing in timecounter code. 
> Timecounter code also has explicit generation checks, which I think
> are not necessary if enough care is taken keeping the old
> generation's data stable, but which help if the generations cycle
> too fast or the timing is messed up by ddb.
>
> Another method that would work here (up to 8GHz; expand as
> necessary) without changing the KPI is:
>
>  	#define	tsc_freq	((uint64_t)_tsc_freq1 + _tsc_freq2)
>
> where _tsc_freq[12] are 32 bits.  The components are kept below
> 2**32 so that they never wrap.  Races may give components from
> different generations, but this doesn't matter since adjustments
> only make small changes to each component, so the result is just an
> average of the values of the old and new generations.

You see the complexity is still there and I don't like it.

Introducing "virtual TSC" with fixed and lower frequency can be better 
solution as I noted in the commit log.

Jung-uk Kim

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 18:48:58 2011
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 2A7DD106564A;
	Fri,  8 Apr 2011 18:48:58 +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 185DA8FC0A;
	Fri,  8 Apr 2011 18:48:58 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p38ImvPp088857;
	Fri, 8 Apr 2011 18:48:57 GMT (envelope-from attilio@svn.freebsd.org)
Received: (from attilio@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p38Imv6p088855;
	Fri, 8 Apr 2011 18:48:57 GMT (envelope-from attilio@svn.freebsd.org)
Message-Id: <201104081848.p38Imv6p088855@svn.freebsd.org>
From: Attilio Rao 
Date: Fri, 8 Apr 2011 18:48: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: r220456 - 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: Fri, 08 Apr 2011 18:48:58 -0000

Author: attilio
Date: Fri Apr  8 18:48:57 2011
New Revision: 220456
URL: http://svn.freebsd.org/changeset/base/220456

Log:
  Reintroduce the fix already discussed in r216805 (please check its history
  for a detailed explanation of the problems).
  
  The only difference with the previous fix is in Solution2:
  CPUBLOCK is no longer set when exiting from callout_reset_*() functions,
  which avoid the deadlock (leading to r217161).
  There is no need to CPUBLOCK there because the running-and-migrating
  assumption is strong enough to avoid problems there.
  Furthermore add a better !SMP compliancy (leading to shrinked code and
  structures) and facility macros/functions.
  
  Tested by:	gianni, pho, dim
  MFC after:	3 weeks

Modified:
  head/sys/kern/kern_timeout.c

Modified: head/sys/kern/kern_timeout.c
==============================================================================
--- head/sys/kern/kern_timeout.c	Fri Apr  8 18:31:01 2011	(r220455)
+++ head/sys/kern/kern_timeout.c	Fri Apr  8 18:48:57 2011	(r220456)
@@ -56,6 +56,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#ifdef SMP
+#include 
+#endif
+
 SDT_PROVIDER_DEFINE(callout_execute);
 SDT_PROBE_DEFINE(callout_execute, kernel, , callout_start, callout-start);
 SDT_PROBE_ARGTYPE(callout_execute, kernel, , callout_start, 0,
@@ -83,6 +87,21 @@ SYSCTL_INT(_debug, OID_AUTO, to_avg_mpca
 int callwheelsize, callwheelbits, callwheelmask;
 
 /*
+ * The callout cpu migration entity represents informations necessary for
+ * describing the migrating callout to the new callout cpu.
+ * The cached informations are very important for deferring migration when
+ * the migrating callout is already running.
+ */
+struct cc_mig_ent {
+#ifdef SMP
+	void	(*ce_migration_func)(void *);
+	void	*ce_migration_arg;
+	int	ce_migration_cpu;
+	int	ce_migration_ticks;
+#endif
+};
+	
+/*
  * There is one struct callout_cpu per cpu, holding all relevant
  * state for the callout processing thread on the individual CPU.
  * In particular:
@@ -100,6 +119,7 @@ int callwheelsize, callwheelbits, callwh
  *	when the callout should be served.
  */
 struct callout_cpu {
+	struct cc_mig_ent	cc_migrating_entity;
 	struct mtx		cc_lock;
 	struct callout		*cc_callout;
 	struct callout_tailq	*cc_callwheel;
@@ -115,7 +135,13 @@ struct callout_cpu {
 };
 
 #ifdef SMP
+#define	cc_migration_func	cc_migrating_entity.ce_migration_func
+#define	cc_migration_arg	cc_migrating_entity.ce_migration_arg
+#define	cc_migration_cpu	cc_migrating_entity.ce_migration_cpu
+#define	cc_migration_ticks	cc_migrating_entity.ce_migration_ticks
+
 struct callout_cpu cc_cpu[MAXCPU];
+#define	CPUBLOCK	MAXCPU
 #define	CC_CPU(cpu)	(&cc_cpu[(cpu)])
 #define	CC_SELF()	CC_CPU(PCPU_GET(cpuid))
 #else
@@ -125,6 +151,7 @@ struct callout_cpu cc_cpu;
 #endif
 #define	CC_LOCK(cc)	mtx_lock_spin(&(cc)->cc_lock)
 #define	CC_UNLOCK(cc)	mtx_unlock_spin(&(cc)->cc_lock)
+#define	CC_LOCK_ASSERT(cc)	mtx_assert(&(cc)->cc_lock, MA_OWNED)
 
 static int timeout_cpu;
 void (*callout_new_inserted)(int cpu, int ticks) = NULL;
@@ -149,6 +176,35 @@ MALLOC_DEFINE(M_CALLOUT, "callout", "Cal
  */
 
 /*
+ * Resets the migration entity tied to a specific callout cpu.
+ */
+static void
+cc_cme_cleanup(struct callout_cpu *cc)
+{
+
+#ifdef SMP
+	cc->cc_migration_cpu = CPUBLOCK;
+	cc->cc_migration_ticks = 0;
+	cc->cc_migration_func = NULL;
+	cc->cc_migration_arg = NULL;
+#endif
+}
+
+/*
+ * Checks if migration is requested by a specific callout cpu.
+ */
+static int
+cc_cme_migrating(struct callout_cpu *cc)
+{
+
+#ifdef SMP
+	return (cc->cc_migration_cpu != CPUBLOCK);
+#else
+	return (0);
+#endif
+}
+
+/*
  * kern_timeout_callwheel_alloc() - kernel low level callwheel initialization 
  *
  *	This code is called very early in the kernel initialization sequence,
@@ -188,6 +244,7 @@ callout_cpu_init(struct callout_cpu *cc)
 	for (i = 0; i < callwheelsize; i++) {
 		TAILQ_INIT(&cc->cc_callwheel[i]);
 	}
+	cc_cme_cleanup(cc);
 	if (cc->cc_callout == NULL)
 		return;
 	for (i = 0; i < ncallout; i++) {
@@ -198,6 +255,29 @@ callout_cpu_init(struct callout_cpu *cc)
 	}
 }
 
+#ifdef SMP
+/*
+ * Switches the cpu tied to a specific callout.
+ * The function expects a locked incoming callout cpu and returns with
+ * locked outcoming callout cpu.
+ */
+static struct callout_cpu *
+callout_cpu_switch(struct callout *c, struct callout_cpu *cc, int new_cpu)
+{
+	struct callout_cpu *new_cc;
+
+	MPASS(c != NULL && cc != NULL);
+	CC_LOCK_ASSERT(cc);
+
+	c->c_cpu = CPUBLOCK;
+	CC_UNLOCK(cc);
+	new_cc = CC_CPU(new_cpu);
+	CC_LOCK(new_cc);
+	c->c_cpu = new_cpu;
+	return (new_cc);
+}
+#endif
+
 /*
  * kern_timeout_callwheel_init() - initialize previously reserved callwheel
  *				   space.
@@ -311,6 +391,13 @@ callout_lock(struct callout *c)
 
 	for (;;) {
 		cpu = c->c_cpu;
+#ifdef SMP
+		if (cpu == CPUBLOCK) {
+			while (c->c_cpu == CPUBLOCK)
+				cpu_spinwait();
+			continue;
+		}
+#endif
 		cc = CC_CPU(cpu);
 		CC_LOCK(cc);
 		if (cpu == c->c_cpu)
@@ -320,6 +407,29 @@ callout_lock(struct callout *c)
 	return (cc);
 }
 
+static void
+callout_cc_add(struct callout *c, struct callout_cpu *cc, int to_ticks,
+    void (*func)(void *), void *arg, int cpu)
+{
+
+	CC_LOCK_ASSERT(cc);
+
+	if (to_ticks <= 0)
+		to_ticks = 1;
+	c->c_arg = arg;
+	c->c_flags |= (CALLOUT_ACTIVE | CALLOUT_PENDING);
+	c->c_func = func;
+	c->c_time = ticks + to_ticks;
+	TAILQ_INSERT_TAIL(&cc->cc_callwheel[c->c_time & callwheelmask], 
+	    c, c_links.tqe);
+	if ((c->c_time - cc->cc_firsttick) < 0 &&
+	    callout_new_inserted != NULL) {
+		cc->cc_firsttick = c->c_time;
+		(*callout_new_inserted)(cpu,
+		    to_ticks + (ticks - cc->cc_ticks));
+	}
+}
+
 /*
  * The callout mechanism is based on the work of Adam M. Costello and 
  * George Varghese, published in a technical report entitled "Redesigning
@@ -497,14 +607,50 @@ softclock(void *arg)
 				}
 				cc->cc_curr = NULL;
 				if (cc->cc_waiting) {
+
 					/*
-					 * There is someone waiting
-					 * for the callout to complete.
+					 * There is someone waiting for the
+					 * callout to complete.
+					 * If the callout was scheduled for
+					 * migration just cancel it.
 					 */
+					if (cc_cme_migrating(cc))
+						cc_cme_cleanup(cc);
 					cc->cc_waiting = 0;
 					CC_UNLOCK(cc);
 					wakeup(&cc->cc_waiting);
 					CC_LOCK(cc);
+				} else if (cc_cme_migrating(cc)) {
+#ifdef SMP
+					struct callout_cpu *new_cc;
+					void (*new_func)(void *);
+					void *new_arg;
+					int new_cpu, new_ticks;
+
+					/*
+					 * If the callout was scheduled for
+					 * migration just perform it now.
+					 */
+					new_cpu = cc->cc_migration_cpu;
+					new_ticks = cc->cc_migration_ticks;
+					new_func = cc->cc_migration_func;
+					new_arg = cc->cc_migration_arg;
+					cc_cme_cleanup(cc);
+
+					/*
+					 * It should be assert here that the
+					 * callout is not destroyed but that
+					 * is not easy.
+					 */
+					new_cc = callout_cpu_switch(c, cc,
+					    new_cpu);
+					callout_cc_add(c, new_cc, new_ticks,
+					    new_func, new_arg, new_cpu);
+					CC_UNLOCK(new_cc);
+					CC_LOCK(cc);
+#else
+					panic("migration should not happen");
+#endif
 				}
 				steps = 0;
 				c = cc->cc_next;
@@ -617,7 +763,6 @@ callout_reset_on(struct callout *c, int 
 	 */
 	if (c->c_flags & CALLOUT_LOCAL_ALLOC)
 		cpu = c->c_cpu;
-retry:
 	cc = callout_lock(c);
 	if (cc->cc_curr == c) {
 		/*
@@ -649,31 +794,30 @@ retry:
 		cancelled = 1;
 		c->c_flags &= ~(CALLOUT_ACTIVE | CALLOUT_PENDING);
 	}
+
+#ifdef SMP
 	/*
-	 * If the lock must migrate we have to check the state again as
-	 * we can't hold both the new and old locks simultaneously.
+	 * If the callout must migrate try to perform it immediately.
+	 * If the callout is currently running, just defer the migration
+	 * to a more appropriate moment.
 	 */
 	if (c->c_cpu != cpu) {
-		c->c_cpu = cpu;
-		CC_UNLOCK(cc);
-		goto retry;
+		if (cc->cc_curr == c) {
+			cc->cc_migration_cpu = cpu;
+			cc->cc_migration_ticks = to_ticks;
+			cc->cc_migration_func = ftn;
+			cc->cc_migration_arg = arg;
+			CTR5(KTR_CALLOUT,
+		    "migration of %p func %p arg %p in %d to %u deferred",
+			    c, c->c_func, c->c_arg, to_ticks, cpu);
+			CC_UNLOCK(cc);
+			return (cancelled);
+		}
+		cc = callout_cpu_switch(c, cc, cpu);
 	}
+#endif
 
-	if (to_ticks <= 0)
-		to_ticks = 1;
-
-	c->c_arg = arg;
-	c->c_flags |= (CALLOUT_ACTIVE | CALLOUT_PENDING);
-	c->c_func = ftn;
-	c->c_time = ticks + to_ticks;
-	TAILQ_INSERT_TAIL(&cc->cc_callwheel[c->c_time & callwheelmask], 
-			  c, c_links.tqe);
-	if ((c->c_time - cc->cc_firsttick) < 0 &&
-	    callout_new_inserted != NULL) {
-		cc->cc_firsttick = c->c_time;
-		(*callout_new_inserted)(cpu,
-		    to_ticks + (ticks - cc->cc_ticks));
-	}
+	callout_cc_add(c, cc, to_ticks, ftn, arg, cpu);
 	CTR5(KTR_CALLOUT, "%sscheduled %p func %p arg %p in %d",
 	    cancelled ? "re" : "", c, c->c_func, c->c_arg, to_ticks);
 	CC_UNLOCK(cc);
@@ -701,7 +845,7 @@ _callout_stop_safe(c, safe)
 	struct	callout *c;
 	int	safe;
 {
-	struct callout_cpu *cc;
+	struct callout_cpu *cc, *old_cc;
 	struct lock_class *class;
 	int use_lock, sq_locked;
 
@@ -721,8 +865,27 @@ _callout_stop_safe(c, safe)
 		use_lock = 0;
 
 	sq_locked = 0;
+	old_cc = NULL;
 again:
 	cc = callout_lock(c);
+
+	/*
+	 * If the callout was migrating while the callout cpu lock was
+	 * dropped,  just drop the sleepqueue lock and check the states
+	 * again.
+	 */
+	if (sq_locked != 0 && cc != old_cc) {
+#ifdef SMP
+		CC_UNLOCK(cc);
+		sleepq_release(&old_cc->cc_waiting);
+		sq_locked = 0;
+		old_cc = NULL;
+		goto again;
+#else
+		panic("migration should not happen");
+#endif
+	}
+
 	/*
 	 * If the callout isn't pending, it's not on the queue, so
 	 * don't attempt to remove it from the queue.  We can try to
@@ -774,8 +937,16 @@ again:
 					CC_UNLOCK(cc);
 					sleepq_lock(&cc->cc_waiting);
 					sq_locked = 1;
+					old_cc = cc;
 					goto again;
 				}
+
+				/*
+				 * Migration could be cancelled here, but
+				 * as long as it is still not sure when it
+				 * will be packed up, just let softclock()
+				 * take care of it.
+				 */
 				cc->cc_waiting = 1;
 				DROP_GIANT();
 				CC_UNLOCK(cc);
@@ -784,6 +955,7 @@ again:
 				    SLEEPQ_SLEEP, 0);
 				sleepq_wait(&cc->cc_waiting, 0);
 				sq_locked = 0;
+				old_cc = NULL;
 
 				/* Reacquire locks previously released. */
 				PICKUP_GIANT();
@@ -800,6 +972,8 @@ again:
 			cc->cc_cancel = 1;
 			CTR3(KTR_CALLOUT, "cancelled %p func %p arg %p",
 			    c, c->c_func, c->c_arg);
+			KASSERT(!cc_cme_migrating(cc),
+			    ("callout wrongly scheduled for migration"));
 			CC_UNLOCK(cc);
 			KASSERT(!sq_locked, ("sleepqueue chain locked"));
 			return (1);

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 19:17:18 2011
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 2CC26106566B;
	Fri,  8 Apr 2011 19:17:18 +0000 (UTC)
	(envelope-from brde@optusnet.com.au)
Received: from mail03.syd.optusnet.com.au (mail03.syd.optusnet.com.au
	[211.29.132.184])
	by mx1.freebsd.org (Postfix) with ESMTP id A51988FC08;
	Fri,  8 Apr 2011 19:17:17 +0000 (UTC)
Received: from c122-106-155-58.carlnfd1.nsw.optusnet.com.au
	(c122-106-155-58.carlnfd1.nsw.optusnet.com.au [122.106.155.58])
	by mail03.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id
	p38JHD38013892
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Sat, 9 Apr 2011 05:17:14 +1000
Date: Sat, 9 Apr 2011 05:17:13 +1000 (EST)
From: Bruce Evans 
X-X-Sender: bde@besplex.bde.org
To: Jung-uk Kim 
In-Reply-To: <201104081317.41254.jkim@FreeBSD.org>
Message-ID: <20110409051607.I963@besplex.bde.org>
References: <201104072328.p37NSSsO055101@svn.freebsd.org>
	<20110408224855.Y1390@besplex.bde.org>
	<201104081317.41254.jkim@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, Bruce Evans 
Subject: Re: svn commit: r220433 - in head/sys: amd64/amd64
 cddl/dev/dtrace/amd64
 cddl/dev/dtrace/i386 compat/linprocfs contrib/altq/altq dev/acpica i386/i386
 i386/isa pc98/pc98 x86/cpufreq x86/isa 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, 08 Apr 2011 19:17:18 -0000

On Fri, 8 Apr 2011, Jung-uk Kim wrote:

> On Friday 08 April 2011 10:54 am, Bruce Evans wrote:
>> On Thu, 7 Apr 2011, Jung-uk Kim wrote:
>>> Log:
>>>  Use atomic load & store for TSC frequency.  It may be overkill
>>> for amd64 but safer for i386 because it can be easily over 4 GHz
>>> now.  More worse, it can be easily changed by user with
>>> 'machdep.tsc_freq' tunable (directly) or cpufreq(4) (indirectly).
>>> ...
>>
>> I disagree with this complexity and churn, and tried to avoid it --
>> see previous mails for more details.
>
> I don't like it myself.  It's sort of my way of expressing "do not use
> 64-bit global variables on 32-bit platforms unless the architecture
> guarantees coherency". ;-)
>
> Seriously, using variant TSC is strongly discouraged for timekeeping.
> Messing up with it from user land is worse.  If it is really
> necessary, it means kernel is broken and we need to fix it.

No, changing it from userland is the correct method.  It is to fix up
the kernel's miscalibration of the TSC (variant or otherwise).  Userland
can use long-running test where the kernel can only afford to do a
short sloppy test at boot time.  The kernel can use long-running tests
after boot time, but this gives complexity in the kernel.

>> There are probably many 64-bit variables that need to be accessed
>> more atomically, and tsc_freq is one of the least in need of atomic
>> accesses, since the race windows are especially tiny for it.  Even
>> when the race is lost, this is harmless except for frequencies that
>> are almost exactly 2^32 Hz, since only sysctls that change the
>> frequency from above this to below, or vice versa, can give an
>> inconsistent value. Thus there is a race window of a few nsec which
>> only matters with a probability of about 1 in 2^32, only for
>> user[s] of the sysctl to change the TSC frequency.
>
> powerd(8) via cpufreq(4) can change tsc_freq frequently if the CPU is
> not P-state invariant.  Well, the chances of getting ~4.3GHz CPU
> without P-state invariant TSC is little low, I guess.

:-).

Other changes to tsc_freq also break tuning by the sysctl.  My tuning
from userland actually determines the frequency by applying a constant
scale factor to a variable frequency from a table, but I only use this
on old machine which don't have cpufreq(4) etc., so I only do it once
at boot time and don't have to worry about cpufreq(4) messing it up.
(The frequency can be changed across boots by either reconfiguring the
BIOS, or on one machine, by using a CPU with a different frequency.
The scale factor for all this is constant because all clocks are derived
from a single clock in hardware.)  Applying a constant scale factor
to the frequencies set by cpufreq(4) should work in the same way, but
you have to know these frequencies accurately and could just use the
actual freqencies.

>> The complexity of this shows that you should try hard not to use
>> 64-bit variables on 32-bit systems if accesses to them are not
>> locked by a mutex.  64-bit systems like amd64 don't need to do
>> anything special, any more than 32-bit systems accessing 32-bit
>> variables.  We assume that accesses of <= the bus width are atomic
>> in a certain weak sense which is enough for variables like
>> tsc_freq.
>
> Actually, Pentium and above guarantees the "weak" atomic memory
> read/write when it is aligned to quad-word boundary.  CMPXCHG8B is
> the only one instruction (except for FPU) useful for that feature,
> though.  I considered implementing weaker version initially but I am
> not sure if it has any benefit.

I think this is a bit x86-specific, and having to do anything that
the compiler won't do automatically makes it too hard to use for an
average variable.  Does just using aligned FPU/MMX/XMM instructions
give atomic operations?

>> I thought of the following KPI-transparent method that can be used
>> for any struct if updates need not be seen immediately.  It is a
>> refined version of timehands method used for timecounters:
>>
>>  	#define	tsc_freq	_tsc_freq[_tsc_gen]
>
> It just hides the implementation.  How about this, then?
>
> #define	tsc_freq	atomic_load_acq_64(&_tsc_freq)
>
> :-P

Not quite the same, since the atomic op is heavyweight.  You used
lots of extra code to avoid multiple accesses to it.  The array
access is only slightly heavier weight than a variable access.
If there are multiple accesses, then _tsc_gen if not the whole
_tsc_freq[_tsc_gen] should be cached in a register.  Even extra
writes to these variables, and sfences, aren't a problem with 
my version, since they are only done in the unusual case where
the high bits are changed.

>> where the everything is updated sufficiently atomically and the
>> object data is guaranteed not to change for a suitably long time
>> after the generation that indexes it is read:
>>
>>  	if ((new_tsc_freq >> 32) == (tsc_freq >> 32)) {
>>  		/*
>>  		 * Usual case.  Below 2**32, or upper bits just not
>>  		 * changing.  No need for complications.
>>  		 */
>>  		tsc_freq = new_tsc_freq;
>>  	else if ((new_tsc_freq & 0xFFFFFFFF) == (tsc_freq & 0xFFFFFFFF))
>> { /*
>>  		 * Upper bits changing but lower bits not.  Very unusual,
>>  		 * and optimized here to give a place for this comment.
>>  		 * Again, no need for complications.
>>  		 */
>>  		tsc_freq = new_tsc_freq;
>>  	} else {

Perhaps your version can avoid the atomic op for the usual case of writing,
as above, but this isn't very useful since most accesses are reads which
need it.

>> ...
>
> You see the complexity is still there and I don't like it.

Yes, all this is a waste of time for just tsc_freq.  It may be needed
for other variables.

Bruce

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 19:54:30 2011
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 216A9106566B;
	Fri,  8 Apr 2011 19:54:30 +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 0FEE98FC17;
	Fri,  8 Apr 2011 19:54:30 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p38JsT5P090286;
	Fri, 8 Apr 2011 19:54:29 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p38JsTED090284;
	Fri, 8 Apr 2011 19:54:29 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104081954.p38JsTED090284@svn.freebsd.org>
From: Jung-uk Kim 
Date: Fri, 8 Apr 2011 19:54: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: r220459 - head/sys/x86/isa
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, 08 Apr 2011 19:54:30 -0000

Author: jkim
Date: Fri Apr  8 19:54:29 2011
New Revision: 220459
URL: http://svn.freebsd.org/changeset/base/220459

Log:
  Refactor DELAYDEBUG as it is only useful for correcting i8254 frequency.

Modified:
  head/sys/x86/isa/clock.c

Modified: head/sys/x86/isa/clock.c
==============================================================================
--- head/sys/x86/isa/clock.c	Fri Apr  8 19:08:48 2011	(r220458)
+++ head/sys/x86/isa/clock.c	Fri Apr  8 19:54:29 2011	(r220459)
@@ -245,6 +245,7 @@ getit(void)
 	return ((high << 8) | low);
 }
 
+#ifndef DELAYDEBUG
 static __inline void
 delay_tsc(int n, uint64_t freq)
 {
@@ -280,6 +281,7 @@ delay_timecounter(struct timecounter *tc
 		last = u;
 	} while (now < end);
 }
+#endif
 
 /*
  * Wait "n" microseconds.
@@ -289,15 +291,23 @@ delay_timecounter(struct timecounter *tc
 void
 DELAY(int n)
 {
-	struct timecounter *tc;
-	uint64_t freq;
 	int delta, prev_tick, tick, ticks_left;
-
 #ifdef DELAYDEBUG
 	int getit_calls = 1;
 	int n1;
 	static int state = 0;
-#endif
+
+	if (state == 0) {
+		state = 1;
+		for (n1 = 1; n1 <= 10000000; n1 *= 10)
+			DELAY(n1);
+		state = 2;
+	}
+	if (state == 1)
+		printf("DELAY(%d)...", n);
+#else
+	struct timecounter *tc;
+	uint64_t freq;
 
 	freq = atomic_load_acq_64(&tsc_freq);
 	if (freq != 0) {
@@ -309,15 +319,6 @@ DELAY(int n)
 		delay_timecounter(tc, n);
 		return;
 	}
-#ifdef DELAYDEBUG
-	if (state == 0) {
-		state = 1;
-		for (n1 = 1; n1 <= 10000000; n1 *= 10)
-			DELAY(n1);
-		state = 2;
-	}
-	if (state == 1)
-		printf("DELAY(%d)...", n);
 #endif
 	/*
 	 * Read the counter first, so that the rest of the setup overhead is

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 21:26:50 2011
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 7931D106566B;
	Fri,  8 Apr 2011 21:26:50 +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 682608FC08;
	Fri,  8 Apr 2011 21:26:50 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p38LQo6C092277;
	Fri, 8 Apr 2011 21:26:50 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p38LQoLH092275;
	Fri, 8 Apr 2011 21:26:50 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <201104082126.p38LQoLH092275@svn.freebsd.org>
From: Konstantin Belousov 
Date: Fri, 8 Apr 2011 21:26: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: r220460 - 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, 08 Apr 2011 21:26:50 -0000

Author: kib
Date: Fri Apr  8 21:26:50 2011
New Revision: 220460
URL: http://svn.freebsd.org/changeset/base/220460

Log:
  Disable local interrupts before testing the PCB_FULL_IRET flag.
  Thread might be preempted after testing, which causes the flag to be
  cleared. If ast was not delivered, we will do sysret with potentially
  wrong fs/gs bases.
  
  Reviewed by:	jhb, jkim
  MFC after:	1 week (together with r220430, r220452)

Modified:
  head/sys/amd64/amd64/exception.S

Modified: head/sys/amd64/amd64/exception.S
==============================================================================
--- head/sys/amd64/amd64/exception.S	Fri Apr  8 19:54:29 2011	(r220459)
+++ head/sys/amd64/amd64/exception.S	Fri Apr  8 21:26:50 2011	(r220460)
@@ -383,10 +383,11 @@ IDTVEC(fast_syscall)
 	movq	%rsp,%rdi
 	call	syscall
 1:	movq	PCPU(CURPCB),%rax
+	/* Disable interrupts before testing PCB_FULL_IRET. */
+	cli
 	testl	$PCB_FULL_IRET,PCB_FLAGS(%rax)
 	jnz	3f
 	/* Check for and handle AST's on return to userland. */
-	cli
 	movq	PCPU(CURTHREAD),%rax
 	testl	$TDF_ASTPENDING | TDF_NEEDRESCHED,TD_FLAGS(%rax)
 	je	2f

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 21:27:32 2011
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 01740106564A;
	Fri,  8 Apr 2011 21:27: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 E49C68FC20;
	Fri,  8 Apr 2011 21:27:31 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p38LRVqw092328;
	Fri, 8 Apr 2011 21:27:31 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p38LRVVu092326;
	Fri, 8 Apr 2011 21:27:31 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <201104082127.p38LRVVu092326@svn.freebsd.org>
From: Konstantin Belousov 
Date: Fri, 8 Apr 2011 21:27: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: r220461 - 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, 08 Apr 2011 21:27:32 -0000

Author: kib
Date: Fri Apr  8 21:27:31 2011
New Revision: 220461
URL: http://svn.freebsd.org/changeset/base/220461

Log:
  Remove setting of PCB_FULL_IRET at the places where we are going to call
  update_gdt_{f,g}sbase. The functions set the flag when td == curthread,
  and sysarch is always called with curthread.
  
  Reviewed by:	jhb, jkim
  MFC after:	1 week

Modified:
  head/sys/amd64/amd64/sys_machdep.c

Modified: head/sys/amd64/amd64/sys_machdep.c
==============================================================================
--- head/sys/amd64/amd64/sys_machdep.c	Fri Apr  8 21:26:50 2011	(r220460)
+++ head/sys/amd64/amd64/sys_machdep.c	Fri Apr  8 21:27:31 2011	(r220461)
@@ -243,7 +243,6 @@ sysarch(td, uap)
 		if (!error) {
 			pcb->pcb_fsbase = i386base;
 			td->td_frame->tf_fs = _ufssel;
-			set_pcb_flags(pcb, PCB_FULL_IRET);
 			update_gdt_fsbase(td, i386base);
 		}
 		break;
@@ -255,7 +254,6 @@ sysarch(td, uap)
 		error = copyin(uap->parms, &i386base, sizeof(i386base));
 		if (!error) {
 			pcb->pcb_gsbase = i386base;
-			set_pcb_flags(pcb, PCB_FULL_IRET);
 			td->td_frame->tf_gs = _ugssel;
 			update_gdt_gsbase(td, i386base);
 		}

From owner-svn-src-head@FreeBSD.ORG  Fri Apr  8 22:29:25 2011
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 40401106564A;
	Fri,  8 Apr 2011 22:29:25 +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 B7C3D8FC19;
	Fri,  8 Apr 2011 22:29:24 +0000 (UTC)
Received: from c122-106-155-58.carlnfd1.nsw.optusnet.com.au
	(c122-106-155-58.carlnfd1.nsw.optusnet.com.au [122.106.155.58])
	by mail04.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id
	p38MTLwu016611
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Sat, 9 Apr 2011 08:29:22 +1000
Date: Sat, 9 Apr 2011 08:29:21 +1000 (EST)
From: Bruce Evans 
X-X-Sender: bde@besplex.bde.org
To: Jung-uk Kim 
In-Reply-To: <201104081954.p38JsTED090284@svn.freebsd.org>
Message-ID: <20110409075110.L834@besplex.bde.org>
References: <201104081954.p38JsTED090284@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: r220459 - head/sys/x86/isa
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, 08 Apr 2011 22:29:25 -0000

On Fri, 8 Apr 2011, Jung-uk Kim wrote:

> Log:
>  Refactor DELAYDEBUG as it is only useful for correcting i8254 frequency.

Er, DELAYDEBUG has nothing to do with the i8254 except that the non-i8254
case was broken (mostly in unreachable code, and missing instrumentation
corresponding to the getit_calls counter).  Now it is more broken --
e.g., configuring DELAYDEBUG now prevents the non-i8254 timers from
even being compiled.

The core of DELAYDEBUG was essentially just:

 		for (n1 = 1; n1 <= 10000000; n1 *= 10) {
 			printf("DELAY(%d)...", n1);
 			DELAY(n1);
 			printf("done\n");
 		}

This could be in an extern function, and works for any implementation of
DELAY().  You observe the resulting delays and fix them if they are too
short or too long (the observation can only be done fairly accurately
for the 2 or 3 final delays of 1/10, 1 and 10 seconds, unless these are
very inaccurate).  But it is implemented as a special state in DELAY()
itself, with the printfs separate from the loop, for convenience and
to allow the printfs to print implementation-specific details.

Perhaps the complications for the state are not useful for debugging
the i8254 case now, since the i8254 has a fixed frequency and is well
understood and debugged.  The delay_timecounter() case doesn't even
need to be debugged at this level, since if the timecounter is broken
then this will be obvious from userland.  But the complications are
useful for the delay_tsc() case, since the TSC doesn't have a fixed
frequency and is often miscalibrated.

Bruce

From owner-svn-src-head@FreeBSD.ORG  Sat Apr  9 01:29:47 2011
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 5AFA3106564A;
	Sat,  9 Apr 2011 01:29:47 +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 33E068FC13;
	Sat,  9 Apr 2011 01:29:47 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p391TloG096972;
	Sat, 9 Apr 2011 01:29:47 GMT (envelope-from bz@svn.freebsd.org)
Received: (from bz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p391TlVJ096970;
	Sat, 9 Apr 2011 01:29:47 GMT (envelope-from bz@svn.freebsd.org)
Message-Id: <201104090129.p391TlVJ096970@svn.freebsd.org>
From: "Bjoern A. Zeeb" 
Date: Sat, 9 Apr 2011 01:29: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: r220462 - 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: Sat, 09 Apr 2011 01:29:47 -0000

Author: bz
Date: Sat Apr  9 01:29:46 2011
New Revision: 220462
URL: http://svn.freebsd.org/changeset/base/220462

Log:
  After r219579 and r219779 unbreak v4-mapped v6 sockets for UDP
  some more.  Similar to what we do for TCP check for v4-mapped
  addresses and then handle them or the normal v6 address case.
  For either set inp_vflags before calling into the pcb connect
  function so that we have an unambiguous view in case we need to
  set the local address or port.
  
  Looked at:	tuexen (as part of more)
  MFC after:	3 days

Modified:
  head/sys/netinet6/udp6_usrreq.c

Modified: head/sys/netinet6/udp6_usrreq.c
==============================================================================
--- head/sys/netinet6/udp6_usrreq.c	Fri Apr  8 21:27:31 2011	(r220461)
+++ head/sys/netinet6/udp6_usrreq.c	Sat Apr  9 01:29:46 2011	(r220462)
@@ -909,43 +909,41 @@ udp6_connect(struct socket *so, struct s
 
 	INP_INFO_WLOCK(&V_udbinfo);
 	INP_WLOCK(inp);
-	if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0 &&
-	    IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
+	if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
 		struct sockaddr_in sin;
 
+		if ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0) {
+			error = EINVAL;
+			goto out;
+		}
 		if (inp->inp_faddr.s_addr != INADDR_ANY) {
 			error = EISCONN;
 			goto out;
 		}
 		in6_sin6_2_sin(&sin, sin6);
+		inp->inp_vflag |= INP_IPV4;
+		inp->inp_vflag &= ~INP_IPV6;
 		error = prison_remote_ip4(td->td_ucred, &sin.sin_addr);
 		if (error != 0)
 			goto out;
 		error = in_pcbconnect(inp, (struct sockaddr *)&sin,
 		    td->td_ucred);
-		if (error == 0) {
-			inp->inp_vflag |= INP_IPV4;
-			inp->inp_vflag &= ~INP_IPV6;
+		if (error == 0)
 			soisconnected(so);
-		}
 		goto out;
 	}
 	if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
 		error = EISCONN;
 		goto out;
 	}
+	inp->inp_vflag &= ~INP_IPV4;
+	inp->inp_vflag |= INP_IPV6;
 	error = prison_remote_ip6(td->td_ucred, &sin6->sin6_addr);
 	if (error != 0)
 		goto out;
 	error = in6_pcbconnect(inp, nam, td->td_ucred);
-	if (error == 0) {
-		if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) {
-			/* should be non mapped addr */
-			inp->inp_vflag &= ~INP_IPV4;
-			inp->inp_vflag |= INP_IPV6;
-		}
+	if (error == 0)
 		soisconnected(so);
-	}
 out:
 	INP_WUNLOCK(inp);
 	INP_INFO_WUNLOCK(&V_udbinfo);

From owner-svn-src-head@FreeBSD.ORG  Sat Apr  9 02:22:49 2011
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 E838D106564A;
	Sat,  9 Apr 2011 02:22:49 +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 A02C08FC0A;
	Sat,  9 Apr 2011 02:22:49 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p392Mnn2097985;
	Sat, 9 Apr 2011 02:22:49 GMT (envelope-from bz@svn.freebsd.org)
Received: (from bz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p392MnJ1097983;
	Sat, 9 Apr 2011 02:22:49 GMT (envelope-from bz@svn.freebsd.org)
Message-Id: <201104090222.p392MnJ1097983@svn.freebsd.org>
From: "Bjoern A. Zeeb" 
Date: Sat, 9 Apr 2011 02:22: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: r220463 - 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: Sat, 09 Apr 2011 02:22:50 -0000

Author: bz
Date: Sat Apr  9 02:22:49 2011
New Revision: 220463
URL: http://svn.freebsd.org/changeset/base/220463

Log:
  Remove a check in udp6_send() that prevented v4-mapped v6 addresses from
  working.  We store v4 and v6 addresses as a union but for v4-mapped
  addresses only store the 32bits w/o the ::ffff: word.  That failed the
  check as for example 127.0.0.1 would be ::7f00:1 rather than ::ffff:7f00:1
  and the IN6_IS_ADDR_V4MAPPED() never worked here.  Given we can hardly get
  here with an unbound local address or invalid inp_vflags remove the check.
  
  Reported by:	tuexen
  Reviewed by:	tuexen
  MFC after:	3 days

Modified:
  head/sys/netinet6/udp6_usrreq.c

Modified: head/sys/netinet6/udp6_usrreq.c
==============================================================================
--- head/sys/netinet6/udp6_usrreq.c	Sat Apr  9 01:29:46 2011	(r220462)
+++ head/sys/netinet6/udp6_usrreq.c	Sat Apr  9 02:22:49 2011	(r220463)
@@ -1045,18 +1045,6 @@ udp6_send(struct socket *so, int flags, 
 		if (hasv4addr) {
 			struct pr_usrreqs *pru;
 
-			if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr) &&
-			    !IN6_IS_ADDR_V4MAPPED(&inp->in6p_laddr)) {
-				/*
-				 * When remote addr is IPv4-mapped address,
-				 * local addr should not be an IPv6 address;
-				 * since you cannot determine how to map IPv6
-				 * source address to IPv4.
-				 */
-				error = EINVAL;
-				goto out;
-			}
-
 			/*
 			 * XXXRW: We release UDP-layer locks before calling
 			 * udp_send() in order to avoid recursion.  However,
@@ -1081,7 +1069,6 @@ udp6_send(struct socket *so, int flags, 
 #endif
 	error = udp6_output(inp, m, addr, control, td);
 #ifdef INET
-out:
 #endif	
 	INP_WUNLOCK(inp);
 	INP_INFO_WUNLOCK(&V_udbinfo);

From owner-svn-src-head@FreeBSD.ORG  Sat Apr  9 07:42:25 2011
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 C05EF106566B;
	Sat,  9 Apr 2011 07:42:25 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id AF81F8FC15;
	Sat,  9 Apr 2011 07:42:25 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p397gPNe005029;
	Sat, 9 Apr 2011 07:42:25 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p397gPpF005025;
	Sat, 9 Apr 2011 07:42:25 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <201104090742.p397gPpF005025@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Sat, 9 Apr 2011 07: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: r220465 - in head: bin/setfacl lib/libc/posix1e 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, 09 Apr 2011 07:42:25 -0000

Author: trasz
Date: Sat Apr  9 07:42:25 2011
New Revision: 220465
URL: http://svn.freebsd.org/changeset/base/220465

Log:
  Make it possible to use permission sets (full_set, modify_set, read_set
  and write_set) with setfacl(1).
  
  PR:		kern/154113
  Submitted by:	Shawn Webb  (earlier version)
  MFC after:	1 month

Modified:
  head/bin/setfacl/setfacl.1
  head/lib/libc/posix1e/acl_support_nfs4.c
  head/sys/sys/acl.h

Modified: head/bin/setfacl/setfacl.1
==============================================================================
--- head/bin/setfacl/setfacl.1	Sat Apr  9 06:01:37 2011	(r220464)
+++ head/bin/setfacl/setfacl.1	Sat Apr  9 07:42:25 2011	(r220465)
@@ -1,5 +1,6 @@
 .\"-
 .\" Copyright (c) 2001 Chris D. Faulhaber
+.\" Copyright (c) 2011 Edward Tomasz Napierała
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -25,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 27, 2010
+.Dd April 9, 2011
 .Dt SETFACL 1
 .Os
 .Sh NAME
@@ -307,7 +308,7 @@ Permissions in long form are separated b
 .Ql /
 character; in short form, they are concatenated together.
 Valid permissions are:
-.Bl -tag -width ".Dv short"
+.Bl -tag -width ".Dv modify_set"
 .It Short
 Long
 .It r
@@ -339,6 +340,20 @@ write_owner
 .It S
 synchronize
 .El
+.Pp
+In addition, the following permission sets may be used:
+.Bl -tag -width ".Dv modify_set"
+.It Set
+Permissions
+.It full_set
+all permissions, as shown above
+.It modify_set
+all permissions except write_acl and write_owner
+.It read_set
+read_data, read_attributes, read_xattr and read_acl
+.It write_set
+write_data, append_data, write_attributes and write_xattr
+.El
 .It Ar "ACL inheritance flags"
 Inheritance flags may be specified in either short or long form.
 Short and long forms may not be mixed.

Modified: head/lib/libc/posix1e/acl_support_nfs4.c
==============================================================================
--- head/lib/libc/posix1e/acl_support_nfs4.c	Sat Apr  9 06:01:37 2011	(r220464)
+++ head/lib/libc/posix1e/acl_support_nfs4.c	Sat Apr  9 07:42:25 2011	(r220465)
@@ -70,6 +70,10 @@ struct flagnames_struct a_access_masks[]
      { ACL_WRITE_ACL, "write_acl", 'C'},
      { ACL_WRITE_OWNER, "write_owner", 'o'},
      { ACL_SYNCHRONIZE, "synchronize", 's'},
+     { ACL_FULL_SET, "full_set", '\0'},
+     { ACL_MODIFY_SET, "modify_set", '\0'},
+     { ACL_READ_SET, "read_set", '\0'},
+     { ACL_WRITE_SET, "write_set", '\0'},
      { 0, 0, 0}};
 
 static const char *
@@ -117,7 +121,7 @@ format_flags_compact(char *str, size_t s
 {
 	size_t i;
 
-	for (i = 0; flags[i].name != NULL; i++) {
+	for (i = 0; flags[i].letter != '\0'; i++) {
 		assert(i < size);
 		if ((flags[i].flag & var) == 0)
 			str[i] = '-';

Modified: head/sys/sys/acl.h
==============================================================================
--- head/sys/sys/acl.h	Sat Apr  9 06:01:37 2011	(r220464)
+++ head/sys/sys/acl.h	Sat Apr  9 07:42:25 2011	(r220465)
@@ -217,12 +217,23 @@ typedef void *acl_t;
 #define	ACL_WRITE_OWNER		0x00004000
 #define	ACL_SYNCHRONIZE		0x00008000
 
-#define	ACL_NFS4_PERM_BITS	(ACL_READ_DATA | ACL_WRITE_DATA | \
+#define	ACL_FULL_SET		(ACL_READ_DATA | ACL_WRITE_DATA | \
     ACL_APPEND_DATA | ACL_READ_NAMED_ATTRS | ACL_WRITE_NAMED_ATTRS | \
     ACL_EXECUTE | ACL_DELETE_CHILD | ACL_READ_ATTRIBUTES | \
     ACL_WRITE_ATTRIBUTES | ACL_DELETE | ACL_READ_ACL | ACL_WRITE_ACL | \
     ACL_WRITE_OWNER | ACL_SYNCHRONIZE)
 
+#define	ACL_MODIFY_SET		(ACL_FULL_SET & \
+    ~(ACL_WRITE_ACL | ACL_WRITE_OWNER))
+
+#define	ACL_READ_SET		(ACL_READ_DATA | ACL_READ_NAMED_ATTRS | \
+    ACL_READ_ATTRIBUTES | ACL_READ_ACL)
+
+#define	ACL_WRITE_SET		(ACL_WRITE_DATA | ACL_APPEND_DATA | \
+    ACL_WRITE_NAMED_ATTRS | ACL_WRITE_ATTRIBUTES)
+
+#define	ACL_NFS4_PERM_BITS	ACL_FULL_SET
+
 /*
  * Possible entry_id values for acl_get_entry(3).
  */

From owner-svn-src-head@FreeBSD.ORG  Sat Apr  9 09:07:31 2011
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 6D339106564A;
	Sat,  9 Apr 2011 09:07:31 +0000 (UTC) (envelope-from uqs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 5C56E8FC0A;
	Sat,  9 Apr 2011 09:07:31 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3997VVg007128;
	Sat, 9 Apr 2011 09:07:31 GMT (envelope-from uqs@svn.freebsd.org)
Received: (from uqs@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3997Vnc007125;
	Sat, 9 Apr 2011 09:07:31 GMT (envelope-from uqs@svn.freebsd.org)
Message-Id: <201104090907.p3997Vnc007125@svn.freebsd.org>
From: Ulrich Spoerlein 
Date: Sat, 9 Apr 2011 09:07: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: r220470 - in head/sys/modules: arcnet dtrace/dtraceall
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, 09 Apr 2011 09:07:31 -0000

Author: uqs
Date: Sat Apr  9 09:07:31 2011
New Revision: 220470
URL: http://svn.freebsd.org/changeset/base/220470

Log:
  Fix make buildworld -DMODULES_WITH_WORLD on i386

Modified:
  head/sys/modules/arcnet/Makefile
  head/sys/modules/dtrace/dtraceall/Makefile

Modified: head/sys/modules/arcnet/Makefile
==============================================================================
--- head/sys/modules/arcnet/Makefile	Sat Apr  9 08:52:22 2011	(r220469)
+++ head/sys/modules/arcnet/Makefile	Sat Apr  9 09:07:31 2011	(r220470)
@@ -4,7 +4,7 @@
 
 KMOD=	arcnet
 SRCS=	if_arcsubr.c
-SRCS+=	opt_inet.h opt_inet6.h opt_ipx.h
+SRCS+=	opt_inet.h opt_inet6.h opt_ipx.h opt_ofed.h
 
 EXPORT_SYMS=	arc_frag_init	\
 		arc_frag_next	\

Modified: head/sys/modules/dtrace/dtraceall/Makefile
==============================================================================
--- head/sys/modules/dtrace/dtraceall/Makefile	Sat Apr  9 08:52:22 2011	(r220469)
+++ head/sys/modules/dtrace/dtraceall/Makefile	Sat Apr  9 09:07:31 2011	(r220470)
@@ -6,8 +6,8 @@ SRCS=		dtraceall.c opt_compat.h
 CFLAGS+=	-I${.CURDIR}/../../..
 
 .if !defined(KERNBUILDDIR)
-opt_compat.h:
 .if ${MACHINE_ARCH} == "amd64"
+opt_compat.h:
 	echo "#define COMPAT_FREEBSD32 1" >> ${.TARGET}
 .endif
 .endif

From owner-svn-src-head@FreeBSD.ORG  Sat Apr  9 13:56:29 2011
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 C64CB106564A;
	Sat,  9 Apr 2011 13:56:29 +0000 (UTC)
	(envelope-from markm@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B36B38FC08;
	Sat,  9 Apr 2011 13:56:29 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p39DuTvE015989;
	Sat, 9 Apr 2011 13:56:29 GMT (envelope-from markm@svn.freebsd.org)
Received: (from markm@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p39DuTji015981;
	Sat, 9 Apr 2011 13:56:29 GMT (envelope-from markm@svn.freebsd.org)
Message-Id: <201104091356.p39DuTji015981@svn.freebsd.org>
From: Mark Murray 
Date: Sat, 9 Apr 2011 13:56: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: r220496 - head/lib/libmd
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, 09 Apr 2011 13:56:29 -0000

Author: markm
Date: Sat Apr  9 13:56:29 2011
New Revision: 220496
URL: http://svn.freebsd.org/changeset/base/220496

Log:
  Add SHA512 (Actually, this is Colin Percival's code for SHA256, with
  relevant constants changed).
  
  While I'm here clean up the tests and Makefile.
  
  PR:		misc/124164
  Submitted by:	KIMURA Yasuhiro < yasu utahime org >
  MFC after:	1 month

Added:
  head/lib/libmd/sha512.3   (contents, props changed)
  head/lib/libmd/sha512.h   (contents, props changed)
  head/lib/libmd/sha512c.c   (contents, props changed)
Modified:
  head/lib/libmd/Makefile
  head/lib/libmd/mddriver.c
  head/lib/libmd/rmddriver.c
  head/lib/libmd/shadriver.c

Modified: head/lib/libmd/Makefile
==============================================================================
--- head/lib/libmd/Makefile	Sat Apr  9 13:45:13 2011	(r220495)
+++ head/lib/libmd/Makefile	Sat Apr  9 13:56:29 2011	(r220496)
@@ -5,12 +5,13 @@ SHLIBDIR?= /lib
 SRCS=	md2c.c md4c.c md5c.c md2hl.c md4hl.c md5hl.c \
 	rmd160c.c rmd160hl.c \
 	sha0c.c sha0hl.c sha1c.c sha1hl.c \
-	sha256c.c sha256hl.c
-INCS=	md2.h md4.h md5.h ripemd.h sha.h sha256.h
+	sha256c.c sha256hl.c \
+	sha512c.c sha512hl.c
+INCS=	md2.h md4.h md5.h ripemd.h sha.h sha256.h sha512.h
 
 WARNS?=	0
 
-MAN+=	md2.3 md4.3 md5.3 ripemd.3 sha.3 sha256.3
+MAN+=	md2.3 md4.3 md5.3 ripemd.3 sha.3 sha256.3 sha512.3
 MLINKS+=md2.3 MD2Init.3 md2.3 MD2Update.3 md2.3 MD2Final.3
 MLINKS+=md2.3 MD2End.3  md2.3 MD2File.3   md2.3 MD2FileChunk.3
 MLINKS+=md2.3 MD2Data.3
@@ -34,10 +35,15 @@ MLINKS+=sha256.3 SHA256_Init.3  sha256.3
 MLINKS+=sha256.3 SHA256_Final.3 sha256.3 SHA256_End.3
 MLINKS+=sha256.3 SHA256_File.3  sha256.3 SHA256_FileChunk.3
 MLINKS+=sha256.3 SHA256_Data.3
+MLINKS+=sha512.3 SHA512_Init.3  sha512.3 SHA512_Update.3
+MLINKS+=sha512.3 SHA512_Final.3 sha512.3 SHA512_End.3
+MLINKS+=sha512.3 SHA512_File.3  sha512.3 SHA512_FileChunk.3
+MLINKS+=sha512.3 SHA512_Data.3
 CLEANFILES+=	md[245]hl.c md[245].ref md[245].3 mddriver \
 		rmd160.ref rmd160hl.c rmddriver \
 		sha0.ref sha0hl.c sha1.ref sha1hl.c shadriver \
-		sha256.ref sha256hl.c
+		sha256.ref sha256hl.c sha512.ref sha512hl.c
+
 CFLAGS+= -I${.CURDIR}
 .PATH: ${.CURDIR}/${MACHINE_ARCH}
 
@@ -81,6 +87,12 @@ sha256hl.c: mdXhl.c
 			-e  's/SHA256__/SHA256_/g' \
 		${.ALLSRC}) > ${.TARGET}
 
+sha512hl.c: mdXhl.c
+	(echo '#define LENGTH 64'; \
+		sed -e 's/mdX/sha512/g' -e 's/MDX/SHA512_/g'	\
+			-e  's/SHA512__/SHA512_/g' \
+		${.ALLSRC}) > ${.TARGET}
+
 rmd160hl.c: mdXhl.c
 	(echo '#define LENGTH 20'; \
 		sed -e 's/mdX/ripemd/g' -e 's/MDX/RIPEMD160_/g' \
@@ -110,8 +122,10 @@ md4.ref:
 	@echo 'MD4 ("abc") = a448017aaf21d8525fc10ae87aa6729d' >> ${.TARGET}
 	@echo 'MD4 ("message digest") = d9130a8164549fe818874806e1c7014b' >> ${.TARGET}
 	@echo 'MD4 ("abcdefghijklmnopqrstuvwxyz") = d79e1c308aa5bbcdeea8ed63df412da9' >> ${.TARGET}
-	@echo 'MD4 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") = 043f8582f241db351ce627e153e7f0e4' >> ${.TARGET}
-	@echo 'MD4 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = e33b4ddc9c38f2199c3e7b164fcc0536' >> ${.TARGET}
+	@echo 'MD4 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+		'043f8582f241db351ce627e153e7f0e4' >> ${.TARGET}
+	@echo 'MD4 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+		'e33b4ddc9c38f2199c3e7b164fcc0536' >> ${.TARGET}
 
 md5.ref:
 	echo 'MD5 test suite:' > ${.TARGET}
@@ -124,54 +138,74 @@ md5.ref:
 	@echo 'MD5 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = 57edf4a22be3c955ac49da2e2107b67a' >> ${.TARGET}
 
 sha0.ref:
-	(echo 'SHA-0 test suite:'; \
-	echo 'SHA-0 ("") = f96cea198ad1dd5617ac084a3d92c6107708c0ef'; \
-	echo 'SHA-0 ("abc") = 0164b8a914cd2a5e74c4f7ff082c4d97f1edf880'; \
-	echo 'SHA-0 ("message digest") =' \
-		'c1b0f222d150ebb9aa36a40cafdc8bcbed830b14'; \
-	echo 'SHA-0 ("abcdefghijklmnopqrstuvwxyz") =' \
-		'b40ce07a430cfd3c033039b9fe9afec95dc1bdcd'; \
-	echo 'SHA-0 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
-		'79e966f7a3a990df33e40e3d7f8f18d2caebadfa'; \
-	echo 'SHA-0 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
-		'4aa29d14d171522ece47bee8957e35a41f3e9cff' ) > ${.TARGET}
+	echo 'SHA-0 test suite:' > ${.TARGET}
+	@echo 'SHA-0 ("") = f96cea198ad1dd5617ac084a3d92c6107708c0ef' >> ${.TARGET}
+	@echo 'SHA-0 ("abc") = 0164b8a914cd2a5e74c4f7ff082c4d97f1edf880' >> ${.TARGET}
+	@echo 'SHA-0 ("message digest") =' \
+		'c1b0f222d150ebb9aa36a40cafdc8bcbed830b14' >> ${.TARGET}
+	@echo 'SHA-0 ("abcdefghijklmnopqrstuvwxyz") =' \
+		'b40ce07a430cfd3c033039b9fe9afec95dc1bdcd' >> ${.TARGET}
+	@echo 'SHA-0 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+		'79e966f7a3a990df33e40e3d7f8f18d2caebadfa' >> ${.TARGET}
+	@echo 'SHA-0 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+		'4aa29d14d171522ece47bee8957e35a41f3e9cff' >> ${.TARGET}
 
 sha1.ref:
-	(echo 'SHA-1 test suite:'; \
-	echo 'SHA-1 ("") = da39a3ee5e6b4b0d3255bfef95601890afd80709'; \
-	echo 'SHA-1 ("abc") = a9993e364706816aba3e25717850c26c9cd0d89d'; \
-	echo 'SHA-1 ("message digest") =' \
-		'c12252ceda8be8994d5fa0290a47231c1d16aae3'; \
-	echo 'SHA-1 ("abcdefghijklmnopqrstuvwxyz") =' \
-		'32d10c7b8cf96570ca04ce37f2a19d84240d3a89'; \
-	echo 'SHA-1 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
-		'761c457bf73b14d27e9e9265c46f4b4dda11f940'; \
-	echo 'SHA-1 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
-		'50abf5706a150990a08b2c5ea40fa0e585554732' ) > ${.TARGET}
+	echo 'SHA-1 test suite:' > ${.TARGET}
+	@echo 'SHA-1 ("") = da39a3ee5e6b4b0d3255bfef95601890afd80709' >> ${.TARGET}
+	@echo 'SHA-1 ("abc") = a9993e364706816aba3e25717850c26c9cd0d89d' >> ${.TARGET}
+	@echo 'SHA-1 ("message digest") =' \
+		'c12252ceda8be8994d5fa0290a47231c1d16aae3' >> ${.TARGET}
+	@echo 'SHA-1 ("abcdefghijklmnopqrstuvwxyz") =' \
+		'32d10c7b8cf96570ca04ce37f2a19d84240d3a89' >> ${.TARGET}
+	@echo 'SHA-1 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+		'761c457bf73b14d27e9e9265c46f4b4dda11f940' >> ${.TARGET}
+	@echo 'SHA-1 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+		'50abf5706a150990a08b2c5ea40fa0e585554732' >> ${.TARGET}
 
 sha256.ref:
 	echo 'SHA-256 test suite:' > ${.TARGET}
 	@echo 'SHA-256 ("") = e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' >> ${.TARGET}
-	@echo 'SHA-256 ("abc") = ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad' >> ${.TARGET}
-	@echo 'SHA-256 ("message digest") = f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650' >> ${.TARGET}
-	@echo 'SHA-256 ("abcdefghijklmnopqrstuvwxyz") = 71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73' >> ${.TARGET}
-	@echo 'SHA-256 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") = db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0' >> ${.TARGET}
-	@echo 'SHA-256 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = f371bc4a311f2b009eef952dd83ca80e2b60026c8e935592d0f9c308453c813e' >> ${.TARGET}
+	@echo 'SHA-256 ("abc") =' \
+		'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad' >> ${.TARGET}
+	@echo 'SHA-256 ("message digest") =' \
+		'f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650' >> ${.TARGET}
+	@echo 'SHA-256 ("abcdefghijklmnopqrstuvwxyz") =' \
+		'71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73' >> ${.TARGET}
+	@echo 'SHA-256 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+		'db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0' >> ${.TARGET}
+	@echo 'SHA-256 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+		'f371bc4a311f2b009eef952dd83ca80e2b60026c8e935592d0f9c308453c813e' >> ${.TARGET}
+
+sha512.ref:
+	echo 'SHA-512 test suite:' > ${.TARGET}
+	@echo 'SHA-512 ("") =' \
+		'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e' >> ${.TARGET}
+	@echo 'SHA-512 ("abc") =' \
+		'ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f' >> ${.TARGET}
+	@echo 'SHA-512 ("message digest") =' \
+		'107dbf389d9e9f71a3a95f6c055b9251bc5268c2be16d6c13492ea45b0199f3309e16455ab1e96118e8a905d5597b72038ddb372a89826046de66687bb420e7c' >> ${.TARGET}
+	@echo 'SHA-512 ("abcdefghijklmnopqrstuvwxyz") =' \
+		'4dbff86cc2ca1bae1e16468a05cb9881c97f1753bce3619034898faa1aabe429955a1bf8ec483d7421fe3c1646613a59ed5441fb0f321389f77f48a879c7b1f1' >> ${.TARGET}
+	@echo 'SHA-512 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+		'1e07be23c26a86ea37ea810c8ec7809352515a970e9253c26f536cfc7a9996c45c8370583e0a78fa4a90041d71a4ceab7423f19c71b9d5a3e01249f0bebd5894' >> ${.TARGET}
+	@echo 'SHA-512 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+		'72ec1ef1124a45b047e8b7c75a932195135bb61de24ec0d1914042246e0aec3a2354e093d76f3048b456764346900cb130d2a4fd5dd16abb5e30bcb850dee843' >> ${.TARGET}
 
 rmd160.ref:
-	(echo 'RIPEMD160 test suite:'; \
-	echo 'RIPEMD160 ("") = 9c1185a5c5e9fc54612808977ee8f548b2258d31'; \
-	echo 'RIPEMD160 ("abc") = 8eb208f7e05d987a9b044a8e98c6b087f15a0bfc'; \
-	echo 'RIPEMD160 ("message digest") =' \
-		'5d0689ef49d2fae572b881b123a85ffa21595f36'; \
-	echo 'RIPEMD160 ("abcdefghijklmnopqrstuvwxyz") =' \
-		'f71c27109c692c1b56bbdceb5b9d2865b3708dbc'; \
-	echo 'RIPEMD160 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
-		'b0e20b6e3116640286ed3a87a5713079b21f5189'; \
-	echo 'RIPEMD160 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
-		'9b752e45573d4b39f4dbd3323cab82bf63326bfb' ) > ${.TARGET}
+	echo 'RIPEMD160 test suite:' > ${.TARGET}
+	@echo 'RIPEMD160 ("") = 9c1185a5c5e9fc54612808977ee8f548b2258d31' >> ${.TARGET}
+	@echo 'RIPEMD160 ("abc") = 8eb208f7e05d987a9b044a8e98c6b087f15a0bfc' >> ${.TARGET}
+	@echo 'RIPEMD160 ("message digest") =' \
+		'5d0689ef49d2fae572b881b123a85ffa21595f36' >> ${.TARGET}
+	@echo 'RIPEMD160 ("abcdefghijklmnopqrstuvwxyz") =' \
+		'f71c27109c692c1b56bbdceb5b9d2865b3708dbc' >> ${.TARGET}
+	@echo 'RIPEMD160 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+		'b0e20b6e3116640286ed3a87a5713079b21f5189' >> ${.TARGET}
+	@echo 'RIPEMD160 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+		'9b752e45573d4b39f4dbd3323cab82bf63326bfb' >> ${.TARGET}
 
-test:	md2.ref md4.ref md5.ref sha0.ref rmd160.ref sha1.ref sha256.ref
+test:	md2.ref md4.ref md5.ref sha0.ref rmd160.ref sha1.ref sha256.ref sha512.ref
 	@${ECHO} if any of these test fail, the code produces wrong results
 	@${ECHO} and should NOT be used.
 	${CC} ${CFLAGS} ${LDFLAGS} -DMD=2 -o mddriver ${.CURDIR}/mddriver.c ./libmd.a
@@ -197,6 +231,9 @@ test:	md2.ref md4.ref md5.ref sha0.ref r
 	${CC} ${CFLAGS} ${LDFLAGS} -DSHA=256 -o shadriver ${.CURDIR}/shadriver.c libmd.a
 	./shadriver | cmp sha256.ref -
 	@${ECHO} SHA-256 passed test
+	${CC} ${CFLAGS} ${LDFLAGS} -DSHA=512 -o shadriver ${.CURDIR}/shadriver.c libmd.a
+	./shadriver | cmp sha512.ref -
+	@${ECHO} SHA-512 passed test
 	-rm -f shadriver
 
 .include 

Modified: head/lib/libmd/mddriver.c
==============================================================================
--- head/lib/libmd/mddriver.c	Sat Apr  9 13:45:13 2011	(r220495)
+++ head/lib/libmd/mddriver.c	Sat Apr  9 13:56:29 2011	(r220496)
@@ -1,33 +1,31 @@
-/* MDDRIVER.C - test driver for MD2, MD4 and MD5
- */
+/* MDDRIVER.C - test driver for MD2, MD4 and MD5 */
+
+/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
+ * reserved.
+ * 
+ * RSA Data Security, Inc. makes no representations concerning either the
+ * merchantability of this software or the suitability of this software for
+ * any particular purpose. It is provided "as is" without express or implied
+ * warranty of any kind.
+ * 
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software. */
 
 #include 
 __FBSDID("$FreeBSD$");
 
-/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All
-   rights reserved.
-
-   RSA Data Security, Inc. makes no representations concerning either
-   the merchantability of this software or the suitability of this
-   software for any particular purpose. It is provided "as is"
-   without express or implied warranty of any kind.
-
-   These notices must be retained in any copies of any part of this
-   documentation and/or software.
- */
-
-/* The following makes MD default to MD5 if it has not already been
-     defined with C compiler flags.
- */
-#ifndef MD
-#define MD 5
-#endif
-
 #include 
 
 #include 
 #include 
 #include 
+
+/* The following makes MD default to MD5 if it has not already been defined
+ * with C compiler flags. */
+#ifndef MD
+#define MD 5
+#endif
+
 #if MD == 2
 #include "md2.h"
 #define MDData MD2Data
@@ -41,32 +39,31 @@ __FBSDID("$FreeBSD$");
 #define MDData MD5Data
 #endif
 
-/* Digests a string and prints the result.
- */
-static void MDString (string)
-char *string;
+/* Digests a string and prints the result. */
+static void 
+MDString(char *string)
 {
-  char buf[33];
+	char buf[33];
 
-  printf ("MD%d (\"%s\") = %s\n", 
-	MD, string, MDData(string,strlen(string),buf));
+	printf("MD%d (\"%s\") = %s\n",
+	       MD, string, MDData(string, strlen(string), buf));
 }
 
-/* Digests a reference suite of strings and prints the results.
- */
-main()
+/* Digests a reference suite of strings and prints the results. */
+int
+main(void)
 {
-  printf ("MD%d test suite:\n", MD);
+	printf("MD%d test suite:\n", MD);
+
+	MDString("");
+	MDString("a");
+	MDString("abc");
+	MDString("message digest");
+	MDString("abcdefghijklmnopqrstuvwxyz");
+	MDString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+		"abcdefghijklmnopqrstuvwxyz0123456789");
+	MDString("1234567890123456789012345678901234567890"
+		"1234567890123456789012345678901234567890");
 
-  MDString ("");
-  MDString ("a");
-  MDString ("abc");
-  MDString ("message digest");
-  MDString ("abcdefghijklmnopqrstuvwxyz");
-  MDString
-    ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
-  MDString
-    ("1234567890123456789012345678901234567890\
-1234567890123456789012345678901234567890");
-  return 0;
+	return 0;
 }

Modified: head/lib/libmd/rmddriver.c
==============================================================================
--- head/lib/libmd/rmddriver.c	Sat Apr  9 13:45:13 2011	(r220495)
+++ head/lib/libmd/rmddriver.c	Sat Apr  9 13:56:29 2011	(r220496)
@@ -1,53 +1,51 @@
-/* RIPEMD160DRIVER.C - test driver for RIPEMD160
- */
+/* RIPEMD160DRIVER.C - test driver for RIPEMD160 */
+
+/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
+ * reserved.
+ * 
+ * RSA Data Security, Inc. makes no representations concerning either the
+ * merchantability of this software or the suitability of this software for
+ * any particular purpose. It is provided "as is" without express or implied
+ * warranty of any kind.
+ * 
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software. */
 
 #include 
 __FBSDID("$FreeBSD$");
 
-/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All
-   rights reserved.
-
-   RSA Data Security, Inc. makes no representations concerning either
-   the merchantability of this software or the suitability of this
-   software for any particular purpose. It is provided "as is"
-   without express or implied warranty of any kind.
-
-   These notices must be retained in any copies of any part of this
-   documentation and/or software.
- */
-
 #include 
 
 #include 
 #include 
 #include 
+
 #include "ripemd.h"
 
-/* Digests a string and prints the result.
- */
-static void RIPEMD160String (string)
-char *string;
+/* Digests a string and prints the result. */
+static void 
+RIPEMD160String(char *string)
 {
-  char buf[2*20+1];
+	char buf[2*20 + 1];
 
-  printf ("RIPEMD160 (\"%s\") = %s\n", 
-	string, RIPEMD160_Data(string,strlen(string),buf));
+	printf("RIPEMD160 (\"%s\") = %s\n",
+	       string, RIPEMD160_Data(string, strlen(string), buf));
 }
 
-/* Digests a reference suite of strings and prints the results.
- */
-main()
+/* Digests a reference suite of strings and prints the results. */
+int
+main(void)
 {
-  printf ("RIPEMD160 test suite:\n");
+	printf("RIPEMD160 test suite:\n");
+
+	RIPEMD160String("");
+	RIPEMD160String("abc");
+	RIPEMD160String("message digest");
+	RIPEMD160String("abcdefghijklmnopqrstuvwxyz");
+	RIPEMD160String("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+		"abcdefghijklmnopqrstuvwxyz0123456789");
+	RIPEMD160String("1234567890123456789012345678901234567890"
+		"1234567890123456789012345678901234567890");
 
-  RIPEMD160String ("");
-  RIPEMD160String ("abc");
-  RIPEMD160String ("message digest");
-  RIPEMD160String ("abcdefghijklmnopqrstuvwxyz");
-  RIPEMD160String
-    ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
-  RIPEMD160String
-    ("1234567890123456789012345678901234567890\
-1234567890123456789012345678901234567890");
-  return 0;
+	return 0;
 }

Added: head/lib/libmd/sha512.3
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lib/libmd/sha512.3	Sat Apr  9 13:56:29 2011	(r220496)
@@ -0,0 +1,139 @@
+.\"
+.\" ----------------------------------------------------------------------------
+.\" "THE BEER-WARE LICENSE" (Revision 42):
+.\"  wrote this file.  As long as you retain this notice you
+.\" can do whatever you want with this stuff. If we meet some day, and you think
+.\" this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
+.\" ----------------------------------------------------------------------------
+.\"
+.\" 	From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp
+.\" $FreeBSD$
+.\"
+.Dd April 1, 2011
+.Dt SHA512 3
+.Os
+.Sh NAME
+.Nm SHA512_Init ,
+.Nm SHA512_Update ,
+.Nm SHA512_Final ,
+.Nm SHA512_End ,
+.Nm SHA512_File ,
+.Nm SHA512_FileChunk ,
+.Nm SHA512_Data
+.Nd calculate the FIPS 180-2 ``SHA-512'' message digest
+.Sh LIBRARY
+.Lb libmd
+.Sh SYNOPSIS
+.In sys/types.h
+.In sha512.h
+.Ft void
+.Fn SHA512_Init "SHA512_CTX *context"
+.Ft void
+.Fn SHA512_Update "SHA512_CTX *context" "const unsigned char *data" "size_t len"
+.Ft void
+.Fn SHA512_Final "unsigned char digest[64]" "SHA512_CTX *context"
+.Ft "char *"
+.Fn SHA512_End "SHA512_CTX *context" "char *buf"
+.Ft "char *"
+.Fn SHA512_File "const char *filename" "char *buf"
+.Ft "char *"
+.Fn SHA512_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
+.Fn SHA512_Data "const unsigned char *data" "unsigned int len" "char *buf"
+.Sh DESCRIPTION
+The
+.Li SHA512_
+functions calculate a 512-bit cryptographic checksum (digest)
+for any number of input bytes.
+A cryptographic checksum is a one-way
+hash function; that is, it is computationally impractical to find
+the input corresponding to a particular output.
+This net result is
+a
+.Dq fingerprint
+of the input-data, which does not disclose the actual input.
+.Pp
+The
+.Fn SHA512_Init ,
+.Fn SHA512_Update ,
+and
+.Fn SHA512_Final
+functions are the core functions.
+Allocate an
+.Vt SHA512_CTX ,
+initialize it with
+.Fn SHA512_Init ,
+run over the data with
+.Fn SHA512_Update ,
+and finally extract the result using
+.Fn SHA512_Final .
+.Pp
+.Fn SHA512_End
+is a wrapper for
+.Fn SHA512_Final
+which converts the return value to a 65-character
+(including the terminating '\e0')
+.Tn ASCII
+string which represents the 512 bits in hexadecimal.
+.Pp
+.Fn SHA512_File
+calculates the digest of a file, and uses
+.Fn SHA512_End
+to return the result.
+If the file cannot be opened, a null pointer is returned.
+.Fn SHA512_FileChunk
+is similar to
+.Fn SHA512_File ,
+but it only calculates the digest over a byte-range of the file specified,
+starting at
+.Fa offset
+and spanning
+.Fa length
+bytes.
+If the
+.Fa length
+parameter is specified as 0, or more than the length of the remaining part
+of the file,
+.Fn SHA512_FileChunk
+calculates the digest from
+.Fa offset
+to the end of file.
+.Fn SHA512_Data
+calculates the digest of a chunk of data in memory, and uses
+.Fn SHA512_End
+to return the result.
+.Pp
+When using
+.Fn SHA512_End ,
+.Fn SHA512_File ,
+or
+.Fn SHA512_Data ,
+the
+.Fa buf
+argument can be a null pointer, in which case the returned string
+is allocated with
+.Xr malloc 3
+and subsequently must be explicitly deallocated using
+.Xr free 3
+after use.
+If the
+.Fa buf
+argument is non-null it must point to at least 65 characters of buffer space.
+.Sh SEE ALSO
+.Xr md2 3 ,
+.Xr md4 3 ,
+.Xr md5 3 ,
+.Xr ripemd 3 ,
+.Xr sha 3
+.Sh HISTORY
+These functions appeared in
+.Fx 4.0 .
+.Sh AUTHORS
+The core hash routines were implemented by Colin Percival based on
+the published
+.Tn FIPS 180-2
+standard.
+.Sh BUGS
+No method is known to exist which finds two files having the same hash value,
+nor to find a file with a specific hash value.
+There is on the other hand no guarantee that such a method does not exist.

Added: head/lib/libmd/sha512.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lib/libmd/sha512.h	Sat Apr  9 13:56:29 2011	(r220496)
@@ -0,0 +1,50 @@
+/*-
+ * Copyright 2005 Colin Percival
+ * 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$
+ */
+
+#ifndef _SHA512_H_
+#define _SHA512_H_
+
+#include 
+
+typedef struct SHA512Context {
+	uint64_t state[8];
+	uint64_t count[2];
+	unsigned char buf[128];
+} SHA512_CTX;
+
+__BEGIN_DECLS
+void	SHA512_Init(SHA512_CTX *);
+void	SHA512_Update(SHA512_CTX *, const void *, size_t);
+void	SHA512_Final(unsigned char [64], SHA512_CTX *);
+char   *SHA512_End(SHA512_CTX *, char *);
+char   *SHA512_File(const char *, char *);
+char   *SHA512_FileChunk(const char *, char *, off_t, off_t);
+char   *SHA512_Data(const void *, unsigned int, char *);
+__END_DECLS
+
+#endif /* !_SHA512_H_ */

Added: head/lib/libmd/sha512c.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lib/libmd/sha512c.c	Sat Apr  9 13:56:29 2011	(r220496)
@@ -0,0 +1,320 @@
+/*-
+ * Copyright 2005 Colin Percival
+ * 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.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+
+#include 
+
+#include "sha512.h"
+
+#if BYTE_ORDER == BIG_ENDIAN
+
+/* Copy a vector of big-endian uint64_t into a vector of bytes */
+#define be64enc_vect(dst, src, len)	\
+	memcpy((void *)dst, (const void *)src, (size_t)len)
+
+/* Copy a vector of bytes into a vector of big-endian uint64_t */
+#define be64dec_vect(dst, src, len)	\
+	memcpy((void *)dst, (const void *)src, (size_t)len)
+
+#else /* BYTE_ORDER != BIG_ENDIAN */
+
+/*
+ * Encode a length len/4 vector of (uint64_t) into a length len vector of
+ * (unsigned char) in big-endian form.  Assumes len is a multiple of 8.
+ */
+static void
+be64enc_vect(unsigned char *dst, const uint64_t *src, size_t len)
+{
+	size_t i;
+
+	for (i = 0; i < len / 8; i++)
+		be64enc(dst + i * 8, src[i]);
+}
+
+/*
+ * Decode a big-endian length len vector of (unsigned char) into a length
+ * len/4 vector of (uint64_t).  Assumes len is a multiple of 8.
+ */
+static void
+be64dec_vect(uint64_t *dst, const unsigned char *src, size_t len)
+{
+	size_t i;
+
+	for (i = 0; i < len / 8; i++)
+		dst[i] = be64dec(src + i * 8);
+}
+
+#endif /* BYTE_ORDER != BIG_ENDIAN */
+
+/* Elementary functions used by SHA512 */
+#define Ch(x, y, z)	((x & (y ^ z)) ^ z)
+#define Maj(x, y, z)	((x & (y | z)) | (y & z))
+#define SHR(x, n)	(x >> n)
+#define ROTR(x, n)	((x >> n) | (x << (64 - n)))
+#define S0(x)		(ROTR(x, 28) ^ ROTR(x, 34) ^ ROTR(x, 39))
+#define S1(x)		(ROTR(x, 14) ^ ROTR(x, 18) ^ ROTR(x, 41))
+#define s0(x)		(ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x, 7))
+#define s1(x)		(ROTR(x, 19) ^ ROTR(x, 61) ^ SHR(x, 6))
+
+/* SHA512 round function */
+#define RND(a, b, c, d, e, f, g, h, k)			\
+	t0 = h + S1(e) + Ch(e, f, g) + k;		\
+	t1 = S0(a) + Maj(a, b, c);			\
+	d += t0;					\
+	h  = t0 + t1;
+
+/* Adjusted round function for rotating state */
+#define RNDr(S, W, i, k)			\
+	RND(S[(80 - i) % 8], S[(81 - i) % 8],	\
+	    S[(82 - i) % 8], S[(83 - i) % 8],	\
+	    S[(84 - i) % 8], S[(85 - i) % 8],	\
+	    S[(86 - i) % 8], S[(87 - i) % 8],	\
+	    W[i] + k)
+
+/*
+ * SHA512 block compression function.  The 512-bit state is transformed via
+ * the 512-bit input block to produce a new state.
+ */
+static void
+SHA512_Transform(uint64_t * state, const unsigned char block[128])
+{
+	uint64_t W[80];
+	uint64_t S[8];
+	uint64_t t0, t1;
+	int i;
+
+	/* 1. Prepare message schedule W. */
+	be64dec_vect(W, block, 128);
+	for (i = 16; i < 80; i++)
+		W[i] = s1(W[i - 2]) + W[i - 7] + s0(W[i - 15]) + W[i - 16];
+
+	/* 2. Initialize working variables. */
+	memcpy(S, state, 64);
+
+	/* 3. Mix. */
+	RNDr(S, W, 0, 0x428a2f98d728ae22ULL);
+	RNDr(S, W, 1, 0x7137449123ef65cdULL);
+	RNDr(S, W, 2, 0xb5c0fbcfec4d3b2fULL);
+	RNDr(S, W, 3, 0xe9b5dba58189dbbcULL);
+	RNDr(S, W, 4, 0x3956c25bf348b538ULL);
+	RNDr(S, W, 5, 0x59f111f1b605d019ULL);
+	RNDr(S, W, 6, 0x923f82a4af194f9bULL);
+	RNDr(S, W, 7, 0xab1c5ed5da6d8118ULL);
+	RNDr(S, W, 8, 0xd807aa98a3030242ULL);
+	RNDr(S, W, 9, 0x12835b0145706fbeULL);
+	RNDr(S, W, 10, 0x243185be4ee4b28cULL);
+	RNDr(S, W, 11, 0x550c7dc3d5ffb4e2ULL);
+	RNDr(S, W, 12, 0x72be5d74f27b896fULL);
+	RNDr(S, W, 13, 0x80deb1fe3b1696b1ULL);
+	RNDr(S, W, 14, 0x9bdc06a725c71235ULL);
+	RNDr(S, W, 15, 0xc19bf174cf692694ULL);
+	RNDr(S, W, 16, 0xe49b69c19ef14ad2ULL);
+	RNDr(S, W, 17, 0xefbe4786384f25e3ULL);
+	RNDr(S, W, 18, 0x0fc19dc68b8cd5b5ULL);
+	RNDr(S, W, 19, 0x240ca1cc77ac9c65ULL);
+	RNDr(S, W, 20, 0x2de92c6f592b0275ULL);
+	RNDr(S, W, 21, 0x4a7484aa6ea6e483ULL);
+	RNDr(S, W, 22, 0x5cb0a9dcbd41fbd4ULL);
+	RNDr(S, W, 23, 0x76f988da831153b5ULL);
+	RNDr(S, W, 24, 0x983e5152ee66dfabULL);
+	RNDr(S, W, 25, 0xa831c66d2db43210ULL);
+	RNDr(S, W, 26, 0xb00327c898fb213fULL);
+	RNDr(S, W, 27, 0xbf597fc7beef0ee4ULL);
+	RNDr(S, W, 28, 0xc6e00bf33da88fc2ULL);
+	RNDr(S, W, 29, 0xd5a79147930aa725ULL);
+	RNDr(S, W, 30, 0x06ca6351e003826fULL);
+	RNDr(S, W, 31, 0x142929670a0e6e70ULL);
+	RNDr(S, W, 32, 0x27b70a8546d22ffcULL);
+	RNDr(S, W, 33, 0x2e1b21385c26c926ULL);
+	RNDr(S, W, 34, 0x4d2c6dfc5ac42aedULL);
+	RNDr(S, W, 35, 0x53380d139d95b3dfULL);
+	RNDr(S, W, 36, 0x650a73548baf63deULL);
+	RNDr(S, W, 37, 0x766a0abb3c77b2a8ULL);
+	RNDr(S, W, 38, 0x81c2c92e47edaee6ULL);
+	RNDr(S, W, 39, 0x92722c851482353bULL);
+	RNDr(S, W, 40, 0xa2bfe8a14cf10364ULL);
+	RNDr(S, W, 41, 0xa81a664bbc423001ULL);
+	RNDr(S, W, 42, 0xc24b8b70d0f89791ULL);
+	RNDr(S, W, 43, 0xc76c51a30654be30ULL);
+	RNDr(S, W, 44, 0xd192e819d6ef5218ULL);
+	RNDr(S, W, 45, 0xd69906245565a910ULL);
+	RNDr(S, W, 46, 0xf40e35855771202aULL);
+	RNDr(S, W, 47, 0x106aa07032bbd1b8ULL);
+	RNDr(S, W, 48, 0x19a4c116b8d2d0c8ULL);
+	RNDr(S, W, 49, 0x1e376c085141ab53ULL);
+	RNDr(S, W, 50, 0x2748774cdf8eeb99ULL);
+	RNDr(S, W, 51, 0x34b0bcb5e19b48a8ULL);
+	RNDr(S, W, 52, 0x391c0cb3c5c95a63ULL);
+	RNDr(S, W, 53, 0x4ed8aa4ae3418acbULL);
+	RNDr(S, W, 54, 0x5b9cca4f7763e373ULL);
+	RNDr(S, W, 55, 0x682e6ff3d6b2b8a3ULL);
+	RNDr(S, W, 56, 0x748f82ee5defb2fcULL);
+	RNDr(S, W, 57, 0x78a5636f43172f60ULL);
+	RNDr(S, W, 58, 0x84c87814a1f0ab72ULL);
+	RNDr(S, W, 59, 0x8cc702081a6439ecULL);
+	RNDr(S, W, 60, 0x90befffa23631e28ULL);
+	RNDr(S, W, 61, 0xa4506cebde82bde9ULL);
+	RNDr(S, W, 62, 0xbef9a3f7b2c67915ULL);
+	RNDr(S, W, 63, 0xc67178f2e372532bULL);
+	RNDr(S, W, 64, 0xca273eceea26619cULL);
+	RNDr(S, W, 65, 0xd186b8c721c0c207ULL);
+	RNDr(S, W, 66, 0xeada7dd6cde0eb1eULL);
+	RNDr(S, W, 67, 0xf57d4f7fee6ed178ULL);
+	RNDr(S, W, 68, 0x06f067aa72176fbaULL);
+	RNDr(S, W, 69, 0x0a637dc5a2c898a6ULL);
+	RNDr(S, W, 70, 0x113f9804bef90daeULL);
+	RNDr(S, W, 71, 0x1b710b35131c471bULL);
+	RNDr(S, W, 72, 0x28db77f523047d84ULL);
+	RNDr(S, W, 73, 0x32caab7b40c72493ULL);
+	RNDr(S, W, 74, 0x3c9ebe0a15c9bebcULL);
+	RNDr(S, W, 75, 0x431d67c49c100d4cULL);
+	RNDr(S, W, 76, 0x4cc5d4becb3e42b6ULL);
+	RNDr(S, W, 77, 0x597f299cfc657e2aULL);
+	RNDr(S, W, 78, 0x5fcb6fab3ad6faecULL);
+	RNDr(S, W, 79, 0x6c44198c4a475817ULL);
+
+	/* 4. Mix local working variables into global state */
+	for (i = 0; i < 8; i++)
+		state[i] += S[i];
+}
+
+static unsigned char PAD[128] = {
+	0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/* Add padding and terminating bit-count. */
+static void
+SHA512_Pad(SHA512_CTX * ctx)
+{
+	unsigned char len[16];
+	uint64_t r, plen;
+
+	/*
+	 * Convert length to a vector of bytes -- we do this now rather
+	 * than later because the length will change after we pad.
+	 */
+	be64enc_vect(len, ctx->count, 16);
+
+	/* Add 1--128 bytes so that the resulting length is 112 mod 128 */
+	r = (ctx->count[1] >> 3) & 0x7f;
+	plen = (r < 112) ? (112 - r) : (240 - r);
+	SHA512_Update(ctx, PAD, (size_t)plen);
+
+	/* Add the terminating bit-count */
+	SHA512_Update(ctx, len, 16);
+}
+
+/* SHA-512 initialization.  Begins a SHA-512 operation. */
+void
+SHA512_Init(SHA512_CTX * ctx)
+{
+
+	/* Zero bits processed so far */
+	ctx->count[0] = ctx->count[1] = 0;
+
+	/* Magic initialization constants */
+	ctx->state[0] = 0x6a09e667f3bcc908ULL;
+	ctx->state[1] = 0xbb67ae8584caa73bULL;
+	ctx->state[2] = 0x3c6ef372fe94f82bULL;
+	ctx->state[3] = 0xa54ff53a5f1d36f1ULL;
+	ctx->state[4] = 0x510e527fade682d1ULL;
+	ctx->state[5] = 0x9b05688c2b3e6c1fULL;
+	ctx->state[6] = 0x1f83d9abfb41bd6bULL;
+	ctx->state[7] = 0x5be0cd19137e2179ULL;
+}
+
+/* Add bytes into the hash */
+void
+SHA512_Update(SHA512_CTX * ctx, const void *in, size_t len)
+{
+	uint64_t bitlen[2];
+	uint64_t r;
+	const unsigned char *src = in;
+
+	/* Number of bytes left in the buffer from previous updates */
+	r = (ctx->count[1] >> 3) & 0x7f;
+
+	/* Convert the length into a number of bits */
+	bitlen[1] = ((uint64_t)len) << 3;
+	bitlen[0] = ((uint64_t)len) >> 61;
+
+	/* Update number of bits */
+	if ((ctx->count[1] += bitlen[1]) < bitlen[1])
+		ctx->count[0]++;
+	ctx->count[0] += bitlen[0];
+
+	/* Handle the case where we don't need to perform any transforms */
+	if (len < 128 - r) {
+		memcpy(&ctx->buf[r], src, len);
+		return;
+	}
+
+	/* Finish the current block */
+	memcpy(&ctx->buf[r], src, 128 - r);
+	SHA512_Transform(ctx->state, ctx->buf);
+	src += 128 - r;
+	len -= 128 - r;
+
+	/* Perform complete blocks */
+	while (len >= 128) {
+		SHA512_Transform(ctx->state, src);
+		src += 128;
+		len -= 128;
+	}
+
+	/* Copy left over data into buffer */
+	memcpy(ctx->buf, src, len);
+}
+
+/*
+ * SHA-512 finalization.  Pads the input data, exports the hash value,
+ * and clears the context state.
+ */
+void
+SHA512_Final(unsigned char digest[64], SHA512_CTX * ctx)
+{
+
+	/* Add padding */
+	SHA512_Pad(ctx);
+
+	/* Write the hash */
+	be64enc_vect(digest, ctx->state, 64);
+
+	/* Clear the context state */
+	memset((void *)ctx, 0, sizeof(*ctx));
+}

Modified: head/lib/libmd/shadriver.c
==============================================================================
--- head/lib/libmd/shadriver.c	Sat Apr  9 13:45:13 2011	(r220495)
+++ head/lib/libmd/shadriver.c	Sat Apr  9 13:56:29 2011	(r220496)
@@ -1,66 +1,67 @@
-/* SHADRIVER.C - test driver for SHA-1 (and SHA-0)
- */
+/* SHADRIVER.C - test driver for SHA-1 (and SHA-2) */
+
+/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
+ * reserved.
+ * 
+ * RSA Data Security, Inc. makes no representations concerning either the
+ * merchantability of this software or the suitability of this software for
+ * any particular purpose. It is provided "as is" without express or implied
+ * warranty of any kind.
+ * 
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software. */
 
 #include 
 __FBSDID("$FreeBSD$");
 
-/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All
-   rights reserved.
-
-   RSA Data Security, Inc. makes no representations concerning either
-   the merchantability of this software or the suitability of this
-   software for any particular purpose. It is provided "as is"
-   without express or implied warranty of any kind.
-
-   These notices must be retained in any copies of any part of this
-   documentation and/or software.
- */
-
-/* The following makes SHA default to SHA-1 if it has not already been
-     defined with C compiler flags.
- */
-#ifndef SHA
-#define SHA 1
-#endif
-
 #include 
 
 #include 
 #include 
 #include 
+
 #include "sha.h"
 #include "sha256.h"
+#include "sha512.h"
+
+/* The following makes SHA default to SHA-1 if it has not already been
+ * defined with C compiler flags. */
+#ifndef SHA
+#define SHA 1
+#endif
+
 #if SHA == 1
 #define SHA_Data SHA1_Data
 #elif SHA == 256
 #define SHA_Data SHA256_Data
+#elif SHA == 512
+#define SHA_Data SHA512_Data
 #endif
 
-/* Digests a string and prints the result.
- */
-static void SHAString (string)
-char *string;
+/* Digests a string and prints the result. */
+static void
+SHAString(char *string)
 {
-  char buf[2*32+1];
+	char buf[2*64 + 1];
 
-  printf ("SHA-%d (\"%s\") = %s\n", 
-	SHA, string, SHA_Data(string,strlen(string),buf));
+	printf("SHA-%d (\"%s\") = %s\n",
+	       SHA, string, SHA_Data(string, strlen(string), buf));
 }
 
-/* Digests a reference suite of strings and prints the results.
- */
-main()
+/* Digests a reference suite of strings and prints the results. */
+int
+main(void)
 {
-  printf ("SHA-%d test suite:\n", SHA);
+	printf("SHA-%d test suite:\n", SHA);
+
+	SHAString("");
+	SHAString("abc");
+	SHAString("message digest");
+	SHAString("abcdefghijklmnopqrstuvwxyz");
+	SHAString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+		  "abcdefghijklmnopqrstuvwxyz0123456789");
+	SHAString("1234567890123456789012345678901234567890"

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-head@FreeBSD.ORG  Sat Apr  9 14:02:04 2011
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 561321065670;
	Sat,  9 Apr 2011 14:02:04 +0000 (UTC)
	(envelope-from markm@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 427D48FC13;
	Sat,  9 Apr 2011 14:02:04 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p39E24Ec016163;
	Sat, 9 Apr 2011 14:02:04 GMT (envelope-from markm@svn.freebsd.org)
Received: (from markm@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p39E24bm016157;
	Sat, 9 Apr 2011 14:02:04 GMT (envelope-from markm@svn.freebsd.org)
Message-Id: <201104091402.p39E24bm016157@svn.freebsd.org>
From: Mark Murray 
Date: Sat, 9 Apr 2011 14:02: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: r220497 - head/lib/libcrypt
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, 09 Apr 2011 14:02:04 -0000

Author: markm
Date: Sat Apr  9 14:02:04 2011
New Revision: 220497
URL: http://svn.freebsd.org/changeset/base/220497

Log:
  Add SHA256/512 ($5$ and $6$) to crypt(3). Used in linux-world, doesn't
  hurt us.
  
  PR:		misc/124164
  Submitted by:	KIMURA Yasuhiro < yasu utahime org >
  MFC after:	1 month

Added:
  head/lib/libcrypt/crypt-sha256.c   (contents, props changed)
  head/lib/libcrypt/crypt-sha512.c   (contents, props changed)
Modified:
  head/lib/libcrypt/Makefile
  head/lib/libcrypt/crypt.c
  head/lib/libcrypt/crypt.h
  head/lib/libcrypt/misc.c

Modified: head/lib/libcrypt/Makefile
==============================================================================
--- head/lib/libcrypt/Makefile	Sat Apr  9 13:56:29 2011	(r220496)
+++ head/lib/libcrypt/Makefile	Sat Apr  9 14:02:04 2011	(r220497)
@@ -12,7 +12,9 @@ LIB=		crypt
 .PATH:		${.CURDIR}/../libmd
 SRCS=		crypt.c misc.c \
 		crypt-md5.c md5c.c \
-		crypt-nthash.c md4c.c
+		crypt-nthash.c md4c.c \
+		crypt-sha256.c sha256c.c \
+		crypt-sha512.c sha512c.c
 MAN=		crypt.3
 MLINKS=		crypt.3 crypt_get_format.3 crypt.3 crypt_set_format.3
 CFLAGS+=	-I${.CURDIR}/../libmd -I${.CURDIR}/../libutil

Added: head/lib/libcrypt/crypt-sha256.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lib/libcrypt/crypt-sha256.c	Sat Apr  9 14:02:04 2011	(r220497)
@@ -0,0 +1,477 @@
+/*
+ * Copyright (c) 2011 The FreeBSD Project. 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.
+ */
+
+/* Based on:
+ * SHA256-based Unix crypt implementation. Released into the Public Domain by
+ * Ulrich Drepper . */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "crypt.h"
+
+/* Define our magic string to mark salt for SHA256 "encryption" replacement. */
+static const char sha256_salt_prefix[] = "$5$";
+
+/* Prefix for optional rounds specification. */
+static const char sha256_rounds_prefix[] = "rounds=";
+
+/* Maximum salt string length. */
+#define SALT_LEN_MAX 16
+/* Default number of rounds if not explicitly specified. */
+#define ROUNDS_DEFAULT 5000
+/* Minimum number of rounds. */
+#define ROUNDS_MIN 1000
+/* Maximum number of rounds. */
+#define ROUNDS_MAX 999999999
+
+static char *
+sha256_crypt_r(const char *key, const char *salt, char *buffer, int buflen)
+{
+	u_long srounds;
+	int n;
+	uint8_t alt_result[32], temp_result[32];
+	SHA256_CTX ctx, alt_ctx;
+	size_t salt_len, key_len, cnt, rounds;
+	char *cp, *copied_key, *copied_salt, *p_bytes, *s_bytes, *endp;
+	const char *num;
+	bool rounds_custom;
+
+	copied_key = NULL;
+	copied_salt = NULL;
+
+	/* Default number of rounds. */
+	rounds = ROUNDS_DEFAULT;
+	rounds_custom = false;
+
+	/* Find beginning of salt string. The prefix should normally always
+	 * be present. Just in case it is not. */
+	if (strncmp(sha256_salt_prefix, salt, sizeof(sha256_salt_prefix) - 1) == 0)
+		/* Skip salt prefix. */
+		salt += sizeof(sha256_salt_prefix) - 1;
+
+	if (strncmp(salt, sha256_rounds_prefix, sizeof(sha256_rounds_prefix) - 1)
+	    == 0) {
+		num = salt + sizeof(sha256_rounds_prefix) - 1;
+		srounds = strtoul(num, &endp, 10);
+
+		if (*endp == '$') {
+			salt = endp + 1;
+			rounds = MAX(ROUNDS_MIN, MIN(srounds, ROUNDS_MAX));
+			rounds_custom = true;
+		}
+	}
+
+	salt_len = MIN(strcspn(salt, "$"), SALT_LEN_MAX);
+	key_len = strlen(key);
+
+	/* Prepare for the real work. */
+	SHA256_Init(&ctx);
+
+	/* Add the key string. */
+	SHA256_Update(&ctx, key, key_len);
+
+	/* The last part is the salt string. This must be at most 8
+	 * characters and it ends at the first `$' character (for
+	 * compatibility with existing implementations). */
+	SHA256_Update(&ctx, salt, salt_len);
+
+	/* Compute alternate SHA256 sum with input KEY, SALT, and KEY. The
+	 * final result will be added to the first context. */
+	SHA256_Init(&alt_ctx);
+
+	/* Add key. */
+	SHA256_Update(&alt_ctx, key, key_len);
+
+	/* Add salt. */
+	SHA256_Update(&alt_ctx, salt, salt_len);
+
+	/* Add key again. */
+	SHA256_Update(&alt_ctx, key, key_len);
+
+	/* Now get result of this (32 bytes) and add it to the other context. */
+	SHA256_Final(alt_result, &alt_ctx);
+
+	/* Add for any character in the key one byte of the alternate sum. */
+	for (cnt = key_len; cnt > 32; cnt -= 32)
+		SHA256_Update(&ctx, alt_result, 32);
+	SHA256_Update(&ctx, alt_result, cnt);
+
+	/* Take the binary representation of the length of the key and for
+	 * every 1 add the alternate sum, for every 0 the key. */
+	for (cnt = key_len; cnt > 0; cnt >>= 1)
+		if ((cnt & 1) != 0)
+			SHA256_Update(&ctx, alt_result, 32);
+		else
+			SHA256_Update(&ctx, key, key_len);
+
+	/* Create intermediate result. */
+	SHA256_Final(alt_result, &ctx);
+
+	/* Start computation of P byte sequence. */
+	SHA256_Init(&alt_ctx);
+
+	/* For every character in the password add the entire password. */
+	for (cnt = 0; cnt < key_len; ++cnt)
+		SHA256_Update(&alt_ctx, key, key_len);
+
+	/* Finish the digest. */
+	SHA256_Final(temp_result, &alt_ctx);
+
+	/* Create byte sequence P. */
+	cp = p_bytes = alloca(key_len);
+	for (cnt = key_len; cnt >= 32; cnt -= 32) {
+		memcpy(cp, temp_result, 32);
+		cp += 32;
+	}
+	memcpy(cp, temp_result, cnt);
+
+	/* Start computation of S byte sequence. */
+	SHA256_Init(&alt_ctx);
+
+	/* For every character in the password add the entire password. */
+	for (cnt = 0; cnt < 16 + alt_result[0]; ++cnt)
+		SHA256_Update(&alt_ctx, salt, salt_len);
+
+	/* Finish the digest. */
+	SHA256_Final(temp_result, &alt_ctx);
+
+	/* Create byte sequence S. */
+	cp = s_bytes = alloca(salt_len);
+	for (cnt = salt_len; cnt >= 32; cnt -= 32) {
+		memcpy(cp, temp_result, 32);
+		cp += 32;
+	}
+	memcpy(cp, temp_result, cnt);
+
+	/* Repeatedly run the collected hash value through SHA256 to burn CPU
+	 * cycles. */
+	for (cnt = 0; cnt < rounds; ++cnt) {
+		/* New context. */
+		SHA256_Init(&ctx);
+
+		/* Add key or last result. */
+		if ((cnt & 1) != 0)
+			SHA256_Update(&ctx, p_bytes, key_len);
+		else
+			SHA256_Update(&ctx, alt_result, 32);
+
+		/* Add salt for numbers not divisible by 3. */
+		if (cnt % 3 != 0)
+			SHA256_Update(&ctx, s_bytes, salt_len);
+
+		/* Add key for numbers not divisible by 7. */
+		if (cnt % 7 != 0)
+			SHA256_Update(&ctx, p_bytes, key_len);
+
+		/* Add key or last result. */
+		if ((cnt & 1) != 0)
+			SHA256_Update(&ctx, alt_result, 32);
+		else
+			SHA256_Update(&ctx, p_bytes, key_len);
+
+		/* Create intermediate result. */
+		SHA256_Final(alt_result, &ctx);
+	}
+
+	/* Now we can construct the result string. It consists of three
+	 * parts. */
+	cp = stpncpy(buffer, sha256_salt_prefix, MAX(0, buflen));
+	buflen -= sizeof(sha256_salt_prefix) - 1;
+
+	if (rounds_custom) {
+		n = snprintf(cp, MAX(0, buflen), "%s%zu$",
+			 sha256_rounds_prefix, rounds);
+
+		cp += n;
+		buflen -= n;
+	}
+
+	cp = stpncpy(cp, salt, MIN((size_t)MAX(0, buflen), salt_len));
+	buflen -= MIN((size_t)MAX(0, buflen), salt_len);
+
+	if (buflen > 0) {
+		*cp++ = '$';
+		--buflen;
+	}
+
+	b64_from_24bit(alt_result[0], alt_result[10], alt_result[20], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[21], alt_result[1], alt_result[11], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[12], alt_result[22], alt_result[2], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[3], alt_result[13], alt_result[23], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[24], alt_result[4], alt_result[14], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[15], alt_result[25], alt_result[5], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[6], alt_result[16], alt_result[26], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[27], alt_result[7], alt_result[17], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[18], alt_result[28], alt_result[8], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[9], alt_result[19], alt_result[29], 4, &buflen, &cp);
+	b64_from_24bit(0, alt_result[31], alt_result[30], 3, &buflen, &cp);
+	if (buflen <= 0) {
+		errno = ERANGE;
+		buffer = NULL;
+	}
+	else
+		*cp = '\0';	/* Terminate the string. */
+
+	/* Clear the buffer for the intermediate result so that people
+	 * attaching to processes or reading core dumps cannot get any
+	 * information. We do it in this way to clear correct_words[] inside
+	 * the SHA256 implementation as well. */
+	SHA256_Init(&ctx);
+	SHA256_Final(alt_result, &ctx);
+	memset(temp_result, '\0', sizeof(temp_result));
+	memset(p_bytes, '\0', key_len);
+	memset(s_bytes, '\0', salt_len);
+	memset(&ctx, '\0', sizeof(ctx));
+	memset(&alt_ctx, '\0', sizeof(alt_ctx));
+	if (copied_key != NULL)
+		memset(copied_key, '\0', key_len);
+	if (copied_salt != NULL)
+		memset(copied_salt, '\0', salt_len);
+
+	return buffer;
+}
+
+/* This entry point is equivalent to crypt(3). */
+char *
+sha256_crypt(const char *key, const char *salt)
+{
+	/* We don't want to have an arbitrary limit in the size of the
+	 * password. We can compute an upper bound for the size of the
+	 * result in advance and so we can prepare the buffer we pass to
+	 * `sha256_crypt_r'. */
+	static char *buffer;
+	static int buflen;
+	int needed;
+	char *new_buffer;
+
+	needed = (sizeof(sha256_salt_prefix) - 1
+	      + sizeof(sha256_rounds_prefix) + 9 + 1
+	      + strlen(salt) + 1 + 43 + 1);
+
+	if (buflen < needed) {
+		new_buffer = (char *)realloc(buffer, needed);
+
+		if (new_buffer == NULL)
+			return NULL;
+
+		buffer = new_buffer;
+		buflen = needed;
+	}
+
+	return sha256_crypt_r(key, salt, buffer, buflen);
+}
+
+#ifdef TEST
+
+static const struct {
+	const char *input;
+	const char result[32];
+} tests[] =
+{
+	/* Test vectors from FIPS 180-2: appendix B.1. */
+	{
+		"abc",
+		"\xba\x78\x16\xbf\x8f\x01\xcf\xea\x41\x41\x40\xde\x5d\xae\x22\x23"
+		"\xb0\x03\x61\xa3\x96\x17\x7a\x9c\xb4\x10\xff\x61\xf2\x00\x15\xad"
+	},
+	/* Test vectors from FIPS 180-2: appendix B.2. */
+	{
+		"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+		"\x24\x8d\x6a\x61\xd2\x06\x38\xb8\xe5\xc0\x26\x93\x0c\x3e\x60\x39"
+		"\xa3\x3c\xe4\x59\x64\xff\x21\x67\xf6\xec\xed\xd4\x19\xdb\x06\xc1"
+	},
+	/* Test vectors from the NESSIE project. */
+	{
+		"",
+		"\xe3\xb0\xc4\x42\x98\xfc\x1c\x14\x9a\xfb\xf4\xc8\x99\x6f\xb9\x24"
+		"\x27\xae\x41\xe4\x64\x9b\x93\x4c\xa4\x95\x99\x1b\x78\x52\xb8\x55"
+	},
+	{
+		"a",
+		"\xca\x97\x81\x12\xca\x1b\xbd\xca\xfa\xc2\x31\xb3\x9a\x23\xdc\x4d"
+		"\xa7\x86\xef\xf8\x14\x7c\x4e\x72\xb9\x80\x77\x85\xaf\xee\x48\xbb"
+	},
+	{
+		"message digest",
+		"\xf7\x84\x6f\x55\xcf\x23\xe1\x4e\xeb\xea\xb5\xb4\xe1\x55\x0c\xad"
+		"\x5b\x50\x9e\x33\x48\xfb\xc4\xef\xa3\xa1\x41\x3d\x39\x3c\xb6\x50"
+	},
+	{
+		"abcdefghijklmnopqrstuvwxyz",
+		"\x71\xc4\x80\xdf\x93\xd6\xae\x2f\x1e\xfa\xd1\x44\x7c\x66\xc9\x52"
+		"\x5e\x31\x62\x18\xcf\x51\xfc\x8d\x9e\xd8\x32\xf2\xda\xf1\x8b\x73"
+	},
+	{
+		"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+		"\x24\x8d\x6a\x61\xd2\x06\x38\xb8\xe5\xc0\x26\x93\x0c\x3e\x60\x39"
+		"\xa3\x3c\xe4\x59\x64\xff\x21\x67\xf6\xec\xed\xd4\x19\xdb\x06\xc1"
+	},
+	{
+		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+		"\xdb\x4b\xfc\xbd\x4d\xa0\xcd\x85\xa6\x0c\x3c\x37\xd3\xfb\xd8\x80"
+		"\x5c\x77\xf1\x5f\xc6\xb1\xfd\xfe\x61\x4e\xe0\xa7\xc8\xfd\xb4\xc0"
+	},
+	{
+		"123456789012345678901234567890123456789012345678901234567890"
+		"12345678901234567890",
+		"\xf3\x71\xbc\x4a\x31\x1f\x2b\x00\x9e\xef\x95\x2d\xd8\x3c\xa8\x0e"
+		"\x2b\x60\x02\x6c\x8e\x93\x55\x92\xd0\xf9\xc3\x08\x45\x3c\x81\x3e"
+	}
+};
+
+#define ntests (sizeof (tests) / sizeof (tests[0]))
+
+static const struct {
+	const char *salt;
+	const char *input;
+	const char *expected;
+} tests2[] =
+{
+	{
+		"$5$saltstring", "Hello world!",
+		"$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5"
+	},
+	{
+		"$5$rounds=10000$saltstringsaltstring", "Hello world!",
+		"$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2."
+		"opqey6IcA"
+	},
+	{
+		"$5$rounds=5000$toolongsaltstring", "This is just a test",
+		"$5$rounds=5000$toolongsaltstrin$Un/5jzAHMgOGZ5.mWJpuVolil07guHPvOW8"
+		"mGRcvxa5"
+	},
+	{
+		"$5$rounds=1400$anotherlongsaltstring",
+		"a very much longer text to encrypt.  This one even stretches over more"
+		"than one line.",
+		"$5$rounds=1400$anotherlongsalts$Rx.j8H.h8HjEDGomFU8bDkXm3XIUnzyxf12"
+		"oP84Bnq1"
+	},
+	{
+		"$5$rounds=77777$short",
+		"we have a short salt string but not a short password",
+		"$5$rounds=77777$short$JiO1O3ZpDAxGJeaDIuqCoEFysAe1mZNJRs3pw0KQRd/"
+	},
+	{
+		"$5$rounds=123456$asaltof16chars..", "a short string",
+		"$5$rounds=123456$asaltof16chars..$gP3VQ/6X7UUEW3HkBn2w1/Ptq2jxPyzV/"
+		"cZKmF/wJvD"
+	},
+	{
+		"$5$rounds=10$roundstoolow", "the minimum number is still observed",
+		"$5$rounds=1000$roundstoolow$yfvwcWrQ8l/K0DAWyuPMDNHpIVlTQebY9l/gL97"
+		"2bIC"
+	},
+};
+
+#define ntests2 (sizeof (tests2) / sizeof (tests2[0]))
+
+int
+main(void)
+{
+	SHA256_CTX ctx;
+	uint8_t sum[32];
+	int result = 0;
+	int i, cnt;
+
+	for (cnt = 0; cnt < (int)ntests; ++cnt) {
+		SHA256_Init(&ctx);
+		SHA256_Update(&ctx, tests[cnt].input, strlen(tests[cnt].input));
+		SHA256_Final(sum, &ctx);
+		if (memcmp(tests[cnt].result, sum, 32) != 0) {
+			for (i = 0; i < 32; i++)
+				printf("%02X", tests[cnt].result[i]);
+			printf("\n");
+			for (i = 0; i < 32; i++)
+				printf("%02X", sum[i]);
+			printf("\n");
+			printf("test %d run %d failed\n", cnt, 1);
+			result = 1;
+		}
+
+		SHA256_Init(&ctx);
+		for (i = 0; tests[cnt].input[i] != '\0'; ++i)
+			SHA256_Update(&ctx, &tests[cnt].input[i], 1);
+		SHA256_Final(sum, &ctx);
+		if (memcmp(tests[cnt].result, sum, 32) != 0) {
+			for (i = 0; i < 32; i++)
+				printf("%02X", tests[cnt].result[i]);
+			printf("\n");
+			for (i = 0; i < 32; i++)
+				printf("%02X", sum[i]);
+			printf("\n");
+			printf("test %d run %d failed\n", cnt, 2);
+			result = 1;
+		}
+	}
+
+	/* Test vector from FIPS 180-2: appendix B.3. */
+	char buf[1000];
+
+	memset(buf, 'a', sizeof(buf));
+	SHA256_Init(&ctx);
+	for (i = 0; i < 1000; ++i)
+		SHA256_Update(&ctx, buf, sizeof(buf));
+	SHA256_Final(sum, &ctx);
+	static const char expected[32] =
+	"\xcd\xc7\x6e\x5c\x99\x14\xfb\x92\x81\xa1\xc7\xe2\x84\xd7\x3e\x67"
+	"\xf1\x80\x9a\x48\xa4\x97\x20\x0e\x04\x6d\x39\xcc\xc7\x11\x2c\xd0";
+
+	if (memcmp(expected, sum, 32) != 0) {
+		printf("test %d failed\n", cnt);
+		result = 1;
+	}
+
+	for (cnt = 0; cnt < ntests2; ++cnt) {
+		char *cp = sha256_crypt(tests2[cnt].input, tests2[cnt].salt);
+
+		if (strcmp(cp, tests2[cnt].expected) != 0) {
+			printf("test %d: expected \"%s\", got \"%s\"\n",
+			       cnt, tests2[cnt].expected, cp);
+			result = 1;
+		}
+	}
+
+	if (result == 0)
+		puts("all tests OK");
+
+	return result;
+}
+
+#endif /* TEST */

Added: head/lib/libcrypt/crypt-sha512.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lib/libcrypt/crypt-sha512.c	Sat Apr  9 14:02:04 2011	(r220497)
@@ -0,0 +1,500 @@
+/*
+ * Copyright (c) 2011 The FreeBSD Project. 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.
+ */
+
+/* Based on:
+ * SHA512-based Unix crypt implementation. Released into the Public Domain by
+ * Ulrich Drepper . */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "crypt.h"
+
+/* Define our magic string to mark salt for SHA512 "encryption" replacement. */
+static const char sha512_salt_prefix[] = "$6$";
+
+/* Prefix for optional rounds specification. */
+static const char sha512_rounds_prefix[] = "rounds=";
+
+/* Maximum salt string length. */
+#define SALT_LEN_MAX 16
+/* Default number of rounds if not explicitly specified. */
+#define ROUNDS_DEFAULT 5000
+/* Minimum number of rounds. */
+#define ROUNDS_MIN 1000
+/* Maximum number of rounds. */
+#define ROUNDS_MAX 999999999
+
+static char *
+sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen)
+{
+	u_long srounds;
+	int n;
+	uint8_t alt_result[64], temp_result[64];
+	SHA512_CTX ctx, alt_ctx;
+	size_t salt_len, key_len, cnt, rounds;
+	char *cp, *copied_key, *copied_salt, *p_bytes, *s_bytes, *endp;
+	const char *num;
+	bool rounds_custom;
+
+	copied_key = NULL;
+	copied_salt = NULL;
+
+	/* Default number of rounds. */
+	rounds = ROUNDS_DEFAULT;
+	rounds_custom = false;
+
+	/* Find beginning of salt string. The prefix should normally always
+	 * be present. Just in case it is not. */
+	if (strncmp(sha512_salt_prefix, salt, sizeof(sha512_salt_prefix) - 1) == 0)
+		/* Skip salt prefix. */
+		salt += sizeof(sha512_salt_prefix) - 1;
+
+	if (strncmp(salt, sha512_rounds_prefix, sizeof(sha512_rounds_prefix) - 1)
+	    == 0) {
+		num = salt + sizeof(sha512_rounds_prefix) - 1;
+		srounds = strtoul(num, &endp, 10);
+
+		if (*endp == '$') {
+			salt = endp + 1;
+			rounds = MAX(ROUNDS_MIN, MIN(srounds, ROUNDS_MAX));
+			rounds_custom = true;
+		}
+	}
+
+	salt_len = MIN(strcspn(salt, "$"), SALT_LEN_MAX);
+	key_len = strlen(key);
+
+	/* Prepare for the real work. */
+	SHA512_Init(&ctx);
+
+	/* Add the key string. */
+	SHA512_Update(&ctx, key, key_len);
+
+	/* The last part is the salt string. This must be at most 8
+	 * characters and it ends at the first `$' character (for
+	 * compatibility with existing implementations). */
+	SHA512_Update(&ctx, salt, salt_len);
+
+	/* Compute alternate SHA512 sum with input KEY, SALT, and KEY. The
+	 * final result will be added to the first context. */
+	SHA512_Init(&alt_ctx);
+
+	/* Add key. */
+	SHA512_Update(&alt_ctx, key, key_len);
+
+	/* Add salt. */
+	SHA512_Update(&alt_ctx, salt, salt_len);
+
+	/* Add key again. */
+	SHA512_Update(&alt_ctx, key, key_len);
+
+	/* Now get result of this (64 bytes) and add it to the other context. */
+	SHA512_Final(alt_result, &alt_ctx);
+
+	/* Add for any character in the key one byte of the alternate sum. */
+	for (cnt = key_len; cnt > 64; cnt -= 64)
+		SHA512_Update(&ctx, alt_result, 64);
+	SHA512_Update(&ctx, alt_result, cnt);
+
+	/* Take the binary representation of the length of the key and for
+	 * every 1 add the alternate sum, for every 0 the key. */
+	for (cnt = key_len; cnt > 0; cnt >>= 1)
+		if ((cnt & 1) != 0)
+			SHA512_Update(&ctx, alt_result, 64);
+		else
+			SHA512_Update(&ctx, key, key_len);
+
+	/* Create intermediate result. */
+	SHA512_Final(alt_result, &ctx);
+
+	/* Start computation of P byte sequence. */
+	SHA512_Init(&alt_ctx);
+
+	/* For every character in the password add the entire password. */
+	for (cnt = 0; cnt < key_len; ++cnt)
+		SHA512_Update(&alt_ctx, key, key_len);
+
+	/* Finish the digest. */
+	SHA512_Final(temp_result, &alt_ctx);
+
+	/* Create byte sequence P. */
+	cp = p_bytes = alloca(key_len);
+	for (cnt = key_len; cnt >= 64; cnt -= 64) {
+		memcpy(cp, temp_result, 64);
+		cp += 64;
+	}
+	memcpy(cp, temp_result, cnt);
+
+	/* Start computation of S byte sequence. */
+	SHA512_Init(&alt_ctx);
+
+	/* For every character in the password add the entire password. */
+	for (cnt = 0; cnt < 16 + alt_result[0]; ++cnt)
+		SHA512_Update(&alt_ctx, salt, salt_len);
+
+	/* Finish the digest. */
+	SHA512_Final(temp_result, &alt_ctx);
+
+	/* Create byte sequence S. */
+	cp = s_bytes = alloca(salt_len);
+	for (cnt = salt_len; cnt >= 64; cnt -= 64) {
+		memcpy(cp, temp_result, 64);
+		cp += 64;
+	}
+	memcpy(cp, temp_result, cnt);
+
+	/* Repeatedly run the collected hash value through SHA512 to burn CPU
+	 * cycles. */
+	for (cnt = 0; cnt < rounds; ++cnt) {
+		/* New context. */
+		SHA512_Init(&ctx);
+
+		/* Add key or last result. */
+		if ((cnt & 1) != 0)
+			SHA512_Update(&ctx, p_bytes, key_len);
+		else
+			SHA512_Update(&ctx, alt_result, 64);
+
+		/* Add salt for numbers not divisible by 3. */
+		if (cnt % 3 != 0)
+			SHA512_Update(&ctx, s_bytes, salt_len);
+
+		/* Add key for numbers not divisible by 7. */
+		if (cnt % 7 != 0)
+			SHA512_Update(&ctx, p_bytes, key_len);
+
+		/* Add key or last result. */
+		if ((cnt & 1) != 0)
+			SHA512_Update(&ctx, alt_result, 64);
+		else
+			SHA512_Update(&ctx, p_bytes, key_len);
+
+		/* Create intermediate result. */
+		SHA512_Final(alt_result, &ctx);
+	}
+
+	/* Now we can construct the result string. It consists of three
+	 * parts. */
+	cp = stpncpy(buffer, sha512_salt_prefix, MAX(0, buflen));
+	buflen -= sizeof(sha512_salt_prefix) - 1;
+
+	if (rounds_custom) {
+		n = snprintf(cp, MAX(0, buflen), "%s%zu$",
+			 sha512_rounds_prefix, rounds);
+
+		cp += n;
+		buflen -= n;
+	}
+
+	cp = stpncpy(cp, salt, MIN((size_t)MAX(0, buflen), salt_len));
+	buflen -= MIN((size_t)MAX(0, buflen), salt_len);
+
+	if (buflen > 0) {
+		*cp++ = '$';
+		--buflen;
+	}
+
+	b64_from_24bit(alt_result[0], alt_result[21], alt_result[42], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[22], alt_result[43], alt_result[1], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[44], alt_result[2], alt_result[23], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[3], alt_result[24], alt_result[45], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[25], alt_result[46], alt_result[4], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[47], alt_result[5], alt_result[26], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[6], alt_result[27], alt_result[48], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[28], alt_result[49], alt_result[7], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[50], alt_result[8], alt_result[29], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[9], alt_result[30], alt_result[51], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[31], alt_result[52], alt_result[10], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[53], alt_result[11], alt_result[32], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[12], alt_result[33], alt_result[54], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[34], alt_result[55], alt_result[13], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[56], alt_result[14], alt_result[35], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[15], alt_result[36], alt_result[57], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[37], alt_result[58], alt_result[16], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[59], alt_result[17], alt_result[38], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[18], alt_result[39], alt_result[60], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[40], alt_result[61], alt_result[19], 4, &buflen, &cp);
+	b64_from_24bit(alt_result[62], alt_result[20], alt_result[41], 4, &buflen, &cp);
+	b64_from_24bit(0, 0, alt_result[63], 2, &buflen, &cp);
+
+	if (buflen <= 0) {
+		errno = ERANGE;
+		buffer = NULL;
+	}
+	else
+		*cp = '\0';	/* Terminate the string. */
+
+	/* Clear the buffer for the intermediate result so that people
+	 * attaching to processes or reading core dumps cannot get any
+	 * information. We do it in this way to clear correct_words[] inside
+	 * the SHA512 implementation as well. */
+	SHA512_Init(&ctx);
+	SHA512_Final(alt_result, &ctx);
+	memset(temp_result, '\0', sizeof(temp_result));
+	memset(p_bytes, '\0', key_len);
+	memset(s_bytes, '\0', salt_len);
+	memset(&ctx, '\0', sizeof(ctx));
+	memset(&alt_ctx, '\0', sizeof(alt_ctx));
+	if (copied_key != NULL)
+		memset(copied_key, '\0', key_len);
+	if (copied_salt != NULL)
+		memset(copied_salt, '\0', salt_len);
+
+	return buffer;
+}
+
+/* This entry point is equivalent to crypt(3). */
+char *
+sha512_crypt(const char *key, const char *salt)
+{
+	/* We don't want to have an arbitrary limit in the size of the
+	 * password. We can compute an upper bound for the size of the
+	 * result in advance and so we can prepare the buffer we pass to
+	 * `sha512_crypt_r'. */
+	static char *buffer;
+	static int buflen;
+	int needed;
+	char *new_buffer;
+
+	needed = (sizeof(sha512_salt_prefix) - 1
+	      + sizeof(sha512_rounds_prefix) + 9 + 1
+	      + strlen(salt) + 1 + 86 + 1);
+
+	if (buflen < needed) {
+		new_buffer = (char *)realloc(buffer, needed);
+
+		if (new_buffer == NULL)
+			return NULL;
+
+		buffer = new_buffer;
+		buflen = needed;
+	}
+
+	return sha512_crypt_r(key, salt, buffer, buflen);
+}
+
+#ifdef TEST
+
+static const struct {
+	const char *input;
+	const char result[64];
+} tests[] =
+{
+	/* Test vectors from FIPS 180-2: appendix C.1. */
+	{
+		"abc",
+		"\xdd\xaf\x35\xa1\x93\x61\x7a\xba\xcc\x41\x73\x49\xae\x20\x41\x31"
+		"\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a"
+		"\x21\x92\x99\x2a\x27\x4f\xc1\xa8\x36\xba\x3c\x23\xa3\xfe\xeb\xbd"
+		"\x45\x4d\x44\x23\x64\x3c\xe8\x0e\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f"
+	},
+	/* Test vectors from FIPS 180-2: appendix C.2. */
+	{
+		"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
+		"hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
+		"\x8e\x95\x9b\x75\xda\xe3\x13\xda\x8c\xf4\xf7\x28\x14\xfc\x14\x3f"
+		"\x8f\x77\x79\xc6\xeb\x9f\x7f\xa1\x72\x99\xae\xad\xb6\x88\x90\x18"
+		"\x50\x1d\x28\x9e\x49\x00\xf7\xe4\x33\x1b\x99\xde\xc4\xb5\x43\x3a"
+		"\xc7\xd3\x29\xee\xb6\xdd\x26\x54\x5e\x96\xe5\x5b\x87\x4b\xe9\x09"
+	},
+	/* Test vectors from the NESSIE project. */
+	{
+		"",
+		"\xcf\x83\xe1\x35\x7e\xef\xb8\xbd\xf1\x54\x28\x50\xd6\x6d\x80\x07"
+		"\xd6\x20\xe4\x05\x0b\x57\x15\xdc\x83\xf4\xa9\x21\xd3\x6c\xe9\xce"
+		"\x47\xd0\xd1\x3c\x5d\x85\xf2\xb0\xff\x83\x18\xd2\x87\x7e\xec\x2f"
+		"\x63\xb9\x31\xbd\x47\x41\x7a\x81\xa5\x38\x32\x7a\xf9\x27\xda\x3e"
+	},
+	{
+		"a",
+		"\x1f\x40\xfc\x92\xda\x24\x16\x94\x75\x09\x79\xee\x6c\xf5\x82\xf2"
+		"\xd5\xd7\xd2\x8e\x18\x33\x5d\xe0\x5a\xbc\x54\xd0\x56\x0e\x0f\x53"
+		"\x02\x86\x0c\x65\x2b\xf0\x8d\x56\x02\x52\xaa\x5e\x74\x21\x05\x46"
+		"\xf3\x69\xfb\xbb\xce\x8c\x12\xcf\xc7\x95\x7b\x26\x52\xfe\x9a\x75"
+	},
+	{
+		"message digest",
+		"\x10\x7d\xbf\x38\x9d\x9e\x9f\x71\xa3\xa9\x5f\x6c\x05\x5b\x92\x51"
+		"\xbc\x52\x68\xc2\xbe\x16\xd6\xc1\x34\x92\xea\x45\xb0\x19\x9f\x33"
+		"\x09\xe1\x64\x55\xab\x1e\x96\x11\x8e\x8a\x90\x5d\x55\x97\xb7\x20"
+		"\x38\xdd\xb3\x72\xa8\x98\x26\x04\x6d\xe6\x66\x87\xbb\x42\x0e\x7c"
+	},
+	{
+		"abcdefghijklmnopqrstuvwxyz",
+		"\x4d\xbf\xf8\x6c\xc2\xca\x1b\xae\x1e\x16\x46\x8a\x05\xcb\x98\x81"
+		"\xc9\x7f\x17\x53\xbc\xe3\x61\x90\x34\x89\x8f\xaa\x1a\xab\xe4\x29"
+		"\x95\x5a\x1b\xf8\xec\x48\x3d\x74\x21\xfe\x3c\x16\x46\x61\x3a\x59"
+		"\xed\x54\x41\xfb\x0f\x32\x13\x89\xf7\x7f\x48\xa8\x79\xc7\xb1\xf1"
+	},
+	{
+		"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+		"\x20\x4a\x8f\xc6\xdd\xa8\x2f\x0a\x0c\xed\x7b\xeb\x8e\x08\xa4\x16"
+		"\x57\xc1\x6e\xf4\x68\xb2\x28\xa8\x27\x9b\xe3\x31\xa7\x03\xc3\x35"
+		"\x96\xfd\x15\xc1\x3b\x1b\x07\xf9\xaa\x1d\x3b\xea\x57\x78\x9c\xa0"
+		"\x31\xad\x85\xc7\xa7\x1d\xd7\x03\x54\xec\x63\x12\x38\xca\x34\x45"
+	},
+	{
+		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+		"\x1e\x07\xbe\x23\xc2\x6a\x86\xea\x37\xea\x81\x0c\x8e\xc7\x80\x93"
+		"\x52\x51\x5a\x97\x0e\x92\x53\xc2\x6f\x53\x6c\xfc\x7a\x99\x96\xc4"
+		"\x5c\x83\x70\x58\x3e\x0a\x78\xfa\x4a\x90\x04\x1d\x71\xa4\xce\xab"
+		"\x74\x23\xf1\x9c\x71\xb9\xd5\xa3\xe0\x12\x49\xf0\xbe\xbd\x58\x94"
+	},
+	{
+		"123456789012345678901234567890123456789012345678901234567890"
+		"12345678901234567890",
+		"\x72\xec\x1e\xf1\x12\x4a\x45\xb0\x47\xe8\xb7\xc7\x5a\x93\x21\x95"
+		"\x13\x5b\xb6\x1d\xe2\x4e\xc0\xd1\x91\x40\x42\x24\x6e\x0a\xec\x3a"
+		"\x23\x54\xe0\x93\xd7\x6f\x30\x48\xb4\x56\x76\x43\x46\x90\x0c\xb1"
+		"\x30\xd2\xa4\xfd\x5d\xd1\x6a\xbb\x5e\x30\xbc\xb8\x50\xde\xe8\x43"
+	}
+};
+
+#define ntests (sizeof (tests) / sizeof (tests[0]))
+
+static const struct {
+	const char *salt;
+	const char *input;
+	const char *expected;
+} tests2[] =
+{
+	{
+		"$6$saltstring", "Hello world!",
+		"$6$saltstring$svn8UoSVapNtMuq1ukKS4tPQd8iKwSMHWjl/O817G3uBnIFNjnQJu"
+		"esI68u4OTLiBFdcbYEdFCoEOfaS35inz1"
+	},
+	{
+		"$6$rounds=10000$saltstringsaltstring", "Hello world!",
+		"$6$rounds=10000$saltstringsaltst$OW1/O6BYHV6BcXZu8QVeXbDWra3Oeqh0sb"
+		"HbbMCVNSnCM/UrjmM0Dp8vOuZeHBy/YTBmSK6H9qs/y3RnOaw5v."
+	},
+	{
+		"$6$rounds=5000$toolongsaltstring", "This is just a test",
+		"$6$rounds=5000$toolongsaltstrin$lQ8jolhgVRVhY4b5pZKaysCLi0QBxGoNeKQ"
+		"zQ3glMhwllF7oGDZxUhx1yxdYcz/e1JSbq3y6JMxxl8audkUEm0"
+	},
+	{
+		"$6$rounds=1400$anotherlongsaltstring",
+		"a very much longer text to encrypt.  This one even stretches over more"
+		"than one line.",
+		"$6$rounds=1400$anotherlongsalts$POfYwTEok97VWcjxIiSOjiykti.o/pQs.wP"
+		"vMxQ6Fm7I6IoYN3CmLs66x9t0oSwbtEW7o7UmJEiDwGqd8p4ur1"
+	},
+	{
+		"$6$rounds=77777$short",
+		"we have a short salt string but not a short password",
+		"$6$rounds=77777$short$WuQyW2YR.hBNpjjRhpYD/ifIw05xdfeEyQoMxIXbkvr0g"
+		"ge1a1x3yRULJ5CCaUeOxFmtlcGZelFl5CxtgfiAc0"
+	},
+	{
+		"$6$rounds=123456$asaltof16chars..", "a short string",
+		"$6$rounds=123456$asaltof16chars..$BtCwjqMJGx5hrJhZywWvt0RLE8uZ4oPwc"
+		"elCjmw2kSYu.Ec6ycULevoBK25fs2xXgMNrCzIMVcgEJAstJeonj1"
+	},
+	{
+		"$6$rounds=10$roundstoolow", "the minimum number is still observed",
+		"$6$rounds=1000$roundstoolow$kUMsbe306n21p9R.FRkW3IGn.S9NPN0x50YhH1x"
+		"hLsPuWGsUSklZt58jaTfF4ZEQpyUNGc0dqbpBYYBaHHrsX."
+	},
+};
+
+#define ntests2 (sizeof (tests2) / sizeof (tests2[0]))
+
+int
+main(void)
+{
+	SHA512_CTX ctx;
+	uint8_t sum[64];
+	int result = 0;
+	int i, cnt;
+
+	for (cnt = 0; cnt < (int)ntests; ++cnt) {
+		SHA512_Init(&ctx);
+		SHA512_Update(&ctx, tests[cnt].input, strlen(tests[cnt].input));
+		SHA512_Final(sum, &ctx);
+		if (memcmp(tests[cnt].result, sum, 64) != 0) {
+			printf("test %d run %d failed\n", cnt, 1);
+			result = 1;
+		}
+
+		SHA512_Init(&ctx);
+		for (i = 0; tests[cnt].input[i] != '\0'; ++i)
+			SHA512_Update(&ctx, &tests[cnt].input[i], 1);
+		SHA512_Final(sum, &ctx);
+		if (memcmp(tests[cnt].result, sum, 64) != 0) {
+			printf("test %d run %d failed\n", cnt, 2);
+			result = 1;
+		}
+	}
+
+	/* Test vector from FIPS 180-2: appendix C.3. */
+	char buf[1000];
+
+	memset(buf, 'a', sizeof(buf));
+	SHA512_Init(&ctx);
+	for (i = 0; i < 1000; ++i)
+		SHA512_Update(&ctx, buf, sizeof(buf));
+	SHA512_Final(sum, &ctx);
+	static const char expected[64] =
+	"\xe7\x18\x48\x3d\x0c\xe7\x69\x64\x4e\x2e\x42\xc7\xbc\x15\xb4\x63"
+	"\x8e\x1f\x98\xb1\x3b\x20\x44\x28\x56\x32\xa8\x03\xaf\xa9\x73\xeb"
+	"\xde\x0f\xf2\x44\x87\x7e\xa6\x0a\x4c\xb0\x43\x2c\xe5\x77\xc3\x1b"
+	"\xeb\x00\x9c\x5c\x2c\x49\xaa\x2e\x4e\xad\xb2\x17\xad\x8c\xc0\x9b";
+
+	if (memcmp(expected, sum, 64) != 0) {
+		printf("test %d failed\n", cnt);
+		result = 1;
+	}
+
+	for (cnt = 0; cnt < ntests2; ++cnt) {
+		char *cp = sha512_crypt(tests2[cnt].input, tests2[cnt].salt);
+
+		if (strcmp(cp, tests2[cnt].expected) != 0) {
+			printf("test %d: expected \"%s\", got \"%s\"\n",
+			       cnt, tests2[cnt].expected, cp);
+			result = 1;
+		}
+	}
+
+	if (result == 0)
+		puts("all tests OK");
+
+	return result;
+}
+
+#endif /* TEST */

Modified: head/lib/libcrypt/crypt.c
==============================================================================
--- head/lib/libcrypt/crypt.c	Sat Apr  9 13:56:29 2011	(r220496)
+++ head/lib/libcrypt/crypt.c	Sat Apr  9 14:02:04 2011	(r220497)
@@ -63,6 +63,16 @@ static const struct {
 		"$3$"

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-head@FreeBSD.ORG  Sat Apr  9 14:09:46 2011
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 F00F7106566C;
	Sat,  9 Apr 2011 14:09:46 +0000 (UTC)
	(envelope-from markm@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DEA228FC14;
	Sat,  9 Apr 2011 14:09:46 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p39E9kc1016337;
	Sat, 9 Apr 2011 14:09:46 GMT (envelope-from markm@svn.freebsd.org)
Received: (from markm@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p39E9kSb016335;
	Sat, 9 Apr 2011 14:09:46 GMT (envelope-from markm@svn.freebsd.org)
Message-Id: <201104091409.p39E9kSb016335@svn.freebsd.org>
From: Mark Murray 
Date: Sat, 9 Apr 2011 14:09:46 +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: r220498 - head/lib/libcrypt
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, 09 Apr 2011 14:09:47 -0000

Author: markm
Date: Sat Apr  9 14:09:46 2011
New Revision: 220498
URL: http://svn.freebsd.org/changeset/base/220498

Log:
  Document SHA256/512 modes.
  
  MFC after:	1 month

Modified:
  head/lib/libcrypt/crypt.3

Modified: head/lib/libcrypt/crypt.3
==============================================================================
--- head/lib/libcrypt/crypt.3	Sat Apr  9 14:02:04 2011	(r220497)
+++ head/lib/libcrypt/crypt.3	Sat Apr  9 14:09:46 2011	(r220498)
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 19, 1997
+.Dd April 9, 2011
 .Dt CRYPT 3
 .Os
 .Sh NAME
@@ -188,6 +188,10 @@ MD5
 Blowfish
 .It
 NT-Hash
+.It
+SHA-256
+.It
+SHA-512
 .El
 .Pp
 Other crypt formats may be easily added.
@@ -226,7 +230,9 @@ Valid values are
 .\"
 .Ql des ,
 .Ql blf ,
-.Ql md5
+.Ql md5 ,
+.Ql sha256 ,
+.Ql sha512
 and
 .Ql nth .
 .Pp

From owner-svn-src-head@FreeBSD.ORG  Sat Apr  9 14:18:03 2011
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 C72A7106564A;
	Sat,  9 Apr 2011 14:18:03 +0000 (UTC)
	(envelope-from nwhitehorn@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B56448FC08;
	Sat,  9 Apr 2011 14:18:03 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p39EI3YI016565;
	Sat, 9 Apr 2011 14:18:03 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Received: (from nwhitehorn@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p39EI3sj016563;
	Sat, 9 Apr 2011 14:18:03 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Message-Id: <201104091418.p39EI3sj016563@svn.freebsd.org>
From: Nathan Whitehorn 
Date: Sat, 9 Apr 2011 14:18:03 +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: r220499 - head/usr.sbin/bsdinstall/scripts
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, 09 Apr 2011 14:18:03 -0000

Author: nwhitehorn
Date: Sat Apr  9 14:18:03 2011
New Revision: 220499
URL: http://svn.freebsd.org/changeset/base/220499

Log:
  Rename the "Reboot" option to "Exit", which reflects what it actually
  does. The rc.local wrapper script will also soon grow an option to use the
  live environment after installation, so an immediate reboot isn't even
  necessarily implied.

Modified:
  head/usr.sbin/bsdinstall/scripts/auto

Modified: head/usr.sbin/bsdinstall/scripts/auto
==============================================================================
--- head/usr.sbin/bsdinstall/scripts/auto	Sat Apr  9 14:09:46 2011	(r220498)
+++ head/usr.sbin/bsdinstall/scripts/auto	Sat Apr  9 14:18:03 2011	(r220499)
@@ -167,7 +167,7 @@ finalconfig() {
 		"Services" "Set daemons to run on startup" \
 		"Time Zone" "Set system timezone" \
 		"Shell" "Open a shell in the new system" \
-		"Reboot" "Apply configuration and reboot" 2>&1 1>&3)
+		"Exit" "Apply configuration and exit installer" 2>&1 1>&3)
 	exec 3>&-
 
 	case "$REVISIT" in

From owner-svn-src-head@FreeBSD.ORG  Sat Apr  9 14:25:59 2011
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 49F201065672;
	Sat,  9 Apr 2011 14:25:59 +0000 (UTC)
	(envelope-from nwhitehorn@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3882B8FC14;
	Sat,  9 Apr 2011 14:25:59 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p39EPxkK017039;
	Sat, 9 Apr 2011 14:25:59 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Received: (from nwhitehorn@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p39EPxjj017037;
	Sat, 9 Apr 2011 14:25:59 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Message-Id: <201104091425.p39EPxjj017037@svn.freebsd.org>
From: Nathan Whitehorn 
Date: Sat, 9 Apr 2011 14:25: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: r220500 - head/release
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, 09 Apr 2011 14:25:59 -0000

Author: nwhitehorn
Date: Sat Apr  9 14:25:58 2011
New Revision: 220500
URL: http://svn.freebsd.org/changeset/base/220500

Log:
  Allow the user to use the live environment post-installation, as well
  as improving error handling.

Modified:
  head/release/rc.local

Modified: head/release/rc.local
==============================================================================
--- head/release/rc.local	Sat Apr  9 14:18:03 2011	(r220499)
+++ head/release/rc.local	Sat Apr  9 14:25:58 2011	(r220500)
@@ -17,8 +17,11 @@ $DIALOG_OK)	# Install
 	BSDINSTALL_CONFIGCURRENT=yes; export BSDINSTALL_CONFIGCURRENT
 	trap true SIGINT	# Ignore cntrl-C here
 	bsdinstall
-	dialog --backtitle "FreeBSD Installer" --title "Complete" --msgbox "Installation of FreeBSD complete! The system will now reboot." 0 0
-	reboot
+	if [ $? -eq 0 ]; then
+		dialog --backtitle "FreeBSD Installer" --title "Complete" --yes-label "Reboot" --no-label "Live CD" --yesno "Installation of FreeBSD complete! Would you like to reboot into the installed system now?" 0 0 && reboot
+	else
+		. /etc/rc.local
+	fi
 	;;
 $DIALOG_CANCEL)	# Live CD
 	exit 0

From owner-svn-src-head@FreeBSD.ORG  Sat Apr  9 14:45:50 2011
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 797131065673;
	Sat,  9 Apr 2011 14:45:50 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 685528FC18;
	Sat,  9 Apr 2011 14:45:50 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p39EjoxN017635;
	Sat, 9 Apr 2011 14:45:50 GMT (envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p39EjoTY017632;
	Sat, 9 Apr 2011 14:45:50 GMT (envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104091445.p39EjoTY017632@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 9 Apr 2011 14: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: r220502 - head/sys/dev/ral
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, 09 Apr 2011 14:45:50 -0000

Author: bschmidt
Date: Sat Apr  9 14:45:50 2011
New Revision: 220502
URL: http://svn.freebsd.org/changeset/base/220502

Log:
  Don't hardcode assumptions about basic rates, similar to what the rt2661
  support code does. While here remove an unnecessary loop.

Modified:
  head/sys/dev/ral/rt2560.c
  head/sys/dev/ral/rt2661.c

Modified: head/sys/dev/ral/rt2560.c
==============================================================================
--- head/sys/dev/ral/rt2560.c	Sat Apr  9 14:27:27 2011	(r220501)
+++ head/sys/dev/ral/rt2560.c	Sat Apr  9 14:45:50 2011	(r220502)
@@ -144,7 +144,8 @@ static void		rt2560_enable_tsf_sync(stru
 static void		rt2560_enable_tsf(struct rt2560_softc *);
 static void		rt2560_update_plcp(struct rt2560_softc *);
 static void		rt2560_update_slot(struct ifnet *);
-static void		rt2560_set_basicrates(struct rt2560_softc *);
+static void		rt2560_set_basicrates(struct rt2560_softc *,
+			    const struct ieee80211_rateset *);
 static void		rt2560_update_led(struct rt2560_softc *, int, int);
 static void		rt2560_set_bssid(struct rt2560_softc *, const uint8_t *);
 static void		rt2560_set_macaddr(struct rt2560_softc *, uint8_t *);
@@ -779,7 +780,7 @@ rt2560_newstate(struct ieee80211vap *vap
 
 		if (vap->iv_opmode != IEEE80211_M_MONITOR) {
 			rt2560_update_plcp(sc);
-			rt2560_set_basicrates(sc);
+			rt2560_set_basicrates(sc, &ni->ni_rates);
 			rt2560_set_bssid(sc, ni->ni_bssid);
 		}
 
@@ -2353,22 +2354,29 @@ rt2560_update_slot(struct ifnet *ifp)
 }
 
 static void
-rt2560_set_basicrates(struct rt2560_softc *sc)
+rt2560_set_basicrates(struct rt2560_softc *sc,
+    const struct ieee80211_rateset *rs)
 {
+#define RV(r)	((r) & IEEE80211_RATE_VAL)
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
+	uint32_t mask = 0;
+	uint8_t rate;
+	int i;
 
-	/* update basic rate set */
-	if (ic->ic_curmode == IEEE80211_MODE_11B) {
-		/* 11b basic rates: 1, 2Mbps */
-		RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x3);
-	} else if (IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan)) {
-		/* 11a basic rates: 6, 12, 24Mbps */
-		RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x150);
-	} else {
-		/* 11g basic rates: 1, 2, 5.5, 11, 6, 12, 24Mbps */
-		RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x15f);
+	for (i = 0; i < rs->rs_nrates; i++) {
+		rate = rs->rs_rates[i];
+
+		if (!(rate & IEEE80211_RATE_BASIC))
+			continue;
+
+		mask |= 1 << ic->ic_rt->rateCodeToIndex[RV(rate)];
 	}
+
+	RAL_WRITE(sc, RT2560_ARSP_PLCP_1, mask);
+
+	DPRINTF(sc, "Setting basic rate mask to 0x%x\n", mask);
+#undef RV
 }
 
 static void

Modified: head/sys/dev/ral/rt2661.c
==============================================================================
--- head/sys/dev/ral/rt2661.c	Sat Apr  9 14:27:27 2011	(r220501)
+++ head/sys/dev/ral/rt2661.c	Sat Apr  9 14:45:50 2011	(r220502)
@@ -1915,7 +1915,7 @@ rt2661_set_basicrates(struct rt2661_soft
 	struct ieee80211com *ic = ifp->if_l2com;
 	uint32_t mask = 0;
 	uint8_t rate;
-	int i, j;
+	int i;
 
 	for (i = 0; i < rs->rs_nrates; i++) {
 		rate = rs->rs_rates[i];
@@ -1923,13 +1923,7 @@ rt2661_set_basicrates(struct rt2661_soft
 		if (!(rate & IEEE80211_RATE_BASIC))
 			continue;
 
-		/*
-		 * Find h/w rate index.  We know it exists because the rate
-		 * set has already been negotiated.
-		 */
-		for (j = 0; ic->ic_sup_rates[IEEE80211_MODE_11G].rs_rates[j] != RV(rate); j++);
-
-		mask |= 1 << j;
+		mask |= 1 << ic->ic_rt->rateCodeToIndex[RV(rate)];
 	}
 
 	RAL_WRITE(sc, RT2661_TXRX_CSR5, mask);

From owner-svn-src-head@FreeBSD.ORG  Sat Apr  9 21:40:48 2011
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 A82ED106566B;
	Sat,  9 Apr 2011 21:40: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 95FEC8FC16;
	Sat,  9 Apr 2011 21:40:48 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p39Lem8p026099;
	Sat, 9 Apr 2011 21:40:48 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p39Lem1A026097;
	Sat, 9 Apr 2011 21:40:48 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <201104092140.p39Lem1A026097@svn.freebsd.org>
From: Konstantin Belousov 
Date: Sat, 9 Apr 2011 21:40: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: r220506 - head/sys/fs/fdescfs
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, 09 Apr 2011 21:40:48 -0000

Author: kib
Date: Sat Apr  9 21:40:48 2011
New Revision: 220506
URL: http://svn.freebsd.org/changeset/base/220506

Log:
  Linuxolator calls VOP_READDIR with ncookies pointer. Implement a
  workaround for fdescfs to not panic when ncookies is not NULL, similar
  to the one committed as r152254, but simpler, due to fdescfs_readdir()
  not calling vfs_read_dirent().
  
  PR:	kern/156177
  MFC after:	1 week

Modified:
  head/sys/fs/fdescfs/fdesc_vnops.c

Modified: head/sys/fs/fdescfs/fdesc_vnops.c
==============================================================================
--- head/sys/fs/fdescfs/fdesc_vnops.c	Sat Apr  9 19:07:44 2011	(r220505)
+++ head/sys/fs/fdescfs/fdesc_vnops.c	Sat Apr  9 21:40:48 2011	(r220506)
@@ -500,16 +500,12 @@ fdesc_readdir(ap)
 	struct dirent *dp = &d;
 	int error, i, off, fcnt;
 
-	/*
-	 * We don't allow exporting fdesc mounts, and currently local
-	 * requests do not need cookies.
-	 */
-	if (ap->a_ncookies)
-		panic("fdesc_readdir: not hungry");
-
 	if (VTOFDESC(ap->a_vp)->fd_type != Froot)
 		panic("fdesc_readdir: not dir");
 
+	if (ap->a_ncookies != NULL)
+		*ap->a_ncookies = 0;
+
 	off = (int)uio->uio_offset;
 	if (off != uio->uio_offset || off < 0 || (u_int)off % UIO_MX != 0 ||
 	    uio->uio_resid < UIO_MX)

From owner-svn-src-head@FreeBSD.ORG  Sat Apr  9 23:55:27 2011
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 CA5561065674;
	Sat,  9 Apr 2011 23:55:27 +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 B91848FC22;
	Sat,  9 Apr 2011 23:55:27 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p39NtRob028792;
	Sat, 9 Apr 2011 23:55:27 GMT (envelope-from rmacklem@svn.freebsd.org)
Received: (from rmacklem@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p39NtRcE028790;
	Sat, 9 Apr 2011 23:55:27 GMT (envelope-from rmacklem@svn.freebsd.org)
Message-Id: <201104092355.p39NtRcE028790@svn.freebsd.org>
From: Rick Macklem 
Date: Sat, 9 Apr 2011 23:55: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: r220507 - head/sys/fs/nfsserver
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, 09 Apr 2011 23:55:27 -0000

Author: rmacklem
Date: Sat Apr  9 23:55:27 2011
New Revision: 220507
URL: http://svn.freebsd.org/changeset/base/220507

Log:
  Add a VOP_UNLOCK() for the directory, when that is not what
  VOP_LOOKUP() returned. This fixes a bug in the experimental
  NFS server for the case where VFS_VGET() fails returning EOPNOTSUPP
  in the ReaddirPlus RPC, forcing the use of VOP_LOOKUP() instead.
  
  MFC after:	2 weeks

Modified:
  head/sys/fs/nfsserver/nfs_nfsdport.c

Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdport.c	Sat Apr  9 21:40:48 2011	(r220506)
+++ head/sys/fs/nfsserver/nfs_nfsdport.c	Sat Apr  9 23:55:27 2011	(r220507)
@@ -1975,9 +1975,13 @@ again:
 							vref(vp);
 							nvp = vp;
 							r = 0;
-						} else
+						} else {
 							r = VOP_LOOKUP(vp, &nvp,
 							    &cn);
+							if (vp != nvp)
+								VOP_UNLOCK(vp,
+								    0);
+						}
 					}
 				}
 				if (!r) {