CVS commit: src/sys/dev

2017-08-07 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Aug  8 05:58:12 UTC 2017

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

Log Message:
Remove dead codes. chan will never be NULL in SIMPLEQ_FOREACH.


To generate a diff of this commit:
cvs rdiff -u -r1.390 -r1.391 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.390 src/sys/dev/audio.c:1.391
--- src/sys/dev/audio.c:1.390	Tue Aug  8 05:54:14 2017
+++ src/sys/dev/audio.c	Tue Aug  8 05:58:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.390 2017/08/08 05:54:14 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.391 2017/08/08 05:58:12 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss 
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.390 2017/08/08 05:54:14 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.391 2017/08/08 05:58:12 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -927,9 +927,6 @@ audiodetach(device_t self, int flags)
 
 	/* free resources */
 	SIMPLEQ_FOREACH(chan, >sc_audiochan, entries) {
-		if (chan == NULL)
-			break;
-
 		if (chan->chan == MIXER_INUSE)
 			continue;
 		audio_free_ring(sc, >vc->sc_mpr);
@@ -938,9 +935,6 @@ audiodetach(device_t self, int flags)
 	audio_free_ring(sc, >sc_pr);
 	audio_free_ring(sc, >sc_rr);
 	SIMPLEQ_FOREACH(chan, >sc_audiochan, entries) {
-		if (chan == NULL)
-			break;
-
 		if (chan->chan == MIXER_INUSE)
 			continue;
 		audio_destroy_pfilters(chan->vc);
@@ -3710,9 +3704,6 @@ audio_mix(void *v)
 		if (!sc->sc_opens)
 			break;		/* ignore interrupt if not open */
 
-		if (chan == NULL)
-			break;
-
 		if (chan == SIMPLEQ_FIRST(>sc_audiochan))
 			continue;
 
@@ -3927,9 +3918,6 @@ audio_upmix(void *v)
 		if (!sc->sc_opens)
 			break;		/* ignore interrupt if not open */
 
-		if (chan == NULL)
-			break;
-
 		if (chan == SIMPLEQ_FIRST(>sc_audiochan))
 			continue;
 



CVS commit: src/sys/dev

2017-08-07 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Aug  8 05:54:14 UTC 2017

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

Log Message:
Introduce audio_destroy_pfilters()/audio_destroy_rfilters()
and use it.


To generate a diff of this commit:
cvs rdiff -u -r1.389 -r1.390 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.389 src/sys/dev/audio.c:1.390
--- src/sys/dev/audio.c:1.389	Tue Aug  8 05:46:23 2017
+++ src/sys/dev/audio.c	Tue Aug  8 05:54:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.389 2017/08/08 05:46:23 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.390 2017/08/08 05:54:14 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss 
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.389 2017/08/08 05:46:23 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.390 2017/08/08 05:54:14 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -298,6 +298,8 @@ static int audio_setup_pfilters(struct a
 			  stream_filter_list_t *, struct virtual_channel *);
 static int audio_setup_rfilters(struct audio_softc *, const audio_params_t *,
 			  stream_filter_list_t *, struct virtual_channel *);
+static void audio_destroy_pfilters(struct virtual_channel *);
+static void audio_destroy_rfilters(struct virtual_channel *);
 static void audio_stream_dtor(audio_stream_t *);
 static int audio_stream_ctor(audio_stream_t *, const audio_params_t *, int);
 static void stream_filter_list_append(stream_filter_list_t *,
@@ -864,7 +866,7 @@ audiodetach(device_t self, int flags)
 {
 	struct audio_softc *sc;
 	struct audio_chan *chan;
-	int maj, mn, i, rc;
+	int maj, mn, rc;
 
 	sc = device_private(self);
 	DPRINTF(("audio_detach: sc=%p flags=%d\n", sc, flags));
@@ -941,21 +943,8 @@ audiodetach(device_t self, int flags)
 
 		if (chan->chan == MIXER_INUSE)
 			continue;
-		for (i = 0; i < chan->vc->sc_npfilters; i++) {
-			chan->vc->sc_pfilters[i]->dtor
-			(chan->vc->sc_pfilters[i]);
-			chan->vc->sc_pfilters[i] = NULL;
-			audio_stream_dtor(>vc->sc_pstreams[i]);
-		}
-		chan->vc->sc_npfilters = 0;
-
-		for (i = 0; i < chan->vc->sc_nrfilters; i++) {
-			chan->vc->sc_rfilters[i]->dtor
-			(chan->vc->sc_rfilters[i]);
-			chan->vc->sc_rfilters[i] = NULL;
-			audio_stream_dtor(>vc->sc_rstreams[i]);
-		}
-		chan->vc->sc_nrfilters = 0;
+		audio_destroy_pfilters(chan->vc);
+		audio_destroy_rfilters(chan->vc);
 	}
 
 	auconv_delete_encodings(sc->sc_encodings);
@@ -1451,6 +1440,32 @@ audio_setup_rfilters(struct audio_softc 
 }
 
 static void
+audio_destroy_pfilters(struct virtual_channel *vc)
+{
+	int i;
+
+	for (i = 0; i < vc->sc_npfilters; i++) {
+		vc->sc_pfilters[i]->dtor(vc->sc_pfilters[i]);
+		vc->sc_pfilters[i] = NULL;
+		audio_stream_dtor(>sc_pstreams[i]);
+	}
+	vc->sc_npfilters = 0;
+}
+
+static void
+audio_destroy_rfilters(struct virtual_channel *vc)
+{
+	int i;
+
+	for (i = 0; i < vc->sc_nrfilters; i++) {
+		vc->sc_rfilters[i]->dtor(vc->sc_rfilters[i]);
+		vc->sc_rfilters[i] = NULL;
+		audio_stream_dtor(>sc_pstreams[i]);
+	}
+	vc->sc_nrfilters = 0;
+}
+
+static void
 audio_stream_dtor(audio_stream_t *stream)
 {
 
@@ -2113,7 +2128,7 @@ audio_open(dev_t dev, struct audio_softc
 struct lwp *l, struct file **nfp)
 {
 	struct file *fp;
-	int error, fd, i, n;
+	int error, fd, n;
 	u_int mode;
 	const struct audio_hw_if *hw;
 	struct virtual_channel *vc;
@@ -2273,18 +2288,8 @@ audio_open(dev_t dev, struct audio_softc
 	return error;
 
 bad:
-	for (i = 0; i < vc->sc_npfilters; i++) {
-		vc->sc_pfilters[i]->dtor(vc->sc_pfilters[i]);
-		vc->sc_pfilters[i] = NULL;
-		audio_stream_dtor(>sc_pstreams[i]);
-	}
-	vc->sc_npfilters = 0;
-	for (i = 0; i < vc->sc_nrfilters; i++) {
-		vc->sc_rfilters[i]->dtor(vc->sc_rfilters[i]);
-		vc->sc_rfilters[i] = NULL;
-		audio_stream_dtor(>sc_rstreams[i]);
-	}
-	vc->sc_nrfilters = 0;
+	audio_destroy_pfilters(vc);
+	audio_destroy_rfilters(vc);
 	if (hw->close != NULL && sc->sc_opens == 0)
 		hw->close(sc->hw_hdl);
 	mutex_exit(sc->sc_lock);
@@ -2432,7 +2437,6 @@ audio_close(struct audio_softc *sc, int 
 {
 	struct virtual_channel *vc;
 	const struct audio_hw_if *hw;
-	int o;
 
 	KASSERT(mutex_owned(sc->sc_lock));
 	
@@ -2493,19 +2497,9 @@ audio_close(struct audio_softc *sc, int 
 	vc->sc_open = 0;
 	vc->sc_mode = 0;
 	vc->sc_full_duplex = 0;
-	
-	for (o = 0; o < vc->sc_npfilters; o++) {
-		vc->sc_pfilters[o]->dtor(vc->sc_pfilters[o]);
-		vc->sc_pfilters[o] = NULL;
-		audio_stream_dtor(>sc_pstreams[o]);
-	}
-	vc->sc_npfilters = 0;
-	for (o = 0; o < vc->sc_nrfilters; o++) {
-		vc->sc_rfilters[o]->dtor(vc->sc_rfilters[o]);
-		vc->sc_rfilters[o] = NULL;
-		audio_stream_dtor(>sc_rstreams[o]);
-	}
-	vc->sc_nrfilters = 0;
+
+	audio_destroy_pfilters(vc);
+	audio_destroy_rfilters(vc);
 
 	if (flags & FREAD)
 		sc->sc_recopens--;



CVS commit: src/sys/dev

2017-08-07 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Aug  8 05:46:23 UTC 2017

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

Log Message:
Add missing initialization of sc_rfilters in audioattach().


To generate a diff of this commit:
cvs rdiff -u -r1.388 -r1.389 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.388 src/sys/dev/audio.c:1.389
--- src/sys/dev/audio.c:1.388	Tue Aug  8 05:42:30 2017
+++ src/sys/dev/audio.c	Tue Aug  8 05:46:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.388 2017/08/08 05:42:30 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.389 2017/08/08 05:46:23 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss 
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.388 2017/08/08 05:42:30 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.389 2017/08/08 05:46:23 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -523,8 +523,9 @@ audioattach(device_t parent, device_t se
 	vc->sc_open = 0;
 	vc->sc_mode = 0;
 	vc->sc_npfilters = 0;
-	memset(vc->sc_pfilters, 0,
-	sizeof(vc->sc_pfilters));
+	vc->sc_nrfilters = 0;
+	memset(vc->sc_pfilters, 0, sizeof(vc->sc_pfilters));
+	memset(vc->sc_rfilters, 0, sizeof(vc->sc_rfilters));
 	vc->sc_lastinfovalid = false;
 	vc->sc_swvol = 255;
 	vc->sc_recswvol = 255;



CVS commit: src/sys/dev

2017-08-07 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Aug  8 05:42:31 UTC 2017

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

Log Message:
Remove a duplicated line.


To generate a diff of this commit:
cvs rdiff -u -r1.387 -r1.388 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.387 src/sys/dev/audio.c:1.388
--- src/sys/dev/audio.c:1.387	Sun Aug  6 10:07:31 2017
+++ src/sys/dev/audio.c	Tue Aug  8 05:42:30 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.387 2017/08/06 10:07:31 nat Exp $	*/
+/*	$NetBSD: audio.c,v 1.388 2017/08/08 05:42:30 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss 
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.387 2017/08/06 10:07:31 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.388 2017/08/08 05:42:30 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -1816,7 +1816,6 @@ audioioctl(struct file *fp, u_long cmd, 
 
 	if ((error = audio_enter(dev, rw, )) != 0)
 		return error;
-	chan = fp->f_audioctx;
 
 	switch (AUDIODEV(dev)) {
 	case SOUND_DEVICE:



CVS commit: src/sys/netipsec

2017-08-07 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Aug  8 04:17:34 UTC 2017

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

Log Message:
MP-ify SAD (key_sad.sahlist and sah entries)

localcount(9) is used to protect key_sad.sahlist and sah entries
as well as SPD (and will be used for SAD sav).

Please read the locking notes of SAD for more details.


To generate a diff of this commit:
cvs rdiff -u -r1.215 -r1.216 src/sys/netipsec/key.c
cvs rdiff -u -r1.18 -r1.19 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.215 src/sys/netipsec/key.c:1.216
--- src/sys/netipsec/key.c:1.215	Tue Aug  8 01:56:49 2017
+++ src/sys/netipsec/key.c	Tue Aug  8 04:17:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.215 2017/08/08 01:56:49 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.216 2017/08/08 04:17:34 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.215 2017/08/08 01:56:49 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.216 2017/08/08 04:17:34 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -198,12 +198,35 @@ static u_int32_t acq_seq = 0;
  * until GC by the timer
  */
 /*
+ * Locking notes on SAD:
+ * - Data structures
+ *   - SAs are managed by the list called key_sad.sahlist and sav lists of sah
+ * entries
+ *   - A sah has sav lists for each SA state
+ *   - Multiple sahs with the same saidx can exist
+ * - Only one entry has MATURE state and others should be DEAD
+ * - DEAD entries are just ignored from searching
+ * - Modifications to the key_sad.sahlist must be done with holding key_sad.lock
+ *   which is a adaptive mutex
+ * - Read accesses to the key_sad.sahlist must be in pserialize(9) read sections
+ * - sah's lifetime is managed by localcount(9)
+ * - Getting an sah entry
+ *   - We get an SP from the key_spd.splist
+ * - Must iterate the list and increment the reference count of a found sah
+ *   (by key_sah_ref) in a pserialize read section
+ *   - A gotten sah must be released after use by key_sah_unref
+ * - An sah is destroyed when its state become DEAD and no sav is
+ *   listed to the sah
+ *   - The destruction is done only in the timer (see key_timehandler_sad)
+ */
+/*
  * 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 __read_mostly;
+static pserialize_t key_spd_psz __read_mostly;
+static pserialize_t key_sad_psz __read_mostly;
 
 /* SPD */
 static struct {
@@ -220,6 +243,7 @@ static struct {
 /* SAD */
 static struct {
 	kmutex_t lock;
+	kcondvar_t cv;
 	struct pslist_head sahlist;
 } key_sad __cacheline_aligned;
 
@@ -614,13 +638,18 @@ static struct mbuf *key_setdumpsp (struc
 static u_int key_getspreqmsglen (const struct secpolicy *);
 static int key_spdexpire (struct secpolicy *);
 static struct secashead *key_newsah (const struct secasindex *);
-static void key_delsah (struct secashead *);
+static void key_unlink_sah(struct secashead *);
+static void key_destroy_sah(struct secashead *);
+static bool key_sah_has_sav(struct secashead *);
+static void key_sah_ref(struct secashead *);
+static void key_sah_unref(struct secashead *);
 static struct secasvar *key_newsav(struct mbuf *,
 	const struct sadb_msghdr *, int *, const char*, int);
 #define	KEY_NEWSAV(m, sadb, e)\
 	key_newsav(m, sadb, e, __func__, __LINE__)
 static void key_delsav (struct secasvar *);
 static struct secashead *key_getsah(const struct secasindex *, int);
+static struct secashead *key_getsah_ref(const struct secasindex *, int);
 static bool key_checkspidup(const struct secasindex *, u_int32_t);
 static struct secasvar *key_getsavbyspi (struct secashead *, u_int32_t);
 static int key_setsaval (struct secasvar *, struct mbuf *,
@@ -800,7 +829,7 @@ key_unlink_sp(struct secpolicy *sp)
 
 #ifdef NET_MPSAFE
 	KASSERT(mutex_ownable(softnet_lock));
-	pserialize_perform(key_psz);
+	pserialize_perform(key_spd_psz);
 #endif
 
 	localcount_drain(>localcount, _spd.cv, _spd.lock);
@@ -2954,9 +2983,13 @@ key_newsah(const struct secasindex *said
 		PSLIST_INIT(>savlist[i]);
 	newsah->saidx = *saidx;
 
-	/* add to saidxtree */
-	newsah->state = SADB_SASTATE_MATURE;
+	localcount_init(>localcount);
+	/* Take a reference for the caller */
+	localcount_acquire(>localcount);
+
+	/* Add to the sah list */
 	SAHLIST_ENTRY_INIT(newsah);
+	newsah->state = SADB_SASTATE_MATURE;
 	mutex_enter(_sad.lock);
 	SAHLIST_WRITER_INSERT_HEAD(newsah);
 	mutex_exit(_sad.lock);
@@ -2964,51 +2997,55 @@ key_newsah(const struct secasindex *said
 	return newsah;
 }
 
-/*
- * delete SA index and all SA registerd.
- */
-static void

CVS commit: src/share/man/man3

2017-08-07 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Aug  8 03:58:43 UTC 2017

Modified Files:
src/share/man/man3: queue.3

Log Message:
s/tail queue/simple queue/ in SIMPLE QUEUES section.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/share/man/man3/queue.3

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/man3/queue.3
diff -u src/share/man/man3/queue.3:1.57 src/share/man/man3/queue.3:1.58
--- src/share/man/man3/queue.3:1.57	Mon Jul  3 21:30:58 2017
+++ src/share/man/man3/queue.3	Tue Aug  8 03:58:43 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: queue.3,v 1.57 2017/07/03 21:30:58 wiz Exp $
+.\"	$NetBSD: queue.3,v 1.58 2017/08/08 03:58:43 isaki Exp $
 .\"
 .\" Copyright (c) 2000, 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -764,13 +764,13 @@ returns the element after the element
 .Pp
 The macro
 .Fn SIMPLEQ_LAST
-returns the last item on the tail queue.
-If the tail queue is empty the return value is
+returns the last item on the simple queue.
+If the simple queue is empty the return value is
 .Dv NULL .
 .Pp
 The macro
 .Fn SIMPLEQ_FOREACH
-traverses the tail queue referenced by
+traverses the simple queue referenced by
 .Fa head
 in the forward direction, assigning each element
 in turn to
@@ -832,7 +832,7 @@ from the simple queue.
 .Pp
 The macro
 .Fn SIMPLEQ_CONCAT
-concatenates the tail queue headed by
+concatenates the simple queue headed by
 .Fa head2
 onto the end of the one headed by
 .Fa head1 ,



CVS commit: src/sys/net

2017-08-07 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Tue Aug  8 03:14:50 UTC 2017

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

Log Message:
fix leak when encap_attach() fails twice.

XXX need pullup to -8 branch


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sys/net/if_gif.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/if_gif.c
diff -u src/sys/net/if_gif.c:1.127 src/sys/net/if_gif.c:1.128
--- src/sys/net/if_gif.c:1.127	Thu Jun 22 09:26:43 2017
+++ src/sys/net/if_gif.c	Tue Aug  8 03:14:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_gif.c,v 1.127 2017/06/22 09:26:43 knakahara Exp $	*/
+/*	$NetBSD: if_gif.c,v 1.128 2017/08/08 03:14:50 knakahara Exp $	*/
 /*	$KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.127 2017/06/22 09:26:43 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.128 2017/08/08 03:14:50 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -997,31 +997,34 @@ gif_set_tunnel(struct ifnet *ifp, struct
 
 	/*
 	 * Secondly, try to set new configurations.
-	 * If the setup failed, rollback to old configurations.
 	 */
-	do {
-		osrc = sc->gif_psrc;
-		odst = sc->gif_pdst;
-		sc->gif_psrc = nsrc;
-		sc->gif_pdst = ndst;
-
+	osrc = sc->gif_psrc;
+	odst = sc->gif_pdst;
+	sc->gif_psrc = nsrc;
+	sc->gif_pdst = ndst;
+	error = gif_encap_attach(sc);
+	if (error && osrc != NULL && odst != NULL) {
+		/*
+		 * Thirdly, when error occured, rollback to old configurations,
+		 * if last setting is valid.
+		 */
+		sc->gif_psrc = osrc;
+		sc->gif_pdst = odst;
+		osrc = nsrc; /* to free */
+		odst = ndst; /* to free */
 		error = gif_encap_attach(sc);
-		if (error) {
-			/* rollback to the last configuration. */
-			nsrc = osrc;
-			ndst = odst;
-			osrc = sc->gif_psrc;
-			odst = sc->gif_pdst;
-
-			continue;
-		}
-	} while (error != 0 && (nsrc != NULL && ndst != NULL));
-	/* Thirdly, even rollback failed, clear configurations. */
+	}
 	if (error) {
-		osrc = sc->gif_psrc;
-		odst = sc->gif_pdst;
+		/*
+		 * Fourthly, even rollback failed or last setting is not valid,
+		 * clear configurations.
+		 */
+		osrc = sc->gif_psrc; /* to free */
+		odst = sc->gif_pdst; /* to free */
 		sc->gif_psrc = NULL;
 		sc->gif_pdst = NULL;
+		sockaddr_free(nsrc);
+		sockaddr_free(ndst);
 	}
 
 	if (osrc)



CVS commit: src/tests/net/ipsec

2017-08-07 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Aug  8 02:27:03 UTC 2017

Modified Files:
src/tests/net/ipsec: common.sh

Log Message:
Fix setkey -D -P outputs

The outputs were tweaked (by me), but I forgot updating libipsec
in my local ATF environment...


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/net/ipsec/common.sh

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

Modified files:

Index: src/tests/net/ipsec/common.sh
diff -u src/tests/net/ipsec/common.sh:1.5 src/tests/net/ipsec/common.sh:1.6
--- src/tests/net/ipsec/common.sh:1.5	Wed Aug  2 06:30:00 2017
+++ src/tests/net/ipsec/common.sh	Tue Aug  8 02:27:03 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: common.sh,v 1.5 2017/08/02 06:30:00 ozaki-r Exp $
+#	$NetBSD: common.sh,v 1.6 2017/08/08 02:27:03 ozaki-r Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -65,7 +65,7 @@ check_sp_entries()
 	$DEBUG && $HIJACKING setkey -D -P
 
 	atf_check -s exit:0 \
-	-o match:"$local_addr\[any\] $remote_addr\[any\] reserved" \
+	-o match:"$local_addr\[any\] $remote_addr\[any\] 255\(reserved\)" \
 	$HIJACKING setkey -D -P
 	# TODO: more detail checks
 }



CVS commit: src/sys/netipsec

2017-08-07 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Aug  8 01:56:49 UTC 2017

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

Log Message:
Add missing mutex_exit


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 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.214 src/sys/netipsec/key.c:1.215
--- src/sys/netipsec/key.c:1.214	Tue Aug  8 01:56:10 2017
+++ src/sys/netipsec/key.c	Tue Aug  8 01:56:49 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.214 2017/08/08 01:56:10 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.215 2017/08/08 01:56:49 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.214 2017/08/08 01:56:10 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.215 2017/08/08 01:56:49 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -6373,8 +6373,10 @@ key_acquire(const struct secasindex *sai
 	} else {
 		/* make new entry for blocking to send SADB_ACQUIRE. */
 		newacq = key_newacq(saidx);
-		if (newacq == NULL)
+		if (newacq == NULL) {
+			mutex_exit(_misc.lock);
 			return ENOBUFS;
+		}
 
 		/* add to key_misc.acqlist */
 		LIST_INSERT_HEAD(_misc.acqlist, newacq, chain);



CVS commit: src/sys/netipsec

2017-08-07 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Aug  8 01:56:10 UTC 2017

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

Log Message:
Tweak wording (pserialize critical section => pserialize read section)

Suggested by riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.213 -r1.214 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.213 src/sys/netipsec/key.c:1.214
--- src/sys/netipsec/key.c:1.213	Tue Aug  8 01:55:17 2017
+++ src/sys/netipsec/key.c	Tue Aug  8 01:56:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.213 2017/08/08 01:55:17 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.214 2017/08/08 01:56:10 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.213 2017/08/08 01:55:17 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.214 2017/08/08 01:56:10 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -156,8 +156,7 @@ 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
  *   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 pserialize(9) read sections
  * - 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
@@ -167,9 +166,9 @@ static u_int32_t acq_seq = 0;
  * - Getting an 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
+ *   (by key_sp_ref) in a pserialize read 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
+ * and take its reference in a pserialize read section
  * (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)
@@ -186,7 +185,7 @@ static u_int32_t acq_seq = 0;
  * is considered invalidated
  *   - The counter is incremented when an SP is being destroyed
  *   - So checking the generation and taking a reference to an SP should be
- * in a critical section of pserialize
+ * in a pserialize read section
  *   - Note that caching doesn't increment the reference counter of an SP
  * - SPs in sockets
  *   - Userland programs can set a policy to a socket by
@@ -1310,7 +1309,7 @@ key_init_sp(struct secpolicy *sp)
 }
 
 /*
- * Must be called in a pserialize critical section. A held SP
+ * Must be called in a pserialize read section. A held SP
  * must be released by key_sp_unref after use.
  */
 void



CVS commit: src/sys/netipsec

2017-08-07 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Aug  8 01:55:17 UTC 2017

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

Log Message:
Add __read_mostly to key_psz

Suggested by riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 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.212 src/sys/netipsec/key.c:1.213
--- src/sys/netipsec/key.c:1.212	Mon Aug  7 07:45:45 2017
+++ src/sys/netipsec/key.c	Tue Aug  8 01:55:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.212 2017/08/07 07:45:45 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.213 2017/08/08 01:55:17 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.212 2017/08/07 07:45:45 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.213 2017/08/08 01:55:17 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -204,7 +204,7 @@ static u_int32_t acq_seq = 0;
  *   - key_misc.lock must be held even for read accesses
  */
 
-static pserialize_t key_psz;
+static pserialize_t key_psz __read_mostly;
 
 /* SPD */
 static struct {



CVS commit: src/sys/dev/hpc

2017-08-07 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Aug  7 23:57:40 UTC 2017

Modified Files:
src/sys/dev/hpc: hpckbd.c

Log Message:
XXX: On hpcsh only - bring back old incorrect hpckbd_keymap_setup()
fixed in 1.31.  The old one with UNCONST does work on hpcsh b/c the
kernel is directly mapped.  The new one does not work on hpcsh b/c it
calls consinit() very early when malloc() is not yet available.

The real fix for this is to fix the constness of wscons keymap
structures that is self-contradictory.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/hpc/hpckbd.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/hpc/hpckbd.c
diff -u src/sys/dev/hpc/hpckbd.c:1.31 src/sys/dev/hpc/hpckbd.c:1.32
--- src/sys/dev/hpc/hpckbd.c:1.31	Mon Jun 12 09:23:39 2017
+++ src/sys/dev/hpc/hpckbd.c	Mon Aug  7 23:57:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpckbd.c,v 1.31 2017/06/12 09:23:39 manu Exp $ */
+/*	$NetBSD: hpckbd.c,v 1.32 2017/08/07 23:57:40 uwe Exp $ */
 
 /*-
  * Copyright (c) 1999-2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.31 2017/06/12 09:23:39 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.32 2017/08/07 23:57:40 uwe Exp $");
 
 #include 
 #include 
@@ -260,6 +260,40 @@ hpckbd_getevent(struct hpckbd_core* hc, 
 	return (1);
 }
 
+
+#ifdef hpcsh
+/*
+ * XXX: Use the old wrong code for now as hpcsh attaches console very
+ * early and it's convenient to be able to do early DDB on wscons.
+ */
+void
+hpckbd_keymap_setup(struct hpckbd_core *hc,
+		const keysym_t *map, int mapsize)
+{
+	int i;
+	struct wscons_keydesc *desc;
+
+	/* fix keydesc table */
+	/* 
+	 * XXX The way this is done is really wrong.  The __UNCONST()
+	 * is a hint as to what is wrong.  This actually ends up modifying
+	 * initialized data which is marked "const".
+	 * The reason we get away with it here is that on sh3 kernel
+	 * is directly mapped.
+	 */
+	desc = (struct wscons_keydesc *)__UNCONST(hpckbd_keymapdata.keydesc);
+	for (i = 0; desc[i].name != 0; i++) {
+		if ((desc[i].name & KB_MACHDEP) && desc[i].map == NULL) {
+			desc[i].map = map;
+			desc[i].map_size = mapsize;
+		}
+	}
+
+	return;
+}
+
+#else
+
 void
 hpckbd_keymap_setup(struct hpckbd_core *hc,
 		const keysym_t *map, int mapsize)
@@ -294,6 +328,7 @@ hpckbd_keymap_setup(struct hpckbd_core *
 
 	return;
 }
+#endif
 
 void
 hpckbd_keymap_lookup(struct hpckbd_core *hc)



CVS commit: src/sys/arch/hpcsh/dev

2017-08-07 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Aug  7 23:42:11 UTC 2017

Modified Files:
src/sys/arch/hpcsh/dev: pfckbd.c

Log Message:
Don't reschedule the callout in the scanning function itself, as that
conflicts with using the same function for polled console.

Makes early ddb work with wscons console again on my Jornada 690.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/hpcsh/dev/pfckbd.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/hpcsh/dev/pfckbd.c
diff -u src/sys/arch/hpcsh/dev/pfckbd.c:1.29 src/sys/arch/hpcsh/dev/pfckbd.c:1.30
--- src/sys/arch/hpcsh/dev/pfckbd.c:1.29	Sun Feb 12 16:34:08 2012
+++ src/sys/arch/hpcsh/dev/pfckbd.c	Mon Aug  7 23:42:11 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pfckbd.c,v 1.29 2012/02/12 16:34:08 matt Exp $	*/
+/*	$NetBSD: pfckbd.c,v 1.30 2017/08/07 23:42:11 uwe Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  * currently, HP Jornada 680/690, HITACHI PERSONA HPW-50PAD only.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pfckbd.c,v 1.29 2012/02/12 16:34:08 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pfckbd.c,v 1.30 2017/08/07 23:42:11 uwe Exp $");
 
 #include "debug_hpcsh.h"
 
@@ -66,7 +66,7 @@ static struct pfckbd_core {
 	struct hpckbd_ic_if pc_if;
 	struct hpckbd_if *pc_hpckbd;
 	uint16_t pc_column[8];
-	void (*pc_callout)(void *);
+	void (*pc_callout)(struct pfckbd_core *);
 } pfckbd_core;
 
 static int pfckbd_match(device_t, cfdata_t, void *);
@@ -83,17 +83,17 @@ static int pfckbd_poll(void *);
 
 static void pfckbd_input(struct pfckbd_core *, int, uint16_t);
 
-static void (*pfckbd_callout_lookup(void))(void *);
-static void pfckbd_callout_unknown(void *);
-static void pfckbd_callout_hp(void *);
-static void pfckbd_callout_hitachi(void *);
+static void (*pfckbd_callout_lookup(void))(struct pfckbd_core *);
+static void pfckbd_callout(void *);
+static void pfckbd_callout_hp(struct pfckbd_core *);
+static void pfckbd_callout_hitachi(struct pfckbd_core *);
 void pfckbd_poll_hitachi_power(void);
 
 
 /* callout function table. this function is platfrom specific. */
 static const struct {
 	platid_mask_t *platform;
-	void (*func)(void *);
+	void (*func)(struct pfckbd_core *);
 } pfckbd_calloutfunc_table[] = {
 	{ _mask_MACH_HP		, pfckbd_callout_hp },
 	{ _mask_MACH_HITACHI	, pfckbd_callout_hitachi }
@@ -144,9 +144,13 @@ pfckbd_attach(device_t parent, device_t 
 	config_found(self, , hpckbd_print);
 
 	/* install callout handler */
-	callout_init(_core.pc_soft_ch, 0);
-	callout_reset(_core.pc_soft_ch, 1,
-		  pfckbd_core.pc_callout, _core);
+	if (pfckbd_core.pc_callout != NULL) {
+		callout_init(_core.pc_soft_ch, 0);
+		callout_reset(_core.pc_soft_ch, 1,
+			  pfckbd_callout, _core);
+	}
+	else
+		aprint_error_dev(self, "unsupported platform\n");
 
 	if (!pmf_device_register(self, NULL, NULL))
 		aprint_error_dev(self, "unable to establish power handler\n");
@@ -191,12 +195,22 @@ pfckbd_poll(void *ic)
 {
 	struct pfckbd_core *pc = ic;
 
-	if (pc->pc_enabled)
+	if (pc->pc_enabled && pc->pc_callout != NULL)
 		(*pc->pc_callout)(pc);
 
 	return 0;
 }
 
+static void
+pfckbd_callout(void *arg)
+{
+	struct pfckbd_core *pc = arg;
+
+	(*pc->pc_callout)(pc);
+	callout_schedule(>pc_soft_ch, 1);
+}
+
+
 /*
  * Called by platform specific scan routines to report key events to hpckbd
  */
@@ -230,7 +244,7 @@ pfckbd_input(struct pfckbd_core *pc, int
 
 /* Look up appropriate callback handler */
 static void
-(*pfckbd_callout_lookup(void))(void *)
+(*pfckbd_callout_lookup(void))(struct pfckbd_core *)
 {
 	int i, n;
 
@@ -242,22 +256,14 @@ static void
  pfckbd_calloutfunc_table[i].platform))
 			return pfckbd_calloutfunc_table[i].func;
 
-	return pfckbd_callout_unknown;
-}
-
-/* Placeholder for unknown platform */
-static void
-pfckbd_callout_unknown(void *arg)
-{
-
-	printf("%s: unknown keyboard switch\n", __func__);
+	return NULL;
 }
 
 /*
  * HP Jornada680/690, HP620LX
  */
 static void
-pfckbd_callout_hp(void *arg)
+pfckbd_callout_hp(struct pfckbd_core *pc)
 {
 #define PFCKBD_HP_PDCR_MASK 0xcc0c
 #define PFCKBD_HP_PECR_MASK 0xf0cf
@@ -288,13 +294,12 @@ pfckbd_callout_hp(void *arg)
 #undef PD
 #undef PE
 
-	struct pfckbd_core *pc = arg;
 	uint16_t dc, ec;
 	int column;
 	uint16_t data;
 
 	if (!pc->pc_enabled)
-		goto reinstall;
+		return;
 
 	/* bits in D/E control regs we do not touch (XXX: can they change?) */
 	dc = _reg_read_2(SH7709_PDCR) & ~PFCKBD_HP_PDCR_MASK;
@@ -330,16 +335,13 @@ pfckbd_callout_hp(void *arg)
 	/* (ignore) extra keys/events (recorder buttons, lid, cable ) */
 	data = _reg_read_1(SH7709_PGDR) | (_reg_read_1(SH7709_PHDR) << 8);
 #endif
-
- reinstall:
-	callout_schedule(>pc_soft_ch, 1);
 }
 
 /*
  * HITACH PERSONA (HPW-50PAD)
  */
 static void
-pfckbd_callout_hitachi(void *arg)
+pfckbd_callout_hitachi(struct pfckbd_core *pc)
 {
 #define PFCKBD_HITACHI_PCCR_MASK 

CVS commit: src/sbin/shutdown

2017-08-07 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Aug  7 22:08:12 UTC 2017

Modified Files:
src/sbin/shutdown: shutdown.c

Log Message:
Use NULL instead of 0 for null pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sbin/shutdown/shutdown.c

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

Modified files:

Index: src/sbin/shutdown/shutdown.c
diff -u src/sbin/shutdown/shutdown.c:1.56 src/sbin/shutdown/shutdown.c:1.57
--- src/sbin/shutdown/shutdown.c:1.56	Fri Mar 28 18:27:14 2014
+++ src/sbin/shutdown/shutdown.c	Mon Aug  7 22:08:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: shutdown.c,v 1.56 2014/03/28 18:27:14 apb Exp $	*/
+/*	$NetBSD: shutdown.c,v 1.57 2017/08/07 22:08:12 uwe Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)shutdown.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: shutdown.c,v 1.56 2014/03/28 18:27:14 apb Exp $");
+__RCSID("$NetBSD: shutdown.c,v 1.57 2017/08/07 22:08:12 uwe Exp $");
 #endif
 #endif /* not lint */
 
@@ -409,7 +409,7 @@ die_you_gravy_sucking_pig_dog(void)
 		*arg++ = "-l";
 		if (bootstr)
 			*arg++ = bootstr;
-		*arg++ = 0;
+		*arg++ = NULL;
 #ifndef DEBUG
 		(void)unlink(_PATH_NOLOGIN);
 		(void)execve(path, __UNCONST(args), NULL);



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

2017-08-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Aug  7 21:50:34 UTC 2017

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

Log Message:
h3_codec_pr_write: clear write mode bit after setting it; fixes an issue with 
output being mutex when skipping tracks in mpg123


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sun8i_h3_codec.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_codec.c
diff -u src/sys/arch/arm/sunxi/sun8i_h3_codec.c:1.1 src/sys/arch/arm/sunxi/sun8i_h3_codec.c:1.2
--- src/sys/arch/arm/sunxi/sun8i_h3_codec.c:1.1	Sun Aug  6 17:15:45 2017
+++ src/sys/arch/arm/sunxi/sun8i_h3_codec.c	Mon Aug  7 21:50:34 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: sun8i_h3_codec.c,v 1.1 2017/08/06 17:15:45 jmcneill Exp $ */
+/* $NetBSD: sun8i_h3_codec.c,v 1.2 2017/08/07 21:50:34 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun8i_h3_codec.c,v 1.1 2017/08/06 17:15:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun8i_h3_codec.c,v 1.2 2017/08/07 21:50:34 jmcneill Exp $");
 
 #include 
 #include 
@@ -194,6 +194,10 @@ h3_codec_pr_write(struct h3_codec_softc 
 	/* Write mode */
 	val |= H3_AC_PR_RW;
 	WR4(csc, H3_PR_CFG, val);
+
+	/* Clear write mode */
+	val &= ~H3_AC_PR_RW;
+	WR4(csc, H3_PR_CFG, val);
 }
 
 static void



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

2017-08-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Aug  7 17:31:11 UTC 2017

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

Log Message:
Fix GCC warning on NET4501, PR/52451.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x86/x86/pmc.c

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

Modified files:

Index: src/sys/arch/x86/x86/pmc.c
diff -u src/sys/arch/x86/x86/pmc.c:1.10 src/sys/arch/x86/x86/pmc.c:1.11
--- src/sys/arch/x86/x86/pmc.c:1.10	Wed Jul 12 17:33:29 2017
+++ src/sys/arch/x86/x86/pmc.c	Mon Aug  7 17:31:11 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmc.c,v 1.10 2017/07/12 17:33:29 maxv Exp $	*/
+/*	$NetBSD: pmc.c,v 1.11 2017/08/07 17:31:11 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmc.c,v 1.10 2017/07/12 17:33:29 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmc.c,v 1.11 2017/08/07 17:31:11 maxv Exp $");
 
 #include "opt_pmc.h"
 
@@ -138,7 +138,7 @@ static int
 pmc_nmi(const struct trapframe *tf, void *dummy)
 {
 	struct cpu_info *ci = curcpu();
-	pmc_state_t *pmc;
+	pmc_state_t *pmc = NULL;
 	pmc_cpu_t *cpu;
 	uint64_t ctr;
 	size_t i;



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

2017-08-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Aug  7 17:10:09 UTC 2017

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

Log Message:
Remove incorrect KASSERT, only the allocation is protected by cpu_lock.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/x86/idt.c

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

Modified files:

Index: src/sys/arch/x86/x86/idt.c
diff -u src/sys/arch/x86/x86/idt.c:1.4 src/sys/arch/x86/x86/idt.c:1.5
--- src/sys/arch/x86/x86/idt.c:1.4	Sat Aug 27 14:19:47 2016
+++ src/sys/arch/x86/x86/idt.c	Mon Aug  7 17:10:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: idt.c,v 1.4 2016/08/27 14:19:47 maxv Exp $	*/
+/*	$NetBSD: idt.c,v 1.5 2017/08/07 17:10:09 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2009 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: idt.c,v 1.4 2016/08/27 14:19:47 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: idt.c,v 1.5 2017/08/07 17:10:09 maxv Exp $");
 
 #include 
 #include 
@@ -119,7 +119,6 @@ void
 idt_vec_set(int vec, void (*function)(void))
 {
 
-	KASSERT(mutex_owned(_lock) || !mp_online);
 	KASSERT(idt_allocmap[vec] == 1);
 	setgate([vec], function, 0, SDT_SYS386IGT, SEL_KPL,
 	GSEL(GCODE_SEL, SEL_KPL));



CVS commit: [perseant-stdc-iso10646] src

2017-08-07 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Mon Aug  7 14:27:11 UTC 2017

Modified Files:
src/lib/libc/locale [perseant-stdc-iso10646]: _wctrans_local.h rune.c
src/usr.bin [perseant-stdc-iso10646]: Makefile

Log Message:
Make it compile again when __STDC_ISO_10646__ is not defined.


To generate a diff of this commit:
cvs rdiff -u -r1.9.40.1 -r1.9.40.2 src/lib/libc/locale/_wctrans_local.h
cvs rdiff -u -r1.46.22.2 -r1.46.22.3 src/lib/libc/locale/rune.c
cvs rdiff -u -r1.229 -r1.229.4.1 src/usr.bin/Makefile

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

Modified files:

Index: src/lib/libc/locale/_wctrans_local.h
diff -u src/lib/libc/locale/_wctrans_local.h:1.9.40.1 src/lib/libc/locale/_wctrans_local.h:1.9.40.2
--- src/lib/libc/locale/_wctrans_local.h:1.9.40.1	Fri Jul 21 20:22:29 2017
+++ src/lib/libc/locale/_wctrans_local.h	Mon Aug  7 14:27:11 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: _wctrans_local.h,v 1.9.40.1 2017/07/21 20:22:29 perseant Exp $	*/
+/*	$NetBSD: _wctrans_local.h,v 1.9.40.2 2017/08/07 14:27:11 perseant Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -40,7 +40,7 @@ __END_DECLS
 static __inline wint_t
 _towctrans_priv(wint_ucs4_t c, _WCTransEntry const *te, const _RuneLocale *rl)
 {
-	wint_kuten_t ktc;
+	wint_kuten_t ktc = 0;
 
 	_citrus_ctype_ucs2kt(rl->rl_citrus_ctype, , c);
 	ktc = (_RUNE_ISCACHED(ktc)

Index: src/lib/libc/locale/rune.c
diff -u src/lib/libc/locale/rune.c:1.46.22.2 src/lib/libc/locale/rune.c:1.46.22.3
--- src/lib/libc/locale/rune.c:1.46.22.2	Fri Jul 21 20:22:29 2017
+++ src/lib/libc/locale/rune.c	Mon Aug  7 14:27:11 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rune.c,v 1.46.22.2 2017/07/21 20:22:29 perseant Exp $	*/
+/*	$NetBSD: rune.c,v 1.46.22.3 2017/08/07 14:27:11 perseant Exp $	*/
 /*-
  * Copyright (c)2010 Citrus Project,
  * All rights reserved.
@@ -312,12 +312,10 @@ do {	\
 
 #define CONVERT_MAP(name)		\
 do {	\
-	wint_ucs4_t map;		\
-	wint_kuten_t kmap;		\
+	wint_kuten_t map;		\
 	int c;\
 	\
 	map = _towctrans_priv(wc, _wctrans_##name(rl), rl);		\
-	_citrus_ctype_ucs2kt(rl->rl_citrus_ctype, , map);		\
 	if (map == wc || (_citrus_ctype_wctob(rl->rl_citrus_ctype,	\
 	map, )  || c == EOF))	\
 		c = i;			\

Index: src/usr.bin/Makefile
diff -u src/usr.bin/Makefile:1.229 src/usr.bin/Makefile:1.229.4.1
--- src/usr.bin/Makefile:1.229	Sun May 21 15:28:42 2017
+++ src/usr.bin/Makefile	Mon Aug  7 14:27:11 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.229 2017/05/21 15:28:42 riastradh Exp $
+#	$NetBSD: Makefile,v 1.229.4.1 2017/08/07 14:27:11 perseant Exp $
 #	from: @(#)Makefile	8.3 (Berkeley) 1/7/94
 
 .include 
@@ -15,7 +15,7 @@ SUBDIR= apply asa at audio audiocfg \
 	getopt gettext gprof \
 	head hexdump iconv id indent infocmp innetgr ipcrm ipcs join jot \
 	kdump ktrace ktruss lam last lastcomm ldd leave \
-	locale locate lock logger login logname look lorder m4 \
+	locale localedef locate lock logger login logname look lorder m4 \
 	machine mail make man menuc mesg midiplay midirecord mixerctl \
 	mkcsmapper mkdep mkesdb mkfifo mklocale mkstr mktemp mkubootimage \
 	moduli msgc msgs \



CVS commit: src/sys/dev

2017-08-07 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Mon Aug  7 13:30:51 UTC 2017

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

Log Message:
Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/aurateconv.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/aurateconv.c
diff -u src/sys/dev/aurateconv.c:1.21 src/sys/dev/aurateconv.c:1.22
--- src/sys/dev/aurateconv.c:1.21	Sun Jul 30 00:47:48 2017
+++ src/sys/dev/aurateconv.c	Mon Aug  7 13:30:51 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: aurateconv.c,v 1.21 2017/07/30 00:47:48 nat Exp $	*/
+/*	$NetBSD: aurateconv.c,v 1.22 2017/08/07 13:30:51 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: aurateconv.c,v 1.21 2017/07/30 00:47:48 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aurateconv.c,v 1.22 2017/08/07 13:30:51 isaki Exp $");
 
 #include 
 #include 
@@ -318,7 +318,7 @@ aurateconv_fetch_to(struct audio_softc *
 WRITE_S##BITS##EN(WP, 0); \
 WP = audio_stream_add_inp(STREAM, WP, (BITS) / NBBY); \
 			} \
-		} else {	/* from->channels < to->channels */ \
+		} else {	/* from->channels > to->channels */ \
 			int j; \
 			for (j = 0; j < (int)(TO)->channels; j++) { \
 WRITE_S##BITS##EN(WP, (V)[j]); \



CVS commit: src/sys

2017-08-07 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug  7 09:24:43 UTC 2017

Modified Files:
src/sys/arch/arm/imx: imxspi.c
src/sys/arch/evbarm/conf: NETWALKER
src/sys/dev/spi: m25p.c

Log Message:
Add support Microchip SST25VF016B.
- Fixed imxspi send and receive bugs.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/imxspi.c
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/evbarm/conf/NETWALKER
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/spi/m25p.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/imx/imxspi.c
diff -u src/sys/arch/arm/imx/imxspi.c:1.2 src/sys/arch/arm/imx/imxspi.c:1.3
--- src/sys/arch/arm/imx/imxspi.c:1.2	Sat Mar 29 12:00:27 2014
+++ src/sys/arch/arm/imx/imxspi.c	Mon Aug  7 09:24:43 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: imxspi.c,v 1.2 2014/03/29 12:00:27 hkenken Exp $	*/
+/*	$NetBSD: imxspi.c,v 1.3 2017/08/07 09:24:43 hkenken Exp $	*/
 
 /*-
  * Copyright (c) 2014  Genetec Corporation.  All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imxspi.c,v 1.2 2014/03/29 12:00:27 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imxspi.c,v 1.3 2017/08/07 09:24:43 hkenken Exp $");
 
 #include "opt_imx.h"
 #include "opt_imxspi.h"
@@ -256,7 +256,7 @@ imxspi_send(struct imxspi_softc *sc)
 		while (chunk->chunk_wresid) {
 			/* transmit fifo full? */
 			if (READ_REG(sc, STATREG) & IMXSPI(STAT_TF))
-return;
+goto out;
 
 			if (chunk->chunk_wptr) {
 data = *chunk->chunk_wptr;
@@ -271,7 +271,7 @@ imxspi_send(struct imxspi_softc *sc)
 		/* advance to next transfer */
 		sc->sc_wchunk = sc->sc_wchunk->chunk_next;
 	}
-
+out:
 	if (!(READ_REG(sc, STATREG) & IMXSPI(INTR_TE_EN)))
 		WRITE_REG(sc, CONREG, READ_REG(sc, CONREG) | IMXSPI(CON_XCH));
 }
@@ -321,7 +321,7 @@ imxspi_sched(struct imxspi_softc *sc)
 			sc->sc_tag->spi_cs_enable(sc->sc_tag->cookie,
 			st->st_slave);
 
-		/*chip slect*/
+		/* chip slect */
 		chipselect = READ_REG(sc, CONREG);
 		chipselect &= ~IMXSPI(CON_CS);
 		chipselect |= __SHIFTIN(st->st_slave, IMXSPI(CON_CS));
@@ -382,19 +382,19 @@ imxspi_intr(void *arg)
 		return 0;
 	}
 
-	/* Transfer Conplete? */
-	if (sr & IMXSPI(INTR_TC_EN)) {
-		/* complete TX */
-		imxspi_send(sc);
-	}
-
-	/* RXFIFO ready */
+	/* RXFIFO ready? */
 	if (sr & IMXSPI(INTR_RR_EN)) {
 		imxspi_recv(sc);
 		if (sc->sc_wchunk == NULL && sc->sc_rchunk == NULL)
 			imxspi_done(sc, err);
 	}
 
+	/* Transfer Conplete? */
+	if (sr & IMXSPI(INTR_TC_EN)) {
+		/* complete TX */
+		imxspi_send(sc);
+	}
+
 	/* status register clear */
 	WRITE_REG(sc, STATREG, sr);
 

Index: src/sys/arch/evbarm/conf/NETWALKER
diff -u src/sys/arch/evbarm/conf/NETWALKER:1.35 src/sys/arch/evbarm/conf/NETWALKER:1.36
--- src/sys/arch/evbarm/conf/NETWALKER:1.35	Mon Dec 21 04:26:29 2015
+++ src/sys/arch/evbarm/conf/NETWALKER	Mon Aug  7 09:24:43 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: NETWALKER,v 1.35 2015/12/21 04:26:29 hkenken Exp $
+#	$NetBSD: NETWALKER,v 1.36 2017/08/07 09:24:43 hkenken Exp $
 #
 #	NETWALKER -- http://www.sharp.co.jp/netwalker/
 #
@@ -113,8 +113,8 @@ lidsw0		at gpio3 offset 12 mask 0x01 # i
 imxpwm0		at axi? addr 0x73FB4000 irq 61
 
 # SPI NOR-Flash
-#spiflash0	at spiflashbus?
-#m25p0		at spi0 slave 1
+spiflash0	at spiflashbus?
+m25p0		at spi0 slave 1
 
 # SD/MMC
 sdhc0	at axi? addr 0x70004000 irq 1	 # eSDHC1

Index: src/sys/dev/spi/m25p.c
diff -u src/sys/dev/spi/m25p.c:1.4 src/sys/dev/spi/m25p.c:1.5
--- src/sys/dev/spi/m25p.c:1.4	Sat Oct 26 15:18:21 2013
+++ src/sys/dev/spi/m25p.c	Mon Aug  7 09:24:43 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: m25p.c,v 1.4 2013/10/26 15:18:21 rkujawa Exp $ */
+/* $NetBSD: m25p.c,v 1.5 2017/08/07 09:24:43 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.4 2013/10/26 15:18:21 rkujawa Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.5 2017/08/07 09:24:43 hkenken Exp $");
 
 #include 
 #include 
@@ -60,6 +60,7 @@ __KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.4
 
 static int m25p_match(device_t , cfdata_t , void *);
 static void m25p_attach(device_t , device_t , void *);
+static void m25p_doattach(device_t);
 static const char *m25p_getname(void *);
 static struct spi_handle *m25p_gethandle(void *);
 static int m25p_getflags(void *);
@@ -95,7 +96,8 @@ static const struct m25p_info {
 	{ 0x14, 0x20, 0x2015, "STMicro M25P16", 2048, 64 },	/* 16Mbit */
 	{ 0x12,	0x20, 0x2013, "STMicro M25P40", 512, 64 },	/* 4Mbit */
 	{ 0xc0, 0x20, 0x7117, "STMicro M25PX64", 8192, 64 },	/* 64Mbit */
-	{ 0x0, 0x20, 0xBB18, "Numonyx N25Q128", 16384, 64 },	/* 128Mbit */
+	{ 0x00, 0x20, 0xBB18, "Numonyx N25Q128", 16384, 64 },	/* 128Mbit */
+	{ 0x00, 0xBF, 0x2541, "Microchip SST25VF016B", 2048, 64 }, /* 16Mbit */
 	{ 0 }
 };
 
@@ -116,20 +118,27 @@ m25p_attach(device_t parent, device_t se
 {
 	struct m25p_softc *sc = 

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

2017-08-07 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug  7 08:54:54 UTC 2017

Modified Files:
src/sys/arch/evbarm/netwalker: netwalker_machdep.c

Log Message:
Clean up IOPORT settings.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/evbarm/netwalker/netwalker_machdep.c

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

Modified files:

Index: src/sys/arch/evbarm/netwalker/netwalker_machdep.c
diff -u src/sys/arch/evbarm/netwalker/netwalker_machdep.c:1.19 src/sys/arch/evbarm/netwalker/netwalker_machdep.c:1.20
--- src/sys/arch/evbarm/netwalker/netwalker_machdep.c:1.19	Mon Dec 21 04:26:29 2015
+++ src/sys/arch/evbarm/netwalker/netwalker_machdep.c	Mon Aug  7 08:54:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: netwalker_machdep.c,v 1.19 2015/12/21 04:26:29 hkenken Exp $	*/
+/*	$NetBSD: netwalker_machdep.c,v 1.20 2017/08/07 08:54:54 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003, 2005, 2010  Genetec Corporation.
@@ -102,7 +102,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netwalker_machdep.c,v 1.19 2015/12/21 04:26:29 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netwalker_machdep.c,v 1.20 2017/08/07 08:54:54 hkenken Exp $");
 
 #include "opt_evbarm_boardtype.h"
 #include "opt_arm_debug.h"
@@ -144,6 +144,7 @@ __KERNEL_RCSID(0, "$NetBSD: netwalker_ma
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -463,27 +464,21 @@ const struct iomux_setup iomux_setup_dat
 	IOMUX_DATA(IOMUXC_GPIO3_IPP_IND_G_IN_3_SELECT_INPUT, INPUT_DAISY_0),
 	IOMUX_MP(CSI2_D12, ALT3, KEEPER | DSEHIGH | SRE), /* GPIO4_9 */
 	IOMUX_MP(CSI2_D13, ALT3, KEEPER | DSEHIGH | SRE),
-#if 1
 	IOMUX_MP(GPIO1_2, ALT1, DSEHIGH | ODE),	/* LCD backlight by PWM */
-#else
-	IOMUX_MP(GPIO1_2, ALT0, DSEHIGH | ODE),	/* LCD backlight by GPIO */
-#endif
-	IOMUX_MP(EIM_A19, ALT1, SRE | DSEHIGH),
+
+	IOMUX_MP(EIM_A19, ALT1, SRE | DSEHIGH),	/* GPIO2_13 */
+
 	/* XXX VGA pins */
 	IOMUX_M(DI_GP4, ALT4),
-	IOMUX_M(GPIO1_8, SION | ALT0),
-
 	IOMUX_MP(GPIO1_8, SION | ALT0, HYS | DSEMID | PU_100K),
+
 	/* I2C1 */
-	IOMUX_MP(EIM_D16, SION | ALT4, HYS | ODE | DSEHIGH | SRE),
-	IOMUX_MP(EIM_D19, SION | ALT4, SRE),	/* SCL */
-	IOMUX_MP(EIM_A19, ALT1, SRE | DSEHIGH), /* GPIO2_13 */
+	IOMUX_MP(EIM_D16, SION | ALT4, HYS | ODE | DSEHIGH | SRE),	/* SDA */
+	IOMUX_MP(EIM_D19, SION | ALT4, SRE),			   	/* SCL */
+	IOMUX_DATA(IOMUXC_I2C1_IPP_SDA_IN_SELECT_INPUT, INPUT_DAISY_0),
+	IOMUX_DATA(IOMUXC_I2C1_IPP_SCL_IN_SELECT_INPUT, INPUT_DAISY_0),
 
-#if 0
-	IOMUX_MP(EIM_A23, ALT1, 0),
-#else
 	IOMUX_M(EIM_A23, ALT1),	/* GPIO2_17 */
-#endif
 
 	/* BT */
 	IOMUX_M(EIM_D20, ALT1),	/* GPIO2_4 BT host wakeup */
@@ -497,6 +492,7 @@ const struct iomux_setup iomux_setup_dat
 	IOMUX_MP(EIM_D27, ALT3, KEEPER | PU_100K | DSEHIGH | SRE), /* RTS */
 	IOMUX_M(NANDF_D15, ALT3),	/* GPIO3_25 */
 	IOMUX_MP(NANDF_D14, ALT3, HYS | PULL | PU_100K ),	/* GPIO3_26 */
+	IOMUX_DATA(IOMUXC_UART3_IPP_UART_RTS_B_SELECT_INPUT, INPUT_DAISY_3),
 
 	/* OJ6SH-T25 */
 	IOMUX_M(CSI1_D9, ALT3),			/* GPIO3_13 */
@@ -532,12 +528,11 @@ const struct iomux_setup iomux_setup_dat
 	/* 26M Osc */
 	IOMUX_MP(DI1_PIN12, ALT4, KEEPER | DSEHIGH | SRE), /* GPIO3_1 */
 
-	/* I2C */
-	IOMUX_MP(KEY_COL4, SION | ALT3, SRE),
+	/* I2C2 */
+	IOMUX_MP(KEY_COL5, SION | ALT3, HYS | ODE | DSEHIGH | SRE),	/* SDA */
+	IOMUX_MP(KEY_COL4, SION | ALT3, SRE),/* SCL */
 	IOMUX_DATA(IOMUXC_I2C2_IPP_SCL_IN_SELECT_INPUT, INPUT_DAISY_1),
-	IOMUX_MP(KEY_COL5, SION | ALT3, HYS | ODE | DSEHIGH | SRE),
 	IOMUX_DATA(IOMUXC_I2C2_IPP_SDA_IN_SELECT_INPUT, INPUT_DAISY_1),
-	IOMUX_DATA(IOMUXC_UART3_IPP_UART_RTS_B_SELECT_INPUT, INPUT_DAISY_3),
 
 	/* NAND */
 	IOMUX_MP(NANDF_WE_B, ALT0, HVE | DSEHIGH | PULL | PU_47K),



CVS commit: src/sys/netipsec

2017-08-07 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Aug  7 07:45:45 UTC 2017

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

Log Message:
Hold key_sad.lock on SAVLIST_WRITER_INSERT_TAIL


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 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.211 src/sys/netipsec/key.c:1.212
--- src/sys/netipsec/key.c:1.211	Mon Aug  7 03:30:45 2017
+++ src/sys/netipsec/key.c	Mon Aug  7 07:45:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.211 2017/08/07 03:30:45 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.212 2017/08/07 07:45: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.211 2017/08/07 03:30:45 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.212 2017/08/07 07:45:45 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -5453,7 +5453,9 @@ key_api_update(struct socket *so, struct
 	newsav->refcnt = 1;
 	newsav->state = SADB_SASTATE_MATURE;
 	SAVLIST_ENTRY_INIT(newsav);
+	mutex_enter(_sad.lock);
 	SAVLIST_WRITER_INSERT_TAIL(sah, SADB_SASTATE_MATURE, newsav);
+	mutex_exit(_sad.lock);
 	key_validate_savlist(sah, SADB_SASTATE_MATURE);
 
 	key_sa_chgstate(sav, SADB_SASTATE_DEAD);
@@ -5644,7 +5646,9 @@ key_api_add(struct socket *so, struct mb
 	newsav->refcnt = 1;
 	newsav->state = SADB_SASTATE_MATURE;
 	SAVLIST_ENTRY_INIT(newsav);
+	mutex_enter(_sad.lock);
 	SAVLIST_WRITER_INSERT_TAIL(sah, SADB_SASTATE_MATURE, newsav);
+	mutex_exit(_sad.lock);
 	key_validate_savlist(sah, SADB_SASTATE_MATURE);
 
 	/*



CVS commit: src/sys/ufs

2017-08-07 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Aug  7 06:53:49 UTC 2017

Modified Files:
src/sys/ufs/lfs: ulfs_vnops.c
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
Tidy up ufs_readdir. First step only; there's plenty more that could be
done to improve this code.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/lfs/ulfs_vnops.c
cvs rdiff -u -r1.237 -r1.238 src/sys/ufs/ufs/ufs_vnops.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/ufs/lfs/ulfs_vnops.c
diff -u src/sys/ufs/lfs/ulfs_vnops.c:1.50 src/sys/ufs/lfs/ulfs_vnops.c:1.51
--- src/sys/ufs/lfs/ulfs_vnops.c:1.50	Fri Aug  4 07:27:42 2017
+++ src/sys/ufs/lfs/ulfs_vnops.c	Mon Aug  7 06:53:49 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ulfs_vnops.c,v 1.50 2017/08/04 07:27:42 maya Exp $	*/
+/*	$NetBSD: ulfs_vnops.c,v 1.51 2017/08/07 06:53:49 dholland Exp $	*/
 /*  from NetBSD: ufs_vnops.c,v 1.232 2016/05/19 18:32:03 riastradh Exp  */
 
 /*-
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.50 2017/08/04 07:27:42 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.51 2017/08/07 06:53:49 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_lfs.h"
@@ -769,129 +769,173 @@ ulfs_readdir(void *v)
 		kauth_cred_t	a_cred;
 		int		*a_eofflag;
 		off_t		**a_cookies;
-		int		*ncookies;
+		int		*a_ncookies;
 	} */ *ap = v;
+
+	/* vnode and fs */
 	struct vnode	*vp = ap->a_vp;
-	LFS_DIRHEADER	*cdp, *ecdp;
-	struct dirent	*ndp;
-	char		*cdbuf, *ndbuf, *endp;
-	struct uio	auio, *uio;
-	struct iovec	aiov;
-	int		error;
-	size_t		count, ccount, rcount, cdbufsz, ndbufsz;
-	off_t		off, *ccp;
-	off_t		startoff;
-	size_t		skipbytes;
 	struct ulfsmount *ump = VFSTOULFS(vp->v_mount);
 	struct lfs *fs = ump->um_lfs;
+	/* caller's buffer */
+	struct uio	*calleruio = ap->a_uio;
+	off_t		startoffset, endoffset;
+	size_t		callerbytes;
+	off_t		curoffset;
+	/* dirent production buffer */
+	char		*direntbuf;
+	size_t		direntbufmax;
+	struct dirent	*dirent, *stopdirent;
+	/* output cookies array */
+	off_t		*cookies;
+	size_t		numcookies, maxcookies;
+	/* disk buffer */
+	off_t		physstart, physend;
+	size_t		skipstart, dropend;
+	char		*rawbuf;
+	size_t		rawbufmax, rawbytes;
+	struct uio	rawuio;
+	struct iovec	rawiov;
+	LFS_DIRHEADER	*rawdp, *stoprawdp;
+	/* general */
+	int		error;
 
 	KASSERT(VOP_ISLOCKED(vp));
 
-	uio = ap->a_uio;
-	count = uio->uio_resid;
-	rcount = count - ((uio->uio_offset + count) & (fs->um_dirblksiz - 1));
+	/* figure out where we want to read */
+	callerbytes = calleruio->uio_resid;
+	startoffset = calleruio->uio_offset;
+	endoffset = startoffset + callerbytes;
 
-	if (rcount < LFS_DIRECTSIZ(fs, 0) || count < _DIRENT_MINSIZE(ndp))
+	if (callerbytes < _DIRENT_MINSIZE(dirent)) {
+		/* no room for even one struct dirent */
 		return EINVAL;
+	}
 
-	startoff = uio->uio_offset & ~(fs->um_dirblksiz - 1);
-	skipbytes = uio->uio_offset - startoff;
-	rcount += skipbytes;
-
-	auio.uio_iov = 
-	auio.uio_iovcnt = 1;
-	auio.uio_offset = startoff;
-	auio.uio_resid = rcount;
-	UIO_SETUP_SYSSPACE();
-	auio.uio_rw = UIO_READ;
-	cdbufsz = rcount;
-	cdbuf = kmem_alloc(cdbufsz, KM_SLEEP);
-	aiov.iov_base = cdbuf;
-	aiov.iov_len = rcount;
-	error = VOP_READ(vp, , 0, ap->a_cred);
+	/* round start and end down to block boundaries */
+	physstart = startoffset & ~(off_t)(fs->um_dirblksiz - 1);
+	physend = endoffset & ~(off_t)(fs->um_dirblksiz - 1);
+	skipstart = startoffset - physstart;
+	dropend = endoffset - physend;
+
+	if (callerbytes - dropend < LFS_DIRECTSIZ(fs, 0)) {
+		/* no room for even one dirheader + name */
+		return EINVAL;
+	}
+
+	/* how much to actually read */
+	rawbufmax = callerbytes + skipstart - dropend;
+
+	/* read it */
+	rawbuf = kmem_alloc(rawbufmax, KM_SLEEP);
+	rawiov.iov_base = rawbuf;
+	rawiov.iov_len = rawbufmax;
+	rawuio.uio_iov = 
+	rawuio.uio_iovcnt = 1;
+	rawuio.uio_offset = physstart;
+	rawuio.uio_resid = rawbufmax;
+	UIO_SETUP_SYSSPACE();
+	rawuio.uio_rw = UIO_READ;
+	error = VOP_READ(vp, , 0, ap->a_cred);
 	if (error != 0) {
-		kmem_free(cdbuf, cdbufsz);
+		kmem_free(rawbuf, rawbufmax);
 		return error;
 	}
+	rawbytes = rawbufmax - rawuio.uio_resid;
 
-	rcount -= auio.uio_resid;
+	/* the raw entries to iterate over */
+	rawdp = (LFS_DIRHEADER *)(void *)rawbuf;
+	stoprawdp = (LFS_DIRHEADER *)(void *)[rawbytes];
 
-	cdp = (LFS_DIRHEADER *)(void *)cdbuf;
-	ecdp = (LFS_DIRHEADER *)(void *)[rcount];
+	/* allocate space to produce dirents into */
+	direntbufmax = callerbytes;
+	direntbuf = kmem_alloc(direntbufmax, KM_SLEEP);
 
-	ndbufsz = count;
-	ndbuf = kmem_alloc(ndbufsz, KM_SLEEP);
-	ndp = (struct dirent *)(void *)ndbuf;
-	endp = [count];
+	/* the dirents to iterate over */
+	dirent = (struct dirent *)(void *)direntbuf;
+	stopdirent = (struct dirent *)(void *)[direntbufmax];
 
-	off = uio->uio_offset;
+	/* the output "cookies" (seek positions of directory entries) 

CVS commit: src/external/mit/xorg/server/drivers

2017-08-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Aug  7 06:51:13 UTC 2017

Modified Files:
src/external/mit/xorg/server/drivers: Makefile

Log Message:
don't build apm, ark or glint on cats for xorg-server 1.18.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/external/mit/xorg/server/drivers/Makefile

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

Modified files:

Index: src/external/mit/xorg/server/drivers/Makefile
diff -u src/external/mit/xorg/server/drivers/Makefile:1.93 src/external/mit/xorg/server/drivers/Makefile:1.94
--- src/external/mit/xorg/server/drivers/Makefile:1.93	Sat Dec  3 16:38:15 2016
+++ src/external/mit/xorg/server/drivers/Makefile	Mon Aug  7 06:51:13 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.93 2016/12/03 16:38:15 macallan Exp $
+#	$NetBSD: Makefile,v 1.94 2017/08/07 06:51:13 mrg Exp $
 
 .include 
 
@@ -142,15 +142,12 @@ SUBDIR+= \
 
 .if ${MACHINE} == "cats"
 SUBDIR+= \
-	xf86-video-apm \
-	xf86-video-ark \
 	xf86-video-ast \
 	xf86-video-ati \
 	xf86-video-chips \
 	xf86-video-cirrus \
 	xf86-video-cirrus_alpine \
 	xf86-video-cirrus_laguna \
-	xf86-video-glint \
 	xf86-video-i128 \
 	xf86-video-i740 \
 	xf86-video-mga \
@@ -167,6 +164,12 @@ SUBDIR+= \
 	xf86-video-tseng \
 	xf86-video-vesa \
 	xf86-video-wsfb
+# needs porting for xorg-server 1.18
+.if ${XORG_SERVER_SUBDIR} == "xorg-server.old"
+	xf86-video-apm \
+	xf86-video-ark \
+	xf86-video-glint
+.endif	# ${XORG_SERVER_SUBDIR} == "xorg-server.old"
 .endif	# ${MACHINE} == "cats"
 
 .if ${MACHINE} == "dreamcast"