CVS commit: src/sys/netipsec

2017-08-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Aug  7 03:30:46 UTC 2017

Modified Files:
src/sys/netipsec: key.c

Log Message:
Describe constraints of key_sp_ref and key_sp_unref

Requested by riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/sys/netipsec/key.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/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.210 src/sys/netipsec/key.c:1.211
--- src/sys/netipsec/key.c:1.210	Mon Aug  7 03:28:31 2017
+++ src/sys/netipsec/key.c	Mon Aug  7 03:30:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.210 2017/08/07 03:28:31 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.211 2017/08/07 03:30:45 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.210 2017/08/07 03:28:31 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.211 2017/08/07 03:30:45 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -1309,6 +1309,10 @@ key_init_sp(struct secpolicy *sp)
 	SPLIST_ENTRY_INIT(sp);
 }
 
+/*
+ * Must be called in a pserialize critical section. A held SP
+ * must be released by key_sp_unref after use.
+ */
 void
 key_sp_ref(struct secpolicy *sp, const char* where, int tag)
 {
@@ -1320,6 +1324,10 @@ key_sp_ref(struct secpolicy *sp, const c
 	sp, sp->id, where, tag, key_sp_refcnt(sp));
 }
 
+/*
+ * Must be called without holding key_spd.lock because the lock
+ * would be held in localcount_release.
+ */
 void
 key_sp_unref(struct secpolicy *sp, const char* where, int tag)
 {



CVS commit: src/sys/netipsec

2017-08-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Aug  7 03:28:31 UTC 2017

Modified Files:
src/sys/netipsec: key.c

Log Message:
Update the locking notes

- Add locking order
- Add locking notes for misc lists such as reglist
- Mention pserialize, key_sp_ref and key_sp_unref on SP operations

Requested by riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.209 -r1.210 src/sys/netipsec/key.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/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.209 src/sys/netipsec/key.c:1.210
--- src/sys/netipsec/key.c:1.209	Mon Aug  7 03:22:33 2017
+++ src/sys/netipsec/key.c	Mon Aug  7 03:28:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.209 2017/08/07 03:22:33 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.210 2017/08/07 03:28:31 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.209 2017/08/07 03:22:33 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.210 2017/08/07 03:28:31 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -149,23 +149,30 @@ static int key_prefered_oldsa = 0;	/* pr
 static u_int32_t acq_seq = 0;
 
 /*
+ * Locking order: there is no order for now; it means that any locks aren't
+ * overlapped.
+ */
+/*
  * Locking notes on SPD:
  * - Modifications to the key_spd.splist must be done with holding key_spd.lock
  *   which is a adaptive mutex
- * - Read accesses to the key_spd.splist must be in critical sections of pserialize(9)
+ * - Read accesses to the key_spd.splist must be in critical sections of
+ *   pserialize(9)
  * - SP's lifetime is managed by localcount(9)
- * - An SP that has been inserted to the key_spd.splist is initially referenced by none,
- *   i.e., a reference from the key_spd.splist isn't counted
+ * - An SP that has been inserted to the key_spd.splist is initially referenced
+ *   by none, i.e., a reference from the key_spd.splist isn't counted
  * - When an SP is being destroyed, we change its state as DEAD, wait for
  *   references to the SP to be released, and then deallocate the SP
  *   (see key_unlink_sp)
  * - Getting an SP
- *   - Normally we get an SP from the key_spd.splist by incrementing the reference count
- * of the SP
+ *   - Normally we get an SP from the key_spd.splist (see key_lookup_sp_byspidx)
+ * - Must iterate the list and increment the reference count of a found SP
+ *   (by key_sp_ref) in a pserialize critical section
  *   - We can gain another reference from a held SP only if we check its state
  * and take its reference in a critical section of pserialize
  * (see esp_output for example)
  *   - We may get an SP from an SP cache. See below
+ *   - A gotten SP must be released after use by KEY_SP_UNREF (key_sp_unref)
  * - Updating member variables of an SP
  *   - Most member variables of an SP are immutable
  *   - Only sp->state and sp->lastused can be changed
@@ -191,6 +198,11 @@ static u_int32_t acq_seq = 0;
  * it directly instead we just mark it DEAD and delay the destruction
  * until GC by the timer
  */
+/*
+ * Locking notes on misc data:
+ * - All lists of key_misc are protected by key_misc.lock
+ *   - key_misc.lock must be held even for read accesses
+ */
 
 static pserialize_t key_psz;
 



CVS commit: src/sys/netipsec

2017-08-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Aug  7 03:22:33 UTC 2017

Modified Files:
src/sys/netipsec: key.c

Log Message:
Move locking notes


To generate a diff of this commit:
cvs rdiff -u -r1.208 -r1.209 src/sys/netipsec/key.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/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.208 src/sys/netipsec/key.c:1.209
--- src/sys/netipsec/key.c:1.208	Mon Aug  7 03:21:58 2017
+++ src/sys/netipsec/key.c	Mon Aug  7 03:22:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.208 2017/08/07 03:21:58 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.209 2017/08/07 03:22:33 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.208 2017/08/07 03:21:58 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.209 2017/08/07 03:22:33 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -135,6 +135,19 @@ percpu_t *pfkeystat_percpu;
  *   field hits 0 (= no external reference other than from SA header.
  */
 
+u_int32_t key_debug_level = 0;
+static u_int key_spi_trycnt = 1000;
+static u_int32_t key_spi_minval = 0x100;
+static u_int32_t key_spi_maxval = 0x0fff;	/* XXX */
+static u_int32_t policy_id = 0;
+static u_int key_int_random = 60;	/*interval to initialize randseed,1(m)*/
+static u_int key_larval_lifetime = 30;	/* interval to expire acquiring, 30(s)*/
+static int key_blockacq_count = 10;	/* counter for blocking SADB_ACQUIRE.*/
+static int key_blockacq_lifetime = 20;	/* lifetime for blocking SADB_ACQUIRE.*/
+static int key_prefered_oldsa = 0;	/* prefered old sa rather than new sa.*/
+
+static u_int32_t acq_seq = 0;
+
 /*
  * Locking notes on SPD:
  * - Modifications to the key_spd.splist must be done with holding key_spd.lock
@@ -179,19 +192,6 @@ percpu_t *pfkeystat_percpu;
  * until GC by the timer
  */
 
-u_int32_t key_debug_level = 0;
-static u_int key_spi_trycnt = 1000;
-static u_int32_t key_spi_minval = 0x100;
-static u_int32_t key_spi_maxval = 0x0fff;	/* XXX */
-static u_int32_t policy_id = 0;
-static u_int key_int_random = 60;	/*interval to initialize randseed,1(m)*/
-static u_int key_larval_lifetime = 30;	/* interval to expire acquiring, 30(s)*/
-static int key_blockacq_count = 10;	/* counter for blocking SADB_ACQUIRE.*/
-static int key_blockacq_lifetime = 20;	/* lifetime for blocking SADB_ACQUIRE.*/
-static int key_prefered_oldsa = 0;	/* prefered old sa rather than new sa.*/
-
-static u_int32_t acq_seq = 0;
-
 static pserialize_t key_psz;
 
 /* SPD */



CVS commit: src/sys/netipsec

2017-08-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Aug  7 03:21:59 UTC 2017

Modified Files:
src/sys/netipsec: key.c keydb.h

Log Message:
Assemble global lists and related locks into cache lines (NFCI)

Also rename variable names from *tree to *list because they are
just lists, not trees.

Suggested by riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.208 src/sys/netipsec/key.c
cvs rdiff -u -r1.17 -r1.18 src/sys/netipsec/keydb.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/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.207 src/sys/netipsec/key.c:1.208
--- src/sys/netipsec/key.c:1.207	Mon Aug  7 03:20:02 2017
+++ src/sys/netipsec/key.c	Mon Aug  7 03:21:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.207 2017/08/07 03:20:02 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.208 2017/08/07 03:21:58 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.207 2017/08/07 03:20:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.208 2017/08/07 03:21:58 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -137,17 +137,17 @@ percpu_t *pfkeystat_percpu;
 
 /*
  * Locking notes on SPD:
- * - Modifications to the sptree must be done with holding key_sp_mtx
+ * - Modifications to the key_spd.splist must be done with holding key_spd.lock
  *   which is a adaptive mutex
- * - Read accesses to the sptree must be in critical sections of pserialize(9)
+ * - Read accesses to the key_spd.splist must be in critical sections of pserialize(9)
  * - SP's lifetime is managed by localcount(9)
- * - An SP that has been inserted to the sptree is initially referenced by none,
- *   i.e., a reference from the pstree isn't counted
+ * - An SP that has been inserted to the key_spd.splist is initially referenced by none,
+ *   i.e., a reference from the key_spd.splist isn't counted
  * - When an SP is being destroyed, we change its state as DEAD, wait for
  *   references to the SP to be released, and then deallocate the SP
  *   (see key_unlink_sp)
  * - Getting an SP
- *   - Normally we get an SP from the sptree by incrementing the reference count
+ *   - Normally we get an SP from the key_spd.splist by incrementing the reference count
  * of the SP
  *   - We can gain another reference from a held SP only if we check its state
  * and take its reference in a critical section of pserialize
@@ -156,7 +156,7 @@ percpu_t *pfkeystat_percpu;
  * - Updating member variables of an SP
  *   - Most member variables of an SP are immutable
  *   - Only sp->state and sp->lastused can be changed
- *   - sp->state of an SP is updated only when destroying it under key_sp_mtx
+ *   - sp->state of an SP is updated only when destroying it under key_spd.lock
  * - SP caches
  *   - SPs can be cached in PCBs
  *   - The lifetime of the caches is controlled by the global generation counter
@@ -172,7 +172,7 @@ percpu_t *pfkeystat_percpu;
  *   - Userland programs can set a policy to a socket by
  * setsockopt(IP_IPSEC_POLICY)
  *   - Such policies (SPs) are set to a socket (PCB) and also inserted to
- * the key_socksplist list (not the sptree)
+ * the key_spd.socksplist list (not the key_spd.splist)
  *   - Such a policy is destroyed when a corresponding socket is destroed,
  * however, a socket can be destroyed in softint so we cannot destroy
  * it directly instead we just mark it DEAD and delay the destruction
@@ -192,17 +192,42 @@ static int key_prefered_oldsa = 0;	/* pr
 
 static u_int32_t acq_seq = 0;
 
-static struct pslist_head sptree[IPSEC_DIR_MAX];		/* SPD */
-static struct pslist_head sahtree;/* SAD */
-static LIST_HEAD(_regtree, secreg) regtree[SADB_SATYPE_MAX + 1];
-			/* registed list */
+static pserialize_t key_psz;
+
+/* SPD */
+static struct {
+	kmutex_t lock;
+	kcondvar_t cv;
+	struct pslist_head splist[IPSEC_DIR_MAX];
+	/*
+	 * The list has SPs that are set to a socket via
+	 * setsockopt(IP_IPSEC_POLICY) from userland. See ipsec_set_policy.
+	 */
+	struct pslist_head socksplist;
+} key_spd __cacheline_aligned;
+
+/* SAD */
+static struct {
+	kmutex_t lock;
+	struct pslist_head sahlist;
+} key_sad __cacheline_aligned;
+
+/* Misc data */
+static struct {
+	kmutex_t lock;
+	/* registed list */
+	LIST_HEAD(_reglist, secreg) reglist[SADB_SATYPE_MAX + 1];
 #ifndef IPSEC_NONBLOCK_ACQUIRE
-static LIST_HEAD(_acqtree, secacq) acqtree;		/* acquiring list */
+	/* acquiring list */
+	LIST_HEAD(_acqlist, secacq) acqlist;
 #endif
 #ifdef notyet
-static LIST_HEAD(_spacqtree, secspacq) spacqtree;	/* SP acquiring list */
+	/* SP acquiring list */
+	LIST_HEAD(_spacqlist, secspacq) spacqlist;
 #endif
+} key_misc __cacheline_aligned;
 
+/* Macros for key_spd.splist */
 #define SPLIST_ENTRY_INIT(sp)			

CVS commit: src/sys/netipsec

2017-08-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Aug  7 03:20:02 UTC 2017

Modified Files:
src/sys/netipsec: key.c

Log Message:
Use KDASSERT instead of KASSERT for mutex_ownable

Because mutex_ownable is too heavy to run in a fast path
even for DIAGNOSTIC + LOCKDEBUG.

Suggested by riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 src/sys/netipsec/key.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/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.206 src/sys/netipsec/key.c:1.207
--- src/sys/netipsec/key.c:1.206	Thu Aug  3 06:32:51 2017
+++ src/sys/netipsec/key.c	Mon Aug  7 03:20:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.206 2017/08/03 06:32:51 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.207 2017/08/07 03:20:02 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.206 2017/08/03 06:32:51 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.207 2017/08/07 03:20:02 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -1297,7 +1297,7 @@ void
 key_sp_unref(struct secpolicy *sp, const char* where, int tag)
 {
 
-	KASSERT(mutex_ownable(_sp_mtx));
+	KDASSERT(mutex_ownable(_sp_mtx));
 
 	KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_STAMP,
 	"DP SP:%p (ID=%u) from %s:%u; refcnt-- now %u\n",



CVS commit: src/sys/netipsec

2017-08-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Aug  7 03:18:32 UTC 2017

Modified Files:
src/sys/netipsec: ipsec.c

Log Message:
Remove out-of-date log output

Pointed out by riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/netipsec/ipsec.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/netipsec/ipsec.c
diff -u src/sys/netipsec/ipsec.c:1.116 src/sys/netipsec/ipsec.c:1.117
--- src/sys/netipsec/ipsec.c:1.116	Thu Aug  3 06:32:51 2017
+++ src/sys/netipsec/ipsec.c	Mon Aug  7 03:18:32 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec.c,v 1.116 2017/08/03 06:32:51 ozaki-r Exp $	*/
+/*	$NetBSD: ipsec.c,v 1.117 2017/08/07 03:18:32 ozaki-r Exp $	*/
 /*	$FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec.c,v 1.2.2.2 2003/07/01 01:38:13 sam Exp $	*/
 /*	$KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.116 2017/08/03 06:32:51 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.117 2017/08/07 03:18:32 ozaki-r Exp $");
 
 /*
  * IPsec controller part.
@@ -297,11 +297,6 @@ ipsec_fillpcbcache(struct inpcbpolicy *p
 	}
 	pcbsp->sp_cache[dir].cachesp = sp;
 	if (pcbsp->sp_cache[dir].cachesp) {
-		KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_STAMP,
-		"DP cause refcnt++:%d SP:%p\n",
-		key_sp_refcnt(pcbsp->sp_cache[dir].cachesp),
-		pcbsp->sp_cache[dir].cachesp);
-
 		/*
 		 * If the PCB is connected, we can remember a hint to
 		 * possibly short-circuit IPsec processing in other places.



CVS commit: src/sys/arch/evbarm/conf

2017-08-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  6 17:16:02 UTC 2017

Modified Files:
src/sys/arch/evbarm/conf: SUNXI

Log Message:
Enable H3 audio support


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/evbarm/conf/SUNXI

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/evbarm/conf/SUNXI
diff -u src/sys/arch/evbarm/conf/SUNXI:1.20 src/sys/arch/evbarm/conf/SUNXI:1.21
--- src/sys/arch/evbarm/conf/SUNXI:1.20	Sat Aug  5 17:52:06 2017
+++ src/sys/arch/evbarm/conf/SUNXI	Sun Aug  6 17:16:02 2017
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: SUNXI,v 1.20 2017/08/05 17:52:06 jmcneill Exp $
+#	$NetBSD: SUNXI,v 1.21 2017/08/06 17:16:02 jmcneill Exp $
 #
 #	Allwinner sunxi family
 #
@@ -117,6 +117,12 @@ iic*		at i2cbus?
 # RTC
 sunxirtc*	at fdt?			# RTC
 
+# Audio
+sunxicodec*	at fdt?			# Audio codec
+h3codec*	at fdt?			# H3 audio codec (analog part)
+audio*		at audiobus?
+spkr*		at audio?
+
 # SDMMC
 sunximmc*	at fdt?			# SDMMC
 sdmmc*		at sunximmc?



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

2017-08-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  6 17:15:45 UTC 2017

Modified Files:
src/sys/arch/arm/sunxi: files.sunxi
Added Files:
src/sys/arch/arm/sunxi: sun8i_h3_codec.c sunxi_codec.c sunxi_codec.h

Log Message:
Add support for Allwinner H3 audio codec.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/sunxi/files.sunxi
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sunxi/sun8i_h3_codec.c \
src/sys/arch/arm/sunxi/sunxi_codec.c src/sys/arch/arm/sunxi/sunxi_codec.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/sunxi/files.sunxi
diff -u src/sys/arch/arm/sunxi/files.sunxi:1.15 src/sys/arch/arm/sunxi/files.sunxi:1.16
--- src/sys/arch/arm/sunxi/files.sunxi:1.15	Sat Aug  5 17:51:49 2017
+++ src/sys/arch/arm/sunxi/files.sunxi	Sun Aug  6 17:15:45 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sunxi,v 1.15 2017/08/05 17:51:49 jmcneill Exp $
+#	$NetBSD: files.sunxi,v 1.16 2017/08/06 17:15:45 jmcneill Exp $
 #
 # Configuration info for Allwinner sunxi family SoCs
 #
@@ -113,6 +113,16 @@ device	sun6idma
 attach	sun6idma at fdt with sun6i_dma
 file	arch/arm/sunxi/sun6i_dma.c		sun6i_dma
 
+# Audio codec
+device	sunxicodec: audiobus, auconv, mulaw, aurateconv
+attach	sunxicodec at fdt with sunxi_codec
+file	arch/arm/sunxi/sunxi_codec.c		sunxi_codec
+
+# Audio codec (analog part)
+device	h3codec
+attach	h3codec at fdt with h3_codec
+file	arch/arm/sunxi/sun8i_h3_codec.c		h3_codec needs-flag
+
 # SOC parameters
 defflag	opt_soc.h			SOC_SUNXI
 defflag	opt_soc.h			SOC_SUN8I: SOC_SUNXI

Added files:

Index: src/sys/arch/arm/sunxi/sun8i_h3_codec.c
diff -u /dev/null src/sys/arch/arm/sunxi/sun8i_h3_codec.c:1.1
--- /dev/null	Sun Aug  6 17:15:45 2017
+++ src/sys/arch/arm/sunxi/sun8i_h3_codec.c	Sun Aug  6 17:15:45 2017
@@ -0,0 +1,471 @@
+/* $NetBSD: sun8i_h3_codec.c,v 1.1 2017/08/06 17:15:45 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2014-2017 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: sun8i_h3_codec.c,v 1.1 2017/08/06 17:15:45 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#define	H3_PR_CFG		0x00
+#define	 H3_AC_PR_RW		__BIT(24)
+#define	 H3_AC_PR_RST		__BIT(18)
+#define	 H3_AC_PR_ADDR		__BITS(20,16)
+#define	 H3_ACDA_PR_WDAT	__BITS(15,8)
+#define	 H3_ACDA_PR_RDAT	__BITS(7,0)
+
+#define	H3_LOMIXSC		0x01
+#define	 H3_LOMIXSC_LDAC	__BIT(1)
+#define	H3_ROMIXSC		0x02
+#define	 H3_ROMIXSC_RDAC	__BIT(1)
+#define	H3_DAC_PA_SRC		0x03
+#define	 H3_DACAREN		__BIT(7)
+#define	 H3_DACALEN		__BIT(6)
+#define	 H3_RMIXEN		__BIT(5)
+#define	 H3_LMIXEN		__BIT(4)
+#define	H3_LINEIN_GCTR		0x05
+#define	 H3_LINEING		__BITS(6,4)
+#define	H3_MIC_GCTR		0x06
+#define	 H3_MIC1_GAIN		__BITS(6,4)
+#define	 H3_MIC2_GAIN		__BITS(2,0)
+#define	H3_PAEN_CTR		0x07
+#define	 H3_LINEOUTEN		__BIT(7)
+#define	H3_LINEOUT_VOLC		0x09
+#define	 H3_LINEOUTVOL		__BITS(7,3)
+#define	H3_MIC2G_LINEOUT_CTR	0x0a
+#define	 H3_LINEOUT_LSEL	__BIT(3)
+#define	 H3_LINEOUT_RSEL	__BIT(2)
+#define	H3_LADCMIXSC		0x0c
+#define	H3_RADCMIXSC		0x0d
+#define	 H3_ADCMIXSC_MIC1	__BIT(6)
+#define	 H3_ADCMIXSC_MIC2	__BIT(5)
+#define	 H3_ADCMIXSC_LINEIN	__BIT(2)
+#define	 H3_ADCMIXSC_OMIXER	__BITS(1,0)
+#define	H3_ADC_AP_EN		0x0f
+#define	 H3_ADCREN		__BIT(7)
+#define	 H3_ADCLEN		__BIT(6)
+#define	 H3_ADCG		__BITS(2,0)
+
+struct h3_codec_softc {
+	device_t		sc_dev;
+	bus_space_tag_t		sc_bst;
+	bus_space_handle_t	sc_bsh;
+	int			sc_phandle;
+};
+
+enum h3_codec_mixer_ctrl {
+	H3_CODEC_OUTPUT_CLASS,
+	H3_CODEC_INPUT_CLASS,
+	

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

2017-08-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  6 17:14:37 UTC 2017

Modified Files:
src/sys/arch/arm/sunxi: sun8i_h3_ccu.c sunxi_ccu.h sunxi_ccu_nkmp.c

Log Message:
Add support for H3 audio PLL and digital audio part.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sun8i_h3_ccu.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_ccu.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_ccu_nkmp.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/arm/sunxi/sun8i_h3_ccu.c
diff -u src/sys/arch/arm/sunxi/sun8i_h3_ccu.c:1.9 src/sys/arch/arm/sunxi/sun8i_h3_ccu.c:1.10
--- src/sys/arch/arm/sunxi/sun8i_h3_ccu.c:1.9	Sat Aug  5 17:50:53 2017
+++ src/sys/arch/arm/sunxi/sun8i_h3_ccu.c	Sun Aug  6 17:14:37 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: sun8i_h3_ccu.c,v 1.9 2017/08/05 17:50:53 jmcneill Exp $ */
+/* $NetBSD: sun8i_h3_ccu.c,v 1.10 2017/08/06 17:14:37 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,7 +29,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_h3_ccu.c,v 1.9 2017/08/05 17:50:53 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_h3_ccu.c,v 1.10 2017/08/06 17:14:37 jmcneill Exp $");
 
 #include 
 #include 
@@ -41,6 +41,7 @@ __KERNEL_RCSID(1, "$NetBSD: sun8i_h3_ccu
 #include 
 #include 
 
+#define	PLL_AUDIO_CTRL_REG	0x008
 #define	PLL_PERIPH0_CTRL_REG	0x028
 #define	AHB1_APB1_CFG_REG	0x054
 #define	APB2_CFG_REG		0x058
@@ -55,6 +56,7 @@ __KERNEL_RCSID(1, "$NetBSD: sun8i_h3_ccu
 #define	SDMMC2_CLK_REG		0x090
 #define	USBPHY_CFG_REG		0x0cc
 #define	MBUS_RST_REG		0x0fc
+#define	AC_DIG_CLK_REG		0x140
 #define	BUS_SOFT_RST_REG0	0x2c0
 #define	BUS_SOFT_RST_REG1	0x2c4
 #define	BUS_SOFT_RST_REG2	0x2c8
@@ -141,6 +143,11 @@ static const char *apb1_parents[] = { "a
 static const char *apb2_parents[] = { "losc", "hosc", "pll_periph0" };
 static const char *mod_parents[] = { "hosc", "pll_periph0", "pll_periph1" };
 
+static const struct sunxi_ccu_nkmp_tbl sunx8_h3_ac_dig_table[] = {
+	{ 24576000, 13, 0, 0, 13 },
+	{ 0 }
+};
+
 static struct sunxi_ccu_clk sun8i_h3_ccu_clks[] = {
 	SUNXI_CCU_NKMP(H3_CLK_PLL_PERIPH0, "pll_periph0", "hosc",
 	PLL_PERIPH0_CTRL_REG,	/* reg */
@@ -151,6 +158,17 @@ static struct sunxi_ccu_clk sun8i_h3_ccu
 	__BIT(31),			/* enable */
 	SUNXI_CCU_NKMP_DIVIDE_BY_TWO),
 
+	SUNXI_CCU_NKMP_TABLE(H3_CLK_PLL_AUDIO_BASE, "pll_audio", "hosc",
+	PLL_AUDIO_CTRL_REG,		/* reg */
+	__BITS(14,8),		/* n */
+	0,/* k */
+	__BITS(4,0),		/* m */
+	__BITS(19,16),		/* p */
+	__BIT(31),			/* enable */
+	__BIT(28),			/* lock */
+	sunx8_h3_ac_dig_table,	/* table */
+	0),
+
 	SUNXI_CCU_PREDIV(H3_CLK_AHB1, "ahb1", ahb1_parents,
 	AHB1_APB1_CFG_REG,	/* reg */
 	__BITS(7,6),	/* prediv */
@@ -203,6 +221,9 @@ static struct sunxi_ccu_clk sun8i_h3_ccu
 	SUNXI_CCU_PHASE(H3_CLK_MMC2_OUTPUT, "mmc2_output", "mmc2",
 	SDMMC2_CLK_REG, __BITS(10,8)),
 
+	SUNXI_CCU_GATE(H3_CLK_AC_DIG, "ac_dig", "pll_audio",
+	AC_DIG_CLK_REG, 31),
+
 	SUNXI_CCU_GATE(H3_CLK_BUS_DMA, "bus-dma", "ahb1",
 	BUS_CLK_GATING_REG0, 6),
 	SUNXI_CCU_GATE(H3_CLK_BUS_MMC0, "bus-mmc0", "ahb1",
@@ -232,6 +253,8 @@ static struct sunxi_ccu_clk sun8i_h3_ccu
 	SUNXI_CCU_GATE(H3_CLK_BUS_OHCI3, "bus-ohci3", "ahb2",
 	BUS_CLK_GATING_REG0, 31),
 
+	SUNXI_CCU_GATE(H3_CLK_BUS_CODEC, "bus-codec", "apb1",
+	BUS_CLK_GATING_REG2, 0),
 	SUNXI_CCU_GATE(H3_CLK_BUS_PIO, "bus-pio", "apb1",
 	BUS_CLK_GATING_REG2, 5),
 

Index: src/sys/arch/arm/sunxi/sunxi_ccu.h
diff -u src/sys/arch/arm/sunxi/sunxi_ccu.h:1.7 src/sys/arch/arm/sunxi/sunxi_ccu.h:1.8
--- src/sys/arch/arm/sunxi/sunxi_ccu.h:1.7	Mon Jul 17 23:26:17 2017
+++ src/sys/arch/arm/sunxi/sunxi_ccu.h	Sun Aug  6 17:14:37 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu.h,v 1.7 2017/07/17 23:26:17 jmcneill Exp $ */
+/* $NetBSD: sunxi_ccu.h,v 1.8 2017/08/06 17:14:37 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -79,6 +79,7 @@ const char *sunxi_ccu_gate_get_parent(st
 	[_id] = {		\
 		.type = SUNXI_CCU_GATE,\
 		.base.name = (_name),\
+		.base.flags = CLK_SET_RATE_PARENT,		\
 		.u.gate.parent = (_pname),			\
 		.u.gate.reg = (_reg),\
 		.u.gate.mask = __BIT(_bit),			\
@@ -86,6 +87,14 @@ const char *sunxi_ccu_gate_get_parent(st
 		.get_parent = sunxi_ccu_gate_get_parent,	\
 	}
 
+struct sunxi_ccu_nkmp_tbl {
+	u_int		rate;
+	uint32_t	n;
+	uint32_t	k;
+	uint32_t	m;
+	uint32_t	p;
+};
+
 struct sunxi_ccu_nkmp {
 	bus_size_t	reg;
 	const char	*parent;
@@ -96,6 +105,7 @@ struct sunxi_ccu_nkmp {
 	uint32_t	lock;
 	uint32_t	enable;
 	uint32_t	flags;
+	const struct sunxi_ccu_nkmp_tbl *table;
 #define	SUNXI_CCU_NKMP_DIVIDE_BY_TWO	__BIT(0)
 #define	SUNXI_CCU_NKMP_FACTOR_N_EXACT	__BIT(1)
 };
@@ -109,8 +119,8 @@ int	sunxi_ccu_nkmp_set_rate(struct sunxi
 const char *sunxi_ccu_nkmp_get_parent(struct 

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

2017-08-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  6 17:13:15 UTC 2017

Modified Files:
src/sys/arch/arm/sunxi: sun6i_dma.c

Log Message:
Fix burst field encoding, and add a helper function to dump registers
from ddb.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sun6i_dma.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/arm/sunxi/sun6i_dma.c
diff -u src/sys/arch/arm/sunxi/sun6i_dma.c:1.1 src/sys/arch/arm/sunxi/sun6i_dma.c:1.2
--- src/sys/arch/arm/sunxi/sun6i_dma.c:1.1	Sat Aug  5 17:51:49 2017
+++ src/sys/arch/arm/sunxi/sun6i_dma.c	Sun Aug  6 17:13:15 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: sun6i_dma.c,v 1.1 2017/08/05 17:51:49 jmcneill Exp $ */
+/* $NetBSD: sun6i_dma.c,v 1.2 2017/08/06 17:13:15 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -26,8 +26,10 @@
  * SUCH DAMAGE.
  */
 
+#include "opt_ddb.h"
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun6i_dma.c,v 1.1 2017/08/05 17:51:49 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun6i_dma.c,v 1.2 2017/08/06 17:13:15 jmcneill Exp $");
 
 #include 
 #include 
@@ -212,8 +214,8 @@ sun6idma_transfer(device_t dev, void *pr
 
 	mem_width = DMA_CFG_DATA_WIDTH(req->dreq_mem_opt.opt_bus_width);
 	dev_width = DMA_CFG_DATA_WIDTH(req->dreq_dev_opt.opt_bus_width);
-	mem_burst = DMA_CFG_BST_LEN(req->dreq_mem_opt.opt_burst_len / NBBY);
-	dev_burst = DMA_CFG_BST_LEN(req->dreq_dev_opt.opt_burst_len / NBBY);
+	mem_burst = DMA_CFG_BST_LEN(req->dreq_mem_opt.opt_burst_len);
+	dev_burst = DMA_CFG_BST_LEN(req->dreq_dev_opt.opt_burst_len);
 
 	mem_cfg = __SHIFTIN(mem_width, DMA_CFG_SRC_DATA_WIDTH) |
 	__SHIFTIN(mem_burst, DMA_CFG_SRC_BST_LEN) |
@@ -249,6 +251,12 @@ sun6idma_transfer(device_t dev, void *pr
 	ch->ch_dmamap->dm_segs[0].ds_addr);
 	DMA_WRITE(sc, DMA_EN_REG(ch->ch_index), DMA_EN_EN);
 
+	if ((DMA_READ(sc, DMA_EN_REG(ch->ch_index)) & DMA_EN_EN) == 0) {
+		aprint_error_dev(sc->sc_dev,
+		"DMA Channel %u failed to start\n", ch->ch_index);
+		return EIO;
+	}
+
 	return 0;
 }
 
@@ -406,3 +414,40 @@ sun6idma_attach(device_t parent, device_
 
 CFATTACH_DECL_NEW(sun6i_dma, sizeof(struct sun6idma_softc),
 sun6idma_match, sun6idma_attach, NULL, NULL);
+
+#ifdef DDB
+void sun6idma_dump(void);
+
+void
+sun6idma_dump(void)
+{
+	struct sun6idma_softc *sc;
+	device_t dev;
+	u_int index;
+
+	dev = device_find_by_driver_unit("sun6idma", 0);
+	if (dev == NULL)
+		return;
+	sc = device_private(dev);
+
+	device_printf(dev, "DMA_IRQ_EN_REG0_REG:   %08x\n", DMA_READ(sc, DMA_IRQ_EN_REG0_REG));
+	device_printf(dev, "DMA_IRQ_EN_REG1_REG:   %08x\n", DMA_READ(sc, DMA_IRQ_EN_REG1_REG));
+	device_printf(dev, "DMA_IRQ_PEND_REG0_REG: %08x\n", DMA_READ(sc, DMA_IRQ_PEND_REG0_REG));
+	device_printf(dev, "DMA_IRQ_PEND_REG1_REG: %08x\n", DMA_READ(sc, DMA_IRQ_PEND_REG1_REG));
+	device_printf(dev, "DMA_STA_REG:   %08x\n", DMA_READ(sc, DMA_STA_REG));
+
+	for (index = 0; index < sc->sc_nchan; index++) {
+		struct sun6idma_channel *ch = >sc_chan[index];
+		if (ch->ch_callback == NULL)
+			continue;
+		device_printf(dev, " %2d: DMA_EN_REG: %08x\n", index, DMA_READ(sc, DMA_EN_REG(index)));
+		device_printf(dev, " %2d: DMA_PAU_REG:%08x\n", index, DMA_READ(sc, DMA_PAU_REG(index)));
+		device_printf(dev, " %2d: DMA_START_ADDR_REG: %08x\n", index, DMA_READ(sc, DMA_START_ADDR_REG(index)));
+		device_printf(dev, " %2d: DMA_CFG_REG:%08x\n", index, DMA_READ(sc, DMA_CFG_REG(index)));
+		device_printf(dev, " %2d: DMA_CUR_SRC_REG:%08x\n", index, DMA_READ(sc, DMA_CUR_SRC_REG(index)));
+		device_printf(dev, " %2d: DMA_CUR_DEST_REG:   %08x\n", index, DMA_READ(sc, DMA_CUR_DEST_REG(index)));
+		device_printf(dev, " %2d: DMA_BCNT_LEFT_REG:  %08x\n", index, DMA_READ(sc, DMA_BCNT_LEFT_REG(index)));
+		device_printf(dev, " %2d: DMA_PARA_REG:   %08x\n", index, DMA_READ(sc, DMA_PARA_REG(index)));
+	}
+}
+#endif



CVS commit: src/sys/arch/pmax/conf

2017-08-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug  6 11:50:21 UTC 2017

Modified Files:
src/sys/arch/pmax/conf: GENERIC

Log Message:
Turn on DIAGNOSTIC and DEBUG.


To generate a diff of this commit:
cvs rdiff -u -r1.191 -r1.192 src/sys/arch/pmax/conf/GENERIC

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/pmax/conf/GENERIC
diff -u src/sys/arch/pmax/conf/GENERIC:1.191 src/sys/arch/pmax/conf/GENERIC:1.192
--- src/sys/arch/pmax/conf/GENERIC:1.191	Fri Jul 28 15:26:16 2017
+++ src/sys/arch/pmax/conf/GENERIC	Sun Aug  6 07:50:21 2017
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.191 2017/07/28 19:26:16 maxv Exp $
+# $NetBSD: GENERIC,v 1.192 2017/08/06 11:50:21 christos Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include		"arch/pmax/conf/std.pmax"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.191 $"
+#ident		"GENERIC-$Revision: 1.192 $"
 
 maxusers	64
 
@@ -47,8 +47,11 @@ makeoptions	DEBUG="-g"
 options 	DDB			# in-kernel debugger
 options 	DDB_HISTORY_SIZE=512	# enable history editing in DDB
 options 	DDB_ONPANIC=0		# don't enter debugger on panic
-#options 	DIAGNOSTIC		# extra kernel debugging checks
-#options 	DEBUG			# extra kernel debugging support
+options 	DIAGNOSTIC		# extra kernel debugging checks
+options 	DEBUG			# extra kernel debugging support
+options		LOCKDEBUG
+#options	VMFAULT_TRACE
+#options	PMAP_FAULTINFO
 options 	COMPAT_43		# compatibility with 4.3BSD binaries
 options 	KTRACE			# system call tracing support
 



CVS commit: src/sys/dev

2017-08-06 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sun Aug  6 10:07:31 UTC 2017

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

Log Message:
Ensure to call mix write if inserting silence into the hw ring.

Addresses PR kern/52459.

Patch provided and tested by isaki@.


To generate a diff of this commit:
cvs rdiff -u -r1.386 -r1.387 src/sys/dev/audio.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.386 src/sys/dev/audio.c:1.387
--- src/sys/dev/audio.c:1.386	Sat Aug  5 13:34:06 2017
+++ src/sys/dev/audio.c	Sun Aug  6 10:07:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.386 2017/08/05 13:34:06 nat Exp $	*/
+/*	$NetBSD: audio.c,v 1.387 2017/08/06 10:07:31 nat Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss 
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.386 2017/08/05 13:34:06 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.387 2017/08/06 10:07:31 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -3682,12 +3682,10 @@ audio_pint(void *v)
 			vc->sc_mpr.s.inp, cc);
 			used -= cc;
 		}
-		goto wake_mix;
 	}
 
 	mix_write(sc);
 
-wake_mix:
 	cv_broadcast(>sc_condvar);
 }
 



CVS commit: src/sys/kern

2017-08-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug  6 09:14:14 UTC 2017

Modified Files:
src/sys/kern: kern_synch.c

Log Message:
use the same string for the log and uprintf.


To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.312 src/sys/kern/kern_synch.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/kern_synch.c
diff -u src/sys/kern/kern_synch.c:1.311 src/sys/kern/kern_synch.c:1.312
--- src/sys/kern/kern_synch.c:1.311	Sun Jul  3 10:24:58 2016
+++ src/sys/kern/kern_synch.c	Sun Aug  6 05:14:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_synch.c,v 1.311 2016/07/03 14:24:58 christos Exp $	*/
+/*	$NetBSD: kern_synch.c,v 1.312 2017/08/06 09:14:14 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.311 2016/07/03 14:24:58 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.312 2017/08/06 09:14:14 christos Exp $");
 
 #include "opt_kstack.h"
 #include "opt_perfctrs.h"
@@ -1208,11 +1208,11 @@ sched_pstats(void)
 		if (__predict_false(runtm >= rlim->rlim_cur)) {
 			if (runtm >= rlim->rlim_max) {
 sig = SIGKILL;
-log(LOG_NOTICE, "pid %d is killed: %s\n",
-	p->p_pid, "exceeded RLIMIT_CPU");
+log(LOG_NOTICE,
+"pid %d, command %s, is killed: %s\n",
+p->p_pid, p->p_comm, "exceeded RLIMIT_CPU");
 uprintf("pid %d, command %s, is killed: %s\n",
-	p->p_pid, p->p_comm,
-	"exceeded RLIMIT_CPU");
+p->p_pid, p->p_comm, "exceeded RLIMIT_CPU");
 			} else {
 sig = SIGXCPU;
 if (rlim->rlim_cur < rlim->rlim_max)



CVS commit: src/doc

2017-08-06 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Aug  6 08:11:39 UTC 2017

Modified Files:
src/doc: CHANGES

Log Message:
Mention high mem.


To generate a diff of this commit:
cvs rdiff -u -r1.2301 -r1.2302 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2301 src/doc/CHANGES:1.2302
--- src/doc/CHANGES:1.2301	Fri Jul 21 01:01:57 2017
+++ src/doc/CHANGES	Sun Aug  6 08:11:38 2017
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2301 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2302 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -30,6 +30,8 @@ Changes from NetBSD 8.0 to NetBSD 9.0:
  		only those attached at pcppi [nat 20170612]
  	bind: Import version 9.10.5-P1. [christos 20170615]
 	dts: Import dts files from Linux 4.11.5. [jmcneill 20170615]
+	amd64: Support 16TB of PA, and 32TB of kernel VA on the architecture
+		side. [maxv 20170617]
 	expat: Import 2.2.1 (security fixes) [christos 20170617]
 	arm: Add support for Allwinner H3 SoC. [jmcneill 20170628]
 	bind: Import version 9.10.5-P2. [christos 20170630]



CVS commit: src/doc

2017-08-06 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Aug  6 08:07:37 UTC 2017

Modified Files:
src/doc: CHANGES.prev

Log Message:
Mention PMCs.


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/doc/CHANGES.prev

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

Modified files:

Index: src/doc/CHANGES.prev
diff -u src/doc/CHANGES.prev:1.133 src/doc/CHANGES.prev:1.134
--- src/doc/CHANGES.prev:1.133	Tue Jun  6 07:13:06 2017
+++ src/doc/CHANGES.prev	Sun Aug  6 08:07:37 2017
@@ -1,4 +1,4 @@
-LIST OF CHANGES FROM PREVIOUS RELEASES:			<$Revision: 1.133 $>
+LIST OF CHANGES FROM PREVIOUS RELEASES:			<$Revision: 1.134 $>
 
 
 Changes from 386bsd 0.1 + patchkit 0.2.2 to NetBSD 0.8:
@@ -12189,6 +12189,8 @@ Changes from NetBSD 7.0 to NetBSD 8.0:
 		OpenBSD/luna88k. [tsutsui 20170309]
 	sqlite3: Import 3.17.0. [christos 20170311]
 	libc: Update to tzcode2017a. [christos 20170311]
+	x86: Revamp the PMC (Performance-Monitoring Counter) support.
+		[maxv 20170311]
 	mdocml: Import 1.14.1. [christos 20170318]
 	sh(1): Arithmetic parser imported from dash (via FreeBSD)
 		adding support for all required operators, as well



CVS commit: src/lib/libarch/i386

2017-08-06 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Aug  6 08:00:40 UTC 2017

Modified Files:
src/lib/libarch/i386: i386_pmc_info.2

Log Message:
Deprecate.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libarch/i386/i386_pmc_info.2

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

Modified files:

Index: src/lib/libarch/i386/i386_pmc_info.2
diff -u src/lib/libarch/i386/i386_pmc_info.2:1.11 src/lib/libarch/i386/i386_pmc_info.2:1.12
--- src/lib/libarch/i386/i386_pmc_info.2:1.11	Wed Apr 30 13:10:50 2008
+++ src/lib/libarch/i386/i386_pmc_info.2	Sun Aug  6 08:00:40 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: i386_pmc_info.2,v 1.11 2008/04/30 13:10:50 martin Exp $
+.\" $NetBSD: i386_pmc_info.2,v 1.12 2017/08/06 08:00:40 maxv Exp $
 .\"
 .\" Copyright (c) 2001 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd November 10, 2001
+.Dd August 6, 2017
 .Dt I386_PMC_INFO 2 i386
 .Os
 .Sh NAME
@@ -48,110 +48,8 @@
 .Ft int
 .Fn i386_pmc_read "struct i386_pmc_read_args *ra"
 .Sh DESCRIPTION
-These functions provide an interface to the CPU performance counters
-on the 586-class and 686-class processors.
-.Pp
-.Fn i386_pmc_info
-will return information about the available CPU counters.
-The information is returned in
-.Fa ia
-having the following structure:
-.Bd -literal
-struct i386_pmc_info_args {
-int type;
-int flags;
-};
-.Ed
-.Pp
-The
-.Em type
-member describes the class of performance counters available.
-Valid values are:
-.Pp
-.Bl -tag -offset indent -width PMC_INFO_HASTSC -compact
-.It PMC_TYPE_NONE
-No PMC support
-.It PMC_TYPE_I586
-586-class CPUs
-.It PMC_TYPE_I686
-686-class Intel CPUs
-.It PMC_TYPE_K7
-686-class AMD CPUs
-.El
-.Pp
-The
-.Em flags
-member describes additional capabilities of the processor.
-Valid values are:
-.Pp
-.Bl -tag -offset indent -width PMC_INFO_HASTSC -compact
-.It PMC_INFO_HASTSC
-CPU has time-stamp counter
-.El
-.Pp
-.Fn i386_pmc_startstop
-is used to start and stop the measurement of the CPU performance counters.
-The argument
-.Fa ssa
-has the following structure:
-.Bd -literal
-struct i386_pmc_startstop_args {
-int counter;
-uint64_t val;
-uint8_t event;
-uint8_t unit;
-uint8_t compare;
-uint8_t flags;
-};
-.Ed
-.Pp
-The counter specified by the member
-.Em counter
-is started if the member
-.Em flags
-has PMC_SETUP_KERNEL or PMC_SETUP_USER set, otherwise the counter is
-stopped.
-The initial value of the counter is set to
-.Em val .
-Additional values for the
-.Em flags
-member are PMC_SETUP_EDGE and PMC_SETUP_INV.
-The
-.Em event
-member specifies some event written to the control register.
-The
-.Em unit
-member specifies the measurement units.
-The
-.Em compare
-member is a mask for the counter.
-.Pp
-.Fn i386_pmc_read
-will return information about a specific CPU counter measured during
-the last measurement period determined by the calling of
-.Fn i386_pmc_startstop .
-The information is returned in
-.Fa ra
-having the following structure:
-.Bd -literal
-struct i386_pmc_read_args {
-int counter;
-uint64_t val;
-uint64_t time;
-};
-.Ed
-.Pp
-The counter to read should be specified by the
-.Em counter
-member.
-Counters are numbered from 0 to
-.Dv PMC_NCOUNTERS .
-The value of the counter is returned in the
-.Em val
-member.
-The time since epoch, measured in CPU clock cycles, is returned in the
-.Em time
-member.
+These functions used to provide an interface to the CPU performance counters.
+They are now deprecated, and always fail.
 .Sh RETURN VALUES
 Upon successful completion zero is returned, otherwise \-1 is returned
 on failure.