CVS commit: src/tests/rump/kernspace

2017-12-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Dec 28 07:46:34 UTC 2017

Modified Files:
src/tests/rump/kernspace: workqueue.c

Log Message:
Fix build


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/rump/kernspace/workqueue.c

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

Modified files:

Index: src/tests/rump/kernspace/workqueue.c
diff -u src/tests/rump/kernspace/workqueue.c:1.5 src/tests/rump/kernspace/workqueue.c:1.6
--- src/tests/rump/kernspace/workqueue.c:1.5	Thu Dec 28 07:10:25 2017
+++ src/tests/rump/kernspace/workqueue.c	Thu Dec 28 07:46:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: workqueue.c,v 1.5 2017/12/28 07:10:25 ozaki-r Exp $	*/
+/*	$NetBSD: workqueue.c,v 1.6 2017/12/28 07:46:34 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: workqueue.c,v 1.5 2017/12/28 07:10:25 ozaki-r Exp $");
+__RCSID("$NetBSD: workqueue.c,v 1.6 2017/12/28 07:46:34 ozaki-r Exp $");
 #endif /* !lint */
 
 #include 
@@ -97,13 +97,13 @@ rumptest_workqueue1()
 	sc = create_sc();
 
 #define ITERATIONS 12435
-	for (size_t i = 0; i < ITERATIONS; ++i) {
+	for (int i = 0; i < ITERATIONS; ++i) {
 		int e;
 		mutex_enter(>mtx);
 		workqueue_enqueue(sc->wq, >wk, NULL);
 		e = cv_timedwait(>cv, >mtx, hz * 2);
 		if (e != 0)
-			panic("cv_timedwait timed out (i=%lu)", i);
+			panic("cv_timedwait timed out (i=%d)", i);
 		mutex_exit(>mtx);
 	}
 



CVS commit: src/tests/rump

2017-12-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Dec 28 07:10:26 UTC 2017

Modified Files:
src/tests/rump/kernspace: kernspace.h workqueue.c
src/tests/rump/rumpkern: t_workqueue.c

Log Message:
Add a test case for workqueue_wait


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/rump/kernspace/kernspace.h
cvs rdiff -u -r1.4 -r1.5 src/tests/rump/kernspace/workqueue.c
cvs rdiff -u -r1.1 -r1.2 src/tests/rump/rumpkern/t_workqueue.c

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

Modified files:

Index: src/tests/rump/kernspace/kernspace.h
diff -u src/tests/rump/kernspace/kernspace.h:1.5 src/tests/rump/kernspace/kernspace.h:1.6
--- src/tests/rump/kernspace/kernspace.h:1.5	Fri Sep 29 13:19:57 2017
+++ src/tests/rump/kernspace/kernspace.h	Thu Dec 28 07:10:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernspace.h,v 1.5 2017/09/29 13:19:57 maya Exp $	*/
+/*	$NetBSD: kernspace.h,v 1.6 2017/12/28 07:10:25 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -41,6 +41,7 @@ void rumptest_tsleep(void);
 void rumptest_alloc(size_t);
 void rumptest_lockme(enum locktest);
 void rumptest_workqueue1(void);
+void rumptest_workqueue_wait(void);
 
 void rumptest_sendsig(char *);
 void rumptest_localsig(int);

Index: src/tests/rump/kernspace/workqueue.c
diff -u src/tests/rump/kernspace/workqueue.c:1.4 src/tests/rump/kernspace/workqueue.c:1.5
--- src/tests/rump/kernspace/workqueue.c:1.4	Thu Dec 28 07:09:31 2017
+++ src/tests/rump/kernspace/workqueue.c	Thu Dec 28 07:10:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: workqueue.c,v 1.4 2017/12/28 07:09:31 ozaki-r Exp $	*/
+/*	$NetBSD: workqueue.c,v 1.5 2017/12/28 07:10:25 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: workqueue.c,v 1.4 2017/12/28 07:09:31 ozaki-r Exp $");
+__RCSID("$NetBSD: workqueue.c,v 1.5 2017/12/28 07:10:25 ozaki-r Exp $");
 #endif /* !lint */
 
 #include 
@@ -112,3 +112,28 @@ rumptest_workqueue1()
 	destroy_sc(sc);
 #undef ITERATIONS
 }
+
+void
+rumptest_workqueue_wait(void)
+{
+	struct test_softc *sc;
+	struct work dummy;
+
+	sc = create_sc();
+
+#define ITERATIONS 12435
+	for (size_t i = 0; i < ITERATIONS; ++i) {
+		KASSERT(sc->counter == i);
+		workqueue_enqueue(sc->wq, >wk, NULL);
+		workqueue_wait(sc->wq, >wk);
+		KASSERT(sc->counter == (i + 1));
+	}
+
+	KASSERT(sc->counter == ITERATIONS);
+
+	/* Wait for a work that is not enqueued. Just return immediately. */
+	workqueue_wait(sc->wq, );
+
+	destroy_sc(sc);
+#undef ITERATIONS
+}

Index: src/tests/rump/rumpkern/t_workqueue.c
diff -u src/tests/rump/rumpkern/t_workqueue.c:1.1 src/tests/rump/rumpkern/t_workqueue.c:1.2
--- src/tests/rump/rumpkern/t_workqueue.c:1.1	Fri Sep 29 12:42:37 2017
+++ src/tests/rump/rumpkern/t_workqueue.c	Thu Dec 28 07:10:26 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_workqueue.c,v 1.1 2017/09/29 12:42:37 maya Exp $	*/
+/*	$NetBSD: t_workqueue.c,v 1.2 2017/12/28 07:10:26 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -55,9 +55,27 @@ ATF_TC_BODY(workqueue1, tc)
 	rump_unschedule();
 }
 
+ATF_TC(workqueue_wait);
+ATF_TC_HEAD(workqueue_wait, tc)
+{
+
+	atf_tc_set_md_var(tc, "descr", "Checks workqueue_wait");
+}
+
+ATF_TC_BODY(workqueue_wait, tc)
+{
+
+	rump_init();
+
+	rump_schedule();
+	rumptest_workqueue_wait(); /* panics if fails */
+	rump_unschedule();
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 	ATF_TP_ADD_TC(tp, workqueue1);
+	ATF_TP_ADD_TC(tp, workqueue_wait);
 
 	return atf_no_error();
 }



CVS commit: src/tests/rump/kernspace

2017-12-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Dec 28 07:09:31 UTC 2017

Modified Files:
src/tests/rump/kernspace: workqueue.c

Log Message:
Functionalize some routines to add new tests easily (NFC)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/rump/kernspace/workqueue.c

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

Modified files:

Index: src/tests/rump/kernspace/workqueue.c
diff -u src/tests/rump/kernspace/workqueue.c:1.3 src/tests/rump/kernspace/workqueue.c:1.4
--- src/tests/rump/kernspace/workqueue.c:1.3	Thu Dec 28 04:38:02 2017
+++ src/tests/rump/kernspace/workqueue.c	Thu Dec 28 07:09:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: workqueue.c,v 1.3 2017/12/28 04:38:02 ozaki-r Exp $	*/
+/*	$NetBSD: workqueue.c,v 1.4 2017/12/28 07:09:31 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: workqueue.c,v 1.3 2017/12/28 04:38:02 ozaki-r Exp $");
+__RCSID("$NetBSD: workqueue.c,v 1.4 2017/12/28 07:09:31 ozaki-r Exp $");
 #endif /* !lint */
 
 #include 
@@ -61,19 +61,15 @@ rump_work1(struct work *wk, void *arg)
 	mutex_exit(>mtx);
 }
 
-void
-rumptest_workqueue1()
+static struct test_softc *
+create_sc(void)
 {
-
 	int rv;
-
 	struct test_softc *sc;
 
 	sc = kmem_zalloc(sizeof(*sc), KM_SLEEP);
-
 	mutex_init(>mtx, MUTEX_DEFAULT, IPL_NONE);
 	cv_init(>cv, "rumpwqcv");
-
 	rv = workqueue_create(>wq, "rumpwq",
 	rump_work1, sc, PRI_SOFTNET, IPL_SOFTNET, 0);
 	if (rv)
@@ -81,6 +77,25 @@ rumptest_workqueue1()
 
 	sc->counter = 0;
 
+	return sc;
+}
+
+static void
+destroy_sc(struct test_softc *sc)
+{
+
+	cv_destroy(>cv);
+	mutex_destroy(>mtx);
+	workqueue_destroy(sc->wq);
+}
+
+void
+rumptest_workqueue1()
+{
+	struct test_softc *sc;
+
+	sc = create_sc();
+
 #define ITERATIONS 12435
 	for (size_t i = 0; i < ITERATIONS; ++i) {
 		int e;
@@ -94,8 +109,6 @@ rumptest_workqueue1()
 
 	KASSERT(sc->counter == ITERATIONS);
 
-	cv_destroy(>cv);
-	mutex_destroy(>mtx);
-	workqueue_destroy(sc->wq);
+	destroy_sc(sc);
+#undef ITERATIONS
 }
-



CVS commit: src/sys/net

2017-12-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Dec 28 07:06:36 UTC 2017

Modified Files:
src/sys/net: if_bridge.c if_spppsubr.c

Log Message:
Ensure the timer isn't running by using workqueue_wait


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/sys/net/if_bridge.c
cvs rdiff -u -r1.177 -r1.178 src/sys/net/if_spppsubr.c

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

Modified files:

Index: src/sys/net/if_bridge.c
diff -u src/sys/net/if_bridge.c:1.146 src/sys/net/if_bridge.c:1.147
--- src/sys/net/if_bridge.c:1.146	Tue Dec 19 03:32:35 2017
+++ src/sys/net/if_bridge.c	Thu Dec 28 07:06:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridge.c,v 1.146 2017/12/19 03:32:35 ozaki-r Exp $	*/
+/*	$NetBSD: if_bridge.c,v 1.147 2017/12/28 07:06:36 ozaki-r Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.146 2017/12/19 03:32:35 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.147 2017/12/28 07:06:36 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bridge_ipf.h"
@@ -1358,7 +1358,8 @@ bridge_stop(struct ifnet *ifp, int disab
 	KASSERT((ifp->if_flags & IFF_RUNNING) != 0);
 	ifp->if_flags &= ~IFF_RUNNING;
 
-	callout_stop(>sc_brcallout);
+	callout_halt(>sc_brcallout, NULL);
+	workqueue_wait(sc->sc_rtage_wq, >sc_rtage_wk);
 	bstp_stop(sc);
 	bridge_rtflush(sc, IFBF_FLUSHDYN);
 }

Index: src/sys/net/if_spppsubr.c
diff -u src/sys/net/if_spppsubr.c:1.177 src/sys/net/if_spppsubr.c:1.178
--- src/sys/net/if_spppsubr.c:1.177	Mon Dec 11 03:29:20 2017
+++ src/sys/net/if_spppsubr.c	Thu Dec 28 07:06:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_spppsubr.c,v 1.177 2017/12/11 03:29:20 ozaki-r Exp $	 */
+/*	$NetBSD: if_spppsubr.c,v 1.178 2017/12/28 07:06:36 ozaki-r Exp $	 */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.177 2017/12/11 03:29:20 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.178 2017/12/28 07:06:36 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1073,6 +1073,7 @@ sppp_detach(struct ifnet *ifp)
 
 	/* to avoid workqueue enqueued */
 	atomic_swap_uint(>ipcp.update_addrs_enqueued, 1);
+	workqueue_wait(sp->ipcp.update_addrs_wq, >ipcp.update_addrs_wk);
 	workqueue_destroy(sp->ipcp.update_addrs_wq);
 	pcq_destroy(sp->ipcp.update_addrs_q);
 



CVS commit: src

2017-12-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Dec 28 07:00:52 UTC 2017

Modified Files:
src/share/man/man9: workqueue.9
src/sys/kern: subr_workqueue.c
src/sys/sys: workqueue.h

Log Message:
Add workqueue_wait that waits for a specific work to finish

The caller must ensure that no new work is enqueued before calling
workqueue_wait. Note that Note that if the workqueue is WQ_PERCPU, the caller
can enqueue a new work to another queue other than the waiting queue.

Discussed on tech-kern@


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/share/man/man9/workqueue.9
cvs rdiff -u -r1.33 -r1.34 src/sys/kern/subr_workqueue.c
cvs rdiff -u -r1.9 -r1.10 src/sys/sys/workqueue.h

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

Modified files:

Index: src/share/man/man9/workqueue.9
diff -u src/share/man/man9/workqueue.9:1.11 src/share/man/man9/workqueue.9:1.12
--- src/share/man/man9/workqueue.9:1.11	Tue Oct 13 04:22:24 2015
+++ src/share/man/man9/workqueue.9	Thu Dec 28 07:00:52 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: workqueue.9,v 1.11 2015/10/13 04:22:24 riastradh Exp $
+.\"	$NetBSD: workqueue.9,v 1.12 2017/12/28 07:00:52 ozaki-r Exp $
 .\"
 .\" Copyright (c)2005 YAMAMOTO Takashi,
 .\" All rights reserved.
@@ -25,7 +25,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" 
-.Dd October 24, 2011
+.Dd December 28, 2017
 .Dt WORKQUEUE 9
 .Os
 .\" 
@@ -47,6 +47,10 @@
 "struct workqueue *wq" "struct work *wk" "struct cpu_info *ci"
 .\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 .Ft void
+.Fn workqueue_wait \
+"struct workqueue *wq" "struct work *wk"
+.\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+.Ft void
 .Fn workqueue_destroy \
 "struct workqueue *wq"
 .\" 
@@ -118,6 +122,19 @@ the
 framework.
 .Pp
 .\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+.Fn workqueue_wait
+waits for a specified work
+.Fa wk
+on the workqueue
+.Fa wq
+to finish.
+The caller must ensure that no new work will be enqueued to the workqueue
+beforehand.
+Note that if the workqueue is
+.Dv WQ_PERCPU ,
+the caller can enqueue a new work to another queue other than the waiting queue.
+.Pp
+.\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 .Fn workqueue_destroy
 destroys a workqueue and frees associated resources.
 The caller should ensure that the workqueue has no work enqueued beforehand.

Index: src/sys/kern/subr_workqueue.c
diff -u src/sys/kern/subr_workqueue.c:1.33 src/sys/kern/subr_workqueue.c:1.34
--- src/sys/kern/subr_workqueue.c:1.33	Sun Oct  7 22:16:21 2012
+++ src/sys/kern/subr_workqueue.c	Thu Dec 28 07:00:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_workqueue.c,v 1.33 2012/10/07 22:16:21 matt Exp $	*/
+/*	$NetBSD: subr_workqueue.c,v 1.34 2017/12/28 07:00:52 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c)2002, 2005, 2006, 2007 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_workqueue.c,v 1.33 2012/10/07 22:16:21 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_workqueue.c,v 1.34 2017/12/28 07:00:52 ozaki-r Exp $");
 
 #include 
 #include 
@@ -49,8 +49,10 @@ SIMPLEQ_HEAD(workqhead, work_impl);
 struct workqueue_queue {
 	kmutex_t q_mutex;
 	kcondvar_t q_cv;
-	struct workqhead q_queue;
+	struct workqhead q_queue_pending;
+	struct workqhead q_queue_running;
 	lwp_t *q_worker;
+	work_impl_t *q_waiter;
 };
 
 struct workqueue {
@@ -115,24 +117,29 @@ workqueue_worker(void *cookie)
 	q = workqueue_queue_lookup(wq, curlwp->l_cpu);
 
 	for (;;) {
-		struct workqhead tmp;
-
 		/*
 		 * we violate abstraction of SIMPLEQ.
 		 */
 
-#if defined(DIAGNOSTIC)
-		tmp.sqh_last = (void *)POISON;
-#endif /* defined(DIAGNOSTIC) */
-
 		mutex_enter(>q_mutex);
-		while (SIMPLEQ_EMPTY(>q_queue))
+		while (SIMPLEQ_EMPTY(>q_queue_pending))
 			cv_wait(>q_cv, >q_mutex);
-		tmp.sqh_first = q->q_queue.sqh_first; /* XXX */
-		SIMPLEQ_INIT(>q_queue);
+		KASSERT(SIMPLEQ_EMPTY(>q_queue_running));
+		q->q_queue_running.sqh_first =
+		q->q_queue_pending.sqh_first; /* XXX */
+		SIMPLEQ_INIT(>q_queue_pending);
 		mutex_exit(>q_mutex);
 
-		workqueue_runlist(wq, );
+		workqueue_runlist(wq, >q_queue_running);
+
+		mutex_enter(>q_mutex);
+		KASSERT(!SIMPLEQ_EMPTY(>q_queue_running));
+		SIMPLEQ_INIT(>q_queue_running);
+		if (__predict_false(q->q_waiter != NULL)) {
+			/* Wake up workqueue_wait */
+			cv_signal(>q_cv);
+		}
+		mutex_exit(>q_mutex);
 	}
 }
 
@@ -159,7 +166,8 @@ workqueue_initqueue(struct workqueue *wq
 
 	mutex_init(>q_mutex, MUTEX_DEFAULT, ipl);
 	cv_init(>q_cv, wq->wq_name);
-	SIMPLEQ_INIT(>q_queue);
+	SIMPLEQ_INIT(>q_queue_pending);
+	SIMPLEQ_INIT(>q_queue_running);
 	ktf = ((wq->wq_flags & WQ_MPSAFE) != 0 ? KTHREAD_MPSAFE : 0);
 	if (wq->wq_prio < PRI_KERNEL)
 		ktf |= KTHREAD_TS;
@@ -194,7 

CVS commit: src/sys/dev/pci

2017-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 28 06:13:50 UTC 2017

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

Log Message:
 Don't use MSI-X if we can use only one queue to save interrupt resource.
Written by knakahara and tested by me.


To generate a diff of this commit:
cvs rdiff -u -r1.549 -r1.550 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.549 src/sys/dev/pci/if_wm.c:1.550
--- src/sys/dev/pci/if_wm.c:1.549	Fri Dec  8 05:22:23 2017
+++ src/sys/dev/pci/if_wm.c	Thu Dec 28 06:13:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.549 2017/12/08 05:22:23 ozaki-r Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.550 2017/12/28 06:13:50 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.549 2017/12/08 05:22:23 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.550 2017/12/28 06:13:50 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1850,16 +1850,25 @@ wm_attach(device_t parent, device_t self
 	}
 
 	wm_adjust_qnum(sc, pci_msix_count(pa->pa_pc, pa->pa_tag));
-
-	/* Allocation settings */
-	max_type = PCI_INTR_TYPE_MSIX;
 	/*
-	 * 82583 has a MSI-X capability in the PCI configuration space but
-	 * it doesn't support it. At least the document doesn't say anything
-	 * about MSI-X.
+	 *  Don't use MSI-X if we can use only one queue to save interrupt
+	 * resource.
 	 */
-	counts[PCI_INTR_TYPE_MSIX]
-	= (sc->sc_type == WM_T_82583) ? 0 : sc->sc_nqueues + 1;
+	if (sc->sc_nqueues > 1) {
+		max_type = PCI_INTR_TYPE_MSIX;
+		/*
+		 *  82583 has a MSI-X capability in the PCI configuration space
+		 * but it doesn't support it. At least the document doesn't
+		 * say anything about MSI-X.
+		 */
+		counts[PCI_INTR_TYPE_MSIX]
+		= (sc->sc_type == WM_T_82583) ? 0 : sc->sc_nqueues + 1;
+	} else {
+		max_type = PCI_INTR_TYPE_MSI;
+		counts[PCI_INTR_TYPE_MSIX] = 0;
+	}
+
+	/* Allocation settings */
 	counts[PCI_INTR_TYPE_MSI] = 1;
 	counts[PCI_INTR_TYPE_INTX] = 1;
 	/* overridden by disable flags */



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

2017-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 28 06:10:01 UTC 2017

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

Log Message:
 Fallback from MSI-X to MSI or INTx if MSI-X setup failed.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/dev/pci/ixgbe/ixgbe.c

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

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.118 src/sys/dev/pci/ixgbe/ixgbe.c:1.119
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.118	Thu Dec 21 09:24:45 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Dec 28 06:10:01 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.118 2017/12/21 09:24:45 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.119 2017/12/28 06:10:01 msaitoh Exp $ */
 
 /**
 
@@ -172,12 +172,14 @@ static void ixgbe_media_status(struc
 static int  ixgbe_media_change(struct ifnet *);
 static int  ixgbe_allocate_pci_resources(struct adapter *,
 		const struct pci_attach_args *);
+static void  ixgbe_free_softint(struct adapter *);
 static void	ixgbe_get_slot_info(struct adapter *);
 static int  ixgbe_allocate_msix(struct adapter *,
 		const struct pci_attach_args *);
 static int  ixgbe_allocate_legacy(struct adapter *,
 		const struct pci_attach_args *);
 static int  ixgbe_configure_interrupts(struct adapter *);
+static void	ixgbe_free_pciintr_resources(struct adapter *);
 static void	ixgbe_free_pci_resources(struct adapter *);
 static void	ixgbe_local_timer(void *);
 static void	ixgbe_local_timer1(void *);
@@ -1043,13 +1045,54 @@ ixgbe_attach(device_t parent, device_t d
 	hw->eeprom.ops.read(hw, IXGBE_ETRACKID_L, );
 	aprint_normal(" ETrackID %08x\n", ((uint32_t)high << 16) | low);
 
-	if (adapter->feat_en & IXGBE_FEATURE_MSIX)
+	if (adapter->feat_en & IXGBE_FEATURE_MSIX) {
 		error = ixgbe_allocate_msix(adapter, pa);
-	else
+		if (error) {
+			/* Free allocated queue structures first */
+			ixgbe_free_transmit_structures(adapter);
+			ixgbe_free_receive_structures(adapter);
+			free(adapter->queues, M_DEVBUF);
+
+			/* Fallback to legacy interrupt */
+			adapter->feat_en &= ~IXGBE_FEATURE_MSIX;
+			if (adapter->feat_cap & IXGBE_FEATURE_MSI)
+adapter->feat_en |= IXGBE_FEATURE_MSI;
+			adapter->num_queues = 1;
+
+			/* Allocate our TX/RX Queues again */
+			if (ixgbe_allocate_queues(adapter)) {
+error = ENOMEM;
+goto err_out;
+			}
+		}
+	}
+	if ((adapter->feat_en & IXGBE_FEATURE_MSIX) == 0)
 		error = ixgbe_allocate_legacy(adapter, pa);
 	if (error) 
 		goto err_late;
 
+	/* Tasklets for Link, SFP, Multispeed Fiber and Flow Director */
+	adapter->link_si = softint_establish(SOFTINT_NET |IXGBE_SOFTINFT_FLAGS,
+	ixgbe_handle_link, adapter);
+	adapter->mod_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS,
+	ixgbe_handle_mod, adapter);
+	adapter->msf_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS,
+	ixgbe_handle_msf, adapter);
+	adapter->phy_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS,
+	ixgbe_handle_phy, adapter);
+	if (adapter->feat_en & IXGBE_FEATURE_FDIR)
+		adapter->fdir_si =
+		softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS,
+			ixgbe_reinit_fdir, adapter);
+	if ((adapter->link_si == NULL) || (adapter->mod_si == NULL)
+	|| (adapter->msf_si == NULL) || (adapter->phy_si == NULL)
+	|| ((adapter->feat_en & IXGBE_FEATURE_FDIR)
+		&& (adapter->fdir_si == NULL))) {
+		aprint_error_dev(dev,
+		"could not establish software interrupts ()\n");
+		goto err_out;
+	}
+
 	error = ixgbe_start_hw(hw);
 	switch (error) {
 	case IXGBE_ERR_EEPROM_VERSION:
@@ -1158,6 +1201,7 @@ err_out:
 	ctrl_ext = IXGBE_READ_REG(>hw, IXGBE_CTRL_EXT);
 	ctrl_ext &= ~IXGBE_CTRL_EXT_DRV_LOAD;
 	IXGBE_WRITE_REG(>hw, IXGBE_CTRL_EXT, ctrl_ext);
+	ixgbe_free_softint(adapter);
 	ixgbe_free_pci_resources(adapter);
 	if (adapter->mta != NULL)
 		free(adapter->mta, M_DEVBUF);
@@ -3113,6 +3157,53 @@ map_err:
 	return (0);
 } /* ixgbe_allocate_pci_resources */
 
+static void
+ixgbe_free_softint(struct adapter *adapter)
+{
+	struct ix_queue *que = adapter->queues;
+	struct tx_ring *txr = adapter->tx_rings;
+	int i;
+
+	for (i = 0; i < adapter->num_queues; i++, que++, txr++) {
+		if (!(adapter->feat_en & IXGBE_FEATURE_LEGACY_TX)) {
+			if (txr->txr_si != NULL)
+softint_disestablish(txr->txr_si);
+		}
+		if (que->que_si != NULL)
+			softint_disestablish(que->que_si);
+	}
+
+	/* Drain the Link queue */
+	if (adapter->link_si != NULL) {
+		softint_disestablish(adapter->link_si);
+		adapter->link_si = NULL;
+	}
+	if (adapter->mod_si != NULL) {
+		softint_disestablish(adapter->mod_si);
+		adapter->mod_si = NULL;
+	}
+	if (adapter->msf_si != NULL) {
+		softint_disestablish(adapter->msf_si);
+		adapter->msf_si = NULL;
+	}
+	if (adapter->phy_si != NULL) {
+		softint_disestablish(adapter->phy_si);
+		

CVS commit: src/sys/dev/pci

2017-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 28 05:43:42 UTC 2017

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

Log Message:
- Fix panic in xhci_pci_detach() if xhci_pci_attach() failed.
- Fallback from MSI to INTx correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/xhci_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/dev/pci/xhci_pci.c
diff -u src/sys/dev/pci/xhci_pci.c:1.10 src/sys/dev/pci/xhci_pci.c:1.11
--- src/sys/dev/pci/xhci_pci.c:1.10	Mon Dec 25 08:39:38 2017
+++ src/sys/dev/pci/xhci_pci.c	Thu Dec 28 05:43:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci_pci.c,v 1.10 2017/12/25 08:39:38 msaitoh Exp $	*/
+/*	$NetBSD: xhci_pci.c,v 1.11 2017/12/28 05:43:42 msaitoh Exp $	*/
 /*	OpenBSD: xhci_pci.c,v 1.4 2014/07/12 17:38:51 yuo Exp	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.10 2017/12/25 08:39:38 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.11 2017/12/28 05:43:42 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_xhci_pci.h"
@@ -204,6 +204,7 @@ alloc_retry:
 		case PCI_INTR_TYPE_MSI:
 			/* The next try is for INTx: Disable MSI */
 			counts[PCI_INTR_TYPE_MSI] = 0;
+			counts[PCI_INTR_TYPE_INTX] = 1;
 			goto alloc_retry;
 		case PCI_INTR_TYPE_INTX:
 		default:
@@ -273,15 +274,15 @@ xhci_pci_detach(device_t self, int flags
 	struct xhci_softc * const sc = >sc_xhci;
 	int rv;
 
-	rv = xhci_detach(sc, flags);
-	if (rv)
-		return rv;
+	if (sc->sc_ios != 0) {
+		rv = xhci_detach(sc, flags);
+		if (rv)
+			return rv;
 
-	pmf_device_deregister(self);
+		pmf_device_deregister(self);
 
-	xhci_shutdown(self, flags);
+		xhci_shutdown(self, flags);
 
-	if (sc->sc_ios) {
 #if 0
 		/* Disable interrupts, so we don't get any spurious ones. */
 		bus_space_write_4(sc->sc_iot, sc->sc_ioh,



CVS commit: src/tests/rump/kernspace

2017-12-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Dec 28 04:38:02 UTC 2017

Modified Files:
src/tests/rump/kernspace: workqueue.c

Log Message:
Fix a race condition on taking the mutex

The workqueue worker can take the mutex before the tester tries to take it after
calling workqueue_enqueue. If it happens, the worker calls cv_broadcast before
the tester calls cv_timedwait and the tester will wait until the cv timed out

Take the mutex before calling workqueue_enqueue so that the tester surely calls
cv_timedwait before the worker calls cv_broadcast.

The fix stabilizes the test, t_workqueue/workqueue1.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/rump/kernspace/workqueue.c

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

Modified files:

Index: src/tests/rump/kernspace/workqueue.c
diff -u src/tests/rump/kernspace/workqueue.c:1.2 src/tests/rump/kernspace/workqueue.c:1.3
--- src/tests/rump/kernspace/workqueue.c:1.2	Thu Dec 28 04:36:15 2017
+++ src/tests/rump/kernspace/workqueue.c	Thu Dec 28 04:38:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: workqueue.c,v 1.2 2017/12/28 04:36:15 ozaki-r Exp $	*/
+/*	$NetBSD: workqueue.c,v 1.3 2017/12/28 04:38:02 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: workqueue.c,v 1.2 2017/12/28 04:36:15 ozaki-r Exp $");
+__RCSID("$NetBSD: workqueue.c,v 1.3 2017/12/28 04:38:02 ozaki-r Exp $");
 #endif /* !lint */
 
 #include 
@@ -84,8 +84,8 @@ rumptest_workqueue1()
 #define ITERATIONS 12435
 	for (size_t i = 0; i < ITERATIONS; ++i) {
 		int e;
-		workqueue_enqueue(sc->wq, >wk, NULL);
 		mutex_enter(>mtx);
+		workqueue_enqueue(sc->wq, >wk, NULL);
 		e = cv_timedwait(>cv, >mtx, hz * 2);
 		if (e != 0)
 			panic("cv_timedwait timed out (i=%lu)", i);



CVS commit: src/tests/rump/kernspace

2017-12-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Dec 28 04:36:15 UTC 2017

Modified Files:
src/tests/rump/kernspace: workqueue.c

Log Message:
Tweak use of cv_timedwait

- Handle its return value
- Specify more appropriate time-out periods (2 ticks is too short)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/rump/kernspace/workqueue.c

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

Modified files:

Index: src/tests/rump/kernspace/workqueue.c
diff -u src/tests/rump/kernspace/workqueue.c:1.1 src/tests/rump/kernspace/workqueue.c:1.2
--- src/tests/rump/kernspace/workqueue.c:1.1	Fri Sep 29 12:42:36 2017
+++ src/tests/rump/kernspace/workqueue.c	Thu Dec 28 04:36:15 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: workqueue.c,v 1.1 2017/09/29 12:42:36 maya Exp $	*/
+/*	$NetBSD: workqueue.c,v 1.2 2017/12/28 04:36:15 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: workqueue.c,v 1.1 2017/09/29 12:42:36 maya Exp $");
+__RCSID("$NetBSD: workqueue.c,v 1.2 2017/12/28 04:36:15 ozaki-r Exp $");
 #endif /* !lint */
 
 #include 
@@ -83,9 +83,12 @@ rumptest_workqueue1()
 
 #define ITERATIONS 12435
 	for (size_t i = 0; i < ITERATIONS; ++i) {
+		int e;
 		workqueue_enqueue(sc->wq, >wk, NULL);
 		mutex_enter(>mtx);
-		cv_timedwait(>cv, >mtx, 2);
+		e = cv_timedwait(>cv, >mtx, hz * 2);
+		if (e != 0)
+			panic("cv_timedwait timed out (i=%lu)", i);
 		mutex_exit(>mtx);
 	}
 



CVS commit: src/sys/kern

2017-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 28 03:39:48 UTC 2017

Modified Files:
src/sys/kern: kern_softint.c subr_pserialize.c subr_psref.c

Log Message:
 Prevent panic or hangup in softint_disestablish(), pserialize_perform() or
psref_target_destroy() while mp_online == false.

 See http://mail-index.netbsd.org/tech-kern/2017/12/25/msg022829.html


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/kern/kern_softint.c
cvs rdiff -u -r1.9 -r1.10 src/sys/kern/subr_pserialize.c \
src/sys/kern/subr_psref.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_softint.c
diff -u src/sys/kern/kern_softint.c:1.44 src/sys/kern/kern_softint.c:1.45
--- src/sys/kern/kern_softint.c:1.44	Wed Nov 22 02:20:21 2017
+++ src/sys/kern/kern_softint.c	Thu Dec 28 03:39:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_softint.c,v 1.44 2017/11/22 02:20:21 msaitoh Exp $	*/
+/*	$NetBSD: kern_softint.c,v 1.45 2017/12/28 03:39:48 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -170,13 +170,14 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.44 2017/11/22 02:20:21 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.45 2017/12/28 03:39:48 msaitoh Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -430,8 +431,10 @@ softint_disestablish(void *arg)
 	 * it again.  So, we are only looking for handler records with
 	 * SOFTINT_ACTIVE already set.
 	 */
-	where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-	xc_wait(where);
+	if (__predict_true(mp_online)) {
+		where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
+		xc_wait(where);
+	}
 
 	for (;;) {
 		/* Collect flag values from each CPU. */

Index: src/sys/kern/subr_pserialize.c
diff -u src/sys/kern/subr_pserialize.c:1.9 src/sys/kern/subr_pserialize.c:1.10
--- src/sys/kern/subr_pserialize.c:1.9	Tue Nov 21 08:49:14 2017
+++ src/sys/kern/subr_pserialize.c	Thu Dec 28 03:39:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pserialize.c,v 1.9 2017/11/21 08:49:14 ozaki-r Exp $	*/
+/*	$NetBSD: subr_pserialize.c,v 1.10 2017/12/28 03:39:48 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.9 2017/11/21 08:49:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.10 2017/12/28 03:39:48 msaitoh Exp $");
 
 #include 
 
@@ -157,6 +157,11 @@ pserialize_perform(pserialize_t psz)
 	KASSERT(psz->psz_owner == NULL);
 	KASSERT(ncpu > 0);
 
+	if (__predict_false(mp_online == false)) {
+		psz_ev_excl.ev_count++;
+		return;
+	}
+
 	/*
 	 * Set up the object and put it onto the queue.  The lock
 	 * activity here provides the necessary memory barrier to
Index: src/sys/kern/subr_psref.c
diff -u src/sys/kern/subr_psref.c:1.9 src/sys/kern/subr_psref.c:1.10
--- src/sys/kern/subr_psref.c:1.9	Thu Dec 14 05:45:55 2017
+++ src/sys/kern/subr_psref.c	Thu Dec 28 03:39:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_psref.c,v 1.9 2017/12/14 05:45:55 ozaki-r Exp $	*/
+/*	$NetBSD: subr_psref.c,v 1.10 2017/12/28 03:39:48 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_psref.c,v 1.9 2017/12/14 05:45:55 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_psref.c,v 1.10 2017/12/28 03:39:48 msaitoh Exp $");
 
 #include 
 #include 
@@ -429,8 +429,14 @@ psreffed_p(struct psref_target *target, 
 		.ret = false,
 	};
 
-	/* Ask all CPUs to say whether they hold a psref to the target.  */
-	xc_wait(xc_broadcast(0, _p_xc, , NULL));
+	if (__predict_true(mp_online)) {
+		/*
+		 * Ask all CPUs to say whether they hold a psref to the
+		 * target.
+		 */
+		xc_wait(xc_broadcast(0, _p_xc, , NULL));
+	} else
+		psreffed_p_xc(, NULL);
 
 	return P.ret;
 }



CVS commit: src/tools

2017-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 27 21:34:12 UTC 2017

Modified Files:
src/tools: Makefile
src/tools/dbsym: Makefile
src/tools/mdsetimage: Makefile

Log Message:
Better EXTERNAL_TOOLCHAIN support from Zachary McGrew
- Allow mdsetimage and dbsym to be built with EXTERNAL_TOOLCHAIN
- Allow BFDDIR and IBERTYDIR to be overwritten for mdsetimage and dbsym


To generate a diff of this commit:
cvs rdiff -u -r1.191 -r1.192 src/tools/Makefile
cvs rdiff -u -r1.11 -r1.12 src/tools/dbsym/Makefile
cvs rdiff -u -r1.13 -r1.14 src/tools/mdsetimage/Makefile

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

Modified files:

Index: src/tools/Makefile
diff -u src/tools/Makefile:1.191 src/tools/Makefile:1.192
--- src/tools/Makefile:1.191	Wed Jun  7 06:38:33 2017
+++ src/tools/Makefile	Wed Dec 27 16:34:11 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.191 2017/06/07 10:38:33 skrll Exp $
+#	$NetBSD: Makefile,v 1.192 2017/12/27 21:34:11 christos Exp $
 
 .include 
 .include 
@@ -53,9 +53,7 @@ TOOLCHAIN_BITS+= pcc
 . endif
 .endif
 
-.if ${TOOLCHAIN_MISSING} == "no"
-# XXX Eventually, we want to be able to build dbsym and mdsetimage
-# XXX if EXTERNAL_TOOLCHAIN is set.
+.if ${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)
 TOOLCHAIN_BITS+= dbsym mdsetimage
 .endif
 

Index: src/tools/dbsym/Makefile
diff -u src/tools/dbsym/Makefile:1.11 src/tools/dbsym/Makefile:1.12
--- src/tools/dbsym/Makefile:1.11	Fri Jan  6 15:27:19 2017
+++ src/tools/dbsym/Makefile	Wed Dec 27 16:34:11 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.11 2017/01/06 20:27:19 christos Exp $
+#	$NetBSD: Makefile,v 1.12 2017/12/27 21:34:11 christos Exp $
 
 NOMAN=	# defined
 
@@ -9,8 +9,8 @@ HOSTPROGNAME=	${MACHINE_GNU_PLATFORM}-db
 HOST_SRCDIR=external/gpl3/binutils/usr.sbin/dbsym
 
 TOOLCHAINOBJ!=	cd ${.CURDIR}/../binutils && ${PRINTOBJDIR}
-BFDDIR=		${TOOLCHAINOBJ}/build/bfd
-IBERTYDIR=	${TOOLCHAINOBJ}/build/libiberty
+BFDDIR?=	${TOOLCHAINOBJ}/build/bfd
+IBERTYDIR?=	${TOOLCHAINOBJ}/build/libiberty
 
 .include "${.CURDIR}/../Makefile.host"
 

Index: src/tools/mdsetimage/Makefile
diff -u src/tools/mdsetimage/Makefile:1.13 src/tools/mdsetimage/Makefile:1.14
--- src/tools/mdsetimage/Makefile:1.13	Fri Jan  6 15:27:19 2017
+++ src/tools/mdsetimage/Makefile	Wed Dec 27 16:34:12 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.13 2017/01/06 20:27:19 christos Exp $
+#	$NetBSD: Makefile,v 1.14 2017/12/27 21:34:12 christos Exp $
 
 NOMAN=	# defined
 
@@ -9,8 +9,8 @@ HOSTPROGNAME=	${MACHINE_GNU_PLATFORM}-md
 HOST_SRCDIR=	external/gpl3/binutils/usr.sbin/mdsetimage
 
 TOOLCHAINOBJ!=	cd ${.CURDIR}/../binutils && ${PRINTOBJDIR}
-BFDDIR=		${TOOLCHAINOBJ}/build/bfd
-IBERTYDIR=	${TOOLCHAINOBJ}/build/libiberty
+BFDDIR?=	${TOOLCHAINOBJ}/build/bfd
+IBERTYDIR?=	${TOOLCHAINOBJ}/build/libiberty
 
 .include "${.CURDIR}/../Makefile.host"
 



CVS commit: src/sys/dev/pci

2017-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 27 20:27:02 UTC 2017

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

Log Message:
PR/52868: Petar Bogdanovic: Add support for Manhattan 158220 card


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/pci/pucdata.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/pucdata.c
diff -u src/sys/dev/pci/pucdata.c:1.99 src/sys/dev/pci/pucdata.c:1.100
--- src/sys/dev/pci/pucdata.c:1.99	Sat Jan 14 23:45:39 2017
+++ src/sys/dev/pci/pucdata.c	Wed Dec 27 15:27:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pucdata.c,v 1.99 2017/01/15 04:45:39 msaitoh Exp $	*/
+/*	$NetBSD: pucdata.c,v 1.100 2017/12/27 20:27:02 christos Exp $	*/
 
 /*
  * Copyright (c) 1998, 1999 Christopher G. Demetriou.  All rights reserved.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pucdata.c,v 1.99 2017/01/15 04:45:39 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pucdata.c,v 1.100 2017/12/27 20:27:02 christos Exp $");
 
 #include 
 #include 
@@ -879,6 +879,15 @@ const struct puc_device_description puc_
 	},
 	},
 
+	/* NetMos PCI NM9865 : 1P */
+	{   "NetMos NM9865 Single LPT",
+	{	PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9865, 0xa000, 0x2000 },
+	{	0x,	0x,	0x,	0x	},
+	{
+		{ PUC_PORT_TYPE_LPT, PCI_BAR0, 0x00, 0x00 },
+	},
+	},
+
 	/* NetMos 2S PCI NM9865 : 2S */
 	{   "NetMos NM9865 2 UART",
 	{	PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9865, 0xa000, 0x3002 },



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

2017-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 27 19:35:05 UTC 2017

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

Log Message:
PR/52867: Martin Husemann: arm sofware breakpoint asm is slightly off

ARM uses an undefined instruction to emulate a software breakpoint.
However, the ptrace.h instruction on the one hand, and gdb/the kernel
disagree on the exact value.

This causes PTRACE_BREAKPOINT_ASM to generate a SIGILL instead of a SIGTRAP.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/include/ptrace.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/ptrace.h
diff -u src/sys/arch/arm/include/ptrace.h:1.11 src/sys/arch/arm/include/ptrace.h:1.12
--- src/sys/arch/arm/include/ptrace.h:1.11	Wed Apr 12 14:17:59 2017
+++ src/sys/arch/arm/include/ptrace.h	Wed Dec 27 14:35:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptrace.h,v 1.11 2017/04/12 18:17:59 kamil Exp $	*/
+/*	$NetBSD: ptrace.h,v 1.12 2017/12/27 19:35:05 christos Exp $	*/
 
 /*
  * Copyright (c) 1995 Frank Lancaster
@@ -64,7 +64,12 @@
 #define PTRACE_REG_SP(_r)		(_r)->r_sp
 #define PTRACE_REG_INTRV(_r)		(_r)->r[0]
 
-#define PTRACE_BREAKPOINT	((const uint8_t[]) { 0xe7, 0xff, 0xff, 0xfe })
-#define PTRACE_BREAKPOINT_INSN	0xe7fe
+#ifdef __ARMEB__
+#define PTRACE_BREAKPOINT	((const uint8_t[]) { 0xfe, 0xde, 0xff, 0xe7 })
+#define PTRACE_BREAKPOINT_INSN	0xfedeffe7
+#else
+#define PTRACE_BREAKPOINT	((const uint8_t[]) { 0xe7, 0xff, 0xde, 0xfe })
+#define PTRACE_BREAKPOINT_INSN	0xe7ffdefe
+#endif
 #define PTRACE_BREAKPOINT_ASM	__asm __volatile (".word " ___STRING(PTRACE_BREAKPOINT_INSN) )
 #define PTRACE_BREAKPOINT_SIZE	4



CVS commit: src/external/gpl3/gdb/dist/gdb

2017-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 27 19:20:41 UTC 2017

Modified Files:
src/external/gpl3/gdb/dist/gdb: amd64-nbsd-nat.c

Log Message:
remove unused code
XXX: we should remove this from all archs


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/gpl3/gdb/dist/gdb/amd64-nbsd-nat.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/gpl3/gdb/dist/gdb/amd64-nbsd-nat.c
diff -u src/external/gpl3/gdb/dist/gdb/amd64-nbsd-nat.c:1.4 src/external/gpl3/gdb/dist/gdb/amd64-nbsd-nat.c:1.5
--- src/external/gpl3/gdb/dist/gdb/amd64-nbsd-nat.c:1.4	Thu Nov 30 10:26:54 2017
+++ src/external/gpl3/gdb/dist/gdb/amd64-nbsd-nat.c	Wed Dec 27 14:20:41 2017
@@ -122,45 +122,6 @@ amd64nbsd_supply_pcb (struct regcache *r
   return 1;
 }
 
-void
-supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
-{
-  amd64_supply_native_gregset (regcache, gregsetp, -1);
-}
-
-/* Fill register REGNUM (if it is a general-purpose register) in
-   *GREGSETP with the value in GDB's register cache.  If REGNUM is -1,
-   do this for all registers.  */
-
-void
-fill_gregset (const struct regcache *regcache,
-	  gregset_t *gregsetp, int regnum)
-{
-  amd64_collect_native_gregset (regcache, gregsetp, regnum);
-}
-
-/* Transfering floating-point registers between GDB, inferiors and cores.  */
-
-/* Fill GDB's register cache with the floating-point and SSE register
-   values in *FPREGSETP.  */
-
-void
-supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
-{
-  amd64_supply_fxsave (regcache, -1, fpregsetp);
-}
-
-/* Fill register REGNUM (if it is a floating-point or SSE register) in
-   *FPREGSETP with the value in GDB's register cache.  If REGNUM is
-   -1, do this for all registers.  */
-
-void
-fill_fpregset (const struct regcache *regcache,
-	   fpregset_t *fpregsetp, int regnum)
-{
-  amd64_collect_fxsave (regcache, regnum, fpregsetp);
-}
-
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 void _initialize_amd64nbsd_nat (void);
 



CVS commit: src/external/gpl3/gdb/dist/gdb

2017-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 27 19:20:04 UTC 2017

Modified Files:
src/external/gpl3/gdb/dist/gdb: x86-bsd-nat.c

Log Message:
one more place to pass the thread id


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/x86-bsd-nat.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/gpl3/gdb/dist/gdb/x86-bsd-nat.c
diff -u src/external/gpl3/gdb/dist/gdb/x86-bsd-nat.c:1.3 src/external/gpl3/gdb/dist/gdb/x86-bsd-nat.c:1.4
--- src/external/gpl3/gdb/dist/gdb/x86-bsd-nat.c:1.3	Fri Dec  1 17:15:17 2017
+++ src/external/gpl3/gdb/dist/gdb/x86-bsd-nat.c	Wed Dec 27 14:20:04 2017
@@ -69,7 +69,7 @@ x86bsd_dr_get (ptid_t ptid, int regnum)
   struct dbreg dbregs;
 
   if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid),
-	  (PTRACE_TYPE_ARG3) , 0) == -1)
+	  (PTRACE_TYPE_ARG3) , ptid_get_lwp (inferior_ptid)) == -1)
 perror_with_name (_("Couldn't read debug registers"));
 
   return DBREG_DRX ((), regnum);



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

2017-12-27 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Wed Dec 27 18:30:02 UTC 2017

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

Log Message:
Without RADEONFB_ALWAYS_ACCEL_PUTCHAR, there are display issues on the 
PowerBook5,2 (G4 FW-800)
Radeon 9600, where console is garbled.
Thanks to  for the pointer.
Closes PR port-macppc/52712


To generate a diff of this commit:
cvs rdiff -u -r1.336 -r1.337 src/sys/arch/macppc/conf/GENERIC

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

Modified files:

Index: src/sys/arch/macppc/conf/GENERIC
diff -u src/sys/arch/macppc/conf/GENERIC:1.336 src/sys/arch/macppc/conf/GENERIC:1.337
--- src/sys/arch/macppc/conf/GENERIC:1.336	Fri Sep 22 04:09:06 2017
+++ src/sys/arch/macppc/conf/GENERIC	Wed Dec 27 18:30:02 2017
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.336 2017/09/22 04:09:06 macallan Exp $
+# $NetBSD: GENERIC,v 1.337 2017/12/27 18:30:02 sevan Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include		"arch/macppc/conf/std.macppc"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.336 $"
+#ident 		"GENERIC-$Revision: 1.337 $"
 
 maxusers	32
 
@@ -287,6 +287,7 @@ voodoofb*	at pci? function ?	# 3Dfx Vood
 
 # ATI Radeon. Still has problems on some hardware
 radeonfb*	at pci? function ?
+options 	RADEONFB_ALWAYS_ACCEL_PUTCHAR
 
 # generic PCI framebuffer, should work with everything supported by OF
 genfb*		at pci? function ?



CVS commit: src/tests/lib/libc/sys

2017-12-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Dec 27 13:38:51 UTC 2017

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
atf: ptrace: Temporarily disable signal3 as it breaks now on some ports

This test is marked as failing with: PR kern/51918.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/tests/lib/libc/sys/t_ptrace_wait.c

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/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.19 src/tests/lib/libc/sys/t_ptrace_wait.c:1.20
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.19	Mon Dec 25 12:38:01 2017
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Wed Dec 27 13:38:51 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.19 2017/12/25 12:38:01 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.20 2017/12/27 13:38:51 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.19 2017/12/25 12:38:01 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.20 2017/12/27 13:38:51 kamil Exp $");
 
 #include 
 #include 
@@ -5770,6 +5770,11 @@ ATF_TC_BODY(signal3, tc)
 #endif
 	sigset_t intmask;
 
+	atf_tc_expect_fail("PR kern/51918");
+
+	// This test breaks now on some ports, temporarily disable it
+	ATF_REQUIRE(0 && "In order to get reliable failure, abort");
+
 #if defined(__sparc__)
 	atf_tc_expect_timeout("PR kern/52167");
 



CVS commit: src/sys/rump/librump/rumpkern

2017-12-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec 27 09:03:22 UTC 2017

Modified Files:
src/sys/rump/librump/rumpkern: locks.c

Log Message:
rump: check if the mutex is surely owned by the caller in mutex_exit

Unlocking a not-owned mutex wasn't detected well (it could detect if the mutex
is not held by anyone but that's not enough). Let's check it (the check is the
same as normal kernel's mutex).

If LOCKDEBUG is enabled, give the check over LOCKDEBUG because it can provide
better debugging information.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/rump/librump/rumpkern/locks.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/rump/librump/rumpkern/locks.c
diff -u src/sys/rump/librump/rumpkern/locks.c:1.78 src/sys/rump/librump/rumpkern/locks.c:1.79
--- src/sys/rump/librump/rumpkern/locks.c:1.78	Wed Dec 27 09:01:53 2017
+++ src/sys/rump/librump/rumpkern/locks.c	Wed Dec 27 09:03:22 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locks.c,v 1.78 2017/12/27 09:01:53 ozaki-r Exp $	*/
+/*	$NetBSD: locks.c,v 1.79 2017/12/27 09:03:22 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.78 2017/12/27 09:01:53 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.79 2017/12/27 09:03:22 ozaki-r Exp $");
 
 #include 
 #include 
@@ -186,6 +186,9 @@ void
 mutex_exit(kmutex_t *mtx)
 {
 
+#ifndef LOCKDEBUG
+	KASSERT(mutex_owned(mtx));
+#endif
 	UNLOCKED(mtx, false);
 	rumpuser_mutex_exit(RUMPMTX(mtx));
 }



CVS commit: src

2017-12-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec 27 09:01:53 UTC 2017

Modified Files:
src/lib/librumpuser: rumpfiber.c rumpuser_pth.c rumpuser_pth_dummy.c
src/sys/rump/include/rump: rumpuser.h
src/sys/rump/librump/rumpkern: locks.c

Log Message:
Distinguish spin mutex and adaptive mutex on rump kernels for LOCKDEBUG

Formerly rump kernels treated the two types of mutexes as both adaptive for
LOCKDEBUG for some reasons.

Now we can detect violations of mutex restrictions on rump kernels such as
taking an adaptive mutex with holding a spin mutex as well as normal kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/librumpuser/rumpfiber.c
cvs rdiff -u -r1.45 -r1.46 src/lib/librumpuser/rumpuser_pth.c
cvs rdiff -u -r1.17 -r1.18 src/lib/librumpuser/rumpuser_pth_dummy.c
cvs rdiff -u -r1.114 -r1.115 src/sys/rump/include/rump/rumpuser.h
cvs rdiff -u -r1.77 -r1.78 src/sys/rump/librump/rumpkern/locks.c

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

Modified files:

Index: src/lib/librumpuser/rumpfiber.c
diff -u src/lib/librumpuser/rumpfiber.c:1.12 src/lib/librumpuser/rumpfiber.c:1.13
--- src/lib/librumpuser/rumpfiber.c:1.12	Sun Feb 15 00:54:32 2015
+++ src/lib/librumpuser/rumpfiber.c	Wed Dec 27 09:01:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfiber.c,v 1.12 2015/02/15 00:54:32 justin Exp $	*/
+/*	$NetBSD: rumpfiber.c,v 1.13 2017/12/27 09:01:53 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2007-2013 Antti Kantee.  All Rights Reserved.
@@ -68,7 +68,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpfiber.c,v 1.12 2015/02/15 00:54:32 justin Exp $");
+__RCSID("$NetBSD: rumpfiber.c,v 1.13 2017/12/27 09:01:53 ozaki-r Exp $");
 #endif /* !lint */
 
 #include 
@@ -693,6 +693,13 @@ rumpuser_mutex_init(struct rumpuser_mtx 
 	*mtxp = mtx;
 }
 
+int
+rumpuser_mutex_spin_p(struct rumpuser_mtx *mtx)
+{
+
+	return (mtx->flags & RUMPUSER_MTX_SPIN) != 0;
+}
+
 void
 rumpuser_mutex_enter(struct rumpuser_mtx *mtx)
 {

Index: src/lib/librumpuser/rumpuser_pth.c
diff -u src/lib/librumpuser/rumpuser_pth.c:1.45 src/lib/librumpuser/rumpuser_pth.c:1.46
--- src/lib/librumpuser/rumpuser_pth.c:1.45	Fri Sep 18 10:56:25 2015
+++ src/lib/librumpuser/rumpuser_pth.c	Wed Dec 27 09:01:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.45 2015/09/18 10:56:25 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.46 2017/12/27 09:01:53 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth.c,v 1.45 2015/09/18 10:56:25 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.46 2017/12/27 09:01:53 ozaki-r Exp $");
 #endif /* !lint */
 
 #include 
@@ -159,6 +159,13 @@ rumpuser_mutex_init(struct rumpuser_mtx 
 	*mtxp = mtx;
 }
 
+int
+rumpuser_mutex_spin_p(struct rumpuser_mtx *mtx)
+{
+
+	return (mtx->flags & RUMPUSER_MTX_SPIN) != 0;
+}
+
 static void
 mtxenter(struct rumpuser_mtx *mtx)
 {

Index: src/lib/librumpuser/rumpuser_pth_dummy.c
diff -u src/lib/librumpuser/rumpuser_pth_dummy.c:1.17 src/lib/librumpuser/rumpuser_pth_dummy.c:1.18
--- src/lib/librumpuser/rumpuser_pth_dummy.c:1.17	Tue Jun 17 06:43:21 2014
+++ src/lib/librumpuser/rumpuser_pth_dummy.c	Wed Dec 27 09:01:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth_dummy.c,v 1.17 2014/06/17 06:43:21 alnsn Exp $	*/
+/*	$NetBSD: rumpuser_pth_dummy.c,v 1.18 2017/12/27 09:01:53 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth_dummy.c,v 1.17 2014/06/17 06:43:21 alnsn Exp $");
+__RCSID("$NetBSD: rumpuser_pth_dummy.c,v 1.18 2017/12/27 09:01:53 ozaki-r Exp $");
 #endif /* !lint */
 
 #include 
@@ -98,6 +98,13 @@ rumpuser_mutex_init(struct rumpuser_mtx 
 	*mtx = calloc(1, sizeof(struct rumpuser_mtx));
 }
 
+int
+rumpuser_mutex_spin_p(struct rumpuser_mtx *mtx)
+{
+
+	return false; /* XXX */
+}
+
 void
 rumpuser_mutex_enter(struct rumpuser_mtx *mtx)
 {

Index: src/sys/rump/include/rump/rumpuser.h
diff -u src/sys/rump/include/rump/rumpuser.h:1.114 src/sys/rump/include/rump/rumpuser.h:1.115
--- src/sys/rump/include/rump/rumpuser.h:1.114	Sat Jan  3 17:24:20 2015
+++ src/sys/rump/include/rump/rumpuser.h	Wed Dec 27 09:01:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.h,v 1.114 2015/01/03 17:24:20 pooka Exp $	*/
+/*	$NetBSD: rumpuser.h,v 1.115 2017/12/27 09:01:53 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2007-2013 Antti Kantee.  All Rights Reserved.
@@ -194,6 +194,7 @@ int  rumpuser_mutex_tryenter(struct rump
 void rumpuser_mutex_exit(struct rumpuser_mtx *);
 void rumpuser_mutex_destroy(struct rumpuser_mtx *);
 void rumpuser_mutex_owner(struct rumpuser_mtx *, struct lwp **);
+int  rumpuser_mutex_spin_p(struct rumpuser_mtx *);
 
 struct rumpuser_rw;
 enum rumprwlock { RUMPUSER_RW_READER, RUMPUSER_RW_WRITER };


CVS commit: src/sys/rump/librump/rumpkern

2017-12-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec 27 08:45:45 UTC 2017

Modified Files:
src/sys/rump/librump/rumpkern: locks.c

Log Message:
Tweak LOCKDEBUG macros (NFC)


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/rump/librump/rumpkern/locks.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/rump/librump/rumpkern/locks.c
diff -u src/sys/rump/librump/rumpkern/locks.c:1.76 src/sys/rump/librump/rumpkern/locks.c:1.77
--- src/sys/rump/librump/rumpkern/locks.c:1.76	Mon Dec 25 09:13:40 2017
+++ src/sys/rump/librump/rumpkern/locks.c	Wed Dec 27 08:45:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locks.c,v 1.76 2017/12/25 09:13:40 ozaki-r Exp $	*/
+/*	$NetBSD: locks.c,v 1.77 2017/12/27 08:45:45 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.76 2017/12/25 09:13:40 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.77 2017/12/27 08:45:45 ozaki-r Exp $");
 
 #include 
 #include 
@@ -62,28 +62,28 @@ static lockops_t rw_lockops = {
 };
 
 #define ALLOCK(lock, ops)\
-lockdebug_alloc(__func__, __LINE__, lock, ops,	\
-(uintptr_t)__builtin_return_address(0))
-#define FREELOCK(lock)			\
-lockdebug_free(__func__, __LINE__, lock)
+	lockdebug_alloc(__func__, __LINE__, lock, ops,	\
+	(uintptr_t)__builtin_return_address(0))
+#define FREELOCK(lock)	\
+	lockdebug_free(__func__, __LINE__, lock)
 #define WANTLOCK(lock, shar)\
-lockdebug_wantlock(__func__, __LINE__, lock,	\
-(uintptr_t)__builtin_return_address(0), shar)
+	lockdebug_wantlock(__func__, __LINE__, lock,	\
+	(uintptr_t)__builtin_return_address(0), shar)
 #define LOCKED(lock, shar)\
-lockdebug_locked(__func__, __LINE__, lock, NULL,	\
-(uintptr_t)__builtin_return_address(0), shar)
-#define UNLOCKED(lock, shar)		\
-lockdebug_unlocked(__func__, __LINE__, lock,	\
-(uintptr_t)__builtin_return_address(0), shar)
-#define BARRIER(lock, slp)		\
-lockdebug_barrier(__func__, __LINE__, lock, slp)
+	lockdebug_locked(__func__, __LINE__, lock, NULL,\
+	(uintptr_t)__builtin_return_address(0), shar)
+#define UNLOCKED(lock, shar)\
+	lockdebug_unlocked(__func__, __LINE__, lock,	\
+	(uintptr_t)__builtin_return_address(0), shar)
+#define BARRIER(lock, slp)\
+	lockdebug_barrier(__func__, __LINE__, lock, slp)
 #else
-#define ALLOCK(a, b)
-#define FREELOCK(a)
-#define WANTLOCK(a, b)
-#define LOCKED(a, b)
-#define UNLOCKED(a, b)
-#define BARRIER(a, b)
+#define ALLOCK(a, b)	do {} while (0)
+#define FREELOCK(a)	do {} while (0)
+#define WANTLOCK(a, b)	do {} while (0)
+#define LOCKED(a, b)	do {} while (0)
+#define UNLOCKED(a, b)	do {} while (0)
+#define BARRIER(a, b)	do {} while (0)
 #endif
 
 /*



CVS commit: src/sys/netinet

2017-12-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec 27 08:35:20 UTC 2017

Modified Files:
src/sys/netinet: in.c

Log Message:
Don't pass rwlock to callout_halt


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/sys/netinet/in.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/netinet/in.c
diff -u src/sys/netinet/in.c:1.212 src/sys/netinet/in.c:1.213
--- src/sys/netinet/in.c:1.212	Mon Dec 25 04:41:48 2017
+++ src/sys/netinet/in.c	Wed Dec 27 08:35:20 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in.c,v 1.212 2017/12/25 04:41:48 ozaki-r Exp $	*/
+/*	$NetBSD: in.c,v 1.213 2017/12/27 08:35:20 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.212 2017/12/25 04:41:48 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.213 2017/12/27 08:35:20 ozaki-r Exp $");
 
 #include "arp.h"
 
@@ -1953,6 +1953,7 @@ in_lltable_free_entry(struct lltable *ll
 {
 	struct ifnet *ifp __diagused;
 	size_t pkts_dropped;
+	bool locked = false;
 
 	LLE_WLOCK_ASSERT(lle);
 	KASSERT(llt != NULL);
@@ -1962,15 +1963,32 @@ in_lltable_free_entry(struct lltable *ll
 		ifp = llt->llt_ifp;
 		IF_AFDATA_WLOCK_ASSERT(ifp);
 		lltable_unlink_entry(llt, lle);
+		locked = true;
 	}
 
+	/*
+	 * We need to release the lock here to lle_timer proceeds;
+	 * lle_timer should stop immediately if LLE_LINKED isn't set.
+	 * Note that we cannot pass lle->lle_lock to callout_halt
+	 * because it's a rwlock.
+	 */
+	LLE_ADDREF(lle);
+	LLE_WUNLOCK(lle);
+	if (locked)
+		IF_AFDATA_WUNLOCK(ifp);
+
 	/* cancel timer */
-	if (callout_halt(>lle_timer, >lle_lock))
-		LLE_REMREF(lle);
+	callout_halt(>lle_timer, NULL);
+
+	LLE_WLOCK(lle);
+	LLE_REMREF(lle);
 
 	/* Drop hold queue */
 	pkts_dropped = llentry_free(lle);
 	arp_stat_add(ARP_STAT_DFRDROPPED, (uint64_t)pkts_dropped);
+
+	if (locked)
+		IF_AFDATA_WLOCK(ifp);
 }
 
 static int



CVS commit: src

2017-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Dec 27 08:29:02 UTC 2017

Modified Files:
src: UPDATING

Log Message:
Minor tweak to the vadvise entry.


To generate a diff of this commit:
cvs rdiff -u -r1.289 -r1.290 src/UPDATING

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

Modified files:

Index: src/UPDATING
diff -u src/UPDATING:1.289 src/UPDATING:1.290
--- src/UPDATING:1.289	Tue Dec 26 20:04:03 2017
+++ src/UPDATING	Wed Dec 27 08:29:02 2017
@@ -1,4 +1,4 @@
-$NetBSD: UPDATING,v 1.289 2017/12/26 20:04:03 christos Exp $
+$NetBSD: UPDATING,v 1.290 2017/12/27 08:29:02 martin Exp $
 
 This file (UPDATING) is intended to be a brief reference to recent
 changes that might cause problems in the build process, and a guide for
@@ -26,7 +26,7 @@ Recent changes:
 		cd $OBJ && find . -type d -name libc | xargs rm -rf
 	For architectures that support multiple "compat" binary targets,
 	you'll need to cleanup both the regular libc directory and the
-	compat one.
+	compat ones (the above command will do that).
 
 20171010:
 	a change to the build structure of external/bsd/acpica/bin/iasl