Module Name:    src
Committed By:   ad
Date:           Sun Jan  5 20:17:43 UTC 2020

Modified Files:
        src/sys/arch/aarch64/aarch64: trap.c
        src/sys/arch/aarch64/include: cpu.h

Log Message:
Give aarch64 a preemption safe cpu_intr_p().


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/aarch64/aarch64/trap.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/aarch64/include/cpu.h

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/trap.c
diff -u src/sys/arch/aarch64/aarch64/trap.c:1.22 src/sys/arch/aarch64/aarch64/trap.c:1.23
--- src/sys/arch/aarch64/aarch64/trap.c:1.22	Tue Dec  3 22:02:43 2019
+++ src/sys/arch/aarch64/aarch64/trap.c	Sun Jan  5 20:17:43 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.22 2019/12/03 22:02:43 jmcneill Exp $ */
+/* $NetBSD: trap.c,v 1.23 2020/01/05 20:17:43 ad Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.22 2019/12/03 22:02:43 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.23 2020/01/05 20:17:43 ad Exp $");
 
 #include "opt_arm_intr_impl.h"
 #include "opt_compat_netbsd32.h"
@@ -619,3 +619,31 @@ void do_trapsignal1(
 #endif
 	(*l->l_proc->p_emul->e_trapsignal)(l, &ksi);
 }
+
+bool
+cpu_intr_p(void)
+{
+	uint64_t ncsw;
+	int idepth;
+	lwp_t *l;
+
+#ifdef __HAVE_PIC_FAST_SOFTINTS
+	/* XXX Copied from cpu.h.  Looks incomplete - needs fixing. */
+	if (ci->ci_cpl < IPL_VM)
+		return false;
+#endif
+
+	l = curlwp;
+	if (__predict_false(l->l_cpu == NULL)) {
+		KASSERT(l == &lwp0);
+		return false;
+	}
+	do {
+		ncsw = l->l_ncsw;
+		__insn_barrier();
+		idepth = l->l_cpu->ci_idepth;
+		__insn_barrier();
+	} while (__predict_false(ncsw != l->l_ncsw));
+
+	return idepth > 0;
+}

Index: src/sys/arch/aarch64/include/cpu.h
diff -u src/sys/arch/aarch64/include/cpu.h:1.16 src/sys/arch/aarch64/include/cpu.h:1.17
--- src/sys/arch/aarch64/include/cpu.h:1.16	Mon Dec  2 18:35:07 2019
+++ src/sys/arch/aarch64/include/cpu.h	Sun Jan  5 20:17:43 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.16 2019/12/02 18:35:07 ad Exp $ */
+/* $NetBSD: cpu.h,v 1.17 2020/01/05 20:17:43 ad Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -157,16 +157,6 @@ cpu_dosoftints(void)
 #endif
 }
 
-static inline bool
-cpu_intr_p(void)
-{
-#ifdef __HAVE_PIC_FAST_SOFTINTS
-	if (ci->ci_cpl < IPL_VM)
-		return false;
-#endif
-	return curcpu()->ci_intr_depth > 0;
-}
-
 void	cpu_attach(device_t, cpuid_t);
 
 #endif /* _KERNEL || _KMEMUSER */

Reply via email to