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-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-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.

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-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 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: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 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.

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 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: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.

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

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-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: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-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-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.

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: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

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: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.

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

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-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-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-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-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-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-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jul  9 06:08:42 UTC 2018

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

Log Message:
fix false positive KASSERT.
the case that secondary processors failed to hatch, and not attached.

when "cpu1 at cpus0: disabled (unresponsive)"


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 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.42 src/sys/arch/arm/pic/pic.c:1.43
--- src/sys/arch/arm/pic/pic.c:1.42	Sun Apr  1 04:35:04 2018
+++ src/sys/arch/arm/pic/pic.c	Mon Jul  9 06:08:42 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.42 2018/04/01 04:35:04 ryo Exp $	*/
+/*	$NetBSD: pic.c,v 1.43 2018/07/09 06:08:42 ryo 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.42 2018/04/01 04:35:04 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.43 2018/07/09 06:08:42 ryo Exp $");
 
 #include 
 #include 
@@ -201,7 +201,7 @@ intr_ipi_send(const kcpuset_t *kcp, u_lo
 			sent_p = true;
 		}
 	}
-	KASSERT(cold || sent_p || arm_cpu_max == 1);
+	KASSERT(cold || sent_p || ncpu <= 1);
 }
 #endif /* MULTIPROCESSOR */
 



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

2017-10-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 12 19:59:22 UTC 2017

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 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.40 src/sys/arch/arm/pic/pic.c:1.41
--- src/sys/arch/arm/pic/pic.c:1.40	Thu Sep 21 19:29:14 2017
+++ src/sys/arch/arm/pic/pic.c	Thu Oct 12 19:59:22 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.40 2017/09/21 19:29:14 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.41 2017/10/12 19:59:22 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.40 2017/09/21 19:29:14 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.41 2017/10/12 19:59:22 skrll Exp $");
 
 #include 
 #include 
@@ -103,7 +103,7 @@ size_t pic_ipl_offset[NIPL+1];
 
 static kmutex_t pic_lock;
 size_t pic_sourcebase;
-static struct evcnt pic_deferral_ev = 
+static struct evcnt pic_deferral_ev =
 EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "deferred", "intr");
 EVCNT_ATTACH_STATIC(pic_deferral_ev);
 
@@ -215,7 +215,7 @@ int
 pic_handle_softint(void *arg)
 {
 	void softint_switch(lwp_t *, int);
-	struct cpu_info * const ci = curcpu(); 
+	struct cpu_info * const ci = curcpu();
 	const size_t softint = (size_t) arg;
 	int s = splhigh();
 	ci->ci_intr_depth--;	// don't count these as interrupts
@@ -283,7 +283,7 @@ pic_mark_pending_sources(struct pic_soft
 		return ipl_mask;
 
 	KASSERT((irq_base & 31) == 0);
-	
+
 	(*pic->pic_ops->pic_block_irqs)(pic, irq_base, pending);
 
 	atomic_or_32(ipending, pending);
@@ -697,7 +697,7 @@ pic_add(struct pic_softc *pic, int irqba
 	 * Allocate a pointer to each cpu's evcnts and then, for each cpu,
 	 * allocate its evcnts and then attach an evcnt for each pin.
 	 * We can't allocate the evcnt structures directly since
-	 * percpu will move the contents of percpu memory around and 
+	 * percpu will move the contents of percpu memory around and
 	 * corrupt the pointers in the evcnts themselves.  Remember, any
 	 * problem can be solved with sufficient indirection.
 	 */
@@ -822,7 +822,7 @@ pic_establish_intr(struct pic_softc *pic
 unblock:
 	(*pic->pic_ops->pic_unblock_irqs)(pic, is->is_irq & ~0x1f,
 	__BIT(is->is_irq & 0x1f));
-	
+
 	/* We're done. */
 	return is;
 }



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

2017-09-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Sep 21 19:29:14 UTC 2017

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

Log Message:
spaces to TAB


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 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.39 src/sys/arch/arm/pic/pic.c:1.40
--- src/sys/arch/arm/pic/pic.c:1.39	Tue Aug 29 22:57:05 2017
+++ src/sys/arch/arm/pic/pic.c	Thu Sep 21 19:29:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.39 2017/08/29 22:57:05 nisimura Exp $	*/
+/*	$NetBSD: pic.c,v 1.40 2017/09/21 19:29:14 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.39 2017/08/29 22:57:05 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.40 2017/09/21 19:29:14 skrll Exp $");
 
 #include 
 #include 
@@ -287,7 +287,7 @@ pic_mark_pending_sources(struct pic_soft
 	(*pic->pic_ops->pic_block_irqs)(pic, irq_base, pending);
 
 	atomic_or_32(ipending, pending);
-while (pending != 0) {
+	while (pending != 0) {
 		int n = ffs(pending);
 		if (n-- == 0)
 			break;



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

2017-08-29 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Aug 29 22:57:05 UTC 2017

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

Log Message:
decouple pic_ipi_kpreempt() from DDB


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 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.38 src/sys/arch/arm/pic/pic.c:1.39
--- src/sys/arch/arm/pic/pic.c:1.38	Fri Aug 25 20:36:16 2017
+++ src/sys/arch/arm/pic/pic.c	Tue Aug 29 22:57:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.38 2017/08/25 20:36:16 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.39 2017/08/29 22:57:05 nisimura 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.38 2017/08/25 20:36:16 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.39 2017/08/29 22:57:05 nisimura Exp $");
 
 #include 
 #include 
@@ -159,6 +159,7 @@ pic_ipi_ddb(void *arg)
 	kdb_trap(-1, arg);
 	return 1;
 }
+#endif /* DDB */
 
 #ifdef __HAVE_PREEMPTION
 int
@@ -167,8 +168,7 @@ pic_ipi_kpreempt(void *arg)
 	atomic_or_uint(()->ci_astpending, __BIT(1));
 	return 1;
 }
-#endif
-#endif /* MULTIPROCESSOR */
+#endif /* __HAVE_PREEMPTION */
 
 void
 intr_cpu_init(struct cpu_info *ci)



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

2017-08-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Aug 25 20:36:16 UTC 2017

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

Log Message:
The assertion at the bottom of intr_ipi_send is invalid for UP configs; add
a text for arm_cpu_max == 1


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 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.37 src/sys/arch/arm/pic/pic.c:1.38
--- src/sys/arch/arm/pic/pic.c:1.37	Thu Jun  1 02:45:06 2017
+++ src/sys/arch/arm/pic/pic.c	Fri Aug 25 20:36:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.37 2017/06/01 02:45:06 chs Exp $	*/
+/*	$NetBSD: pic.c,v 1.38 2017/08/25 20:36:16 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.37 2017/06/01 02:45:06 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.38 2017/08/25 20:36:16 jmcneill Exp $");
 
 #include 
 #include 
@@ -206,7 +206,7 @@ intr_ipi_send(const kcpuset_t *kcp, u_lo
 			sent_p = true;
 		}
 	}
-	KASSERT(cold || sent_p);
+	KASSERT(cold || sent_p || arm_cpu_max == 1);
 }
 #endif /* MULTIPROCESSOR */
 



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

2015-10-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Oct 11 20:20:33 UTC 2015

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

Log Message:
unblock interrupts also when reusing a previously freed irq slot.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 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.35 src/sys/arch/arm/pic/pic.c:1.36
--- src/sys/arch/arm/pic/pic.c:1.35	Sat Apr 18 14:09:32 2015
+++ src/sys/arch/arm/pic/pic.c	Sun Oct 11 20:20:33 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.35 2015/04/18 14:09:32 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.36 2015/10/11 20:20:33 mlelstv 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.35 2015/04/18 14:09:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.36 2015/10/11 20:20:33 mlelstv Exp $");
 
 #include 
 #include 
@@ -793,7 +793,7 @@ pic_establish_intr(struct pic_softc *pic
 		if (pic__iplsources[off] == NULL) {
 			is->is_iplidx = off - pic_ipl_offset[ipl];
 			pic__iplsources[off] = is;
-			return is;
+			goto unblock;
 		}
 	}
 
@@ -824,6 +824,7 @@ pic_establish_intr(struct pic_softc *pic
 
 	(*pic->pic_ops->pic_establish_irq)(pic, is);
 
+unblock:
 	(*pic->pic_ops->pic_unblock_irqs)(pic, is->is_irq & ~0x1f,
 	__BIT(is->is_irq & 0x1f));
 	



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

2015-07-07 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Tue Jul  7 21:43:46 UTC 2015

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

Log Message:
Protect #include opt_multiprocessor.h with _KERNEL_OPT


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 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.15 src/sys/arch/arm/pic/picvar.h:1.16
--- src/sys/arch/arm/pic/picvar.h:1.15	Wed Apr 15 15:45:06 2015
+++ src/sys/arch/arm/pic/picvar.h	Tue Jul  7 21:43:46 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.15 2015/04/15 15:45:06 matt Exp $	*/
+/*	$NetBSD: picvar.h,v 1.16 2015/07/07 21:43:46 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -30,7 +30,9 @@
 #ifndef _ARM_PIC_PICVAR_H_
 #define _ARM_PIC_PICVAR_H_
 
+#ifdef _KERNEL_OPT
 #include opt_multiprocessor.h
+#endif
 
 #ifdef MULTIPROCESSOR
 #include sys/kcpuset.h



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

2015-04-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Apr 18 14:09:32 UTC 2015

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

Log Message:
Serialise work in pic_add.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 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.34 src/sys/arch/arm/pic/pic.c:1.35
--- src/sys/arch/arm/pic/pic.c:1.34	Wed Apr 15 15:45:06 2015
+++ src/sys/arch/arm/pic/pic.c	Sat Apr 18 14:09:32 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.34 2015/04/15 15:45:06 matt Exp $	*/
+/*	$NetBSD: pic.c,v 1.35 2015/04/18 14:09:32 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include opt_multiprocessor.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.34 2015/04/15 15:45:06 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.35 2015/04/18 14:09:32 skrll Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -42,6 +42,8 @@ __KERNEL_RCSID(0, $NetBSD: pic.c,v 1.34
 #include sys/intr.h
 #include sys/kernel.h
 #include sys/kmem.h
+#include sys/mutex.h
+#include sys/once.h
 #include sys/xcall.h
 #include sys/ipi.h
 
@@ -98,11 +100,15 @@ struct intrsource **pic_iplsource[NIPL] 
 	[0 ... NIPL-1] = pic__iplsources,
 };
 size_t pic_ipl_offset[NIPL+1];
+
+static kmutex_t pic_lock;
 size_t pic_sourcebase;
 static struct evcnt pic_deferral_ev = 
 EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, deferred, intr);
 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)
@@ -622,10 +628,23 @@ pic_pending_zero(void *v0, void *v1, str
 }
 #endif /* __HAVE_PIC_PENDING_INTRS  MULTIPROCESSOR */
 
+static int
+pic_init(void)
+{
+
+	mutex_init(pic_lock, MUTEX_DEFAULT, IPL_HIGH);
+
+	return 0;
+}
+
 void
 pic_add(struct pic_softc *pic, int irqbase)
 {
 	int slot, maybe_slot = -1;
+	size_t sourcebase;
+	static ONCE_DECL(pic_once);
+
+	RUN_ONCE(pic_once, pic_init);
 
 	KASSERT(strlen(pic-pic_name)  0);
 
@@ -641,6 +660,7 @@ pic_add(struct pic_softc *pic, int irqba
 	}
 #endif /* __HAVE_PIC_PENDING_INTRS  MULTIPROCESSOR */
 
+	mutex_enter(pic_lock);
 	for (slot = 0; slot  PIC_MAXPICS; slot++) {
 		struct pic_softc * const xpic = pic_list[slot];
 		if (xpic == NULL) {
@@ -669,6 +689,10 @@ pic_add(struct pic_softc *pic, int irqba
 	KASSERTMSG(pic-pic_maxsources = PIC_MAXSOURCES, %zu,
 	pic-pic_maxsources);
 	KASSERT(pic_sourcebase + pic-pic_maxsources = PIC_MAXMAXSOURCES);
+	sourcebase = pic_sourcebase;
+	pic_sourcebase += pic-pic_maxsources;
+
+	mutex_exit(pic_lock);
 
 	/*
 	 * Allocate a pointer to each cpu's evcnts and then, for each cpu,
@@ -686,9 +710,8 @@ pic_add(struct pic_softc *pic, int irqba
 	 */
 	percpu_foreach(pic-pic_percpu, pic_percpu_allocate, pic);
 
-	pic-pic_sources = pic_sources[pic_sourcebase];
+	pic-pic_sources = pic_sources[sourcebase];
 	pic-pic_irqbase = irqbase;
-	pic_sourcebase += pic-pic_maxsources;
 	pic-pic_id = slot;
 #ifdef __HAVE_PIC_SET_PRIORITY
 	KASSERT((slot == 0) == (pic-pic_ops-pic_set_priority != NULL));



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

2015-04-12 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun Apr 12 08:52:54 UTC 2015

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

Log Message:
Use right kcpuset call.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 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.29 src/sys/arch/arm/pic/pic.c:1.30
--- src/sys/arch/arm/pic/pic.c:1.29	Sat Apr 11 19:39:09 2015
+++ src/sys/arch/arm/pic/pic.c	Sun Apr 12 08:52:54 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.29 2015/04/11 19:39:09 matt Exp $	*/
+/*	$NetBSD: pic.c,v 1.30 2015/04/12 08:52:54 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include opt_multiprocessor.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.29 2015/04/11 19:39:09 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.30 2015/04/12 08:52:54 matt Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -182,7 +182,7 @@ intr_ipi_send(const kcpuset_t *kcp, u_lo
 		struct pic_softc * const pic = pic_list[slot];
 		if (pic == NULL || pic-pic_cpus == NULL)
 			continue;
-		if (kcp == NULL || kcpuset_intersect(kcp, pic-pic_cpus)) {
+		if (kcp == NULL || kcpuset_intersecting_p(kcp, pic-pic_cpus)) {
 			(*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

2015-04-12 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun Apr 12 08:55:14 UTC 2015

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

Log Message:
Don't need pic_ipi_sender anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 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.30 src/sys/arch/arm/pic/pic.c:1.31
--- src/sys/arch/arm/pic/pic.c:1.30	Sun Apr 12 08:52:54 2015
+++ src/sys/arch/arm/pic/pic.c	Sun Apr 12 08:55:14 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.30 2015/04/12 08:52:54 matt Exp $	*/
+/*	$NetBSD: pic.c,v 1.31 2015/04/12 08:55:14 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include opt_multiprocessor.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.30 2015/04/12 08:52:54 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.31 2015/04/12 08:55:14 matt Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -161,18 +161,6 @@ intr_cpu_init(struct cpu_info *ci)
 
 typedef void (*pic_ipi_send_func_t)(struct pic_softc *, u_long);
 
-static struct pic_softc *
-pic_ipi_sender(void)
-{
-	for (size_t slot = 0; slot  PIC_MAXPICS; slot++) {
-		struct pic_softc * const pic = pic_list[slot];
-		if (pic != NULL  pic-pic_ops-pic_ipi_send != NULL) {
-			return pic;
-		}
-	}
-	return NULL;
-}
-
 void
 intr_ipi_send(const kcpuset_t *kcp, u_long ipi)
 {



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

2015-04-12 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun Apr 12 15:32:19 UTC 2015

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

Log Message:
Don't send IPIs to ourselves if sending to everyone.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 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.31 src/sys/arch/arm/pic/pic.c:1.32
--- src/sys/arch/arm/pic/pic.c:1.31	Sun Apr 12 08:55:14 2015
+++ src/sys/arch/arm/pic/pic.c	Sun Apr 12 15:32:19 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.31 2015/04/12 08:55:14 matt Exp $	*/
+/*	$NetBSD: pic.c,v 1.32 2015/04/12 15:32:19 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include opt_multiprocessor.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.31 2015/04/12 08:55:14 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.32 2015/04/12 15:32:19 matt Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -164,6 +164,7 @@ typedef void (*pic_ipi_send_func_t)(stru
 void
 intr_ipi_send(const kcpuset_t *kcp, u_long ipi)
 {
+	struct cpu_info * const ci = curcpu();
 	KASSERT(ipi  NIPI);
 	bool __diagused sent_p = false;
 	for (size_t slot = 0; slot  PIC_MAXPICS; slot++) {
@@ -171,6 +172,10 @@ 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
+			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

2015-04-11 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sat Apr 11 19:39:09 UTC 2015

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

Log Message:
Adapt pic to deal with the BCM2836 interrupts.
Move pic_pending_pics, pic_pending_ipls, and pic_blocked_irqs into a
structure and make then per-cpu.  There is no global interrupt state anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 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.28 src/sys/arch/arm/pic/pic.c:1.29
--- src/sys/arch/arm/pic/pic.c:1.28	Wed Apr  8 21:43:30 2015
+++ src/sys/arch/arm/pic/pic.c	Sat Apr 11 19:39:09 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.28 2015/04/08 21:43:30 matt Exp $	*/
+/*	$NetBSD: pic.c,v 1.29 2015/04/11 19:39:09 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include opt_multiprocessor.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.28 2015/04/08 21:43:30 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.29 2015/04/11 19:39:09 matt Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -61,17 +61,31 @@ __KERNEL_RCSID(0, $NetBSD: pic.c,v 1.28
 #include arm/pic/picvar.h
 
 #if defined(__HAVE_PIC_PENDING_INTRS)
+/*
+ * This implementation of pending interrupts on a MULTIPROCESSOR system makes
+ * the assumption that a PIC (pic_softc) shall only have all its interrupts
+ * come from the same CPU.  In other words, interrupts from a single PIC will
+ * not be distributed among multiple CPUs.
+ */
+struct pic_pending {
+	volatile uint32_t blocked_pics;
+	volatile uint32_t pending_pics;
+	volatile uint32_t pending_ipls;
+};
 static uint32_t
 	pic_find_pending_irqs_by_ipl(struct pic_softc *, size_t, uint32_t, int);
 static struct pic_softc *
-	pic_list_find_pic_by_pending_ipl(uint32_t);
+	pic_list_find_pic_by_pending_ipl(struct pic_pending *, uint32_t);
 static void
-	pic_deliver_irqs(struct pic_softc *, int, void *);
+	pic_deliver_irqs(struct pic_pending *, struct pic_softc *, int, void *);
 static void
-	pic_list_deliver_irqs(register_t, int, void *);
-volatile uint32_t pic_blocked_pics;
-volatile uint32_t pic_pending_pics;
-volatile uint32_t pic_pending_ipls;
+	pic_list_deliver_irqs(struct pic_pending *, register_t, int, void *);
+
+#ifdef MULTIPROCESSOR
+percpu_t *pic_pending_percpu;
+#else
+struct pic_pending pic_pending;
+#endif /* MULTIPROCESSOR */
 #endif /* __HAVE_PIC_PENDING_INTRS */
 
 struct pic_softc *pic_list[PIC_MAXPICS];
@@ -162,12 +176,22 @@ pic_ipi_sender(void)
 void
 intr_ipi_send(const kcpuset_t *kcp, u_long ipi)
 {
-	struct pic_softc * const pic = pic_ipi_sender();
 	KASSERT(ipi  NIPI);
-	if (cold  pic == NULL)
-		return;
-	KASSERT(pic != NULL);
-	(*pic-pic_ops-pic_ipi_send)(pic, kcp, ipi);
+	bool __diagused sent_p = false;
+	for (size_t slot = 0; slot  PIC_MAXPICS; slot++) {
+		struct pic_softc * const pic = pic_list[slot];
+		if (pic == NULL || pic-pic_cpus == NULL)
+			continue;
+		if (kcp == NULL || kcpuset_intersect(kcp, pic-pic_cpus)) {
+			(*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 (kcp != NULL || pic-pic_cpus == kcpuset_running)
+return;
+			sent_p = true;
+		}
+	}
+	KASSERT(cold || sent_p);
 }
 #endif /* MULTIPROCESSOR */
 
@@ -208,8 +232,16 @@ pic_mark_pending_source(struct pic_softc
 	__BIT(is-is_irq  0x1f));
 
 	atomic_or_32(pic-pic_pending_ipls, ipl_mask);
-	atomic_or_32(pic_pending_ipls, ipl_mask);
-	atomic_or_32(pic_pending_pics, __BIT(pic-pic_id));
+#ifdef MULTIPROCESSOR
+	struct pic_pending *pend = percpu_getref(pic_pending_percpu);
+#else
+	struct pic_pending *pend = pic_pending;
+#endif
+	atomic_or_32(pend-pending_ipls, ipl_mask);
+	atomic_or_32(pend-pending_pics, __BIT(pic-pic_id));
+#ifdef MULTIPROCESSOR
+	percpu_putref(pic_pending_percpu);
+#endif
 }
 
 void
@@ -252,9 +284,16 @@ pic_mark_pending_sources(struct pic_soft
 	}
 
 	atomic_or_32(pic-pic_pending_ipls, ipl_mask);
-	atomic_or_32(pic_pending_ipls, ipl_mask);
-	atomic_or_32(pic_pending_pics, __BIT(pic-pic_id));
-
+#ifdef MULTIPROCESSOR
+	struct pic_pending *pend = percpu_getref(pic_pending_percpu);
+#else
+	struct pic_pending *pend = pic_pending;
+#endif
+	atomic_or_32(pend-pending_ipls, ipl_mask);
+	atomic_or_32(pend-pending_pics, __BIT(pic-pic_id));
+#ifdef MULTIPROCESSOR
+	percpu_putref(pic_pending_percpu);
+#endif
 	return ipl_mask;
 }
 
@@ -324,7 +363,8 @@ pic_dispatch(struct intrsource *is, void
 
 #if defined(__HAVE_PIC_PENDING_INTRS)
 void
-pic_deliver_irqs(struct pic_softc *pic, int ipl, void *frame)
+pic_deliver_irqs(struct pic_pending *pend, struct pic_softc *pic, int ipl,
+void *frame)
 {
 	const uint32_t ipl_mask = __BIT(ipl);
 	struct intrsource *is;
@@ -339,7 +379,7 @@ pic_deliver_irqs(struct pic_softc *pic, 
 	uint32_t 

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

2015-04-09 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Apr  9 06:03:43 UTC 2015

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

Log Message:
Only if we __HAVE_PIC_PENDING_INTRS do we need the variables to track them.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 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.12 src/sys/arch/arm/pic/picvar.h:1.13
--- src/sys/arch/arm/pic/picvar.h:1.12	Wed Apr  8 21:43:30 2015
+++ src/sys/arch/arm/pic/picvar.h	Thu Apr  9 06:03:43 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.12 2015/04/08 21:43:30 matt Exp $	*/
+/*	$NetBSD: picvar.h,v 1.13 2015/04/09 06:03:43 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -125,9 +125,11 @@ struct pic_percpu {
 struct pic_softc {
 	const struct pic_ops *pic_ops;
 	struct intrsource **pic_sources;
+#ifdef __HAVE_PIC_PENDING_INTRS
 	volatile uint32_t pic_pending_irqs[(PIC_MAXSOURCES + 31) / 32];
 	volatile uint32_t pic_blocked_irqs[(PIC_MAXSOURCES + 31) / 32];
 	volatile uint32_t pic_pending_ipls;
+#endif
 	size_t pic_maxsources;
 	percpu_t *pic_percpu;
 	uint8_t pic_id;
@@ -167,7 +169,7 @@ void	pic_set_priority(struct cpu_info *,
 void	pic_add(struct pic_softc *, int);
 void	pic_do_pending_int(void);
 #ifdef MULTIPROCESSOR
-int	pic_ipi_nop(void *);
+int	pic_ipi_nop(void *);		// IPI_KPREEMPT tto
 int	pic_ipi_xcall(void *);
 int	pic_ipi_generic(void *);
 int	pic_ipi_shootdown(void *);



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

2015-04-01 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Apr  2 03:11:34 UTC 2015

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

Log Message:
#include sys/lwp.h


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 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.6 src/sys/arch/arm/pic/pic_splfuncs.c:1.7
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.6	Sun Mar 29 00:31:30 2015
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Thu Apr  2 03:11:34 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.6 2015/03/29 00:31:30 matt Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.7 2015/04/02 03:11:34 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,12 +28,13 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic_splfuncs.c,v 1.6 2015/03/29 00:31:30 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic_splfuncs.c,v 1.7 2015/04/02 03:11:34 matt Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
 #include sys/atomic.h
 #include sys/evcnt.h
+#include sys/lwp.h
 #include sys/kernel.h
 
 #include dev/cons.h



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

2015-03-28 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun Mar 29 00:31:30 UTC 2015

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

Log Message:
Add aarch64 support (mostly remapping I32_bit and F32_bit onto aarch64 bits).


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.5 -r1.6 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.25 src/sys/arch/arm/pic/pic.c:1.26
--- src/sys/arch/arm/pic/pic.c:1.25	Sat Nov  8 17:09:38 2014
+++ src/sys/arch/arm/pic/pic.c	Sun Mar 29 00:31:30 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.25 2014/11/08 17:09:38 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.26 2015/03/29 00:31:30 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include opt_multiprocessor.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.25 2014/11/08 17:09:38 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.26 2015/03/29 00:31:30 matt Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -45,8 +45,14 @@ __KERNEL_RCSID(0, $NetBSD: pic.c,v 1.25
 #include sys/xcall.h
 #include sys/ipi.h
 
+#if defined(__arm__)
 #include arm/armreg.h
 #include arm/cpufunc.h
+#elif defined(__aarch64__)
+#include aarch64/locore.h
+#define I32_bit		DAIF_I
+#define F32_bit		DAIF_F
+#endif
 
 #ifdef DDB
 #include arm/db_machdep.h

Index: src/sys/arch/arm/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.5 src/sys/arch/arm/pic/pic_splfuncs.c:1.6
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.5	Wed Apr 16 22:44:42 2014
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Sun Mar 29 00:31:30 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.5 2014/04/16 22:44:42 matt Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.6 2015/03/29 00:31:30 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic_splfuncs.c,v 1.5 2014/04/16 22:44:42 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic_splfuncs.c,v 1.6 2015/03/29 00:31:30 matt Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -38,9 +38,15 @@ __KERNEL_RCSID(0, $NetBSD: pic_splfuncs
 
 #include dev/cons.h
 
+#if defined(__arm__)
 #include arm/armreg.h
 #include arm/cpu.h
 #include arm/cpufunc.h
+#elif defined(__aarch64__)
+#include aarch64/locore.h
+#define I32_bit		DAIF_I
+#define F32_bit		DAIF_F
+#endif
 
 #include arm/pic/picvar.h
 
@@ -67,7 +73,7 @@ _spllower(int newipl)
 		ci-ci_intr_depth++;
 		pic_do_pending_ints(psw, newipl, NULL);
 		ci-ci_intr_depth--;
-		if ((psw  I32_bit) == 0)
+		if ((psw  I32_bit) == 0 || newipl == IPL_NONE)
 			cpsie(I32_bit);
 		cpu_dosoftints();
 	}



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

2014-11-08 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Nov  8 17:09:38 UTC 2014

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

Log Message:
Include opt_multiprocessor.h


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 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.24 src/sys/arch/arm/pic/pic.c:1.25
--- src/sys/arch/arm/pic/pic.c:1.24	Wed Oct 29 14:41:57 2014
+++ src/sys/arch/arm/pic/pic.c	Sat Nov  8 17:09:38 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.24 2014/10/29 14:41:57 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.25 2014/11/08 17:09:38 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -30,9 +30,10 @@
 
 #define _INTR_PRIVATE
 #include opt_ddb.h
+#include opt_multiprocessor.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.24 2014/10/29 14:41:57 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.25 2014/11/08 17:09:38 skrll Exp $);
 
 #include sys/param.h
 #include sys/atomic.h



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

2014-10-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Oct 29 14:41:57 UTC 2014

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

Log Message:
In the MULTIPROCESSOR case mark all interrupt handlers not at IPL_VM as
mpsafe, so the kernel_lock is only taken at IPL_VM as per spl(9).


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 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.23 src/sys/arch/arm/pic/pic.c:1.24
--- src/sys/arch/arm/pic/pic.c:1.23	Mon Oct 13 09:21:06 2014
+++ src/sys/arch/arm/pic/pic.c	Wed Oct 29 14:41:57 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.23 2014/10/13 09:21:06 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.24 2014/10/29 14:41:57 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
 #include opt_ddb.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.23 2014/10/13 09:21:06 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.24 2014/10/29 14:41:57 skrll Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -646,7 +646,7 @@ pic_establish_intr(struct pic_softc *pic
 	is-is_func = func;
 	is-is_arg = arg;
 #ifdef MULTIPROCESSOR
-	is-is_mpsafe = (type  IST_MPSAFE);
+	is-is_mpsafe = (type  IST_MPSAFE) || ipl != IPL_VM;
 #endif
 
 	if (pic-pic_ops-pic_source_name)



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

2014-10-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Oct 13 09:21:06 UTC 2014

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

Log Message:
Comment out a printf that was confusing entering ddb output.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 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.22 src/sys/arch/arm/pic/pic.c:1.23
--- src/sys/arch/arm/pic/pic.c:1.22	Mon May 19 22:47:53 2014
+++ src/sys/arch/arm/pic/pic.c	Mon Oct 13 09:21:06 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.22 2014/05/19 22:47:53 rmind Exp $	*/
+/*	$NetBSD: pic.c,v 1.23 2014/10/13 09:21:06 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
 #include opt_ddb.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.22 2014/05/19 22:47:53 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.23 2014/10/13 09:21:06 skrll Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -119,7 +119,7 @@ pic_ipi_generic(void *arg)
 int
 pic_ipi_ddb(void *arg)
 {
-	printf(%s: %s: tf=%p\n, __func__, curcpu()-ci_cpuname, arg);
+//	printf(%s: %s: tf=%p\n, __func__, curcpu()-ci_cpuname, arg);
 	kdb_trap(-1, arg);
 	return 1;
 }



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

2014-03-13 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Mar 13 23:47:53 UTC 2014

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

Log Message:
Support MPSAFE interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.8 -r1.9 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.20 src/sys/arch/arm/pic/pic.c:1.21
--- src/sys/arch/arm/pic/pic.c:1.20	Mon Mar  3 08:50:48 2014
+++ src/sys/arch/arm/pic/pic.c	Thu Mar 13 23:47:53 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.20 2014/03/03 08:50:48 matt Exp $	*/
+/*	$NetBSD: pic.c,v 1.21 2014/03/13 23:47:53 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -27,10 +27,13 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.20 2014/03/03 08:50:48 matt Exp $);
 
 #define _INTR_PRIVATE
+#include opt_ddb.h
+
+#include sys/cdefs.h
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.21 2014/03/13 23:47:53 matt Exp $);
+
 #include sys/param.h
 #include sys/atomic.h
 #include sys/cpu.h
@@ -43,6 +46,10 @@ __KERNEL_RCSID(0, $NetBSD: pic.c,v 1.20
 #include arm/armreg.h
 #include arm/cpufunc.h
 
+#ifdef DDB
+#include arm/db_machdep.h
+#endif
+
 #include arm/pic/picvar.h
 
 static uint32_t
@@ -100,6 +107,16 @@ pic_ipi_xcall(void *arg)
 	return 1;
 }
 
+#ifdef DDB
+int
+pic_ipi_ddb(void *arg)
+{
+	printf(%s: %s: tf=%p\n, __func__, curcpu()-ci_cpuname, arg);
+	kdb_trap(-1, arg);
+	return 1;
+}
+#endif
+
 void
 intr_cpu_init(struct cpu_info *ci)
 {
@@ -269,7 +286,11 @@ pic_dispatch(struct intrsource *is, void
 #ifdef MULTIPROCESSOR
 	if (!is-is_mpsafe) {
 		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);
+		KASSERT(ci_blcnt == curcpu()-ci_biglock_count);
+		KASSERT(l_blcnt == curlwp-l_blcnt);
 		KERNEL_UNLOCK_ONE(NULL);
 	} else
 #endif
@@ -613,11 +634,11 @@ pic_establish_intr(struct pic_softc *pic
 	is-is_pic = pic;
 	is-is_irq = irq;
 	is-is_ipl = ipl;
-	is-is_type = type;
+	is-is_type = type  0xff;
 	is-is_func = func;
 	is-is_arg = arg;
 #ifdef MULTIPROCESSOR
-	is-is_mpsafe = false;
+	is-is_mpsafe = (type  IST_MPSAFE);
 #endif
 
 	if (pic-pic_ops-pic_source_name)

Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.8 src/sys/arch/arm/pic/picvar.h:1.9
--- src/sys/arch/arm/pic/picvar.h:1.8	Mon Mar  3 08:50:48 2014
+++ src/sys/arch/arm/pic/picvar.h	Thu Mar 13 23:47:53 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.8 2014/03/03 08:50:48 matt Exp $	*/
+/*	$NetBSD: picvar.h,v 1.9 2014/03/13 23:47:53 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -47,11 +47,13 @@ struct cpu_info;
 #define	IPI_AST			0	/* just get an interrupt */
 #define	IPI_XCALL		1	/* xcall */
 #define	IPI_NOP			2	/* just get an interrupt (armv6) */
-#ifndef __HAVE_PREEMPTION
-#define	NIPI			3
+#define	IPI_SHOOTDOWN		3	/* cause a tlb shootdown */
+#define	IPI_DDB			4	/* enter DDB */
+#ifdef __HAVE_PREEMPTION
+#define	IPI_KPREEMPT		5	/* cause a preemption */
+#define	NIPI			6
 #else
-#define	IPI_KPREEMPT		4	/* cause a preemption */
-#define	NIPI			4
+#define	NIPI			5
 #endif
 
 int	pic_handle_intr(void *);
@@ -158,6 +160,8 @@ void	pic_do_pending_int(void);
 #ifdef MULTIPROCESSOR
 int	pic_ipi_nop(void *);
 int	pic_ipi_xcall(void *);
+int	pic_ipi_shootdown(void *);
+int	pic_ipi_ddb(void *);
 #endif
 #ifdef __HAVE_PIC_FAST_SOFTINTS
 int	pic_handle_softint(void *);



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

2014-03-03 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Mon Mar  3 08:50:48 UTC 2014

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

Log Message:
Add a mpsafe flag to the intrsource


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.7 -r1.8 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.19 src/sys/arch/arm/pic/pic.c:1.20
--- src/sys/arch/arm/pic/pic.c:1.19	Tue Jan 28 13:20:30 2014
+++ src/sys/arch/arm/pic/pic.c	Mon Mar  3 08:50:48 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.19 2014/01/28 13:20:30 martin Exp $	*/
+/*	$NetBSD: pic.c,v 1.20 2014/03/03 08:50:48 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.19 2014/01/28 13:20:30 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.20 2014/03/03 08:50:48 matt Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -255,18 +255,27 @@ pic_find_pending_irqs_by_ipl(struct pic_
 void
 pic_dispatch(struct intrsource *is, void *frame)
 {
-	int rv __unused;
+	int (*func)(void *) = is-is_func;
+	void *arg = is-is_arg;
 
-	if (__predict_false(is-is_arg == NULL)
-	 __predict_true(frame != NULL)) {
-		rv = (*is-is_func)(frame);
-	} else if (__predict_true(is-is_arg != NULL)) {
-		rv = (*is-is_func)(is-is_arg);
-	} else {
-		pic_deferral_ev.ev_count++;
-		return;
+	if (__predict_false(arg == NULL)) {
+		if (__predict_false(frame == NULL)) {
+			pic_deferral_ev.ev_count++;
+			return;
+		}
+		arg = frame;
 	}
 
+#ifdef MULTIPROCESSOR
+	if (!is-is_mpsafe) {
+		KERNEL_LOCK(1, NULL);
+		(void)(*func)(arg);
+		KERNEL_UNLOCK_ONE(NULL);
+	} else
+#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++;
@@ -607,6 +616,9 @@ pic_establish_intr(struct pic_softc *pic
 	is-is_type = type;
 	is-is_func = func;
 	is-is_arg = arg;
+#ifdef MULTIPROCESSOR
+	is-is_mpsafe = false;
+#endif
 
 	if (pic-pic_ops-pic_source_name)
 		(*pic-pic_ops-pic_source_name)(pic, irq, is-is_source,

Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.7 src/sys/arch/arm/pic/picvar.h:1.8
--- src/sys/arch/arm/pic/picvar.h:1.7	Sat Sep  1 00:00:42 2012
+++ src/sys/arch/arm/pic/picvar.h	Mon Mar  3 08:50:48 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.7 2012/09/01 00:00:42 matt Exp $	*/
+/*	$NetBSD: picvar.h,v 1.8 2014/03/03 08:50:48 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -99,6 +99,7 @@ struct intrsource {
 	uint8_t is_ipl;/* IPL_xxx */
 	uint8_t is_irq;/* local to pic */
 	uint8_t is_iplidx;
+	bool is_mpsafe;
 	char is_source[16];
 };
 



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

2014-01-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jan 28 13:20:30 UTC 2014

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

Log Message:
Mark a diagnostic-only variable


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 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.18 src/sys/arch/arm/pic/pic.c:1.19
--- src/sys/arch/arm/pic/pic.c:1.18	Sun Dec  8 14:37:01 2013
+++ src/sys/arch/arm/pic/pic.c	Tue Jan 28 13:20:30 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.18 2013/12/08 14:37:01 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.19 2014/01/28 13:20:30 martin Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.18 2013/12/08 14:37:01 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.19 2014/01/28 13:20:30 martin Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -288,7 +288,7 @@ pic_deliver_irqs(struct pic_softc *pic, 
 	uint32_t pending_irqs;
 	uint32_t blocked_irqs;
 	int irq;
-	bool progress = false;
+	bool progress __diagused = false;
 	
 	KASSERT(pic-pic_pending_ipls  ipl_mask);
 



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

2013-12-08 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Dec  8 14:37:01 UTC 2013

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

Log Message:
Mark rv as unused (for now)


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 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.17 src/sys/arch/arm/pic/pic.c:1.18
--- src/sys/arch/arm/pic/pic.c:1.17	Sat Sep  7 00:32:02 2013
+++ src/sys/arch/arm/pic/pic.c	Sun Dec  8 14:37:01 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.17 2013/09/07 00:32:02 matt Exp $	*/
+/*	$NetBSD: pic.c,v 1.18 2013/12/08 14:37:01 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.17 2013/09/07 00:32:02 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.18 2013/12/08 14:37:01 skrll Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -255,7 +255,7 @@ pic_find_pending_irqs_by_ipl(struct pic_
 void
 pic_dispatch(struct intrsource *is, void *frame)
 {
-	int rv;
+	int rv __unused;
 
 	if (__predict_false(is-is_arg == NULL)
 	 __predict_true(frame != NULL)) {



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

2013-10-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct  3 12:53:29 UTC 2013

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

Log Message:
Update to reflect the move of armadaxpreg.h


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/pic/armadaxp_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/armadaxp_splfuncs.c
diff -u src/sys/arch/arm/pic/armadaxp_splfuncs.c:1.2 src/sys/arch/arm/pic/armadaxp_splfuncs.c:1.3
--- src/sys/arch/arm/pic/armadaxp_splfuncs.c:1.2	Wed May 29 23:50:35 2013
+++ src/sys/arch/arm/pic/armadaxp_splfuncs.c	Thu Oct  3 12:53:29 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: armadaxp_splfuncs.c,v 1.2 2013/05/29 23:50:35 rkujawa Exp $	*/
+/*	$NetBSD: armadaxp_splfuncs.c,v 1.3 2013/10/03 12:53:29 skrll Exp $	*/
 /***
 Copyright (C) Marvell International Ltd. and its affiliates
 
@@ -37,7 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
 ***/
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: armadaxp_splfuncs.c,v 1.2 2013/05/29 23:50:35 rkujawa Exp $);
+__KERNEL_RCSID(0, $NetBSD: armadaxp_splfuncs.c,v 1.3 2013/10/03 12:53:29 skrll Exp $);
 
 #define _INTR_PRIVATE
 
@@ -56,7 +56,7 @@ __KERNEL_RCSID(0, $NetBSD: armadaxp_spl
 
 #include arm/marvell/mvsocreg.h
 #include arm/marvell/mvsocvar.h
-#include evbarm/armadaxp/armadaxpreg.h
+#include arm/marvell/armadaxpreg.h
 
 #include evbarm/marvell/marvellreg.h
 #include dev/marvell/marvellreg.h



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

2013-09-06 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sat Sep  7 00:32:02 UTC 2013

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

Log Message:
Use KASSERTMSG


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 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.16 src/sys/arch/arm/pic/pic.c:1.17
--- src/sys/arch/arm/pic/pic.c:1.16	Mon Aug 19 07:06:06 2013
+++ src/sys/arch/arm/pic/pic.c	Sat Sep  7 00:32:02 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.16 2013/08/19 07:06:06 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.17 2013/09/07 00:32:02 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.16 2013/08/19 07:06:06 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.17 2013/09/07 00:32:02 matt Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -527,7 +527,8 @@ pic_add(struct pic_softc *pic, int irqba
 	printf(%s: pic_sourcebase=%zu pic_maxsources=%zu\n,
 	pic-pic_name, pic_sourcebase, pic-pic_maxsources);
 #endif
-	KASSERT(pic-pic_maxsources = PIC_MAXSOURCES);
+	KASSERTMSG(pic-pic_maxsources = PIC_MAXSOURCES, %zu,
+	pic-pic_maxsources);
 	KASSERT(pic_sourcebase + pic-pic_maxsources = PIC_MAXMAXSOURCES);
 
 	/*



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

2013-08-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Aug 19 07:06:06 UTC 2013

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

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 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.15 src/sys/arch/arm/pic/pic.c:1.16
--- src/sys/arch/arm/pic/pic.c:1.15	Tue Oct 30 07:42:35 2012
+++ src/sys/arch/arm/pic/pic.c	Mon Aug 19 07:06:06 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.15 2012/10/30 07:42:35 msaitoh Exp $	*/
+/*	$NetBSD: pic.c,v 1.16 2013/08/19 07:06:06 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.15 2012/10/30 07:42:35 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.16 2013/08/19 07:06:06 skrll Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -257,7 +257,6 @@ pic_dispatch(struct intrsource *is, void
 {
 	int rv;
 
-
 	if (__predict_false(is-is_arg == NULL)
 	 __predict_true(frame != NULL)) {
 		rv = (*is-is_func)(frame);



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

2012-10-30 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Oct 30 07:42:38 UTC 2012

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

Log Message:
Fix a bug that incorrect arg is passed to pic_block_irqs() on disestablish.
Fixes PR#45371 by Yuichiro Goto.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 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.14 src/sys/arch/arm/pic/pic.c:1.15
--- src/sys/arch/arm/pic/pic.c:1.14	Sat Sep  1 01:44:16 2012
+++ src/sys/arch/arm/pic/pic.c	Tue Oct 30 07:42:35 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.14 2012/09/01 01:44:16 matt Exp $	*/
+/*	$NetBSD: pic.c,v 1.15 2012/10/30 07:42:35 msaitoh Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.14 2012/09/01 01:44:16 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.15 2012/10/30 07:42:35 msaitoh Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -684,7 +684,7 @@ pic_disestablish_source(struct intrsourc
 
 	KASSERT(is == pic-pic_sources[irq]);
 
-	(*pic-pic_ops-pic_block_irqs)(pic, irq  ~31, __BIT(irq));
+	(*pic-pic_ops-pic_block_irqs)(pic, irq  ~0x1f, __BIT(irq  0x1f));
 	pic-pic_sources[irq] = NULL;
 	pic__iplsources[pic_ipl_offset[is-is_ipl] + is-is_iplidx] = NULL;
 	/*



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

2012-08-31 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sat Sep  1 00:00:42 UTC 2012

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

Log Message:
Add PIC hooks for MP and for the ARM Generic Interrupt Controller.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/pic/files.pic \
src/sys/arch/arm/pic/pic_splfuncs.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.6 -r1.7 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/files.pic
diff -u src/sys/arch/arm/pic/files.pic:1.3 src/sys/arch/arm/pic/files.pic:1.4
--- src/sys/arch/arm/pic/files.pic:1.3	Fri Mar 11 03:16:14 2011
+++ src/sys/arch/arm/pic/files.pic	Sat Sep  1 00:00:42 2012
@@ -1,9 +1,11 @@
-#	$NetBSD: files.pic,v 1.3 2011/03/11 03:16:14 bsh Exp $
+#	$NetBSD: files.pic,v 1.4 2012/09/01 00:00:42 matt Exp $
 #
 # Configuration info for the common PIC code.
 #
 define	pic
 define	pic_splfuncs
+defflag opt_arm_intr_impl.h		__HAVE_PIC_SET_PRIORITY
+defflag opt_arm_intr_impl.h		__HAVE_PIC_SOFTINT
 
 file	arch/arm/pic/pic.c		pic
 file	arch/arm/pic/pic_splfuncs.c	pic  pic_splfuncs
Index: src/sys/arch/arm/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.3 src/sys/arch/arm/pic/pic_splfuncs.c:1.4
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.3	Sat Jul 14 07:52:53 2012
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Sat Sep  1 00:00:42 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.3 2012/07/14 07:52:53 matt Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.4 2012/09/01 00:00:42 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,15 +28,15 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic_splfuncs.c,v 1.3 2012/07/14 07:52:53 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic_splfuncs.c,v 1.4 2012/09/01 00:00:42 matt Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
-#include sys/evcnt.h
-#include sys/atomic.h
-#include sys/malloc.h
-#include sys/mallocvar.h
 #include sys/atomic.h
+#include sys/evcnt.h
+#include sys/kernel.h
+
+#include dev/cons.h
 
 #include arm/armreg.h
 #include arm/cpu.h
@@ -63,11 +63,13 @@ _spllower(int newipl)
 	const int oldipl = ci-ci_cpl;
 	KASSERT(panicstr || newipl = ci-ci_cpl);
 	if (newipl  ci-ci_cpl) {
-		register_t psw = disable_interrupts(I32_bit);
+		register_t psw = cpsid(I32_bit);
 		ci-ci_intr_depth++;
 		pic_do_pending_ints(psw, newipl, NULL);
 		ci-ci_intr_depth--;
-		restore_interrupts(psw);
+		if ((psw  I32_bit) == 0)
+			cpsie(I32_bit);
+		cpu_dosoftints();
 	}
 	return oldipl;
 }
@@ -77,12 +79,26 @@ splx(int savedipl)
 {
 	struct cpu_info * const ci = curcpu();
 	KASSERT(savedipl  NIPL);
-	if (savedipl  ci-ci_cpl) {
-		register_t psw = disable_interrupts(I32_bit);
-		ci-ci_intr_depth++;
-		pic_do_pending_ints(psw, savedipl, NULL);
-		ci-ci_intr_depth--;
-		restore_interrupts(psw);
+
+	if (__predict_false(savedipl == ci-ci_cpl)) {
+		return;
 	}
-	ci-ci_cpl = savedipl;
+
+	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);
+
+	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);
+	cpu_dosoftints();
+	KASSERTMSG(ci-ci_cpl == savedipl, cpl %d savedipl %d,
+	ci-ci_cpl, savedipl);
+	if ((psw  I32_bit) == 0)
+		cpsie(I32_bit);
+
+	KASSERTMSG(ci-ci_cpl == savedipl, cpl %d savedipl %d,
+	ci-ci_cpl, savedipl);
 }

Index: src/sys/arch/arm/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.12 src/sys/arch/arm/pic/pic.c:1.13
--- src/sys/arch/arm/pic/pic.c:1.12	Fri Jul 20 21:53:57 2012
+++ src/sys/arch/arm/pic/pic.c	Sat Sep  1 00:00:42 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.12 2012/07/20 21:53:57 matt Exp $	*/
+/*	$NetBSD: pic.c,v 1.13 2012/09/01 00:00:42 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,15 +28,17 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.12 2012/07/20 21:53:57 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.13 2012/09/01 00:00:42 matt Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
-#include sys/evcnt.h
-#include sys/atomic.h
-#include sys/kmem.h
 #include sys/atomic.h
 #include sys/cpu.h
+#include sys/evcnt.h
+#include sys/intr.h
+#include sys/kernel.h
+#include sys/kmem.h
+#include sys/xcall.h
 
 #include arm/armreg.h
 #include arm/cpufunc.h
@@ -74,10 +76,80 @@ EVCNT_ATTACH_STATIC(pic_deferral_ev);
 void
 pic_set_priority(struct cpu_info *ci, int newipl)
 {
-	register_t psw = disable_interrupts(I32_bit);
+	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;
-	

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

2012-08-31 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sat Sep  1 01:44:17 UTC 2012

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

Log Message:
Add #ifdef DIAGNOSTIC / #endif


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 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.13 src/sys/arch/arm/pic/pic.c:1.14
--- src/sys/arch/arm/pic/pic.c:1.13	Sat Sep  1 00:00:42 2012
+++ src/sys/arch/arm/pic/pic.c	Sat Sep  1 01:44:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.13 2012/09/01 00:00:42 matt Exp $	*/
+/*	$NetBSD: pic.c,v 1.14 2012/09/01 01:44:16 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.13 2012/09/01 00:00:42 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.14 2012/09/01 01:44:16 matt Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -476,7 +476,9 @@ 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

2012-07-20 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Fri Jul 20 21:53:57 UTC 2012

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

Log Message:
Fix botched change to use right value for ipl.  Thanks jak


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 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.11 src/sys/arch/arm/pic/pic.c:1.12
--- src/sys/arch/arm/pic/pic.c:1.11	Sat Jul 14 07:52:53 2012
+++ src/sys/arch/arm/pic/pic.c	Fri Jul 20 21:53:57 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.11 2012/07/14 07:52:53 matt Exp $	*/
+/*	$NetBSD: pic.c,v 1.12 2012/07/20 21:53:57 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.11 2012/07/14 07:52:53 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.12 2012/07/20 21:53:57 matt Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -377,7 +377,7 @@ pic_do_pending_ints(register_t psw, int 
 			if (ipl = newipl)
 break;
 
-			pic_set_priority(ci, newipl);
+			pic_set_priority(ci, ipl);
 			pic_list_deliver_irqs(psw, ipl, frame);
 			pic_list_unblock_irqs();
 		}



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

2012-07-14 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sat Jul 14 07:52:53 UTC 2012

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

Log Message:
Add hooks for __HAVE_PIC_SET_PRIORITY which allows updating of a hardware
(PIC) priority based on current IPL.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/pic/pic_splfuncs.c
cvs rdiff -u -r1.5 -r1.6 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.10 src/sys/arch/arm/pic/pic.c:1.11
--- src/sys/arch/arm/pic/pic.c:1.10	Sat Jul  7 08:05:48 2012
+++ src/sys/arch/arm/pic/pic.c	Sat Jul 14 07:52:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.10 2012/07/07 08:05:48 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.11 2012/07/14 07:52:53 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,24 +28,21 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.10 2012/07/07 08:05:48 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.11 2012/07/14 07:52:53 matt Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
 #include sys/evcnt.h
 #include sys/atomic.h
-#include sys/malloc.h
-#include sys/mallocvar.h
+#include sys/kmem.h
 #include sys/atomic.h
+#include sys/cpu.h
 
 #include arm/armreg.h
-#include arm/cpu.h
 #include arm/cpufunc.h
 
 #include arm/pic/picvar.h
 
-MALLOC_DEFINE(M_INTRSOURCE, intrsource, interrupt source);
-
 static uint32_t
 	pic_find_pending_irqs_by_ipl(struct pic_softc *, size_t, uint32_t, int);
 static struct pic_softc *
@@ -73,7 +70,16 @@ static struct evcnt pic_deferral_ev = 
 EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, deferred, intr);
 EVCNT_ATTACH_STATIC(pic_deferral_ev);
 
-
+#ifdef __HAVE_PIC_SET_PRIORITY
+void
+pic_set_priority(struct cpu_info *ci, int newipl)
+{
+	register_t psw = disable_interrupts(I32_bit);
+	ci-ci_cpl = newipl;
+	(pic_list[0]-pic_set_priority)(newipl);
+	restore_interrupts(psw);
+}
+#endif
 
 int
 pic_handle_intr(void *arg)
@@ -371,13 +377,13 @@ pic_do_pending_ints(register_t psw, int 
 			if (ipl = newipl)
 break;
 
-			ci-ci_cpl = ipl;
+			pic_set_priority(ci, newipl);
 			pic_list_deliver_irqs(psw, ipl, frame);
 			pic_list_unblock_irqs();
 		}
 	}
 	if (ci-ci_cpl != newipl)
-		ci-ci_cpl = newipl;
+		pic_set_priority(ci, newipl);
 #ifdef __HAVE_FAST_SOFTINTS
 	cpu_dosoftints();
 #endif
@@ -449,7 +455,7 @@ pic_establish_intr(struct pic_softc *pic
 		return NULL;
 	}
 
-	is = malloc(sizeof(*is), M_INTRSOURCE, M_NOWAIT|M_ZERO);
+	is = kmem_zalloc(sizeof(*is), KM_SLEEP);
 	if (is == NULL)
 		return NULL;
 
@@ -527,7 +533,7 @@ pic_disestablish_source(struct intrsourc
 	pic__iplsources[pic_ipl_offset[is-is_ipl] + is-is_iplidx] = NULL;
 	evcnt_detach(is-is_ev);
 
-	free(is, M_INTRSOURCE);
+	kmem_free(is, sizeof(*is));
 }
 
 void *
@@ -535,6 +541,9 @@ intr_establish(int irq, int ipl, int typ
 {
 	int slot;
 
+	KASSERT(!cpu_intr_p());
+	KASSERT(!cpu_softintr_p());
+
 	for (slot = 0; slot  PIC_MAXPICS; slot++) {
 		struct pic_softc * const pic = pic_list[slot];
 		if (pic == NULL || pic-pic_irqbase  0)

Index: src/sys/arch/arm/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.2 src/sys/arch/arm/pic/pic_splfuncs.c:1.3
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.2	Sat May 28 20:56:37 2011
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Sat Jul 14 07:52:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.2 2011/05/28 20:56:37 jakllsch Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.3 2012/07/14 07:52:53 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic_splfuncs.c,v 1.2 2011/05/28 20:56:37 jakllsch Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic_splfuncs.c,v 1.3 2012/07/14 07:52:53 matt Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -51,8 +51,9 @@ _splraise(int newipl)
 	struct cpu_info * const ci = curcpu();
 	const int oldipl = ci-ci_cpl;
 	KASSERT(newipl  NIPL);
-	if (newipl  ci-ci_cpl)
-		ci-ci_cpl = newipl;
+	if (newipl  ci-ci_cpl) {
+		pic_set_priority(ci, newipl);
+	}
 	return oldipl;
 }
 int

Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.5 src/sys/arch/arm/pic/picvar.h:1.6
--- src/sys/arch/arm/pic/picvar.h:1.5	Mon Nov 15 09:25:58 2010
+++ src/sys/arch/arm/pic/picvar.h	Sat Jul 14 07:52:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.5 2010/11/15 09:25:58 bsh Exp $	*/
+/*	$NetBSD: picvar.h,v 1.6 2012/07/14 07:52:53 matt Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -100,8 +100,23 @@ struct pic_ops {
 
 	void (*pic_establish_irq)(struct pic_softc *, struct intrsource *);
 	void (*pic_source_name)(struct pic_softc 

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

2012-07-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jul  7 08:05:48 UTC 2012

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

Log Message:
Convert a KASSERT to a KASSERTMSG


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 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.9 src/sys/arch/arm/pic/pic.c:1.10
--- src/sys/arch/arm/pic/pic.c:1.9	Wed Jul  4 13:34:24 2012
+++ src/sys/arch/arm/pic/pic.c	Sat Jul  7 08:05:48 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.9 2012/07/04 13:34:24 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.10 2012/07/07 08:05:48 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.9 2012/07/04 13:34:24 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.10 2012/07/07 08:05:48 skrll Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -159,7 +159,8 @@ pic_find_pending_irqs_by_ipl(struct pic_
 
 		irq_mask = __BIT(irq);
 #if 1
-		KASSERT(pic-pic_sources[irq_base + irq] != NULL);
+		KASSERTMSG(pic-pic_sources[irq_base + irq] != NULL,
+		   %s: irq_base %zu irq %d\n, __func__, irq_base, irq);
 #else
 		if (pic-pic_sources[irq_base + irq] == NULL) {
 			aprint_error(stray interrupt? irq_base=%zu irq=%d\n,



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

2012-07-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jul  4 13:34:24 UTC 2012

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

Log Message:
Add a KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 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.8 src/sys/arch/arm/pic/pic.c:1.9
--- src/sys/arch/arm/pic/pic.c:1.8	Fri Mar 11 03:16:14 2011
+++ src/sys/arch/arm/pic/pic.c	Wed Jul  4 13:34:24 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.8 2011/03/11 03:16:14 bsh Exp $	*/
+/*	$NetBSD: pic.c,v 1.9 2012/07/04 13:34:24 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.8 2011/03/11 03:16:14 bsh Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.9 2012/07/04 13:34:24 skrll Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -412,6 +412,7 @@ pic_add(struct pic_softc *pic, int irqba
 	printf(%s: pic_sourcebase=%zu pic_maxsources=%zu\n,
 	pic-pic_name, pic_sourcebase, pic-pic_maxsources);
 #endif
+	KASSERT(pic-pic_maxsources = PIC_MAXSOURCES);
 	KASSERT(pic_sourcebase + pic-pic_maxsources = PIC_MAXMAXSOURCES);
 
 	pic-pic_sources = pic_sources[pic_sourcebase];



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

2011-05-28 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat May 28 20:56:37 UTC 2011

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

Log Message:
Restore ci_intr_depth increment for duration of pic_do_pending_ints() lost
when this code was moved.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 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.1 src/sys/arch/arm/pic/pic_splfuncs.c:1.2
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.1	Fri Mar 11 03:16:14 2011
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Sat May 28 20:56:37 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.1 2011/03/11 03:16:14 bsh Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.2 2011/05/28 20:56:37 jakllsch Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic_splfuncs.c,v 1.1 2011/03/11 03:16:14 bsh Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic_splfuncs.c,v 1.2 2011/05/28 20:56:37 jakllsch Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -63,7 +63,9 @@
 	KASSERT(panicstr || newipl = ci-ci_cpl);
 	if (newipl  ci-ci_cpl) {
 		register_t psw = disable_interrupts(I32_bit);
+		ci-ci_intr_depth++;
 		pic_do_pending_ints(psw, newipl, NULL);
+		ci-ci_intr_depth--;
 		restore_interrupts(psw);
 	}
 	return oldipl;
@@ -76,7 +78,9 @@
 	KASSERT(savedipl  NIPL);
 	if (savedipl  ci-ci_cpl) {
 		register_t psw = disable_interrupts(I32_bit);
+		ci-ci_intr_depth++;
 		pic_do_pending_ints(psw, savedipl, NULL);
+		ci-ci_intr_depth--;
 		restore_interrupts(psw);
 	}
 	ci-ci_cpl = savedipl;



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

2011-02-01 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Tue Feb  1 21:44:27 UTC 2011

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

Log Message:
Increment ci-ci_intr_depth for the duration of pic_do_pending_ints().
Fixes locking catastrophy commonly noticed with mvsata(4) on evbarm.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 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.6 src/sys/arch/arm/pic/pic.c:1.7
--- src/sys/arch/arm/pic/pic.c:1.6	Tue Aug 31 14:33:41 2010
+++ src/sys/arch/arm/pic/pic.c	Tue Feb  1 21:44:27 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.6 2010/08/31 14:33:41 kiyohara Exp $	*/
+/*	$NetBSD: pic.c,v 1.7 2011/02/01 21:44:27 jakllsch Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.6 2010/08/31 14:33:41 kiyohara Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.7 2011/02/01 21:44:27 jakllsch Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -539,7 +539,9 @@
 	KASSERT(panicstr || newipl = ci-ci_cpl);
 	if (newipl  ci-ci_cpl) {
 		register_t psw = disable_interrupts(I32_bit);
+		ci-ci_intr_depth++;
 		pic_do_pending_ints(psw, newipl, NULL);
+		ci-ci_intr_depth--;
 		restore_interrupts(psw);
 	}
 	return oldipl;
@@ -552,7 +554,9 @@
 	KASSERT(savedipl  NIPL);
 	if (savedipl  ci-ci_cpl) {
 		register_t psw = disable_interrupts(I32_bit);
+		ci-ci_intr_depth++;
 		pic_do_pending_ints(psw, savedipl, NULL);
+		ci-ci_intr_depth--;
 		restore_interrupts(psw);
 	}
 	ci-ci_cpl = savedipl;



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

2010-11-15 Thread Hiroyuki Bessho
Module Name:src
Committed By:   bsh
Date:   Mon Nov 15 09:25:58 UTC 2010

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

Log Message:
fix compile error about missing evcnt definition.
picvar.h is now included very early because of uebayashi's change to 
sys/param.h.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 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.4 src/sys/arch/arm/pic/picvar.h:1.5
--- src/sys/arch/arm/pic/picvar.h:1.4	Tue Dec 30 05:43:14 2008
+++ src/sys/arch/arm/pic/picvar.h	Mon Nov 15 09:25:58 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.4 2008/12/30 05:43:14 matt Exp $	*/
+/*	$NetBSD: picvar.h,v 1.5 2010/11/15 09:25:58 bsh Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -57,6 +57,8 @@
 
 #ifdef _INTR_PRIVATE
 
+#include sys/evcnt.h
+
 #ifndef PIC_MAXPICS
 #define PIC_MAXPICS	32
 #endif



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

2010-08-31 Thread KIYOHARA Takashi
Module Name:src
Committed By:   kiyohara
Date:   Tue Aug 31 14:23:27 UTC 2010

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

Log Message:
Fix lost interrupt. (1/2)
 + Change blocked_irqs that dispach if change pending_irqs in the loop.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 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.4 src/sys/arch/arm/pic/pic.c:1.5
--- src/sys/arch/arm/pic/pic.c:1.4	Tue Dec 30 05:43:14 2008
+++ src/sys/arch/arm/pic/pic.c	Tue Aug 31 14:23:27 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.4 2008/12/30 05:43:14 matt Exp $	*/
+/*	$NetBSD: pic.c,v 1.5 2010/08/31 14:23:27 kiyohara Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.4 2008/12/30 05:43:14 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.5 2010/08/31 14:23:27 kiyohara Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -229,7 +229,7 @@
 #endif
 		}
 		progress = true;
-		blocked_irqs = pending_irqs;
+		blocked_irqs = 0;
 		do {
 			irq = ffs(pending_irqs) - 1;
 			KASSERT(irq = 0);
@@ -240,9 +240,9 @@
 cpsie(I32_bit);
 pic_dispatch(is, frame);
 cpsid(I32_bit);
+blocked_irqs |= __BIT(irq);
 			} else {
 KASSERT(0);
-blocked_irqs = ~__BIT(irq);
 			}
 			pending_irqs = pic_find_pending_irqs_by_ipl(pic,
 			irq_base, *ipending, ipl);



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

2010-08-31 Thread KIYOHARA Takashi
Module Name:src
Committed By:   kiyohara
Date:   Tue Aug 31 14:33:41 UTC 2010

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

Log Message:
Fix lost interrupt. (2/2)
  + It is likely to lose sight of interrupt when the interrupt of irq_base
that is smaller than the same at the level is generated if PIC_MAXSOURCES
is 33 or more.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 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.5 src/sys/arch/arm/pic/pic.c:1.6
--- src/sys/arch/arm/pic/pic.c:1.5	Tue Aug 31 14:23:27 2010
+++ src/sys/arch/arm/pic/pic.c	Tue Aug 31 14:33:41 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.5 2010/08/31 14:23:27 kiyohara Exp $	*/
+/*	$NetBSD: pic.c,v 1.6 2010/08/31 14:33:41 kiyohara Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.5 2010/08/31 14:23:27 kiyohara Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.6 2010/08/31 14:33:41 kiyohara Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -193,6 +193,7 @@
 	size_t irq_base;
 #if PIC_MAXSOURCES  32
 	size_t irq_count;
+	int poi = 0;		/* Possibility of interrupting */
 #endif
 	uint32_t pending_irqs;
 	uint32_t blocked_irqs;
@@ -214,14 +215,20 @@
 		if (pending_irqs == 0) {
 #if PIC_MAXSOURCES  32
 			irq_count += 32;
-			if (__predict_true(irq_count = pic-pic_maxsources))
-break;
-			irq_base += 32;
-			ipending++;
-			iblocked++;
-			if (irq_base = pic-pic_maxsources) {
+			if (__predict_true(irq_count = pic-pic_maxsources)) {
+if (!poi)
+	/*Interrupt at this level was handled.*/
+	break;
+irq_base = 0;
+irq_count = 0;
+poi = 0;
 ipending = pic-pic_pending_irqs;
 iblocked = pic-pic_blocked_irqs;
+			} else {
+irq_base += 32;
+ipending++;
+iblocked++;
+KASSERT(irq_base = pic-pic_maxsources);
 			}
 			continue;
 #else
@@ -240,6 +247,13 @@
 cpsie(I32_bit);
 pic_dispatch(is, frame);
 cpsid(I32_bit);
+#if PIC_MAXSOURCES  32
+/*
+ * There is a possibility of interrupting
+ * from cpsie() to cpsid().
+ */
+poi = 1;
+#endif
 blocked_irqs |= __BIT(irq);
 			} else {
 KASSERT(0);