CVS commit: src/sys/arch/x86/x86

2016-07-17 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jul 17 10:46:43 UTC 2016

Modified Files:
src/sys/arch/x86/x86: x86_machdep.c

Log Message:
Simplify x86_add_cluster.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/x86/x86/x86_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/x86_machdep.c
diff -u src/sys/arch/x86/x86/x86_machdep.c:1.73 src/sys/arch/x86/x86/x86_machdep.c:1.74
--- src/sys/arch/x86/x86/x86_machdep.c:1.73	Sat Jul 16 17:13:25 2016
+++ src/sys/arch/x86/x86/x86_machdep.c	Sun Jul 17 10:46:43 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_machdep.c,v 1.73 2016/07/16 17:13:25 maxv Exp $	*/
+/*	$NetBSD: x86_machdep.c,v 1.74 2016/07/17 10:46:43 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.73 2016/07/16 17:13:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.74 2016/07/17 10:46:43 maxv Exp $");
 
 #include "opt_modular.h"
 #include "opt_physmem.h"
@@ -501,8 +501,7 @@ x86_select_freelist(uint64_t maxaddr)
 }
 
 static int
-x86_add_cluster(phys_ram_seg_t *seg_clusters, int seg_cluster_cnt,
-struct extent *iomem_ex, uint64_t seg_start, uint64_t seg_end,
+x86_add_cluster(struct extent *iomem_ex, uint64_t seg_start, uint64_t seg_end,
 uint32_t type)
 {
 	uint64_t new_physmem = 0;
@@ -523,7 +522,7 @@ x86_add_cluster(phys_ram_seg_t *seg_clus
 		aprint_verbose("WARNING: skipping large memory map entry: "
 		"0x%"PRIx64"/0x%"PRIx64"/0x%x\n",
 		seg_start, (seg_end - seg_start), type);
-		return seg_cluster_cnt;
+		return 0;
 	}
 
 	/*
@@ -533,16 +532,16 @@ x86_add_cluster(phys_ram_seg_t *seg_clus
 		seg_end -= PAGE_SIZE;
 
 	if (seg_end <= seg_start)
-		return seg_cluster_cnt;
+		return 0;
 
-	for (i = 0; i < seg_cluster_cnt; i++) {
-		cluster = _clusters[i];
+	for (i = 0; i < mem_cluster_cnt; i++) {
+		cluster = _clusters[i];
 		if ((cluster->start == round_page(seg_start)) &&
 		(cluster->size == trunc_page(seg_end) - cluster->start)) {
 #ifdef DEBUG_MEMLOAD
 			printf("WARNING: skipping duplicate segment entry\n");
 #endif
-			return seg_cluster_cnt;
+			return 0;
 		}
 	}
 
@@ -566,24 +565,22 @@ x86_add_cluster(phys_ram_seg_t *seg_clus
 			"(0x%"PRIx64"/0x%"PRIx64"/0x%x) FROM "
 			"IOMEM EXTENT MAP!\n",
 			seg_start, seg_end - seg_start, type);
-			return seg_cluster_cnt;
+			return 0;
 		}
 	}
 
-	/*
-	 * If it's not free memory, skip it.
-	 */
+	/* If it's not free memory, skip it. */
 	if (type != BIM_Memory)
-		return seg_cluster_cnt;
+		return 0;
 
-	/* XXX XXX XXX */
-	if (seg_cluster_cnt >= VM_PHYSSEG_MAX)
+	if (mem_cluster_cnt >= VM_PHYSSEG_MAX) {
 		panic("%s: too many memory segments (increase VM_PHYSSEG_MAX)",
 			__func__);
+	}
 
 #ifdef PHYSMEM_MAX_ADDR
 	if (seg_start >= MBTOB(PHYSMEM_MAX_ADDR))
-		return seg_cluster_cnt;
+		return 0;
 	if (seg_end > MBTOB(PHYSMEM_MAX_ADDR))
 		seg_end = MBTOB(PHYSMEM_MAX_ADDR);
 #endif
@@ -592,9 +589,9 @@ x86_add_cluster(phys_ram_seg_t *seg_clus
 	seg_end = trunc_page(seg_end);
 
 	if (seg_start == seg_end)
-		return seg_cluster_cnt;
+		return 0;
 
-	cluster = _clusters[seg_cluster_cnt];
+	cluster = _clusters[mem_cluster_cnt];
 	cluster->start = seg_start;
 	if (iomem_ex != NULL)
 		new_physmem = physmem + atop(seg_end - seg_start);
@@ -602,7 +599,7 @@ x86_add_cluster(phys_ram_seg_t *seg_clus
 #ifdef PHYSMEM_MAX_SIZE
 	if (iomem_ex != NULL) {
 		if (physmem >= atop(MBTOB(PHYSMEM_MAX_SIZE)))
-			return seg_cluster_cnt;
+			return 0;
 		if (new_physmem > atop(MBTOB(PHYSMEM_MAX_SIZE))) {
 			seg_end = seg_start + MBTOB(PHYSMEM_MAX_SIZE) - ptoa(physmem);
 			new_physmem = atop(MBTOB(PHYSMEM_MAX_SIZE));
@@ -617,9 +614,9 @@ x86_add_cluster(phys_ram_seg_t *seg_clus
 			avail_end = seg_end;
 		physmem = new_physmem;
 	}
-	seg_cluster_cnt++;
+	mem_cluster_cnt++;
 
-	return seg_cluster_cnt;
+	return 0;
 }
 
 static int
@@ -680,16 +677,10 @@ x86_parse_clusters(struct btinfo_memmap 
 			"0x%"PRIx64"/0x%"PRIx64"/0x%x\n", seg_start,
 			seg_end - seg_start, type);
 
-			mem_cluster_cnt = x86_add_cluster(mem_clusters,
-			mem_cluster_cnt, iomem_ex, seg_start, 0xa,
-			type);
-			mem_cluster_cnt = x86_add_cluster(mem_clusters,
-			mem_cluster_cnt, iomem_ex, 0x10, seg_end,
-			type);
+			x86_add_cluster(iomem_ex, seg_start, 0xa, type);
+			x86_add_cluster(iomem_ex, 0x10, seg_end, type);
 		} else {
-			mem_cluster_cnt = x86_add_cluster(mem_clusters,
-			mem_cluster_cnt, iomem_ex, seg_start, seg_end,
-			type);
+			x86_add_cluster(iomem_ex, seg_start, seg_end, type);
 		}
 	}
 



CVS commit: src/sys/arch/mips/mips

2016-07-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jul 17 12:56:13 UTC 2016

Modified Files:
src/sys/arch/mips/mips: mipsX_subr.S

Log Message:
Update instruction numbers in comments


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/mips/mips/mipsX_subr.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/mips/mips/mipsX_subr.S
diff -u src/sys/arch/mips/mips/mipsX_subr.S:1.71 src/sys/arch/mips/mips/mipsX_subr.S:1.72
--- src/sys/arch/mips/mips/mipsX_subr.S:1.71	Tue Jul 12 03:34:50 2016
+++ src/sys/arch/mips/mips/mipsX_subr.S	Sun Jul 17 12:56:12 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: mipsX_subr.S,v 1.71 2016/07/12 03:34:50 matt Exp $	*/
+/*	$NetBSD: mipsX_subr.S,v 1.72 2016/07/17 12:56:12 skrll Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -373,30 +373,30 @@ VECTOR(MIPSX(tlb_miss), unknown)
 	nop	#01: nop
 	PTR_SRL k1, k0, 31			#02: clear useg bits
 	beqz	k1, 1f#03: k1==0 -> useg address
-	 PTR_SRL k1,k0,2*(PGSHIFT-PTR_SCALESHIFT)+(PGSHIFT-2)+PGSHIFT #05: clear valid bits
-	bnez	k1, MIPSX(nopagetable)		#04: not legal address
-	 PTR_SRL k0, 2*(PGSHIFT-PTR_SCALESHIFT)+(PGSHIFT-2) #05: k0=seg offset (almost)
-	bgez	k0, 1f#05: k0<0 -> kernel fault
-	 lui	k1, %hi(CPUVAR(PMAP_SEGTAB))	#06: k1=hi of segtab
-	PTR_ADDI k1,  1 << PTR_SCALESHIFT	#07: kernel segtab entry
+	 PTR_SRL k1,k0,2*(PGSHIFT-PTR_SCALESHIFT)+(PGSHIFT-2)+PGSHIFT #04: clear valid bits
+	bnez	k1, MIPSX(nopagetable)		#05: not legal address
+	 PTR_SRL k0, 2*(PGSHIFT-PTR_SCALESHIFT)+(PGSHIFT-2) #06: k0=seg offset (almost)
+	bgez	k0, 1f#07: k0<0 -> kernel fault
+	 lui	k1, %hi(CPUVAR(PMAP_SEGTAB))	#08: k1=hi of segtab
+	PTR_ADDI k1,  1 << PTR_SCALESHIFT	#09: kernel segtab entry
 1:
-	andi	k0, NBPG-(1<10)
-	andi	k0, (NPTEPG-1) << PTPSHIFT	#0c: k0=page table offset
-	PTR_ADDU k1, k0#0d: k1=pte address
+	 PTR_SRL k0, PGSHIFT - PTPSHIFT		#0c: k0=VPN (aka va>>10)
+	andi	k0, (NPTEPG-1) << PTPSHIFT	#0d: k0=page table offset
+	PTR_ADDU k1, k0#0e: k1=pte address
 #endif
-	INT_L	k0, 0(k1)			#0e: k0=lo0 pte
+	INT_L	k0, 0(k1)			#0f: k0=lo0 pte
 #ifdef MIPSNNR2
-	_EXT	k0, k0, 0, WIRED_POS		#0f: chop top 2 bits
+	_EXT	k0, k0, 0, WIRED_POS		#10: chop top 2 bits
 #else
-	_SLL	k0, WIRED_SHIFT			#0f: chop top 2 bits (part 1a)
-	_SRL	k0, WIRED_SHIFT			#10: chop top 2 bits (part 1b)
+	_SLL	k0, WIRED_SHIFT			#10: chop top 2 bits (part 1a)
+	_SRL	k0, WIRED_SHIFT			#11: chop top 2 bits (part 1b)
 #endif
-	INT_ADDU k1, k0, MIPS3_PG_NEXT		#11: k1=lo1 pte
+	INT_ADDU k1, k0, MIPS3_PG_NEXT		#12: k1=lo1 pte
 #else /* (PGSHIFT & 1) == 0 */
-	 PTR_SRL k0, PGSHIFT - PTPSHIFT		#0b: k0=VPN (aka va>>10) --ds--
-	andi	k0, 

CVS commit: src/sys/arch/mips/mips

2016-07-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jul 17 16:44:39 UTC 2016

Modified Files:
src/sys/arch/mips/mips: mipsX_subr.S

Log Message:
Fixup some Loongson code after recent changes to pmap and PAGE_SIZE


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/mips/mips/mipsX_subr.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/mips/mips/mipsX_subr.S
diff -u src/sys/arch/mips/mips/mipsX_subr.S:1.72 src/sys/arch/mips/mips/mipsX_subr.S:1.73
--- src/sys/arch/mips/mips/mipsX_subr.S:1.72	Sun Jul 17 12:56:12 2016
+++ src/sys/arch/mips/mips/mipsX_subr.S	Sun Jul 17 16:44:39 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: mipsX_subr.S,v 1.72 2016/07/17 12:56:12 skrll Exp $	*/
+/*	$NetBSD: mipsX_subr.S,v 1.73 2016/07/17 16:44:39 skrll Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -372,10 +372,10 @@ VECTOR(MIPSX(tlb_miss), unknown)
 #ifdef _LP64
 	nop	#01: nop
 	PTR_SRL k1, k0, 31			#02: clear useg bits
-	beqz	k1, 1f#03: k1==0 -> useg address
-	 PTR_SRL k1,k0,2*(PGSHIFT-PTR_SCALESHIFT)+(PGSHIFT-2)+PGSHIFT #04: clear valid bits
+	beqz	k1, 2f#03: k1==0 -> useg address
+	 PTR_SRL k1,k0,XSEGSHIFT+XSEGLENGTH+2	#04: clear valid bits
 	bnez	k1, MIPSX(nopagetable)		#05: not legal address
-	 PTR_SRL k0, 2*(PGSHIFT-PTR_SCALESHIFT)+(PGSHIFT-2) #06: k0=seg offset (almost)
+	 PTR_SRL k0, XSEGSHIFT - PTR_SCALESHIFT #06: k0=seg offset (almost)
 	bgez	k0, 1f#07: k0<0 -> kernel fault
 	 lui	k1, %hi(CPUVAR(PMAP_SEGTAB))	#08: k1=hi of segtab
 	PTR_ADDI k1,  1 << PTR_SCALESHIFT	#09: kernel segtab entry
@@ -386,9 +386,13 @@ VECTOR(MIPSX(tlb_miss), unknown)
 	dmfc0	k0, MIPS_COP_0_BAD_VADDR	#0d: k0=bad address (again)
 	PTR_L	k1, 0(k1)			#0e: k1=seg entry
 	b	MIPSX(tlb_miss_common)		#0f
-	 PTR_SRL k0, 1*(PGSHIFT-PTR_SCALESHIFT)+(PGSHIFT-2) #10: k0=seg offset (almost)
+#ifdef MIPSNNR2
+	 _EXT	k0, k0, SEGSHIFT, SEGLENGTH	#0f: k0=seg index
+#else
+	 PTR_SRL k0, SEGSHIFT - PTR_SCALESHIFT	#0f: k0=seg offset (almost)
+#endif
 #endif /* LP64 */
-1: /* handle useg addresses */
+2: /* handle useg addresses */
 	lui	k1, %hi(CPUVAR(PMAP_SEG0TAB))	#11: k1=hi of seg0tab
 	dsrl	k0, 31#12: clear low 31 bits
 	bnez	k0, MIPSX(nopagetable)		#13: not legal address



CVS commit: src/usr.sbin/makemandb

2016-07-17 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Jul 17 12:18:12 UTC 2016

Modified Files:
src/usr.sbin/makemandb: makemandb.c

Log Message:
Fix extraction of section number and machine architecture from man pages.
With the latest API, mdoc_validate()/man_validate() needs to be called before
reading the roff_man.meta field, otherwise it is NULL.

Also, if a man page doesn't specify machine architecture, don't default to '?'
, let it be stored as null in the db. Otherwise, the output of apropos(1) shows
the names of the results as \?/


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/makemandb/makemandb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makemandb/makemandb.c
diff -u src/usr.sbin/makemandb/makemandb.c:1.40 src/usr.sbin/makemandb/makemandb.c:1.41
--- src/usr.sbin/makemandb/makemandb.c:1.40	Fri Jul 15 19:41:33 2016
+++ src/usr.sbin/makemandb/makemandb.c	Sun Jul 17 12:18:12 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.40 2016/07/15 19:41:33 christos Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.41 2016/07/17 12:18:12 abhinav Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.40 2016/07/15 19:41:33 christos Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.41 2016/07/17 12:18:12 abhinav Exp $");
 
 #include 
 #include 
@@ -928,16 +928,18 @@ begin_parse(const char *file, struct mpa
 		return;
 	}
 
-	set_machine(roff, rec);
-	set_section(roff, rec);
 	if (roff->macroset == MACROSET_MDOC) {
+		mdoc_validate(roff);
 		rec->page_type = MDOC;
 		proff_node(roff->first->child, rec, mdocs);
 	} else if (roff->macroset == MACROSET_MAN) {
+		man_validate(roff);
 		rec->page_type = MAN;
 		proff_node(roff->first->child, rec, mans);
 	} else
 		warnx("Unknown macroset %d", roff->macroset);
+	set_machine(roff, rec);
+	set_section(roff, rec);
 }
 
 /*
@@ -967,8 +969,8 @@ set_machine(const struct roff_man *rm, m
 	if (rm == NULL)
 		return;
 	const struct roff_meta *rm_meta = >meta;
-	const char *a = rm_meta->arch == NULL ? "?" : rm_meta->arch;
-	rec->machine = estrdup(a);
+	if (rm_meta->arch)
+		rec->machine = estrdup(rm_meta->arch);
 }
 
 /*



CVS commit: src/lib/libpthread

2016-07-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jul 17 13:49:43 UTC 2016

Modified Files:
src/lib/libpthread: pthread_mutex.c pthread_types.h

Log Message:
Use anonymous union for ptm_ceiling and old __pthread_spin_t field to
maintain backward compatibility and fix hppa build.  hppa has an non-
integer type __pthread_spin_t


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/lib/libpthread/pthread_mutex.c
cvs rdiff -u -r1.18 -r1.19 src/lib/libpthread/pthread_types.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libpthread/pthread_mutex.c
diff -u src/lib/libpthread/pthread_mutex.c:1.61 src/lib/libpthread/pthread_mutex.c:1.62
--- src/lib/libpthread/pthread_mutex.c:1.61	Sat Jul 16 12:58:11 2016
+++ src/lib/libpthread/pthread_mutex.c	Sun Jul 17 13:49:43 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pthread_mutex.c,v 1.61 2016/07/16 12:58:11 skrll Exp $	*/
+/*	$NetBSD: pthread_mutex.c,v 1.62 2016/07/17 13:49:43 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: pthread_mutex.c,v 1.61 2016/07/16 12:58:11 skrll Exp $");
+__RCSID("$NetBSD: pthread_mutex.c,v 1.62 2016/07/17 13:49:43 skrll Exp $");
 
 #include 
 #include 
@@ -796,7 +796,7 @@ pthread__mutex_deferwake(pthread_t self,
 int
 pthread_mutex_getprioceiling(const pthread_mutex_t *ptm, int *ceil) 
 {
-	*ceil = (unsigned int)ptm->ptm_ceiling;
+	*ceil = ptm->ptm_ceiling;
 	return 0;
 }
 
@@ -807,9 +807,9 @@ pthread_mutex_setprioceiling(pthread_mut
 
 	error = pthread_mutex_lock(ptm);
 	if (error == 0) {
-		*old_ceil = (unsigned int)ptm->ptm_ceiling;
+		*old_ceil = ptm->ptm_ceiling;
 		/*check range*/
-		ptm->ptm_ceiling = (unsigned char)ceil;
+		ptm->ptm_ceiling = ceil;
 		pthread_mutex_unlock(ptm);
 	}
 	return error;

Index: src/lib/libpthread/pthread_types.h
diff -u src/lib/libpthread/pthread_types.h:1.18 src/lib/libpthread/pthread_types.h:1.19
--- src/lib/libpthread/pthread_types.h:1.18	Sun Jul  3 14:24:58 2016
+++ src/lib/libpthread/pthread_types.h	Sun Jul 17 13:49:43 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pthread_types.h,v 1.18 2016/07/03 14:24:58 christos Exp $	*/
+/*	$NetBSD: pthread_types.h,v 1.19 2016/07/17 13:49:43 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2008 The NetBSD Foundation, Inc.
@@ -115,7 +115,10 @@ struct	__pthread_mutex_st {
 #ifdef __CPU_SIMPLE_LOCK_PAD
 	uint8_t		ptm_pad1[3];
 #endif
-	__pthread_spin_t ptm_ceiling;
+	union {
+		unsigned char ptm_ceiling;
+		__pthread_spin_t ptm_unused;
+	};
 #ifdef __CPU_SIMPLE_LOCK_PAD
 	uint8_t		ptm_pad2[3];
 #endif
@@ -131,13 +134,13 @@ struct	__pthread_mutex_st {
 #ifdef __CPU_SIMPLE_LOCK_PAD
 #define _PTHREAD_MUTEX_INITIALIZER { _PT_MUTEX_MAGIC, 			\
 __SIMPLELOCK_UNLOCKED, { 0, 0, 0 },	\
-__SIMPLELOCK_UNLOCKED, { 0, 0, 0 },	\
+{ 0 }, { 0, 0, 0 },			\
 NULL, NULL, 0, NULL			\
   }
 #else
 #define _PTHREAD_MUTEX_INITIALIZER { _PT_MUTEX_MAGIC, 			\
 __SIMPLELOCK_UNLOCKED,		\
-__SIMPLELOCK_UNLOCKED,		\
+{ 0 } ,\
 NULL, NULL, 0, NULL			\
   }
 #endif /* __CPU_SIMPLE_LOCK_PAD */



CVS commit: src/usr.sbin/makemandb

2016-07-17 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Jul 17 15:56:14 UTC 2016

Modified Files:
src/usr.sbin/makemandb: makemandb.c

Log Message:
Use deroff() from mandoc(3) to directly parse the Nd macro rather
than parsing it by hand.

With the latest mandoc(3), the .Nd macro was getting parsed twice. This fixes
that problem and cleans up the code as well.

ok christos@


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/makemandb/makemandb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makemandb/makemandb.c
diff -u src/usr.sbin/makemandb/makemandb.c:1.41 src/usr.sbin/makemandb/makemandb.c:1.42
--- src/usr.sbin/makemandb/makemandb.c:1.41	Sun Jul 17 12:18:12 2016
+++ src/usr.sbin/makemandb/makemandb.c	Sun Jul 17 15:56:14 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.41 2016/07/17 12:18:12 abhinav Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.42 2016/07/17 15:56:14 abhinav Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.41 2016/07/17 12:18:12 abhinav Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.42 2016/07/17 15:56:14 abhinav Exp $");
 
 #include 
 #include 
@@ -999,41 +999,9 @@ pmdoc_Nm(const struct roff_node *n, mand
 static void
 pmdoc_Nd(const struct roff_node *n, mandb_rec *rec)
 {
-	char *buf = NULL;
-	char *name;
-	char *nd_text;
+	if (n->type == ROFFT_BODY)
+		deroff(>name_desc, n);
 
-	if (n == NULL || (n->type != ROFFT_TEXT && n->tok == MDOC_MAX))
-		return;
-
-	if (n->type == ROFFT_TEXT) {
-		if (rec->xr_found && n->next) {
-			/*
-			 * An Xr macro was seen previously, so parse this
-			 * and the next node, as "Name(Section)".
-			 */
-			name = n->string;
-			n = n->next;
-			assert(n->type == ROFFT_TEXT);
-			easprintf(, "%s(%s)", name, n->string);
-			concat(>name_desc, buf);
-			free(buf);
-		} else {
-			nd_text = parse_escape(n->string);
-			concat(>name_desc, nd_text);
-			free(nd_text);
-		}
-		rec->xr_found = 0;
-	} else if (mdocs[n->tok] == pmdoc_Xr) {
-		/* Remember that we have encountered an Xr macro */
-		rec->xr_found = 1;
-	}
-
-	if (n->child)
-		pmdoc_Nd(n->child, rec);
-
-	if(n->next)
-		pmdoc_Nd(n->next, rec);
 }
 
 /*



CVS commit: [pgoyette-localcount] src/sys/kern

2016-07-17 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sun Jul 17 12:09:21 UTC 2016

Modified Files:
src/sys/kern [pgoyette-localcount]: subr_devsw.c

Log Message:
More details in KASSERTs to aid debugging


To generate a diff of this commit:
cvs rdiff -u -r1.34.2.4 -r1.34.2.5 src/sys/kern/subr_devsw.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_devsw.c
diff -u src/sys/kern/subr_devsw.c:1.34.2.4 src/sys/kern/subr_devsw.c:1.34.2.5
--- src/sys/kern/subr_devsw.c:1.34.2.4	Sun Jul 17 05:02:19 2016
+++ src/sys/kern/subr_devsw.c	Sun Jul 17 12:09:21 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_devsw.c,v 1.34.2.4 2016/07/17 05:02:19 pgoyette Exp $	*/
+/*	$NetBSD: subr_devsw.c,v 1.34.2.5 2016/07/17 12:09:21 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.4 2016/07/17 05:02:19 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.5 2016/07/17 12:09:21 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dtrace.h"
@@ -143,11 +143,15 @@ devsw_attach(const char *devname,
 	mutex_enter(_lock);
 
 	if (bdev != NULL) {
-		KASSERT(bdev->d_localcount != NULL);
-		KASSERT(bdev->d_localcount != cdev->d_localcount);
+		KASSERTMSG(bdev->d_localcount != NULL,
+		"%s: bdev %s has no d_localcount", __func__, devname);
+		KASSERTMSG(bdev->d_localcount != cdev->d_localcount,
+		"%s: bdev and cdev for %s have same d_localcount",
+		__func__, devname);
 	}
 	if (cdev != NULL)
-		KASSERT(cdev->d_localcount != NULL);
+		KASSERTMGS(cdev->d_localcount != NULL,
+		"%s: cdev %s has no d_localcount", __func__, devname);
 
 	for (i = 0 ; i < max_devsw_convs ; i++) {
 		conv = _conv[i];
@@ -272,7 +276,7 @@ bdevsw_attach(const struct bdevsw *devsw
 	}
 
 	if (*devmajor >= MAXDEVSW) {
-		printf("bdevsw_attach: block majors exhausted");
+		printf("%s: block majors exhausted", __func__);
 		return (ENOMEM);
 	}
 
@@ -293,7 +297,8 @@ bdevsw_attach(const struct bdevsw *devsw
 	membar_producer();
 
 	bdevsw[*devmajor] = devsw;
-	KASSERT(devsw->d_localcount != NULL);
+	KASSERTMSG(devsw->d_localcount != NULL, "%s: bdev for major %d has "
+	"no localcount", __func__, *devmajor);
 	localcount_init(devsw->d_localcount);
 
 	return (0);
@@ -324,7 +329,7 @@ cdevsw_attach(const struct cdevsw *devsw
 	}
 
 	if (*devmajor >= MAXDEVSW) {
-		printf("cdevsw_attach: character majors exhausted");
+		printf("%s: character majors exhausted", __func__);
 		return (ENOMEM);
 	}
 
@@ -345,7 +350,8 @@ cdevsw_attach(const struct cdevsw *devsw
 	membar_producer();
 
 	cdevsw[*devmajor] = devsw;
-	KASSERT(devsw->d_localcount != NULL);
+	KASSERTMSG(devsw->d_localcount != NULL, "%s: cdev for major %d has "
+	"no localcount", __func__, *devmajor);
 	localcount_init(devsw->d_localcount);
 
 	return (0);
@@ -371,7 +377,7 @@ devsw_detach_locked(const struct bdevsw 
 continue;
 
 			KASSERTMSG(bdev->d_localcount != NULL,
-			"%s: no bdev localcount", __func__);
+			"%s: no bdev localcount for major %d", __func__, i);
 			break;
 		}
 	}
@@ -382,7 +388,7 @@ devsw_detach_locked(const struct bdevsw 
 continue;
 
 			KASSERTMSG(cdev->d_localcount != NULL,
-			"%s: no cdev localcount", __func__);
+			"%s: no cdev localcount for major %d", __func__, j);
 			break;
 		}
 	}
@@ -400,7 +406,7 @@ devsw_detach_locked(const struct bdevsw 
 	pserialize_perform(device_psz);
 
 	/*
-	 * Here, no new readers can reach the bdev and cdev via the
+	 * No new readers can reach the bdev and cdev via the
 	 * {b,c}devsw[] arrays.  Wait for existing references to
 	 * drain, and then destroy.
 	 */



CVS commit: src/sys/dev/usb

2016-07-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jul 17 20:13:19 UTC 2016

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
Various improvement from t-hash (and a bit from me).

- Flesh out the abort routine
- Avoid using EVENT_DATA
- Miscellaneous debug
- Comment improvement


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/dev/usb/xhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.62 src/sys/dev/usb/xhci.c:1.63
--- src/sys/dev/usb/xhci.c:1.62	Fri Jul  8 05:38:31 2016
+++ src/sys/dev/usb/xhci.c	Sun Jul 17 20:13:19 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.62 2016/07/08 05:38:31 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.63 2016/07/17 20:13:19 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.62 2016/07/08 05:38:31 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.63 2016/07/17 20:13:19 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -520,6 +520,17 @@ xhci_trb_get_idx(struct xhci_ring *xr, u
 	return 0;
 }
 
+static unsigned int
+xhci_get_epstate(struct xhci_softc * const sc, struct xhci_slot * const xs,
+u_int dci)
+{
+	uint32_t *cp;
+
+	usb_syncmem(>xs_dc_dma, 0, sc->sc_pgsz, BUS_DMASYNC_POSTREAD);
+	cp = xhci_slot_get_dcv(sc, xs, dci);
+	return XHCI_EPCTX_0_EPSTATE_GET(le32toh(cp[0]));
+}
+
 /* --- */
 
 void
@@ -1279,7 +1290,7 @@ xhci_unconfigure_endpoint(struct usbd_pi
 
 /* 4.6.8, 6.4.3.7 */
 static usbd_status
-xhci_reset_endpoint(struct usbd_pipe *pipe)
+xhci_reset_endpoint_locked(struct usbd_pipe *pipe)
 {
 	struct xhci_softc * const sc = XHCI_PIPE2SC(pipe);
 	struct xhci_slot * const xs = pipe->up_dev->ud_hcpriv;
@@ -1290,17 +1301,31 @@ xhci_reset_endpoint(struct usbd_pipe *pi
 	XHCIHIST_FUNC(); XHCIHIST_CALLED();
 	DPRINTFN(4, "slot %u dci %u", xs->xs_idx, dci, 0, 0);
 
+	KASSERT(mutex_owned(>sc_lock));
+
 	trb.trb_0 = 0;
 	trb.trb_2 = 0;
 	trb.trb_3 = XHCI_TRB_3_SLOT_SET(xs->xs_idx) |
 	XHCI_TRB_3_EP_SET(dci) |
 	XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_RESET_EP);
 
-	err = xhci_do_command(sc, , USBD_DEFAULT_TIMEOUT);
+	err = xhci_do_command_locked(sc, , USBD_DEFAULT_TIMEOUT);
 
 	return err;
 }
 
+static usbd_status
+xhci_reset_endpoint(struct usbd_pipe *pipe)
+{
+	struct xhci_softc * const sc = XHCI_PIPE2SC(pipe);
+
+	mutex_enter(>sc_lock);
+	usbd_status ret = xhci_reset_endpoint_locked(pipe);
+	mutex_exit(>sc_lock);
+
+	return ret;
+}
+
 /*
  * 4.6.9, 6.4.3.8
  * Stop execution of TDs on xfer ring.
@@ -1340,7 +1365,7 @@ xhci_stop_endpoint(struct usbd_pipe *pip
  * error will be generated.
  */
 static usbd_status
-xhci_set_dequeue(struct usbd_pipe *pipe)
+xhci_set_dequeue_locked(struct usbd_pipe *pipe)
 {
 	struct xhci_softc * const sc = XHCI_PIPE2SC(pipe);
 	struct xhci_slot * const xs = pipe->up_dev->ud_hcpriv;
@@ -1352,6 +1377,8 @@ xhci_set_dequeue(struct usbd_pipe *pipe)
 	XHCIHIST_FUNC(); XHCIHIST_CALLED();
 	DPRINTFN(4, "slot %u dci %u", xs->xs_idx, dci, 0, 0);
 
+	KASSERT(mutex_owned(>sc_lock));
+
 	xhci_host_dequeue(xr);
 
 	/* set DCS */
@@ -1361,11 +1388,23 @@ xhci_set_dequeue(struct usbd_pipe *pipe)
 	XHCI_TRB_3_EP_SET(dci) |
 	XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_SET_TR_DEQUEUE);
 
-	err = xhci_do_command(sc, , USBD_DEFAULT_TIMEOUT);
+	err = xhci_do_command_locked(sc, , USBD_DEFAULT_TIMEOUT);
 
 	return err;
 }
 
+static usbd_status
+xhci_set_dequeue(struct usbd_pipe *pipe)
+{
+	struct xhci_softc * const sc = XHCI_PIPE2SC(pipe);
+
+	mutex_enter(>sc_lock);
+	usbd_status ret = xhci_set_dequeue_locked(pipe);
+	mutex_exit(>sc_lock);
+
+	return ret;
+}
+
 /*
  * Open new pipe: called from usbd_setup_pipe_flags.
  * Fills methods of pipe.
@@ -1508,12 +1547,14 @@ xhci_close_pipe(struct usbd_pipe *pipe)
 
 /*
  * Abort transfer.
- * May be called from softintr context.
+ * Should be called with sc_lock held.
  */
 static void
 xhci_abort_xfer(struct usbd_xfer *xfer, usbd_status status)
 {
 	struct xhci_softc * const sc = XHCI_XFER2SC(xfer);
+	struct xhci_slot * const xs = xfer->ux_pipe->up_dev->ud_hcpriv;
+	const u_int dci = xhci_ep_get_dci(xfer->ux_pipe->up_endpoint->ue_edesc);
 
 	XHCIHIST_FUNC(); XHCIHIST_CALLED();
 	DPRINTFN(4, "xfer %p pipe %p status %d",
@@ -1530,10 +1571,66 @@ xhci_abort_xfer(struct usbd_xfer *xfer, 
 		return;
 	}
 
-	/* XXX need more stuff */
+	/*
+	 * If an abort is already in progress then just wait for it to
+	 * complete and return.
+	 */
+	if (xfer->ux_hcflags & UXFER_ABORTING) {
+		DPRINTFN(4, "already aborting", 0, 0, 0, 0);
+#ifdef DIAGNOSTIC
+		if (status == USBD_TIMEOUT)
+			DPRINTFN(4, "TIMEOUT while aborting", 0, 0, 0, 0);
+#endif
+		/* Override the status which might be USBD_TIMEOUT. */
+		xfer->ux_status = status;
+		DPRINTFN(4, "xfer %p waiting for abort to finish", xfer, 0, 0,
+		0);
+		xfer->ux_hcflags |= UXFER_ABORTWAIT;
+		while 

CVS commit: src/distrib/sets/lists/comp

2016-07-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jul 17 19:44:57 UTC 2016

Modified Files:
src/distrib/sets/lists/comp: mi

Log Message:
remove ctf lint library


To generate a diff of this commit:
cvs rdiff -u -r1.2051 -r1.2052 src/distrib/sets/lists/comp/mi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2051 src/distrib/sets/lists/comp/mi:1.2052
--- src/distrib/sets/lists/comp/mi:1.2051	Mon Jul 11 23:39:55 2016
+++ src/distrib/sets/lists/comp/mi	Sun Jul 17 15:44:56 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2051 2016/07/12 03:39:55 knakahara Exp $
+#	$NetBSD: mi,v 1.2052 2016/07/17 19:44:56 christos Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -3667,7 +3667,6 @@
 ./usr/libdata/lint/llib-lcrypto_idea.ln		comp-obsolete		obsolete
 ./usr/libdata/lint/llib-lcrypto_mdc2.ln		comp-obsolete		obsolete
 ./usr/libdata/lint/llib-lcrypto_rc5.ln		comp-c-lintlib		lint,crypto_rc5
-./usr/libdata/lint/llib-lctf.ln			comp-c-lintlib		lint,ctf
 ./usr/libdata/lint/llib-lcurses.ln		comp-c-lintlib		lint
 ./usr/libdata/lint/llib-ldes.ln			comp-c-lintlib		lint,crypto
 ./usr/libdata/lint/llib-ldm.ln			comp-c-lintlib		lint



CVS commit: [pgoyette-localcount] src/sys/kern

2016-07-17 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sun Jul 17 21:40:47 UTC 2016

Modified Files:
src/sys/kern [pgoyette-localcount]: subr_devsw.c

Log Message:
Fix typo in KASSERTMSG macro name


To generate a diff of this commit:
cvs rdiff -u -r1.34.2.6 -r1.34.2.7 src/sys/kern/subr_devsw.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_devsw.c
diff -u src/sys/kern/subr_devsw.c:1.34.2.6 src/sys/kern/subr_devsw.c:1.34.2.7
--- src/sys/kern/subr_devsw.c:1.34.2.6	Sun Jul 17 21:39:17 2016
+++ src/sys/kern/subr_devsw.c	Sun Jul 17 21:40:47 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_devsw.c,v 1.34.2.6 2016/07/17 21:39:17 pgoyette Exp $	*/
+/*	$NetBSD: subr_devsw.c,v 1.34.2.7 2016/07/17 21:40:47 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.6 2016/07/17 21:39:17 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.7 2016/07/17 21:40:47 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dtrace.h"
@@ -157,7 +157,7 @@ devsw_attach(const char *devname,
 		__func__, devname);
 	}
 	if (cdev != NULL)
-		KASSERTMGS(cdev->d_localcount != NULL,
+		KASSERTMSG(cdev->d_localcount != NULL,
 		"%s: cdev %s has no d_localcount", __func__, devname);
 
 	for (i = 0 ; i < max_devsw_convs ; i++) {



CVS commit: [pgoyette-localcount] src/sys

2016-07-17 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jul 18 03:50:00 UTC 2016

Modified Files:
src/sys/dev [pgoyette-localcount]: audio.c cgd.c fss.c ld.c md.c
rndpseudo.c vnd.c
src/sys/dev/dm [pgoyette-localcount]: device-mapper.c
src/sys/dev/pci [pgoyette-localcount]: pci_usrreq.c
src/sys/dev/scsipi [pgoyette-localcount]: cd.c sd.c
src/sys/dev/sysmon [pgoyette-localcount]: sysmon.c
src/sys/dev/usb [pgoyette-localcount]: ucom.c ulpt.c
src/sys/dev/wscons [pgoyette-localcount]: wskbd.c wsmouse.c
src/sys/kern [pgoyette-localcount]: kern_drvctl.c tty_ptm.c tty_pty.c
tty_tty.c
src/sys/net [pgoyette-localcount]: if_tap.c
src/sys/net/npf [pgoyette-localcount]: npf.c
src/sys/opencrypto [pgoyette-localcount]: cryptodev.c
src/sys/rump/librump/rumpvfs [pgoyette-localcount]: devnull.c rumpblk.c

Log Message:
Rump drivers are always installed via devsw_attach() so we need to
always allocate a 'struct localcount' for these drivers whenever they
are built as modules.


To generate a diff of this commit:
cvs rdiff -u -r1.268 -r1.268.2.1 src/sys/dev/audio.c
cvs rdiff -u -r1.108 -r1.108.2.1 src/sys/dev/cgd.c
cvs rdiff -u -r1.93 -r1.93.2.1 src/sys/dev/fss.c
cvs rdiff -u -r1.94 -r1.94.2.1 src/sys/dev/ld.c
cvs rdiff -u -r1.76 -r1.76.2.1 src/sys/dev/md.c
cvs rdiff -u -r1.35 -r1.35.2.1 src/sys/dev/rndpseudo.c
cvs rdiff -u -r1.256 -r1.256.2.1 src/sys/dev/vnd.c
cvs rdiff -u -r1.38 -r1.38.2.1 src/sys/dev/dm/device-mapper.c
cvs rdiff -u -r1.29 -r1.29.2.1 src/sys/dev/pci/pci_usrreq.c
cvs rdiff -u -r1.331 -r1.331.2.1 src/sys/dev/scsipi/cd.c
cvs rdiff -u -r1.317 -r1.317.2.1 src/sys/dev/scsipi/sd.c
cvs rdiff -u -r1.28 -r1.28.2.1 src/sys/dev/sysmon/sysmon.c
cvs rdiff -u -r1.113 -r1.113.2.1 src/sys/dev/usb/ucom.c
cvs rdiff -u -r1.97 -r1.97.2.1 src/sys/dev/usb/ulpt.c
cvs rdiff -u -r1.136 -r1.136.2.1 src/sys/dev/wscons/wskbd.c
cvs rdiff -u -r1.66 -r1.66.8.1 src/sys/dev/wscons/wsmouse.c
cvs rdiff -u -r1.41 -r1.41.2.1 src/sys/kern/kern_drvctl.c
cvs rdiff -u -r1.37 -r1.37.2.1 src/sys/kern/tty_ptm.c
cvs rdiff -u -r1.142 -r1.142.2.1 src/sys/kern/tty_pty.c
cvs rdiff -u -r1.40 -r1.40.8.1 src/sys/kern/tty_tty.c
cvs rdiff -u -r1.84 -r1.84.2.1 src/sys/net/if_tap.c
cvs rdiff -u -r1.31 -r1.31.2.1 src/sys/net/npf/npf.c
cvs rdiff -u -r1.85 -r1.85.2.1 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.7 -r1.7.2.1 src/sys/rump/librump/rumpvfs/devnull.c
cvs rdiff -u -r1.64 -r1.64.2.1 src/sys/rump/librump/rumpvfs/rumpblk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/audio.c
diff -u src/sys/dev/audio.c:1.268 src/sys/dev/audio.c:1.268.2.1
--- src/sys/dev/audio.c:1.268	Thu Jul 14 10:19:05 2016
+++ src/sys/dev/audio.c	Mon Jul 18 03:49:59 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.268 2016/07/14 10:19:05 msaitoh Exp $	*/
+/*	$NetBSD: audio.c,v 1.268.2.1 2016/07/18 03:49:59 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -155,7 +155,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.268 2016/07/14 10:19:05 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.268.2.1 2016/07/18 03:49:59 pgoyette Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -178,6 +178,7 @@ __KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -346,6 +347,10 @@ dev_type_poll(audiopoll);
 dev_type_mmap(audiommap);
 dev_type_kqfilter(audiokqfilter);
 
+#ifdef _MODULE
+struct localcount audio_localcount;
+#endif
+
 const struct cdevsw audio_cdevsw = {
 	.d_open = audioopen,
 	.d_close = audioclose,
@@ -358,6 +363,9 @@ const struct cdevsw audio_cdevsw = {
 	.d_mmap = audiommap,
 	.d_kqfilter = audiokqfilter,
 	.d_discard = nodiscard,
+#ifdef _MODULE
+	.d_localcount = _localcount,
+#endif
 	.d_flag = D_OTHER | D_MPSAFE
 };
 

Index: src/sys/dev/cgd.c
diff -u src/sys/dev/cgd.c:1.108 src/sys/dev/cgd.c:1.108.2.1
--- src/sys/dev/cgd.c:1.108	Sun Jul 10 17:40:23 2016
+++ src/sys/dev/cgd.c	Mon Jul 18 03:49:59 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.108 2016/07/10 17:40:23 riastradh Exp $ */
+/* $NetBSD: cgd.c,v 1.108.2.1 2016/07/18 03:49:59 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108 2016/07/10 17:40:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.1 2016/07/18 03:49:59 pgoyette Exp $");
 
 #include 
 #include 
@@ -51,6 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.10
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -70,6 +71,10 @@ static dev_type_strategy(cgdstrategy);
 static dev_type_dump(cgddump);
 static dev_type_size(cgdsize);
 
+#ifdef _MODULE
+struct localcount cgd_b_localcount, cgd_c_localcount;
+#endif
+
 const struct bdevsw cgd_bdevsw = {
 	.d_open = cgdopen,
 	.d_close = cgdclose,
@@ -78,6 +83,9 @@ 

CVS commit: [pgoyette-localcount] src/distrib/sets/lists/comp

2016-07-17 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jul 18 03:39:13 UTC 2016

Modified Files:
src/distrib/sets/lists/comp [pgoyette-localcount]: mi

Log Message:
Update sets for new devsw_attach MLINKS


To generate a diff of this commit:
cvs rdiff -u -r1.2051.2.2 -r1.2051.2.3 src/distrib/sets/lists/comp/mi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2051.2.2 src/distrib/sets/lists/comp/mi:1.2051.2.3
--- src/distrib/sets/lists/comp/mi:1.2051.2.2	Sat Jul 16 09:49:24 2016
+++ src/distrib/sets/lists/comp/mi	Mon Jul 18 03:39:13 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2051.2.2 2016/07/16 09:49:24 pgoyette Exp $
+#	$NetBSD: mi,v 1.2051.2.3 2016/07/18 03:39:13 pgoyette Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -9865,7 +9865,9 @@
 ./usr/share/man/cat9/bcmp.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/bcopy.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/bdevsw_lookup.0		comp-sys-catman		.cat
+./usr/share/man/cat9/bdevsw_lookup_acquire.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/bdevsw_lookup_major.0	comp-sys-catman		.cat
+./usr/share/man/cat9/bdevsw_release.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/bdevvp.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/bdwrite.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/be16dec.0			comp-sys-catman		.cat
@@ -10006,7 +10008,9 @@
 ./usr/share/man/cat9/cardbus_mapreg_map.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/cardbus_mapreg_unmap.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/cdevsw_lookup.0		comp-sys-catman		.cat
+./usr/share/man/cat9/cdevsw_lookup_acquire.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/cdevsw_lookup_major.0	comp-sys-catman		.cat
+./usr/share/man/cat9/cdevsw_release.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/cdevvp.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/checkalias.0		comp-obsolete		obsolete
 ./usr/share/man/cat9/child_return.0		comp-sys-catman		.cat
@@ -17049,7 +17053,9 @@
 ./usr/share/man/html9/bcmp.html			comp-sys-htmlman	html
 ./usr/share/man/html9/bcopy.html		comp-sys-htmlman	html
 ./usr/share/man/html9/bdevsw_lookup.html	comp-sys-htmlman	html
+./usr/share/man/html9/bdevsw_lookup_acquire.html comp-sys-htmlman	html
 ./usr/share/man/html9/bdevsw_lookup_major.html	comp-sys-htmlman	html
+./usr/share/man/html9/bdevsw_release.html	comp-sys-htmlman	html
 ./usr/share/man/html9/bdevvp.html		comp-sys-htmlman	html
 ./usr/share/man/html9/bdwrite.html		comp-sys-htmlman	html
 ./usr/share/man/html9/be16dec.html		comp-sys-htmlman	html
@@ -17188,7 +17194,9 @@
 ./usr/share/man/html9/cardbus_mapreg_map.html	comp-sys-htmlman	html
 ./usr/share/man/html9/cardbus_mapreg_unmap.html comp-sys-htmlman	html
 ./usr/share/man/html9/cdevsw_lookup.html	comp-sys-htmlman	html
+./usr/share/man/html9/cdevsw_lookup_acquire.html comp-sys-htmlman	html
 ./usr/share/man/html9/cdevsw_lookup_major.html	comp-sys-htmlman	html
+./usr/share/man/html9/cdevsw_release.html	comp-sys-htmlman	html
 ./usr/share/man/html9/cdevvp.html		comp-sys-htmlman	html
 ./usr/share/man/html9/checkalias.html		comp-obsolete	obsolete
 ./usr/share/man/html9/child_return.html		comp-sys-htmlman	html
@@ -24337,7 +24345,9 @@
 ./usr/share/man/man9/bcmp.9			comp-sys-man		.man
 ./usr/share/man/man9/bcopy.9			comp-sys-man		.man
 ./usr/share/man/man9/bdevsw_lookup.9		comp-sys-man		.man
+./usr/share/man/man9/bdevsw_lookup_acquire.9	comp-sys-man		.man
 ./usr/share/man/man9/bdevsw_lookup_major.9	comp-sys-man		.man
+./usr/share/man/man9/bdevsw_release.9		comp-sys-man		.man
 ./usr/share/man/man9/bdevvp.9			comp-sys-man		.man
 ./usr/share/man/man9/bdwrite.9			comp-sys-man		.man
 ./usr/share/man/man9/be16dec.9			comp-sys-man		.man
@@ -24478,7 +24488,9 @@
 ./usr/share/man/man9/cardbus_mapreg_map.9	comp-sys-man		.man
 ./usr/share/man/man9/cardbus_mapreg_unmap.9	comp-sys-man		.man
 ./usr/share/man/man9/cdevsw_lookup.9		comp-sys-man		.man
+./usr/share/man/man9/cdevsw_lookup_acquire.9	comp-sys-man		.man
 ./usr/share/man/man9/cdevsw_lookup_major.9	comp-sys-man		.man
+./usr/share/man/man9/cdevsw_release.9		comp-sys-man		.man
 ./usr/share/man/man9/cdevvp.9			comp-sys-man		.man
 ./usr/share/man/man9/checkalias.9		comp-obsolete		obsolete
 ./usr/share/man/man9/child_return.9		comp-sys-man		.man



CVS commit: [pgoyette-localcount] src/share/man/man9

2016-07-17 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jul 18 03:38:09 UTC 2016

Modified Files:
src/share/man/man9 [pgoyette-localcount]: Makefile

Log Message:
Additional MLINKS for devsw_attach


To generate a diff of this commit:
cvs rdiff -u -r1.396.2.2 -r1.396.2.3 src/share/man/man9/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/Makefile
diff -u src/share/man/man9/Makefile:1.396.2.2 src/share/man/man9/Makefile:1.396.2.3
--- src/share/man/man9/Makefile:1.396.2.2	Sat Jul 16 09:49:24 2016
+++ src/share/man/man9/Makefile	Mon Jul 18 03:38:09 2016
@@ -1,4 +1,4 @@
-#   $NetBSD: Makefile,v 1.396.2.2 2016/07/16 09:49:24 pgoyette Exp $
+#   $NetBSD: Makefile,v 1.396.2.3 2016/07/18 03:38:09 pgoyette Exp $
 
 #	Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -281,8 +281,12 @@ MLINKS+=delay.9 DELAY.9
 MLINKS+=devsw_attach.9 devsw_detach.9 \
 	devsw_attach.9 bdevsw_lookup.9 \
 	devsw_attach.9 cdevsw_lookup.9 \
+	devsw_attach.9 bdevsw_lookup_acquire.9 \
+	devsw_attach.9 cdevsw_lookup_acquire.9 \
 	devsw_attach.9 bdevsw_lookup_major.9 \
-	devsw_attach.9 cdevsw_lookup_major.9
+	devsw_attach.9 cdevsw_lookup_major.9 \
+	devsw_attach.9 bdevsw_release.9 \
+	devsw_attach.9 cdevsw_release.9
 MLINKS+=disk.9 disk_attach.9 disk.9 disk_detach.9 \
 	disk.9 disk_busy.9 disk.9 disk_unbusy.9 disk.9 disk_find.9 \
 	disk.9 disk_init.9 disk.9 disk_destroy.9 disk.9 disk_begindetach.9



CVS commit: [pgoyette-localcount] src/external/cddl/osnet

2016-07-17 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jul 18 03:50:58 UTC 2016

Modified Files:
src/external/cddl/osnet/dev/fbt [pgoyette-localcount]: fbt.c
src/external/cddl/osnet/dev/sdt [pgoyette-localcount]: sdt.c
src/external/cddl/osnet/dist/uts/common/dtrace [pgoyette-localcount]:
dtrace.c
src/external/cddl/osnet/dist/uts/common/fs/zfs [pgoyette-localcount]:
zfs_ioctl.c

Log Message:
More rump drivers that need to have a 'struct localcount' when built
as modules.


To generate a diff of this commit:
cvs rdiff -u -r1.18.2.2 -r1.18.2.3 src/external/cddl/osnet/dev/fbt/fbt.c
cvs rdiff -u -r1.16.2.2 -r1.16.2.3 src/external/cddl/osnet/dev/sdt/sdt.c
cvs rdiff -u -r1.32.2.2 -r1.32.2.3 \
src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c
cvs rdiff -u -r1.10 -r1.10.2.1 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/fbt.c
diff -u src/external/cddl/osnet/dev/fbt/fbt.c:1.18.2.2 src/external/cddl/osnet/dev/fbt/fbt.c:1.18.2.3
--- src/external/cddl/osnet/dev/fbt/fbt.c:1.18.2.2	Sun Jul 17 05:18:11 2016
+++ src/external/cddl/osnet/dev/fbt/fbt.c	Mon Jul 18 03:50:58 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt.c,v 1.18.2.2 2016/07/17 05:18:11 pgoyette Exp $	*/
+/*	$NetBSD: fbt.c,v 1.18.2.3 2016/07/18 03:50:58 pgoyette Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -166,7 +166,7 @@ static const struct cdevsw fbt_cdevsw = 
 	.d_mmap		= nommap,
 	.d_kqfilter	= nokqfilter,
 	.d_discard	= nodiscard,
-	.d_localcount	= fbt_localcount,
+	.d_localcount	= _localcount,
 	.d_flag		= D_OTHER
 };
 

Index: src/external/cddl/osnet/dev/sdt/sdt.c
diff -u src/external/cddl/osnet/dev/sdt/sdt.c:1.16.2.2 src/external/cddl/osnet/dev/sdt/sdt.c:1.16.2.3
--- src/external/cddl/osnet/dev/sdt/sdt.c:1.16.2.2	Sun Jul 17 05:18:11 2016
+++ src/external/cddl/osnet/dev/sdt/sdt.c	Mon Jul 18 03:50:58 2016
@@ -39,7 +39,7 @@
  * unloaded; in particular, probes may not span multiple kernel modules.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdt.c,v 1.16.2.2 2016/07/17 05:18:11 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdt.c,v 1.16.2.3 2016/07/18 03:50:58 pgoyette Exp $");
 
 #include 
 #include 
@@ -133,7 +133,7 @@ static const struct cdevsw sdt_cdevsw = 
 	.d_mmap		= nommap,
 	.d_kqfilter	= nokqfilter,
 	.d_discard	= nodiscard,
-	.d_localcount	= sdt_localcount,
+	.d_localcount	= _localcount,
 	.d_flag		= D_OTHER
 };
 #endif

Index: src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c
diff -u src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.32.2.2 src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.32.2.3
--- src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.32.2.2	Sun Jul 17 05:18:11 2016
+++ src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c	Mon Jul 18 03:50:58 2016
@@ -15353,7 +15353,7 @@ const struct cdevsw dtrace_cdevsw = {
 	.d_mmap		= nommap,
 	.d_kqfilter	= nokqfilter,
 	.d_discard	= nodiscard,
-	.d_localcount	= dtrace_localcount,
+	.d_localcount	= _localcount,
 	.d_flag		= D_OTHER | D_MPSAFE
 };
 

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.10 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.10.2.1
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c:1.10	Fri Apr 10 20:55:38 2015
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c	Mon Jul 18 03:50:58 2016
@@ -66,6 +66,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "zfs_namecheck.h"
 #include "zfs_prop.h"
@@ -4562,6 +4563,10 @@ nb_zfsdev_ioctl(dev_t dev, u_long cmd, v
 	);
 }
 
+#ifdef _MODULE
+struct localcount zfs_b_localcount, zfs_c_localcount;
+#endif
+
 const struct bdevsw zfs_bdevsw = {
 	.d_open = nb_zvol_bopen,
 	.d_close = nb_zvol_bclose,
@@ -4569,6 +4574,9 @@ const struct bdevsw zfs_bdevsw = {
 	.d_ioctl = nb_zfsdev_ioctl,
 	.d_dump = nodump,
 	.d_psize = nosize,
+#ifdef _MODULE
+	.d_localcount = _b_localcount,
+#endif
 	.d_flag = D_DISK | D_MPSAFE
 };
 
@@ -4583,6 +4591,9 @@ const struct cdevsw zfs_cdevsw = {
 	.d_poll = nopoll,
 	.d_mmap = nommap,
 	.d_kqfilter = nokqfilter,
+#ifdef _MODULE
+	.d_localcount = _c_localcount,
+#endif
 	.d_flag = D_DISK | D_MPSAFE
 };
 



CVS commit: [pgoyette-localcount] src/sys

2016-07-17 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sun Jul 17 21:39:17 UTC 2016

Modified Files:
src/sys/kern [pgoyette-localcount]: init_main.c subr_devsw.c
src/sys/sys [pgoyette-localcount]: conf.h

Log Message:
Instead of initializing the 'pserialize_t psz' while holding a lock,
create a new devsw_detach_init() routine to hande this, and call it
after the pserialize system has been initialized.


To generate a diff of this commit:
cvs rdiff -u -r1.482 -r1.482.2.1 src/sys/kern/init_main.c
cvs rdiff -u -r1.34.2.5 -r1.34.2.6 src/sys/kern/subr_devsw.c
cvs rdiff -u -r1.146.2.1 -r1.146.2.2 src/sys/sys/conf.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/init_main.c
diff -u src/sys/kern/init_main.c:1.482 src/sys/kern/init_main.c:1.482.2.1
--- src/sys/kern/init_main.c:1.482	Thu Jul  7 06:55:43 2016
+++ src/sys/kern/init_main.c	Sun Jul 17 21:39:17 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: init_main.c,v 1.482 2016/07/07 06:55:43 msaitoh Exp $	*/
+/*	$NetBSD: init_main.c,v 1.482.2.1 2016/07/17 21:39:17 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.482 2016/07/07 06:55:43 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.482.2.1 2016/07/17 21:39:17 pgoyette Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -311,6 +311,9 @@ main(void)
 	/* Passive serialization. */
 	pserialize_init();
 
+	/* Init the detach capability in devsw */
+	devsw_detach_init();
+
 	/* Initialize the extent manager. */
 	extent_init();
 

Index: src/sys/kern/subr_devsw.c
diff -u src/sys/kern/subr_devsw.c:1.34.2.5 src/sys/kern/subr_devsw.c:1.34.2.6
--- src/sys/kern/subr_devsw.c:1.34.2.5	Sun Jul 17 12:09:21 2016
+++ src/sys/kern/subr_devsw.c	Sun Jul 17 21:39:17 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_devsw.c,v 1.34.2.5 2016/07/17 12:09:21 pgoyette Exp $	*/
+/*	$NetBSD: subr_devsw.c,v 1.34.2.6 2016/07/17 21:39:17 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.5 2016/07/17 12:09:21 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.6 2016/07/17 21:39:17 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dtrace.h"
@@ -127,6 +127,13 @@ devsw_init(void)
 	cv_init(_cv, "devsw");
 }
 
+void
+devsw_detach_init(void)
+{
+
+	device_psz = pserialize_create();
+}
+
 int
 devsw_attach(const char *devname,
 	 const struct bdevsw *bdev, devmajor_t *bmajor,
@@ -397,12 +404,7 @@ devsw_detach_locked(const struct bdevsw 
 	if (j < max_cdevsws )
 		cdevsw[j] = NULL;
 
-	/*
-	 * If we haven't already done so, create the serialization
-	 * stucture.  Then wait for all current readers to finish.
-	 */
-	if(__predict_false(device_psz == NULL))
-		device_psz = pserialize_create();
+	/* Wait for all current readers to finish with the devsw */
 	pserialize_perform(device_psz);
 
 	/*

Index: src/sys/sys/conf.h
diff -u src/sys/sys/conf.h:1.146.2.1 src/sys/sys/conf.h:1.146.2.2
--- src/sys/sys/conf.h:1.146.2.1	Sat Jul 16 07:54:13 2016
+++ src/sys/sys/conf.h	Sun Jul 17 21:39:17 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: conf.h,v 1.146.2.1 2016/07/16 07:54:13 pgoyette Exp $	*/
+/*	$NetBSD: conf.h,v 1.146.2.2 2016/07/17 21:39:17 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -270,6 +270,7 @@ struct devsw_conv {
 };
 
 void devsw_init(void);
+void devsw_detach_init(void);
 const char *devsw_blk2name(devmajor_t);
 const char *cdevsw_getname(devmajor_t);
 const char *bdevsw_getname(devmajor_t);