Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/aarch64 Give aarch64 a preemption safe cpu_intr_p().



details:   https://anonhg.NetBSD.org/src/rev/f0b37e156711
branches:  trunk
changeset: 968183:f0b37e156711
user:      ad <ad%NetBSD.org@localhost>
date:      Sun Jan 05 20:17:43 2020 +0000

description:
Give aarch64 a preemption safe cpu_intr_p().

diffstat:

 sys/arch/aarch64/aarch64/trap.c |  32 ++++++++++++++++++++++++++++++--
 sys/arch/aarch64/include/cpu.h  |  12 +-----------
 2 files changed, 31 insertions(+), 13 deletions(-)

diffs (76 lines):

diff -r 52c8c2abf729 -r f0b37e156711 sys/arch/aarch64/aarch64/trap.c
--- a/sys/arch/aarch64/aarch64/trap.c   Sun Jan 05 18:37:54 2020 +0000
+++ b/sys/arch/aarch64/aarch64/trap.c   Sun Jan 05 20:17:43 2020 +0000
@@ -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 @@
 #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;
+}
diff -r 52c8c2abf729 -r f0b37e156711 sys/arch/aarch64/include/cpu.h
--- a/sys/arch/aarch64/include/cpu.h    Sun Jan 05 18:37:54 2020 +0000
+++ b/sys/arch/aarch64/include/cpu.h    Sun Jan 05 20:17:43 2020 +0000
@@ -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 @@
 #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 */



Home | Main Index | Thread Index | Old Index