Module: xenomai-forge
Branch: master
Commit: 863dcec436f575bd0ed330383ae531e2c81170df
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=863dcec436f575bd0ed330383ae531e2c81170df

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Jan  2 16:59:34 2012 +0100

cobalt: rebase lostage handlers over ipipe_post_work_root()

---

 include/asm-arm/bits/shadow.h        |    1 +
 include/asm-blackfin/bits/shadow.h   |    1 +
 include/asm-generic/bits/Makefile.am |    1 +
 include/asm-generic/bits/Makefile.in |    1 +
 include/asm-generic/bits/shadow.h    |  141 ++++++++++++++++++++++++++
 include/asm-generic/ipipe/wrappers.h |   52 ++--------
 include/asm-nios2/bits/shadow.h      |    1 +
 include/asm-powerpc/bits/shadow.h    |    1 +
 include/asm-sh/bits/shadow.h         |    1 +
 include/asm-x86/bits/shadow.h        |    3 +
 include/cobalt/nucleus/shadow.h      |   12 +--
 kernel/cobalt/mq.c                   |   27 ++++-
 kernel/cobalt/nucleus/pod.c          |    2 +-
 kernel/cobalt/nucleus/shadow.c       |  185 +++++++++++++---------------------
 kernel/cobalt/nucleus/synch.c        |    4 +-
 15 files changed, 257 insertions(+), 176 deletions(-)

diff --git a/include/asm-arm/bits/shadow.h b/include/asm-arm/bits/shadow.h
index 08a0b06..22b4f3e 100644
--- a/include/asm-arm/bits/shadow.h
+++ b/include/asm-arm/bits/shadow.h
@@ -27,6 +27,7 @@
 #error "Pure kernel header included from user-space!"
 #endif
 
+#include <asm-generic/xenomai/bits/shadow.h>
 #include <asm/cacheflush.h>
 
 static inline void xnarch_init_shadow_tcb(xnarchtcb_t * tcb,
diff --git a/include/asm-blackfin/bits/shadow.h 
b/include/asm-blackfin/bits/shadow.h
index baa33eb..7445c89 100644
--- a/include/asm-blackfin/bits/shadow.h
+++ b/include/asm-blackfin/bits/shadow.h
@@ -24,6 +24,7 @@
 #error "Pure kernel header included from user-space!"
 #endif
 
+#include <asm-generic/xenomai/bits/shadow.h>
 #include <asm/cacheflush.h>
 
 static inline void xnarch_init_shadow_tcb(xnarchtcb_t * tcb,
diff --git a/include/asm-generic/bits/Makefile.am 
b/include/asm-generic/bits/Makefile.am
index 786b122..c5fcd7b 100644
--- a/include/asm-generic/bits/Makefile.am
+++ b/include/asm-generic/bits/Makefile.am
@@ -4,5 +4,6 @@ includesub_HEADERS = \
        bind.h \
        current.h \
        pod.h \
+       shadow.h \
        sigshadow.h \
        timeconv.h
diff --git a/include/asm-generic/bits/Makefile.in 
b/include/asm-generic/bits/Makefile.in
index 93cc8fb..c46f6e4 100644
--- a/include/asm-generic/bits/Makefile.in
+++ b/include/asm-generic/bits/Makefile.in
@@ -245,6 +245,7 @@ includesub_HEADERS = \
        bind.h \
        current.h \
        pod.h \
+       shadow.h \
        sigshadow.h \
        timeconv.h
 
diff --git a/include/asm-generic/bits/shadow.h 
b/include/asm-generic/bits/shadow.h
new file mode 100644
index 0000000..24e432b
--- /dev/null
+++ b/include/asm-generic/bits/shadow.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2001,2002,2003,2004,2005 Philippe Gerum <r...@xenomai.org>.
+ * Copyright (C) 2004,2005 Gilles Chanteperdrix 
<gilles.chanteperd...@xenomai.org>.
+ *
+ * Xenomai is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Xenomai is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Xenomai; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _XENO_ASM_GENERIC_BITS_SHADOW_H
+#define _XENO_ASM_GENERIC_BITS_SHADOW_H
+
+#ifndef __KERNEL__
+#error "Pure kernel header included from user-space!"
+#endif
+
+#ifdef CONFIG_XENO_LEGACY_IPIPE
+
+#define WORKBUF_SIZE 2048
+static DEFINE_PER_CPU_ALIGNED(unsigned char[WORKBUF_SIZE], work_buf);
+static DEFINE_PER_CPU(void *, work_tail);
+
+static int lostage_virq;
+
+static void do_lostage_work(unsigned int virq, void *cookie)
+{
+       struct ipipe_work_header *work;
+       unsigned long flags;
+       void *curr, *tail;
+       int cpu;
+
+       cpu = smp_processor_id();
+       curr = per_cpu(work_buf, cpu);
+
+       for (;;) {
+               flags = hard_local_irq_save();
+               tail = per_cpu(work_tail, cpu);
+               if (curr == tail) {
+                       per_cpu(work_tail, cpu) = per_cpu(work_buf, cpu);
+                       hard_local_irq_restore(flags);
+                       return;
+               }
+               work = curr;
+               curr += work->size;
+               hard_local_irq_restore(flags);
+               work->handler(work);
+       }
+}
+
+void ipipe_post_work_root(struct ipipe_work_header *work)
+{
+       unsigned long flags;
+       void *tail;
+       int cpu;
+
+       flags = ipipe_test_and_stall_head();
+       tail = per_cpu(work_tail, cpu);
+       cpu = ipipe_processor_id();
+
+       if (WARN_ON_ONCE((unsigned char *)tail + work->size >=
+                        per_cpu(work_buf, cpu) + WORKBUF_SIZE))
+               goto out;
+
+       memcpy(tail, work, work->size);
+       per_cpu(work_tail, cpu) = tail + work->size;
+       ipipe_post_irq_root(lostage_virq);
+out:
+       ipipe_restore_head(flags);
+}
+
+static inline void __xnshadow_init(void)
+{
+       int key, cpu;
+
+       key = ipipe_alloc_ptdkey();
+       /* In emulation mode, we want PTD key #0, no matter what. */
+       BUG_ON(key != 0);
+
+       lostage_virq = ipipe_alloc_virq();
+       BUG_ON(lostage_virq == 0);
+
+       for_each_online_cpu(cpu)
+               per_cpu(work_tail, cpu) = per_cpu(work_buf, cpu);
+
+       ipipe_request_irq(ipipe_root_domain, lostage_virq,
+                         do_lostage_work, NULL, NULL);
+}
+
+static inline void __xnshadow_exit(void)
+{
+       ipipe_free_virq(lostage_virq);
+       ipipe_free_ptdkey(0);
+}
+
+static inline void set_ptd(struct ipipe_threadinfo *p)
+{
+       current->ptd[0] = p;
+}
+
+static inline void clear_ptd(void)
+{
+       current->ptd[0] = NULL;
+}
+
+static inline void hijack_current(void)
+{ 
+       int cpu = task_cpu(current);
+
+       rthal_archdata.task_hijacked[cpu] = current;
+       schedule();
+}
+
+#else /* !CONFIG_XENO_LEGACY_IPIPE */
+
+static inline void __xnshadow_init(void) { }
+
+static inline void __xnshadow_exit(void) { }
+
+#define set_ptd(p)  do { } while (0)
+
+static inline void clear_ptd(void) { }
+
+static inline void hijack_current(void)
+{ 
+       schedule();
+}
+
+#endif /* !CONFIG_XENO_LEGACY_IPIPE */
+
+#endif /* !_XENO_ASM_GENERIC_BITS_SHADOW_H */
diff --git a/include/asm-generic/ipipe/wrappers.h 
b/include/asm-generic/ipipe/wrappers.h
index 3266d75..f29b8bc 100644
--- a/include/asm-generic/ipipe/wrappers.h
+++ b/include/asm-generic/ipipe/wrappers.h
@@ -36,6 +36,11 @@ struct ipipe_trap_data {
        struct pt_regs *regs;
 };
 
+struct ipipe_work_header {
+       size_t size;
+       void (*handler)(struct ipipe_work_header *work);
+};
+
 #ifndef CONFIG_XENO_OPT_HOSTRT
 #define IPIPE_EVENT_HOSTRT  -1 /* Never received */
 #endif
@@ -206,27 +211,7 @@ static inline void ipipe_set_hooks(struct ipipe_domain 
*ipd,
        }
 }
 
-static inline void alloc_ptd_key(void)
-{
-       int key = ipipe_alloc_ptdkey();
-       /* In emulation mode, we want PTD key #0, no matter what. */
-       BUG_ON(key != 0);
-}
-
-static inline void free_ptd_key(void)
-{
-       ipipe_free_ptdkey(0);
-}
-
-static inline void set_ptd(struct ipipe_threadinfo *p)
-{
-       current->ptd[0] = p;
-}
-
-static inline void clear_ptd(void)
-{
-       current->ptd[0] = NULL;
-}
+void ipipe_post_work_root(struct ipipe_work_header *work);
 
 static inline
 struct ipipe_threadinfo *ipipe_task_threadinfo(struct task_struct *p)
@@ -244,14 +229,6 @@ struct ipipe_threadinfo *ipipe_current_threadinfo(void)
        return ipipe_task_threadinfo(current);
 }
 
-static inline void hijack_current(void)
-{ 
-       int cpu = task_cpu(current);
-
-       rthal_archdata.task_hijacked[cpu] = current;
-       schedule();
-}
-
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) && 
defined(CONFIG_GENERIC_HARDIRQS)
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
@@ -361,21 +338,6 @@ static inline void hard_cond_local_irq_restore(unsigned 
long flags)
        local_irq_restore_hw_cond(flags);
 }
 
-#else /* !CONFIG_XENO_LEGACY_IPIPE */
-
-static inline void alloc_ptd_key(void) { }
-
-static inline void free_ptd_key(void) { }
-
-#define set_ptd(p)  do { } while (0)
-
-static inline void clear_ptd(void) { }
-
-static inline void hijack_current(void)
-{ 
-       schedule();
-}
-
-#endif /* !CONFIG_XENO_LEGACY_IPIPE */
+#endif /* CONFIG_XENO_LEGACY_IPIPE */
 
 #endif /* _XENO_ASM_GENERIC_IPIPE_WRAPPERS_H */
diff --git a/include/asm-nios2/bits/shadow.h b/include/asm-nios2/bits/shadow.h
index d3d84cd..f96b62d 100644
--- a/include/asm-nios2/bits/shadow.h
+++ b/include/asm-nios2/bits/shadow.h
@@ -24,6 +24,7 @@
 #error "Pure kernel header included from user-space!"
 #endif
 
+#include <asm-generic/xenomai/bits/shadow.h>
 #include <asm/cacheflush.h>
 
 static inline void xnarch_init_shadow_tcb(xnarchtcb_t * tcb,
diff --git a/include/asm-powerpc/bits/shadow.h 
b/include/asm-powerpc/bits/shadow.h
index 6892b5e..0715e45 100644
--- a/include/asm-powerpc/bits/shadow.h
+++ b/include/asm-powerpc/bits/shadow.h
@@ -27,6 +27,7 @@
 #error "Pure kernel header included from user-space!"
 #endif
 
+#include <asm-generic/xenomai/bits/shadow.h>
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 #include <asm/cache.h>
 #else
diff --git a/include/asm-sh/bits/shadow.h b/include/asm-sh/bits/shadow.h
index e7f3178..5cc63de 100644
--- a/include/asm-sh/bits/shadow.h
+++ b/include/asm-sh/bits/shadow.h
@@ -24,6 +24,7 @@
 #error "Pure kernel header included from user-space!"
 #endif
 
+#include <asm-generic/xenomai/bits/shadow.h>
 #include <asm/cacheflush.h>
 
 static inline void xnarch_init_shadow_tcb(xnarchtcb_t * tcb,
diff --git a/include/asm-x86/bits/shadow.h b/include/asm-x86/bits/shadow.h
index 094518d..1ef376e 100644
--- a/include/asm-x86/bits/shadow.h
+++ b/include/asm-x86/bits/shadow.h
@@ -1,3 +1,6 @@
+
+#include <asm-generic/xenomai/bits/shadow.h>
+
 #ifdef __i386__
 #include "shadow_32.h"
 #else
diff --git a/include/cobalt/nucleus/shadow.h b/include/cobalt/nucleus/shadow.h
index cd687ee..7088d5a 100644
--- a/include/cobalt/nucleus/shadow.h
+++ b/include/cobalt/nucleus/shadow.h
@@ -29,13 +29,6 @@
 #define XNSHADOW_CLIENT_ATTACH  0
 #define XNSHADOW_CLIENT_DETACH  1
 
-#define LO_START_REQ    0
-#define LO_WAKEUP_REQ   1
-#define LO_SIGGRP_REQ   2
-#define LO_SIGTHR_REQ   3
-#define LO_UNMAP_REQ    4
-#define LO_FREEMEM_REQ  5
-
 struct xnthread;
 struct xnmutex;
 struct pt_regs;
@@ -113,8 +106,7 @@ void xnshadow_reset_shield(void);
 
 void xnshadow_send_sig(struct xnthread *thread,
                       int sig,
-                      int arg,
-                      int specific);
+                      int arg);
 
 void xnshadow_call_mayday(struct xnthread *thread, int sigtype);
 
@@ -122,6 +114,4 @@ void xnshadow_kick(struct xnthread *thread);
 
 void xnshadow_demote(struct xnthread *thread);
 
-void xnshadow_post_linux(int type, void *ptr, size_t val);
-
 #endif /* !_XENO_NUCLEUS_SHADOW_H */
diff --git a/kernel/cobalt/mq.c b/kernel/cobalt/mq.c
index 9b35d97..42552b0 100644
--- a/kernel/cobalt/mq.c
+++ b/kernel/cobalt/mq.c
@@ -138,8 +138,30 @@ static inline int cobalt_mq_init(cobalt_mq_t * mq, const 
struct mq_attr *attr)
        return 0;
 }
 
+struct lostage_memfree {
+       struct ipipe_work_header work; /* Must be first. */
+       void *mem;
+       size_t memsize;
+};
+
+static void lostage_mq_memfree(struct ipipe_work_header *work)
+{
+       struct lostage_memfree *rq;
+
+       rq = container_of(work, struct lostage_memfree, work);
+       xnarch_free_pages(rq->mem, rq->memsize);
+}
+
 static inline void cobalt_mq_destroy(cobalt_mq_t *mq)
 {
+       struct lostage_memfree freework = {
+               .work = {
+                       .size = sizeof(freework),
+                       .handler = lostage_mq_memfree,
+               },
+               .mem = mq->mem,
+               .memsize = mq->memsize,
+       };
        int resched;
        spl_t s;
 
@@ -150,10 +172,7 @@ static inline void cobalt_mq_destroy(cobalt_mq_t *mq)
        xnlock_put_irqrestore(&nklock, s);
        xnselect_destroy(&mq->read_select);
        xnselect_destroy(&mq->write_select);
-       if (!xnpod_root_p())
-               xnshadow_post_linux(LO_FREEMEM_REQ, mq->mem, mq->memsize);
-       else
-               xnarch_free_pages(mq->mem, mq->memsize);
+       ipipe_post_work_root(&freework.work);
 
        if (resched)
                xnpod_schedule();
diff --git a/kernel/cobalt/nucleus/pod.c b/kernel/cobalt/nucleus/pod.c
index 6a9c7fc..2ee0bf8 100644
--- a/kernel/cobalt/nucleus/pod.c
+++ b/kernel/cobalt/nucleus/pod.c
@@ -1006,7 +1006,7 @@ void xnpod_delete_thread(xnthread_t *thread)
            !xnthread_test_info(thread, XNABORT) &&
            !xnpod_current_p(thread)) {
                if (!xnpod_userspace_p())
-                       xnshadow_send_sig(thread, SIGKILL, 0, 1);
+                       xnshadow_send_sig(thread, SIGKILL, 0);
                /*
                 * Otherwise, assume the interface library has issued
                 * pthread_cancel on the target thread, which should
diff --git a/kernel/cobalt/nucleus/shadow.c b/kernel/cobalt/nucleus/shadow.c
index 74e2239..136c328 100644
--- a/kernel/cobalt/nucleus/shadow.c
+++ b/kernel/cobalt/nucleus/shadow.c
@@ -2,7 +2,7 @@
  * \brief Real-time shadow services.
  * \author Philippe Gerum
  *
- * Copyright (C) 2001-2008 Philippe Gerum <r...@xenomai.org>.
+ * Copyright (C) 2001-2012 Philippe Gerum <r...@xenomai.org>.
  * Copyright (C) 2004 The RTAI project <http://www.rtai.org>
  * Copyright (C) 2004 The HYADES project <http://www.hyades-itea.org>
  * Copyright (C) 2005 The Xenomai project <http://www.xenomai.org>
@@ -72,26 +72,6 @@ struct xnskin_slot {
        struct xnskin_props *props;
 } skins[XENOMAI_SKINS_NR];
 
-static int lostage_apc;
-
-static struct __lostagerq {
-       int in, out;
-       struct {
-               int type;
-               void *ptr;
-               size_t val;
-#define LO_MAX_REQUESTS 64     /* Must be a ^2 */
-       } req[LO_MAX_REQUESTS];
-} lostagerq[XNARCH_NR_CPUS];
-
-#define xnshadow_sig_mux(sig, arg) ((sig) | ((arg) << 8))
-#define xnshadow_sig_demux(muxed, sig, arg) \
-       do {                                 \
-               int _muxed = (muxed);        \
-               (sig) = _muxed & 0xff;       \
-               (arg) = _muxed >> 8;         \
-       } while (0)
-
 static int nucleus_muxid = -1;
 
 static struct semaphore completion_mutex;
@@ -298,91 +278,67 @@ static inline void unlock_timers(void)
                clrbits(nkclock.status, XNTBLCK);
 }
 
-static void lostage_handler(void *cookie)
+struct lostage_wakeup {
+       struct ipipe_work_header work; /* Must be first. */
+       struct task_struct *task;
+};
+
+static void lostage_task_wakeup(struct ipipe_work_header *work)
 {
-       int cpu, reqnum, type, sig, sigarg;
-       struct __lostagerq *rq;
+       struct lostage_wakeup *rq;
        struct task_struct *p;
-       size_t val;
-
-       cpu = smp_processor_id();
-       rq = &lostagerq[cpu];
 
-       while ((reqnum = rq->out) != rq->in) {
-               type = rq->req[reqnum].type;
-               val = rq->req[reqnum].val;
+       rq = container_of(work, struct lostage_wakeup, work);
+       p = rq->task;
 
-               /* make sure we read the request before releasing its slot */
-               barrier();
+       trace_mark(xn_nucleus, lostage_wakeup, "comm %s pid %d",
+                  p->comm, p->pid);
 
-               rq->out = (reqnum + 1) & (LO_MAX_REQUESTS - 1);
-
-               trace_mark(xn_nucleus, lostage_work,
-                          "type %d comm %s pid %d",
-                          type, p->comm, p->pid);
-
-               switch (type) {
-               case LO_UNMAP_REQ:
-                       /* fall through */
-               case LO_WAKEUP_REQ:
-                       xnpod_schedule();
-                       /* fall through */
-               case LO_START_REQ:
-                       p = rq->req[reqnum].ptr;
-                       wake_up_process(p);
-                       break;
-               case LO_SIGTHR_REQ:
-                       p = rq->req[reqnum].ptr;
-                       xnshadow_sig_demux(val, sig, sigarg);
-                       if (sig == SIGSHADOW || sig == SIGDEBUG) {
-                               siginfo_t si;
-                               memset(&si, '\0', sizeof(si));
-                               si.si_signo = sig;
-                               si.si_code = SI_QUEUE;
-                               si.si_int = sigarg;
-                               send_sig_info(sig, &si, p);
-                       } else
-                               send_sig(sig, p, 1);
-                       break;
-               case LO_SIGGRP_REQ:
-                       p = rq->req[reqnum].ptr;
-                       kill_proc_info(val, SEND_SIG_PRIV, p->pid);
-                       break;
-               case LO_FREEMEM_REQ:
-                       xnarch_free_pages(rq->req[reqnum].ptr, val);
-                       break;
-               }
-       }
+       xnpod_schedule();       /* XXX: why this? */
+       wake_up_process(p);
 }
 
-void xnshadow_post_linux(int type, void *ptr, size_t val)
+static void post_wakeup(struct task_struct *p)
 {
-       struct __lostagerq *rq;
-       int cpu, reqnum;
-       spl_t s;
+       struct lostage_wakeup wakework = {
+               .work = {
+                       .size = sizeof(wakework),
+                       .handler = lostage_task_wakeup,
+               },
+               .task = p,
+       };
 
-       XENO_ASSERT(NUCLEUS, ptr,
-               xnpod_fatal("%s() invoked "
-                           "with NULL arg pointer (req=%d, arg=%Zu)?!",
-                           __FUNCTION__, type, val);
-               );
+       ipipe_post_work_root(&wakework.work);
+}
 
-       splhigh(s);
+struct lostage_signal {
+       struct ipipe_work_header work; /* Must be first. */
+       struct task_struct *task;
+       int signo, sigval;
+};
 
-       cpu = ipipe_processor_id();
-       rq = &lostagerq[cpu];
-       reqnum = rq->in;
-       rq->in = (reqnum + 1) & (LO_MAX_REQUESTS - 1);
-       if (XENO_DEBUG(NUCLEUS) && rq->in == rq->out)
-           xnpod_fatal("lostage queue overflow on CPU %d! "
-                       "Increase LO_MAX_REQUESTS", cpu);
-       rq->req[reqnum].type = type;
-       rq->req[reqnum].ptr = ptr;
-       rq->req[reqnum].val = val;
+static void lostage_task_signal(struct ipipe_work_header *work)
+{
+       struct lostage_signal *rq;
+       struct task_struct *p;
+       siginfo_t si;
+       int signo;
 
-       __rthal_apc_schedule(lostage_apc);
+       rq = container_of(work, struct lostage_signal, work);
+       p = rq->task;
+       signo = rq->signo;
 
-       splexit(s);
+       trace_mark(xn_nucleus, lostage_signal, "comm %s pid %d sig %d",
+                  p->comm, p->pid, signo);
+
+       if (signo == SIGSHADOW || signo == SIGDEBUG) {
+               memset(&si, '\0', sizeof(si));
+               si.si_signo = signo;
+               si.si_code = SI_QUEUE;
+               si.si_int = rq->sigval;
+               send_sig_info(signo, &si, p);
+       } else
+               send_sig(signo, p, 1);
 }
 
 static inline int normalize_priority(int prio)
@@ -660,7 +616,7 @@ void xnshadow_relax(int notify, int reason)
         * xnpod_suspend_thread() has an interrupts-on section built in.
         */
        splmax();
-       xnshadow_post_linux(LO_WAKEUP_REQ, p, 0);
+       post_wakeup(p);
 
        /*
         * Task nklock to synchronize the Linux task state manipulation with
@@ -696,8 +652,7 @@ void xnshadow_relax(int notify, int reason)
                prio = normalize_priority(xnthread_current_priority(thread));
                xnthread_clear_info(thread, XNPRIOSET);
                xnshadow_send_sig(thread, SIGSHADOW,
-                                 sigshadow_int(SIGSHADOW_ACTION_RENICE, prio),
-                                 1);
+                                 sigshadow_int(SIGSHADOW_ACTION_RENICE, prio));
        }
 
 #ifdef CONFIG_SMP
@@ -827,8 +782,7 @@ void xnshadow_demote(struct xnthread *thread) /* nklock 
locked, irqs off */
         * real-time scheduling.
         */
        xnshadow_send_sig(thread, SIGSHADOW,
-                         sigshadow_int(SIGSHADOW_ACTION_RENICE, 0),
-                         1);
+                         sigshadow_int(SIGSHADOW_ACTION_RENICE, 0));
 }
 EXPORT_SYMBOL_GPL(xnshadow_demote);
 
@@ -1064,7 +1018,7 @@ void xnshadow_unmap(xnthread_t *thread)
 
        destroy_threadinfo();
 
-       xnshadow_post_linux(LO_UNMAP_REQ, p, xnthread_get_magic(thread));
+       post_wakeup(p);
 }
 EXPORT_SYMBOL_GPL(xnshadow_unmap);
 
@@ -1078,7 +1032,7 @@ void xnshadow_start(struct xnthread *thread)
 
        if (p->state == TASK_INTERRUPTIBLE)
                /* Wakeup the Linux mate waiting on the barrier. */
-               xnshadow_post_linux(LO_START_REQ, p, 0);
+               post_wakeup(p);
 }
 EXPORT_SYMBOL_GPL(xnshadow_start);
 
@@ -1093,13 +1047,13 @@ void xnshadow_renice(struct xnthread *thread)
        int prio = normalize_priority(thread->cprio);
 
        xnshadow_send_sig(thread, SIGSHADOW,
-                         sigshadow_int(SIGSHADOW_ACTION_RENICE, prio), 1);
+                         sigshadow_int(SIGSHADOW_ACTION_RENICE, prio));
 }
 
 void xnshadow_suspend(struct xnthread *thread)
 {
        /* Called with nklock locked, Xenomai interrupts off. */
-       xnshadow_send_sig(thread, SIGSHADOW, SIGSHADOW_ACTION_HARDEN, 1);
+       xnshadow_send_sig(thread, SIGSHADOW, SIGSHADOW_ACTION_HARDEN);
 }
 EXPORT_SYMBOL_GPL(xnshadow_suspend);
 
@@ -1206,7 +1160,7 @@ void xnshadow_call_mayday(struct xnthread *thread, int 
sigtype)
 {
        struct task_struct *p = xnthread_archtcb(thread)->user_task;
        xnthread_set_info(thread, XNKICKED);
-       xnshadow_send_sig(thread, SIGDEBUG, sigtype, 1);
+       xnshadow_send_sig(thread, SIGDEBUG, sigtype);
        xnarch_call_mayday(p);
 }
 EXPORT_SYMBOL_GPL(xnshadow_call_mayday);
@@ -1849,11 +1803,19 @@ substitute_linux_syscall(struct pt_regs *regs)
        return 0;
 }
 
-void xnshadow_send_sig(xnthread_t *thread, int sig, int arg, int specific)
+void xnshadow_send_sig(xnthread_t *thread, int sig, int arg)
 {
-       xnshadow_post_linux(specific ? LO_SIGTHR_REQ : LO_SIGGRP_REQ,
-                           xnthread_user_task(thread),
-                           xnshadow_sig_mux(sig, specific ? arg : 0));
+       struct lostage_signal sigwork = {
+               .work = {
+                       .size = sizeof(sigwork),
+                       .handler = lostage_task_signal,
+               },
+               .task = xnthread_user_task(thread),
+               .signo = sig,
+               .sigval = arg,
+       };
+
+       ipipe_post_work_root(&sigwork.work);
 }
 EXPORT_SYMBOL_GPL(xnshadow_send_sig);
 
@@ -2618,16 +2580,14 @@ int xnshadow_mount(void)
        unsigned i, size;
        int cpu, ret;
 
+       __xnshadow_init();
+
        sema_init(&completion_mutex, 1);
-       alloc_ptd_key();
 
        ret = xndebug_init();
        if (ret)
                return ret;
 
-       lostage_apc =
-           rthal_apc_alloc("lostage_handler", &lostage_handler, NULL);
-
        for_each_online_cpu(cpu) {
                if (!xnarch_cpu_supported(cpu))
                        continue;
@@ -2695,8 +2655,7 @@ void xnshadow_cleanup(void)
                kthread_stop(sched->gatekeeper);
        }
 
-       rthal_apc_free(lostage_apc);
-       free_ptd_key();
+       __xnshadow_exit();
 
        mayday_cleanup_page();
 
diff --git a/kernel/cobalt/nucleus/synch.c b/kernel/cobalt/nucleus/synch.c
index e8039b7..f6a9d06 100644
--- a/kernel/cobalt/nucleus/synch.c
+++ b/kernel/cobalt/nucleus/synch.c
@@ -713,7 +713,7 @@ void __xnsynch_fixup_rescnt(struct xnthread *thread)
 {
        if (xnthread_get_rescnt(thread) == 0)
                xnshadow_send_sig(thread, SIGDEBUG,
-                                 SIGDEBUG_MIGRATE_PRIOINV, 1);
+                                 SIGDEBUG_MIGRATE_PRIOINV);
        else
                xnthread_dec_rescnt(thread);
 }
@@ -1018,7 +1018,7 @@ void xnsynch_detect_claimed_relax(struct xnthread *owner)
                        if (xnthread_test_state(sleeper, XNTRAPSW)) {
                                xnthread_set_info(sleeper, XNSWREP);
                                xnshadow_send_sig(sleeper, SIGDEBUG,
-                                                 SIGDEBUG_MIGRATE_PRIOINV, 1);
+                                                 SIGDEBUG_MIGRATE_PRIOINV);
                        }
                }
        }


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to