CVS commit: src

2015-04-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr  9 05:03:58 UTC 2015

Modified Files:
src/sys/kern: vfs_syscalls.c
src/tests/fs/vfs: t_vnops.c

Log Message:
Tests claim rename(..., x/.) yields EISDIR, so do that.  Fixes zfs.


To generate a diff of this commit:
cvs rdiff -u -r1.493 -r1.494 src/sys/kern/vfs_syscalls.c
cvs rdiff -u -r1.46 -r1.47 src/tests/fs/vfs/t_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/kern/vfs_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.493 src/sys/kern/vfs_syscalls.c:1.494
--- src/sys/kern/vfs_syscalls.c:1.493	Sun Feb 15 10:48:21 2015
+++ src/sys/kern/vfs_syscalls.c	Thu Apr  9 05:03:58 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.493 2015/02/15 10:48:21 martin Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.494 2015/04/09 05:03:58 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.493 2015/02/15 10:48:21 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.494 2015/04/09 05:03:58 riastradh Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_fileassoc.h
@@ -4286,7 +4286,7 @@ do_sys_renameat(struct lwp *l, int fromf
 	((tnd.ni_cnd.cn_namelen == 2) 
 		(tnd.ni_cnd.cn_nameptr[0] == '.') 
 		(tnd.ni_cnd.cn_nameptr[1] == '.'))) {
-		error = EINVAL;	/* XXX EISDIR?  */
+		error = EISDIR;
 		goto abort1;
 	}
 

Index: src/tests/fs/vfs/t_vnops.c
diff -u src/tests/fs/vfs/t_vnops.c:1.46 src/tests/fs/vfs/t_vnops.c:1.47
--- src/tests/fs/vfs/t_vnops.c:1.46	Thu Apr  9 05:02:28 2015
+++ src/tests/fs/vfs/t_vnops.c	Thu Apr  9 05:03:58 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_vnops.c,v 1.46 2015/04/09 05:02:28 riastradh Exp $	*/
+/*	$NetBSD: t_vnops.c,v 1.47 2015/04/09 05:03:58 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -274,8 +274,6 @@ rename_dir(const atf_tc_t *tc, const cha
 	md(pb1, mp, dir3/.);
 	if (rump_sys_rename(pb1, pb3) != -1 || errno != EINVAL)
 		atf_tc_fail_errno(rename 2);
-	if (FSTYPE_ZFS(tc))
-		atf_tc_expect_fail(PR kern/47656: Test known to be broken);
 	if (rump_sys_rename(pb3, pb1) != -1 || errno != EISDIR)
 		atf_tc_fail_errno(rename 3);
 



CVS commit: src/sys/kern

2015-04-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr  9 05:08:15 UTC 2015

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

Log Message:
But rename(..., x/..) is still supposed to yield EINVAL.  Go figure.


To generate a diff of this commit:
cvs rdiff -u -r1.494 -r1.495 src/sys/kern/vfs_syscalls.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/vfs_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.494 src/sys/kern/vfs_syscalls.c:1.495
--- src/sys/kern/vfs_syscalls.c:1.494	Thu Apr  9 05:03:58 2015
+++ src/sys/kern/vfs_syscalls.c	Thu Apr  9 05:08:15 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.494 2015/04/09 05:03:58 riastradh Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.495 2015/04/09 05:08:15 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.494 2015/04/09 05:03:58 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.495 2015/04/09 05:08:15 riastradh Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_fileassoc.h
@@ -4281,14 +4281,16 @@ do_sys_renameat(struct lwp *l, int fromf
 	 * until the VOP_RENAME protocol changes, because file systems
 	 * will no doubt begin to depend on this check.
 	 */
-	if (((tnd.ni_cnd.cn_namelen == 1) 
-		(tnd.ni_cnd.cn_nameptr[0] == '.')) ||
-	((tnd.ni_cnd.cn_namelen == 2) 
-		(tnd.ni_cnd.cn_nameptr[0] == '.') 
-		(tnd.ni_cnd.cn_nameptr[1] == '.'))) {
+	if ((tnd.ni_cnd.cn_namelen == 1)  (tnd.ni_cnd.cn_nameptr[0] == '.')) {
 		error = EISDIR;
 		goto abort1;
 	}
+	if ((tnd.ni_cnd.cn_namelen == 2) 
+	(tnd.ni_cnd.cn_nameptr[0] == '.') 
+	(tnd.ni_cnd.cn_nameptr[1] == '.')) {
+		error = EINVAL;
+		goto abort1;
+	}
 
 	/*
 	 * Get the mount point.  If the file system has been unmounted,



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

2015-04-08 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Apr  9 00:38:30 UTC 2015

Modified Files:
src/sys/arch/arm/cortex: gic.c

Log Message:
All SGIs are MPSAFE so establish them as such.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/cortex/gic.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/cortex/gic.c
diff -u src/sys/arch/arm/cortex/gic.c:1.16 src/sys/arch/arm/cortex/gic.c:1.17
--- src/sys/arch/arm/cortex/gic.c:1.16	Fri Mar 20 07:57:27 2015
+++ src/sys/arch/arm/cortex/gic.c	Thu Apr  9 00:38:29 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: gic.c,v 1.16 2015/03/20 07:57:27 skrll Exp $	*/
+/*	$NetBSD: gic.c,v 1.17 2015/04/09 00:38:29 matt Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,7 +34,7 @@
 #define _INTR_PRIVATE
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: gic.c,v 1.16 2015/03/20 07:57:27 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: gic.c,v 1.17 2015/04/09 00:38:29 matt Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -597,33 +597,33 @@ armgic_attach(device_t parent, device_t 
 		}
 	}
 #ifdef __HAVE_PIC_FAST_SOFTINTS
-	intr_establish(SOFTINT_BIO, IPL_SOFTBIO, IST_EDGE,
+	intr_establish(SOFTINT_BIO, IPL_SOFTBIO, IST_MPSAFE | IST_EDGE,
 	pic_handle_softint, (void *)SOFTINT_BIO);
-	intr_establish(SOFTINT_CLOCK, IPL_SOFTCLOCK, IST_EDGE,
+	intr_establish(SOFTINT_CLOCK, IPL_SOFTCLOCK, IST_MPSAFE | IST_EDGE,
 	pic_handle_softint, (void *)SOFTINT_CLOCK);
-	intr_establish(SOFTINT_NET, IPL_SOFTNET, IST_EDGE,
+	intr_establish(SOFTINT_NET, IPL_SOFTNET, IST_MPSAFE | IST_EDGE,
 	pic_handle_softint, (void *)SOFTINT_NET);
-	intr_establish(SOFTINT_SERIAL, IPL_SOFTSERIAL, IST_EDGE,
+	intr_establish(SOFTINT_SERIAL, IPL_SOFTSERIAL, IST_MPSAFE | IST_EDGE,
 	pic_handle_softint, (void *)SOFTINT_SERIAL);
 #endif
 #ifdef MULTIPROCESSOR
-	intr_establish(ARMGIC_SGI_IPIBASE + IPI_AST, IPL_VM, IST_EDGE,
-	pic_ipi_nop, (void *)-1);
-	intr_establish(ARMGIC_SGI_IPIBASE + IPI_XCALL, IPL_VM, IST_EDGE,
-	pic_ipi_xcall, (void *)-1);
-	intr_establish(ARMGIC_SGI_IPIBASE + IPI_GENERIC, IPL_VM, IST_EDGE,
-	pic_ipi_generic, (void *)-1);
-	intr_establish(ARMGIC_SGI_IPIBASE + IPI_NOP, IPL_VM, IST_EDGE,
-	pic_ipi_nop, (void *)-1);
-	intr_establish(ARMGIC_SGI_IPIBASE + IPI_SHOOTDOWN, IPL_VM, IST_EDGE,
-	pic_ipi_shootdown, (void *)-1);
+	intr_establish(ARMGIC_SGI_IPIBASE + IPI_AST, IPL_VM,
+	IST_MPSAFE | IST_EDGE, pic_ipi_nop, (void *)-1);
+	intr_establish(ARMGIC_SGI_IPIBASE + IPI_XCALL, IPL_VM,
+	IST_MPSAFE | IST_EDGE, pic_ipi_xcall, (void *)-1);
+	intr_establish(ARMGIC_SGI_IPIBASE + IPI_GENERIC, IPL_VM,
+	IST_MPSAFE | IST_EDGE, pic_ipi_generic, (void *)-1);
+	intr_establish(ARMGIC_SGI_IPIBASE + IPI_NOP, IPL_VM,
+	IST_MPSAFE | IST_EDGE, pic_ipi_nop, (void *)-1);
+	intr_establish(ARMGIC_SGI_IPIBASE + IPI_SHOOTDOWN, IPL_VM,
+	IST_MPSAFE | IST_EDGE, pic_ipi_shootdown, (void *)-1);
 #ifdef DDB
-	intr_establish(ARMGIC_SGI_IPIBASE + IPI_DDB, IPL_HIGH, IST_EDGE,
-	pic_ipi_ddb, NULL);
+	intr_establish(ARMGIC_SGI_IPIBASE + IPI_DDB, IPL_HIGH,
+	IST_MPSAFE | IST_EDGE, pic_ipi_ddb, NULL);
 #endif
 #ifdef __HAVE_PREEMPTION
-	intr_establish(ARMGIC_SGI_IPIBASE + IPI_KPREEMPT, IPL_VM, IST_EDGE,
-	pic_ipi_nop, (void *)-1);
+	intr_establish(ARMGIC_SGI_IPIBASE + IPI_KPREEMPT, IPL_VM,
+	IST_MPSAFE | IST_EDGE, pic_ipi_nop, (void *)-1);
 #endif
 	armgic_cpu_init(sc-sc_pic, curcpu());
 #endif



CVS commit: src

2015-04-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr  9 05:32:53 UTC 2015

Modified Files:
src/external/cddl/osnet/sys/sys: vnode.h
src/tests/fs/vfs: t_vnops.c

Log Message:
Fix vattr_init_mask: mode is mode_t, not u_short.

Fixes fs/vfs/t_vnops:zfs_attrs test.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/cddl/osnet/sys/sys/vnode.h
cvs rdiff -u -r1.47 -r1.48 src/tests/fs/vfs/t_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/external/cddl/osnet/sys/sys/vnode.h
diff -u src/external/cddl/osnet/sys/sys/vnode.h:1.12 src/external/cddl/osnet/sys/sys/vnode.h:1.13
--- src/external/cddl/osnet/sys/sys/vnode.h:1.12	Tue Oct 29 09:53:51 2013
+++ src/external/cddl/osnet/sys/sys/vnode.h	Thu Apr  9 05:32:53 2015
@@ -1,5 +1,5 @@
 
-/*	$NetBSD: vnode.h,v 1.12 2013/10/29 09:53:51 hannken Exp $	*/
+/*	$NetBSD: vnode.h,v 1.13 2015/04/09 05:32:53 riastradh Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -521,7 +521,7 @@ vattr_init_mask(vattr_t *vap)
 		vap-va_mask |= AT_ATIME;
 	if (vap-va_mtime.tv_sec != VNOVAL)
 		vap-va_mask |= AT_MTIME;
-	if (vap-va_mode != (u_short)VNOVAL)
+	if (vap-va_mode != (mode_t)VNOVAL)
 		vap-va_mask |= AT_MODE;
 }
 

Index: src/tests/fs/vfs/t_vnops.c
diff -u src/tests/fs/vfs/t_vnops.c:1.47 src/tests/fs/vfs/t_vnops.c:1.48
--- src/tests/fs/vfs/t_vnops.c:1.47	Thu Apr  9 05:03:58 2015
+++ src/tests/fs/vfs/t_vnops.c	Thu Apr  9 05:32:53 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_vnops.c,v 1.47 2015/04/09 05:03:58 riastradh Exp $	*/
+/*	$NetBSD: t_vnops.c,v 1.48 2015/04/09 05:32:53 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -641,8 +641,6 @@ attrs(const atf_tc_t *tc, const char *mp
 
 	RL(rump_sys_stat(TESTFILE, sb2));
 #define CHECK(a) ATF_REQUIRE_EQ(sb.a, sb2.a)
-	if (FSTYPE_ZFS(tc))
-		atf_tc_expect_fail(PR kern/47656: Test known to be broken);
 	if (!(FSTYPE_MSDOS(tc) || FSTYPE_SYSVBFS(tc))) {
 		CHECK(st_uid);
 		CHECK(st_gid);



CVS commit: src

2015-04-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr  9 05:02:28 UTC 2015

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_dir.c
src/tests/fs/vfs: t_vnops.c

Log Message:
Fix return code of rmdir(nonempty) in zfs: ENOTEMPTY, not EEXIST.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_dir.c
cvs rdiff -u -r1.45 -r1.46 src/tests/fs/vfs/t_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/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_dir.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_dir.c:1.9 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_dir.c:1.10
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_dir.c:1.9	Thu Oct 18 14:29:44 2012
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_dir.c	Thu Apr  9 05:02:28 2015
@@ -801,7 +801,7 @@ zfs_link_destroy(zfs_dirlock_t *dl, znod
 		if (zp_is_dir  !zfs_dirempty(zp)) {	/* dir not empty */
 			mutex_exit(zp-z_lock);
 			vn_vfsunlock(vp);
-			return (EEXIST);
+			return (ENOTEMPTY);
 		}
 		if (zp-z_phys-zp_links = zp_is_dir) {
 			zfs_panic_recover(zfs: link count on vnode %p is %u, 

Index: src/tests/fs/vfs/t_vnops.c
diff -u src/tests/fs/vfs/t_vnops.c:1.45 src/tests/fs/vfs/t_vnops.c:1.46
--- src/tests/fs/vfs/t_vnops.c:1.45	Tue Mar 24 23:24:55 2015
+++ src/tests/fs/vfs/t_vnops.c	Thu Apr  9 05:02:28 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_vnops.c,v 1.45 2015/03/24 23:24:55 riastradh Exp $	*/
+/*	$NetBSD: t_vnops.c,v 1.46 2015/04/09 05:02:28 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -179,8 +179,6 @@ dir_notempty(const atf_tc_t *tc, const c
 	rump_sys_close(fd);
 
 	rv = rump_sys_rmdir(pb);
-	if (FSTYPE_ZFS(tc))
-		atf_tc_expect_fail(PR kern/47656: Test known to be broken);
 	if (rv != -1 || errno != ENOTEMPTY)
 		atf_tc_fail(non-empty directory removed succesfully);
 



CVS commit: src/sys/arch/arm

2015-04-08 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Apr  8 21:43:30 UTC 2015

Modified Files:
src/sys/arch/arm/marvell: mvsoc_intr.h
src/sys/arch/arm/pic: pic.c picvar.h

Log Message:
Add __HAVE_PIC_HAVE_PENDING_INTRS and define it if __HAVE_PIC_SET_PRIORITY
is undefined (also define in mvsoc_intr.h since their use of the latter is
peculiar).  This new define controls whether the pending interrupt logic is
compiled.  The GIC doesn't use pending interrupts since it uses the priority
level on the GIC to control delivery of interrupts, thus there can never
be a pending interrupt.  The kernel shrinks about 4KB with the removal of
the pending interupt support,


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/marvell/mvsoc_intr.h
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/pic/picvar.h

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

Modified files:

Index: src/sys/arch/arm/marvell/mvsoc_intr.h
diff -u src/sys/arch/arm/marvell/mvsoc_intr.h:1.4 src/sys/arch/arm/marvell/mvsoc_intr.h:1.5
--- src/sys/arch/arm/marvell/mvsoc_intr.h:1.4	Tue Mar 18 06:46:14 2014
+++ src/sys/arch/arm/marvell/mvsoc_intr.h	Wed Apr  8 21:43:30 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: mvsoc_intr.h,v 1.4 2014/03/18 06:46:14 matt Exp $	*/
+/*	$NetBSD: mvsoc_intr.h,v 1.5 2015/04/08 21:43:30 matt Exp $	*/
 /*
  * Copyright (c) 2010 KIYOHARA Takashi
  * All rights reserved.
@@ -33,6 +33,7 @@
 
 #if defined(ARMADAXP)
 #define __HAVE_PIC_SET_PRIORITY
+#define __HAVE_PIC_PENDING_INTRS
 #endif
 #endif
 

Index: src/sys/arch/arm/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.27 src/sys/arch/arm/pic/pic.c:1.28
--- src/sys/arch/arm/pic/pic.c:1.27	Wed Apr  8 18:10:08 2015
+++ src/sys/arch/arm/pic/pic.c	Wed Apr  8 21:43:30 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.27 2015/04/08 18:10:08 matt Exp $	*/
+/*	$NetBSD: pic.c,v 1.28 2015/04/08 21:43:30 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include opt_multiprocessor.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.27 2015/04/08 18:10:08 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.28 2015/04/08 21:43:30 matt Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -60,6 +60,7 @@ __KERNEL_RCSID(0, $NetBSD: pic.c,v 1.27
 
 #include arm/pic/picvar.h
 
+#if defined(__HAVE_PIC_PENDING_INTRS)
 static uint32_t
 	pic_find_pending_irqs_by_ipl(struct pic_softc *, size_t, uint32_t, int);
 static struct pic_softc *
@@ -68,14 +69,15 @@ static void
 	pic_deliver_irqs(struct pic_softc *, int, void *);
 static void
 	pic_list_deliver_irqs(register_t, int, void *);
+volatile uint32_t pic_blocked_pics;
+volatile uint32_t pic_pending_pics;
+volatile uint32_t pic_pending_ipls;
+#endif /* __HAVE_PIC_PENDING_INTRS */
 
 struct pic_softc *pic_list[PIC_MAXPICS];
 #if PIC_MAXPICS  32
 #error PIC_MAXPICS  32 not supported
 #endif
-volatile uint32_t pic_blocked_pics;
-volatile uint32_t pic_pending_pics;
-volatile uint32_t pic_pending_ipls;
 struct intrsource *pic_sources[PIC_MAXMAXSOURCES];
 struct intrsource *pic__iplsources[PIC_MAXMAXSOURCES];
 struct intrsource **pic_iplsource[NIPL] = {
@@ -196,6 +198,7 @@ pic_handle_intr(void *arg)
 	return rv  0;
 }
 
+#if defined(__HAVE_PIC_PENDING_INTRS)
 void
 pic_mark_pending_source(struct pic_softc *pic, struct intrsource *is)
 {
@@ -283,6 +286,7 @@ pic_find_pending_irqs_by_ipl(struct pic_
 		pending = ~irq_mask;
 	}
 }
+#endif /* __HAVE_PIC_PENDING_INTRS */
 
 void
 pic_dispatch(struct intrsource *is, void *frame)
@@ -318,6 +322,7 @@ pic_dispatch(struct intrsource *is, void
 	percpu_putref(is-is_pic-pic_percpu);
 }
 
+#if defined(__HAVE_PIC_PENDING_INTRS)
 void
 pic_deliver_irqs(struct pic_softc *pic, int ipl, void *frame)
 {
@@ -483,6 +488,7 @@ pic_list_deliver_irqs(register_t psw, in
 	}
 	atomic_and_32(pic_pending_ipls, ~ipl_mask);
 }
+#endif /* __HAVE_PIC_PENDING_INTRS */
 
 void
 pic_do_pending_ints(register_t psw, int newipl, void *frame)
@@ -492,6 +498,7 @@ pic_do_pending_ints(register_t psw, int 
 		KASSERTMSG(ci-ci_cpl == IPL_HIGH, cpl %d, ci-ci_cpl);
 		return;
 	}
+#if defined(__HAVE_PIC_PENDING_INTRS)
 	while ((pic_pending_ipls  ~__BIT(newipl))  __BIT(newipl)) {
 		KASSERT(pic_pending_ipls  __BIT(NIPL));
 		for (;;) {
@@ -505,6 +512,7 @@ pic_do_pending_ints(register_t psw, int 
 			pic_list_unblock_irqs();
 		}
 	}
+#endif /* __HAVE_PIC_PENDING_INTRS */
 #ifdef __HAVE_PREEEMPTION
 	if (newipl == IPL_NONE  (ci-ci_astpending  __BIT(1))) {
 		pic_set_priority(ci, IPL_SCHED);

Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.11 src/sys/arch/arm/pic/picvar.h:1.12
--- src/sys/arch/arm/pic/picvar.h:1.11	Wed Oct 29 14:14:14 2014
+++ src/sys/arch/arm/pic/picvar.h	Wed Apr  8 21:43:30 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.11 2014/10/29 14:14:14 skrll Exp $	*/
+/*	$NetBSD: picvar.h,v 1.12 

CVS commit: src/share/mk

2015-04-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Apr  8 06:03:09 UTC 2015

Modified Files:
src/share/mk: bsd.own.mk

Log Message:
remove support to look for GCC 4.5 in gcc.old.


To generate a diff of this commit:
cvs rdiff -u -r1.844 -r1.845 src/share/mk/bsd.own.mk

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

Modified files:

Index: src/share/mk/bsd.own.mk
diff -u src/share/mk/bsd.own.mk:1.844 src/share/mk/bsd.own.mk:1.845
--- src/share/mk/bsd.own.mk:1.844	Sun Mar  1 07:46:04 2015
+++ src/share/mk/bsd.own.mk	Wed Apr  8 06:03:09 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.own.mk,v 1.844 2015/03/01 07:46:04 mrg Exp $
+#	$NetBSD: bsd.own.mk,v 1.845 2015/04/08 06:03:09 mrg Exp $
 
 # This needs to be before bsd.init.mk
 .if defined(BSD_MK_COMPAT_FILE)
@@ -78,9 +78,7 @@ MKGCCCMDS?=	no
 # We import the old gcc as gcc.old when upgrading.  EXTERNAL_GCC_SUBDIR is
 # set to the relevant subdirectory in src/external/gpl3 for his HAVE_GCC.
 #
-.if ${HAVE_GCC} == 45
-EXTERNAL_GCC_SUBDIR=	gcc.old
-.elif ${HAVE_GCC} == 48
+.if ${HAVE_GCC} == 48
 EXTERNAL_GCC_SUBDIR=	gcc
 .else
 EXTERNAL_GCC_SUBDIR=	/does/not/exist



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

2015-04-08 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Apr  8 12:07:40 UTC 2015

Modified Files:
src/sys/arch/arm/arm32: cpuswitch.S

Log Message:
Make TPIDRPRW_IS_CURLWP work for MULTIPROCESSOR.
get curcpu() from new lwp.
don't set lwp l_cpu (already done).
Remove support for __HAVE_UNNESTED_INTRS
don't set curlwp until after we are done saving the oldlwp.
disable interrupts when setting curlwp/kernel stack pointer.
Overall, these changes simplify cpu_switchto even more.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/arch/arm/arm32/cpuswitch.S

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/arm32/cpuswitch.S
diff -u src/sys/arch/arm/arm32/cpuswitch.S:1.89 src/sys/arch/arm/arm32/cpuswitch.S:1.90
--- src/sys/arch/arm/arm32/cpuswitch.S:1.89	Tue Mar 24 21:09:11 2015
+++ src/sys/arch/arm/arm32/cpuswitch.S	Wed Apr  8 12:07:40 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpuswitch.S,v 1.89 2015/03/24 21:09:11 skrll Exp $	*/
+/*	$NetBSD: cpuswitch.S,v 1.90 2015/04/08 12:07:40 matt Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -87,10 +87,10 @@
 #include arm/asm.h
 #include arm/locore.h
 
-	RCSID($NetBSD: cpuswitch.S,v 1.89 2015/03/24 21:09:11 skrll Exp $)
+	RCSID($NetBSD: cpuswitch.S,v 1.90 2015/04/08 12:07:40 matt Exp $)
 
 /* LINTSTUB: include sys/param.h */
-	
+
 #undef IRQdisable
 #undef IRQenable
 
@@ -138,38 +138,8 @@ ENTRY(cpu_switchto)
 
 #ifdef TPIDRPRW_IS_CURCPU
 	GET_CURCPU(r5)
-#elif defined(TPIDRPRW_IS_CURLWP)
-	mrc	p15, 0, r0, c13, c0, 4		/* get old lwp (r4 maybe 0) */
-	ldr	r5, [r0, #(L_CPU)]		/* get cpu from old lwp */
-#elif !defined(MULTIPROCESSOR) 
-	ldr	r5, [r6, #L_CPU]		/* get cpu from new lwp */
-#else
-#error curcpu() method not defined
-#endif
-
-	/* rem: r4 = old lwp */
-	/* rem: r5 = curcpu() */
-	/* rem: r6 = new lwp */
-	
-#ifndef __HAVE_UNNESTED_INTRS
-	IRQdisable
-#endif
-
-#ifdef MULTIPROCESSOR
-	str	r5, [r6, #(L_CPU)]
 #else
-	/* l-l_cpu initialized in fork1() for single-processor */
-#endif
-
-#if defined(TPIDRPRW_IS_CURLWP)
-	mcr	p15, 0, r6, c13, c0, 4		/* set current lwp */
-#endif
-	/* We have a new curlwp now so make a note it */
-	str	r6, [r5, #(CI_CURLWP)]
-
-	/* At this point we can allow IRQ's again. */
-#ifndef __HAVE_UNNESTED_INTRS
-	IRQenable
+	ldr	r5, [r6, #L_CPU]		/* get cpu from new lwp */
 #endif
 
 	/* rem: r4 = old lwp */
@@ -226,9 +196,26 @@ ENTRY(cpu_switchto)
 	/* Restore saved context */
 
 .Ldo_switch:
+	/* rem: r4 = old lwp */
+	/* rem: r5 = curcpu() */
+	/* rem: r6 = new lwp */
+
+	IRQdisable
+#if defined(TPIDRPRW_IS_CURLWP)
+	mcr	p15, 0, r6, c13, c0, 4		/* set current lwp */
+#endif
+
+	/* We have a new curlwp now so make a note of it */
+	str	r6, [r5, #(CI_CURLWP)]
 	/* Get the new pcb */
 	ldr	r7, [r6, #(L_PCB)]
 
+	/* make sure we are using the new lwp's stack */
+	ldr	sp, [r7, #(PCB_KSP)]
+
+	/* At this point we can allow IRQ's again. */
+	IRQenable
+
 	/* rem: r4 = old lwp */
 	/* rem: r5 = curcpu() */
 	/* rem: r6 = new lwp */
@@ -292,14 +279,13 @@ ENTRY(cpu_switchto)
 	ldr	r10, [r7, #(PCB_R10)]
 	ldr	r11, [r7, #(PCB_R11)]
 	ldr	r12, [r7, #(PCB_R12)]
-	ldr	r13, [r7, #(PCB_KSP)]	/* sp */
 #elif defined(_ARM_ARCH_DWORD_OK)
 	ldrd	r8, r9, [r7, #(PCB_R8)]
 	ldrd	r10, r11, [r7, #(PCB_R10)]
-	ldrd	r12, r13, [r7, #(PCB_R12)]	/* sp */
+	ldr	r12, [r7, #(PCB_R12)]
 #else
 	add	r0, r7, #PCB_R8
-	ldmia	r0, {r8-r13}
+	ldmia	r0, {r8-r12}
 #endif
 
 	/* Record the old lwp for pmap_activate()'s benefit */
@@ -410,9 +396,7 @@ ENTRY_NP(softint_switch)
 	/* this is an invariant so load before disabling intrs */
 	ldr	r2, [r5, #(L_PCB)]	/* get new lwp's pcb */
 
-#ifndef __HAVE_UNNESTED_INTRS
 	IRQdisable
-#endif
 	/*
 	 * We're switching to a bound LWP so its l_cpu is already correct.
 	 */
@@ -429,10 +413,7 @@ ENTRY_NP(softint_switch)
 	ldr	sp, [r5, #(L_MD_TF)]	/* get new lwp's stack ptr */
 
 	/* At this point we can allow IRQ's again. */
-#ifndef __HAVE_UNNESTED_INTRS
 	IRQenable
-#endif
-
 	/* r1 still has ipl */
 	mov	r0, r4			/* r0 has pinned (old) lwp */
 	bl	_C_LABEL(softint_dispatch)
@@ -441,14 +422,12 @@ ENTRY_NP(softint_switch)
 	 */
 	ldr	r2, [r4, #(L_PCB)]	/* get pinned lwp's pcb */
 
-#ifndef __HAVE_UNNESTED_INTRS
-	IRQdisable
-#endif
 	/*
 	 * We don't need to restore all the registers since another lwp was
 	 * never executed.  But we do need the SP from the formerly pinned lwp.
 	 */
 
+	IRQdisable
 #if defined(TPIDRPRW_IS_CURLWP)
 	mcr	p15, 0, r4, c13, c0, 4		/* restore pinned lwp */
 #endif



CVS commit: src/sys/arch/arm

2015-04-08 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Apr  8 07:29:44 UTC 2015

Modified Files:
src/sys/arch/arm/arm: arm_machdep.c
src/sys/arch/arm/include: cpu.h

Log Message:
Add an agnostic version of curlwp and curcpu() for modules since they won't
know if the kernel was built with TPIDRPRW_IS_CUR{LWP,CPU} or not.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arm/arm/arm_machdep.c
cvs rdiff -u -r1.85 -r1.86 src/sys/arch/arm/include/cpu.h

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

Modified files:

Index: src/sys/arch/arm/arm/arm_machdep.c
diff -u src/sys/arch/arm/arm/arm_machdep.c:1.43 src/sys/arch/arm/arm/arm_machdep.c:1.44
--- src/sys/arch/arm/arm/arm_machdep.c:1.43	Wed Oct 29 14:14:14 2014
+++ src/sys/arch/arm/arm/arm_machdep.c	Wed Apr  8 07:29:44 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm_machdep.c,v 1.43 2014/10/29 14:14:14 skrll Exp $	*/
+/*	$NetBSD: arm_machdep.c,v 1.44 2015/04/08 07:29:44 matt Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -76,10 +76,11 @@
 #include opt_cputypes.h
 #include opt_arm_debug.h
 #include opt_multiprocessor.h
+#include opt_modular.h
 
 #include sys/param.h
 
-__KERNEL_RCSID(0, $NetBSD: arm_machdep.c,v 1.43 2014/10/29 14:14:14 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: arm_machdep.c,v 1.44 2015/04/08 07:29:44 matt Exp $);
 
 #include sys/exec.h
 #include sys/proc.h
@@ -212,7 +213,7 @@ setregs(struct lwp *l, struct exec_packa
 void
 startlwp(void *arg)
 {
-	ucontext_t *uc = arg; 
+	ucontext_t *uc = (ucontext_t *)arg; 
 	lwp_t *l = curlwp;
 	int error __diagused;
 
@@ -306,3 +307,17 @@ ucas_ras_check(trapframe_t *tf)
 		tf-tf_pc = (vaddr_t)ucas_32_ras_start;
 	}
 }
+
+#ifdef MODULAR
+struct lwp *
+arm_curlwp(void)
+{
+	return curlwp;
+}
+
+struct cpu_info *
+arm_curcpu(void)
+{
+	return curcpu();
+}
+#endif

Index: src/sys/arch/arm/include/cpu.h
diff -u src/sys/arch/arm/include/cpu.h:1.85 src/sys/arch/arm/include/cpu.h:1.86
--- src/sys/arch/arm/include/cpu.h:1.85	Thu Apr  2 03:22:51 2015
+++ src/sys/arch/arm/include/cpu.h	Wed Apr  8 07:29:44 2015
@@ -180,7 +180,15 @@ struct cpu_info {
 
 extern struct cpu_info cpu_info_store;
 
-#if defined(TPIDRPRW_IS_CURLWP)
+struct lwp *arm_curlwp(void);
+struct cpu_info *arm_curcpu(void);
+
+#if defined(_MODULE)
+
+#define	curlwp		arm_curlwp()
+#define curcpu()	arm_curcpu()
+
+#elif defined(TPIDRPRW_IS_CURLWP)
 static inline struct lwp *
 _curlwp(void)
 {



CVS commit: src/sys/arch/arm

2015-04-08 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Apr  8 08:35:54 UTC 2015

Modified Files:
src/sys/arch/arm/ep93xx: ep93xx_intr.c
src/sys/arch/arm/ixp12x0: ixp12x0_intr.c

Log Message:
Include sys/lwp.h instead of arm/cpu.h

sys/lwp.h is preferred because arm/cpu.h has a dependency on sys/lwp.h.

Suggested by skrll@ and matt@


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/ep93xx/ep93xx_intr.c
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/arm/ixp12x0/ixp12x0_intr.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/ep93xx/ep93xx_intr.c
diff -u src/sys/arch/arm/ep93xx/ep93xx_intr.c:1.23 src/sys/arch/arm/ep93xx/ep93xx_intr.c:1.24
--- src/sys/arch/arm/ep93xx/ep93xx_intr.c:1.23	Tue Apr  7 03:19:24 2015
+++ src/sys/arch/arm/ep93xx/ep93xx_intr.c	Wed Apr  8 08:35:54 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: ep93xx_intr.c,v 1.23 2015/04/07 03:19:24 ozaki-r Exp $ */
+/* $NetBSD: ep93xx_intr.c,v 1.24 2015/04/08 08:35:54 ozaki-r Exp $ */
 
 /*
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ep93xx_intr.c,v 1.23 2015/04/07 03:19:24 ozaki-r Exp $);
+__KERNEL_RCSID(0, $NetBSD: ep93xx_intr.c,v 1.24 2015/04/08 08:35:54 ozaki-r Exp $);
 
 /*
  * Interrupt support for the Cirrus Logic EP93XX
@@ -43,12 +43,12 @@ __KERNEL_RCSID(0, $NetBSD: ep93xx_intr.
 #include sys/systm.h
 #include sys/malloc.h
 #include sys/termios.h
+#include sys/lwp.h
 
 #include sys/bus.h
 #include sys/intr.h
 
 #include arm/locore.h
-#include arm/cpu.h
 
 #include arm/ep93xx/ep93xxreg.h 
 #include arm/ep93xx/ep93xxvar.h 

Index: src/sys/arch/arm/ixp12x0/ixp12x0_intr.c
diff -u src/sys/arch/arm/ixp12x0/ixp12x0_intr.c:1.30 src/sys/arch/arm/ixp12x0/ixp12x0_intr.c:1.31
--- src/sys/arch/arm/ixp12x0/ixp12x0_intr.c:1.30	Tue Apr  7 03:19:25 2015
+++ src/sys/arch/arm/ixp12x0/ixp12x0_intr.c	Wed Apr  8 08:35:54 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: ixp12x0_intr.c,v 1.30 2015/04/07 03:19:25 ozaki-r Exp $ */
+/* $NetBSD: ixp12x0_intr.c,v 1.31 2015/04/08 08:35:54 ozaki-r Exp $ */
 
 /*
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ixp12x0_intr.c,v 1.30 2015/04/07 03:19:25 ozaki-r Exp $);
+__KERNEL_RCSID(0, $NetBSD: ixp12x0_intr.c,v 1.31 2015/04/08 08:35:54 ozaki-r Exp $);
 
 /*
  * Interrupt support for the Intel ixp12x0
@@ -42,9 +42,9 @@ __KERNEL_RCSID(0, $NetBSD: ixp12x0_intr
 #include sys/termios.h
 #include sys/bus.h
 #include sys/intr.h
+#include sys/lwp.h
 
 #include arm/locore.h
-#include arm/cpu.h
 
 #include arm/ixp12x0/ixp12x0reg.h 
 #include arm/ixp12x0/ixp12x0var.h 



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

2015-04-08 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Apr  8 16:37:32 UTC 2015

Modified Files:
src/sys/arch/arm/arm: arm_machdep.c

Log Message:
Small tweaks for preemption.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/arm/arm/arm_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/arm/arm/arm_machdep.c
diff -u src/sys/arch/arm/arm/arm_machdep.c:1.44 src/sys/arch/arm/arm/arm_machdep.c:1.45
--- src/sys/arch/arm/arm/arm_machdep.c:1.44	Wed Apr  8 07:29:44 2015
+++ src/sys/arch/arm/arm/arm_machdep.c	Wed Apr  8 16:37:32 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm_machdep.c,v 1.44 2015/04/08 07:29:44 matt Exp $	*/
+/*	$NetBSD: arm_machdep.c,v 1.45 2015/04/08 16:37:32 matt Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
 
 #include sys/param.h
 
-__KERNEL_RCSID(0, $NetBSD: arm_machdep.c,v 1.44 2015/04/08 07:29:44 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: arm_machdep.c,v 1.45 2015/04/08 16:37:32 matt Exp $);
 
 #include sys/exec.h
 #include sys/proc.h
@@ -266,7 +266,7 @@ cpu_need_resched(struct cpu_info *ci, in
 #ifdef __HAVE_PREEMPTION
 		atomic_or_uint(l-l_dopreempt, DOPREEMPT_ACTIVE);
 		if (ci == cur_ci) {
-			softint_trigger(SOFTINT_KPREEMPT);
+			ci-ci_astpending |= 2;
 		} else {
 			ipi = IPI_KPREEMPT;
 			goto send_ipi;
@@ -274,7 +274,7 @@ cpu_need_resched(struct cpu_info *ci, in
 #endif /* __HAVE_PREEMPTION */
 		return;
 	}
-	ci-ci_astpending = 1;
+	ci-ci_astpending |= 1;
 #ifdef MULTIPROCESSOR
 	if (ci == curcpu() || !immed)
 		return;



CVS commit: src/crypto/external/bsd/openssh/dist

2015-04-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr  8 15:49:47 UTC 2015

Modified Files:
src/crypto/external/bsd/openssh/dist: dispatch.c packet.c

Log Message:
ssh_packet_write_wait() returns number of bytes now; check for negative
for error instead of 0. Fixes ssh command restrictions, reported by
Tobias Nygren.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/crypto/external/bsd/openssh/dist/dispatch.c
cvs rdiff -u -r1.16 -r1.17 src/crypto/external/bsd/openssh/dist/packet.c

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

Modified files:

Index: src/crypto/external/bsd/openssh/dist/dispatch.c
diff -u src/crypto/external/bsd/openssh/dist/dispatch.c:1.4 src/crypto/external/bsd/openssh/dist/dispatch.c:1.5
--- src/crypto/external/bsd/openssh/dist/dispatch.c:1.4	Fri Apr  3 19:58:19 2015
+++ src/crypto/external/bsd/openssh/dist/dispatch.c	Wed Apr  8 11:49:46 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dispatch.c,v 1.4 2015/04/03 23:58:19 christos Exp $	*/
+/*	$NetBSD: dispatch.c,v 1.5 2015/04/08 15:49:46 christos Exp $	*/
 /* $OpenBSD: dispatch.c,v 1.26 2015/02/12 20:34:19 dtucker Exp $ */
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include includes.h
-__RCSID($NetBSD: dispatch.c,v 1.4 2015/04/03 23:58:19 christos Exp $);
+__RCSID($NetBSD: dispatch.c,v 1.5 2015/04/08 15:49:46 christos Exp $);
 #include sys/types.h
 
 #include signal.h
@@ -51,7 +51,7 @@ dispatch_protocol_error(int type, u_int3
 	if ((r = sshpkt_start(ssh, SSH2_MSG_UNIMPLEMENTED)) != 0 ||
 	(r = sshpkt_put_u32(ssh, seq)) != 0 ||
 	(r = sshpkt_send(ssh)) != 0 ||
-	(r = ssh_packet_write_wait(ssh)) != 0)
+	(r = ssh_packet_write_wait(ssh))  0)
 		sshpkt_fatal(ssh, __func__, r);
 	return 0;
 }

Index: src/crypto/external/bsd/openssh/dist/packet.c
diff -u src/crypto/external/bsd/openssh/dist/packet.c:1.16 src/crypto/external/bsd/openssh/dist/packet.c:1.17
--- src/crypto/external/bsd/openssh/dist/packet.c:1.16	Fri Apr  3 19:58:19 2015
+++ src/crypto/external/bsd/openssh/dist/packet.c	Wed Apr  8 11:49:46 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: packet.c,v 1.16 2015/04/03 23:58:19 christos Exp $	*/
+/*	$NetBSD: packet.c,v 1.17 2015/04/08 15:49:46 christos Exp $	*/
 /* $OpenBSD: packet.c,v 1.208 2015/02/13 18:57:00 markus Exp $ */
 /*
  * Author: Tatu Ylonen y...@cs.hut.fi
@@ -39,7 +39,7 @@
  */
 
 #include includes.h
-__RCSID($NetBSD: packet.c,v 1.16 2015/04/03 23:58:19 christos Exp $);
+__RCSID($NetBSD: packet.c,v 1.17 2015/04/08 15:49:46 christos Exp $);
 #include sys/param.h	/* MIN roundup */
 #include sys/types.h
 #include sys/queue.h
@@ -1452,7 +1452,7 @@ ssh_packet_read_poll1(struct ssh *ssh, u
 		if (emsg != NULL) {
 			error(%s, emsg);
 			if ((r = sshpkt_disconnect(ssh, %s, emsg)) != 0 ||
-			(r = ssh_packet_write_wait(ssh)) != 0)
+			(r = ssh_packet_write_wait(ssh))  0)
 	return r;
 			return SSH_ERR_CONN_CORRUPT;
 		}
@@ -1487,7 +1487,7 @@ ssh_packet_read_poll1(struct ssh *ssh, u
 		error(%s: len %d != sshbuf_len %zd, __func__,
 		len, sshbuf_len(state-incoming_packet));
 		if ((r = sshpkt_disconnect(ssh, invalid packet length)) != 0 ||
-		(r = ssh_packet_write_wait(ssh)) != 0)
+		(r = ssh_packet_write_wait(ssh))  0)
 			return r;
 		return SSH_ERR_CONN_CORRUPT;
 	}
@@ -1497,7 +1497,7 @@ ssh_packet_read_poll1(struct ssh *ssh, u
 	if (checksum != stored_checksum) {
 		error(Corrupted check bytes on input);
 		if ((r = sshpkt_disconnect(ssh, connection corrupted)) != 0 ||
-		(r = ssh_packet_write_wait(ssh)) != 0)
+		(r = ssh_packet_write_wait(ssh))  0)
 			return r;
 		return SSH_ERR_CONN_CORRUPT;
 	}
@@ -1521,7 +1521,7 @@ ssh_packet_read_poll1(struct ssh *ssh, u
 	if (*typep  SSH_MSG_MIN || *typep  SSH_MSG_MAX) {
 		error(Invalid ssh1 packet type: %d, *typep);
 		if ((r = sshpkt_disconnect(ssh, invalid packet type)) != 0 ||
-		(r = ssh_packet_write_wait(ssh)) != 0)
+		(r = ssh_packet_write_wait(ssh))  0)
 			return r;
 		return SSH_ERR_PROTOCOL_ERROR;
 	}
@@ -1694,7 +1694,7 @@ ssh_packet_read_poll2(struct ssh *ssh, u
 	if (padlen  4)	{
 		if ((r = sshpkt_disconnect(ssh,
 		Corrupted padlen %d on input., padlen)) != 0 ||
-		(r = ssh_packet_write_wait(ssh)) != 0)
+		(r = ssh_packet_write_wait(ssh))  0)
 			return r;
 		return SSH_ERR_CONN_CORRUPT;
 	}
@@ -1727,7 +1727,7 @@ ssh_packet_read_poll2(struct ssh *ssh, u
 	if (*typep  SSH2_MSG_MIN || *typep = SSH2_MSG_LOCAL_MIN) {
 		if ((r = sshpkt_disconnect(ssh,
 		Invalid ssh2 packet type: %d, *typep)) != 0 ||
-		(r = ssh_packet_write_wait(ssh)) != 0)
+		(r = ssh_packet_write_wait(ssh))  0)
 			return r;
 		return SSH_ERR_PROTOCOL_ERROR;
 	}
@@ -1896,7 +1896,7 @@ ssh_packet_send_debug(struct ssh *ssh, c
 		(r = sshpkt_send(ssh)) != 0)
 			fatal(%s: %s, __func__, ssh_err(r));
 	}
-	if ((r = ssh_packet_write_wait(ssh)) != 0)
+	if ((r = ssh_packet_write_wait(ssh))  0)
 		fatal(%s: %s, 

CVS commit: src/sys/arch/arm/include/arm32

2015-04-08 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Apr  8 16:38:42 UTC 2015

Modified Files:
src/sys/arch/arm/include/arm32: frame.h

Log Message:
CI_ASTPENDING is now a bitfield and low bit is for user ASTs.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/arm/include/arm32/frame.h

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

Modified files:

Index: src/sys/arch/arm/include/arm32/frame.h
diff -u src/sys/arch/arm/include/arm32/frame.h:1.39 src/sys/arch/arm/include/arm32/frame.h:1.40
--- src/sys/arch/arm/include/arm32/frame.h:1.39	Wed Feb 26 01:56:51 2014
+++ src/sys/arch/arm/include/arm32/frame.h	Wed Apr  8 16:38:42 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: frame.h,v 1.39 2014/02/26 01:56:51 matt Exp $	*/
+/*	$NetBSD: frame.h,v 1.40 2015/04/08 16:38:42 matt Exp $	*/
 
 /*
  * Copyright (c) 1994-1997 Mark Brinicombe.
@@ -174,7 +174,7 @@ void validate_trapframe(trapframe_t *, i
  */
 #define	ENABLE_ALIGNMENT_FAULTS		\
 	and	r7, r0, #(PSR_MODE)	/* Test for USR32 mode */	;\
-	teq	r7, #(PSR_USR32_MODE)	;\
+	cmp	r7, #(PSR_USR32_MODE)	;\
 	GET_CURCPU(r4)			/* r4 = cpuinfo */		;\
 	bne	1f			/* Not USR mode skip AFLT */	;\
 	ldr	r1, [r4, #CI_CURLWP]	/* get curlwp from cpu_info */	;\
@@ -197,10 +197,10 @@ void validate_trapframe(trapframe_t *, i
 	DO_PENDING_SOFTINTS		;\
 	GET_CPSR(r5)			/* save CPSR */			;\
 	CPSID_I(r1, r5)			/* Disable interrupts */	;\
-	teq	r7, #(PSR_USR32_MODE)	/* Returning to USR mode? */	;\
+	cmp	r7, #(PSR_USR32_MODE)	/* Returning to USR mode? */	;\
 	bne	3f			/* Nope, get out now */		;\
 1:	ldr	r1, [r4, #CI_ASTPENDING] /* Pending AST? */		;\
-	teq	r1, #0x		;\
+	tst	r1, #0x0001		;\
 	bne	2f			/* Yup. Go deal with it */	;\
 	ldr	r1, [r4, #CI_CURLWP]	/* get curlwp from cpu_info */	;\
 	ldr	r0, [r1, #L_MD_FLAGS]	/* get md_flags from lwp */	;\
@@ -213,7 +213,7 @@ void validate_trapframe(trapframe_t *, i
 	adr	lr, 3f			;\
 	B_CF_CONTROL(r2)		/* Set new CTRL reg value */	;\
 	/* NOTREACHED */		\
-2:	mov	r1, #0x		;\
+2:	bic	r1, r1, #0x0001	;\
 	str	r1, [r4, #CI_ASTPENDING] /* Clear astpending */		;\
 	CPSIE_I(r5, r5)			/* Restore interrupts */	;\
 	mov	r0, sp			;\
@@ -235,12 +235,12 @@ void validate_trapframe(trapframe_t *, i
 	DO_PENDING_SOFTINTS		;\
 	GET_CPSR(r5)			/* save CPSR */			;\
 	CPSID_I(r1, r5)			/* Disable interrupts */	;\
-	teq	r7, #(PSR_USR32_MODE)	;\
+	cmp	r7, #(PSR_USR32_MODE)	;\
 	bne	2f			/* Nope, get out now */		;\
 1:	ldr	r1, [r4, #CI_ASTPENDING] /* Pending AST? */		;\
-	teq	r1, #0x		;\
+	tst	r1, #0x0001		;\
 	beq	2f			/* Nope. Just bail */		;\
-	mov	r1, #0x		;\
+	bic	r1, r1, #0x0001	;\
 	str	r1, [r4, #CI_ASTPENDING] /* Clear astpending */		;\
 	CPSIE_I(r5, r5)			/* Restore interrupts */	;\
 	mov	r0, sp			;\
@@ -288,7 +288,7 @@ LOCK_CAS_DEBUG_LOCALS
 #define	LOCK_CAS_CHECK			 \
 	ldr	r0, [sp]		/* get saved PSR */		;\
 	and	r0, r0, #(PSR_MODE)	/* check for SVC32 mode */	;\
-	teq	r0, #(PSR_SVC32_MODE)	;\
+	cmp	r0, #(PSR_SVC32_MODE)	;\
 	bne	99f			/* nope, get out now */		;\
 	ldr	r0, [sp, #(TF_PC)]	;\
 	ldr	r1, .L_lock_cas_end	;\



CVS commit: src/sys/kern

2015-04-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Apr  8 14:13:55 UTC 2015

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

Log Message:
Fix a bit of indentation.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/kern/kern_rndq.c

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

Modified files:

Index: src/sys/kern/kern_rndq.c
diff -u src/sys/kern/kern_rndq.c:1.42 src/sys/kern/kern_rndq.c:1.43
--- src/sys/kern/kern_rndq.c:1.42	Wed Apr  8 14:11:21 2015
+++ src/sys/kern/kern_rndq.c	Wed Apr  8 14:13:55 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rndq.c,v 1.42 2015/04/08 14:11:21 riastradh Exp $	*/
+/*	$NetBSD: kern_rndq.c,v 1.43 2015/04/08 14:13:55 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_rndq.c,v 1.42 2015/04/08 14:11:21 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_rndq.c,v 1.43 2015/04/08 14:13:55 riastradh Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -577,10 +577,9 @@ rnd_init(void)
 	c ?  with counter\n : \n);
 	if (boot_rsp != NULL) {
 		mutex_spin_enter(rndpool_mtx);
-			rndpool_add_data(rnd_pool, boot_rsp-data,
-	 sizeof(boot_rsp-data),
-	 MIN(boot_rsp-entropy,
-	 RND_POOLBITS / 2));
+		rndpool_add_data(rnd_pool, boot_rsp-data,
+		sizeof(boot_rsp-data),
+		MIN(boot_rsp-entropy, RND_POOLBITS / 2));
 		if (rndpool_get_entropy_count(rnd_pool) 
 		RND_ENTROPY_THRESHOLD * 8) {
 	rnd_initial_entropy = 1;



CVS commit: src/sys/dev/pci

2015-04-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Apr  8 13:47:06 UTC 2015

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

Log Message:
Don't forget to bus_dmamap_unload.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/viornd.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/viornd.c
diff -u src/sys/dev/pci/viornd.c:1.5 src/sys/dev/pci/viornd.c:1.6
--- src/sys/dev/pci/viornd.c:1.5	Thu Nov  6 01:42:01 2014
+++ src/sys/dev/pci/viornd.c	Wed Apr  8 13:47:06 2015
@@ -1,4 +1,4 @@
-/* 	$NetBSD: viornd.c,v 1.5 2014/11/06 01:42:01 pooka Exp $ */
+/* 	$NetBSD: viornd.c,v 1.6 2015/04/08 13:47:06 riastradh Exp $ */
 /*	$OpenBSD: viornd.c,v 1.1 2014/01/21 21:14:58 sf Exp $	*/
 
 /*
@@ -205,6 +205,7 @@ viornd_attach( device_t parent, device_t
 	viornd_get(VIORND_BUFSIZE, sc);
 	return;
 vio_failed:
+	bus_dmamap_unload(vsc-sc_dmat, sc-sc_dmamap);
 load_failed:
 	bus_dmamap_destroy(vsc-sc_dmat, sc-sc_dmamap);
 create_failed:



CVS commit: src/sys/kern

2015-04-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Apr  8 14:04:47 UTC 2015

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

Log Message:
Gather (some) rnd_skew state into a cacheline-aligned static struct.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/kern/kern_rndq.c

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

Modified files:

Index: src/sys/kern/kern_rndq.c
diff -u src/sys/kern/kern_rndq.c:1.39 src/sys/kern/kern_rndq.c:1.40
--- src/sys/kern/kern_rndq.c:1.39	Wed Apr  8 13:45:01 2015
+++ src/sys/kern/kern_rndq.c	Wed Apr  8 14:04:47 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rndq.c,v 1.39 2015/04/08 13:45:01 riastradh Exp $	*/
+/*	$NetBSD: kern_rndq.c,v 1.40 2015/04/08 14:04:47 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_rndq.c,v 1.39 2015/04/08 13:45:01 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_rndq.c,v 1.40 2015/04/08 14:04:47 riastradh Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -169,7 +169,6 @@ static krndsource_t rnd_source_anonymous
 krndsource_t rnd_printf_source, rnd_autoconf_source;
 
 void *rnd_process, *rnd_wakeup;
-struct callout skew_callout, skew_stop_callout;
 
 void	  		rnd_wakeup_readers(void);
 static inline uint32_t	rnd_counter(void);
@@ -432,46 +431,53 @@ rnd_dv_estimate(krndsource_t *rs, uint32
 }
 
 #if defined(__HAVE_CPU_COUNTER)
-kmutex_trnd_skew_mtx;
+static struct {
+	kmutex_t	lock;
+	struct callout	callout;
+	struct callout	stop_callout;
+} rnd_skew __cacheline_aligned;
 
-static void rnd_skew(void *);
+static void rnd_skew_intr(void *);
 
 static void
 rnd_skew_enable(krndsource_t *rs, bool enabled)
 {
-	mutex_spin_enter(rnd_skew_mtx);
+
+	mutex_spin_enter(rnd_skew.lock);
 	if (enabled) {
-		rnd_skew(rs);
+		rnd_skew_intr(rs);
 	} else {
-		callout_stop(skew_callout);
+		callout_stop(rnd_skew.callout);
 	}
-	mutex_spin_exit(rnd_skew_mtx);
+	mutex_spin_exit(rnd_skew.lock);
 }
 
 static void
-rnd_skew_stop(void *arg)
+rnd_skew_stop_intr(void *arg)
 {
-	mutex_spin_enter(rnd_skew_mtx);
-	callout_stop(skew_callout);
-	mutex_spin_exit(rnd_skew_mtx);
+
+	mutex_spin_enter(rnd_skew.lock);
+	callout_stop(rnd_skew.callout);
+	mutex_spin_exit(rnd_skew.lock);
 }
 
 static void
 rnd_skew_get(size_t bytes, void *priv)
 {
 	krndsource_t *skewsrcp = priv;
+
 	if (RND_ENABLED(skewsrcp)) {
 		/* Measure for 30s */
-		if (mutex_tryenter(rnd_skew_mtx)) {
-			callout_schedule(skew_stop_callout, hz * 30);
-			callout_schedule(skew_callout, 1);
-			mutex_spin_exit(rnd_skew_mtx);
+		if (mutex_tryenter(rnd_skew.lock)) {
+			callout_schedule(rnd_skew.stop_callout, hz * 30);
+			callout_schedule(rnd_skew.callout, 1);
+			mutex_spin_exit(rnd_skew.lock);
 		}
 	}
 }
 
 static void
-rnd_skew(void *arg)
+rnd_skew_intr(void *arg)
 {
 	static krndsource_t skewsrc;
 	static int live, flipflop;
@@ -484,7 +490,7 @@ rnd_skew(void *arg)
 	 */
 	if (__predict_false(!live)) {
 		/* XXX must be spin, taken with rndpool_mtx held */
-		mutex_init(rnd_skew_mtx, MUTEX_DEFAULT, IPL_VM);
+		mutex_init(rnd_skew.lock, MUTEX_DEFAULT, IPL_VM);
 		rndsource_setcb(skewsrc, rnd_skew_get, skewsrc);
 		rndsource_setenable(skewsrc, rnd_skew_enable);
 		rnd_attach_source(skewsrc, callout, RND_TYPE_SKEW,
@@ -494,18 +500,18 @@ rnd_skew(void *arg)
 		live = 1;
 		return;
 	}
-	mutex_spin_enter(rnd_skew_mtx);
+	mutex_spin_enter(rnd_skew.lock);
 	flipflop = !flipflop;
 
 	if (RND_ENABLED(skewsrc)) {
 		if (flipflop) {
 			rnd_add_uint32(skewsrc, rnd_counter());
-			callout_schedule(skew_callout, hz / 10);
+			callout_schedule(rnd_skew.callout, hz / 10);
 		} else {
-			callout_schedule(skew_callout, 1);
+			callout_schedule(rnd_skew.callout, 1);
 		}
 	}
-	mutex_spin_exit(rnd_skew_mtx);
+	mutex_spin_exit(rnd_skew.lock);
 }
 #endif
 
@@ -571,11 +577,11 @@ rnd_init(void)
  	 *
 	 */
 #if defined(__HAVE_CPU_COUNTER)
-	callout_init(skew_callout, CALLOUT_MPSAFE);
-	callout_init(skew_stop_callout, CALLOUT_MPSAFE);
-	callout_setfunc(skew_callout, rnd_skew, NULL);
-	callout_setfunc(skew_stop_callout, rnd_skew_stop, NULL);
-	rnd_skew(NULL);
+	callout_init(rnd_skew.callout, CALLOUT_MPSAFE);
+	callout_init(rnd_skew.stop_callout, CALLOUT_MPSAFE);
+	callout_setfunc(rnd_skew.callout, rnd_skew_intr, NULL);
+	callout_setfunc(rnd_skew.stop_callout, rnd_skew_stop_intr, NULL);
+	rnd_skew_intr(NULL);
 #endif
 
 	rnd_printf_verbose(rnd: initialised (%u)%s, RND_POOLBITS,



CVS commit: src/sys/dev/usb

2015-04-08 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Apr  8 12:38:13 UTC 2015

Modified Files:
src/sys/dev/usb: if_axe.c if_axen.c if_rum.c

Log Message:
Added pmf hook.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/usb/if_axe.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/if_axen.c
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/usb/if_rum.c

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

Modified files:

Index: src/sys/dev/usb/if_axe.c
diff -u src/sys/dev/usb/if_axe.c:1.67 src/sys/dev/usb/if_axe.c:1.68
--- src/sys/dev/usb/if_axe.c:1.67	Sun Aug 10 16:44:36 2014
+++ src/sys/dev/usb/if_axe.c	Wed Apr  8 12:38:13 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axe.c,v 1.67 2014/08/10 16:44:36 tls Exp $	*/
+/*	$NetBSD: if_axe.c,v 1.68 2015/04/08 12:38:13 nonaka Exp $	*/
 /*	$OpenBSD: if_axe.c,v 1.96 2010/01/09 05:33:08 jsg Exp $ */
 
 /*
@@ -89,7 +89,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_axe.c,v 1.67 2014/08/10 16:44:36 tls Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_axe.c,v 1.68 2015/04/08 12:38:13 nonaka Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_inet.h
@@ -852,6 +852,9 @@ axe_attach(device_t parent, device_t sel
 	splx(s);
 
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc-axe_udev, sc-axe_dev);
+
+	if (!pmf_device_register(self, NULL, NULL))
+		aprint_error_dev(self, couldn't establish power handler\n);
 }
 
 int
@@ -867,6 +870,8 @@ axe_detach(device_t self, int flags)
 	if (!sc-axe_attached)
 		return 0;
 
+	pmf_device_deregister(self);
+
 	sc-axe_dying = true;
 
 	/*

Index: src/sys/dev/usb/if_axen.c
diff -u src/sys/dev/usb/if_axen.c:1.4 src/sys/dev/usb/if_axen.c:1.5
--- src/sys/dev/usb/if_axen.c:1.4	Thu Feb 12 13:07:37 2015
+++ src/sys/dev/usb/if_axen.c	Wed Apr  8 12:38:13 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axen.c,v 1.4 2015/02/12 13:07:37 nonaka Exp $	*/
+/*	$NetBSD: if_axen.c,v 1.5 2015/04/08 12:38:13 nonaka Exp $	*/
 /*	$OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_axen.c,v 1.4 2015/02/12 13:07:37 nonaka Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_axen.c,v 1.5 2015/04/08 12:38:13 nonaka Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_inet.h
@@ -803,6 +803,9 @@ axen_attach(device_t parent, device_t se
 	splx(s);
 
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc-axen_udev,sc-axen_dev);
+
+	if (!pmf_device_register(self, NULL, NULL))
+		aprint_error_dev(self, couldn't establish power handler\n);
 }
 
 static int
@@ -818,6 +821,8 @@ axen_detach(device_t self, int flags)
 	if (!sc-axen_attached)
 		return 0;
 
+	pmf_device_deregister(self);
+
 	sc-axen_dying = true;
 
 	/*

Index: src/sys/dev/usb/if_rum.c
diff -u src/sys/dev/usb/if_rum.c:1.49 src/sys/dev/usb/if_rum.c:1.50
--- src/sys/dev/usb/if_rum.c:1.49	Wed Jan  7 07:05:48 2015
+++ src/sys/dev/usb/if_rum.c	Wed Apr  8 12:38:13 2015
@@ -1,5 +1,5 @@
 /*	$OpenBSD: if_rum.c,v 1.40 2006/09/18 16:20:20 damien Exp $	*/
-/*	$NetBSD: if_rum.c,v 1.49 2015/01/07 07:05:48 ozaki-r Exp $	*/
+/*	$NetBSD: if_rum.c,v 1.50 2015/04/08 12:38:13 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2005-2007 Damien Bergamini damien.bergam...@free.fr
@@ -24,7 +24,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_rum.c,v 1.49 2015/01/07 07:05:48 ozaki-r Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_rum.c,v 1.50 2015/04/08 12:38:13 nonaka Exp $);
 
 #include sys/param.h
 #include sys/sockio.h
@@ -483,6 +483,9 @@ rum_attach(device_t parent, device_t sel
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc-sc_udev,
 	sc-sc_dev);
 
+	if (!pmf_device_register(self, NULL, NULL))
+		aprint_error_dev(self, couldn't establish power handler\n);
+
 	return;
 }
 
@@ -497,6 +500,8 @@ rum_detach(device_t self, int flags)
 	if (!ifp-if_softc)
 		return 0;
 
+	pmf_device_deregister(self);
+
 	s = splusb();
 
 	rum_stop(ifp, 1);



CVS commit: src/sys/kern

2015-04-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Apr  8 14:08:49 UTC 2015

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

Log Message:
Don't do broken lazy initialization.  Just do it up front.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/kern/kern_rndq.c

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

Modified files:

Index: src/sys/kern/kern_rndq.c
diff -u src/sys/kern/kern_rndq.c:1.40 src/sys/kern/kern_rndq.c:1.41
--- src/sys/kern/kern_rndq.c:1.40	Wed Apr  8 14:04:47 2015
+++ src/sys/kern/kern_rndq.c	Wed Apr  8 14:08:49 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rndq.c,v 1.40 2015/04/08 14:04:47 riastradh Exp $	*/
+/*	$NetBSD: kern_rndq.c,v 1.41 2015/04/08 14:08:49 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_rndq.c,v 1.40 2015/04/08 14:04:47 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_rndq.c,v 1.41 2015/04/08 14:08:49 riastradh Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -435,6 +435,7 @@ static struct {
 	kmutex_t	lock;
 	struct callout	callout;
 	struct callout	stop_callout;
+	krndsource_t	source;
 } rnd_skew __cacheline_aligned;
 
 static void rnd_skew_intr(void *);
@@ -466,6 +467,7 @@ rnd_skew_get(size_t bytes, void *priv)
 {
 	krndsource_t *skewsrcp = priv;
 
+	KASSERT(skewsrcp == rnd_skew.source);
 	if (RND_ENABLED(skewsrcp)) {
 		/* Measure for 30s */
 		if (mutex_tryenter(rnd_skew.lock)) {
@@ -479,8 +481,7 @@ rnd_skew_get(size_t bytes, void *priv)
 static void
 rnd_skew_intr(void *arg)
 {
-	static krndsource_t skewsrc;
-	static int live, flipflop;
+	static int flipflop;
 
 	/*
 	 * Even on systems with seemingly stable clocks, the
@@ -488,24 +489,12 @@ rnd_skew_intr(void *arg)
 	 * about every 2 calls.
 	 *
 	 */
-	if (__predict_false(!live)) {
-		/* XXX must be spin, taken with rndpool_mtx held */
-		mutex_init(rnd_skew.lock, MUTEX_DEFAULT, IPL_VM);
-		rndsource_setcb(skewsrc, rnd_skew_get, skewsrc);
-		rndsource_setenable(skewsrc, rnd_skew_enable);
-		rnd_attach_source(skewsrc, callout, RND_TYPE_SKEW,
-  RND_FLAG_COLLECT_VALUE|
-  RND_FLAG_ESTIMATE_VALUE|
-  RND_FLAG_HASCB|RND_FLAG_HASENABLE);
-		live = 1;
-		return;
-	}
 	mutex_spin_enter(rnd_skew.lock);
 	flipflop = !flipflop;
 
-	if (RND_ENABLED(skewsrc)) {
+	if (RND_ENABLED(rnd_skew.source)) {
 		if (flipflop) {
-			rnd_add_uint32(skewsrc, rnd_counter());
+			rnd_add_uint32(rnd_skew.source, rnd_counter());
 			callout_schedule(rnd_skew.callout, hz / 10);
 		} else {
 			callout_schedule(rnd_skew.callout, 1);
@@ -577,10 +566,17 @@ rnd_init(void)
  	 *
 	 */
 #if defined(__HAVE_CPU_COUNTER)
+	/* IPL_VM because taken while rndpool_mtx is held.  */
+	mutex_init(rnd_skew.lock, MUTEX_DEFAULT, IPL_VM);
 	callout_init(rnd_skew.callout, CALLOUT_MPSAFE);
 	callout_init(rnd_skew.stop_callout, CALLOUT_MPSAFE);
 	callout_setfunc(rnd_skew.callout, rnd_skew_intr, NULL);
 	callout_setfunc(rnd_skew.stop_callout, rnd_skew_stop_intr, NULL);
+	rndsource_setcb(rnd_skew.source, rnd_skew_get, rnd_skew.source);
+	rndsource_setenable(rnd_skew.source, rnd_skew_enable);
+	rnd_attach_source(rnd_skew.source, callout, RND_TYPE_SKEW,
+	RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_VALUE|
+	RND_FLAG_HASCB|RND_FLAG_HASENABLE);
 	rnd_skew_intr(NULL);
 #endif
 



CVS commit: src/sys

2015-04-08 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Wed Apr  8 13:31:42 UTC 2015

Modified Files:
src/sys/rump: rump.sysmap
src/sys/rump/include/rump: rump_syscalls.h
src/sys/rump/librump/rumpkern: rump_syscalls.c
src/sys/rump/librump/rumpvfs: rumpvfs_syscalls.c
src/sys/sys: syscallargs.h

Log Message:
regen after syscall update


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/rump.sysmap
cvs rdiff -u -r1.82 -r1.83 src/sys/rump/include/rump/rump_syscalls.h
cvs rdiff -u -r1.107 -r1.108 src/sys/rump/librump/rumpkern/rump_syscalls.c
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/librump/rumpvfs/rumpvfs_syscalls.c
cvs rdiff -u -r1.260 -r1.261 src/sys/sys/syscallargs.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/rump/rump.sysmap
diff -u src/sys/rump/rump.sysmap:1.2 src/sys/rump/rump.sysmap:1.3
--- src/sys/rump/rump.sysmap:1.2	Fri Jul 25 08:27:36 2014
+++ src/sys/rump/rump.sysmap	Wed Apr  8 13:31:42 2015
@@ -100,6 +100,7 @@
 254  sys_nomodule   _ksem_getvalue rump___sysimpl__ksem_getvalue
 255  sys_nomodule   _ksem_destroy  rump___sysimpl__ksem_destroy
 256  sys_nomodule   _ksem_timedwaitrump___sysimpl__ksem_timedwait
+270  sys___posix_rename __posix_rename rump___sysimpl___posix_rename
 274  sys_lchmod lchmod rump___sysimpl_lchmod
 275  sys_lchown lchown rump___sysimpl_lchown
 276  sys_nomodule   lutimesrump___sysimpl_lutimes

Index: src/sys/rump/include/rump/rump_syscalls.h
diff -u src/sys/rump/include/rump/rump_syscalls.h:1.82 src/sys/rump/include/rump/rump_syscalls.h:1.83
--- src/sys/rump/include/rump/rump_syscalls.h:1.82	Sat Mar  7 16:40:05 2015
+++ src/sys/rump/include/rump/rump_syscalls.h	Wed Apr  8 13:31:42 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: rump_syscalls.h,v 1.82 2015/03/07 16:40:05 christos Exp $ */
+/* $NetBSD: rump_syscalls.h,v 1.83 2015/04/08 13:31:42 justin Exp $ */
 
 /*
  * System call protos in rump namespace.
@@ -108,6 +108,10 @@
 #define RUMP_SYS_RENAME_AIO_CANCEL rump___sysimpl_aio_cancel
 #endif
 
+#ifndef RUMP_SYS_RENAME___POSIX_RENAME
+#define RUMP_SYS_RENAME___POSIX_RENAME rump___sysimpl___posix_rename
+#endif
+
 #ifndef RUMP_SYS_RENAME_LISTXATTR
 #define RUMP_SYS_RENAME_LISTXATTR rump___sysimpl_listxattr
 #endif
@@ -937,6 +941,7 @@ int rump_sys__ksem_trywait(intptr_t) __R
 int rump_sys__ksem_getvalue(intptr_t, unsigned int *) __RENAME(RUMP_SYS_RENAME__KSEM_GETVALUE);
 int rump_sys__ksem_destroy(intptr_t) __RENAME(RUMP_SYS_RENAME__KSEM_DESTROY);
 int rump_sys__ksem_timedwait(intptr_t, const struct timespec *) __RENAME(RUMP_SYS_RENAME__KSEM_TIMEDWAIT);
+int rump_sys___posix_rename(const char *, const char *) __RENAME(RUMP_SYS_RENAME___POSIX_RENAME);
 int rump_sys_lchmod(const char *, mode_t) __RENAME(RUMP_SYS_RENAME_LCHMOD);
 int rump_sys_lchown(const char *, uid_t, gid_t) __RENAME(RUMP_SYS_RENAME_LCHOWN);
 int rump_sys_lutimes(const char *, const struct timeval *) __RENAME(RUMP_SYS_RENAME_LUTIMES);

Index: src/sys/rump/librump/rumpkern/rump_syscalls.c
diff -u src/sys/rump/librump/rumpkern/rump_syscalls.c:1.107 src/sys/rump/librump/rumpkern/rump_syscalls.c:1.108
--- src/sys/rump/librump/rumpkern/rump_syscalls.c:1.107	Sun Mar  8 20:32:21 2015
+++ src/sys/rump/librump/rumpkern/rump_syscalls.c	Wed Apr  8 13:31:42 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: rump_syscalls.c,v 1.107 2015/03/08 20:32:21 christos Exp $ */
+/* $NetBSD: rump_syscalls.c,v 1.108 2015/04/08 13:31:42 justin Exp $ */
 
 /*
  * System call vector and marshalling for rump.
@@ -15,7 +15,7 @@
 
 #ifdef __NetBSD__
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rump_syscalls.c,v 1.107 2015/03/08 20:32:21 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: rump_syscalls.c,v 1.108 2015/04/08 13:31:42 justin Exp $);
 
 #include sys/fstypes.h
 #include sys/proc.h
@@ -2954,6 +2954,35 @@ __weak_alias(__ksem_timedwait,rump___sys
 __strong_alias(_sys__ksem_timedwait,rump___sysimpl__ksem_timedwait);
 #endif /* RUMP_KERNEL_IS_LIBC */
 
+int rump___sysimpl___posix_rename(const char *, const char *);
+int
+rump___sysimpl___posix_rename(const char * from, const char * to)
+{
+	register_t retval[2];
+	int error = 0;
+	int rv = -1;
+	struct sys___posix_rename_args callarg;
+
+	memset(callarg, 0, sizeof(callarg));
+	SPARG(callarg, from) = from;
+	SPARG(callarg, to) = to;
+
+	error = rsys_syscall(SYS___posix_rename, callarg, sizeof(callarg), retval);
+	rsys_seterrno(error);
+	if (error == 0) {
+		if (sizeof(int)  sizeof(register_t))
+			rv = *(int *)retval;
+		else
+			rv = *retval;
+	}
+	return rv;
+}
+#ifdef RUMP_KERNEL_IS_LIBC
+__weak_alias(__posix_rename,rump___sysimpl___posix_rename);
+__weak_alias(___posix_rename,rump___sysimpl___posix_rename);
+__strong_alias(_sys___posix_rename,rump___sysimpl___posix_rename);
+#endif /* RUMP_KERNEL_IS_LIBC */
+
 int rump___sysimpl_lchmod(const 

CVS commit: src/sys/dev/usb

2015-04-08 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Apr  8 12:29:42 UTC 2015

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

Log Message:
Add pmf hook.

fix PR/49783 USB WiFi ural0 rejects hw.acpi.sleep.state=3.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/usb/if_ural.c

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

Modified files:

Index: src/sys/dev/usb/if_ural.c
diff -u src/sys/dev/usb/if_ural.c:1.44 src/sys/dev/usb/if_ural.c:1.45
--- src/sys/dev/usb/if_ural.c:1.44	Tue Jan 22 12:40:43 2013
+++ src/sys/dev/usb/if_ural.c	Wed Apr  8 12:29:42 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ural.c,v 1.44 2013/01/22 12:40:43 jmcneill Exp $ */
+/*	$NetBSD: if_ural.c,v 1.45 2015/04/08 12:29:42 nonaka Exp $ */
 /*	$FreeBSD: /repoman/r/ncvs/src/sys/dev/usb/if_ural.c,v 1.40 2006/06/02 23:14:40 sam Exp $	*/
 
 /*-
@@ -24,7 +24,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_ural.c,v 1.44 2013/01/22 12:40:43 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_ural.c,v 1.45 2015/04/08 12:29:42 nonaka Exp $);
 
 #include sys/param.h
 #include sys/sockio.h
@@ -524,6 +524,9 @@ ural_attach(device_t parent, device_t se
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc-sc_udev,
 	sc-sc_dev);
 
+	if (!pmf_device_register(self, NULL, NULL))
+		aprint_error_dev(self, couldn't establish power handler\n);
+
 	return;
 }
 
@@ -535,6 +538,8 @@ ural_detach(device_t self, int flags)
 	struct ifnet *ifp = sc-sc_if;
 	int s;
 
+	pmf_device_deregister(self);
+
 	s = splusb();
 
 	ural_stop(ifp, 1);



CVS commit: src/lib/libc/softfloat

2015-04-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr  8 13:16:37 UTC 2015

Modified Files:
src/lib/libc/softfloat: Makefile.inc

Log Message:
Restrict the arm compiler optimization hack to gcc 4.5


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/lib/libc/softfloat/Makefile.inc

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/softfloat/Makefile.inc
diff -u src/lib/libc/softfloat/Makefile.inc:1.19 src/lib/libc/softfloat/Makefile.inc:1.20
--- src/lib/libc/softfloat/Makefile.inc:1.19	Sun Aug 10 23:39:08 2014
+++ src/lib/libc/softfloat/Makefile.inc	Wed Apr  8 13:16:37 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.19 2014/08/10 23:39:08 matt Exp $
+#	$NetBSD: Makefile.inc,v 1.20 2015/04/08 13:16:37 martin Exp $
 
 SOFTFLOAT_BITS?=64
 .PATH:		${ARCHDIR}/softfloat \
@@ -31,7 +31,7 @@ SRCS+=		${SRCS.softfloat}
 
 # XXX
 .if defined(HAVE_GCC)
-. if (${LIBC_MACHINE_CPU} == arm)
+. if (${LIBC_MACHINE_CPU} == arm)  (${HAVE_GCC} == 45)
 # See doc/HACKS for more information.
 COPTS.softfloat.c+=	-Wno-enum-compare
 COPTS.softfloat.c+=	${${ACTIVE_CXX} == gcc:? -fno-tree-vrp :}



CVS commit: src/sys/kern

2015-04-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Apr  8 13:24:23 UTC 2015

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

Log Message:
Don't read past the end of the sample buffer...  (Seriously???)


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/kern/kern_rndq.c

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

Modified files:

Index: src/sys/kern/kern_rndq.c
diff -u src/sys/kern/kern_rndq.c:1.37 src/sys/kern/kern_rndq.c:1.38
--- src/sys/kern/kern_rndq.c:1.37	Wed Apr  8 03:14:29 2015
+++ src/sys/kern/kern_rndq.c	Wed Apr  8 13:24:23 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rndq.c,v 1.37 2015/04/08 03:14:29 riastradh Exp $	*/
+/*	$NetBSD: kern_rndq.c,v 1.38 2015/04/08 13:24:23 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_rndq.c,v 1.37 2015/04/08 03:14:29 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_rndq.c,v 1.38 2015/04/08 13:24:23 riastradh Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -1070,7 +1070,7 @@ rnd_process_events(void)
 		SIMPLEQ_REMOVE_HEAD(dq_samples, next);
 		source = sample-source;
 		entropy = sample-entropy;
-		sample_count = sample-cursor + 1;
+		sample_count = sample-cursor;
 
 		/*
 		 * Don't provide a side channel for timing attacks on



CVS commit: src/sys/kern

2015-04-08 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Wed Apr  8 13:24:25 UTC 2015

Modified Files:
src/sys/kern: syscalls.master

Log Message:
Add __posix_rename as a rump syscall


To generate a diff of this commit:
cvs rdiff -u -r1.272 -r1.273 src/sys/kern/syscalls.master

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/syscalls.master
diff -u src/sys/kern/syscalls.master:1.272 src/sys/kern/syscalls.master:1.273
--- src/sys/kern/syscalls.master:1.272	Sun Feb 22 00:50:30 2015
+++ src/sys/kern/syscalls.master	Wed Apr  8 13:24:25 2015
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.272 2015/02/22 00:50:30 christos Exp $
+	$NetBSD: syscalls.master,v 1.273 2015/04/08 13:24:25 justin Exp $
 
 ;	@(#)syscalls.master	8.2 (Berkeley) 1/13/94
 
@@ -523,7 +523,7 @@
 267	UNIMPL
 268	UNIMPL
 269	UNIMPL
-270	STD 		{ int|sys||__posix_rename(const char *from, \
+270	STD 	 RUMP	{ int|sys||__posix_rename(const char *from, \
 			const char *to); }
 271	STD 		{ int|sys||swapctl(int cmd, void *arg, int misc); }
 272	COMPAT_30 MODULAR { int|sys||getdents(int fd, char *buf, size_t count); }



CVS commit: src/sys

2015-04-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Apr  8 13:45:01 UTC 2015

Modified Files:
src/sys/kern: kern_rndpool.c kern_rndq.c
src/sys/sys: rnd.h

Log Message:
Omit needless state.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/kern/kern_rndpool.c
cvs rdiff -u -r1.38 -r1.39 src/sys/kern/kern_rndq.c
cvs rdiff -u -r1.43 -r1.44 src/sys/sys/rnd.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/kern/kern_rndpool.c
diff -u src/sys/kern/kern_rndpool.c:1.7 src/sys/kern/kern_rndpool.c:1.8
--- src/sys/kern/kern_rndpool.c:1.7	Mon Aug 11 13:59:24 2014
+++ src/sys/kern/kern_rndpool.c	Wed Apr  8 13:45:01 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: kern_rndpool.c,v 1.7 2014/08/11 13:59:24 riastradh Exp $*/
+/*  $NetBSD: kern_rndpool.c,v 1.8 2015/04/08 13:45:01 riastradh Exp $*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_rndpool.c,v 1.7 2014/08/11 13:59:24 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_rndpool.c,v 1.8 2015/04/08 13:45:01 riastradh Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -49,16 +49,6 @@ __KERNEL_RCSID(0, $NetBSD: kern_rndpool
 #define	TAP4	 9
 #define	TAP5	 7
 
-/*
- * Let others know: the pool is full.
- *
- * XXX these should be per-pool if we really mean to allow multiple pools.
- */
-int rnd_full = 0;			/* Flag: is the pool full? */
-int rnd_filled = 0;			/* Count: how many times filled? */
-int rnd_empty = 1;			/* Flag: is the pool empty? */
-extern int	rnd_initial_entropy;	/* Have ever hit the threshold */
-
 static inline void rndpool_add_one_word(rndpool_t *, u_int32_t);
 
 void
@@ -237,8 +227,6 @@ rndpool_add_data(rndpool_t *rp,
 	if (rp-stats.curentropy  RND_POOLBITS) {
 		rp-stats.discarded += (rp-stats.curentropy - RND_POOLBITS);
 		rp-stats.curentropy = RND_POOLBITS;
-		rnd_filled++;
-		rnd_full = 1;
 	}
 }
 
@@ -270,10 +258,6 @@ rndpool_extract_data(rndpool_t *rp, void
 	buf = p;
 	remain = len;
 
-	if (rp-stats.curentropy  RND_POOLBITS / 2) {
-		rnd_full = 0;
-	}
-
 	KASSERT(RND_ENTROPY_THRESHOLD * 2 = sizeof(digest));
 
 	while (remain != 0  ! (mode == RND_EXTRACT_GOOD 

Index: src/sys/kern/kern_rndq.c
diff -u src/sys/kern/kern_rndq.c:1.38 src/sys/kern/kern_rndq.c:1.39
--- src/sys/kern/kern_rndq.c:1.38	Wed Apr  8 13:24:23 2015
+++ src/sys/kern/kern_rndq.c	Wed Apr  8 13:45:01 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rndq.c,v 1.38 2015/04/08 13:24:23 riastradh Exp $	*/
+/*	$NetBSD: kern_rndq.c,v 1.39 2015/04/08 13:45:01 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_rndq.c,v 1.38 2015/04/08 13:24:23 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_rndq.c,v 1.39 2015/04/08 13:45:01 riastradh Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -308,13 +308,11 @@ rnd_wakeup_readers(void)
 
 	/*
 	 * XXX This bookkeeping shouldn't be here -- this is not where
-	 * the rnd_empty/rnd_initial_entropy state change actually
-	 * happens.
+	 * the rnd_initial_entropy state change actually happens.
 	 */
 	mutex_spin_enter(rndpool_mtx);
 	const size_t entropy_count = rndpool_get_entropy_count(rnd_pool);
 	if (entropy_count  RND_ENTROPY_THRESHOLD * 8) {
-		rnd_empty = 1;
 		mutex_spin_exit(rndpool_mtx);
 		return;
 	} else {
@@ -323,7 +321,6 @@ rnd_wakeup_readers(void)
 			rnd_printf_verbose(rnd: have initial entropy (%zu)\n,
 			entropy_count);
 #endif
-		rnd_empty = 0;
 		rnd_initial_entropy = 1;
 	}
 	mutex_spin_exit(rndpool_mtx);
@@ -1125,7 +1122,6 @@ skip:		SIMPLEQ_INSERT_TAIL(df_samples, 
 	if (pool_entropy  RND_ENTROPY_THRESHOLD * 8) {
 		wake++;
 	} else {
-		rnd_empty = 1;
 		rnd_getmore(howmany((RND_POOLBITS - pool_entropy), NBBY));
 		rnd_printf_verbose(rnd: empty, asking for %d bytes\n,
 		(int)(howmany((RND_POOLBITS - pool_entropy), NBBY)));

Index: src/sys/sys/rnd.h
diff -u src/sys/sys/rnd.h:1.43 src/sys/sys/rnd.h:1.44
--- src/sys/sys/rnd.h:1.43	Sun Oct 26 18:22:32 2014
+++ src/sys/sys/rnd.h	Wed Apr  8 13:45:01 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rnd.h,v 1.43 2014/10/26 18:22:32 tls Exp $	*/
+/*	$NetBSD: rnd.h,v 1.44 2015/04/08 13:45:01 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -228,16 +228,11 @@ rnd_add_uint64(krndsource_t *kr, uint64_
 	}
 }
 
-extern int	rnd_empty;
-extern int	rnd_full;
-extern int	rnd_filled;
 extern int	rnd_initial_entropy;
 
 extern int	rnd_ready;
 extern int	rnd_printing;		/* XXX recursion through printf */
 
-extern int	rnd_blockonce;
-
 #endif /* _KERNEL */
 
 #define	RND_MAXSTATCOUNT	10	/* 10 sources at once max */



CVS commit: src/sys/kern

2015-04-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Apr  8 14:11:21 UTC 2015

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

Log Message:
Remove unnecessary, and actively wrong and harmful, locking.

Obviously this `enable callback' never actually worked, because it
would deadlock against itself as soon as you try it.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/kern/kern_rndq.c

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

Modified files:

Index: src/sys/kern/kern_rndq.c
diff -u src/sys/kern/kern_rndq.c:1.41 src/sys/kern/kern_rndq.c:1.42
--- src/sys/kern/kern_rndq.c:1.41	Wed Apr  8 14:08:49 2015
+++ src/sys/kern/kern_rndq.c	Wed Apr  8 14:11:21 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rndq.c,v 1.41 2015/04/08 14:08:49 riastradh Exp $	*/
+/*	$NetBSD: kern_rndq.c,v 1.42 2015/04/08 14:11:21 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_rndq.c,v 1.41 2015/04/08 14:08:49 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_rndq.c,v 1.42 2015/04/08 14:11:21 riastradh Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -444,22 +444,18 @@ static void
 rnd_skew_enable(krndsource_t *rs, bool enabled)
 {
 
-	mutex_spin_enter(rnd_skew.lock);
 	if (enabled) {
 		rnd_skew_intr(rs);
 	} else {
 		callout_stop(rnd_skew.callout);
 	}
-	mutex_spin_exit(rnd_skew.lock);
 }
 
 static void
 rnd_skew_stop_intr(void *arg)
 {
 
-	mutex_spin_enter(rnd_skew.lock);
 	callout_stop(rnd_skew.callout);
-	mutex_spin_exit(rnd_skew.lock);
 }
 
 static void
@@ -470,11 +466,8 @@ rnd_skew_get(size_t bytes, void *priv)
 	KASSERT(skewsrcp == rnd_skew.source);
 	if (RND_ENABLED(skewsrcp)) {
 		/* Measure for 30s */
-		if (mutex_tryenter(rnd_skew.lock)) {
-			callout_schedule(rnd_skew.stop_callout, hz * 30);
-			callout_schedule(rnd_skew.callout, 1);
-			mutex_spin_exit(rnd_skew.lock);
-		}
+		callout_schedule(rnd_skew.stop_callout, hz * 30);
+		callout_schedule(rnd_skew.callout, 1);
 	}
 }
 



CVS commit: src/sys/arch/arm

2015-04-08 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Apr  8 18:10:08 UTC 2015

Modified Files:
src/sys/arch/arm/arm: arm_machdep.c ast.c
src/sys/arch/arm/include/arm32: frame.h
src/sys/arch/arm/pic: pic.c

Log Message:
Don't clear CI_ASTPENDING in exception return, do it in ast() instead.
Add basic support for __HAVE_PREEMPTION.
Use atomic ops for ci_astpending if __HAVE_PREEMPTION is defined.
Use kpreempt_disable/kpreempt_enable


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/arm/arm/arm_machdep.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/arm/ast.c
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/arm/include/arm32/frame.h
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/pic/pic.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/arm/arm_machdep.c
diff -u src/sys/arch/arm/arm/arm_machdep.c:1.45 src/sys/arch/arm/arm/arm_machdep.c:1.46
--- src/sys/arch/arm/arm/arm_machdep.c:1.45	Wed Apr  8 16:37:32 2015
+++ src/sys/arch/arm/arm/arm_machdep.c	Wed Apr  8 18:10:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm_machdep.c,v 1.45 2015/04/08 16:37:32 matt Exp $	*/
+/*	$NetBSD: arm_machdep.c,v 1.46 2015/04/08 18:10:08 matt Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
 
 #include sys/param.h
 
-__KERNEL_RCSID(0, $NetBSD: arm_machdep.c,v 1.45 2015/04/08 16:37:32 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: arm_machdep.c,v 1.46 2015/04/08 18:10:08 matt Exp $);
 
 #include sys/exec.h
 #include sys/proc.h
@@ -266,7 +266,7 @@ cpu_need_resched(struct cpu_info *ci, in
 #ifdef __HAVE_PREEMPTION
 		atomic_or_uint(l-l_dopreempt, DOPREEMPT_ACTIVE);
 		if (ci == cur_ci) {
-			ci-ci_astpending |= 2;
+			atomic_or_uint(ci-ci_astpending, __BIT(1));
 		} else {
 			ipi = IPI_KPREEMPT;
 			goto send_ipi;
@@ -274,7 +274,11 @@ cpu_need_resched(struct cpu_info *ci, in
 #endif /* __HAVE_PREEMPTION */
 		return;
 	}
-	ci-ci_astpending |= 1;
+#ifdef __HAVE_PREEMPTION
+	atomic_or_uint(ci-ci_astpending, __BIT(0));
+#else
+	ci-ci_astpending = __BIT(0);
+#endif
 #ifdef MULTIPROCESSOR
 	if (ci == curcpu() || !immed)
 		return;
@@ -321,3 +325,31 @@ arm_curcpu(void)
 	return curcpu();
 }
 #endif
+
+#ifdef __HAVE_PREEMPTION
+void
+cpu_set_curpri(int pri)
+{
+	kpreempt_disable();
+	curcpu()-ci_schedstate.spc_curpriority = pri;
+	kpreempt_enable();
+}
+
+bool
+cpu_kpreempt_enter(uintptr_t where, int s)
+{
+	return s == IPL_NONE;
+}
+
+void
+cpu_kpreempt_exit(uintptr_t where)
+{
+	atomic_and_uint(curcpu()-ci_astpending, (unsigned int)~__BIT(1));
+}
+
+bool
+cpu_kpreempt_disabled(void)
+{
+	return curcpu()-ci_cpl != IPL_NONE;
+}
+#endif /* __HAVE_PREEMPTION */

Index: src/sys/arch/arm/arm/ast.c
diff -u src/sys/arch/arm/arm/ast.c:1.25 src/sys/arch/arm/arm/ast.c:1.26
--- src/sys/arch/arm/arm/ast.c:1.25	Wed Oct 29 10:56:19 2014
+++ src/sys/arch/arm/arm/ast.c	Wed Apr  8 18:10:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ast.c,v 1.25 2014/10/29 10:56:19 skrll Exp $	*/
+/*	$NetBSD: ast.c,v 1.26 2015/04/08 18:10:08 matt Exp $	*/
 
 /*
  * Copyright (c) 1994,1995 Mark Brinicombe
@@ -41,7 +41,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ast.c,v 1.25 2014/10/29 10:56:19 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: ast.c,v 1.26 2015/04/08 18:10:08 matt Exp $);
 
 #include opt_ddb.h
 
@@ -50,10 +50,11 @@ __KERNEL_RCSID(0, $NetBSD: ast.c,v 1.25
 #include sys/proc.h
 #include sys/acct.h
 #include sys/systm.h
+#include sys/atomic.h
 #include sys/kernel.h
 #include sys/signal.h
-#include sys/vmmeter.h
 #include sys/userret.h
+#include sys/vmmeter.h
 
 #include arm/locore.h
 
@@ -76,11 +77,17 @@ userret(struct lwp *l)
 	 * If our ASID got released, access via TTBR0 will have been disabled.
 	 * So if it is disabled, activate the lwp again to get a new ASID.
 	 */
+#ifdef __HAVE_PREEMPTION
+	kpreempt_disable();
+#endif
 	KASSERT(curcpu()-ci_pmap_cur == l-l_proc-p_vmspace-vm_map.pmap);
-	if (armreg_ttbcr_read()  TTBCR_S_PD0) {
+	if (__predict_false(armreg_ttbcr_read()  TTBCR_S_PD0)) {
 		pmap_activate(l);
 	}
 	KASSERT(!(armreg_ttbcr_read()  TTBCR_S_PD0));
+#ifdef __HAVE_PREEMPTION
+	kpreempt_enable();
+#endif
 #endif
 
 	/* Invoke MI userret code */
@@ -116,12 +123,23 @@ ast(struct trapframe *tf)
 	KASSERT(VALID_R15_PSR(tf-tf_pc, tf-tf_spsr));
 #endif
 
-	curcpu()-ci_data.cpu_ntrap++;
-	//curcpu()-ci_data.cpu_nast++;
+#ifdef __HAVE_PREEEMPTION
+	kpreempt_disable();
+#endif
+	struct cpu_info * const ci = curcpu();
+
+	ci-ci_data.cpu_ntrap++;
 
-#ifdef DEBUG
-	KDASSERT(curcpu()-ci_cpl == IPL_NONE);
-#endif	
+	KDASSERT(ci-ci_cpl == IPL_NONE);
+#ifdef __HAVE_PREEEMPTION
+	atomic_and_uint(ci-ci_astpending, ~__BIT(0));
+#else
+	ci-ci_astpending = 0;
+#endif
+	const int want_resched = ci-ci_want_resched;
+#ifdef __HAVE_PREEEMPTION
+	kpreempt_enable();
+#endif
 
 	if (l-l_pflag  LP_OWEUPC) {
 		l-l_pflag = ~LP_OWEUPC;
@@ -129,8 +147,7 @@ ast(struct trapframe *tf)
 	}
 
 	/* Allow a forced task switch. 

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

2015-04-08 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Apr  8 18:10:44 UTC 2015

Modified Files:
src/sys/arch/arm/include: cpu.h

Log Message:
Add basic support for __HAVE_PREEMPTION.
Use atomic ops for ci_astpending if __HAVE_PREEMPTION is defined.


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/arch/arm/include/cpu.h

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

Modified files:

Index: src/sys/arch/arm/include/cpu.h
diff -u src/sys/arch/arm/include/cpu.h:1.86 src/sys/arch/arm/include/cpu.h:1.87
--- src/sys/arch/arm/include/cpu.h:1.86	Wed Apr  8 07:29:44 2015
+++ src/sys/arch/arm/include/cpu.h	Wed Apr  8 18:10:44 2015
@@ -137,6 +137,7 @@ static inline void cpu_dosoftints(void);
 #ifdef _KMEMUSER
 #include sys/intr.h
 #endif
+#include sys/atomic.h
 #include sys/cpu_data.h
 #include sys/device_if.h
 #include sys/evcnt.h
@@ -150,7 +151,7 @@ struct cpu_info {
 	uint32_t ci_arm_cpurev;		/* CPU revision */
 	uint32_t ci_ctrl;		/* The CPU control register */
 	int ci_cpl;			/* current processor level (spl) */
-	int ci_astpending;		/* */
+	volatile int ci_astpending;	/* */
 	int ci_want_resched;		/* resched() was called */
 	int ci_intr_depth;		/* */
 	struct cpu_softc *ci_softc;	/* platform softc */
@@ -276,7 +277,12 @@ void	cpu_proc_fork(struct proc *, struct
  * Scheduling glue
  */
 
-#define setsoftast()			(curcpu()-ci_astpending = 1)
+#ifdef __HAVE_PREEMPTION
+#define setsoftast()		atomic_or_uint(curcpu()-ci_astpending, \
+__BIT(0))
+#else
+#define setsoftast()		(curcpu()-ci_astpending = __BIT(0))
+#endif
 
 /*
  * Notify the current process (p) that it has a signal pending,
@@ -292,6 +298,9 @@ void	cpu_proc_fork(struct proc *, struct
  */
 #define	cpu_need_proftick(l)	((l)-l_pflag |= LP_OWEUPC, setsoftast())
 
+/* for preeemption. */
+void	cpu_set_curpri(int);
+
 /*
  * We've already preallocated the stack for the idlelwps for additional CPUs.  
  * This hook allows to return them.



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

2015-04-08 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Apr  8 20:42:09 UTC 2015

Modified Files:
src/sys/arch/arm/include: cpu.h

Log Message:
Make sure TPIDRPRw_IS_CURLWP is being used when __HAVE_PREEEMPTION is defined.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/arm/include/cpu.h

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

Modified files:

Index: src/sys/arch/arm/include/cpu.h
diff -u src/sys/arch/arm/include/cpu.h:1.87 src/sys/arch/arm/include/cpu.h:1.88
--- src/sys/arch/arm/include/cpu.h:1.87	Wed Apr  8 18:10:44 2015
+++ src/sys/arch/arm/include/cpu.h	Wed Apr  8 20:42:09 2015
@@ -209,6 +209,9 @@ static inline struct cpu_info *lwp_getcp
 // curcpu() expands into two instructions: a mrc and a ldr
 #define	curcpu()	lwp_getcpu(_curlwp())
 #elif defined(TPIDRPRW_IS_CURCPU)
+#ifdef __HAVE_PREEMPTION
+#error __HAVE_PREEMPTION requires TPIDRPRW_IS_CURLWP
+#endif
 static inline struct cpu_info *
 curcpu(void)
 {
@@ -216,8 +219,10 @@ curcpu(void)
 }
 #elif !defined(MULTIPROCESSOR)
 #define	curcpu()	(cpu_info_store)
+#elif !defined(__HAVE_PREEEMPTION)
+#error MULTIPROCESSOR  !__HAVE_PREEMPTION requires TPIDRPRW_IS_CURCPU or TPIDRPRW_IS_CURLWP
 #else
-#error MULTIPROCESSOR requires TPIDRPRW_IS_CURCPU or TPIDRPRW_IS_CURLWP
+#error MULTIPROCESSOR  __HAVE_PREEMPTION requires TPIDRPRW_IS_CURLWP
 #endif /* !TPIDRPRW_IS_CURCPU  !TPIDRPRW_IS_CURLWP */
 
 #ifndef curlwp