Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/pic Add a mpsafe flag to the intrsource



details:   https://anonhg.NetBSD.org/src/rev/f947497fb03d
branches:  trunk
changeset: 793998:f947497fb03d
user:      matt <matt%NetBSD.org@localhost>
date:      Mon Mar 03 08:50:48 2014 +0000

description:
Add a mpsafe flag to the intrsource

diffstat:

 sys/arch/arm/pic/pic.c    |  34 +++++++++++++++++++++++-----------
 sys/arch/arm/pic/picvar.h |   3 ++-
 2 files changed, 25 insertions(+), 12 deletions(-)

diffs (82 lines):

diff -r aa172c5365a7 -r f947497fb03d sys/arch/arm/pic/pic.c
--- a/sys/arch/arm/pic/pic.c    Mon Mar 03 08:45:18 2014 +0000
+++ b/sys/arch/arm/pic/pic.c    Mon Mar 03 08:50:48 2014 +0000
@@ -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 @@
 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 @@
        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,
diff -r aa172c5365a7 -r f947497fb03d sys/arch/arm/pic/picvar.h
--- a/sys/arch/arm/pic/picvar.h Mon Mar 03 08:45:18 2014 +0000
+++ b/sys/arch/arm/pic/picvar.h Mon Mar 03 08:50:48 2014 +0000
@@ -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 @@
        uint8_t is_ipl;                         /* IPL_xxx */
        uint8_t is_irq;                         /* local to pic */
        uint8_t is_iplidx;
+       bool is_mpsafe;
        char is_source[16];
 };
 



Home | Main Index | Thread Index | Old Index