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);