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

2022-10-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 30 10:20:46 UTC 2022

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

Log Message:
arm/pic: Sprinkle dtrace probes on interrupt handlers like x86.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.84 src/sys/arch/arm/pic/pic.c:1.85
--- src/sys/arch/arm/pic/pic.c:1.84	Sat Oct 29 15:13:27 2022
+++ src/sys/arch/arm/pic/pic.c	Sun Oct 30 10:20:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.84 2022/10/29 15:13:27 riastradh Exp $	*/
+/*	$NetBSD: pic.c,v 1.85 2022/10/30 10:20:45 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.84 2022/10/29 15:13:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.85 2022/10/30 10:20:45 riastradh Exp $");
 
 #include 
 #include 
@@ -47,6 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.84
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -94,6 +95,16 @@ EVCNT_ATTACH_STATIC(pic_deferral_ev);
 
 static int pic_init(void);
 
+SDT_PROBE_DEFINE3(sdt, kernel, intr, entry,
+"void (*)(void *)"/*func*/,
+"void *"/*arg*/,
+"struct intrsource *"/*is*/);
+SDT_PROBE_DEFINE4(sdt, kernel, intr, return,
+"void (*)(void *)"/*func*/,
+"void *"/*arg*/,
+"struct intrsource *"/*is*/,
+"int"/*handled*/);
+
 #ifdef __HAVE_PIC_SET_PRIORITY
 void
 pic_set_priority(struct cpu_info *ci, int newipl)
@@ -333,7 +344,7 @@ pic_dispatch(struct intrsource *is, void
 {
 	int (*func)(void *) = is->is_func;
 	void *arg = is->is_arg;
-	int ocpl, ncpl;
+	int ocpl, ncpl, handled __unused;
 
 	if (__predict_false(arg == NULL)) {
 		if (__predict_false(frame == NULL)) {
@@ -353,12 +364,16 @@ pic_dispatch(struct intrsource *is, void
 		KERNEL_LOCK(1, NULL);
 		const u_int ci_blcnt __diagused = curcpu()->ci_biglock_count;
 		const u_int l_blcnt __diagused = curlwp->l_blcnt;
-		(void)(*func)(arg);
+		SDT_PROBE3(sdt, kernel, intr, entry,  func, arg, is);
+		handled = (*func)(arg);
+		SDT_PROBE4(sdt, kernel, intr, return,  func, arg, is, handled);
 		KASSERT(ci_blcnt == curcpu()->ci_biglock_count);
 		KASSERT(l_blcnt == curlwp->l_blcnt);
 		KERNEL_UNLOCK_ONE(NULL);
 	} else {
-		(void)(*func)(arg);
+		SDT_PROBE3(sdt, kernel, intr, entry,  func, arg, is);
+		handled = (*func)(arg);
+		SDT_PROBE4(sdt, kernel, intr, return,  func, arg, is, handled);
 	}
 	ncpl = curcpu()->ci_cpl;
 	KASSERTMSG(ocpl <= ncpl, "pic %s irq %u intrsource %s:"



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

2022-10-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 30 10:20:46 UTC 2022

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

Log Message:
arm/pic: Sprinkle dtrace probes on interrupt handlers like x86.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 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.



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

2022-10-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Oct 29 15:13:28 UTC 2022

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

Log Message:
arm/pic: Use a local variable to reduce #ifdef scope.

Avoids straddling a conditional this way.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 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.



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

2022-10-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Oct 29 15:13:28 UTC 2022

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

Log Message:
arm/pic: Use a local variable to reduce #ifdef scope.

Avoids straddling a conditional this way.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.83 src/sys/arch/arm/pic/pic.c:1.84
--- src/sys/arch/arm/pic/pic.c:1.83	Thu Jul 28 10:26:26 2022
+++ src/sys/arch/arm/pic/pic.c	Sat Oct 29 15:13:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.83 2022/07/28 10:26:26 riastradh Exp $	*/
+/*	$NetBSD: pic.c,v 1.84 2022/10/29 15:13:27 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.83 2022/07/28 10:26:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.84 2022/10/29 15:13:27 riastradh Exp $");
 
 #include 
 #include 
@@ -345,7 +345,11 @@ pic_dispatch(struct intrsource *is, void
 
 	ocpl = curcpu()->ci_cpl;
 #ifdef MULTIPROCESSOR
-	if (!is->is_mpsafe) {
+	const bool mpsafe = is->is_mpsafe;
+#else
+	const bool mpsafe = true;
+#endif
+	if (!mpsafe) {
 		KERNEL_LOCK(1, NULL);
 		const u_int ci_blcnt __diagused = curcpu()->ci_biglock_count;
 		const u_int l_blcnt __diagused = curlwp->l_blcnt;
@@ -353,9 +357,9 @@ pic_dispatch(struct intrsource *is, void
 		KASSERT(ci_blcnt == curcpu()->ci_biglock_count);
 		KASSERT(l_blcnt == curlwp->l_blcnt);
 		KERNEL_UNLOCK_ONE(NULL);
-	} else
-#endif
+	} else {
 		(void)(*func)(arg);
+	}
 	ncpl = curcpu()->ci_cpl;
 	KASSERTMSG(ocpl <= ncpl, "pic %s irq %u intrsource %s:"
 	" cpl slipped %d -> %d",



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

2022-07-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Jul 28 10:26:26 UTC 2022

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

Log Message:
arm/pic: Mark definitions static to match declarations.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.82 src/sys/arch/arm/pic/pic.c:1.83
--- src/sys/arch/arm/pic/pic.c:1.82	Thu Jul 28 10:26:15 2022
+++ src/sys/arch/arm/pic/pic.c	Thu Jul 28 10:26:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.82 2022/07/28 10:26:15 riastradh Exp $	*/
+/*	$NetBSD: pic.c,v 1.83 2022/07/28 10:26:26 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.82 2022/07/28 10:26:15 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.83 2022/07/28 10:26:26 riastradh Exp $");
 
 #include 
 #include 
@@ -298,7 +298,7 @@ pic_mark_pending_sources(struct pic_soft
 	return ipl_mask;
 }
 
-uint32_t
+static uint32_t
 pic_find_pending_irqs_by_ipl(struct pic_softc *pic, size_t irq_base,
 	uint32_t pending, int ipl)
 {
@@ -369,7 +369,7 @@ pic_dispatch(struct intrsource *is, void
 }
 
 #if defined(__HAVE_PIC_PENDING_INTRS)
-void
+static void
 pic_deliver_irqs(struct cpu_info *ci, struct pic_softc *pic, int ipl,
 void *frame)
 {
@@ -505,7 +505,7 @@ pic_list_unblock_irqs(struct cpu_info *c
 	}
 }
 
-struct pic_softc *
+static struct pic_softc *
 pic_list_find_pic_by_pending_ipl(struct cpu_info *ci, uint32_t ipl_mask)
 {
 	uint32_t pending_pics = ci->ci_pending_pics;
@@ -524,7 +524,7 @@ pic_list_find_pic_by_pending_ipl(struct 
 	}
 }
 
-void
+static void
 pic_list_deliver_irqs(struct cpu_info *ci, register_t psw, int ipl,
 void *frame)
 {



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

2022-07-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Jul 28 10:26:26 UTC 2022

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

Log Message:
arm/pic: Mark definitions static to match declarations.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 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.



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

2022-07-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Jul 28 10:26:15 UTC 2022

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

Log Message:
arm/pic: Assert ci_cpl doesn't lower across interrupt handler.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.81 src/sys/arch/arm/pic/pic.c:1.82
--- src/sys/arch/arm/pic/pic.c:1.81	Thu Jul 28 07:15:27 2022
+++ src/sys/arch/arm/pic/pic.c	Thu Jul 28 10:26:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.81 2022/07/28 07:15:27 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.82 2022/07/28 10:26:15 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.81 2022/07/28 07:15:27 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.82 2022/07/28 10:26:15 riastradh Exp $");
 
 #include 
 #include 
@@ -333,6 +333,7 @@ pic_dispatch(struct intrsource *is, void
 {
 	int (*func)(void *) = is->is_func;
 	void *arg = is->is_arg;
+	int ocpl, ncpl;
 
 	if (__predict_false(arg == NULL)) {
 		if (__predict_false(frame == NULL)) {
@@ -342,6 +343,7 @@ pic_dispatch(struct intrsource *is, void
 		arg = frame;
 	}
 
+	ocpl = curcpu()->ci_cpl;
 #ifdef MULTIPROCESSOR
 	if (!is->is_mpsafe) {
 		KERNEL_LOCK(1, NULL);
@@ -354,6 +356,11 @@ pic_dispatch(struct intrsource *is, void
 	} else
 #endif
 		(void)(*func)(arg);
+	ncpl = curcpu()->ci_cpl;
+	KASSERTMSG(ocpl <= ncpl, "pic %s irq %u intrsource %s:"
+	" cpl slipped %d -> %d",
+	is->is_pic->pic_name, is->is_irq, is->is_source,
+	ocpl, ncpl);
 
 	struct pic_percpu * const pcpu = percpu_getref(is->is_pic->pic_percpu);
 	KASSERT(pcpu->pcpu_magic == PICPERCPU_MAGIC);



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

2022-07-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Jul 28 10:26:15 UTC 2022

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

Log Message:
arm/pic: Assert ci_cpl doesn't lower across interrupt handler.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 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.



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

2022-07-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul 28 07:15:27 UTC 2022

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

Log Message:
Catch up with the per lwp astpending (rather than per cpu) flag in the
preemption code.  NFC as preemption (still) isn't enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.80 src/sys/arch/arm/pic/pic.c:1.81
--- src/sys/arch/arm/pic/pic.c:1.80	Sat Jun 25 12:41:56 2022
+++ src/sys/arch/arm/pic/pic.c	Thu Jul 28 07:15:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.80 2022/06/25 12:41:56 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.81 2022/07/28 07:15:27 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.80 2022/06/25 12:41:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.81 2022/07/28 07:15:27 skrll Exp $");
 
 #include 
 #include 
@@ -150,7 +150,9 @@ pic_ipi_ddb(void *arg)
 int
 pic_ipi_kpreempt(void *arg)
 {
-	atomic_or_uint(()->ci_astpending, __BIT(1));
+	struct lwp * const l = curlwp;
+
+	l->l_md.md_astpending |= __BIT(1);
 	return 1;
 }
 #endif /* __HAVE_PREEMPTION */
@@ -554,7 +556,8 @@ pic_do_pending_ints(register_t psw, int 
 	}
 #endif /* __HAVE_PIC_PENDING_INTRS */
 #ifdef __HAVE_PREEMPTION
-	if (newipl == IPL_NONE && (ci->ci_astpending & __BIT(1))) {
+	struct lwp * const l = curlwp;
+	if (newipl == IPL_NONE && (l->l_md.md_astpending & __BIT(1))) {
 		pic_set_priority(ci, IPL_SCHED);
 		kpreempt(0);
 	}



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

2022-07-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul 28 07:15:27 UTC 2022

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

Log Message:
Catch up with the per lwp astpending (rather than per cpu) flag in the
preemption code.  NFC as preemption (still) isn't enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 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.



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

2022-06-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jun 25 12:39:46 UTC 2022

Modified Files:
src/sys/arch/arm/pic: pic_splfuncs.c

Log Message:
pic: splx performance improvement

Skip disabling interrupts and check for pending hard interrupts if old
ipl was < IPL_VM.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/pic/pic_splfuncs.c

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



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

2022-06-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jun 25 12:39:46 UTC 2022

Modified Files:
src/sys/arch/arm/pic: pic_splfuncs.c

Log Message:
pic: splx performance improvement

Skip disabling interrupts and check for pending hard interrupts if old
ipl was < IPL_VM.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/pic/pic_splfuncs.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/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.22 src/sys/arch/arm/pic/pic_splfuncs.c:1.23
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.22	Mon Sep 20 21:05:15 2021
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Sat Jun 25 12:39:46 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.22 2021/09/20 21:05:15 jmcneill Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.23 2022/06/25 12:39:46 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -31,7 +31,7 @@
 #include "opt_modular.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.22 2021/09/20 21:05:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.23 2022/06/25 12:39:46 jmcneill Exp $");
 
 #define _INTR_PRIVATE
 #include 
@@ -97,17 +97,22 @@ pic_default_splx(int savedipl)
 		return;
 	}
 
-	register_t psw = DISABLE_INTERRUPT_SAVE();
-	KASSERTMSG(panicstr != NULL || savedipl < ci->ci_cpl,
-	"splx(%d) to a higher ipl than %d", savedipl, ci->ci_cpl);
-
-	ci->ci_intr_depth++;
-	pic_do_pending_ints(psw, savedipl, NULL);
-	ci->ci_intr_depth--;
-	KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",
-	ci->ci_cpl, savedipl);
-	if ((psw & I32_bit) == 0)
-		ENABLE_INTERRUPT();
+	if (ci->ci_cpl >= IPL_VM) {
+		register_t psw = DISABLE_INTERRUPT_SAVE();
+		KASSERTMSG(panicstr != NULL || savedipl < ci->ci_cpl,
+		"splx(%d) to a higher ipl than %d", savedipl, ci->ci_cpl);
+
+		ci->ci_intr_depth++;
+		pic_do_pending_ints(psw, savedipl, NULL);
+		ci->ci_intr_depth--;
+		KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",
+		ci->ci_cpl, savedipl);
+		if ((psw & I32_bit) == 0)
+			ENABLE_INTERRUPT();
+	} else {
+		pic_set_priority(ci, savedipl);
+	}
+
 	cpu_dosoftints();
 	KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",
 	ci->ci_cpl, savedipl);



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

2022-01-02 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jan  2 11:17:39 UTC 2022

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

Log Message:
arm: No #if DIAGNOSTIC needed any more.

Compiler can (and gcc does) flush call to strlen when the result is
unused, so no performance impact here.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.78 src/sys/arch/arm/pic/pic.c:1.79
--- src/sys/arch/arm/pic/pic.c:1.78	Tue Dec 21 07:11:02 2021
+++ src/sys/arch/arm/pic/pic.c	Sun Jan  2 11:17:39 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.78 2021/12/21 07:11:02 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.79 2022/01/02 11:17:39 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.78 2021/12/21 07:11:02 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.79 2022/01/02 11:17:39 riastradh Exp $");
 
 #include 
 #include 
@@ -575,9 +575,7 @@ pic_percpu_allocate(void *v0, void *v1, 
 	KASSERT(pcpu->pcpu_evs != NULL);
 
 #define	PCPU_NAMELEN	32
-#ifdef DIAGNOSTIC
 	const size_t namelen = strlen(pic->pic_name) + 4 + strlen(ci->ci_data.cpu_name);
-#endif
 
 	KASSERT(namelen < PCPU_NAMELEN);
 	pcpu->pcpu_name = kmem_alloc(PCPU_NAMELEN, KM_SLEEP);



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

2022-01-02 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jan  2 11:17:39 UTC 2022

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

Log Message:
arm: No #if DIAGNOSTIC needed any more.

Compiler can (and gcc does) flush call to strlen when the result is
unused, so no performance impact here.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 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.



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

2021-12-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 07:11:02 UTC 2021

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

Log Message:
Fix a bug where pic_establish_intr would fail to call pic_establish_irq
if a free pic__iplsources slot was found, i.e. an interrupt handler at
the same ipl had been disestablished previously.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.77 src/sys/arch/arm/pic/pic.c:1.78
--- src/sys/arch/arm/pic/pic.c:1.77	Tue Dec 21 07:07:32 2021
+++ src/sys/arch/arm/pic/pic.c	Tue Dec 21 07:11:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.77 2021/12/21 07:07:32 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.78 2021/12/21 07:11:02 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.77 2021/12/21 07:07:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.78 2021/12/21 07:11:02 skrll Exp $");
 
 #include 
 #include 
@@ -754,42 +754,44 @@ pic_establish_intr(struct pic_softc *pic
 	/*
 	 * First try to use an existing slot which is empty.
 	 */
+	bool found = false;
 	for (off = pic_ipl_offset[ipl]; off < pic_ipl_offset[ipl + 1]; off++) {
 		if (pic__iplsources[off] == NULL) {
-			is->is_iplidx = off - pic_ipl_offset[ipl];
-			pic__iplsources[off] = is;
-			goto unblock;
+			found = true;
+			break;
 		}
 	}
 
-	/*
-	 * Move up all the sources by one.
- 	 */
-	if (ipl < NIPL) {
-		off = pic_ipl_offset[ipl + 1];
-		memmove(__iplsources[off + 1], __iplsources[off],
-		sizeof(pic__iplsources[0]) * (pic_ipl_offset[NIPL] - off));
-	}
+	if (!found) {
+		/*
+		* Move up all the sources by one.
+		*/
+		if (ipl < NIPL) {
+			off = pic_ipl_offset[ipl + 1];
+			memmove(__iplsources[off + 1], __iplsources[off],
+			sizeof(pic__iplsources[0]) * (pic_ipl_offset[NIPL] - off));
+		}
 
-	/*
-	 * Advance the offset of all IPLs higher than this.  Include an
-	 * extra one as well.  Thus the number of sources per ipl is
-	 * pic_ipl_offset[ipl + 1] - pic_ipl_offset[ipl].
-	 */
-	for (nipl = ipl + 1; nipl <= NIPL; nipl++)
-		pic_ipl_offset[nipl]++;
+		/*
+		* Advance the offset of all IPLs higher than this.  Include an
+		* extra one as well.  Thus the number of sources per ipl is
+		* pic_ipl_offset[ipl + 1] - pic_ipl_offset[ipl].
+		*/
+		for (nipl = ipl + 1; nipl <= NIPL; nipl++)
+			pic_ipl_offset[nipl]++;
+
+		off = pic_ipl_offset[ipl + 1] - 1;
+	}
 
 	/*
-	 * Insert into the previously made position at the end of this IPL's
-	 * sources.
+	 * Insert into the 'found' or the just made slot position at the end
+	 * of this IPL's sources.
 	 */
-	off = pic_ipl_offset[ipl + 1] - 1;
 	is->is_iplidx = off - pic_ipl_offset[ipl];
 	pic__iplsources[off] = is;
 
 	(*pic->pic_ops->pic_establish_irq)(pic, is);
 
-unblock:
 	if (!mp_online || !is->is_mpsafe || !is->is_percpu) {
 		(*pic->pic_ops->pic_unblock_irqs)(pic, is->is_irq & ~0x1f,
 		__BIT(is->is_irq & 0x1f));



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

2021-12-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 07:11:02 UTC 2021

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

Log Message:
Fix a bug where pic_establish_intr would fail to call pic_establish_irq
if a free pic__iplsources slot was found, i.e. an interrupt handler at
the same ipl had been disestablished previously.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 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.



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

2021-12-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 07:07:32 UTC 2021

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

Log Message:
G/C pic_iplsource


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.76 src/sys/arch/arm/pic/pic.c:1.77
--- src/sys/arch/arm/pic/pic.c:1.76	Tue Dec 21 06:51:16 2021
+++ src/sys/arch/arm/pic/pic.c	Tue Dec 21 07:07:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.76 2021/12/21 06:51:16 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.77 2021/12/21 07:07:32 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.76 2021/12/21 06:51:16 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.77 2021/12/21 07:07:32 skrll Exp $");
 
 #include 
 #include 
@@ -83,9 +83,6 @@ struct pic_softc *pic_list[PIC_MAXPICS];
 #endif
 struct intrsource *pic_sources[PIC_MAXMAXSOURCES];
 struct intrsource *pic__iplsources[PIC_MAXMAXSOURCES];
-struct intrsource **pic_iplsource[NIPL] = {
-	[0 ... NIPL - 1] = pic__iplsources,
-};
 size_t pic_ipl_offset[NIPL + 1];
 
 static kmutex_t pic_lock;



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

2021-12-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 07:07:32 UTC 2021

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

Log Message:
G/C pic_iplsource


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 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.



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

2021-12-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 06:51:17 UTC 2021

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 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.



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

2021-12-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 06:51:17 UTC 2021

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.75 src/sys/arch/arm/pic/pic.c:1.76
--- src/sys/arch/arm/pic/pic.c:1.75	Sun Oct 31 16:29:18 2021
+++ src/sys/arch/arm/pic/pic.c	Tue Dec 21 06:51:16 2021
@@ -1,4 +1,5 @@
-/*	$NetBSD: pic.c,v 1.75 2021/10/31 16:29:18 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.76 2021/12/21 06:51:16 skrll Exp $	*/
+
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +34,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.75 2021/10/31 16:29:18 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.76 2021/12/21 06:51:16 skrll Exp $");
 
 #include 
 #include 
@@ -83,9 +84,9 @@ struct pic_softc *pic_list[PIC_MAXPICS];
 struct intrsource *pic_sources[PIC_MAXMAXSOURCES];
 struct intrsource *pic__iplsources[PIC_MAXMAXSOURCES];
 struct intrsource **pic_iplsource[NIPL] = {
-	[0 ... NIPL-1] = pic__iplsources,
+	[0 ... NIPL - 1] = pic__iplsources,
 };
-size_t pic_ipl_offset[NIPL+1];
+size_t pic_ipl_offset[NIPL + 1];
 
 static kmutex_t pic_lock;
 static size_t pic_sourcebase;
@@ -756,7 +757,7 @@ pic_establish_intr(struct pic_softc *pic
 	/*
 	 * First try to use an existing slot which is empty.
 	 */
-	for (off = pic_ipl_offset[ipl]; off < pic_ipl_offset[ipl+1]; off++) {
+	for (off = pic_ipl_offset[ipl]; off < pic_ipl_offset[ipl + 1]; off++) {
 		if (pic__iplsources[off] == NULL) {
 			is->is_iplidx = off - pic_ipl_offset[ipl];
 			pic__iplsources[off] = is;
@@ -768,15 +769,15 @@ pic_establish_intr(struct pic_softc *pic
 	 * Move up all the sources by one.
  	 */
 	if (ipl < NIPL) {
-		off = pic_ipl_offset[ipl+1];
-		memmove(__iplsources[off+1], __iplsources[off],
+		off = pic_ipl_offset[ipl + 1];
+		memmove(__iplsources[off + 1], __iplsources[off],
 		sizeof(pic__iplsources[0]) * (pic_ipl_offset[NIPL] - off));
 	}
 
 	/*
 	 * Advance the offset of all IPLs higher than this.  Include an
 	 * extra one as well.  Thus the number of sources per ipl is
-	 * pic_ipl_offset[ipl+1] - pic_ipl_offset[ipl].
+	 * pic_ipl_offset[ipl + 1] - pic_ipl_offset[ipl].
 	 */
 	for (nipl = ipl + 1; nipl <= NIPL; nipl++)
 		pic_ipl_offset[nipl]++;



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

2021-10-31 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 31 16:29:18 UTC 2021

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

Log Message:
Only perform pic_unblock_percpu if all of the following are true
- mp_online, i.e. APs are running.
- is_mpsafe, i.e. the interrupt handler is MP safe
- is_percpu, i.e. the interrupt actually requires it!

The last one (is_percpu) is true for GIC PPI+SGI only.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.74 src/sys/arch/arm/pic/pic.c:1.75
--- src/sys/arch/arm/pic/pic.c:1.74	Sun Oct 31 16:24:47 2021
+++ src/sys/arch/arm/pic/pic.c	Sun Oct 31 16:29:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.74 2021/10/31 16:24:47 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.75 2021/10/31 16:29:18 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.74 2021/10/31 16:24:47 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.75 2021/10/31 16:29:18 skrll Exp $");
 
 #include 
 #include 
@@ -792,7 +792,7 @@ pic_establish_intr(struct pic_softc *pic
 	(*pic->pic_ops->pic_establish_irq)(pic, is);
 
 unblock:
-	if (!mp_online || !is->is_mpsafe) {
+	if (!mp_online || !is->is_mpsafe || !is->is_percpu) {
 		(*pic->pic_ops->pic_unblock_irqs)(pic, is->is_irq & ~0x1f,
 		__BIT(is->is_irq & 0x1f));
 	} else {



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

2021-10-31 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 31 16:29:18 UTC 2021

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

Log Message:
Only perform pic_unblock_percpu if all of the following are true
- mp_online, i.e. APs are running.
- is_mpsafe, i.e. the interrupt handler is MP safe
- is_percpu, i.e. the interrupt actually requires it!

The last one (is_percpu) is true for GIC PPI+SGI only.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 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.



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

2021-10-31 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 31 16:24:47 UTC 2021

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

Log Message:
Assert we can sleep in pic_add


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 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.



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

2021-10-31 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 31 16:24:47 UTC 2021

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

Log Message:
Assert we can sleep in pic_add


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.73 src/sys/arch/arm/pic/pic.c:1.74
--- src/sys/arch/arm/pic/pic.c:1.73	Sun Oct 31 16:23:48 2021
+++ src/sys/arch/arm/pic/pic.c	Sun Oct 31 16:24:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.73 2021/10/31 16:23:48 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.74 2021/10/31 16:24:47 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.73 2021/10/31 16:23:48 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.74 2021/10/31 16:24:47 skrll Exp $");
 
 #include 
 #include 
@@ -613,6 +613,8 @@ pic_add(struct pic_softc *pic, int irqba
 	size_t sourcebase;
 	static ONCE_DECL(pic_once);
 
+	ASSERT_SLEEPABLE();
+
 	RUN_ONCE(_once, pic_init);
 
 	KASSERT(strlen(pic->pic_name) > 0);



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

2021-08-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Aug 10 15:31:55 UTC 2021

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

Log Message:
arm: pic: allow overriding _splraise/_spllower/splx


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/pic/pic_splfuncs.c
cvs rdiff -u -r1.34 -r1.35 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/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.20 src/sys/arch/arm/pic/pic_splfuncs.c:1.21
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.20	Sat Mar 27 12:15:09 2021
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Tue Aug 10 15:31:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.20 2021/03/27 12:15:09 jmcneill Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.21 2021/08/10 15:31:55 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.20 2021/03/27 12:15:09 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.21 2021/08/10 15:31:55 jmcneill Exp $");
 
 #define _INTR_PRIVATE
 #include 
@@ -46,9 +46,16 @@ __KERNEL_RCSID(0, "$NetBSD: pic_splfuncs
 
 #include 
 
+static int	pic_default_splraise(int);
+static int	pic_default_spllower(int);
+static void	pic_default_splx(int);
+
+int (*_splraise)(int) = pic_default_splraise;
+int (*_spllower)(int) = pic_default_spllower;
+void (*splx)(int) = pic_default_splx;
 
-int
-_splraise(int newipl)
+static int
+pic_default_splraise(int newipl)
 {
 	struct cpu_info * const ci = curcpu();
 	const int oldipl = ci->ci_cpl;
@@ -58,8 +65,9 @@ _splraise(int newipl)
 	}
 	return oldipl;
 }
-int
-_spllower(int newipl)
+
+static int
+pic_default_spllower(int newipl)
 {
 	struct cpu_info * const ci = curcpu();
 	const int oldipl = ci->ci_cpl;
@@ -76,8 +84,8 @@ _spllower(int newipl)
 	return oldipl;
 }
 
-void
-splx(int savedipl)
+static void
+pic_default_splx(int savedipl)
 {
 	struct cpu_info * const ci = curcpu();
 	KASSERT(savedipl < NIPL);

Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.34 src/sys/arch/arm/pic/picvar.h:1.35
--- src/sys/arch/arm/pic/picvar.h:1.34	Sat Mar 27 12:15:09 2021
+++ src/sys/arch/arm/pic/picvar.h	Tue Aug 10 15:31:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.34 2021/03/27 12:15:09 jmcneill Exp $	*/
+/*	$NetBSD: picvar.h,v 1.35 2021/08/10 15:31:55 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -40,9 +40,10 @@
 
 typedef uint32_t	intr_handle_t;		/* for ACPI */
 
-int	_splraise(int);
-int	_spllower(int);
-void	splx(int);
+extern int	(*_splraise)(int);
+extern int	(*_spllower)(int);
+extern void	(*splx)(int);
+
 const char *
 	intr_typename(int);
 



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

2021-08-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Aug 10 15:31:55 UTC 2021

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

Log Message:
arm: pic: allow overriding _splraise/_spllower/splx


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/pic/pic_splfuncs.c
cvs rdiff -u -r1.34 -r1.35 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.



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

2021-02-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 27 14:22:07 UTC 2021

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

Log Message:
machine/cpufunc.h -> arm/cpufunc.h for the benefit of non-evbarm ports


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 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.



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

2021-02-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 27 14:22:07 UTC 2021

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

Log Message:
machine/cpufunc.h -> arm/cpufunc.h for the benefit of non-evbarm ports


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 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/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.32 src/sys/arch/arm/pic/picvar.h:1.33
--- src/sys/arch/arm/pic/picvar.h:1.32	Fri Feb 26 10:06:42 2021
+++ src/sys/arch/arm/pic/picvar.h	Sat Feb 27 14:22:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.32 2021/02/26 10:06:42 jmcneill Exp $	*/
+/*	$NetBSD: picvar.h,v 1.33 2021/02/27 14:22:07 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -107,7 +107,7 @@ void	intr_ipi_send(const kcpuset_t *, u_
 #include 
 #include 
 
-#include 
+#include 
 
 #ifndef PIC_MAXPICS
 #define PIC_MAXPICS	32



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

2021-02-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Feb 26 10:06:42 UTC 2021

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

Log Message:
Unfortunately we need to disable interrupts in pic_set_priority to keep
hardware and ci_cpl in sync.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 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/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.31 src/sys/arch/arm/pic/picvar.h:1.32
--- src/sys/arch/arm/pic/picvar.h:1.31	Sun Feb 21 17:07:45 2021
+++ src/sys/arch/arm/pic/picvar.h	Fri Feb 26 10:06:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.31 2021/02/21 17:07:45 jmcneill Exp $	*/
+/*	$NetBSD: picvar.h,v 1.32 2021/02/26 10:06:42 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -107,6 +107,8 @@ void	intr_ipi_send(const kcpuset_t *, u_
 #include 
 #include 
 
+#include 
+
 #ifndef PIC_MAXPICS
 #define PIC_MAXPICS	32
 #endif
@@ -184,10 +186,14 @@ struct pic_ops {
  */
 #define pic_set_priority(ci, newipl)	\
 	do {\
+		register_t __psw = cpsid(I32_bit);			\
 		(ci)->ci_cpl = (newipl);\
 		if (__predict_true(pic_list[0] != NULL)) {		\
 			(pic_list[0]->pic_ops->pic_set_priority)(pic_list[0], newipl); \
 		}			\
+		if ((__psw & I32_bit) == 0) {\
+			cpsie(I32_bit);	\
+		}			\
 	} while (0)
 #else
 #define	pic_set_priority(ci, newipl)		((void)((ci)->ci_cpl = (newipl)))



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

2021-02-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Feb 26 10:06:42 UTC 2021

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

Log Message:
Unfortunately we need to disable interrupts in pic_set_priority to keep
hardware and ci_cpl in sync.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 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.



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

2021-02-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Feb 22 21:16:25 UTC 2021

Modified Files:
src/sys/arch/arm/pic: pic_splfuncs.c

Log Message:
Make the splx fast path smaller.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/pic/pic_splfuncs.c

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



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

2021-02-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Feb 22 21:16:25 UTC 2021

Modified Files:
src/sys/arch/arm/pic: pic_splfuncs.c

Log Message:
Make the splx fast path smaller.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/pic/pic_splfuncs.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/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.17 src/sys/arch/arm/pic/pic_splfuncs.c:1.18
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.17	Sun Feb 21 17:07:45 2021
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Mon Feb 22 21:16:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.17 2021/02/21 17:07:45 jmcneill Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.18 2021/02/22 21:16:25 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.17 2021/02/21 17:07:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.18 2021/02/22 21:16:25 jmcneill Exp $");
 
 #define _INTR_PRIVATE
 #include 
@@ -46,23 +46,34 @@ __KERNEL_RCSID(0, "$NetBSD: pic_splfuncs
 
 #include 
 
+#if defined(__HAVE_CPU_DOSOFTINTS_CI)
+#define	CPU_DOSOFTINTS(ci)	cpu_dosoftints_ci((ci))
+#else
+#define	CPU_DOSOFTINTS(ci)	cpu_dosoftints()
+#endif
+
+#if defined(__HAVE_PIC_PENDING_INTRS)
+static void	splx_dopendingints(struct cpu_info *, const int);
+#endif
+
 int
 _splraise(int newipl)
 {
 	struct cpu_info * const ci = curcpu();
 	const int oldipl = ci->ci_cpl;
-	KASSERT(newipl < NIPL);
+	KDASSERT(newipl < NIPL);
 	if (newipl > ci->ci_cpl) {
 		pic_set_priority(ci, newipl);
 	}
 	return oldipl;
 }
+
 int
 _spllower(int newipl)
 {
 	struct cpu_info * const ci = curcpu();
 	const int oldipl = ci->ci_cpl;
-	KASSERT(panicstr || newipl <= ci->ci_cpl);
+	KDASSERT(panicstr || newipl <= ci->ci_cpl);
 	if (newipl < ci->ci_cpl) {
 		register_t psw = cpsid(I32_bit);
 		ci->ci_intr_depth++;
@@ -79,17 +90,29 @@ void
 splx(int savedipl)
 {
 	struct cpu_info * const ci = curcpu();
-	KASSERT(savedipl < NIPL);
+	KDASSERT(savedipl < NIPL);
 
 	if (__predict_false(savedipl == ci->ci_cpl)) {
 		return;
 	}
 
 #if defined(__HAVE_PIC_PENDING_INTRS)
-	if (__predict_true(ci->ci_pending_ipls == 0)) {
-		goto skip_pending;
+	if (__predict_false(ci->ci_pending_ipls != 0)) {
+		splx_dopendingints(ci, savedipl);
 	}
+#endif
+
+	pic_set_priority(ci, savedipl);
+	CPU_DOSOFTINTS(ci);
 
+	KDASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",
+	ci->ci_cpl, savedipl);
+}
+
+#if defined(__HAVE_PIC_PENDING_INTRS)
+static void __noinline
+splx_dopendingints(struct cpu_info *ci, const int savedipl)
+{
 	const register_t psw = cpsid(I32_bit);
 	ci->ci_intr_depth++;
 	while ((ci->ci_pending_ipls & ~__BIT(savedipl)) > __BIT(savedipl)) {
@@ -110,16 +133,5 @@ splx(int savedipl)
 	if ((psw & I32_bit) == 0) {
 		cpsie(I32_bit);
 	}
-skip_pending:
-#endif
-
-	pic_set_priority(ci, savedipl);
-#if defined(__HAVE_CPU_DOSOFTINTS_CI)
-	cpu_dosoftints_ci(ci);
-#else
-	cpu_dosoftints();
-#endif
-
-	KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",
-	ci->ci_cpl, savedipl);
 }
+#endif



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

2021-02-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Feb 21 17:07:45 UTC 2021

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

Log Message:
Inline pic_set_priority and use cpu_dosoftints_ci when available.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/pic/pic_splfuncs.c
cvs rdiff -u -r1.30 -r1.31 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.



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

2021-02-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Feb 21 17:07:45 UTC 2021

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

Log Message:
Inline pic_set_priority and use cpu_dosoftints_ci when available.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/pic/pic_splfuncs.c
cvs rdiff -u -r1.30 -r1.31 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.68 src/sys/arch/arm/pic/pic.c:1.69
--- src/sys/arch/arm/pic/pic.c:1.68	Sun Feb 21 08:31:36 2021
+++ src/sys/arch/arm/pic/pic.c	Sun Feb 21 17:07:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.68 2021/02/21 08:31:36 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.69 2021/02/21 17:07:45 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.68 2021/02/21 08:31:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.69 2021/02/21 17:07:45 jmcneill Exp $");
 
 #include 
 #include 
@@ -95,34 +95,6 @@ EVCNT_ATTACH_STATIC(pic_deferral_ev);
 
 static int pic_init(void);
 
-#ifdef __HAVE_PIC_SET_PRIORITY
-void
-pic_set_priority(struct cpu_info *ci, int newipl)
-{
-	register_t psw = cpsid(I32_bit);
-	if (pic_list[0] != NULL)
-		(pic_list[0]->pic_ops->pic_set_priority)(pic_list[0], newipl);
-	ci->ci_cpl = newipl;
-	if ((psw & I32_bit) == 0)
-		cpsie(I32_bit);
-}
-
-void
-pic_set_priority_psw(struct cpu_info *ci, register_t psw, int newipl)
-{
-	if ((psw & I32_bit) == 0) {
-		DISABLE_INTERRUPT();
-	}
-	if (pic_list[0] != NULL) {
-		(pic_list[0]->pic_ops->pic_set_priority)(pic_list[0], newipl);
-	}
-	ci->ci_cpl = newipl;
-	if ((psw & I32_bit) == 0) {
-		ENABLE_INTERRUPT();
-	}
-}
-#endif
-
 #ifdef MULTIPROCESSOR
 int
 pic_ipi_ast(void *arg)
@@ -564,7 +536,7 @@ pic_do_pending_ints(register_t psw, int 
 			if (ipl <= newipl)
 break;
 
-			pic_set_priority_psw(ci, psw, ipl);
+			pic_set_priority(ci, ipl);
 			pic_list_deliver_irqs(ci, psw, ipl, frame);
 			pic_list_unblock_irqs(ci);
 		}
@@ -573,12 +545,12 @@ pic_do_pending_ints(register_t psw, int 
 #ifdef __HAVE_PREEMPTION
 	struct lwp *l = curlwp;
 	if (newipl == IPL_NONE && (l->l_md.md_astpending & __BIT(1))) {
-		pic_set_priority_psw(ci, psw, IPL_SCHED);
+		pic_set_priority(ci, IPL_SCHED);
 		kpreempt(0);
 	}
 #endif
 	if (ci->ci_cpl != newipl)
-		pic_set_priority_psw(ci, psw, newipl);
+		pic_set_priority(ci, newipl);
 }
 
 static void

Index: src/sys/arch/arm/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.16 src/sys/arch/arm/pic/pic_splfuncs.c:1.17
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.16	Sat Feb 20 22:53:31 2021
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Sun Feb 21 17:07:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.16 2021/02/20 22:53:31 jmcneill Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.17 2021/02/21 17:07:45 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.16 2021/02/20 22:53:31 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.17 2021/02/21 17:07:45 jmcneill Exp $");
 
 #define _INTR_PRIVATE
 #include 
@@ -101,7 +101,7 @@ splx(int savedipl)
 break;
 			}
 
-			pic_set_priority_psw(ci, psw, ipl);
+			pic_set_priority(ci, ipl);
 			pic_list_deliver_irqs(ci, psw, ipl, NULL);
 			pic_list_unblock_irqs(ci);
 		}
@@ -113,11 +113,12 @@ splx(int savedipl)
 skip_pending:
 #endif
 
-	ci->ci_cpl = savedipl;
-	if (__predict_true(pic_list[0] != NULL)) {
-		(pic_list[0]->pic_ops->pic_set_priority)(pic_list[0], savedipl);
-	}
+	pic_set_priority(ci, savedipl);
+#if defined(__HAVE_CPU_DOSOFTINTS_CI)
+	cpu_dosoftints_ci(ci);
+#else
 	cpu_dosoftints();
+#endif
 
 	KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",
 	ci->ci_cpl, savedipl);

Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.30 src/sys/arch/arm/pic/picvar.h:1.31
--- src/sys/arch/arm/pic/picvar.h:1.30	Sat Feb 20 19:30:46 2021
+++ src/sys/arch/arm/pic/picvar.h	Sun Feb 21 17:07:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.30 2021/02/20 19:30:46 jmcneill Exp $	*/
+/*	$NetBSD: picvar.h,v 1.31 2021/02/21 17:07:45 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -176,18 +176,21 @@ struct pic_ops {
 #endif
 };
 
+/* Using an inline causes catch-22 problems with cpu.h */
 #ifdef __HAVE_PIC_SET_PRIORITY
 /*
  * This is used to update a hardware pic with a value corresponding
  * to the ipl being set.
  */
-struct cpu_info;
-void	pic_set_priority(struct cpu_info *, int);
-void	pic_set_priority_psw(struct cpu_info *, register_t, int);

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

2021-02-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb 21 08:31:36 UTC 2021

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

Log Message:
Fixup with __HAVE_PREEMPTION code which is currently unused


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.67 src/sys/arch/arm/pic/pic.c:1.68
--- src/sys/arch/arm/pic/pic.c:1.67	Sat Feb 20 19:30:46 2021
+++ src/sys/arch/arm/pic/pic.c	Sun Feb 21 08:31:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.67 2021/02/20 19:30:46 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.68 2021/02/21 08:31:36 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.67 2021/02/20 19:30:46 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.68 2021/02/21 08:31:36 skrll Exp $");
 
 #include 
 #include 
@@ -166,7 +166,9 @@ pic_ipi_ddb(void *arg)
 int
 pic_ipi_kpreempt(void *arg)
 {
-	atomic_or_uint(()->ci_astpending, __BIT(1));
+	struct lwp *l = curlwp;
+
+	l->l_md.md_astpending |= __BIT(1);
 	return 1;
 }
 #endif /* __HAVE_PREEMPTION */
@@ -569,7 +571,8 @@ pic_do_pending_ints(register_t psw, int 
 	}
 #endif /* __HAVE_PIC_PENDING_INTRS */
 #ifdef __HAVE_PREEMPTION
-	if (newipl == IPL_NONE && (ci->ci_astpending & __BIT(1))) {
+	struct lwp *l = curlwp;
+	if (newipl == IPL_NONE && (l->l_md.md_astpending & __BIT(1))) {
 		pic_set_priority_psw(ci, psw, IPL_SCHED);
 		kpreempt(0);
 	}



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

2021-02-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb 21 08:31:36 UTC 2021

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

Log Message:
Fixup with __HAVE_PREEMPTION code which is currently unused


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 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.



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

2021-02-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 20 22:53:31 UTC 2021

Modified Files:
src/sys/arch/arm/pic: pic_splfuncs.c

Log Message:
Only disable/enable interrupts if processing pending interrupts, and
inline pic_set_pending_psw.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/pic/pic_splfuncs.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/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.15 src/sys/arch/arm/pic/pic_splfuncs.c:1.16
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.15	Sat Feb 20 19:35:07 2021
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Sat Feb 20 22:53:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.15 2021/02/20 19:35:07 jmcneill Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.16 2021/02/20 22:53:31 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.15 2021/02/20 19:35:07 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.16 2021/02/20 22:53:31 jmcneill Exp $");
 
 #define _INTR_PRIVATE
 #include 
@@ -85,13 +85,12 @@ splx(int savedipl)
 		return;
 	}
 
-	register_t psw = cpsid(I32_bit);
-
 #if defined(__HAVE_PIC_PENDING_INTRS)
 	if (__predict_true(ci->ci_pending_ipls == 0)) {
 		goto skip_pending;
 	}
 
+	const register_t psw = cpsid(I32_bit);
 	ci->ci_intr_depth++;
 	while ((ci->ci_pending_ipls & ~__BIT(savedipl)) > __BIT(savedipl)) {
 		KASSERT(ci->ci_pending_ipls < __BIT(NIPL));
@@ -108,10 +107,16 @@ splx(int savedipl)
 		}
 	}
 	ci->ci_intr_depth--;
+	if ((psw & I32_bit) == 0) {
+		cpsie(I32_bit);
+	}
 skip_pending:
 #endif
 
-	pic_set_priority_psw(ci, psw, savedipl);
+	ci->ci_cpl = savedipl;
+	if (__predict_true(pic_list[0] != NULL)) {
+		(pic_list[0]->pic_ops->pic_set_priority)(pic_list[0], savedipl);
+	}
 	cpu_dosoftints();
 
 	KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",



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

2021-02-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 20 22:53:31 UTC 2021

Modified Files:
src/sys/arch/arm/pic: pic_splfuncs.c

Log Message:
Only disable/enable interrupts if processing pending interrupts, and
inline pic_set_pending_psw.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/pic/pic_splfuncs.c

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



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

2021-02-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 20 19:35:07 UTC 2021

Modified Files:
src/sys/arch/arm/pic: pic_splfuncs.c

Log Message:
Adjust ci_intr_depth when processing pending ints


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/pic/pic_splfuncs.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/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.14 src/sys/arch/arm/pic/pic_splfuncs.c:1.15
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.14	Sat Feb 20 19:30:46 2021
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Sat Feb 20 19:35:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.14 2021/02/20 19:30:46 jmcneill Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.15 2021/02/20 19:35:07 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.14 2021/02/20 19:30:46 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.15 2021/02/20 19:35:07 jmcneill Exp $");
 
 #define _INTR_PRIVATE
 #include 
@@ -92,6 +92,7 @@ splx(int savedipl)
 		goto skip_pending;
 	}
 
+	ci->ci_intr_depth++;
 	while ((ci->ci_pending_ipls & ~__BIT(savedipl)) > __BIT(savedipl)) {
 		KASSERT(ci->ci_pending_ipls < __BIT(NIPL));
 		for (;;) {
@@ -106,6 +107,7 @@ splx(int savedipl)
 			pic_list_unblock_irqs(ci);
 		}
 	}
+	ci->ci_intr_depth--;
 skip_pending:
 #endif
 



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

2021-02-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 20 19:35:07 UTC 2021

Modified Files:
src/sys/arch/arm/pic: pic_splfuncs.c

Log Message:
Adjust ci_intr_depth when processing pending ints


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/pic/pic_splfuncs.c

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



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

2021-02-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 20 19:30:46 UTC 2021

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

Log Message:
Inline "pic_do_pending_ints" in splx and check ci_pending_ipls to optimize
the common case (hw priority, no cascaded interrupts pending).

This also removes the need for the "pic_pending_used" flag, and should fix
booting on Raspberry Pi 3.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/pic/pic_splfuncs.c
cvs rdiff -u -r1.29 -r1.30 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.66 src/sys/arch/arm/pic/pic.c:1.67
--- src/sys/arch/arm/pic/pic.c:1.66	Sat Feb 20 14:51:07 2021
+++ src/sys/arch/arm/pic/pic.c	Sat Feb 20 19:30:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.66 2021/02/20 14:51:07 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.67 2021/02/20 19:30:46 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.66 2021/02/20 14:51:07 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.67 2021/02/20 19:30:46 jmcneill Exp $");
 
 #include 
 #include 
@@ -60,8 +60,6 @@ __KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.66
 
 #if defined(__HAVE_PIC_PENDING_INTRS)
 
-bool pic_pending_used __read_mostly = false;
-
 /*
  * This implementation of pending interrupts on a MULTIPROCESSOR system makes
  * the assumption that a PIC (pic_softc) shall only have all its interrupts
@@ -74,8 +72,6 @@ static struct pic_softc *
 	pic_list_find_pic_by_pending_ipl(struct cpu_info *, uint32_t);
 static void
 	pic_deliver_irqs(struct cpu_info *, struct pic_softc *, int, void *);
-static void
-	pic_list_deliver_irqs(struct cpu_info *, register_t, int, void *);
 
 #endif /* __HAVE_PIC_PENDING_INTRS */
 
@@ -261,9 +257,6 @@ pic_mark_pending_source(struct pic_softc
 	const uint32_t ipl_mask = __BIT(is->is_ipl);
 	struct cpu_info * const ci = curcpu();
 
-	if (!pic_pending_used)
-		pic_pending_used = true;
-
 	atomic_or_32(>pic_pending_irqs[is->is_irq >> 5],
 	__BIT(is->is_irq & 0x1f));
 
@@ -296,9 +289,6 @@ pic_mark_pending_sources(struct pic_soft
 	if (pending == 0)
 		return ipl_mask;
 
-	if (!pic_pending_used)
-		pic_pending_used = true;
-
 	KASSERT((irq_base & 31) == 0);
 
 	(*pic->pic_ops->pic_block_irqs)(pic, irq_base, pending);
@@ -480,7 +470,7 @@ pic_deliver_irqs(struct cpu_info *ci, st
 		atomic_and_32(>ci_pending_pics, ~__BIT(pic->pic_id));
 }
 
-static void
+void
 pic_list_unblock_irqs(struct cpu_info *ci)
 {
 	uint32_t blocked_pics = ci->ci_blocked_pics;

Index: src/sys/arch/arm/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.13 src/sys/arch/arm/pic/pic_splfuncs.c:1.14
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.13	Tue Feb 16 22:12:50 2021
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Sat Feb 20 19:30:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.13 2021/02/16 22:12:50 jmcneill Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.14 2021/02/20 19:30:46 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.13 2021/02/16 22:12:50 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.14 2021/02/20 19:30:46 jmcneill Exp $");
 
 #define _INTR_PRIVATE
 #include 
@@ -46,12 +46,6 @@ __KERNEL_RCSID(0, "$NetBSD: pic_splfuncs
 
 #include 
 
-#if defined(__HAVE_PIC_PENDING_INTRS)
-extern bool pic_pending_used;
-#else
-#define pic_pending_used	false
-#endif
-
 int
 _splraise(int newipl)
 {
@@ -70,16 +64,12 @@ _spllower(int newipl)
 	const int oldipl = ci->ci_cpl;
 	KASSERT(panicstr || newipl <= ci->ci_cpl);
 	if (newipl < ci->ci_cpl) {
-		if (__predict_false(pic_pending_used)) {
-			register_t psw = cpsid(I32_bit);
-			ci->ci_intr_depth++;
-			pic_do_pending_ints(psw, newipl, NULL);
-			ci->ci_intr_depth--;
-			if ((psw & I32_bit) == 0 || newipl == IPL_NONE)
-cpsie(I32_bit);
-		} else {
-			pic_set_priority(ci, newipl);
-		}
+		register_t psw = cpsid(I32_bit);
+		ci->ci_intr_depth++;
+		pic_do_pending_ints(psw, newipl, NULL);
+		ci->ci_intr_depth--;
+		if ((psw & I32_bit) == 0 || newipl == IPL_NONE)
+			cpsie(I32_bit);
 		cpu_dosoftints();
 	}
 	return oldipl;
@@ -95,27 +85,32 @@ splx(int savedipl)
 		return;
 	}
 
-	if (__predict_false(pic_pending_used)) {
-		register_t psw = cpsid(I32_bit);
-		KASSERTMSG(panicstr != NULL || savedipl < ci->ci_cpl,
-		"splx(%d) to a higher ipl than %d", savedipl, ci->ci_cpl);
+	register_t psw = cpsid(I32_bit);
 
-		if ((psw & I32_bit) == 0) {
-			ci->ci_intr_depth++;
-			pic_do_pending_ints(psw, savedipl, NULL);
-			ci->ci_intr_depth--;
-			

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

2021-02-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 20 19:30:46 UTC 2021

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

Log Message:
Inline "pic_do_pending_ints" in splx and check ci_pending_ipls to optimize
the common case (hw priority, no cascaded interrupts pending).

This also removes the need for the "pic_pending_used" flag, and should fix
booting on Raspberry Pi 3.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/pic/pic_splfuncs.c
cvs rdiff -u -r1.29 -r1.30 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.



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

2021-02-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 20 18:18:53 UTC 2021

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

Log Message:
remove "pic_do_pending_int() prototype; no matching function


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 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.



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

2021-02-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 20 18:18:53 UTC 2021

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

Log Message:
remove "pic_do_pending_int() prototype; no matching function


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 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/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.28 src/sys/arch/arm/pic/picvar.h:1.29
--- src/sys/arch/arm/pic/picvar.h:1.28	Tue Feb 16 07:27:12 2021
+++ src/sys/arch/arm/pic/picvar.h	Sat Feb 20 18:18:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.28 2021/02/16 07:27:12 skrll Exp $	*/
+/*	$NetBSD: picvar.h,v 1.29 2021/02/20 18:18:53 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -191,7 +191,6 @@ void	pic_set_priority_psw(struct cpu_inf
 #define	PIC_IRQBASE_ALLOC	(-2)
 
 int	pic_add(struct pic_softc *, int);
-void	pic_do_pending_int(void);
 #ifdef MULTIPROCESSOR
 int	pic_ipi_ast(void *);
 int	pic_ipi_nop(void *);



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

2021-02-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Feb 16 22:12:50 UTC 2021

Modified Files:
src/sys/arch/arm/pic: pic.c pic_splfuncs.c

Log Message:
pic: avoid pic_do_pending_ints if pic_mark_pending_* has never been called


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/pic/pic_splfuncs.c

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



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

2021-02-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Feb 16 22:12:50 UTC 2021

Modified Files:
src/sys/arch/arm/pic: pic.c pic_splfuncs.c

Log Message:
pic: avoid pic_do_pending_ints if pic_mark_pending_* has never been called


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/pic/pic_splfuncs.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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.64 src/sys/arch/arm/pic/pic.c:1.65
--- src/sys/arch/arm/pic/pic.c:1.64	Mon Feb 15 16:32:07 2021
+++ src/sys/arch/arm/pic/pic.c	Tue Feb 16 22:12:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.64 2021/02/15 16:32:07 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.65 2021/02/16 22:12:49 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.64 2021/02/15 16:32:07 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.65 2021/02/16 22:12:49 jmcneill Exp $");
 
 #include 
 #include 
@@ -59,6 +59,9 @@ __KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.64
 #include 
 
 #if defined(__HAVE_PIC_PENDING_INTRS)
+
+bool pic_pending_used __read_mostly = false;
+
 /*
  * This implementation of pending interrupts on a MULTIPROCESSOR system makes
  * the assumption that a PIC (pic_softc) shall only have all its interrupts
@@ -279,6 +282,9 @@ pic_mark_pending_source(struct pic_softc
 {
 	const uint32_t ipl_mask = __BIT(is->is_ipl);
 
+	if (!pic_pending_used)
+		pic_pending_used = true;
+
 	atomic_or_32(>pic_pending_irqs[is->is_irq >> 5],
 	__BIT(is->is_irq & 0x1f));
 
@@ -309,6 +315,9 @@ pic_mark_pending_sources(struct pic_soft
 	volatile uint32_t *ipending = >pic_pending_irqs[irq_base >> 5];
 	uint32_t ipl_mask = 0;
 
+	if (!pic_pending_used)
+		pic_pending_used = true;
+
 	if (pending == 0)
 		return ipl_mask;
 

Index: src/sys/arch/arm/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.12 src/sys/arch/arm/pic/pic_splfuncs.c:1.13
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.12	Mon Feb 15 16:32:07 2021
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Tue Feb 16 22:12:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.12 2021/02/15 16:32:07 jmcneill Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.13 2021/02/16 22:12:50 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.12 2021/02/15 16:32:07 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.13 2021/02/16 22:12:50 jmcneill Exp $");
 
 #define _INTR_PRIVATE
 #include 
@@ -46,6 +46,11 @@ __KERNEL_RCSID(0, "$NetBSD: pic_splfuncs
 
 #include 
 
+#if defined(__HAVE_PIC_PENDING_INTRS)
+extern bool pic_pending_used;
+#else
+#define pic_pending_used	false
+#endif
 
 int
 _splraise(int newipl)
@@ -65,12 +70,16 @@ _spllower(int newipl)
 	const int oldipl = ci->ci_cpl;
 	KASSERT(panicstr || newipl <= ci->ci_cpl);
 	if (newipl < ci->ci_cpl) {
-		register_t psw = cpsid(I32_bit);
-		ci->ci_intr_depth++;
-		pic_do_pending_ints(psw, newipl, NULL);
-		ci->ci_intr_depth--;
-		if ((psw & I32_bit) == 0 || newipl == IPL_NONE)
-			cpsie(I32_bit);
+		if (__predict_false(pic_pending_used)) {
+			register_t psw = cpsid(I32_bit);
+			ci->ci_intr_depth++;
+			pic_do_pending_ints(psw, newipl, NULL);
+			ci->ci_intr_depth--;
+			if ((psw & I32_bit) == 0 || newipl == IPL_NONE)
+cpsie(I32_bit);
+		} else {
+			pic_set_priority(ci, newipl);
+		}
 		cpu_dosoftints();
 	}
 	return oldipl;
@@ -86,21 +95,26 @@ splx(int savedipl)
 		return;
 	}
 
-	register_t psw = cpsid(I32_bit);
-	KASSERTMSG(panicstr != NULL || savedipl < ci->ci_cpl,
-	"splx(%d) to a higher ipl than %d", savedipl, ci->ci_cpl);
-
-	if ((psw & I32_bit) == 0) {
-		ci->ci_intr_depth++;
-		pic_do_pending_ints(psw, savedipl, NULL);
-		ci->ci_intr_depth--;
-		KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",
-		ci->ci_cpl, savedipl);
+	if (__predict_false(pic_pending_used)) {
+		register_t psw = cpsid(I32_bit);
+		KASSERTMSG(panicstr != NULL || savedipl < ci->ci_cpl,
+		"splx(%d) to a higher ipl than %d", savedipl, ci->ci_cpl);
 
-		cpsie(I32_bit);
-		cpu_dosoftints();
+		if ((psw & I32_bit) == 0) {
+			ci->ci_intr_depth++;
+			pic_do_pending_ints(psw, savedipl, NULL);
+			ci->ci_intr_depth--;
+			KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",
+			ci->ci_cpl, savedipl);
+
+			cpsie(I32_bit);
+			cpu_dosoftints();
+		} else {
+			pic_set_priority_psw(ci, psw, savedipl);
+		}
 	} else {
-		pic_set_priority_psw(ci, psw, savedipl);
+		pic_set_priority(ci, savedipl);
+		cpu_dosoftints();
 	}
 
 	KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",



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

2021-02-15 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Feb 16 07:27:12 UTC 2021

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

Log Message:
Provide a pic_set_priority_psw in the case that __HAVE_PIC_SET_PRIORITY
is not defined.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 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/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.27 src/sys/arch/arm/pic/picvar.h:1.28
--- src/sys/arch/arm/pic/picvar.h:1.27	Mon Feb 15 16:32:07 2021
+++ src/sys/arch/arm/pic/picvar.h	Tue Feb 16 07:27:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.27 2021/02/15 16:32:07 jmcneill Exp $	*/
+/*	$NetBSD: picvar.h,v 1.28 2021/02/16 07:27:12 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -184,7 +184,8 @@ void	pic_set_priority(struct cpu_info *,
 void	pic_set_priority_psw(struct cpu_info *, register_t, int);
 #else
 /* Using an inline causes catch-22 problems with cpu.h */
-#define	pic_set_priority(ci, newipl)	((void)((ci)->ci_cpl = (newipl)))
+#define	pic_set_priority(ci, newipl)		((void)((ci)->ci_cpl = (newipl)))
+#define	pic_set_priority_psw(ci, psw, newipl)	((void)((ci)->ci_cpl = (newipl)))
 #endif
 
 #define	PIC_IRQBASE_ALLOC	(-2)



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

2021-02-15 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Feb 16 07:27:12 UTC 2021

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

Log Message:
Provide a pic_set_priority_psw in the case that __HAVE_PIC_SET_PRIORITY
is not defined.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 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.



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

2021-02-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Feb 15 16:32:07 UTC 2021

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

Log Message:
splx: use pic_set_priority_psw in interrupts disabled case to skip a few
more daif accesses.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/pic/pic_splfuncs.c
cvs rdiff -u -r1.26 -r1.27 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.63 src/sys/arch/arm/pic/pic.c:1.64
--- src/sys/arch/arm/pic/pic.c:1.63	Mon Feb 15 13:03:52 2021
+++ src/sys/arch/arm/pic/pic.c	Mon Feb 15 16:32:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.63 2021/02/15 13:03:52 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.64 2021/02/15 16:32:07 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.63 2021/02/15 13:03:52 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.64 2021/02/15 16:32:07 jmcneill Exp $");
 
 #include 
 #include 
@@ -130,7 +130,7 @@ pic_set_priority(struct cpu_info *ci, in
 		cpsie(I32_bit);
 }
 
-static void
+void
 pic_set_priority_psw(struct cpu_info *ci, register_t psw, int newipl)
 {
 	if ((psw & I32_bit) == 0) {

Index: src/sys/arch/arm/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.11 src/sys/arch/arm/pic/pic_splfuncs.c:1.12
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.11	Mon Feb 15 16:04:01 2021
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Mon Feb 15 16:32:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.11 2021/02/15 16:04:01 jmcneill Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.12 2021/02/15 16:32:07 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.11 2021/02/15 16:04:01 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.12 2021/02/15 16:32:07 jmcneill Exp $");
 
 #define _INTR_PRIVATE
 #include 
@@ -100,7 +100,7 @@ splx(int savedipl)
 		cpsie(I32_bit);
 		cpu_dosoftints();
 	} else {
-		pic_set_priority(ci, savedipl);
+		pic_set_priority_psw(ci, psw, savedipl);
 	}
 
 	KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",

Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.26 src/sys/arch/arm/pic/picvar.h:1.27
--- src/sys/arch/arm/pic/picvar.h:1.26	Tue Dec 24 20:40:09 2019
+++ src/sys/arch/arm/pic/picvar.h	Mon Feb 15 16:32:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.26 2019/12/24 20:40:09 skrll Exp $	*/
+/*	$NetBSD: picvar.h,v 1.27 2021/02/15 16:32:07 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -181,6 +181,7 @@ struct pic_ops {
  */
 struct cpu_info;
 void	pic_set_priority(struct cpu_info *, int);
+void	pic_set_priority_psw(struct cpu_info *, register_t, int);
 #else
 /* Using an inline causes catch-22 problems with cpu.h */
 #define	pic_set_priority(ci, newipl)	((void)((ci)->ci_cpl = (newipl)))



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

2021-02-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Feb 15 16:32:07 UTC 2021

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

Log Message:
splx: use pic_set_priority_psw in interrupts disabled case to skip a few
more daif accesses.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/pic/pic_splfuncs.c
cvs rdiff -u -r1.26 -r1.27 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.



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

2021-02-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Feb 15 16:04:01 UTC 2021

Modified Files:
src/sys/arch/arm/pic: pic_splfuncs.c

Log Message:
splx: restore priority even if interrupts are disabled


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

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



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

2021-02-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Feb 15 16:04:01 UTC 2021

Modified Files:
src/sys/arch/arm/pic: pic_splfuncs.c

Log Message:
splx: restore priority even if interrupts are disabled


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/pic/pic_splfuncs.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/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.10 src/sys/arch/arm/pic/pic_splfuncs.c:1.11
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.10	Mon Feb 15 15:42:58 2021
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Mon Feb 15 16:04:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.10 2021/02/15 15:42:58 jmcneill Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.11 2021/02/15 16:04:01 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.10 2021/02/15 15:42:58 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.11 2021/02/15 16:04:01 jmcneill Exp $");
 
 #define _INTR_PRIVATE
 #include 
@@ -99,6 +99,8 @@ splx(int savedipl)
 
 		cpsie(I32_bit);
 		cpu_dosoftints();
+	} else {
+		pic_set_priority(ci, savedipl);
 	}
 
 	KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",



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

2021-02-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Feb 15 15:42:58 UTC 2021

Modified Files:
src/sys/arch/arm/pic: pic_splfuncs.c

Log Message:
splx: only dispatch hard interrupts if interrupts are enabled


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/pic/pic_splfuncs.c

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



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

2021-02-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Feb 15 15:42:58 UTC 2021

Modified Files:
src/sys/arch/arm/pic: pic_splfuncs.c

Log Message:
splx: only dispatch hard interrupts if interrupts are enabled


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/pic/pic_splfuncs.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/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.9 src/sys/arch/arm/pic/pic_splfuncs.c:1.10
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.9	Mon Feb 15 15:07:47 2021
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Mon Feb 15 15:42:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.9 2021/02/15 15:07:47 jmcneill Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.10 2021/02/15 15:42:58 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.9 2021/02/15 15:07:47 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.10 2021/02/15 15:42:58 jmcneill Exp $");
 
 #define _INTR_PRIVATE
 #include 
@@ -90,15 +90,17 @@ splx(int savedipl)
 	KASSERTMSG(panicstr != NULL || savedipl < ci->ci_cpl,
 	"splx(%d) to a higher ipl than %d", savedipl, ci->ci_cpl);
 
-	ci->ci_intr_depth++;
-	pic_do_pending_ints(psw, savedipl, NULL);
-	ci->ci_intr_depth--;
-	KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",
-	ci->ci_cpl, savedipl);
 	if ((psw & I32_bit) == 0) {
+		ci->ci_intr_depth++;
+		pic_do_pending_ints(psw, savedipl, NULL);
+		ci->ci_intr_depth--;
+		KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",
+		ci->ci_cpl, savedipl);
+
 		cpsie(I32_bit);
 		cpu_dosoftints();
 	}
+
 	KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",
 	ci->ci_cpl, savedipl);
 }



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

2021-02-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Feb 15 15:07:48 UTC 2021

Modified Files:
src/sys/arch/arm/pic: pic_splfuncs.c

Log Message:
splx: only dispatch softints if interrupts are enabled


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/pic/pic_splfuncs.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/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.8 src/sys/arch/arm/pic/pic_splfuncs.c:1.9
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.8	Sun Apr  1 04:35:04 2018
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Mon Feb 15 15:07:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.8 2018/04/01 04:35:04 ryo Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.9 2021/02/15 15:07:47 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.8 2018/04/01 04:35:04 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.9 2021/02/15 15:07:47 jmcneill Exp $");
 
 #define _INTR_PRIVATE
 #include 
@@ -95,9 +95,10 @@ splx(int savedipl)
 	ci->ci_intr_depth--;
 	KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",
 	ci->ci_cpl, savedipl);
-	if ((psw & I32_bit) == 0)
+	if ((psw & I32_bit) == 0) {
 		cpsie(I32_bit);
-	cpu_dosoftints();
+		cpu_dosoftints();
+	}
 	KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",
 	ci->ci_cpl, savedipl);
 }



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

2021-02-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Feb 15 15:07:48 UTC 2021

Modified Files:
src/sys/arch/arm/pic: pic_splfuncs.c

Log Message:
splx: only dispatch softints if interrupts are enabled


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/pic/pic_splfuncs.c

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



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

2021-02-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Feb 15 13:03:52 UTC 2021

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

Log Message:
pic: reduce the number of daif accesses in pic_do_pending_ints

The caller has already provided daif state. No need to keep updating
daif via pic_set_priority if it's already in the state we need (interrupts
disabled).


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 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.



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

2021-02-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Feb 15 13:03:52 UTC 2021

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

Log Message:
pic: reduce the number of daif accesses in pic_do_pending_ints

The caller has already provided daif state. No need to keep updating
daif via pic_set_priority if it's already in the state we need (interrupts
disabled).


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.62 src/sys/arch/arm/pic/pic.c:1.63
--- src/sys/arch/arm/pic/pic.c:1.62	Sun Feb  7 21:18:37 2021
+++ src/sys/arch/arm/pic/pic.c	Mon Feb 15 13:03:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.62 2021/02/07 21:18:37 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.63 2021/02/15 13:03:52 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.62 2021/02/07 21:18:37 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.63 2021/02/15 13:03:52 jmcneill Exp $");
 
 #include 
 #include 
@@ -129,6 +129,21 @@ pic_set_priority(struct cpu_info *ci, in
 	if ((psw & I32_bit) == 0)
 		cpsie(I32_bit);
 }
+
+static void
+pic_set_priority_psw(struct cpu_info *ci, register_t psw, int newipl)
+{
+	if ((psw & I32_bit) == 0) {
+		DISABLE_INTERRUPT();
+	}
+	if (pic_list[0] != NULL) {
+		(pic_list[0]->pic_ops->pic_set_priority)(pic_list[0], newipl);
+	}
+	ci->ci_cpl = newipl;
+	if ((psw & I32_bit) == 0) {
+		ENABLE_INTERRUPT();
+	}
+}
 #endif
 
 #ifdef MULTIPROCESSOR
@@ -573,7 +588,7 @@ pic_do_pending_ints(register_t psw, int 
 			if (ipl <= newipl)
 break;
 
-			pic_set_priority(ci, ipl);
+			pic_set_priority_psw(ci, psw, ipl);
 			pic_list_deliver_irqs(pend, psw, ipl, frame);
 			pic_list_unblock_irqs(pend);
 		}
@@ -582,12 +597,12 @@ pic_do_pending_ints(register_t psw, int 
 #endif /* __HAVE_PIC_PENDING_INTRS */
 #ifdef __HAVE_PREEMPTION
 	if (newipl == IPL_NONE && (ci->ci_astpending & __BIT(1))) {
-		pic_set_priority(ci, IPL_SCHED);
+		pic_set_priority_psw(ci, psw, IPL_SCHED);
 		kpreempt(0);
 	}
 #endif
 	if (ci->ci_cpl != newipl)
-		pic_set_priority(ci, newipl);
+		pic_set_priority_psw(ci, psw, newipl);
 }
 
 static void



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

2021-02-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Feb  7 21:18:37 UTC 2021

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

Log Message:
Use ENABLE_INTERRUPT() / DISABLE_INTERRUPT() instead of cpsie()/cpsid() in
places where we don't care about the cpsie() return value.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.61 src/sys/arch/arm/pic/pic.c:1.62
--- src/sys/arch/arm/pic/pic.c:1.61	Sun Nov  1 14:42:05 2020
+++ src/sys/arch/arm/pic/pic.c	Sun Feb  7 21:18:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.61 2020/11/01 14:42:05 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.62 2021/02/07 21:18:37 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.61 2020/11/01 14:42:05 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.62 2021/02/07 21:18:37 jmcneill Exp $");
 
 #include 
 #include 
@@ -447,13 +447,14 @@ pic_deliver_irqs(struct pic_pending *pen
 			atomic_and_32(ipending, ~__BIT(irq));
 			is = pic->pic_sources[irq_base + irq];
 			if (is != NULL) {
-cpsie(I32_bit);
+ENABLE_INTERRUPT();
 pic_dispatch(is, frame);
-cpsid(I32_bit);
+DISABLE_INTERRUPT();
 #if PIC_MAXSOURCES > 32
 /*
  * There is a possibility of interrupting
- * from cpsie() to cpsid().
+ * from ENABLE_INTERRUPT() to
+ * DISABLE_INTERRUPT().
  */
 poi = 1;
 #endif



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

2021-02-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Feb  7 21:18:37 UTC 2021

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

Log Message:
Use ENABLE_INTERRUPT() / DISABLE_INTERRUPT() instead of cpsie()/cpsid() in
places where we don't care about the cpsie() return value.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 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.



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

2020-11-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  1 14:42:05 UTC 2020

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

Log Message:
intr_ipi_send: assert that kcp is either NULL or contains exactly one CPU


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.60 src/sys/arch/arm/pic/pic.c:1.61
--- src/sys/arch/arm/pic/pic.c:1.60	Mon Oct 26 07:16:41 2020
+++ src/sys/arch/arm/pic/pic.c	Sun Nov  1 14:42:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.60 2020/10/26 07:16:41 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.61 2020/11/01 14:42:05 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.60 2020/10/26 07:16:41 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.61 2020/11/01 14:42:05 jmcneill Exp $");
 
 #include 
 #include 
@@ -197,6 +197,7 @@ intr_ipi_send(const kcpuset_t *kcp, u_lo
 {
 	struct cpu_info * const ci = curcpu();
 	KASSERT(ipi < NIPI);
+	KASSERT(kcp == NULL || kcpuset_countset(kcp) == 1);
 	bool __diagused sent_p = false;
 	for (size_t slot = 0; slot < PIC_MAXPICS; slot++) {
 		struct pic_softc * const pic = pic_list[slot];



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

2020-11-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  1 14:42:05 UTC 2020

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

Log Message:
intr_ipi_send: assert that kcp is either NULL or contains exactly one CPU


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 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.



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

2020-10-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Oct 26 07:16:41 UTC 2020

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

Log Message:
Improve a comment


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.59 src/sys/arch/arm/pic/pic.c:1.60
--- src/sys/arch/arm/pic/pic.c:1.59	Mon Oct 26 07:14:42 2020
+++ src/sys/arch/arm/pic/pic.c	Mon Oct 26 07:16:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.59 2020/10/26 07:14:42 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.60 2020/10/26 07:16:41 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.59 2020/10/26 07:14:42 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.60 2020/10/26 07:16:41 skrll Exp $");
 
 #include 
 #include 
@@ -203,11 +203,19 @@ intr_ipi_send(const kcpuset_t *kcp, u_lo
 		if (pic == NULL || pic->pic_cpus == NULL)
 			continue;
 		if (kcp == NULL || kcpuset_intersecting_p(kcp, pic->pic_cpus)) {
-			// never send to ourself
+			/*
+			 * Never send to ourself.
+			 *
+			 * This test uses pointer comparison for systems
+			 * that have a pic per cpu, e.g. RPI[23].  GIC sets
+			 * pic_cpus to kcpuset_running and handles "not for
+			 * self" internally.
+			 */
 			if (pic->pic_cpus == ci->ci_kcpuset)
 continue;
 
 			(*pic->pic_ops->pic_ipi_send)(pic, kcp, ipi);
+
 			/*
 			 * If we were targeting a single CPU or this pic
 			 * handles all cpus, we're done.



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

2020-10-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Oct 26 07:16:41 UTC 2020

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

Log Message:
Improve a comment


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 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.



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

2020-10-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Oct 26 07:14:42 UTC 2020

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 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.



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

2020-10-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Oct 26 07:14:42 UTC 2020

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.58 src/sys/arch/arm/pic/pic.c:1.59
--- src/sys/arch/arm/pic/pic.c:1.58	Sun Oct 25 08:29:30 2020
+++ src/sys/arch/arm/pic/pic.c	Mon Oct 26 07:14:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.58 2020/10/25 08:29:30 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.59 2020/10/26 07:14:42 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.58 2020/10/25 08:29:30 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.59 2020/10/26 07:14:42 skrll Exp $");
 
 #include 
 #include 
@@ -208,8 +208,10 @@ intr_ipi_send(const kcpuset_t *kcp, u_lo
 continue;
 
 			(*pic->pic_ops->pic_ipi_send)(pic, kcp, ipi);
-			// If we were targeting a single CPU or this pic
-			// handles all cpus, we're done.
+			/*
+			 * If we were targeting a single CPU or this pic
+			 * handles all cpus, we're done.
+			 */
 			if (kcp != NULL || pic->pic_cpus == kcpuset_running)
 return;
 			sent_p = true;



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

2020-10-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 25 08:29:30 UTC 2020

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

Log Message:
KASSERT -> KASSERTMSG


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.57 src/sys/arch/arm/pic/pic.c:1.58
--- src/sys/arch/arm/pic/pic.c:1.57	Mon Jul 27 16:26:51 2020
+++ src/sys/arch/arm/pic/pic.c	Sun Oct 25 08:29:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.57 2020/07/27 16:26:51 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.58 2020/10/25 08:29:30 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.57 2020/07/27 16:26:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.58 2020/10/25 08:29:30 skrll Exp $");
 
 #include 
 #include 
@@ -215,7 +215,8 @@ intr_ipi_send(const kcpuset_t *kcp, u_lo
 			sent_p = true;
 		}
 	}
-	KASSERT(cold || sent_p || ncpu <= 1);
+	KASSERTMSG(cold || sent_p || ncpu <= 1, "cold %d sent_p %d ncpu %d",
+	cold, sent_p, ncpu);
 }
 #endif /* MULTIPROCESSOR */
 



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

2020-10-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 25 08:29:30 UTC 2020

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

Log Message:
KASSERT -> KASSERTMSG


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 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.



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

2020-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jul 27 16:26:51 UTC 2020

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.56 src/sys/arch/arm/pic/pic.c:1.57
--- src/sys/arch/arm/pic/pic.c:1.56	Sat Feb  1 12:55:35 2020
+++ src/sys/arch/arm/pic/pic.c	Mon Jul 27 16:26:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.56 2020/02/01 12:55:35 riastradh Exp $	*/
+/*	$NetBSD: pic.c,v 1.57 2020/07/27 16:26:51 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.56 2020/02/01 12:55:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.57 2020/07/27 16:26:51 skrll Exp $");
 
 #include 
 #include 
@@ -692,7 +692,7 @@ pic_add(struct pic_softc *pic, int irqba
 	KASSERT((pic->pic_cpus != NULL) == (pic->pic_ops->pic_ipi_send != NULL));
 #endif
 	pic_list[slot] = pic;
-	
+
 	return irqbase;
 }
 



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

2020-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jul 27 16:26:51 UTC 2020

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 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.



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

2020-02-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb  1 12:55:26 UTC 2020

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

Log Message:
Reduce some ifdefs.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.54 src/sys/arch/arm/pic/pic.c:1.55
--- src/sys/arch/arm/pic/pic.c:1.54	Sat Feb  1 12:55:13 2020
+++ src/sys/arch/arm/pic/pic.c	Sat Feb  1 12:55:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.54 2020/02/01 12:55:13 riastradh Exp $	*/
+/*	$NetBSD: pic.c,v 1.55 2020/02/01 12:55:26 riastradh Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.54 2020/02/01 12:55:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.55 2020/02/01 12:55:26 riastradh Exp $");
 
 #include 
 #include 
@@ -81,8 +81,20 @@ static void
 
 #ifdef MULTIPROCESSOR
 percpu_t *pic_pending_percpu;
+static struct pic_pending *
+pic_pending_get(void)
+{
+	return percpu_getref(pic_pending_percpu);
+}
+static void
+pic_pending_put(struct pic_pending *pend)
+{
+	percpu_putref(pic_pending_percpu);
+}
 #else
 struct pic_pending pic_pending;
+#define	pic_pending_get()	(_pending)
+#define	pic_pending_put(pend)	__nothing
 #endif /* MULTIPROCESSOR */
 #endif /* __HAVE_PIC_PENDING_INTRS */
 
@@ -244,16 +256,10 @@ pic_mark_pending_source(struct pic_softc
 	__BIT(is->is_irq & 0x1f));
 
 	atomic_or_32(>pic_pending_ipls, ipl_mask);
-#ifdef MULTIPROCESSOR
-	struct pic_pending *pend = percpu_getref(pic_pending_percpu);
-#else
-	struct pic_pending *pend = _pending;
-#endif
+	struct pic_pending *pend = pic_pending_get();
 	atomic_or_32(>pending_ipls, ipl_mask);
 	atomic_or_32(>pending_pics, __BIT(pic->pic_id));
-#ifdef MULTIPROCESSOR
-	percpu_putref(pic_pending_percpu);
-#endif
+	pic_pending_put(pend);
 }
 
 void
@@ -296,16 +302,10 @@ pic_mark_pending_sources(struct pic_soft
 	}
 
 	atomic_or_32(>pic_pending_ipls, ipl_mask);
-#ifdef MULTIPROCESSOR
-	struct pic_pending *pend = percpu_getref(pic_pending_percpu);
-#else
-	struct pic_pending *pend = _pending;
-#endif
+	struct pic_pending *pend = pic_pending_get();
 	atomic_or_32(>pending_ipls, ipl_mask);
 	atomic_or_32(>pending_pics, __BIT(pic->pic_id));
-#ifdef MULTIPROCESSOR
-	percpu_putref(pic_pending_percpu);
-#endif
+	pic_pending_put(pend);
 	return ipl_mask;
 }
 
@@ -553,11 +553,7 @@ pic_do_pending_ints(register_t psw, int 
 		return;
 	}
 #if defined(__HAVE_PIC_PENDING_INTRS)
-#ifdef MULTIPROCESSOR
-	struct pic_pending *pend = percpu_getref(pic_pending_percpu);
-#else
-	struct pic_pending *pend = _pending;
-#endif
+	struct pic_pending *pend = pic_pending_get();
 	while ((pend->pending_ipls & ~__BIT(newipl)) > __BIT(newipl)) {
 		KASSERT(pend->pending_ipls < __BIT(NIPL));
 		for (;;) {
@@ -571,9 +567,7 @@ pic_do_pending_ints(register_t psw, int 
 			pic_list_unblock_irqs(pend);
 		}
 	}
-#ifdef MULTIPROCESSOR
-	percpu_putref(pic_pending_percpu);
-#endif
+	pic_pending_put(pend);
 #endif /* __HAVE_PIC_PENDING_INTRS */
 #ifdef __HAVE_PREEMPTION
 	if (newipl == IPL_NONE && (ci->ci_astpending & __BIT(1))) {



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

2020-02-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb  1 12:55:03 UTC 2020

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

Log Message:
Switch arm pic allocation and initialization to percpu_create.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 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.



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

2020-02-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb  1 12:55:03 UTC 2020

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

Log Message:
Switch arm pic allocation and initialization to percpu_create.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.52 src/sys/arch/arm/pic/pic.c:1.53
--- src/sys/arch/arm/pic/pic.c:1.52	Tue Dec 24 20:40:09 2019
+++ src/sys/arch/arm/pic/pic.c	Sat Feb  1 12:55:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.52 2019/12/24 20:40:09 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.53 2020/02/01 12:55:02 riastradh Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.52 2019/12/24 20:40:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.53 2020/02/01 12:55:02 riastradh Exp $");
 
 #include 
 #include 
@@ -647,12 +647,8 @@ pic_add(struct pic_softc *pic, int irqba
 
 #if defined(__HAVE_PIC_PENDING_INTRS) && defined(MULTIPROCESSOR)
 	if (__predict_false(pic_pending_percpu == NULL)) {
-		pic_pending_percpu = percpu_alloc(sizeof(struct pic_pending));
-
-		/*
-		 * Now zero the per-cpu pending data.
-		 */
-		percpu_foreach(pic_pending_percpu, pic_pending_zero, NULL);
+		pic_pending_percpu = percpu_create(sizeof(struct pic_pending),
+		pic_pending_zero, NULL, NULL);
 	}
 #endif /* __HAVE_PIC_PENDING_INTRS && MULTIPROCESSOR */
 
@@ -702,12 +698,8 @@ pic_add(struct pic_softc *pic, int irqba
 	 * corrupt the pointers in the evcnts themselves.  Remember, any
 	 * problem can be solved with sufficient indirection.
 	 */
-	pic->pic_percpu = percpu_alloc(sizeof(struct pic_percpu));
-
-	/*
-	 * Now allocate the per-cpu evcnts.
-	 */
-	percpu_foreach(pic->pic_percpu, pic_percpu_allocate, pic);
+	pic->pic_percpu = percpu_create(sizeof(struct pic_percpu),
+	pic_percpu_allocate, NULL, pic);
 
 	pic->pic_sources = _sources[sourcebase];
 	pic->pic_irqbase = irqbase;



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

2020-02-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb  1 12:55:13 UTC 2020

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

Log Message:
pic_pending_zero is unnecessary; percpu_alloc already zeroes.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.53 src/sys/arch/arm/pic/pic.c:1.54
--- src/sys/arch/arm/pic/pic.c:1.53	Sat Feb  1 12:55:02 2020
+++ src/sys/arch/arm/pic/pic.c	Sat Feb  1 12:55:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.53 2020/02/01 12:55:02 riastradh Exp $	*/
+/*	$NetBSD: pic.c,v 1.54 2020/02/01 12:55:13 riastradh Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.53 2020/02/01 12:55:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.54 2020/02/01 12:55:13 riastradh Exp $");
 
 #include 
 #include 
@@ -616,15 +616,6 @@ pic_percpu_allocate(void *v0, void *v1, 
 #endif
 }
 
-#if defined(__HAVE_PIC_PENDING_INTRS) && defined(MULTIPROCESSOR)
-static void
-pic_pending_zero(void *v0, void *v1, struct cpu_info *ci)
-{
-	struct pic_pending * const p = v0;
-	memset(p, 0, sizeof(*p));
-}
-#endif /* __HAVE_PIC_PENDING_INTRS && MULTIPROCESSOR */
-
 static int
 pic_init(void)
 {
@@ -646,10 +637,8 @@ pic_add(struct pic_softc *pic, int irqba
 	KASSERT(strlen(pic->pic_name) > 0);
 
 #if defined(__HAVE_PIC_PENDING_INTRS) && defined(MULTIPROCESSOR)
-	if (__predict_false(pic_pending_percpu == NULL)) {
-		pic_pending_percpu = percpu_create(sizeof(struct pic_pending),
-		pic_pending_zero, NULL, NULL);
-	}
+	if (__predict_false(pic_pending_percpu == NULL))
+		pic_pending_percpu = percpu_alloc(sizeof(struct pic_pending));
 #endif /* __HAVE_PIC_PENDING_INTRS && MULTIPROCESSOR */
 
 	mutex_enter(_lock);



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

2020-02-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb  1 12:55:26 UTC 2020

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

Log Message:
Reduce some ifdefs.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 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.



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

2020-02-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb  1 12:55:35 UTC 2020

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.55 src/sys/arch/arm/pic/pic.c:1.56
--- src/sys/arch/arm/pic/pic.c:1.55	Sat Feb  1 12:55:26 2020
+++ src/sys/arch/arm/pic/pic.c	Sat Feb  1 12:55:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.55 2020/02/01 12:55:26 riastradh Exp $	*/
+/*	$NetBSD: pic.c,v 1.56 2020/02/01 12:55:35 riastradh Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,20 +33,20 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.55 2020/02/01 12:55:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.56 2020/02/01 12:55:35 riastradh Exp $");
 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
 
 #include 
 #include 
@@ -366,7 +366,6 @@ pic_dispatch(struct intrsource *is, void
 #endif
 		(void)(*func)(arg);
 
-
 	struct pic_percpu * const pcpu = percpu_getref(is->is_pic->pic_percpu);
 	KASSERT(pcpu->pcpu_magic == PICPERCPU_MAGIC);
 	pcpu->pcpu_evs[is->is_irq].ev_count++;
@@ -509,7 +508,6 @@ pic_list_unblock_irqs(struct pic_pending
 	}
 }
 
-
 struct pic_softc *
 pic_list_find_pic_by_pending_ipl(struct pic_pending *pend, uint32_t ipl_mask)
 {



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

2020-02-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb  1 12:55:35 UTC 2020

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 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.



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

2020-02-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb  1 12:55:13 UTC 2020

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

Log Message:
pic_pending_zero is unnecessary; percpu_alloc already zeroes.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 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.



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

2019-12-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 24 20:40:09 UTC 2019

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

Log Message:
Update pic_add to allocate and return an irqbase if passed
PIC_IRQBASE_ALLOC.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.25 -r1.26 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.51 src/sys/arch/arm/pic/pic.c:1.52
--- src/sys/arch/arm/pic/pic.c:1.51	Tue Dec 24 20:37:44 2019
+++ src/sys/arch/arm/pic/pic.c	Tue Dec 24 20:40:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.51 2019/12/24 20:37:44 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.52 2019/12/24 20:40:09 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.51 2019/12/24 20:37:44 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.52 2019/12/24 20:40:09 skrll Exp $");
 
 #include 
 #include 
@@ -99,6 +99,7 @@ size_t pic_ipl_offset[NIPL+1];
 
 static kmutex_t pic_lock;
 static size_t pic_sourcebase;
+static int pic_lastbase;
 static struct evcnt pic_deferral_ev =
 EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "deferred", "intr");
 EVCNT_ATTACH_STATIC(pic_deferral_ev);
@@ -633,7 +634,7 @@ pic_init(void)
 	return 0;
 }
 
-void
+int
 pic_add(struct pic_softc *pic, int irqbase)
 {
 	int slot, maybe_slot = -1;
@@ -656,6 +657,9 @@ pic_add(struct pic_softc *pic, int irqba
 #endif /* __HAVE_PIC_PENDING_INTRS && MULTIPROCESSOR */
 
 	mutex_enter(_lock);
+	if (irqbase == PIC_IRQBASE_ALLOC) {
+		irqbase = pic_lastbase;
+	}
 	for (slot = 0; slot < PIC_MAXPICS; slot++) {
 		struct pic_softc * const xpic = pic_list[slot];
 		if (xpic == NULL) {
@@ -686,7 +690,8 @@ pic_add(struct pic_softc *pic, int irqba
 	KASSERT(pic_sourcebase + pic->pic_maxsources <= PIC_MAXMAXSOURCES);
 	sourcebase = pic_sourcebase;
 	pic_sourcebase += pic->pic_maxsources;
-
+if (pic_lastbase < irqbase + pic->pic_maxsources)
+pic_lastbase = irqbase + pic->pic_maxsources;
 	mutex_exit(_lock);
 
 	/*
@@ -714,6 +719,8 @@ pic_add(struct pic_softc *pic, int irqba
 	KASSERT((pic->pic_cpus != NULL) == (pic->pic_ops->pic_ipi_send != NULL));
 #endif
 	pic_list[slot] = pic;
+	
+	return irqbase;
 }
 
 int

Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.25 src/sys/arch/arm/pic/picvar.h:1.26
--- src/sys/arch/arm/pic/picvar.h:1.25	Mon Dec 23 15:51:47 2019
+++ src/sys/arch/arm/pic/picvar.h	Tue Dec 24 20:40:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.25 2019/12/23 15:51:47 jmcneill Exp $	*/
+/*	$NetBSD: picvar.h,v 1.26 2019/12/24 20:40:09 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -186,7 +186,9 @@ void	pic_set_priority(struct cpu_info *,
 #define	pic_set_priority(ci, newipl)	((void)((ci)->ci_cpl = (newipl)))
 #endif
 
-void	pic_add(struct pic_softc *, int);
+#define	PIC_IRQBASE_ALLOC	(-2)
+
+int	pic_add(struct pic_softc *, int);
 void	pic_do_pending_int(void);
 #ifdef MULTIPROCESSOR
 int	pic_ipi_ast(void *);



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

2019-12-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 24 20:40:09 UTC 2019

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

Log Message:
Update pic_add to allocate and return an irqbase if passed
PIC_IRQBASE_ALLOC.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.25 -r1.26 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.



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

2019-12-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 24 20:37:44 UTC 2019

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

Log Message:
Make pic_sourcebase static


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 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.



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

2019-12-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 24 20:37:44 UTC 2019

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

Log Message:
Make pic_sourcebase static


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.50 src/sys/arch/arm/pic/pic.c:1.51
--- src/sys/arch/arm/pic/pic.c:1.50	Mon Dec 23 15:51:47 2019
+++ src/sys/arch/arm/pic/pic.c	Tue Dec 24 20:37:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.50 2019/12/23 15:51:47 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.51 2019/12/24 20:37:44 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.50 2019/12/23 15:51:47 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.51 2019/12/24 20:37:44 skrll Exp $");
 
 #include 
 #include 
@@ -98,7 +98,7 @@ struct intrsource **pic_iplsource[NIPL] 
 size_t pic_ipl_offset[NIPL+1];
 
 static kmutex_t pic_lock;
-size_t pic_sourcebase;
+static size_t pic_sourcebase;
 static struct evcnt pic_deferral_ev =
 EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "deferred", "intr");
 EVCNT_ATTACH_STATIC(pic_deferral_ev);



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

2019-12-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Dec 23 15:51:47 UTC 2019

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

Log Message:
Add reference counts to intr_mask/intr_unmask as calls can be nested, spotted 
by thorpej


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.24 -r1.25 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.



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

2019-12-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Dec 23 15:51:47 UTC 2019

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

Log Message:
Add reference counts to intr_mask/intr_unmask as calls can be nested, spotted 
by thorpej


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.24 -r1.25 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.49 src/sys/arch/arm/pic/pic.c:1.50
--- src/sys/arch/arm/pic/pic.c:1.49	Mon Dec 23 15:34:23 2019
+++ src/sys/arch/arm/pic/pic.c	Mon Dec 23 15:51:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.49 2019/12/23 15:34:23 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.50 2019/12/23 15:51:47 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.49 2019/12/23 15:34:23 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.50 2019/12/23 15:51:47 jmcneill Exp $");
 
 #include 
 #include 
@@ -909,7 +909,8 @@ intr_mask(void *ih)
 	struct pic_softc * const pic = is->is_pic;
 	const int irq = is->is_irq;
 
-	(*pic->pic_ops->pic_block_irqs)(pic, irq & ~0x1f, __BIT(irq & 0x1f));
+	if (atomic_inc_32_nv(>is_mask_count) == 1)
+		(*pic->pic_ops->pic_block_irqs)(pic, irq & ~0x1f, __BIT(irq & 0x1f));
 }
 
 void
@@ -919,7 +920,8 @@ intr_unmask(void *ih)
 	struct pic_softc * const pic = is->is_pic;
 	const int irq = is->is_irq;
 
-	(*pic->pic_ops->pic_unblock_irqs)(pic, irq & ~0x1f, __BIT(irq & 0x1f));
+	if (atomic_dec_32_nv(>is_mask_count) == 0)
+		(*pic->pic_ops->pic_unblock_irqs)(pic, irq & ~0x1f, __BIT(irq & 0x1f));
 }
 
 const char *

Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.24 src/sys/arch/arm/pic/picvar.h:1.25
--- src/sys/arch/arm/pic/picvar.h:1.24	Mon Dec 23 15:34:23 2019
+++ src/sys/arch/arm/pic/picvar.h	Mon Dec 23 15:51:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.24 2019/12/23 15:34:23 jmcneill Exp $	*/
+/*	$NetBSD: picvar.h,v 1.25 2019/12/23 15:51:47 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -126,6 +126,7 @@ struct intrsource {
 	bool is_mpsafe;
 	char is_source[16];
 	char *is_xname;
+	uint32_t is_mask_count;
 };
 
 struct pic_percpu {



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

2019-03-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Wed Mar 27 07:29:29 UTC 2019

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

Log Message:
enlarge pic_name[] from 14 to 16. bcm2835_intr.c@1.20 used to the limit.
(sizeof struct pic_softc was not changed. it's just same as padding)


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 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/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.22 src/sys/arch/arm/pic/picvar.h:1.23
--- src/sys/arch/arm/pic/picvar.h:1.22	Fri Nov 16 15:06:22 2018
+++ src/sys/arch/arm/pic/picvar.h	Wed Mar 27 07:29:29 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.22 2018/11/16 15:06:22 jmcneill Exp $	*/
+/*	$NetBSD: picvar.h,v 1.23 2019/03/27 07:29:29 ryo Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -149,7 +149,7 @@ struct pic_softc {
 	percpu_t *pic_percpu;
 	uint8_t pic_id;
 	int pic_irqbase;
-	char pic_name[14];
+	char pic_name[16];
 };
 
 struct pic_ops {



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

2019-03-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Wed Mar 27 07:29:29 UTC 2019

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

Log Message:
enlarge pic_name[] from 14 to 16. bcm2835_intr.c@1.20 used to the limit.
(sizeof struct pic_softc was not changed. it's just same as padding)


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 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.



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

2018-11-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov 13 20:24:48 UTC 2018

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

Log Message:
Fix intrctl for pics with non-0 irqbase


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 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.



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

2018-11-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov 13 20:24:48 UTC 2018

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

Log Message:
Fix intrctl for pics with non-0 irqbase


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.46 src/sys/arch/arm/pic/pic.c:1.47
--- src/sys/arch/arm/pic/pic.c:1.46	Sun Nov 11 10:14:14 2018
+++ src/sys/arch/arm/pic/pic.c	Tue Nov 13 20:24:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.46 2018/11/11 10:14:14 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.47 2018/11/13 20:24:48 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.46 2018/11/11 10:14:14 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.47 2018/11/13 20:24:48 jmcneill Exp $");
 
 #include 
 #include 
@@ -916,7 +916,7 @@ intr_get_source(const char *intrid)
 		if (pic == NULL || pic->pic_irqbase < 0)
 			continue;
 		for (irq = 0; irq < pic->pic_maxsources; irq++) {
-			is = pic->pic_sources[irq - pic->pic_irqbase];
+			is = pic->pic_sources[irq];
 			if (is == NULL || is->is_source[0] == '\0')
 continue;
 
@@ -945,7 +945,7 @@ interrupt_construct_intrids(const kcpuse
 		struct pic_softc * const pic = pic_list[slot];
 		if (pic != NULL && pic->pic_irqbase >= 0) {
 			for (irq = 0; irq < pic->pic_maxsources; irq++) {
-is = pic->pic_sources[irq - pic->pic_irqbase];
+is = pic->pic_sources[irq];
 if (is && is->is_source[0] != '\0')
 	count++;
 			}
@@ -960,7 +960,7 @@ interrupt_construct_intrids(const kcpuse
 		if (pic == NULL || pic->pic_irqbase < 0)
 			continue;
 		for (irq = 0; irq < pic->pic_maxsources; irq++) {
-			is = pic->pic_sources[irq - pic->pic_irqbase];
+			is = pic->pic_sources[irq];
 			if (is == NULL || is->is_source[0] == '\0')
 continue;
 



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

2018-11-11 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 11 10:14:15 UTC 2018

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

Log Message:
Add support for intrctl(8).


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.45 src/sys/arch/arm/pic/pic.c:1.46
--- src/sys/arch/arm/pic/pic.c:1.45	Fri Oct 12 21:46:32 2018
+++ src/sys/arch/arm/pic/pic.c	Sun Nov 11 10:14:14 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.45 2018/10/12 21:46:32 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.46 2018/11/11 10:14:14 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.45 2018/10/12 21:46:32 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.46 2018/11/11 10:14:14 jmcneill Exp $");
 
 #include 
 #include 
@@ -901,7 +901,187 @@ intr_string(intr_handle_t irq, char *buf
 	return NULL;
 }
 
+static struct intrsource *
+intr_get_source(const char *intrid)
+{
+	struct intrsource *is;
+	intrid_t buf;
+	size_t slot;
+	int irq;
+
+	KASSERT(mutex_owned(_lock));
+
+	for (slot = 0; slot < PIC_MAXPICS; slot++) {
+		struct pic_softc * const pic = pic_list[slot];
+		if (pic == NULL || pic->pic_irqbase < 0)
+			continue;
+		for (irq = 0; irq < pic->pic_maxsources; irq++) {
+			is = pic->pic_sources[irq - pic->pic_irqbase];
+			if (is == NULL || is->is_source[0] == '\0')
+continue;
+
+			snprintf(buf, sizeof(buf), "%s %s", pic->pic_name, is->is_source);
+			if (strcmp(buf, intrid) == 0)
+return is;
+		}
+	}
+
+	return NULL;
+}
+
+struct intrids_handler *
+interrupt_construct_intrids(const kcpuset_t *cpuset)
+{
+	struct intrids_handler *iih;
+	struct intrsource *is;
+	int count, irq, n;
+	size_t slot;
+
+	if (kcpuset_iszero(cpuset))
+		return NULL;
+
+	count = 0;
+	for (slot = 0; slot < PIC_MAXPICS; slot++) {
+		struct pic_softc * const pic = pic_list[slot];
+		if (pic != NULL && pic->pic_irqbase >= 0) {
+			for (irq = 0; irq < pic->pic_maxsources; irq++) {
+is = pic->pic_sources[irq - pic->pic_irqbase];
+if (is && is->is_source[0] != '\0')
+	count++;
+			}
+		}
+	}
+
+	iih = kmem_zalloc(sizeof(int) + sizeof(intrid_t) * count, KM_SLEEP);
+	iih->iih_nids = count;
+
+	for (n = 0, slot = 0; n < count && slot < PIC_MAXPICS; slot++) {
+		struct pic_softc * const pic = pic_list[slot];
+		if (pic == NULL || pic->pic_irqbase < 0)
+			continue;
+		for (irq = 0; irq < pic->pic_maxsources; irq++) {
+			is = pic->pic_sources[irq - pic->pic_irqbase];
+			if (is == NULL || is->is_source[0] == '\0')
+continue;
+
+			snprintf(iih->iih_intrids[n++], sizeof(intrid_t), "%s %s",
+			pic->pic_name, is->is_source);
+		}
+	}
+
+	return iih;
+}
+
+void
+interrupt_destruct_intrids(struct intrids_handler *iih)
+{
+	if (iih == NULL)
+		return;
+
+	kmem_free(iih, sizeof(int) + sizeof(intrid_t) * iih->iih_nids);
+}
+
+void
+interrupt_get_available(kcpuset_t *cpuset)
+{
+	CPU_INFO_ITERATOR cii;
+	struct cpu_info *ci;
+
+	kcpuset_zero(cpuset);
+
+	mutex_enter(_lock);
+	for (CPU_INFO_FOREACH(cii, ci)) {
+		if ((ci->ci_schedstate.spc_flags & SPCF_NOINTR) == 0)
+			kcpuset_set(cpuset, cpu_index(ci));
+	}
+	mutex_exit(_lock);
+}
+
+void
+interrupt_get_devname(const char *intrid, char *buf, size_t len)
+{
+	buf[0] = '\0';
+}
+
+struct interrupt_get_count_arg {
+	struct intrsource *is;
+	uint64_t count;
+	u_int cpu_idx;
+};
+
+static void
+interrupt_get_count_cb(void *v0, void *v1, struct cpu_info *ci)
+{
+	struct pic_percpu * const pcpu = v0;
+	struct interrupt_get_count_arg * const arg = v1;
+
+	if (arg->cpu_idx != cpu_index(ci))
+		return;
+
+	arg->count = pcpu->pcpu_evs[arg->is->is_irq].ev_count;
+}
+
+uint64_t
+interrupt_get_count(const char *intrid, u_int cpu_idx)
+{
+	struct interrupt_get_count_arg arg;
+	struct intrsource *is;
+	uint64_t count;
+
+	count = 0;
+
+	mutex_enter(_lock);
+	is = intr_get_source(intrid);
+	if (is != NULL && is->is_pic != NULL) {
+		arg.is = is;
+		arg.count = 0;
+		arg.cpu_idx = cpu_idx;
+		percpu_foreach(is->is_pic->pic_percpu, interrupt_get_count_cb, );
+		count = arg.count;
+	}
+	mutex_exit(_lock);
+
+	return count;
+}
+
 #ifdef MULTIPROCESSOR
+void
+interrupt_get_assigned(const char *intrid, kcpuset_t *cpuset)
+{
+	struct intrsource *is;
+	struct pic_softc *pic;
+
+	kcpuset_zero(cpuset);
+
+	mutex_enter(_lock);
+	is = intr_get_source(intrid);
+	if (is != NULL) {
+		pic = is->is_pic;
+		if (pic && pic->pic_ops->pic_get_affinity)
+			pic->pic_ops->pic_get_affinity(pic, is->is_irq, cpuset);
+	}
+	mutex_exit(_lock);
+}
+
+int
+interrupt_distribute_handler(const char *intrid, const kcpuset_t *newset,
+kcpuset_t *oldset)
+{
+	struct intrsource *is;
+	int error;
+
+	mutex_enter(_lock);
+	is = intr_get_source(intrid);

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

2018-11-11 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 11 10:14:15 UTC 2018

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

Log Message:
Add support for intrctl(8).


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 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.



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

2018-11-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov  9 23:34:20 UTC 2018

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

Log Message:
Increase size of is_irq and pic_irqbase


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 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/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.20 src/sys/arch/arm/pic/picvar.h:1.21
--- src/sys/arch/arm/pic/picvar.h:1.20	Fri Oct 12 21:46:32 2018
+++ src/sys/arch/arm/pic/picvar.h	Fri Nov  9 23:34:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.20 2018/10/12 21:46:32 jmcneill Exp $	*/
+/*	$NetBSD: picvar.h,v 1.21 2018/11/09 23:34:20 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -117,7 +117,7 @@ struct intrsource {
 	struct pic_softc *is_pic;		/* owning PIC */
 	uint8_t is_type;			/* IST_xxx */
 	uint8_t is_ipl;/* IPL_xxx */
-	uint16_t is_irq;			/* local to pic */
+	uint32_t is_irq;			/* local to pic */
 	uint8_t is_iplidx;
 	bool is_mpsafe;
 	char is_source[16];
@@ -145,7 +145,7 @@ struct pic_softc {
 	size_t pic_maxsources;
 	percpu_t *pic_percpu;
 	uint8_t pic_id;
-	int16_t pic_irqbase;
+	int pic_irqbase;
 	char pic_name[14];
 };
 



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

2018-11-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov  9 23:34:20 UTC 2018

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

Log Message:
Increase size of is_irq and pic_irqbase


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 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.



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

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 21:46:32 UTC 2018

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

Log Message:
Implement intr_string(9)


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.19 -r1.20 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.44 src/sys/arch/arm/pic/pic.c:1.45
--- src/sys/arch/arm/pic/pic.c:1.44	Sun Jul 15 16:03:24 2018
+++ src/sys/arch/arm/pic/pic.c	Fri Oct 12 21:46:32 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.44 2018/07/15 16:03:24 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.45 2018/10/12 21:46:32 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.44 2018/07/15 16:03:24 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.45 2018/10/12 21:46:32 jmcneill Exp $");
 
 #include 
 #include 
@@ -883,6 +883,24 @@ intr_disestablish(void *ih)
 	pic_disestablish_source(is);
 }
 
+const char *
+intr_string(intr_handle_t irq, char *buf, size_t len)
+{
+	for (size_t slot = 0; slot < PIC_MAXPICS; slot++) {
+		struct pic_softc * const pic = pic_list[slot];
+		if (pic == NULL || pic->pic_irqbase < 0)
+			continue;
+		if (pic->pic_irqbase <= irq
+		&& irq < pic->pic_irqbase + pic->pic_maxsources) {
+			struct intrsource * const is = pic->pic_sources[irq - pic->pic_irqbase];
+			snprintf(buf, len, "%s %s", pic->pic_name, is->is_source);
+			return buf;
+		}
+	}
+
+	return NULL;
+}
+
 #ifdef MULTIPROCESSOR
 int
 interrupt_distribute(void *ih, const kcpuset_t *newset, kcpuset_t *oldset)

Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.19 src/sys/arch/arm/pic/picvar.h:1.20
--- src/sys/arch/arm/pic/picvar.h:1.19	Sat Sep  8 11:54:26 2018
+++ src/sys/arch/arm/pic/picvar.h	Fri Oct 12 21:46:32 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.19 2018/09/08 11:54:26 jmcneill Exp $	*/
+/*	$NetBSD: picvar.h,v 1.20 2018/10/12 21:46:32 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,6 +38,8 @@
 #include 
 #endif
 
+typedef uint32_t	intr_handle_t;		/* for ACPI */
+
 int	_splraise(int);
 int	_spllower(int);
 void	splx(int);
@@ -86,6 +88,7 @@ void	pic_dispatch(struct intrsource *is,
 void	*intr_establish(int irq, int ipl, int type, int (*func)(void *),
 	void *arg);
 void	intr_disestablish(void *);
+const char *intr_string(intr_handle_t, char *, size_t);
 #ifdef MULTIPROCESSOR
 void	intr_cpu_init(struct cpu_info *);
 void	intr_ipi_send(const kcpuset_t *, u_long ipi);



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

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 21:46:32 UTC 2018

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

Log Message:
Implement intr_string(9)


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.19 -r1.20 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.



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

2018-09-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  8 11:54:26 UTC 2018

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

Log Message:
Increase the size of is_irq from 8- to 16-bits to allow for > 256 IRQs per pic.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 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/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.18 src/sys/arch/arm/pic/picvar.h:1.19
--- src/sys/arch/arm/pic/picvar.h:1.18	Mon Jul 16 10:13:34 2018
+++ src/sys/arch/arm/pic/picvar.h	Sat Sep  8 11:54:26 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.18 2018/07/16 10:13:34 jmcneill Exp $	*/
+/*	$NetBSD: picvar.h,v 1.19 2018/09/08 11:54:26 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -114,7 +114,7 @@ struct intrsource {
 	struct pic_softc *is_pic;		/* owning PIC */
 	uint8_t is_type;			/* IST_xxx */
 	uint8_t is_ipl;/* IPL_xxx */
-	uint8_t is_irq;/* local to pic */
+	uint16_t is_irq;			/* local to pic */
 	uint8_t is_iplidx;
 	bool is_mpsafe;
 	char is_source[16];



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

2018-09-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  8 11:54:26 UTC 2018

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

Log Message:
Increase the size of is_irq from 8- to 16-bits to allow for > 256 IRQs per pic.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 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.



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

2018-07-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jul 16 10:13:34 UTC 2018

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

Log Message:
I added is_affinity to intrsource in the previous commit but it is not used. 
Remove it.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 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/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.17 src/sys/arch/arm/pic/picvar.h:1.18
--- src/sys/arch/arm/pic/picvar.h:1.17	Sun Jul 15 16:03:24 2018
+++ src/sys/arch/arm/pic/picvar.h	Mon Jul 16 10:13:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.17 2018/07/15 16:03:24 jmcneill Exp $	*/
+/*	$NetBSD: picvar.h,v 1.18 2018/07/16 10:13:34 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -118,9 +118,6 @@ struct intrsource {
 	uint8_t is_iplidx;
 	bool is_mpsafe;
 	char is_source[16];
-#ifdef MULTIPROCESSOR
-	kcpuset_t *is_affinity;
-#endif
 };
 
 struct pic_percpu {



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

2018-07-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jul 16 10:13:34 UTC 2018

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

Log Message:
I added is_affinity to intrsource in the previous commit but it is not used. 
Remove it.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 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.



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

2018-07-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jul 15 16:03:25 UTC 2018

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

Log Message:
Add support for setting and getting interrupt affinity.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.16 -r1.17 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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.43 src/sys/arch/arm/pic/pic.c:1.44
--- src/sys/arch/arm/pic/pic.c:1.43	Mon Jul  9 06:08:42 2018
+++ src/sys/arch/arm/pic/pic.c	Sun Jul 15 16:03:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.43 2018/07/09 06:08:42 ryo Exp $	*/
+/*	$NetBSD: pic.c,v 1.44 2018/07/15 16:03:24 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.43 2018/07/09 06:08:42 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.44 2018/07/15 16:03:24 jmcneill Exp $");
 
 #include 
 #include 
@@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.43
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -881,3 +882,26 @@ intr_disestablish(void *ih)
 
 	pic_disestablish_source(is);
 }
+
+#ifdef MULTIPROCESSOR
+int
+interrupt_distribute(void *ih, const kcpuset_t *newset, kcpuset_t *oldset)
+{
+	struct intrsource * const is = ih;
+	struct pic_softc * const pic = is->is_pic;
+
+	if (pic == NULL)
+		return EOPNOTSUPP;
+	if (pic->pic_ops->pic_set_affinity == NULL ||
+	pic->pic_ops->pic_get_affinity == NULL)
+		return EOPNOTSUPP;
+
+	if (!is->is_mpsafe)
+		return EINVAL;
+
+	if (oldset != NULL)
+		pic->pic_ops->pic_get_affinity(pic, is->is_irq, oldset);
+
+	return pic->pic_ops->pic_set_affinity(pic, is->is_irq, newset);
+}
+#endif

Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.16 src/sys/arch/arm/pic/picvar.h:1.17
--- src/sys/arch/arm/pic/picvar.h:1.16	Tue Jul  7 21:43:46 2015
+++ src/sys/arch/arm/pic/picvar.h	Sun Jul 15 16:03:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.16 2015/07/07 21:43:46 matt Exp $	*/
+/*	$NetBSD: picvar.h,v 1.17 2018/07/15 16:03:24 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -76,6 +76,10 @@ void	*pic_establish_intr(struct pic_soft
 	int (*func)(void *), void *arg);
 int	pic_alloc_irq(struct pic_softc *pic);
 void	pic_disestablish_source(struct intrsource *is);
+#ifdef MULTIPROCESSOR
+void	pic_distribute_source(struct intrsource *is, const kcpuset_t *,
+	kcpuset_t *);
+#endif
 void	pic_do_pending_ints(register_t psw, int newipl, void *frame);
 void	pic_dispatch(struct intrsource *is, void *frame);
 
@@ -114,6 +118,9 @@ struct intrsource {
 	uint8_t is_iplidx;
 	bool is_mpsafe;
 	char is_source[16];
+#ifdef MULTIPROCESSOR
+	kcpuset_t *is_affinity;
+#endif
 };
 
 struct pic_percpu {
@@ -156,6 +163,8 @@ struct pic_ops {
 #ifdef MULTIPROCESSOR
 	void (*pic_cpu_init)(struct pic_softc *, struct cpu_info *);
 	void (*pic_ipi_send)(struct pic_softc *, const kcpuset_t *, u_long);
+	int (*pic_set_affinity)(struct pic_softc *, size_t, const kcpuset_t *);
+	void (*pic_get_affinity)(struct pic_softc *, size_t, kcpuset_t *);
 #endif
 };
 



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

2018-07-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jul 15 16:03:25 UTC 2018

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

Log Message:
Add support for setting and getting interrupt affinity.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.16 -r1.17 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.



  1   2   >