CVS commit: src/sys/dev/dkwedge

2017-02-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Feb 28 04:47:41 UTC 2017

Modified Files:
src/sys/dev/dkwedge: dkwedge_rdb.c

Log Message:
remove unnecessary substitution. no functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/dkwedge/dkwedge_rdb.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/dkwedge/dkwedge_rdb.c
diff -u src/sys/dev/dkwedge/dkwedge_rdb.c:1.3 src/sys/dev/dkwedge/dkwedge_rdb.c:1.4
--- src/sys/dev/dkwedge/dkwedge_rdb.c:1.3	Tue Feb 28 04:46:02 2017
+++ src/sys/dev/dkwedge/dkwedge_rdb.c	Tue Feb 28 04:47:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: dkwedge_rdb.c,v 1.3 2017/02/28 04:46:02 rin Exp $	*/
+/*	$NetBSD: dkwedge_rdb.c,v 1.4 2017/02/28 04:47:41 rin Exp $	*/
 
 /*
  * Adapted from arch/amiga/amiga/disksubr.c:
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dkwedge_rdb.c,v 1.3 2017/02/28 04:46:02 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dkwedge_rdb.c,v 1.4 2017/02/28 04:47:41 rin Exp $");
 
 #include 
 #include 
@@ -123,7 +123,7 @@ dkwedge_discover_rdb(struct disk *pdk, s
 	unsigned char archtype;
 	bool found, root, swap;
 
-	secsize = bufsize = DEV_BSIZE << pdk->dk_blkshift;
+	secsize = DEV_BSIZE << pdk->dk_blkshift;
 	bufsize = roundup(MAX(sizeof(struct partblock), sizeof(struct rdblock)),
 	secsize);
 	bp = DKW_MALLOC(bufsize);



CVS commit: src/sys/dev/dkwedge

2017-02-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Feb 28 04:46:02 UTC 2017

Modified Files:
src/sys/dev/dkwedge: dkwedge_rdb.c

Log Message:
determine the buffer size by roundup(9)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/dkwedge/dkwedge_rdb.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/dkwedge/dkwedge_rdb.c
diff -u src/sys/dev/dkwedge/dkwedge_rdb.c:1.2 src/sys/dev/dkwedge/dkwedge_rdb.c:1.3
--- src/sys/dev/dkwedge/dkwedge_rdb.c:1.2	Tue Feb 28 04:39:58 2017
+++ src/sys/dev/dkwedge/dkwedge_rdb.c	Tue Feb 28 04:46:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: dkwedge_rdb.c,v 1.2 2017/02/28 04:39:58 rin Exp $	*/
+/*	$NetBSD: dkwedge_rdb.c,v 1.3 2017/02/28 04:46:02 rin Exp $	*/
 
 /*
  * Adapted from arch/amiga/amiga/disksubr.c:
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dkwedge_rdb.c,v 1.2 2017/02/28 04:39:58 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dkwedge_rdb.c,v 1.3 2017/02/28 04:46:02 rin Exp $");
 
 #include 
 #include 
@@ -124,9 +124,8 @@ dkwedge_discover_rdb(struct disk *pdk, s
 	bool found, root, swap;
 
 	secsize = bufsize = DEV_BSIZE << pdk->dk_blkshift;
-	while (bufsize < sizeof(struct partblock) ||
-	   bufsize < sizeof(struct rdblock))
-		bufsize *= 2;
+	bufsize = roundup(MAX(sizeof(struct partblock), sizeof(struct rdblock)),
+	secsize);
 	bp = DKW_MALLOC(bufsize);
 
 	/*
@@ -160,10 +159,9 @@ dkwedge_discover_rdb(struct disk *pdk, s
 	if (secsize != newsecsize) {
 		aprint_verbose("secsize changed from %u to %u\n",
 		secsize, newsecsize);
-		secsize = bufsize = newsecsize;
-		while (bufsize < sizeof(struct partblock) ||
-		   bufsize < sizeof(struct rdblock))
-			bufsize *= 2;
+		secsize = newsecsize;
+		bufsize = roundup(MAX(sizeof(struct partblock),
+		sizeof(struct rdblock)), secsize);
 		bp = DKW_REALLOC(bp, bufsize);
 	}
 



CVS commit: src/sys/dev/dkwedge

2017-02-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Feb 28 04:39:58 UTC 2017

Modified Files:
src/sys/dev/dkwedge: dkwedge_rdb.c

Log Message:
Remove PARANOID macro; we should always update secsize if necessary.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/dkwedge/dkwedge_rdb.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/dkwedge/dkwedge_rdb.c
diff -u src/sys/dev/dkwedge/dkwedge_rdb.c:1.1 src/sys/dev/dkwedge/dkwedge_rdb.c:1.2
--- src/sys/dev/dkwedge/dkwedge_rdb.c:1.1	Sun Feb 26 11:56:49 2017
+++ src/sys/dev/dkwedge/dkwedge_rdb.c	Tue Feb 28 04:39:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: dkwedge_rdb.c,v 1.1 2017/02/26 11:56:49 rin Exp $	*/
+/*	$NetBSD: dkwedge_rdb.c,v 1.2 2017/02/28 04:39:58 rin Exp $	*/
 
 /*
  * Adapted from arch/amiga/amiga/disksubr.c:
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dkwedge_rdb.c,v 1.1 2017/02/26 11:56:49 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dkwedge_rdb.c,v 1.2 2017/02/28 04:39:58 rin Exp $");
 
 #include 
 #include 
@@ -96,9 +96,6 @@ __KERNEL_RCSID(0, "$NetBSD: dkwedge_rdb.
 #define	ADJUST_NR(x)	(x)
 #endif
 
-/* XXX */
-#define	PARANOID
-
 #ifdef _KERNEL
 #define	DKW_MALLOC(SZ)	malloc((SZ), M_DEVBUF, M_WAITOK)
 #define	DKW_FREE(PTR)	free((PTR), M_DEVBUF)
@@ -121,7 +118,7 @@ dkwedge_discover_rdb(struct disk *pdk, s
 	struct rdblock *rbp;
 	void *bp;
 	int error;
-	unsigned blk_per_cyl, bufsize, nextb, secsize, tabsize;
+	unsigned blk_per_cyl, bufsize, newsecsize, nextb, secsize, tabsize;
 	const char *ptype;
 	unsigned char archtype;
 	bool found, root, swap;
@@ -159,8 +156,7 @@ dkwedge_discover_rdb(struct disk *pdk, s
 		goto done;
 	}
 
-#ifdef PARANOID
-	unsigned newsecsize = be32toh(rbp->nbytes);
+	newsecsize = be32toh(rbp->nbytes);
 	if (secsize != newsecsize) {
 		aprint_verbose("secsize changed from %u to %u\n",
 		secsize, newsecsize);
@@ -170,7 +166,6 @@ dkwedge_discover_rdb(struct disk *pdk, s
 			bufsize *= 2;
 		bp = DKW_REALLOC(bp, bufsize);
 	}
-#endif
 
 	strlcpy(dkw.dkw_parent, pdk->dk_name, sizeof(dkw.dkw_parent));
 



CVS commit: src/sys/netinet6

2017-02-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Feb 28 04:07:11 UTC 2017

Modified Files:
src/sys/netinet6: in6.c

Log Message:
Separate the code of joining multicast groups

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.239 -r1.240 src/sys/netinet6/in6.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/netinet6/in6.c
diff -u src/sys/netinet6/in6.c:1.239 src/sys/netinet6/in6.c:1.240
--- src/sys/netinet6/in6.c:1.239	Tue Feb 28 02:56:49 2017
+++ src/sys/netinet6/in6.c	Tue Feb 28 04:07:11 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6.c,v 1.239 2017/02/28 02:56:49 ozaki-r Exp $	*/
+/*	$NetBSD: in6.c,v 1.240 2017/02/28 04:07:11 ozaki-r Exp $	*/
 /*	$KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.239 2017/02/28 02:56:49 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.240 2017/02/28 04:07:11 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -778,6 +778,204 @@ in6_control(struct socket *so, u_long cm
 	return error;
 }
 
+static int
+in6_join_mcastgroups(struct in6_aliasreq *ifra, struct in6_ifaddr *ia,
+struct ifnet *ifp, struct in6_multi **in6m_sol, int flags)
+{
+	int error;
+	struct sockaddr_in6 mltaddr, mltmask;
+	struct in6_multi_mship *imm;
+	struct in6_addr llsol;
+	struct rtentry *rt;
+	int dad_delay;
+	char ip6buf[INET6_ADDRSTRLEN];
+
+	KASSERT(in6m_sol != NULL);
+
+	/* join solicited multicast addr for new host id */
+	memset(&llsol, 0, sizeof(struct in6_addr));
+	llsol.s6_addr16[0] = htons(0xff02);
+	llsol.s6_addr32[1] = 0;
+	llsol.s6_addr32[2] = htonl(1);
+	llsol.s6_addr32[3] = ifra->ifra_addr.sin6_addr.s6_addr32[3];
+	llsol.s6_addr8[12] = 0xff;
+	if ((error = in6_setscope(&llsol, ifp, NULL)) != 0) {
+		/* XXX: should not happen */
+		log(LOG_ERR, "%s: in6_setscope failed\n", __func__);
+		goto out;
+	}
+	dad_delay = 0;
+	if ((flags & IN6_IFAUPDATE_DADDELAY)) {
+		/*
+		 * We need a random delay for DAD on the address
+		 * being configured.  It also means delaying
+		 * transmission of the corresponding MLD report to
+		 * avoid report collision.
+		 * [draft-ietf-ipv6-rfc2462bis-02.txt]
+		 */
+		dad_delay = cprng_fast32() % (MAX_RTR_SOLICITATION_DELAY * hz);
+	}
+
+#define	MLTMASK_LEN  4	/* mltmask's masklen (=32bit=4octet) */
+	/* join solicited multicast addr for new host id */
+	imm = in6_joingroup(ifp, &llsol, &error, dad_delay);
+	if (!imm) {
+		nd6log(LOG_ERR,
+		"addmulti failed for %s on %s (errno=%d)\n",
+		IN6_PRINT(ip6buf, &llsol), if_name(ifp), error);
+		goto out;
+	}
+	LIST_INSERT_HEAD(&ia->ia6_memberships, imm, i6mm_chain);
+	*in6m_sol = imm->i6mm_maddr;
+
+	sockaddr_in6_init(&mltmask, &in6mask32, 0, 0, 0);
+
+	/*
+	 * join link-local all-nodes address
+	 */
+	sockaddr_in6_init(&mltaddr, &in6addr_linklocal_allnodes,
+	0, 0, 0);
+	if ((error = in6_setscope(&mltaddr.sin6_addr, ifp, NULL)) != 0)
+		goto out; /* XXX: should not fail */
+
+	/*
+	 * XXX: do we really need this automatic routes?
+	 * We should probably reconsider this stuff.  Most applications
+	 * actually do not need the routes, since they usually specify
+	 * the outgoing interface.
+	 */
+	rt = rtalloc1(sin6tosa(&mltaddr), 0);
+	if (rt) {
+		if (memcmp(&mltaddr.sin6_addr,
+		&satocsin6(rt_getkey(rt))->sin6_addr,
+		MLTMASK_LEN)) {
+			rt_unref(rt);
+			rt = NULL;
+		} else if (rt->rt_ifp != ifp) {
+			IN6_DPRINTF("%s: rt_ifp %p -> %p (%s) "
+			"network %04x:%04x::/32 = %04x:%04x::/32\n",
+			__func__, rt->rt_ifp, ifp, ifp->if_xname,
+			ntohs(mltaddr.sin6_addr.s6_addr16[0]),
+			ntohs(mltaddr.sin6_addr.s6_addr16[1]),
+			satocsin6(rt_getkey(rt))->sin6_addr.s6_addr16[0],
+			satocsin6(rt_getkey(rt))->sin6_addr.s6_addr16[1]);
+			rt_replace_ifa(rt, &ia->ia_ifa);
+			rt->rt_ifp = ifp;
+		}
+	}
+	if (!rt) {
+		struct rt_addrinfo info;
+
+		memset(&info, 0, sizeof(info));
+		info.rti_info[RTAX_DST] = sin6tosa(&mltaddr);
+		info.rti_info[RTAX_GATEWAY] = sin6tosa(&ia->ia_addr);
+		info.rti_info[RTAX_NETMASK] = sin6tosa(&mltmask);
+		info.rti_info[RTAX_IFA] = sin6tosa(&ia->ia_addr);
+		/* XXX: we need RTF_CONNECTED to fake nd6_rtrequest */
+		info.rti_flags = RTF_UP | RTF_CONNECTED;
+		error = rtrequest1(RTM_ADD, &info, NULL);
+		if (error)
+			goto out;
+	} else {
+		rt_unref(rt);
+	}
+	imm = in6_joingroup(ifp, &mltaddr.sin6_addr, &error, 0);
+	if (!imm) {
+		nd6log(LOG_WARNING,
+		"addmulti failed for %s on %s (errno=%d)\n",
+		IN6_PRINT(ip6buf, &mltaddr.sin6_addr),
+		if_name(ifp), error);
+		goto out;
+	}
+	LIST_INSERT_HEAD(&ia->ia6_memberships, imm, i6mm_chain);
+
+	/*
+	 * join node information group address
+	 */
+	dad_delay = 0;
+	if ((flags & IN6_IFAUPDATE_DADDELAY)) {
+		/*
+		 * The spec doesn't say anything about delay for this
+		 * group, but the same logic should apply.
+		 */
+		dad_delay = cprng_fast3

CVS commit: src

2017-02-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Feb 28 03:32:11 UTC 2017

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/net/if_loop: Makefile
Added Files:
src/tests/net/if_loop: t_basic.sh

Log Message:
Add tests for loopback interface


To generate a diff of this commit:
cvs rdiff -u -r1.724 -r1.725 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.3 -r1.4 src/tests/net/if_loop/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/net/if_loop/t_basic.sh

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.724 src/distrib/sets/lists/tests/mi:1.725
--- src/distrib/sets/lists/tests/mi:1.724	Wed Feb 22 09:09:49 2017
+++ src/distrib/sets/lists/tests/mi	Tue Feb 28 03:32:11 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.724 2017/02/22 09:09:49 kamil Exp $
+# $NetBSD: mi,v 1.725 2017/02/28 03:32:11 ozaki-r Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3261,6 +3261,7 @@
 ./usr/tests/net/if_looptests-net-tests		compattestfile,atf
 ./usr/tests/net/if_loop/Atffile			tests-net-tests		atf,rump
 ./usr/tests/net/if_loop/Kyuafile		tests-net-tests		atf,rump,kyua
+./usr/tests/net/if_loop/t_basic			tests-net-tests		atf,rump
 ./usr/tests/net/if_loop/t_pr			tests-net-tests		atf,rump
 ./usr/tests/net/if_pppoe			tests-net-tests		compattestfile,atf
 ./usr/tests/net/if_pppoe/Atffile		tests-net-tests		atf,rump

Index: src/tests/net/if_loop/Makefile
diff -u src/tests/net/if_loop/Makefile:1.3 src/tests/net/if_loop/Makefile:1.4
--- src/tests/net/if_loop/Makefile:1.3	Mon Aug  8 14:58:40 2016
+++ src/tests/net/if_loop/Makefile	Tue Feb 28 03:32:11 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2016/08/08 14:58:40 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.4 2017/02/28 03:32:11 ozaki-r Exp $
 #
 
 .include 
@@ -10,4 +10,9 @@ TESTS_C=	t_pr
 LDADD+=		-lrumpnet_netinet -lrumpnet_net -lrumpnet
 LDADD+=		-lrump -lrumpuser -lrump -lpthread -lrumpdev -lrumpvfs
 
+.for name in basic
+TESTS_SH+=		t_${name}
+TESTS_SH_SRC_t_${name}=	../net_common.sh t_${name}.sh
+.endfor
+
 .include 

Added files:

Index: src/tests/net/if_loop/t_basic.sh
diff -u /dev/null src/tests/net/if_loop/t_basic.sh:1.1
--- /dev/null	Tue Feb 28 03:32:11 2017
+++ src/tests/net/if_loop/t_basic.sh	Tue Feb 28 03:32:11 2017
@@ -0,0 +1,63 @@
+#	$NetBSD: t_basic.sh,v 1.1 2017/02/28 03:32:11 ozaki-r Exp $
+#
+# Copyright (c) 2017 Internet Initiative Japan Inc.
+# 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``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 FOUNDATION OR CONTRIBUTORS
+# 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.
+#
+
+BUS=bus
+SOCK_LOCAL=unix://loop_basic_local
+
+atf_test_case loop_create_destroy cleanup
+loop_create_destroy_head()
+{
+
+	atf_set "descr" "tests of creation and deletion of a loopback interface"
+	atf_set "require.progs" "rump_server"
+}
+
+loop_create_destroy_body()
+{
+
+	rump_server_start $SOCK_LOCAL netinet6
+
+	export RUMP_SERVER=${SOCK_LOCAL}
+
+	atf_check -s exit:0 rump.ifconfig lo1 create
+	atf_check -s exit:0 rump.ifconfig lo1 up
+	atf_check -s exit:0 rump.ifconfig lo1 down
+	atf_check -s exit:0 rump.ifconfig lo1 destroy
+}
+
+loop_create_destroy_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
+atf_init_test_cases()
+{
+
+	atf_add_test_case loop_create_destroy
+}



CVS commit: src/sys/netinet6

2017-02-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Feb 28 02:56:49 UTC 2017

Modified Files:
src/sys/netinet6: in6.c

Log Message:
Prevent ia6 from being freed in in6_ifinit

It fixes a panic (diagnostic assertion "entry->ple_prevp != NULL" failed)
on:
  ifconfig lo1 create
  ifconfig lo1 127.0.0.2
reported by ryo@


To generate a diff of this commit:
cvs rdiff -u -r1.238 -r1.239 src/sys/netinet6/in6.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/netinet6/in6.c
diff -u src/sys/netinet6/in6.c:1.238 src/sys/netinet6/in6.c:1.239
--- src/sys/netinet6/in6.c:1.238	Thu Feb 23 07:57:10 2017
+++ src/sys/netinet6/in6.c	Tue Feb 28 02:56:49 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6.c,v 1.238 2017/02/23 07:57:10 ozaki-r Exp $	*/
+/*	$NetBSD: in6.c,v 1.239 2017/02/28 02:56:49 ozaki-r Exp $	*/
 /*	$KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.238 2017/02/23 07:57:10 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.239 2017/02/28 02:56:49 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1043,6 +1043,13 @@ in6_update_ifa1(struct ifnet *ifp, struc
 		ia->ia6_lifetime.ia6t_preferred = time_uptime;
 	}
 
+	if (hostIsNew) {
+		/*
+		 * We need a reference to ia before calling in6_ifinit.
+		 * Otherwise ia can be freed in in6_ifinit accidentally.
+		 */
+		ifaref(&ia->ia_ifa);
+	}
 	/* reset the interface and routing table appropriately. */
 	error = in6_ifinit(ifp, ia, &ifra->ifra_addr, hostIsNew);
 	if (error != 0) {
@@ -1059,13 +1066,12 @@ in6_update_ifa1(struct ifnet *ifp, struc
 
 	/*
 	 * Insert ia to the global list and ifa to the interface's list.
+	 * A reference to it is already gained above.
 	 */
 	mutex_enter(&in6_ifaddr_lock);
 	IN6_ADDRLIST_WRITER_INSERT_TAIL(ia);
 	mutex_exit(&in6_ifaddr_lock);
 
-	/* gain a refcnt for the link from in6_ifaddr */
-	ifaref(&ia->ia_ifa);
 	ifa_insert(ifp, &ia->ia_ifa);
 
 	/*



CVS commit: src/sys/kern

2017-02-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Tue Feb 28 00:33:36 UTC 2017

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

Log Message:
pi_bsize must be at least pi_secsize

Allows block device accesses to 4KiB logical sector disks to function on the
vast majority of ports with 2KiB BLKDEV_IOSIZE.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/kern/subr_disk.c

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

Modified files:

Index: src/sys/kern/subr_disk.c
diff -u src/sys/kern/subr_disk.c:1.116 src/sys/kern/subr_disk.c:1.117
--- src/sys/kern/subr_disk.c:1.116	Wed Jan  6 00:22:30 2016
+++ src/sys/kern/subr_disk.c	Tue Feb 28 00:33:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_disk.c,v 1.116 2016/01/06 00:22:30 christos Exp $	*/
+/*	$NetBSD: subr_disk.c,v 1.117 2017/02/28 00:33:36 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1999, 2000, 2009 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.116 2016/01/06 00:22:30 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.117 2017/02/28 00:33:36 jakllsch Exp $");
 
 #include 
 #include 
@@ -573,7 +573,7 @@ disk_ioctl(struct disk *dk, dev_t dev, u
 		pi = data;
 		memset(pi, 0, sizeof(*pi));
 		pi->pi_secsize = dk->dk_geom.dg_secsize;
-		pi->pi_bsize = BLKDEV_IOSIZE;
+		pi->pi_bsize = MAX(BLKDEV_IOSIZE, pi->pi_secsize);
 
 		if (DISKPART(dev) == RAW_PART) {
 			pi->pi_size = dk->dk_geom.dg_secperunit;



CVS commit: src/sys/external/bsd/drm2

2017-02-27 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon Feb 27 23:52:06 UTC 2017

Modified Files:
src/sys/external/bsd/drm2/dist/include/drm: drmP.h
src/sys/external/bsd/drm2/pci: drm_pci.c

Log Message:
Revert "drmkms_pci: use MSI if available."

Fix PR/51997.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/external/bsd/drm2/dist/include/drm/drmP.h
cvs rdiff -u -r1.14 -r1.15 src/sys/external/bsd/drm2/pci/drm_pci.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/external/bsd/drm2/dist/include/drm/drmP.h
diff -u src/sys/external/bsd/drm2/dist/include/drm/drmP.h:1.12 src/sys/external/bsd/drm2/dist/include/drm/drmP.h:1.13
--- src/sys/external/bsd/drm2/dist/include/drm/drmP.h:1.12	Tue Feb 21 14:19:39 2017
+++ src/sys/external/bsd/drm2/dist/include/drm/drmP.h	Mon Feb 27 23:52:05 2017
@@ -1268,7 +1268,6 @@ struct drm_device {
 	bool irq_enabled;		/**< True if irq handler is enabled */
 #ifdef __NetBSD__
 	struct drm_bus_irq_cookie *irq_cookie;
-	pci_intr_handle_t *intr_handles;
 #endif
 	__volatile__ long context_flag;	/**< Context swapping flag */
 	int last_context;		/**< Last current context */

Index: src/sys/external/bsd/drm2/pci/drm_pci.c
diff -u src/sys/external/bsd/drm2/pci/drm_pci.c:1.14 src/sys/external/bsd/drm2/pci/drm_pci.c:1.15
--- src/sys/external/bsd/drm2/pci/drm_pci.c:1.14	Tue Feb 21 14:19:40 2017
+++ src/sys/external/bsd/drm2/pci/drm_pci.c	Mon Feb 27 23:52:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_pci.c,v 1.14 2017/02/21 14:19:40 nonaka Exp $	*/
+/*	$NetBSD: drm_pci.c,v 1.15 2017/02/27 23:52:05 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.14 2017/02/21 14:19:40 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.15 2017/02/27 23:52:05 nonaka Exp $");
 
 #include 
 #include 
@@ -232,17 +232,16 @@ drm_pci_irq_install(struct drm_device *d
 struct drm_bus_irq_cookie **cookiep)
 {
 	const struct pci_attach_args *const pa = drm_pci_attach_args(dev);
+	pci_intr_handle_t ih;
 	const char *intrstr;
 	void *ih_cookie;
 	char intrbuf[PCI_INTRSTR_LEN];
 
-	if (pci_intr_alloc(pa, &dev->intr_handles, NULL, 0))
+	if (pci_intr_map(pa, &ih))
 		return -ENOENT;
 
-	intrstr = pci_intr_string(pa->pa_pc, dev->intr_handles[0], intrbuf,
-	sizeof(intrbuf));
-	ih_cookie = pci_intr_establish(pa->pa_pc, dev->intr_handles[0],
-	IPL_DRM, handler, arg);
+	intrstr = pci_intr_string(pa->pa_pc, ih, intrbuf, sizeof(intrbuf));
+	ih_cookie = pci_intr_establish(pa->pa_pc, ih, IPL_DRM, handler, arg);
 	if (ih_cookie == NULL) {
 		aprint_error_dev(dev->dev,
 		"couldn't establish interrupt at %s (%s)\n",
@@ -263,7 +262,6 @@ drm_pci_irq_uninstall(struct drm_device 
 	const struct pci_attach_args *pa = drm_pci_attach_args(dev);
 
 	pci_intr_disestablish(pa->pa_pc, (void *)cookie);
-	pci_intr_release(pa->pa_pc, dev->intr_handles, 1);
 }
 
 static const char *



CVS commit: src/sys/dev

2017-02-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Feb 27 23:31:00 UTC 2017

Modified Files:
src/sys/dev: audio.c audiobell.c audiovar.h

Log Message:
minor clean ups:
- mark a bunch of local things static
- export an explicit set of functions for audiobell, instead of hooking
  directly into the device callbacks, and avoid non-shared headers for
  the same prototypes
- s/audioprobe/audiomatch/
- use __func__


To generate a diff of this commit:
cvs rdiff -u -r1.313 -r1.314 src/sys/dev/audio.c
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/audiobell.c
cvs rdiff -u -r1.50 -r1.51 src/sys/dev/audiovar.h

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

Modified files:

Index: src/sys/dev/audio.c
diff -u src/sys/dev/audio.c:1.313 src/sys/dev/audio.c:1.314
--- src/sys/dev/audio.c:1.313	Mon Feb 27 10:31:02 2017
+++ src/sys/dev/audio.c	Mon Feb 27 23:31:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.313 2017/02/27 10:31:02 nat Exp $	*/
+/*	$NetBSD: audio.c,v 1.314 2017/02/27 23:31:00 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss 
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.313 2017/02/27 10:31:02 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.314 2017/02/27 23:31:00 mrg Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -233,8 +233,8 @@ int	audio_poll(struct audio_softc *, int
 int	audio_kqfilter(struct audio_chan *, struct knote *);
 paddr_t audiommap(dev_t, off_t, int, struct virtual_channel *);
 paddr_t audio_mmap(struct audio_softc *, off_t, int, struct virtual_channel *);
-int	audio_fop_mmap(struct file *, off_t *, size_t, int, int *, int *,
-			 struct uvm_object **, int *);
+static	int audio_fop_mmap(struct file *, off_t *, size_t, int, int *, int *,
+			   struct uvm_object **, int *);
 
 int	mixer_open(dev_t, struct audio_softc *, int, int, struct lwp *,
 		   struct file **);
@@ -315,12 +315,12 @@ static int audio_sysctl_frequency(SYSCTL
 static int audio_sysctl_precision(SYSCTLFN_PROTO);
 static int audio_sysctl_channels(SYSCTLFN_PROTO);
 
-int	audioprobe(device_t, cfdata_t, void *);
-void	audioattach(device_t, device_t, void *);
-int	audiodetach(device_t, int);
-int	audioactivate(device_t, enum devact);
-void	audiochilddet(device_t, device_t);
-int	audiorescan(device_t, const char *, const int *);
+static int	audiomatch(device_t, cfdata_t, void *);
+static void	audioattach(device_t, device_t, void *);
+static int	audiodetach(device_t, int);
+static int	audioactivate(device_t, enum devact);
+static void	audiochilddet(device_t, device_t);
+static int	audiorescan(device_t, const char *, const int *);
 
 #ifdef AUDIO_PM_IDLE
 static void	audio_idle(void *);
@@ -348,13 +348,13 @@ static void	audio_exit(struct audio_soft
 static int	audio_waitio(struct audio_softc *, kcondvar_t *,
 			 struct virtual_channel *);
 
-int audioclose(struct file *);
-int audioread(struct file *, off_t *, struct uio *, kauth_cred_t, int);
-int audiowrite(struct file *, off_t *, struct uio *, kauth_cred_t, int);
-int audioioctl(struct file *, u_long, void *);
-int audiopoll(struct file *, int);
-int audiokqfilter(struct file *, struct knote *);
-int audiostat(struct file *, struct stat *);
+static int audioclose(struct file *);
+static int audioread(struct file *, off_t *, struct uio *, kauth_cred_t, int);
+static int audiowrite(struct file *, off_t *, struct uio *, kauth_cred_t, int);
+static int audioioctl(struct file *, u_long, void *);
+static int audiopoll(struct file *, int);
+static int audiokqfilter(struct file *, struct knote *);
+static int audiostat(struct file *, struct stat *);
 
 struct portname {
 	const char *name;
@@ -413,9 +413,8 @@ static int	uio_fetcher_fetch_to(struct a
 static int	null_fetcher_fetch_to(struct audio_softc *, stream_fetcher_t *,
   audio_stream_t *, int);
 
-int audiobellopen(dev_t, int, int, struct lwp *, struct file **);
-
-dev_type_open(audioopen);
+static dev_type_open(audioopen);
+/* XXXMRG use more dev_type_xxx */
 
 const struct cdevsw audio_cdevsw = {
 	.d_open = audioopen,
@@ -460,23 +459,23 @@ int auto_config_freq[] = { 48000, 44100,
 			   22050, 16000, 11025, 8000, 4000 };
 
 CFATTACH_DECL3_NEW(audio, sizeof(struct audio_softc),
-audioprobe, audioattach, audiodetach, audioactivate, audiorescan,
+audiomatch, audioattach, audiodetach, audioactivate, audiorescan,
 audiochilddet, DVF_DETACH_SHUTDOWN);
 
 extern struct cfdriver audio_cd;
 
-int
-audioprobe(device_t parent, cfdata_t match, void *aux)
+static int
+audiomatch(device_t parent, cfdata_t match, void *aux)
 {
 	struct audio_attach_args *sa;
 
 	sa = aux;
-	DPRINTF(("audioprobe: type=%d sa=%p hw=%p\n",
-		 sa->type, sa, sa->hwif));
+	DPRINTF(("%s: type=%d sa=%p hw=%p\n",
+		 __func__, sa->type, sa, sa->hwif));
 	return (sa->type == AUDIODEV_TYPE_AUDIO) ? 1 : 0;
 }
 
-void
+static void
 audioattach(device_t parent, device_t self, void *aux)
 {
 	struct audio_softc *sc;
@@ -905

CVS commit: src/sys/dev/ic

2017-02-27 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Feb 27 21:48:34 UTC 2017

Modified Files:
src/sys/dev/ic: ld_nvme.c

Log Message:
remote extra pasted line


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/ic/ld_nvme.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/ic/ld_nvme.c
diff -u src/sys/dev/ic/ld_nvme.c:1.11 src/sys/dev/ic/ld_nvme.c:1.12
--- src/sys/dev/ic/ld_nvme.c:1.11	Mon Feb 27 21:32:33 2017
+++ src/sys/dev/ic/ld_nvme.c	Mon Feb 27 21:48:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_nvme.c,v 1.11 2017/02/27 21:32:33 jdolecek Exp $	*/
+/*	$NetBSD: ld_nvme.c,v 1.12 2017/02/27 21:48:34 jdolecek Exp $	*/
 
 /*-
  * Copyright (C) 2016 NONAKA Kimihiro 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.11 2017/02/27 21:32:33 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.12 2017/02/27 21:48:34 jdolecek Exp $");
 
 #include 
 #include 
@@ -194,7 +194,6 @@ static int
 ld_nvme_ioctl(struct ld_softc *ld, u_long cmd, void *addr, int32_t flag, bool poll)
 {
 	int error;
-	struct ld_nvme_softc *sc = device_private(ld->sc_dv);
 
 	switch (cmd) {
 	case DIOCCACHESYNC:



CVS commit: src/sys/sys

2017-02-27 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Feb 27 21:33:47 UTC 2017

Modified Files:
src/sys/sys: param.h

Log Message:
Welcome to 7.99.63 - struct ld_softc changes


To generate a diff of this commit:
cvs rdiff -u -r1.529 -r1.530 src/sys/sys/param.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/sys/param.h
diff -u src/sys/sys/param.h:1.529 src/sys/sys/param.h:1.530
--- src/sys/sys/param.h:1.529	Thu Feb 23 03:48:20 2017
+++ src/sys/sys/param.h	Mon Feb 27 21:33:47 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.529 2017/02/23 03:48:20 kamil Exp $	*/
+/*	$NetBSD: param.h,v 1.530 2017/02/27 21:33:47 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	799006200	/* NetBSD 7.99.62 */
+#define	__NetBSD_Version__	799006300	/* NetBSD 7.99.63 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src/sys/dev

2017-02-27 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Feb 27 21:32:33 UTC 2017

Modified Files:
src/sys/dev: ld.c ldvar.h
src/sys/dev/i2o: ld_iop.c
src/sys/dev/ic: ld_icp.c ld_nvme.c
src/sys/dev/pci: ld_twa.c ld_twe.c ld_virtio.c

Log Message:
refactor the ld(4) DIOCCACHESYNC hook into general ioctl hook, so that 
attachments
would be able to implement arbitrary other ioctls


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/ld.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ldvar.h
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/i2o/ld_iop.c
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/ic/ld_icp.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ic/ld_nvme.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/ld_twa.c
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/pci/ld_twe.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/ld_virtio.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/ld.c
diff -u src/sys/dev/ld.c:1.99 src/sys/dev/ld.c:1.100
--- src/sys/dev/ld.c:1.99	Sat Nov 26 12:32:03 2016
+++ src/sys/dev/ld.c	Mon Feb 27 21:32:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld.c,v 1.99 2016/11/26 12:32:03 mlelstv Exp $	*/
+/*	$NetBSD: ld.c,v 1.100 2017/02/27 21:32:33 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.99 2016/11/26 12:32:03 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.100 2017/02/27 21:32:33 jdolecek Exp $");
 
 #include 
 #include 
@@ -70,6 +70,7 @@ static void	ld_set_geometry(struct ld_so
 static void	ld_config_interrupts (device_t);
 static int	ld_lastclose(device_t);
 static int	ld_discard(device_t, off_t, off_t);
+static int	ld_flush(device_t, bool);
 
 extern struct	cfdriver ld_cd;
 
@@ -247,15 +248,12 @@ ldenddetach(struct ld_softc *sc)
 	pmf_device_deregister(dksc->sc_dev);
 
 	/*
-	 * XXX We can't really flush the cache here, beceause the
+	 * XXX We can't really flush the cache here, because the
 	 * XXX device may already be non-existent from the controller's
 	 * XXX perspective.
 	 */
 #if 0
-	/* Flush the device's cache. */
-	if (sc->sc_flush != NULL)
-		if ((*sc->sc_flush)(sc, 0) != 0)
-			device_printf(dksc->sc_dev, "unable to flush cache\n");
+	ld_flush(dksc->sc_dev, false);
 #endif
 	cv_destroy(&sc->sc_drain);
 	mutex_destroy(&sc->sc_mutex);
@@ -272,14 +270,8 @@ ld_suspend(device_t dev, const pmf_qual_
 static bool
 ld_shutdown(device_t dev, int flags)
 {
-	struct ld_softc *sc = device_private(dev);
-	struct dk_softc *dksc = &sc->sc_dksc;
-
-	if ((flags & RB_NOSYNC) == 0 && sc->sc_flush != NULL
-	&& (*sc->sc_flush)(sc, LDFL_POLL) != 0) {
-		device_printf(dksc->sc_dev, "unable to flush cache\n");
+	if ((flags & RB_NOSYNC) == 0 && ld_flush(dev, true) != 0)
 		return false;
-	}
 
 	return true;
 }
@@ -303,10 +295,7 @@ ldopen(dev_t dev, int flags, int fmt, st
 static int
 ld_lastclose(device_t self)
 {
-	struct ld_softc *sc = device_private(self);
-
-	if (sc->sc_flush != NULL && (*sc->sc_flush)(sc, 0) != 0)
-		device_printf(self, "unable to flush cache\n");
+	ld_flush(self, false);
 
 	return 0;
 }
@@ -356,6 +345,10 @@ ldioctl(dev_t dev, u_long cmd, void *add
 
 	error = 0;
 
+	/*
+	 * Some common checks so that individual attachments wouldn't need
+	 * to duplicate them.
+	 */
 	switch (cmd) {
 	case DIOCCACHESYNC:
 		/*
@@ -364,18 +357,40 @@ ldioctl(dev_t dev, u_long cmd, void *add
 		 */
 		if ((flag & FWRITE) == 0)
 			error = EBADF;
-		else if (sc->sc_flush)
-			error = (*sc->sc_flush)(sc, 0);
 		else
-			error = 0;	/* XXX Error out instead? */
+			error = 0;
 		break;
+	}
 
-	default:
-		error = dk_ioctl(dksc, dev, cmd, addr, flag, l);
-		break;
+	if (error != 0)
+		return (error);
+
+	if (sc->sc_ioctl) {
+		error = (*sc->sc_ioctl)(sc, cmd, addr, flag, 0);
+		if (error != EPASSTHROUGH)
+			return (error);
 	}
 
-	return (error);
+	/* something not handled by the attachment */
+	return dk_ioctl(dksc, dev, cmd, addr, flag, l);
+}
+
+/*
+ * Flush the device's cache.
+ */
+static int
+ld_flush(device_t self, bool poll)
+{
+	int error = 0;
+	struct ld_softc *sc = device_private(self);
+
+	if (sc->sc_ioctl) {
+		error = (*sc->sc_ioctl)(sc, DIOCCACHESYNC, NULL, 0, poll);
+		if (error != 0)
+			device_printf(self, "unable to flush cache\n");
+	}
+
+	return error;
 }
 
 static void

Index: src/sys/dev/ldvar.h
diff -u src/sys/dev/ldvar.h:1.28 src/sys/dev/ldvar.h:1.29
--- src/sys/dev/ldvar.h:1.28	Fri Sep 16 15:20:50 2016
+++ src/sys/dev/ldvar.h	Mon Feb 27 21:32:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ldvar.h,v 1.28 2016/09/16 15:20:50 jdolecek Exp $	*/
+/*	$NetBSD: ldvar.h,v 1.29 2017/02/27 21:32:33 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@ struct ld_softc {
 	int		sc_maxqueuecnt;	/* maximum h/w queue depth */
 
 	int		(*sc_dump)(struct ld_softc *, void *, int, int);
-	int		(*sc_flush)(struct ld_softc *, int);
+	

CVS commit: src/sys/dev/dkwedge

2017-02-27 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Feb 27 21:27:07 UTC 2017

Modified Files:
src/sys/dev/dkwedge: dk.c

Log Message:
pass also DIOCGCACHE to underlying device, so that upper layers would be able
to get the device cache properties without knowing the topology; while here also
pass down DIOCGSTRATEGY for neater dkctl(8) output


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/dev/dkwedge/dk.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/dkwedge/dk.c
diff -u src/sys/dev/dkwedge/dk.c:1.94 src/sys/dev/dkwedge/dk.c:1.95
--- src/sys/dev/dkwedge/dk.c:1.94	Thu Jan 19 00:44:40 2017
+++ src/sys/dev/dkwedge/dk.c	Mon Feb 27 21:27:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: dk.c,v 1.94 2017/01/19 00:44:40 maya Exp $	*/
+/*	$NetBSD: dk.c,v 1.95 2017/02/27 21:27:07 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.94 2017/01/19 00:44:40 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.95 2017/02/27 21:27:07 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -1478,16 +1478,10 @@ dkioctl(dev_t dev, u_long cmd, void *dat
 	error = 0;
 	
 	switch (cmd) {
+	case DIOCGSTRATEGY:
+	case DIOCGCACHE:
 	case DIOCCACHESYNC:
-		/*
-		 * XXX Do we really need to care about having a writable
-		 * file descriptor here?
-		 */
-		if ((flag & FWRITE) == 0)
-			error = EBADF;
-		else
-			error = VOP_IOCTL(sc->sc_parent->dk_rawvp,
-	  cmd, data, flag,
+		error = VOP_IOCTL(sc->sc_parent->dk_rawvp, cmd, data, flag,
 	  l != NULL ? l->l_cred : NOCRED);
 		break;
 	case DIOCGWEDGEINFO:



CVS commit: src/sys/dev

2017-02-27 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Feb 27 21:25:46 UTC 2017

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

Log Message:
pass also DIOCGCACHE to underlying device, so that upper layers would be able
to get device cache properties without knowing the topology


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/dev/cgd.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/cgd.c
diff -u src/sys/dev/cgd.c:1.113 src/sys/dev/cgd.c:1.114
--- src/sys/dev/cgd.c:1.113	Thu Dec 22 20:57:33 2016
+++ src/sys/dev/cgd.c	Mon Feb 27 21:25:45 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.113 2016/12/22 20:57:33 kamil Exp $ */
+/* $NetBSD: cgd.c,v 1.114 2017/02/27 21:25:45 jdolecek Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.113 2016/12/22 20:57:33 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.114 2017/02/27 21:25:45 jdolecek Exp $");
 
 #include 
 #include 
@@ -715,14 +715,10 @@ cgdioctl(dev_t dev, u_long cmd, void *da
 		if (DK_BUSY(&cs->sc_dksc, pmask))
 			return EBUSY;
 		return cgd_ioctl_clr(cs, l);
+	case DIOCGCACHE:
 	case DIOCCACHESYNC:
-		/*
-		 * XXX Do we really need to care about having a writable
-		 * file descriptor here?
-		 */
-		if ((flag & FWRITE) == 0)
-			return (EBADF);
-
+		if (!DK_ATTACHED(dksc))
+			return ENOENT;
 		/*
 		 * We pass this call down to the underlying disk.
 		 */



CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo

2017-02-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Feb 27 20:29:00 UTC 2017

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo:
nouveau_engine_fifo_nvc0.c

Log Message:
Avoid __ffs64(0).

>From maya@.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \

src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_nvc0.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/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_nvc0.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_nvc0.c:1.5 src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_nvc0.c:1.6
--- src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_nvc0.c:1.5	Sun Oct 25 21:44:16 2015
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_nvc0.c	Mon Feb 27 20:29:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_engine_fifo_nvc0.c,v 1.5 2015/10/25 21:44:16 mrg Exp $	*/
+/*	$NetBSD: nouveau_engine_fifo_nvc0.c,v 1.6 2017/02/27 20:29:00 riastradh Exp $	*/
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_fifo_nvc0.c,v 1.5 2015/10/25 21:44:16 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_fifo_nvc0.c,v 1.6 2017/02/27 20:29:00 riastradh Exp $");
 
 #include 
 #include 
@@ -448,11 +448,15 @@ nvc0_fifo_recover_work(struct work_struc
 	priv->mask = 0ULL;
 	spin_unlock_irqrestore(&priv->base.lock, flags);
 
-	for (todo = mask; engn = __ffs64(todo), todo; todo &= ~(1 << engn))
+	for (todo = mask;
+	 todo && (engn = __ffs64(todo), 1);
+	 todo &= ~(1 << engn))
 		engm |= 1 << nvc0_fifo_engidx(priv, engn);
 	nv_mask(priv, 0x002630, engm, engm);
 
-	for (todo = mask; engn = __ffs64(todo), todo; todo &= ~(1 << engn)) {
+	for (todo = mask;
+	 todo && (engn = __ffs64(todo), 1);
+	 todo &= ~(1 << engn)) {
 		if ((engine = (void *)nouveau_engine(priv, engn))) {
 			nv_ofuncs(engine)->fini(engine, false);
 			WARN_ON(nv_ofuncs(engine)->init(engine));



CVS commit: src/libexec/ld.elf_so

2017-02-27 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Feb 27 20:25:26 UTC 2017

Modified Files:
src/libexec/ld.elf_so: rtld.c

Log Message:
tag the powerpc hackish_return_address() as __noinline.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/libexec/ld.elf_so/rtld.c

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

Modified files:

Index: src/libexec/ld.elf_so/rtld.c
diff -u src/libexec/ld.elf_so/rtld.c:1.182 src/libexec/ld.elf_so/rtld.c:1.183
--- src/libexec/ld.elf_so/rtld.c:1.182	Thu Dec  1 18:21:39 2016
+++ src/libexec/ld.elf_so/rtld.c	Mon Feb 27 20:25:26 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtld.c,v 1.182 2016/12/01 18:21:39 christos Exp $	 */
+/*	$NetBSD: rtld.c,v 1.183 2017/02/27 20:25:26 chs Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: rtld.c,v 1.182 2016/12/01 18:21:39 christos Exp $");
+__RCSID("$NetBSD: rtld.c,v 1.183 2017/02/27 20:25:26 chs Exp $");
 #endif /* not lint */
 
 #include 
@@ -1071,7 +1071,7 @@ _rtld_objmain_sym(const char *name)
 }
 
 #ifdef __powerpc__
-static void *
+static __noinline void *
 hackish_return_address(void)
 {
 	return __builtin_return_address(1);



CVS commit: src/tests/lib/csu/arch/powerpc

2017-02-27 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Feb 27 20:22:32 UTC 2017

Modified Files:
src/tests/lib/csu/arch/powerpc: h_initfini_align.S

Log Message:
check the lower bits of the stack pointer,
not the lower bits of the upper half of the stack pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/csu/arch/powerpc/h_initfini_align.S

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

Modified files:

Index: src/tests/lib/csu/arch/powerpc/h_initfini_align.S
diff -u src/tests/lib/csu/arch/powerpc/h_initfini_align.S:1.1 src/tests/lib/csu/arch/powerpc/h_initfini_align.S:1.2
--- src/tests/lib/csu/arch/powerpc/h_initfini_align.S:1.1	Wed Dec 11 17:31:56 2013
+++ src/tests/lib/csu/arch/powerpc/h_initfini_align.S	Mon Feb 27 20:22:32 2017
@@ -1,8 +1,8 @@
-/*	$NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $	*/
+/*	$NetBSD: h_initfini_align.S,v 1.2 2017/02/27 20:22:32 chs Exp $	*/
 
 #include 
 
-RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $")
+RCSID("$NetBSD: h_initfini_align.S,v 1.2 2017/02/27 20:22:32 chs Exp $")
 
 /*
  * LINTSTUB: bool check_stack_alignment(void);
@@ -10,7 +10,7 @@ RCSID("$NetBSD: h_initfini_align.S,v 1.1
 
 _ENTRY(check_stack_alignment)
 	li	%r3,0
-	andis.	%r0,%r1,15
+	andi.	%r0,%r1,15
 	bnelr	%cr0
 	li	%r3,1
 	blr



CVS commit: src/sys/arch/shark/ofw

2017-02-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Feb 27 18:30:42 UTC 2017

Modified Files:
src/sys/arch/shark/ofw: vlpci.c

Log Message:
Flesh out missing functions.  Get IO space and interrupts working.

Successfully tested with RTL8029 ne(4)@pci(4).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/shark/ofw/vlpci.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/shark/ofw/vlpci.c
diff -u src/sys/arch/shark/ofw/vlpci.c:1.3 src/sys/arch/shark/ofw/vlpci.c:1.4
--- src/sys/arch/shark/ofw/vlpci.c:1.3	Sun Feb 19 14:34:40 2017
+++ src/sys/arch/shark/ofw/vlpci.c	Mon Feb 27 18:30:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vlpci.c,v 1.3 2017/02/19 14:34:40 jakllsch Exp $	*/
+/*	$NetBSD: vlpci.c,v 1.4 2017/02/27 18:30:42 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 2017 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vlpci.c,v 1.3 2017/02/19 14:34:40 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vlpci.c,v 1.4 2017/02/27 18:30:42 jakllsch Exp $");
 
 #include "opt_pci.h"
 #include "pci.h"
@@ -56,6 +56,16 @@ static pcitag_t	vlpci_pc_make_tag(void *
 static void	vlpci_pc_decompose_tag(void *, pcitag_t, int *, int *, int *);
 static pcireg_t	vlpci_pc_conf_read(void *, pcitag_t, int);
 static void	vlpci_pc_conf_write(void *, pcitag_t, int, pcireg_t);
+
+static int	vlpci_pc_intr_map(const struct pci_attach_args *,
+pci_intr_handle_t *);
+static const char * vlpci_pc_intr_string(void *, pci_intr_handle_t, char *,
+size_t);
+static const struct evcnt * vlpci_pc_intr_evcnt(void *, pci_intr_handle_t);
+static void *	vlpci_pc_intr_establish(void *, pci_intr_handle_t, int,
+int (*)(void *), void *);
+static void 	vlpci_pc_intr_disestablish(void *, void *);
+
 #ifdef __HAVE_PCI_CONF_HOOK
 static int	vlpci_pc_conf_hook(void *, int, int, int, pcireg_t);
 #endif
@@ -119,8 +129,12 @@ vlpci_attach(device_t parent, device_t s
 	}
 
 	/* Enable VLB/PCI bridge */
-	regwrite_1(sc, 0x96, 0x18); /* Undocumented by VIA */
-	regwrite_1(sc, 0x93, 0xd0);
+	regwrite_1(sc, 0x96, 0x18); /* enable LOCAL#, compatible mode */
+	regwrite_1(sc, 0x93, 0x60); /* IOCHCK# on IOCHCK#/NMI */
+	regwrite_1(sc, 0x86, 2<<5); /* invert all INTx to IRQ */
+	regwrite_1(sc, 0x97, 0x00); /* don't do per-INTx conversions */
+	regwrite_1(sc, 0x91, 0xbb); /* enable INT[AB] to IRQ 10 */
+	regwrite_1(sc, 0x90, 0xbb); /* enable INT[CD] to IRQ 10 */
 
 	pc->pc_conf_v = sc;
 	pc->pc_attach_hook = vlpci_pc_attach_hook;
@@ -129,14 +143,28 @@ vlpci_attach(device_t parent, device_t s
 	pc->pc_decompose_tag = vlpci_pc_decompose_tag;
 	pc->pc_conf_read = vlpci_pc_conf_read;
 	pc->pc_conf_write = vlpci_pc_conf_write;
+
+	pc->pc_intr_v = sc;
+	pc->pc_intr_map = vlpci_pc_intr_map;
+	pc->pc_intr_string = vlpci_pc_intr_string;
+	pc->pc_intr_evcnt = vlpci_pc_intr_evcnt;
+	pc->pc_intr_establish = vlpci_pc_intr_establish;
+	pc->pc_intr_disestablish = vlpci_pc_intr_disestablish;
+
 #ifdef __HAVE_PCI_CONF_HOOK
 	pc->pc_conf_hook = vlpci_pc_conf_hook;
 #endif
 	pc->pc_conf_interrupt = vlpci_pc_conf_interrupt;
 
-	pc->pc_intr_v = sc;
+	/* try to assure IO space is enabled on the default device-function */
+	vlpci_pc_conf_write(sc, vlpci_pc_make_tag(sc, 0, 6, 0),
+	PCI_COMMAND_STATUS_REG,
+	vlpci_pc_conf_read(sc, vlpci_pc_make_tag(sc, 0, 6, 0),
+	PCI_COMMAND_STATUS_REG) |
+	PCI_COMMAND_IO_ENABLE);
 
-	pba.pba_flags = PCI_FLAGS_IO_OKAY; /* XXX test this, implement more */
+	pba.pba_flags = PCI_FLAGS_IO_OKAY; /* try for more someday */
+	pba.pba_iot = &isa_io_bs_tag;
 	pba.pba_pc = &sc->sc_pc;
 	pba.pba_bus = 0;
 
@@ -219,6 +247,54 @@ vlpci_pc_conf_write(void *v, pcitag_t ta
 	mutex_spin_exit(&sc->sc_lock);
 }
 
+static int
+vlpci_pc_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ih)
+{
+	switch (pa->pa_intrpin) {
+	default:
+	case 0:
+		return EINVAL;
+	case 1:
+	case 2:
+	case 3:
+	case 4:
+		*ih = 10;
+		return 0;
+	}
+}
+
+static const char *
+vlpci_pc_intr_string(void *v, pci_intr_handle_t ih, char *buf, size_t len)
+{
+
+	if (ih == PCI_INTERRUPT_PIN_NONE)
+		return NULL;
+	snprintf(buf, len, "irq %2lu", ih);
+	return buf;
+}
+
+static const struct evcnt *
+vlpci_pc_intr_evcnt(void *v, pci_intr_handle_t ih)
+{
+	return NULL;
+}
+
+static void *
+vlpci_pc_intr_establish(void *v, pci_intr_handle_t pih, int ipl,
+int (*callback)(void *), void *arg)
+{
+	if (pih == 0)
+		return NULL;
+
+	return isa_intr_establish(NULL, pih, IST_LEVEL, ipl, callback, arg);
+}
+
+static void
+vlpci_pc_intr_disestablish(void *v, void *w)
+{
+	panic("%s unimplemented", __func__);
+}
+
 #ifdef __HAVE_PCI_CONF_HOOK
 static int
 vlpci_pc_conf_hook(void *v, int b, int d, int f, pcireg_t id)



CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo

2017-02-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Feb 27 18:28:40 UTC 2017

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo:
nouveau_engine_fifo_nve0.c

Log Message:
Avoid __ffs64(0).


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \

src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_nve0.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/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_nve0.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_nve0.c:1.6 src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_nve0.c:1.7
--- src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_nve0.c:1.6	Mon Oct 26 07:12:08 2015
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_nve0.c	Mon Feb 27 18:28:39 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_engine_fifo_nve0.c,v 1.6 2015/10/26 07:12:08 mrg Exp $	*/
+/*	$NetBSD: nouveau_engine_fifo_nve0.c,v 1.7 2017/02/27 18:28:39 riastradh Exp $	*/
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_fifo_nve0.c,v 1.6 2015/10/26 07:12:08 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_fifo_nve0.c,v 1.7 2017/02/27 18:28:39 riastradh Exp $");
 
 #include 
 #include 
@@ -476,11 +476,15 @@ nve0_fifo_recover_work(struct work_struc
 	priv->mask = 0ULL;
 	spin_unlock_irqrestore(&priv->base.lock, flags);
 
-	for (todo = mask; engn = __ffs64(todo), todo; todo &= ~(1 << engn))
+	for (todo = mask;
+	 todo && (engn = __ffs64(todo), 1);
+	 todo &= ~(1 << engn))
 		engm |= 1 << nve0_fifo_engidx(priv, engn);
 	nv_mask(priv, 0x002630, engm, engm);
 
-	for (todo = mask; engn = __ffs64(todo), todo; todo &= ~(1 << engn)) {
+	for (todo = mask;
+	 todo && (engn = __ffs64(todo), 1);
+	 todo &= ~(1 << engn)) {
 		if ((engine = (void *)nouveau_engine(priv, engn))) {
 			nv_ofuncs(engine)->fini(engine, false);
 			WARN_ON(nv_ofuncs(engine)->init(engine));



CVS commit: src/sys/dev/pci

2017-02-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Feb 27 16:16:23 UTC 2017

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

Log Message:
fix printf formats (clang build)


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/sys/dev/pci/pci_subr.c

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

Modified files:

Index: src/sys/dev/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.161 src/sys/dev/pci/pci_subr.c:1.162
--- src/sys/dev/pci/pci_subr.c:1.161	Mon Feb 27 09:13:56 2017
+++ src/sys/dev/pci/pci_subr.c	Mon Feb 27 11:16:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.161 2017/02/27 14:13:56 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.162 2017/02/27 16:16:23 christos Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.161 2017/02/27 14:13:56 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.162 2017/02/27 16:16:23 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -2658,22 +2658,24 @@ pci_conf_print_vc_cap(const pcireg_t *re
 }
 
 static void
-pci_conf_print_pwrbdgt_base_power(uint8_t base, int scale)
+pci_conf_print_pwrbdgt_base_power(uint8_t base, unsigned int scale)
 {
-	int sdiv = 1;
-	const char *s;
-	int i;
-	
 	if (base <= 0xef) {
-		for (i = scale; i > 0; i--)
+		unsigned int sdiv = 1;
+		for (unsigned int i = scale; i > 0; i--)
 			sdiv *= 10;
-		printf("%hhu", base / sdiv);
+
+		printf("%u", base / sdiv);
+
 		if (scale != 0) {
-			printf(".%hhu", base % sdiv);
+			printf(".%u", base % sdiv);
 		}
 		printf ("W\n");
 		return;
 	}
+
+	const char *s;
+
 	switch (base) {
 	case 0xf0:
 		s = "239W < x <= 250W";



CVS commit: src/sys/arch/amiga/amiga

2017-02-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Feb 27 15:59:36 UTC 2017

Modified Files:
src/sys/arch/amiga/amiga: disksubr.c

Log Message:
If lp->d_secsize is updated, we need to reallocate the buffer.
Thanks mlelstv for his comment on port-amiga.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/arch/amiga/amiga/disksubr.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/amiga/amiga/disksubr.c
diff -u src/sys/arch/amiga/amiga/disksubr.c:1.65 src/sys/arch/amiga/amiga/disksubr.c:1.66
--- src/sys/arch/amiga/amiga/disksubr.c:1.65	Sat Feb 25 22:45:59 2017
+++ src/sys/arch/amiga/amiga/disksubr.c	Mon Feb 27 15:59:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: disksubr.c,v 1.65 2017/02/25 22:45:59 rin Exp $	*/
+/*	$NetBSD: disksubr.c,v 1.66 2017/02/27 15:59:36 rin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.65 2017/02/25 22:45:59 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.66 2017/02/27 15:59:36 rin Exp $");
 
 #include 
 #include 
@@ -239,7 +239,11 @@ readdisklabel(dev_t dev, void (*strat)(s
 		lp->d_partitions[i].p_offset = 0;
 	}
 
-	lp->d_secsize = rbp->nbytes;
+	if (lp->d_secsize != rbp->nbytes) {
+		lp->d_secsize = rbp->nbytes;
+		allocbuf(bp, (int)lp->d_secsize, 1);
+		rbp = baddr(bp);
+	}
 	lp->d_nsectors = rbp->nsectors;
 	lp->d_ntracks = rbp->nheads;
 	/*



CVS commit: src/sys

2017-02-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Feb 27 14:13:57 UTC 2017

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

Log Message:
 Decode AGP capability.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/dev/pci/agp.c
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/pci/agpreg.h
cvs rdiff -u -r1.160 -r1.161 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.120 -r1.121 src/sys/dev/pci/pcireg.h
cvs rdiff -u -r1.11 -r1.12 src/sys/sys/agpio.h

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

Modified files:

Index: src/sys/dev/pci/agp.c
diff -u src/sys/dev/pci/agp.c:1.83 src/sys/dev/pci/agp.c:1.84
--- src/sys/dev/pci/agp.c:1.83	Fri Jul 25 08:10:38 2014
+++ src/sys/dev/pci/agp.c	Mon Feb 27 14:13:56 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: agp.c,v 1.83 2014/07/25 08:10:38 dholland Exp $	*/
+/*	$NetBSD: agp.c,v 1.84 2017/02/27 14:13:56 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2000 Doug Rabson
@@ -65,7 +65,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: agp.c,v 1.83 2014/07/25 08:10:38 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: agp.c,v 1.84 2017/02/27 14:13:56 msaitoh Exp $");
 
 #include 
 #include 
@@ -471,9 +471,9 @@ agp_generic_enable(struct agp_softc *sc,
 	}
 
 	tstatus = pci_conf_read(sc->as_pc, sc->as_tag,
-	sc->as_capoff + AGP_STATUS);
+	sc->as_capoff + PCI_AGP_STATUS);
 	mstatus = pci_conf_read(pa.pa_pc, pa.pa_tag,
-	capoff + AGP_STATUS);
+	capoff + PCI_AGP_STATUS);
 
 	if (AGP_MODE_GET_MODE_3(mode) &&
 	AGP_MODE_GET_MODE_3(tstatus) &&
@@ -492,9 +492,9 @@ agp_generic_enable_v2(struct agp_softc *
 	int rq, sba, fw, rate;
 
 	tstatus = pci_conf_read(sc->as_pc, sc->as_tag,
-	sc->as_capoff + AGP_STATUS);
+	sc->as_capoff + PCI_AGP_STATUS);
 	mstatus = pci_conf_read(pa->pa_pc, pa->pa_tag,
-	capoff + AGP_STATUS);
+	capoff + PCI_AGP_STATUS);
 
 	/* Set RQ to the min of mode, tstatus and mstatus */
 	rq = AGP_MODE_GET_RQ(mode);
@@ -531,8 +531,9 @@ agp_generic_enable_v2(struct agp_softc *
 	command = AGP_MODE_SET_RATE(command, rate);
 	command = AGP_MODE_SET_AGP(command, 1);
 	pci_conf_write(sc->as_pc, sc->as_tag,
-	sc->as_capoff + AGP_COMMAND, command);
-	pci_conf_write(pa->pa_pc, pa->pa_tag, capoff + AGP_COMMAND, command);
+	sc->as_capoff + PCI_AGP_COMMAND, command);
+	pci_conf_write(pa->pa_pc, pa->pa_tag, capoff + PCI_AGP_COMMAND,
+		   command);
 
 	return 0;
 }
@@ -546,9 +547,9 @@ agp_generic_enable_v3(struct agp_softc *
 	int rq, sba, fw, rate, arqsz, cal;
 
 	tstatus = pci_conf_read(sc->as_pc, sc->as_tag,
-	sc->as_capoff + AGP_STATUS);
+	sc->as_capoff + PCI_AGP_STATUS);
 	mstatus = pci_conf_read(pa->pa_pc, pa->pa_tag,
-	capoff + AGP_STATUS);
+	capoff + PCI_AGP_STATUS);
 
 	/* Set RQ to the min of mode, tstatus and mstatus */
 	rq = AGP_MODE_GET_RQ(mode);
@@ -598,8 +599,9 @@ agp_generic_enable_v3(struct agp_softc *
 	command = AGP_MODE_SET_RATE(command, rate);
 	command = AGP_MODE_SET_AGP(command, 1);
 	pci_conf_write(sc->as_pc, sc->as_tag,
-	sc->as_capoff + AGP_COMMAND, command);
-	pci_conf_write(pa->pa_pc, pa->pa_tag, capoff + AGP_COMMAND, command);
+	sc->as_capoff + PCI_AGP_COMMAND, command);
+	pci_conf_write(pa->pa_pc, pa->pa_tag, capoff + PCI_AGP_COMMAND,
+		   command);
 
 	return 0;
 }
@@ -895,7 +897,7 @@ agp_info_user(struct agp_softc *sc, agp_
 	info->bridge_id = sc->as_id;
 	if (sc->as_capoff != 0)
 		info->agp_mode = pci_conf_read(sc->as_pc, sc->as_tag,
-	   sc->as_capoff + AGP_STATUS);
+	   sc->as_capoff + PCI_AGP_STATUS);
 	else
 		info->agp_mode = 0; /* i810 doesn't have real AGP */
 	info->aper_base = sc->as_apaddr;
@@ -1148,7 +1150,7 @@ agp_get_info(void *devcookie, struct agp
 	struct agp_softc *sc = devcookie;
 
 	info->ai_mode = pci_conf_read(sc->as_pc, sc->as_tag,
-	sc->as_capoff + AGP_STATUS);
+	sc->as_capoff + PCI_AGP_STATUS);
 	info->ai_aperture_base = sc->as_apaddr;
 	info->ai_aperture_size = sc->as_apsize;	/* XXXfvdl inconsistent */
 	info->ai_memory_allowed = sc->as_maxmem;

Index: src/sys/dev/pci/agpreg.h
diff -u src/sys/dev/pci/agpreg.h:1.23 src/sys/dev/pci/agpreg.h:1.24
--- src/sys/dev/pci/agpreg.h:1.23	Sun May  1 04:22:50 2016
+++ src/sys/dev/pci/agpreg.h	Mon Feb 27 14:13:56 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: agpreg.h,v 1.23 2016/05/01 04:22:50 nonaka Exp $	*/
+/*	$NetBSD: agpreg.h,v 1.24 2017/02/27 14:13:56 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2000 Doug Rabson
@@ -36,9 +36,6 @@
  */
 #define AGP_APBASE		0x10
 
-#define AGP_STATUS		0x4
-#define AGP_COMMAND		0x8
-
 /*
  * Config registers for Intel AGP chipsets.
  */

Index: src/sys/dev/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.160 src/sys/dev/pci/pci_subr.c:1.161
--- src/sys/dev/pci/pci_subr.c:1.160	Sun Feb 26 05:41:47 2017
+++ src/sys/dev/pci/pci_subr.c	Mon Feb 27 14:13:56 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.160 2017/02/26 05:41:47 msaitoh Exp $	*/
+/*	$NetBS

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

2017-02-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Feb 27 12:38:00 UTC 2017

Modified Files:
src/sys/arch/arm/nvidia: tegra_xusb.c

Log Message:
Attach the usb2 bus - missed in merge from nick-nhusb


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/nvidia/tegra_xusb.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/nvidia/tegra_xusb.c
diff -u src/sys/arch/arm/nvidia/tegra_xusb.c:1.2 src/sys/arch/arm/nvidia/tegra_xusb.c:1.3
--- src/sys/arch/arm/nvidia/tegra_xusb.c:1.2	Tue Jan  3 12:37:08 2017
+++ src/sys/arch/arm/nvidia/tegra_xusb.c	Mon Feb 27 12:38:00 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_xusb.c,v 1.2 2017/01/03 12:37:08 skrll Exp $ */
+/* $NetBSD: tegra_xusb.c,v 1.3 2017/02/27 12:38:00 skrll Exp $ */
 
 /*
  * Copyright (c) 2016 Jonathan A. Kollasch
@@ -30,7 +30,7 @@
 #include "opt_tegra.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_xusb.c,v 1.2 2017/01/03 12:37:08 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_xusb.c,v 1.3 2017/02/27 12:38:00 skrll Exp $");
 
 #include 
 #include 
@@ -374,6 +374,8 @@ tegra_xusb_mountroot(device_t self)
 
 	sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint);
 
+	sc->sc_child2 = config_found(self, &sc->sc_bus2, usbctlprint);
+
 	error = xusb_mailbox_send(psc, 0x0100);
 	if (error) {
 		aprint_error_dev(self, "send failed, error=%d\n", error);



CVS commit: src/sys/dev

2017-02-27 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Mon Feb 27 10:31:02 UTC 2017

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

Log Message:
Audio passes the atf test again.


To generate a diff of this commit:
cvs rdiff -u -r1.312 -r1.313 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.312 src/sys/dev/audio.c:1.313
--- src/sys/dev/audio.c:1.312	Sun Feb 26 16:22:55 2017
+++ src/sys/dev/audio.c	Mon Feb 27 10:31:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.312 2017/02/26 16:22:55 riastradh Exp $	*/
+/*	$NetBSD: audio.c,v 1.313 2017/02/27 10:31:02 nat Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss 
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.312 2017/02/26 16:22:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.313 2017/02/27 10:31:02 nat Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -3431,14 +3431,13 @@ audiostartp(struct audio_softc *sc, stru
 	vc->sc_pbus = true;
 	if (sc->sc_trigger_started == false) {
 		audio_mix(sc);
-
+		audio_mix(sc);
+		mutex_enter(sc->sc_intr_lock);
+		mix_write(sc);
 		vc = chan->vc;
 		vc->sc_mpr.s.outp =
 		audio_stream_add_outp(&vc->sc_mpr.s,
 		  vc->sc_mpr.s.outp, vc->sc_mpr.blksize);
-		audio_mix(sc);
-		mutex_enter(sc->sc_intr_lock);
-		mix_write(sc);
 		mix_write(sc);
 		cv_broadcast(&sc->sc_condvar);
 		mutex_exit(sc->sc_intr_lock);



CVS commit: src/sys/dev/pci

2017-02-27 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Feb 27 09:27:27 UTC 2017

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
fix Tx queue assignment when the number of H/W queues is less than ncpu.


To generate a diff of this commit:
cvs rdiff -u -r1.487 -r1.488 src/sys/dev/pci/if_wm.c

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.487 src/sys/dev/pci/if_wm.c:1.488
--- src/sys/dev/pci/if_wm.c:1.487	Fri Feb 24 10:09:21 2017
+++ src/sys/dev/pci/if_wm.c	Mon Feb 27 09:27:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.487 2017/02/24 10:09:21 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.488 2017/02/27 09:27:27 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -84,7 +84,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.487 2017/02/24 10:09:21 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.488 2017/02/27 09:27:27 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -6470,7 +6470,7 @@ wm_select_txqueue(struct ifnet *ifp, str
 	 * TODO:
 	 * distribute by flowid(RSS has value).
 	 */
-	return (cpuid + sc->sc_affinity_offset) % sc->sc_nqueues;
+return (cpuid + ncpu - sc->sc_affinity_offset) % sc->sc_nqueues;  
 }
 
 /*



CVS commit: src

2017-02-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Feb 27 08:26:53 UTC 2017

Modified Files:
src/sys/netinet: ip_carp.c
src/tests/net/carp: t_basic.sh

Log Message:
Make CARP on IPv6 work

It passes ATF tests but no more, no less.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/netinet/ip_carp.c
cvs rdiff -u -r1.3 -r1.4 src/tests/net/carp/t_basic.sh

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

Modified files:

Index: src/sys/netinet/ip_carp.c
diff -u src/sys/netinet/ip_carp.c:1.84 src/sys/netinet/ip_carp.c:1.85
--- src/sys/netinet/ip_carp.c:1.84	Thu Feb  2 02:52:10 2017
+++ src/sys/netinet/ip_carp.c	Mon Feb 27 08:26:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_carp.c,v 1.84 2017/02/02 02:52:10 ozaki-r Exp $	*/
+/*	$NetBSD: ip_carp.c,v 1.85 2017/02/27 08:26:53 ozaki-r Exp $	*/
 /*	$OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $	*/
 
 /*
@@ -33,7 +33,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.84 2017/02/02 02:52:10 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.85 2017/02/27 08:26:53 ozaki-r Exp $");
 
 /*
  * TODO:
@@ -252,6 +252,12 @@ carp_cksum(struct mbuf *m, int len)
 	return (in_cksum(m, len));
 }
 
+static __inline u_int16_t
+carp6_cksum(struct mbuf *m, uint32_t off, uint32_t len)
+{
+	return (in6_cksum(m, IPPROTO_CARP, off, len));
+}
+
 static void
 carp_hmac_prepare(struct carp_softc *sc)
 {
@@ -601,16 +607,13 @@ _carp6_proto_input(struct mbuf *m, int o
 		return;
 	}
 
-
 	/* verify the CARP checksum */
-	m->m_data += off;
-	if (carp_cksum(m, sizeof(*ch))) {
+	if (carp6_cksum(m, off, sizeof(*ch))) {
 		CARP_STATINC(CARP_STAT_BADSUM);
 		CARP_LOG(sc, ("checksum failed, on %s", rcvif->if_xname));
 		m_freem(m);
 		return;
 	}
-	m->m_data -= off;
 
 	carp_proto_input_c(m, ch, AF_INET6);
 	return;
@@ -1120,7 +1123,7 @@ carp_send_ad(void *v)
 		}
 	}
 #endif /* INET */
-#ifdef INET6_notyet
+#ifdef INET6
 	if (sc->sc_naddrs6) {
 		struct ip6_hdr *ip6;
 		struct ifaddr *ifa;
@@ -1161,7 +1164,7 @@ carp_send_ad(void *v)
 
 		ip6->ip6_dst.s6_addr16[0] = htons(0xff02);
 		ip6->ip6_dst.s6_addr8[15] = 0x12;
-		if (in6_setscope(&ip6->ip6_dst, sc->sc_carpdev, NULL) != 0) {
+		if (in6_setscope(&ip6->ip6_dst, &sc->sc_if, NULL) != 0) {
 			sc->sc_if.if_oerrors++;
 			m_freem(m);
 			CARP_LOG(sc, ("in6_setscope failed"));
@@ -1173,9 +1176,8 @@ carp_send_ad(void *v)
 		if (carp_prepare_ad(m, sc, ch_ptr))
 			goto retry_later;
 
-		m->m_data += sizeof(*ip6);
-		ch_ptr->carp_cksum = carp_cksum(m, len - sizeof(*ip6));
-		m->m_data -= sizeof(*ip6);
+		ch_ptr->carp_cksum = carp6_cksum(m, sizeof(*ip6),
+		len - sizeof(*ip6));
 
 		nanotime(&sc->sc_if.if_lastchange);
 		sc->sc_if.if_opackets++;
@@ -1530,7 +1532,7 @@ carp_setrun(struct carp_softc *sc, sa_fa
 			callout_schedule(&sc->sc_md_tmo, tvtohz(&tv));
 			break;
 #endif /* INET */
-#ifdef INET6_notyet
+#ifdef INET6
 		case AF_INET6:
 			callout_schedule(&sc->sc_md6_tmo, tvtohz(&tv));
 			break;
@@ -1538,7 +1540,7 @@ carp_setrun(struct carp_softc *sc, sa_fa
 		default:
 			if (sc->sc_naddrs)
 callout_schedule(&sc->sc_md_tmo, tvtohz(&tv));
-#ifdef INET6_notyet
+#ifdef INET6
 			if (sc->sc_naddrs6)
 callout_schedule(&sc->sc_md6_tmo, tvtohz(&tv));
 #endif /* INET6 */

Index: src/tests/net/carp/t_basic.sh
diff -u src/tests/net/carp/t_basic.sh:1.3 src/tests/net/carp/t_basic.sh:1.4
--- src/tests/net/carp/t_basic.sh:1.3	Mon Feb 27 07:25:59 2017
+++ src/tests/net/carp/t_basic.sh	Mon Feb 27 08:26:53 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: t_basic.sh,v 1.3 2017/02/27 07:25:59 ozaki-r Exp $
+#	$NetBSD: t_basic.sh,v 1.4 2017/02/27 08:26:53 ozaki-r Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -273,8 +273,6 @@ test_carp6_handover()
 {
 	local op=$1
 
-	atf_expect_fail 'The implementation of CARP on IPv6 is incomplete yet.'
-
 	rump_server_start $SOCK_CLIENT netinet6
 	rump_server_start $SOCK_MASTER netinet6
 	rump_server_start $SOCK_BACKUP netinet6