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

2017-10-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Oct 19 06:29:16 UTC 2017

Modified Files:
src/sys/arch/x86/include: specialreg.h

Log Message:
 Add the following bits in AMD Fn800a %edx features (SVM features):
PFThreshold (PAUSE filter threshold)
AVIC (AMD virtual interrupt controller)
V_VMSAVE_VMLOAD (virtualized VMSAVE and VMLOAD)
vGIF (virtualized GIF)


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/arch/x86/include/specialreg.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/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.104 src/sys/arch/x86/include/specialreg.h:1.105
--- src/sys/arch/x86/include/specialreg.h:1.104	Wed Oct 18 03:38:32 2017
+++ src/sys/arch/x86/include/specialreg.h	Thu Oct 19 06:29:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.104 2017/10/18 03:38:32 msaitoh Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.105 2017/10/19 06:29:16 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -539,13 +539,18 @@
 #define CPUID_AMD_SVM_FlushByASID	0x0040
 #define CPUID_AMD_SVM_DecodeAssist	0x0080
 #define CPUID_AMD_SVM_PauseFilter	0x0400
+#define CPUID_AMD_SVM_PFThreshold	0x0x001000 /* PAUSE filter threshold */
+#define CPUID_AMD_SVM_AVIC		0x2000 /* AMD Virtual intr. ctrl */
+#define CPUID_AMD_SVM_V_VMSAVE_VMLOAD	0x8000 /* Virtual VM{SAVE/LOAD} */
+#define CPUID_AMD_SVM_vGIF		0x0001 /* Virtualized GIF */
 #define CPUID_AMD_SVM_FLAGS	 "\20" \
-	"\1" "NP"	"\2" "LbrVirt"	"\3" "SVML"	"\4" "NRIPS" \
-	"\5" "TSCRate"	"\6" "VMCBCleanBits" \
-		"\7" "FlushByASID"	"\10" "DecodeAssist" \
+	"\1" "NP"	"\2" "LbrVirt"	"\3" "SVML"	"\4" "NRIPS"	\
+	"\5" "TSCRate"	"\6" "VMCBCleanBits" \
+			"\7" "FlushByASID" "\10" "DecodeAssist"	\
 	"\11" "B08"	"\12" "B09"	"\13" "PauseFilter" "\14" "B11" \
-	"\15" "B12"	"\16" "B13"	"\17" "B17"	"\20" "B18" \
-	"\21" "B19"
+	"\15" "PFThreshold" "\16" "AVIC" "\17" "B14"			\
+		"\20" "V_VMSAVE_VMLOAD"	\
+	"\21" "VGIF"
 
 /*
  * Centaur Extended Feature flags



CVS commit: src/sys/dev/pci

2017-10-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Oct 19 05:52:57 UTC 2017

Modified Files:
src/sys/dev/pci: pci_subr.c pcireg.h

Log Message:
 Fix a bug that the TPH ST table is decoded even if it's not in the TPH
Requester extended capability structure.


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.134 -r1.135 src/sys/dev/pci/pcireg.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/dev/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.193 src/sys/dev/pci/pci_subr.c:1.194
--- src/sys/dev/pci/pci_subr.c:1.193	Thu Oct 12 02:40:34 2017
+++ src/sys/dev/pci/pci_subr.c	Thu Oct 19 05:52:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.193 2017/10/12 02:40:34 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.194 2017/10/19 05:52:57 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.193 2017/10/12 02:40:34 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.194 2017/10/19 05:52:57 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -3499,15 +3499,15 @@ pci_conf_print_dpa_cap(const pcireg_t *r
 }
 
 static const char *
-pci_conf_print_tph_req_cap_sttabloc(unsigned char val)
+pci_conf_print_tph_req_cap_sttabloc(uint8_t val)
 {
 
 	switch (val) {
-	case 0x0:
+	case PCI_TPH_REQ_STTBLLOC_NONE:
 		return "Not Present";
-	case 0x1:
+	case PCI_TPH_REQ_STTBLLOC_TPHREQ:
 		return "in the TPH Requester Capability Structure";
-	case 0x2:
+	case PCI_TPH_REQ_STTBLLOC_MSIX:
 		return "in the MSI-X Table";
 	default:
 		return "Unknown";
@@ -3519,6 +3519,7 @@ pci_conf_print_tph_req_cap(const pcireg_
 {
 	pcireg_t reg;
 	int size, i, j;
+	uint8_t sttbloc;
 
 	printf("\n  TPH Requester Extended Capability\n");
 
@@ -3528,9 +3529,9 @@ pci_conf_print_tph_req_cap(const pcireg_
 	onoff("Interrupt Vector Mode Supported", reg, PCI_TPH_REQ_CAP_INTVEC);
 	onoff("Device Specific Mode Supported", reg, PCI_TPH_REQ_CAP_DEVSPEC);
 	onoff("Extend TPH Reqester Supported", reg, PCI_TPH_REQ_CAP_XTPHREQ);
+	sttbloc = __SHIFTOUT(reg, PCI_TPH_REQ_CAP_STTBLLOC);
 	printf("  ST Table Location: %s\n",
-	pci_conf_print_tph_req_cap_sttabloc(
-		(unsigned char)__SHIFTOUT(reg, PCI_TPH_REQ_CAP_STTBLLOC)));
+	pci_conf_print_tph_req_cap_sttabloc(sttbloc));
 	size = __SHIFTOUT(reg, PCI_TPH_REQ_CAP_STTBLSIZ) + 1;
 	printf("  ST Table Size: %d\n", size);
 
@@ -3566,7 +3567,10 @@ pci_conf_print_tph_req_cap(const pcireg_
 		printf("(reserved vaule)\n");
 		break;
 	}
-	
+
+	if (sttbloc != PCI_TPH_REQ_STTBLLOC_TPHREQ)
+		return;
+
 	for (i = 0; i < size ; i += 2) {
 		reg = regs[o2i(extcapoff + PCI_TPH_REQ_STTBL + i / 2)];
 		for (j = 0; j < 2 ; j++) {

Index: src/sys/dev/pci/pcireg.h
diff -u src/sys/dev/pci/pcireg.h:1.134 src/sys/dev/pci/pcireg.h:1.135
--- src/sys/dev/pci/pcireg.h:1.134	Tue Oct 10 03:11:01 2017
+++ src/sys/dev/pci/pcireg.h	Thu Oct 19 05:52:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcireg.h,v 1.134 2017/10/10 03:11:01 msaitoh Exp $	*/
+/*	$NetBSD: pcireg.h,v 1.135 2017/10/19 05:52:57 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -1904,6 +1904,9 @@ struct pci_rom {
 #define	PCI_TPH_REQ_CAP_DEVSPEC	__BIT(2)   /* Device Specific Mode Supported */
 #define	PCI_TPH_REQ_CAP_XTPHREQ	__BIT(8)/* Extend TPH Reqester Supported */
 #define	PCI_TPH_REQ_CAP_STTBLLOC __BITS(10, 9)	/* ST Table Location */
+#define	PCI_TPH_REQ_STTBLLOC_NONE 	0	/* not present */
+#define	PCI_TPH_REQ_STTBLLOC_TPHREQ 	1	/* in the TPHREQ cap */
+#define	PCI_TPH_REQ_STTBLLOC_MSIX 	2	/* in the MSI-X table */
 #define	PCI_TPH_REQ_CAP_STTBLSIZ __BITS(26, 16)	/* ST Table Size */
 #define	PCI_TPH_REQ_CTL	0x08	/* TPH Requester Control */
 #define	PCI_TPH_REQ_CTL_STSEL	__BITS(2, 0)	/* ST Mode Select */



CVS commit: src/sys/arch/arm/broadcom

2017-10-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 19 05:45:37 UTC 2017

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_cm.h bcm2835_pwm.h

Log Message:
Fix RCSIds


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/broadcom/bcm2835_cm.h \
src/sys/arch/arm/broadcom/bcm2835_pwm.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/arm/broadcom/bcm2835_cm.h
diff -u src/sys/arch/arm/broadcom/bcm2835_cm.h:1.1 src/sys/arch/arm/broadcom/bcm2835_cm.h:1.2
--- src/sys/arch/arm/broadcom/bcm2835_cm.h:1.1	Sat Nov 21 07:41:29 2015
+++ src/sys/arch/arm/broadcom/bcm2835_cm.h	Thu Oct 19 05:45:37 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: */
+/*	$NetBSD: bcm2835_cm.h,v 1.2 2017/10/19 05:45:37 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
Index: src/sys/arch/arm/broadcom/bcm2835_pwm.h
diff -u src/sys/arch/arm/broadcom/bcm2835_pwm.h:1.1 src/sys/arch/arm/broadcom/bcm2835_pwm.h:1.2
--- src/sys/arch/arm/broadcom/bcm2835_pwm.h:1.1	Sat Nov 21 07:41:29 2015
+++ src/sys/arch/arm/broadcom/bcm2835_pwm.h	Thu Oct 19 05:45:37 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: */
+/*	$NetBSD: bcm2835_pwm.h,v 1.2 2017/10/19 05:45:37 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.



CVS commit: src/sys/dev/usb

2017-10-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 19 05:39:22 UTC 2017

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

Log Message:
KASSERT -> KASSERTMSG and while I'm here update a comment


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/dev/usb/usbdi.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/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.173 src/sys/dev/usb/usbdi.c:1.174
--- src/sys/dev/usb/usbdi.c:1.173	Thu Jun  1 02:45:12 2017
+++ src/sys/dev/usb/usbdi.c	Thu Oct 19 05:39:22 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.173 2017/06/01 02:45:12 chs Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.174 2017/10/19 05:39:22 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.173 2017/06/01 02:45:12 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.174 2017/10/19 05:39:22 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -856,7 +856,7 @@ usbd_get_interface(struct usbd_interface
 
 /*** Internal routines ***/
 
-/* Dequeue all pipe operations, called at splusb(). */
+/* Dequeue all pipe operations, called with bus lock held. */
 Static usbd_status
 usbd_ar_pipe(struct usbd_pipe *pipe)
 {
@@ -999,7 +999,8 @@ usb_insert_transfer(struct usbd_xfer *xf
 	xfer, pipe, pipe->up_running, xfer->ux_timeout);
 
 	KASSERT(mutex_owned(pipe->up_dev->ud_bus->ub_lock));
-	KASSERT(xfer->ux_state == XFER_BUSY);
+	KASSERTMSG(xfer->ux_state == XFER_BUSY, "xfer %p state is %x", xfer,
+	xfer->ux_state);
 
 #ifdef DIAGNOSTIC
 	xfer->ux_state = XFER_ONQU;



CVS commit: src/external/lgpl3/gmp/dist

2017-10-18 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Oct 19 03:26:29 UTC 2017

Modified Files:
src/external/lgpl3/gmp/dist: acinclude.m4 configure

Log Message:
external/lgpl3/gmp build fail in configure phase with "ln -s J 
/etc/malloc.conf".

patch from pkgsrc/devel/gmp
  http://mail-index.netbsd.org/pkgsrc-changes/2017/06/15/msg158404.html


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/lgpl3/gmp/dist/acinclude.m4
cvs rdiff -u -r1.6 -r1.7 src/external/lgpl3/gmp/dist/configure

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

Modified files:

Index: src/external/lgpl3/gmp/dist/acinclude.m4
diff -u src/external/lgpl3/gmp/dist/acinclude.m4:1.4 src/external/lgpl3/gmp/dist/acinclude.m4:1.5
--- src/external/lgpl3/gmp/dist/acinclude.m4:1.4	Tue Aug 22 09:55:44 2017
+++ src/external/lgpl3/gmp/dist/acinclude.m4	Thu Oct 19 03:26:28 2017
@@ -744,7 +744,7 @@ main ()
   long i;
   for (i = 0; i < 88 + 1; i++)
 a[i] = ~0L;
-  r = malloc (1 * sizeof (unsigned long));
+  r = calloc (1, sizeof (unsigned long));
   r2 = r;
   for (i = 0; i < 528; i += 23)
 {

Index: src/external/lgpl3/gmp/dist/configure
diff -u src/external/lgpl3/gmp/dist/configure:1.6 src/external/lgpl3/gmp/dist/configure:1.7
--- src/external/lgpl3/gmp/dist/configure:1.6	Tue Aug 22 09:55:44 2017
+++ src/external/lgpl3/gmp/dist/configure	Thu Oct 19 03:26:28 2017
@@ -6786,7 +6786,7 @@ main ()
   long i;
   for (i = 0; i < 88 + 1; i++)
 a[i] = ~0L;
-  r = malloc (1 * sizeof (unsigned long));
+  r = calloc (1, sizeof (unsigned long));
   r2 = r;
   for (i = 0; i < 528; i += 23)
 {
@@ -8404,7 +8404,7 @@ main ()
   long i;
   for (i = 0; i < 88 + 1; i++)
 a[i] = ~0L;
-  r = malloc (1 * sizeof (unsigned long));
+  r = calloc (1, sizeof (unsigned long));
   r2 = r;
   for (i = 0; i < 528; i += 23)
 {



CVS commit: src/usr.sbin/cpuctl/arch

2017-10-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Oct 19 03:09:55 UTC 2017

Modified Files:
src/usr.sbin/cpuctl/arch: i386.c

Log Message:
Update from Intel SDM:
 0x55: Xeon Scalable (Skylake)
 0x57: Xeon Phi [357]200 (Knights Landing)
 0x66: Future Core (Cannon Lake)
 0x85: Future Xeon Phi (Knights Mill)


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/usr.sbin/cpuctl/arch/i386.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/cpuctl/arch/i386.c
diff -u src/usr.sbin/cpuctl/arch/i386.c:1.77 src/usr.sbin/cpuctl/arch/i386.c:1.78
--- src/usr.sbin/cpuctl/arch/i386.c:1.77	Tue Oct 17 14:48:42 2017
+++ src/usr.sbin/cpuctl/arch/i386.c	Thu Oct 19 03:09:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: i386.c,v 1.77 2017/10/17 14:48:42 msaitoh Exp $	*/
+/*	$NetBSD: i386.c,v 1.78 2017/10/19 03:09:55 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: i386.c,v 1.77 2017/10/17 14:48:42 msaitoh Exp $");
+__RCSID("$NetBSD: i386.c,v 1.78 2017/10/19 03:09:55 msaitoh Exp $");
 #endif /* not lint */
 
 #include 
@@ -371,16 +371,17 @@ const struct cpu_cpuid_nameclass i386_cp
 [0x4d] = "Atom C2000",
 [0x4e] = "6th gen Core, Xeon E3-1[25]00 v5 (Skylake)",
 [0x4f] = "Xeon E[57] v4 (Broadwell), Core i7-69xx Extreme",
-[0x55] = "Future Xeon",
+[0x55] = "Xeon Scalable (Skylake)",
 [0x56] = "Xeon D-1500 (Broadwell)",
-[0x57] = "Xeon Phi [357]200",
+[0x57] = "Xeon Phi [357]200 (Knights Landing)",
 [0x5a] = "Atom E3500",
 [0x5c] = "Atom (Goldmont)",
 [0x5d] = "Atom X3-C3000 (Silvermont)",
 [0x5e] = "6th gen Core, Xeon E3-1[25]00 v5 (Skylake)",
 [0x5f] = "Atom (Goldmont, Denverton)",
+[0x66] = "Future Core (Cannon Lake)",
 [0x7a] = "Atom (Goldmont Plus)",
-[0x85] = "Future Xeon Phi",
+[0x85] = "Future Xeon Phi (Knights Mill)",
 [0x8e] = "7th gen Core (Kaby Lake)",
 [0x9e] = "7th gen Core (Kaby Lake)",
 			},



CVS commit: src/bin/sh

2017-10-18 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Oct 19 01:57:18 UTC 2017

Modified Files:
src/bin/sh: jobs.c

Log Message:
Re-factor the code that extracts status from exited jobs, avoiding
code duplication, and reducing the size of /bin/sh by a trivial amount.

NFCI.

This is being done now as there are two other changes forthcoming, both
of which benefit - one would result in even more code duplication without
this, the other might need to alter how this is done, and doing it after this
means there's just one place to change (if required).


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/bin/sh/jobs.c

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

Modified files:

Index: src/bin/sh/jobs.c
diff -u src/bin/sh/jobs.c:1.89 src/bin/sh/jobs.c:1.90
--- src/bin/sh/jobs.c:1.89	Fri Sep 29 17:53:57 2017
+++ src/bin/sh/jobs.c	Thu Oct 19 01:57:18 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: jobs.c,v 1.89 2017/09/29 17:53:57 kre Exp $	*/
+/*	$NetBSD: jobs.c,v 1.90 2017/10/19 01:57:18 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)jobs.c	8.5 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: jobs.c,v 1.89 2017/09/29 17:53:57 kre Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.90 2017/10/19 01:57:18 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -98,6 +98,7 @@ STATIC struct job *getjob(const char *, 
 STATIC int dowait(int, struct job *);
 #define WBLOCK	1
 #define WNOFREE 2
+STATIC int jobstatus(const struct job *, int);
 STATIC int waitproc(int, struct job *, int *);
 STATIC void cmdtxt(union node *);
 STATIC void cmdlist(union node *, int);
@@ -606,13 +607,48 @@ freejob(struct job *jp)
 	INTON;
 }
 
+/*
+ * Extract the status of a completed job (for $?)
+ */
+STATIC int
+jobstatus(const struct job *jp, int raw)
+{
+	int status = 0;
+	int retval;
+
+	if (pipefail && jp->nprocs) {
+		int i;
+
+		for (i = 0; i < jp->nprocs; i++)
+			if (jp->ps[i].status != 0)
+status = jp->ps[i].status;
+	} else
+		status = jp->ps[jp->nprocs ? jp->nprocs - 1 : 0].status;
+
+	if (raw)
+		return status;
+
+	if (WIFEXITED(status))
+		retval = WEXITSTATUS(status);
+#if JOBS
+	else if (WIFSTOPPED(status))
+		retval = WSTOPSIG(status) + 128;
+#endif
+	else {
+		/* XXX: limits number of signals */
+		retval = WTERMSIG(status) + 128;
+	}
+
+	return retval;
+}
+
 
 
 int
 waitcmd(int argc, char **argv)
 {
 	struct job *job;
-	int status, retval;
+	int retval;
 	struct job *jp;
 
 	nextopt("");
@@ -649,27 +685,7 @@ waitcmd(int argc, char **argv)
 			if (dowait(WBLOCK|WNOFREE, job) == -1)
 			   return 128 + lastsig();
 		}
-		if (pipefail && job->nprocs) {
-			int i;
-
-			status = 0;
-			for (i = 0; i < job->nprocs; i++)
-if (job->ps[i].status != 0)
-	status = job->ps[i].status;
-		} else
-			status =
-			job->ps[job->nprocs ? job->nprocs - 1 : 0].status;
-
-		if (WIFEXITED(status))
-			retval = WEXITSTATUS(status);
-#if JOBS
-		else if (WIFSTOPPED(status))
-			retval = WSTOPSIG(status) + 128;
-#endif
-		else {
-			/* XXX: limits number of signals */
-			retval = WTERMSIG(status) + 128;
-		}
+		retval = jobstatus(job, 0);
 		if (!iflag)
 			freejob(job);
 	}
@@ -1023,13 +1039,8 @@ waitforjob(struct job *jp)
 	if (jp->state == JOBSTOPPED && curjob != jp - jobtab)
 		set_curjob(jp, 2);
 #endif
-	if (pipefail) {
-		status = 0;
-		for (st = 0; st < jp->nprocs; st++)
-			if (jp->ps[st].status != 0)
-status = jp->ps[st].status;
-	} else
-		status = jp->ps[jp->nprocs - 1].status;
+	status = jobstatus(jp, 1);
+
 	/* convert to 8 bits */
 	if (WIFEXITED(status))
 		st = WEXITSTATUS(status);



CVS commit: src/sys/net

2017-10-18 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Oct 19 01:57:15 UTC 2017

Modified Files:
src/sys/net: bpf.c

Log Message:
Turn on D_MPSAFE flag of bpf_cdevsw that is already MP-safe

Pointed out by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 src/sys/net/bpf.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/net/bpf.c
diff -u src/sys/net/bpf.c:1.216 src/sys/net/bpf.c:1.217
--- src/sys/net/bpf.c:1.216	Mon Feb 20 03:08:38 2017
+++ src/sys/net/bpf.c	Thu Oct 19 01:57:15 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.216 2017/02/20 03:08:38 ozaki-r Exp $	*/
+/*	$NetBSD: bpf.c,v 1.217 2017/10/19 01:57:15 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.216 2017/02/20 03:08:38 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.217 2017/10/19 01:57:15 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -296,7 +296,7 @@ const struct cdevsw bpf_cdevsw = {
 	.d_mmap = nommap,
 	.d_kqfilter = nokqfilter,
 	.d_discard = nodiscard,
-	.d_flag = D_OTHER
+	.d_flag = D_OTHER | D_MPSAFE
 };
 
 bpfjit_func_t



CVS commit: src/bin/test

2017-10-18 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Oct 18 18:11:54 UTC 2017

Modified Files:
src/bin/test: test.1

Log Message:
Remove unnecessary Tn.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/bin/test/test.1

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

Modified files:

Index: src/bin/test/test.1
diff -u src/bin/test/test.1:1.32 src/bin/test/test.1:1.33
--- src/bin/test/test.1:1.32	Wed Oct 18 08:54:59 2017
+++ src/bin/test/test.1	Wed Oct 18 18:11:54 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: test.1,v 1.32 2017/10/18 08:54:59 kre Exp $
+.\"	$NetBSD: test.1,v 1.33 2017/10/18 18:11:54 wiz Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -108,8 +108,7 @@ is nonzero.
 .It Fl p Ar file
 True if
 .Ar file
-exists and is a named pipe
-.Po Tn FIFO Pc .
+exists and is a named pipe (FIFO).
 .It Fl r Ar file
 True if
 .Ar file



CVS commit: src/sys/arch/amd64/stand/prekern

2017-10-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Oct 18 17:12:42 UTC 2017

Modified Files:
src/sys/arch/amd64/stand/prekern: mm.c

Log Message:
If a branch is already there, use it and don't create a new one. This way
we can call mm_map_tree twice with neighboring regions.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amd64/stand/prekern/mm.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/amd64/stand/prekern/mm.c
diff -u src/sys/arch/amd64/stand/prekern/mm.c:1.2 src/sys/arch/amd64/stand/prekern/mm.c:1.3
--- src/sys/arch/amd64/stand/prekern/mm.c:1.2	Sun Oct 15 06:37:32 2017
+++ src/sys/arch/amd64/stand/prekern/mm.c	Wed Oct 18 17:12:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mm.c,v 1.2 2017/10/15 06:37:32 maxv Exp $	*/
+/*	$NetBSD: mm.c,v 1.3 2017/10/18 17:12:42 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -82,6 +82,12 @@ mm_palloc(size_t npages)
 	return pa;
 }
 
+static bool
+mm_pte_is_valid(pt_entry_t pte)
+{
+	return ((pte & PG_V) != 0);
+}
+
 paddr_t
 mm_vatopa(vaddr_t va)
 {
@@ -111,39 +117,46 @@ mm_map_tree(vaddr_t startva, vaddr_t end
 {
 	size_t i, size, nL4e, nL3e, nL2e;
 	size_t L4e_idx, L3e_idx, L2e_idx;
-	paddr_t L3page_pa, L2page_pa, L1page_pa;
+	paddr_t pa;
+
+	size = endva - startva;
 
 	/*
-	 * Initialize constants.
+	 * Build L4.
 	 */
-	size = endva - startva;
-	nL4e = roundup(size, NBPD_L4) / NBPD_L4;
-	nL3e = roundup(size, NBPD_L3) / NBPD_L3;
-	nL2e = roundup(size, NBPD_L2) / NBPD_L2;
 	L4e_idx = pl4_i(startva);
-	L3e_idx = pl3_i(startva);
-	L2e_idx = pl2_i(startva);
-
-	ASSERT(nL4e == 1);
+	nL4e = roundup(size, NBPD_L4) / NBPD_L4;
 	ASSERT(L4e_idx == 511);
+	ASSERT(nL4e == 1);
+	if (!mm_pte_is_valid(L4_BASE[L4e_idx])) {
+		pa = mm_palloc(1);
+		L4_BASE[L4e_idx] = pa | PG_V | PG_RW;
+	}
 
 	/*
-	 * Allocate the physical pages.
+	 * Build L3.
 	 */
-	L3page_pa = mm_palloc(nL4e);
-	L2page_pa = mm_palloc(nL3e);
-	L1page_pa = mm_palloc(nL2e);
+	L3e_idx = pl3_i(startva);
+	nL3e = roundup(size, NBPD_L3) / NBPD_L3;
+	for (i = 0; i < nL3e; i++) {
+		if (mm_pte_is_valid(L3_BASE[L3e_idx+i])) {
+			continue;
+		}
+		pa = mm_palloc(1);
+		L3_BASE[L3e_idx+i] = pa | PG_V | PG_RW;
+	}
 
 	/*
-	 * Build the branch in the page tree. We link the levels together,
-	 * from L4 to L1.
+	 * Build L2.
 	 */
-	L4_BASE[L4e_idx] = L3page_pa | PG_V | PG_RW;
-	for (i = 0; i < nL3e; i++) {
-		L3_BASE[L3e_idx+i] = (L2page_pa + i * PAGE_SIZE) | PG_V | PG_RW;
-	}
+	L2e_idx = pl2_i(startva);
+	nL2e = roundup(size, NBPD_L2) / NBPD_L2;
 	for (i = 0; i < nL2e; i++) {
-		L2_BASE[L2e_idx+i] = (L1page_pa + i * PAGE_SIZE) | PG_V | PG_RW;
+		if (mm_pte_is_valid(L2_BASE[L2e_idx+i])) {
+			continue;
+		}
+		pa = mm_palloc(1);
+		L2_BASE[L2e_idx+i] = pa | PG_V | PG_RW;
 	}
 }
 



CVS commit: src/sys/lib/libsa

2017-10-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Oct 18 16:29:56 UTC 2017

Modified Files:
src/sys/lib/libsa: loadfile_elf32.c

Log Message:
Group the sections into segments, and align to KERNALIGN only between
segments. Prerequisite for other changes. Unfortunately the code is not
very compact, but whatever.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/lib/libsa/loadfile_elf32.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/lib/libsa/loadfile_elf32.c
diff -u src/sys/lib/libsa/loadfile_elf32.c:1.47 src/sys/lib/libsa/loadfile_elf32.c:1.48
--- src/sys/lib/libsa/loadfile_elf32.c:1.47	Fri Oct 13 10:39:26 2017
+++ src/sys/lib/libsa/loadfile_elf32.c	Wed Oct 18 16:29:56 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: loadfile_elf32.c,v 1.47 2017/10/13 10:39:26 maxv Exp $ */
+/* $NetBSD: loadfile_elf32.c,v 1.48 2017/10/18 16:29:56 maxv Exp $ */
 
 /*
  * Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc.
@@ -341,7 +341,7 @@ ELFNAMEEND(loadfile_dynamic)(int fd, Elf
 {
 	const u_long offset = 0;
 	Elf_Shdr *shdr;
-	Elf_Addr shpp, addr;
+	Elf_Addr shpp, addr, align;
 	int i, j, loaded;
 	size_t size, shdrsz;
 	Elf_Addr maxp, elfp = 0;
@@ -383,11 +383,22 @@ ELFNAMEEND(loadfile_dynamic)(int fd, Elf
 	maxp += roundup(shdrsz, ELFROUND);
 
 	/*
-	 * Load the KERNEL SECTIONS.
+	 * Load the KERNEL SECTIONS, and group them into segments. First text,
+	 * then rodata, then data. Between sections, we align to the requested
+	 * section alignment. Between segments, we align to KERNALIGN.
 	 */
+
+	/* text */
 	maxp = roundup(maxp, KERNALIGN);
 	for (i = 0; i < elf->e_shnum; i++) {
-		addr = maxp;
+		if (!(shdr[i].sh_flags & SHF_EXECINSTR)) {
+			continue;
+		}
+		align = shdr[i].sh_addralign;
+		if (align == 0) {
+			align = ELFROUND;
+		}
+		addr = roundup(maxp, align);
 		size = (size_t)shdr[i].sh_size;
 
 		loaded = 0;
@@ -411,15 +422,94 @@ ELFNAMEEND(loadfile_dynamic)(int fd, Elf
 		}
 
 		if (loaded) {
-			shdr[i].sh_offset = maxp - elfp;
-			maxp = roundup(maxp + size, KERNALIGN);
+			shdr[i].sh_offset = addr - elfp;
+			maxp = addr + size;
+		}
+	}
+
+	/* rodata */
+	maxp = roundup(maxp, KERNALIGN);
+	for (i = 0; i < elf->e_shnum; i++) {
+		if ((shdr[i].sh_flags & (SHF_EXECINSTR|SHF_WRITE))) {
+			continue;
+		}
+		align = shdr[i].sh_addralign;
+		if (align == 0) {
+			align = ELFROUND;
+		}
+		addr = roundup(maxp, align);
+		size = (size_t)shdr[i].sh_size;
+
+		loaded = 0;
+		switch (shdr[i].sh_type) {
+		case SHT_NOBITS:
+			/* Zero out bss. */
+			BZERO(addr, size);
+			loaded = 1;
+			break;
+		case SHT_PROGBITS:
+			ret = ELFNAMEEND(readfile_global)(fd, offset,
+			shdr[i].sh_offset, addr, size);
+			if (ret == -1) {
+goto out;
+			}
+			loaded = 1;
+			break;
+		default:
+			loaded = 0;
+			break;
+		}
+
+		if (loaded) {
+			shdr[i].sh_offset = addr - elfp;
+			maxp = addr + size;
+		}
+	}
+
+	/* data */
+	maxp = roundup(maxp, KERNALIGN);
+	for (i = 0; i < elf->e_shnum; i++) {
+		if (!(shdr[i].sh_flags & SHF_WRITE) ||
+		(shdr[i].sh_flags & SHF_EXECINSTR)) {
+			continue;
+		}
+		align = shdr[i].sh_addralign;
+		if (align == 0) {
+			align = ELFROUND;
+		}
+		addr = roundup(maxp, align);
+		size = (size_t)shdr[i].sh_size;
+
+		loaded = 0;
+		switch (shdr[i].sh_type) {
+		case SHT_NOBITS:
+			/* Zero out bss. */
+			BZERO(addr, size);
+			loaded = 1;
+			break;
+		case SHT_PROGBITS:
+			ret = ELFNAMEEND(readfile_global)(fd, offset,
+			shdr[i].sh_offset, addr, size);
+			if (ret == -1) {
+goto out;
+			}
+			loaded = 1;
+			break;
+		default:
+			loaded = 0;
+			break;
+		}
+
+		if (loaded) {
+			shdr[i].sh_offset = addr - elfp;
+			maxp = addr + size;
 		}
 	}
 
 	/*
 	 * Load the SYM+REL SECTIONS.
 	 */
-	maxp = roundup(maxp, ELFROUND);
+	maxp = roundup(maxp, KERNALIGN);
 	for (i = 0; i < elf->e_shnum; i++) {
 		addr = maxp;
 		size = (size_t)shdr[i].sh_size;



CVS commit: src/sys/dev/usb

2017-10-18 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct 18 16:01:58 UTC 2017

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

Log Message:
Match BUFFALO CEWL-1 (Sony UWA-BR100 WLAN)


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/usb/if_athn_usb.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/if_athn_usb.c
diff -u src/sys/dev/usb/if_athn_usb.c:1.23 src/sys/dev/usb/if_athn_usb.c:1.24
--- src/sys/dev/usb/if_athn_usb.c:1.23	Sat Sep 23 14:27:44 2017
+++ src/sys/dev/usb/if_athn_usb.c	Wed Oct 18 16:01:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_athn_usb.c,v 1.23 2017/09/23 14:27:44 skrll Exp $	*/
+/*	$NetBSD: if_athn_usb.c,v 1.24 2017/10/18 16:01:58 jmcneill Exp $	*/
 /*	$OpenBSD: if_athn_usb.c,v 1.12 2013/01/14 09:50:31 jsing Exp $	*/
 
 /*-
@@ -22,7 +22,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.23 2017/09/23 14:27:44 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.24 2017/10/18 16:01:58 jmcneill Exp $");
 
 #ifdef	_KERNEL_OPT
 #include "opt_inet.h"
@@ -223,7 +223,8 @@ athn_usb_lookup(int vendor, int product)
 		_D( LITEON,	LITEON_AR9271,	  	NONE ),
 		_D( NETGEAR,	NETGEAR_WNA1100,	NONE ),
 		_D( NETGEAR,	NETGEAR_WNDA3200,	AR7010 ),
-		_D( VIA,	VIA_AR9271,		NONE )
+		_D( VIA,	VIA_AR9271,		NONE ),
+		_D( MELCO,	MELCO_CEWL_1,		AR7010 ),
 #undef _D
 	};
 



CVS commit: src/sys/dev/usb

2017-10-18 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct 18 16:00:53 UTC 2017

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
Add Sony UWA-BR100 WLAN adapter


To generate a diff of this commit:
cvs rdiff -u -r1.740 -r1.741 src/sys/dev/usb/usbdevs

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/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.740 src/sys/dev/usb/usbdevs:1.741
--- src/sys/dev/usb/usbdevs:1.740	Fri Sep 29 22:05:54 2017
+++ src/sys/dev/usb/usbdevs	Wed Oct 18 16:00:53 2017
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.740 2017/09/29 22:05:54 scole Exp $
+$NetBSD: usbdevs,v 1.741 2017/10/18 16:00:53 jmcneill Exp $
 
 /*
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -2172,6 +2172,7 @@ product MELCO RT2870_2		0x0150	RT2870
 product MELCO WLIUCGNHP		0x0158	WLI-UC-GNHP
 product MELCO WLIUCGN		0x015d	WLI-UC-GN
 product MELCO WLIUCG301N	0x016f	WLI-UC-G301N
+product MELCO CEWL_1		0x017f	Sony UWA-BR100 WLAN
 product MELCO WLIUCGNM		0x01a2	WLI-UC-GNM
 product MELCO WLIUCGNM2T	0x01ee	WLI-UC-GNM2T
 product MELCO WIU2300D		0x0241	WI-U2-300D



CVS commit: src/sys/arch/macppc/macppc

2017-10-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Oct 18 12:55:14 UTC 2017

Modified Files:
src/sys/arch/macppc/macppc: pic_u3_ht.c

Log Message:
do what freebsd does:
- when disabling an interrupt, disable it on the HT PIC as well
- when establishing an interrupt, don't enable it right away
- program IRQs 0-3 as level, like freebsd does
Now svwsata is almost usable. We still get an interrupt storm but it doesn't
eat up all CPU cycles anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/macppc/macppc/pic_u3_ht.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/macppc/macppc/pic_u3_ht.c
diff -u src/sys/arch/macppc/macppc/pic_u3_ht.c:1.2 src/sys/arch/macppc/macppc/pic_u3_ht.c:1.3
--- src/sys/arch/macppc/macppc/pic_u3_ht.c:1.2	Thu Jun  1 02:45:06 2017
+++ src/sys/arch/macppc/macppc/pic_u3_ht.c	Wed Oct 18 12:55:14 2017
@@ -43,6 +43,12 @@
 #include 
 #include 
 
+#ifdef U3_HT_PIC_DEPUG
+#define DPRINTF aprint_error
+#else
+#define DPRINTF if (0) printf
+#endif
+
 struct u3_ht_irqmap {
 	int im_index;
 	int im_level;
@@ -78,6 +84,7 @@ static void u3_ht_finish_setup(struct pi
 static int u3_ht_is_ht_irq(struct u3_ht_ops *, int);
 static void u3_ht_establish_ht_irq(struct u3_ht_ops *, int, int);
 static void u3_ht_enable_ht_irq(struct u3_ht_ops *, int);
+static void u3_ht_disable_ht_irq(struct u3_ht_ops *, int);
 static void u3_ht_ack_ht_irq(struct u3_ht_ops *, int);
 
 static void u3_ht_set_priority(struct u3_ht_ops *, int, int);
@@ -206,7 +213,7 @@ setup_u3_ht(uint32_t addr, uint32_t len,
 
 	u3_ht_set_priority(u3_ht, 0, 15);
 
-	for (irq = 0; irq < pic->pic_numintrs; irq++) {
+	for (irq = 0; irq < 4; irq++) {
 		x = irq;
 		x |= OPENPIC_IMASK;
 		x |= OPENPIC_POLARITY_NEGATIVE;
@@ -215,6 +222,15 @@ setup_u3_ht(uint32_t addr, uint32_t len,
 		u3_ht_write(u3_ht, OPENPIC_SRC_VECTOR(irq), x);
 		u3_ht_write(u3_ht, OPENPIC_IDEST(irq), 1 << 0);
 	}
+	for (irq = 4; irq < pic->pic_numintrs; irq++) {
+		x = irq;
+		x |= OPENPIC_IMASK;
+		x |= OPENPIC_POLARITY_NEGATIVE;
+		x |= OPENPIC_SENSE_EDGE;
+		x |= 8 << OPENPIC_PRIORITY_SHIFT;
+		u3_ht_write(u3_ht, OPENPIC_SRC_VECTOR(irq), x);
+		u3_ht_write(u3_ht, OPENPIC_IDEST(irq), 1 << 0);
+	}
 
 	x = u3_ht_read(u3_ht, OPENPIC_CONFIG);
 	x |= OPENPIC_CONFIG_8259_PASSTHRU_DISABLE;
@@ -253,6 +269,8 @@ setup_u3_ht_workarounds(struct u3_ht_ops
 	ht_reg = mapiodev(reg[1], reg[2], false);
 	KASSERT(ht_reg != NULL);
 
+	memset(irqmap, 0, sizeof(u3_ht->ht_irqmap));
+
 	for (child = OF_child(parent); child != 0; child = OF_peer(child)) {
 		if (OF_getprop(child, "reg", reg, 4) != 4) 
 			continue;
@@ -284,6 +302,8 @@ setup_u3_ht_workarounds(struct u3_ht_ops
 		nirq = in32rb(base + 0x04);
 		nirq = (nirq >> 16) & 0xff;
 
+		DPRINTF("dev %08x nirq %d pos %08x\n", (uint32_t)base, nirq, (uint32_t)pos);
+		DPRINTF("devreg %08x\n", in32rb(dev_reg + PCI_ID_REG));
 		for (i = 0; i <= nirq; i++) {
 			out8rb(base + 0x02, 0x10 + (i << 1));
 			tmp = in32rb(base + 0x04);
@@ -333,6 +353,9 @@ u3_ht_disable_irq(struct pic_ops *pic, i
  	x = u3_ht_read(u3_ht, OPENPIC_SRC_VECTOR(irq));
  	x |= OPENPIC_IMASK;
  	u3_ht_write(u3_ht, OPENPIC_SRC_VECTOR(irq), x);
+
+	if (u3_ht_is_ht_irq(u3_ht, irq))
+		u3_ht_disable_ht_irq(u3_ht, irq);
 }
 
 static int
@@ -385,8 +408,8 @@ u3_ht_establish_irq(struct pic_ops *pic,
 	if (u3_ht_is_ht_irq(u3_ht, irq))
 		u3_ht_establish_ht_irq(u3_ht, irq, type);
 
-	aprint_debug("%s: setting IRQ %d to priority %d\n", __func__, irq,
-	realpri);
+	aprint_error("%s: setting IRQ %d %d to priority %d %x\n", __func__, irq,
+	type, realpri, x);
 }
 
 static void
@@ -422,10 +445,15 @@ u3_ht_establish_ht_irq(struct u3_ht_ops 
 	out8rb(irqmap->im_base + 0x02, 0x10 + (irqmap->im_index << 1));
 
 	x = in32rb(irqmap->im_base + 0x04);
-	x &= ~0x23;
+	/* mask interrupt */
+	out32rb(irqmap->im_base + 0x04, x | 1);
+
+	/* mask out EOI and LEVEL bits */
+	x &= ~0x22;
 
 	if (type == IST_LEVEL_HIGH || type == IST_LEVEL_LOW) {
 		irqmap->im_level = 1;
+		DPRINTF("level\n");
 		x |= 0x22;
 	} else {
 		irqmap->im_level = 0;
@@ -449,6 +477,18 @@ u3_ht_enable_ht_irq(struct u3_ht_ops *u3
 }
 
 static void
+u3_ht_disable_ht_irq(struct u3_ht_ops *u3_ht, int irq)
+{
+	struct u3_ht_irqmap *irqmap = &u3_ht->ht_irqmap[irq];
+	u_int x;
+
+	out8rb(irqmap->im_base + 0x02, 0x10 + (irqmap->im_index << 1));
+	x = in32rb(irqmap->im_base + 0x04);
+	x |= 0x01;
+	out32rb(irqmap->im_base + 0x04, x);
+}
+
+static void
 u3_ht_ack_ht_irq(struct u3_ht_ops *u3_ht, int irq)
 {
 	struct u3_ht_irqmap *irqmap = &u3_ht->ht_irqmap[irq];



CVS commit: src/sys/dev/pci/ixgbe

2017-10-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Oct 18 10:43:32 UTC 2017

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c ixv.c

Log Message:
 Protect ec_multi* with mutex like other MP safe Ethernet drivers.
See if_ether.h rev. 1.66 and related stuff:
http://mail-index.netbsd.org/source-changes/2016/12/28/msg080289.html


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.71 -r1.72 src/sys/dev/pci/ixgbe/ixv.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.104 src/sys/dev/pci/ixgbe/ixgbe.c:1.105
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.104	Fri Oct 13 04:52:40 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Oct 18 10:43:32 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.104 2017/10/13 04:52:40 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.105 2017/10/18 10:43:32 msaitoh Exp $ */
 
 /**
 
@@ -2726,11 +2726,13 @@ ixgbe_set_promisc(struct adapter *adapte
 	struct ether_multistep step;
 	struct ethercom *ec = &adapter->osdep.ec;
 
+	KASSERT(mutex_owned(&adapter->core_mtx));
 	rctl = IXGBE_READ_REG(&adapter->hw, IXGBE_FCTRL);
 	rctl &= (~IXGBE_FCTRL_UPE);
 	if (ifp->if_flags & IFF_ALLMULTI)
 		mcnt = MAX_NUM_MULTICAST_ADDRESSES;
 	else {
+		ETHER_LOCK(ec);
 		ETHER_FIRST_MULTI(step, ec, enm);
 		while (enm != NULL) {
 			if (mcnt == MAX_NUM_MULTICAST_ADDRESSES)
@@ -2738,6 +2740,7 @@ ixgbe_set_promisc(struct adapter *adapte
 			mcnt++;
 			ETHER_NEXT_MULTI(step, enm);
 		}
+		ETHER_UNLOCK(ec);
 	}
 	if (mcnt < MAX_NUM_MULTICAST_ADDRESSES)
 		rctl &= (~IXGBE_FCTRL_MPE);
@@ -3906,12 +3909,14 @@ ixgbe_set_multi(struct adapter *adapter)
 	struct ether_multi	*enm;
 	struct ether_multistep	step;
 
+	KASSERT(mutex_owned(&adapter->core_mtx));
 	IOCTL_DEBUGOUT("ixgbe_set_multi: begin");
 
 	mta = adapter->mta;
 	bzero(mta, sizeof(*mta) * MAX_NUM_MULTICAST_ADDRESSES);
 
 	ifp->if_flags &= ~IFF_ALLMULTI;
+	ETHER_LOCK(ec);
 	ETHER_FIRST_MULTI(step, ec, enm);
 	while (enm != NULL) {
 		if ((mcnt == MAX_NUM_MULTICAST_ADDRESSES) ||
@@ -3926,6 +3931,7 @@ ixgbe_set_multi(struct adapter *adapter)
 		mcnt++;
 		ETHER_NEXT_MULTI(step, enm);
 	}
+	ETHER_UNLOCK(ec);
 
 	fctrl = IXGBE_READ_REG(&adapter->hw, IXGBE_FCTRL);
 	fctrl &= ~(IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.71 src/sys/dev/pci/ixgbe/ixv.c:1.72
--- src/sys/dev/pci/ixgbe/ixv.c:1.71	Fri Oct 13 08:17:44 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Wed Oct 18 10:43:32 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.71 2017/10/13 08:17:44 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.72 2017/10/18 10:43:32 msaitoh Exp $*/
 
 /**
 
@@ -1048,8 +1048,10 @@ ixv_set_multi(struct adapter *adapter)
 	u8 *update_ptr;
 	intmcnt = 0;
 
+	KASSERT(mutex_owned(&adapter->core_mtx));
 	IOCTL_DEBUGOUT("ixv_set_multi: begin");
 
+	ETHER_LOCK(ec);
 	ETHER_FIRST_MULTI(step, ec, enm);
 	while (enm != NULL) {
 		bcopy(enm->enm_addrlo,
@@ -1061,6 +1063,7 @@ ixv_set_multi(struct adapter *adapter)
 			break;
 		ETHER_NEXT_MULTI(step, enm);
 	}
+	ETHER_UNLOCK(ec);
 
 	update_ptr = mta;
 



CVS commit: src/bin/test

2017-10-18 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Wed Oct 18 08:54:59 UTC 2017

Modified Files:
src/bin/test: test.1

Log Message:
I have seen (way too often) uses of test(1) that are not defined to
actually work (but just happen to, today, and in some cases, even
that trusts to some luck.)

It has been recently pointed out to me that the man page (ie: this
file) doesn't give any real guidance to what is really acceptable,
and what is not.

The CAVEATS section does note that the grammar is ambiguous, but then
just says that test(1) implements what POSIX requires, and refers
readers to the relevant section of the POSIX standard for more details.
That is probably asking too much of the average reader...

So, add some extra information in the CAVEATS with what is defined to work,
and what should be avoided.   Not all of the POSIX rules are here, but this
might hopefully help script authors avoid some of the pitfalls.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/bin/test/test.1

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

Modified files:

Index: src/bin/test/test.1
diff -u src/bin/test/test.1:1.31 src/bin/test/test.1:1.32
--- src/bin/test/test.1:1.31	Mon Jul  3 21:33:24 2017
+++ src/bin/test/test.1	Wed Oct 18 08:54:59 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: test.1,v 1.31 2017/07/03 21:33:24 wiz Exp $
+.\"	$NetBSD: test.1,v 1.32 2017/10/18 08:54:59 kre Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\" @(#)test.1	8.1 (Berkeley) 5/31/93
 .\"
-.Dd August 12, 2016
+.Dd October 17, 2017
 .Dt TEST 1
 .Os
 .Sh NAME
@@ -328,3 +328,57 @@ section 4.62.4,
 are evaluated consistently according to the rules specified in the
 standards document.
 All other cases are subject to the ambiguity in the command semantics.
+.Pp
+This means that
+.Nm
+should not be used with more than 4 operands
+(where the terminating
+.Cm \&]
+in the case of the
+.Nm \&[
+command does not count as an operand,)
+and that the obsolete
+.Fl a
+and
+.Fl o
+options should not be used.
+Instead invoke
+.Nm
+multiple times connected by the
+.Dq &&
+and
+.Dq ||
+operators from
+.Xr sh 1 .
+When those operators are not used, there is no need
+for the parentheses as grouping symbols, so those should also be
+avoided.
+Using
+.Xr sh 1 Ns 's
+.Cm \&!
+command instead of the equivalent operator from
+.Nm
+can also protect the script from future test enhancements.
+.Pp
+Most expressions with 3 or less operands will evaluate as expected,
+though be aware that with 3 operands,
+if the second is a known binary operator,
+that is always evaluated,
+regardless of what the other operands might suggest had been intended.
+If, and only if, the middle operand is not a defined binary operator
+is the first operand examined to see if it is
+.Cm \&!
+in which case the remaining operands are evaluated as a two operand test,
+and the result inverted.
+The only other defined three operand case is the meaningless
+degenerate case where parentheses (1st and 3rd operands)
+surround a one operand expression.
+.Pp
+With 4 operands there are just two defined cases, the first
+where the first operand is
+.Cm \&!
+in which case the result of the three operand test on the
+remaining operands is inverted,
+and the second is similar to the 3 operand case,
+the degenerate case of parentheses surrounding an (in this case)
+2 operand test expression.



CVS commit: src/sys/dev/ata

2017-10-18 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Oct 18 08:38:35 UTC 2017

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
add newlines to the debug messages


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/sys/dev/ata/ata.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/ata/ata.c
diff -u src/sys/dev/ata/ata.c:1.137 src/sys/dev/ata/ata.c:1.138
--- src/sys/dev/ata/ata.c:1.137	Sun Oct 15 14:41:06 2017
+++ src/sys/dev/ata/ata.c	Wed Oct 18 08:38:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata.c,v 1.137 2017/10/15 14:41:06 jdolecek Exp $	*/
+/*	$NetBSD: ata.c,v 1.138 2017/10/18 08:38:35 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.137 2017/10/15 14:41:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.138 2017/10/18 08:38:35 jdolecek Exp $");
 
 #include "opt_ata.h"
 
@@ -1132,14 +1132,14 @@ atastart(struct ata_channel *chp)
 again:
 	KASSERT(chq->queue_active <= chq->queue_openings);
 	if (chq->queue_active == chq->queue_openings) {
-		ATADEBUG_PRINT(("%s: channel completely busy", __func__),
+		ATADEBUG_PRINT(("%s: channel completely busy\n", __func__),
 		DEBUG_XFERS);
 		goto out;
 	}
 
 	/* is there a xfer ? */
 	if ((xfer = TAILQ_FIRST(&chp->ch_queue->queue_xfer)) == NULL) {
-		ATADEBUG_PRINT(("%s: queue_xfer is empty", __func__),
+		ATADEBUG_PRINT(("%s: queue_xfer is empty\n", __func__),
 		DEBUG_XFERS);
 		goto out;
 	}