CVS commit: src/sys

2010-06-01 Thread Matt Fleming
Module Name:src
Committed By:   mjf
Date:   Tue Jun  1 22:13:30 UTC 2010

Modified Files:
src/sys/arch/amd64/conf: kern.ldscript kern.ldscript.2MB
kern.ldscript.Xen
src/sys/arch/i386/conf: kern.ldscript
src/sys/arch/sparc64/conf: kern.ldscript kern32.ldscript
src/sys/modules/xldscripts: kmodule
src/sys/net: if_gre.h
src/sys/sys: cdefs_elf.h

Log Message:
Add __cacheline_aligned and __read_mostly annotations.

These annotations help to mitigate false sharing on multiprocessor
systems.

Variables annotated with __cacheline_aligned are placed into the
.data.cacheline_aligned section in the kernel. Each item in this
section is aligned on a cachline boundary - this avoids false
sharing. Highly contended global locks are a good candidate for
__cacheline_aligned annotation.

Variables annotated with __read_mostly are packed together tightly
into a .data.read_mostly section in the kernel. The idea here is that
we can pack infrequently modified data items into a cacheline and
avoid having to purge the cache, which would happen if read mostly
data and write mostly data shared a cachline. Initialisation variables
are a prime candiate for __read_mostly annotations.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amd64/conf/kern.ldscript
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amd64/conf/kern.ldscript.2MB \
src/sys/arch/amd64/conf/kern.ldscript.Xen
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/conf/kern.ldscript
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc64/conf/kern.ldscript
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc64/conf/kern32.ldscript
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/xldscripts/kmodule
cvs rdiff -u -r1.39 -r1.40 src/sys/net/if_gre.h
cvs rdiff -u -r1.30 -r1.31 src/sys/sys/cdefs_elf.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/arch/amd64/conf/kern.ldscript
diff -u src/sys/arch/amd64/conf/kern.ldscript:1.4 src/sys/arch/amd64/conf/kern.ldscript:1.5
--- src/sys/arch/amd64/conf/kern.ldscript:1.4	Thu Oct 18 15:28:33 2007
+++ src/sys/arch/amd64/conf/kern.ldscript	Tue Jun  1 22:13:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern.ldscript,v 1.4 2007/10/18 15:28:33 yamt Exp $	*/
+/*	$NetBSD: kern.ldscript,v 1.5 2010/06/01 22:13:30 mjf Exp $	*/
 
 OUTPUT_FORMAT(elf64-x86-64, elf64-x86-64,
 	  elf64-x86-64)
@@ -32,8 +32,22 @@
AT (LOADADDR(.text) + (ADDR(.data) - ADDR(.text)))
{
  *(.data)
- *(.data.*)
}
+
+   . = ALIGN(64);	/* COHERENCY_UNIT */
+   .data.cacheline_aligned :
+   AT (LOADADDR(.text) + (ADDR(.data.cacheline_aligned) - ADDR(.text)))
+   {
+ *(.data.cacheline_aligned)
+   }
+   . = ALIGN(64);	/* COHERENCY_UNIT */
+   .data.read_mostly :
+   AT (LOADADDR(.text) + (ADDR(.data.read_mostly) - ADDR(.text)))
+   {
+ *(.data.read_mostly)
+   }
+   . = ALIGN(64);	/* COHERENCY_UNIT */
+
_edata = . ;
PROVIDE (edata = .) ;
__bss_start = . ;

Index: src/sys/arch/amd64/conf/kern.ldscript.2MB
diff -u src/sys/arch/amd64/conf/kern.ldscript.2MB:1.2 src/sys/arch/amd64/conf/kern.ldscript.2MB:1.3
--- src/sys/arch/amd64/conf/kern.ldscript.2MB:1.2	Thu Oct 18 15:28:33 2007
+++ src/sys/arch/amd64/conf/kern.ldscript.2MB	Tue Jun  1 22:13:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern.ldscript.2MB,v 1.2 2007/10/18 15:28:33 yamt Exp $	*/
+/*	$NetBSD: kern.ldscript.2MB,v 1.3 2010/06/01 22:13:30 mjf Exp $	*/
 
 OUTPUT_FORMAT(elf64-x86-64, elf64-x86-64,
 	  elf64-x86-64)
@@ -33,8 +33,20 @@
AT (LOADADDR(.text) + (ADDR(.data) - ADDR(.text)))
{
  *(.data)
- *(.data.*)
}
+   . = ALIGN(64);	/* COHERENCY_UNIT */
+   .data.cacheline_aligned :
+   AT (LOADADDR(.text) + (ADDR(.data.cacheline_aligned) - ADDR(.text)))
+   {
+ *(.data.cacheline_aligned)
+   }
+   . = ALIGN(64);	/* COHERENCY_UNIT */
+   .data.read_mostly :
+   AT (LOADADDR(.text) + (ADDR(.data.read_mostly) - ADDR(.text)))
+   {
+ *(.data.read_mostly)
+   }
+   . = ALIGN(64);	/* COHERENCY_UNIT */
_edata = . ;
PROVIDE (edata = .) ;
__bss_start = . ;
Index: src/sys/arch/amd64/conf/kern.ldscript.Xen
diff -u src/sys/arch/amd64/conf/kern.ldscript.Xen:1.2 src/sys/arch/amd64/conf/kern.ldscript.Xen:1.3
--- src/sys/arch/amd64/conf/kern.ldscript.Xen:1.2	Thu Nov 22 16:16:44 2007
+++ src/sys/arch/amd64/conf/kern.ldscript.Xen	Tue Jun  1 22:13:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern.ldscript.Xen,v 1.2 2007/11/22 16:16:44 bouyer Exp $	*/
+/*	$NetBSD: kern.ldscript.Xen,v 1.3 2010/06/01 22:13:30 mjf Exp $	*/
 
 OUTPUT_FORMAT(elf64-x86-64, elf64-x86-64,
 	  elf64-x86-64)
@@ -26,8 +26,20 @@
AT (LOADADDR(.text) + (ADDR(.data) - ADDR(.text)))
{
  *(.data)
- *(.data.*)
}
+   . = ALIGN(64);	/* COHERENCY_UNIT */
+   .data.cacheline_aligned :
+   AT (LOADADDR(.text) + (ADDR(.data.cacheline_aligned) - ADDR(.text)))
+   {
+ *(.data.cacheline_aligned)
+   }
+   . = ALIGN(64);	/* COHERENCY_UNIT */
+   

CVS commit: src/sys/arch/hp700/hp700

2009-05-17 Thread Matt Fleming
Module Name:src
Committed By:   mjf
Date:   Sun May 17 18:21:29 UTC 2009

Modified Files:
src/sys/arch/hp700/hp700: pim.h

Log Message:
u_intNN_t - uintNN_t


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/hp700/hp700/pim.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/arch/hp700/hp700/pim.h
diff -u src/sys/arch/hp700/hp700/pim.h:1.3 src/sys/arch/hp700/hp700/pim.h:1.4
--- src/sys/arch/hp700/hp700/pim.h:1.3	Sat May 16 16:06:06 2009
+++ src/sys/arch/hp700/hp700/pim.h	Sun May 17 18:21:29 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pim.h,v 1.3 2009/05/16 16:06:06 mjf Exp $	*/
+/*	$NetBSD: pim.h,v 1.4 2009/05/17 18:21:29 mjf Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -45,93 +45,93 @@
 struct hp700_pim_regs {
 
 	/* The general registers. */
-	u_int	pim_regs_r0;
-	u_int	pim_regs_r1;
-	u_int	pim_regs_r2;
-	u_int	pim_regs_r3;
-	u_int	pim_regs_r4;
-	u_int	pim_regs_r5;
-	u_int	pim_regs_r6;
-	u_int	pim_regs_r7;
-	u_int	pim_regs_r8;
-	u_int	pim_regs_r9;
-	u_int	pim_regs_r10;
-	u_int	pim_regs_r11;
-	u_int	pim_regs_r12;
-	u_int	pim_regs_r13;
-	u_int	pim_regs_r14;
-	u_int	pim_regs_r15;
-	u_int	pim_regs_r16;
-	u_int	pim_regs_r17;
-	u_int	pim_regs_r18;
-	u_int	pim_regs_r19;
-	u_int	pim_regs_r20;
-	u_int	pim_regs_r21;
-	u_int	pim_regs_r22;
-	u_int	pim_regs_r23;
-	u_int	pim_regs_r24;
-	u_int	pim_regs_r25;
-	u_int	pim_regs_r26;
-	u_int	pim_regs_r27;
-	u_int	pim_regs_r28;
-	u_int	pim_regs_r29;
-	u_int	pim_regs_r30;
-	u_int	pim_regs_r31;
+	uint32_t	pim_regs_r0;
+	uint32_t	pim_regs_r1;
+	uint32_t	pim_regs_r2;
+	uint32_t	pim_regs_r3;
+	uint32_t	pim_regs_r4;
+	uint32_t	pim_regs_r5;
+	uint32_t	pim_regs_r6;
+	uint32_t	pim_regs_r7;
+	uint32_t	pim_regs_r8;
+	uint32_t	pim_regs_r9;
+	uint32_t	pim_regs_r10;
+	uint32_t	pim_regs_r11;
+	uint32_t	pim_regs_r12;
+	uint32_t	pim_regs_r13;
+	uint32_t	pim_regs_r14;
+	uint32_t	pim_regs_r15;
+	uint32_t	pim_regs_r16;
+	uint32_t	pim_regs_r17;
+	uint32_t	pim_regs_r18;
+	uint32_t	pim_regs_r19;
+	uint32_t	pim_regs_r20;
+	uint32_t	pim_regs_r21;
+	uint32_t	pim_regs_r22;
+	uint32_t	pim_regs_r23;
+	uint32_t	pim_regs_r24;
+	uint32_t	pim_regs_r25;
+	uint32_t	pim_regs_r26;
+	uint32_t	pim_regs_r27;
+	uint32_t	pim_regs_r28;
+	uint32_t	pim_regs_r29;
+	uint32_t	pim_regs_r30;
+	uint32_t	pim_regs_r31;
 
 	/* The control registers. */
-	u_int	pim_regs_cr0;
-	u_int	pim_regs_cr1;
-	u_int	pim_regs_cr2;
-	u_int	pim_regs_cr3;
-	u_int	pim_regs_cr4;
-	u_int	pim_regs_cr5;
-	u_int	pim_regs_cr6;
-	u_int	pim_regs_cr7;
-	u_int	pim_regs_cr8;
-	u_int	pim_regs_cr9;
-	u_int	pim_regs_cr10;
-	u_int	pim_regs_cr11;
-	u_int	pim_regs_cr12;
-	u_int	pim_regs_cr13;
-	u_int	pim_regs_cr14;
-	u_int	pim_regs_cr15;
-	u_int	pim_regs_cr16;
-	u_int	pim_regs_cr17;
-	u_int	pim_regs_cr18;
-	u_int	pim_regs_cr19;
-	u_int	pim_regs_cr20;
-	u_int	pim_regs_cr21;
-	u_int	pim_regs_cr22;
-	u_int	pim_regs_cr23;
-	u_int	pim_regs_cr24;
-	u_int	pim_regs_cr25;
-	u_int	pim_regs_cr26;
-	u_int	pim_regs_cr27;
-	u_int	pim_regs_cr28;
-	u_int	pim_regs_cr29;
-	u_int	pim_regs_cr30;
-	u_int	pim_regs_cr31;
+	uint32_t	pim_regs_cr0;
+	uint32_t	pim_regs_cr1;
+	uint32_t	pim_regs_cr2;
+	uint32_t	pim_regs_cr3;
+	uint32_t	pim_regs_cr4;
+	uint32_t	pim_regs_cr5;
+	uint32_t	pim_regs_cr6;
+	uint32_t	pim_regs_cr7;
+	uint32_t	pim_regs_cr8;
+	uint32_t	pim_regs_cr9;
+	uint32_t	pim_regs_cr10;
+	uint32_t	pim_regs_cr11;
+	uint32_t	pim_regs_cr12;
+	uint32_t	pim_regs_cr13;
+	uint32_t	pim_regs_cr14;
+	uint32_t	pim_regs_cr15;
+	uint32_t	pim_regs_cr16;
+	uint32_t	pim_regs_cr17;
+	uint32_t	pim_regs_cr18;
+	uint32_t	pim_regs_cr19;
+	uint32_t	pim_regs_cr20;
+	uint32_t	pim_regs_cr21;
+	uint32_t	pim_regs_cr22;
+	uint32_t	pim_regs_cr23;
+	uint32_t	pim_regs_cr24;
+	uint32_t	pim_regs_cr25;
+	uint32_t	pim_regs_cr26;
+	uint32_t	pim_regs_cr27;
+	uint32_t	pim_regs_cr28;
+	uint32_t	pim_regs_cr29;
+	uint32_t	pim_regs_cr30;
+	uint32_t	pim_regs_cr31;
 
 	/* The space registers. */
-	u_int	pim_regs_sr0;
-	u_int	pim_regs_sr1;
-	u_int	pim_regs_sr2;
-	u_int	pim_regs_sr3;
-	u_int	pim_regs_sr4;
-	u_int	pim_regs_sr5;
-	u_int	pim_regs_sr6;
-	u_int	pim_regs_sr7;
+	uint32_t	pim_regs_sr0;
+	uint32_t	pim_regs_sr1;
+	uint32_t	pim_regs_sr2;
+	uint32_t	pim_regs_sr3;
+	uint32_t	pim_regs_sr4;
+	uint32_t	pim_regs_sr5;
+	uint32_t	pim_regs_sr6;
+	uint32_t	pim_regs_sr7;
 
 	/* The back entries of the instruction address queues. */
-	u_int	pim_regs_iisq_tail;
-	u_int	pim_regs_iioq_tail;
+	uint32_t	pim_regs_iisq_tail;
+	uint32_t	pim_regs_iioq_tail;
 };
 
 /* The PIM data for HPMC and LPMC contains this check information. */
 struct hp700_pim_checks {
 
 	/* The Check Type. */
-	u_int	pim_check_type;
+	uint32_t	pim_check_type;
 #define	PIM_CHECK_CACHE		(1  31)
 #define	PIM_CHECK_TLB		(1  30)
 #define	PIM_CHECK_BUS		(1  29)
@@ -142,7 +142,7 @@
 	 * The CPU State.  In addition to the common PIM_CPU_
 	 * bits defined below, some fields are HPMC-specific.
 	 */
-	u_int	

CVS commit: src/sys/arch/hp700/hp700

2009-05-16 Thread Matt Fleming
Module Name:src
Committed By:   mjf
Date:   Sat May 16 16:06:06 UTC 2009

Modified Files:
src/sys/arch/hp700/hp700: machdep.c pim.h

Log Message:
Add PA-RISC 2.0 PIM support.

Fix the HPMC exception handler so that, if we're running on a PA-RISC
2.0 machine, we use the 64-bit PIM data structures.

There was also a bug in the HPMC exception handler that stopped output
being written to the console after we'd taken the exception. We need
to make a PDC_IO pdc call to reset I/O.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/hp700/hp700/machdep.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/hp700/hp700/pim.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/arch/hp700/hp700/machdep.c
diff -u src/sys/arch/hp700/hp700/machdep.c:1.63 src/sys/arch/hp700/hp700/machdep.c:1.64
--- src/sys/arch/hp700/hp700/machdep.c:1.63	Wed May 13 14:33:42 2009
+++ src/sys/arch/hp700/hp700/machdep.c	Sat May 16 16:06:06 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.63 2009/05/13 14:33:42 skrll Exp $	*/
+/*	$NetBSD: machdep.c,v 1.64 2009/05/16 16:06:06 mjf Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.63 2009/05/13 14:33:42 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.64 2009/05/16 16:06:06 mjf Exp $);
 
 #include opt_cputype.h
 #include opt_ddb.h
@@ -1455,12 +1455,20 @@
  * an LPMC, or a TOC.  The check type is passed in as a trap
  * type, one of T_HPMC, T_LPMC, or T_INTERRUPT (for TOC).
  */
-static char pim_data_buffer[4096];	/* XXX assumed to be big enough */
+static char pim_data_buffer[896] __attribute__((__aligned__(8)));
 static char in_check = 0;
-void
-hppa_machine_check(int check_type)
+
+#define	PIM_WORD(name, word, bits)			\
+do {			\
+	snprintb(bitmask_buffer, sizeof(bitmask_buffer),\
+	bits, word);\
+	printf(%s %s, name, bitmask_buffer);		\
+} while (/* CONSTCOND */ 0)
+
+
+static inline void
+hppa_pim_dump(int check_type)
 {
-	int pdc_pim_type;
 	struct hp700_pim_hpmc *hpmc;
 	struct hp700_pim_lpmc *lpmc;
 	struct hp700_pim_toc *toc;
@@ -1470,37 +1478,20 @@
 	int reg_i, reg_j, reg_k;
 	char bitmask_buffer[64];
 	const char *name;
-	int error;
-#define	PIM_WORD(name, word, bits)			\
-do {			\
-	snprintb(bitmask_buffer, sizeof(bitmask_buffer),\
-	bits, word);\
-	printf(%s %s, name, bitmask_buffer);		\
-} while (/* CONSTCOND */ 0)
 
-	/* Do an fcacheall(). */
-	fcacheall();
-
-	/* Dispatch on the check type. */
 	regs = NULL;
 	checks = NULL;
 	switch (check_type) {
 	case T_HPMC:
-		name = HPMC;
-		pdc_pim_type = PDC_PIM_HPMC;
 		hpmc = (struct hp700_pim_hpmc *) pim_data_buffer;
 		regs = hpmc-pim_hpmc_regs;
 		checks = hpmc-pim_hpmc_checks;
 		break;
 	case T_LPMC:
-		name = LPMC;
-		pdc_pim_type = PDC_PIM_LPMC;
 		lpmc = (struct hp700_pim_lpmc *) pim_data_buffer;
 		checks = lpmc-pim_lpmc_checks;
 		break;
 	case T_INTERRUPT:
-		name = TOC;
-		pdc_pim_type = PDC_PIM_TOC;
 		toc = (struct hp700_pim_toc *) pim_data_buffer;
 		regs = toc-pim_toc_regs;
 		break;
@@ -1508,11 +1499,6 @@
 		panic(unknown machine check type);
 		/* NOTREACHED */
 	}
-	printf(\nmachine check: %s, name);
-	error = pdc_call((iodcio_t)pdc, 0, PDC_PIM, pdc_pim_type,
-		pdc_pim, pim_data_buffer, sizeof(pim_data_buffer));
-	if (error  0)
-		printf( - WARNING: could not transfer PIM info (%d), error);
 
 	/* If we have register arrays, display them. */
 	if (regs != NULL) {
@@ -1538,7 +1524,8 @@
 		}
 
 		/* Print out some interesting registers. */
-		printf(\n\n\tIIA 0x%x:0x%08x 0x%x:0x%08x,
+		printf(\n\n\tIIA head 0x%x:0x%08x\n
+			\tIIA tail 0x%x:0x%08x,
 			regs-pim_regs_cr17, regs-pim_regs_cr18,
 			regs-pim_regs_iisq_tail, regs-pim_regs_iioq_tail);
 		PIM_WORD(\n\tIPSW, regs-pim_regs_cr22, PSW_BITS);
@@ -1569,6 +1556,164 @@
 		printf(\n\tPath Info 0x%08x,
 			checks-pim_check_path_info);
 	}
+}
+
+static inline void
+hppa_pim64_dump(int check_type)
+{
+	struct hp700_pim64_hpmc *hpmc;
+	struct hp700_pim64_lpmc *lpmc;
+	struct hp700_pim64_toc *toc;
+	struct hp700_pim64_regs *regs;
+	struct hp700_pim64_checks *checks;
+	int reg_i, reg_j, reg_k;
+	uint64_t *regarray;
+	char bitmask_buffer[64];
+	const char *name;
+
+	regs = NULL;
+	checks = NULL;
+	switch (check_type) {
+	case T_HPMC:
+		hpmc = (struct hp700_pim64_hpmc *) pim_data_buffer;
+		regs = hpmc-pim_hpmc_regs;
+		checks = hpmc-pim_hpmc_checks;
+		break;
+	case T_LPMC:
+		lpmc = (struct hp700_pim64_lpmc *) pim_data_buffer;
+		checks = lpmc-pim_lpmc_checks;
+		break;
+	case T_INTERRUPT:
+		toc = (struct hp700_pim64_toc *) pim_data_buffer;
+		regs = toc-pim_toc_regs;
+		break;
+	default:
+		panic(unknown machine check type);
+		/* NOTREACHED */
+	}
+
+	/* If we have register arrays, display them. */
+	if (regs != NULL) {
+		for (reg_i = 0; reg_i  3; reg_i++) {
+			if (reg_i == 0) {
+name = General;
+

CVS commit: src/sys/arch/hp700/gsc

2009-04-15 Thread Matt Fleming
Module Name:src
Committed By:   mjf
Date:   Wed Apr 15 20:07:58 UTC 2009

Modified Files:
src/sys/arch/hp700/gsc: harmony.c

Log Message:
Get audio capture fully working with harmony(4) and fix PR/35239.

skrll@ reports that with this patch he can record and playback audio.
Suprisingly the bug was actually with playback and not with capture.
When not capturing or playing audio we write to or read from empty
buffers, the problem was that playback and capture were using the same
buffer and the playback code managed to pick up a bit of data that was
written from the capture code.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/hp700/gsc/harmony.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/hp700/gsc/harmony.c
diff -u src/sys/arch/hp700/gsc/harmony.c:1.13 src/sys/arch/hp700/gsc/harmony.c:1.14
--- src/sys/arch/hp700/gsc/harmony.c:1.13	Tue Sep 23 14:07:11 2008
+++ src/sys/arch/hp700/gsc/harmony.c	Wed Apr 15 20:07:58 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: harmony.c,v 1.13 2008/09/23 14:07:11 mjf Exp $	*/
+/*	$NetBSD: harmony.c,v 1.14 2009/04/15 20:07:58 mjf Exp $	*/
 
 /*	$OpenBSD: harmony.c,v 1.23 2004/02/13 21:28:19 mickey Exp $	*/
 
@@ -133,6 +133,8 @@
 void harmony_tick_cp(void *);
 void harmony_try_more(struct harmony_softc *, int, int,
 	struct harmony_channel *);
+static void harmony_empty_input(struct harmony_softc *);
+static void harmony_empty_output(struct harmony_softc *);
 
 #if NRND  0
 void harmony_acc_tmo(void *);
@@ -243,7 +245,7 @@
 	for (i = 0; i  CAPTURE_EMPTYS; i++)
 		sc-sc_capture_paddrs[i] =
 		sc-sc_empty_map-dm_segs[0].ds_addr +
-		offsetof(struct harmony_empty, playback[i][0]);
+		offsetof(struct harmony_empty, capture[i][0]);
 
 	bus_dmamap_sync(sc-sc_dmat, sc-sc_empty_map,
 	offsetof(struct harmony_empty, playback[0][0]),
@@ -663,6 +665,18 @@
 	return 0;
 }
 
+static void
+harmony_empty_output(struct harmony_softc *sc)
+{
+
+	WRITE_REG(sc, HARMONY_PNXTADD,
+	sc-sc_playback_paddrs[sc-sc_playback_empty]);
+	SYNC_REG(sc, HARMONY_PNXTADD, BUS_SPACE_BARRIER_WRITE);
+
+	if (++sc-sc_playback_empty == PLAYBACK_EMPTYS)
+		sc-sc_playback_empty = 0;
+}
+
 int
 harmony_halt_output(void *vsc)
 {
@@ -670,9 +684,23 @@
 
 	sc = vsc;
 	sc-sc_playing = 0;
+
+	harmony_empty_output(sc);
 	return 0;
 }
 
+static void
+harmony_empty_input(struct harmony_softc *sc)
+{
+
+	WRITE_REG(sc, HARMONY_RNXTADD,
+	sc-sc_capture_paddrs[sc-sc_capture_empty]);
+	SYNC_REG(sc, HARMONY_RNXTADD, BUS_SPACE_BARRIER_WRITE);
+
+	if (++sc-sc_capture_empty == CAPTURE_EMPTYS)
+		sc-sc_capture_empty = 0;
+}
+
 int
 harmony_halt_input(void *vsc)
 {
@@ -680,6 +708,8 @@
 
 	sc = vsc;
 	sc-sc_capturing = 0;
+
+	harmony_empty_input(sc);
 	return 0;
 }
 
@@ -1097,12 +1127,9 @@
 	bus_size_t togo;
 
 	c = sc-sc_capture;
-	if (sc-sc_capturing == 0) {
-		WRITE_REG(sc, HARMONY_RNXTADD,
-		sc-sc_capture_paddrs[sc-sc_capture_empty]);
-		if (++sc-sc_capture_empty == CAPTURE_EMPTYS)
-			sc-sc_capture_empty = 0;
-	} else {
+	if (sc-sc_capturing == 0)
+		harmony_empty_input(sc);
+	else {
 		d = c-c_current;
 		togo = c-c_segsz - c-c_cnt;
 		if (togo == 0) {
@@ -1143,12 +1170,9 @@
 	bus_size_t togo;
 
 	c = sc-sc_playback;
-	if (sc-sc_playing == 0) {
-		WRITE_REG(sc, HARMONY_PNXTADD,
-		sc-sc_playback_paddrs[sc-sc_playback_empty]);
-		if (++sc-sc_playback_empty == PLAYBACK_EMPTYS)
-			sc-sc_playback_empty = 0;
-	} else {
+	if (sc-sc_playing == 0)
+		harmony_empty_output(sc);
+	else {
 		d = c-c_current;
 		togo = c-c_segsz - c-c_cnt;
 		if (togo == 0) {



CVS commit: src/share/man/man9

2009-04-02 Thread Matt Fleming
Module Name:src
Committed By:   mjf
Date:   Thu Apr  2 19:02:43 UTC 2009

Modified Files:
src/share/man/man9: scsipi.9

Log Message:
Continue my crusade - queueing - queuing


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/share/man/man9/scsipi.9

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/scsipi.9
diff -u src/share/man/man9/scsipi.9:1.21 src/share/man/man9/scsipi.9:1.22
--- src/share/man/man9/scsipi.9:1.21	Thu Mar 12 12:41:01 2009
+++ src/share/man/man9/scsipi.9	Thu Apr  2 19:02:42 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: scsipi.9,v 1.21 2009/03/12 12:41:01 joerg Exp $
+.\	$NetBSD: scsipi.9,v 1.22 2009/04/02 19:02:42 mjf Exp $
 .\
 .\
 .\ Copyright (c) 2001 Manuel Bouyer.
@@ -378,7 +378,7 @@
 .It Dv PERIPH_CAP_DT
 DT transfers
 .It Dv PERIPH_CAP_TQING
-tagged queueing
+tagged queuing
 .El
 Whenever the xfer mode changes, the driver should call
 .Fn scsipi_async_event