[Xenomai-git] Jan Kiszka : cobalt/timer: Make xntimer_get_overruns robust against stopped timers

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: b861d69e01e9697a1e759c9e76881511a7aeab9a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b861d69e01e9697a1e759c9e76881511a7aeab9a

Author: Jan Kiszka 
Date:   Wed Feb 24 21:44:41 2016 +0100

cobalt/timer: Make xntimer_get_overruns robust against stopped timers

xntimer_get_overruns might be called on meanwhile stopped timers,
specifically by cobalt_timer_deliver. We crash if we try to dequeue a
stopped timer, and we should not restart it as well.

Signed-off-by: Jan Kiszka 

---

 kernel/cobalt/timer.c |   14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
index db6263d..3e85a53 100644
--- a/kernel/cobalt/timer.c
+++ b/kernel/cobalt/timer.c
@@ -602,13 +602,15 @@ unsigned long long xntimer_get_overruns(struct xntimer 
*timer, xnticks_t now)
overruns = xnarch_div64(delta, period);
timer->pexpect_ticks += overruns;
 
-   q = xntimer_percpu_queue(timer);
-   xntimer_dequeue(timer, q);
-   while (xntimerh_date(>aplink) < now) {
-   timer->periodic_ticks++;
-   xntimer_update_date(timer);
+   if (xntimer_running_p(timer)) {
+   q = xntimer_percpu_queue(timer);
+   xntimer_dequeue(timer, q);
+   while (xntimerh_date(>aplink) < now) {
+   timer->periodic_ticks++;
+   xntimer_update_date(timer);
+   }
+   xntimer_enqueue_and_program(timer, q);
}
-   xntimer_enqueue_and_program(timer, q);
}
 
timer->pexpect_ticks++;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : testsuite/smokey: cpu-affinity: silence unused_result warning

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 5abccffbb372c9572a0a92fada734529e9de19d9
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5abccffbb372c9572a0a92fada734529e9de19d9

Author: Philippe Gerum 
Date:   Sun Feb 28 15:41:38 2016 +0100

testsuite/smokey: cpu-affinity: silence unused_result warning

---

 testsuite/smokey/cpu-affinity/cpu-affinity.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/testsuite/smokey/cpu-affinity/cpu-affinity.c 
b/testsuite/smokey/cpu-affinity/cpu-affinity.c
index 2674f76..4a59ff6 100644
--- a/testsuite/smokey/cpu-affinity/cpu-affinity.c
+++ b/testsuite/smokey/cpu-affinity/cpu-affinity.c
@@ -88,8 +88,11 @@ static int load_test_module(void)
 
 static void unload_test_module(int fd)
 {
+   int status;
+   
close(fd);
-   system("rmmod xeno_rtdmtest");
+   status = system("rmmod xeno_rtdmtest");
+   (void)status;
 }
 
 static void *__run_cpu_affinity(void *arg)


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : testsuite/smokey: mutex: fix centralized init

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 5c85ac7439e63711cb7d3c813da31ecb6cb8e3f6
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5c85ac7439e63711cb7d3c813da31ecb6cb8e3f6

Author: Philippe Gerum 
Date:   Wed Feb 17 09:21:27 2016 +0100

testsuite/smokey: mutex: fix centralized init

---

 testsuite/smokey/posix-mutex/posix-mutex.c |   55 +++-
 1 file changed, 30 insertions(+), 25 deletions(-)

diff --git a/testsuite/smokey/posix-mutex/posix-mutex.c 
b/testsuite/smokey/posix-mutex/posix-mutex.c
index 8298351..ac71b31 100644
--- a/testsuite/smokey/posix-mutex/posix-mutex.c
+++ b/testsuite/smokey/posix-mutex/posix-mutex.c
@@ -133,14 +133,14 @@ static void __check_current_mode(const char *file, int 
line,
__check_current_mode(__FILE__, __LINE__, (mask), (expected_value))
 
 static int dispatch(const char *service_name,
- int service_type, int check, int expected, ...)
+   int service_type, int check, int expected, ...)
 {
unsigned long long timeout;
pthread_t *thread;
pthread_cond_t *cond;
void *handler;
va_list ap;
-   int status;
+   int status, protocol, type;
pthread_mutex_t *mutex;
struct sched_param param;
pthread_attr_t threadattr;
@@ -152,14 +152,11 @@ static int dispatch(const char *service_name,
case MUTEX_CREATE:
mutex = va_arg(ap, pthread_mutex_t *);
pthread_mutexattr_init();
-#ifdef HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL
-   if (va_arg(ap, int) != 0)
-   pthread_mutexattr_setprotocol(,
- PTHREAD_PRIO_INHERIT);
-#else
-   status = va_arg(ap, int);
-#endif
-   pthread_mutexattr_settype(, va_arg(ap, int));
+   protocol = va_arg(ap, int);
+   /* May fail if unsupported, that's ok. */
+   pthread_mutexattr_setprotocol(, protocol);
+   type = va_arg(ap, int);
+   pthread_mutexattr_settype(, type);
status = pthread_mutex_init(mutex, );
break;
 
@@ -310,7 +307,8 @@ static void simple_wait(void)
 
smokey_trace("%s", __func__);
 
-   dispatch("simple mutex_init", MUTEX_CREATE, 1, 0, , 0, 0);
+   dispatch("simple mutex_init", MUTEX_CREATE, 1, 0, ,
+PTHREAD_PRIO_NONE, PTHREAD_MUTEX_NORMAL);
dispatch("simple mutex_lock 1", MUTEX_LOCK, 1, 0, );
dispatch("simple thread_create", THREAD_CREATE, 1, 0, _tid, 2,
 waiter, );
@@ -371,8 +369,8 @@ static void recursive_wait(void)
 
smokey_trace("%s", __func__);
 
-   dispatch("rec mutex_init", MUTEX_CREATE, 1, 0, , 0,
-PTHREAD_MUTEX_RECURSIVE);
+   dispatch("rec mutex_init", MUTEX_CREATE, 1, 0, ,
+PTHREAD_PRIO_NONE, PTHREAD_MUTEX_RECURSIVE);
dispatch("rec mutex_lock 1", MUTEX_LOCK, 1, 0, );
dispatch("rec mutex_lock 2", MUTEX_LOCK, 1, 0, );
 
@@ -448,8 +446,8 @@ static void errorcheck_wait(void)
 
smokey_trace("%s", __func__);
 
-   dispatch("errorcheck mutex_init", MUTEX_CREATE, 1, 0, , 0,
-PTHREAD_MUTEX_ERRORCHECK);
+   dispatch("errorcheck mutex_init", MUTEX_CREATE, 1, 0, ,
+PTHREAD_PRIO_NONE, PTHREAD_MUTEX_ERRORCHECK);
dispatch("errorcheck mutex_lock 1", MUTEX_LOCK, 1, 0, );
 
err = pthread_mutex_lock();
@@ -510,7 +508,8 @@ static void timed_mutex(void)
 
smokey_trace("%s", __func__);
 
-   dispatch("timed_mutex mutex_init", MUTEX_CREATE, 1, 0, , 1, 0);
+   dispatch("timed_mutex mutex_init", MUTEX_CREATE, 1, 0, ,
+PTHREAD_PRIO_INHERIT, PTHREAD_MUTEX_NORMAL);
dispatch("timed_mutex mutex_lock 1", MUTEX_LOCK, 1, 0, );
dispatch("timed_mutex thread_create", THREAD_CREATE, 1, 0, _tid,
 2, timed_waiter, );
@@ -530,7 +529,8 @@ static void mode_switch(void)
 
smokey_trace("%s", __func__);
 
-   dispatch("switch mutex_init", MUTEX_CREATE, 1, 0, , 1, 0);
+   dispatch("switch mutex_init", MUTEX_CREATE, 1, 0, ,
+PTHREAD_PRIO_INHERIT, PTHREAD_MUTEX_NORMAL);
 
check_current_mode(XNRELAX, XNRELAX);
 
@@ -554,7 +554,8 @@ static void pi_wait(void)
 #endif
smokey_trace("%s", __func__);
 
-   dispatch("pi mutex_init", MUTEX_CREATE, 1, 0, , 1, 0);
+   dispatch("pi mutex_init", MUTEX_CREATE, 1, 0, ,
+PTHREAD_PRIO_INHERIT, PTHREAD_MUTEX_NORMAL);
dispatch("pi mutex_lock 1", MUTEX_LOCK, 1, 0, );
 
check_current_prio(2);
@@ -594,7 +595,8 @@ static void lock_stealing(void)
 
smokey_trace("%s", __func__);
 
-   dispatch("lock_stealing mutex_init", MUTEX_CREATE, 1, 0, , 1, 0);
+   dispatch("lock_stealing mutex_init", MUTEX_CREATE, 1, 0, ,
+PTHREAD_PRIO_INHERIT, PTHREAD_MUTEX_NORMAL);
dispatch("lock_stealing 

[Xenomai-git] Jan Kiszka : cobalt/posix/timer: Allow extension to override timer_gettimeout value

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: a94d4232f1b1a910355cd1df687f7b88ec6a2578
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a94d4232f1b1a910355cd1df687f7b88ec6a2578

Author: Jan Kiszka 
Date:   Mon Feb 22 18:27:27 2016 +0100

cobalt/posix/timer: Allow extension to override timer_gettimeout value

Move the call into a potential cobalt extension to the front so that
it can completely control the value returned by timer_gettimeout.

Signed-off-by: Jan Kiszka 

---

 kernel/cobalt/posix/timer.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/kernel/cobalt/posix/timer.c b/kernel/cobalt/posix/timer.c
index 8c4d2da..b4cd511 100644
--- a/kernel/cobalt/posix/timer.c
+++ b/kernel/cobalt/posix/timer.c
@@ -286,6 +286,10 @@ timer_gettimeout(struct cobalt_timer *__restrict__ timer,
 {
int ret = 0;
 
+   if (cobalt_call_extension(timer_gettime, >extref,
+ ret, value) && ret != 0)
+   return;
+
if (!xntimer_running_p(>timerbase)) {
value->it_value.tv_sec = 0;
value->it_value.tv_nsec = 0;
@@ -294,9 +298,7 @@ timer_gettimeout(struct cobalt_timer *__restrict__ timer,
return;
}
 
-   if (!cobalt_call_extension(timer_gettime, >extref,
-  ret, value) || ret == 0)
-   __cobalt_timer_getval(>timerbase, value);
+   __cobalt_timer_getval(>timerbase, value);
 }
 
 int __cobalt_timer_setval(struct xntimer *__restrict__ timer, int clock_flag,


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/threadobj: fix status returned by threadobj_sleep()

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 00a68ec28ee25cd3a6fc9e1f1f3e4af7bab4635b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=00a68ec28ee25cd3a6fc9e1f1f3e4af7bab4635b

Author: Philippe Gerum 
Date:   Tue Feb  9 11:50:20 2016 +0100

copperplate/threadobj: fix status returned by threadobj_sleep()

---

 lib/copperplate/threadobj.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index 2d37d46..e0b2c9f 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -1600,7 +1600,7 @@ int threadobj_sleep(const struct timespec *ts)
 */
if (ts->tv_sec == 0 && ts->tv_nsec == 0) {
sigemptyset();
-   ret = __RT(sigwaitinfo(, NULL)) ? -errno : 0;
+   ret = __RT(sigwaitinfo(, NULL)) ? errno : 0;
} else
ret = __RT(clock_nanosleep(CLOCK_COPPERPLATE,
   TIMER_ABSTIME, ts, NULL));


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/blackfin: upgrade I-pipe support

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 601a5aae1f069489c6b2341bfc76e945fca1bcad
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=601a5aae1f069489c6b2341bfc76e945fca1bcad

Author: Philippe Gerum 
Date:   Mon Feb 29 10:12:26 2016 +0100

cobalt/blackfin: upgrade I-pipe support

---

 .../patches/ipipe-core-4.1.18-blackfin-1.patch |12078 
 1 file changed, 12078 insertions(+)

Diff:   
http://git.xenomai.org/?p=xenomai-3.git;a=commitdiff;h=601a5aae1f069489c6b2341bfc76e945fca1bcad

___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/init: get system heap from the normal zone

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 4f9655d6d5a32985fa582ddf47fe7529bf28f567
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4f9655d6d5a32985fa582ddf47fe7529bf28f567

Author: Philippe Gerum 
Date:   Fri Mar  4 11:26:39 2016 +0100

cobalt/init: get system heap from the normal zone

---

 kernel/cobalt/init.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/cobalt/init.c b/kernel/cobalt/init.c
index 6cbb67b..5a6fdbf 100644
--- a/kernel/cobalt/init.c
+++ b/kernel/cobalt/init.c
@@ -18,7 +18,6 @@
  */
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -156,7 +155,7 @@ static void sys_shutdown(void)
xnregistry_cleanup();
membase = xnheap_get_membase(_heap);
xnheap_destroy(_heap);
-   vfree(membase);
+   xnheap_vfree(membase);
 }
 
 static int __init mach_setup(void)
@@ -289,7 +288,7 @@ static __init int sys_init(void)
if (sysheap_size_arg == 0)
sysheap_size_arg = CONFIG_XENO_OPT_SYS_HEAPSZ;
 
-   heapaddr = vmalloc(sysheap_size_arg * 1024);
+   heapaddr = xnheap_vmalloc(sysheap_size_arg * 1024);
if (heapaddr == NULL ||
xnheap_init(_heap, heapaddr, sysheap_size_arg * 1024)) {
return -ENOMEM;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/intr: remove unused label

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: de97629570203e1323b5f824bd7b45f1709e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=de97629570203e1323b5f824bd7b45f1709e

Author: Philippe Gerum 
Date:   Sun Jan 10 18:41:51 2016 +0100

cobalt/intr: remove unused label

---

 kernel/cobalt/intr.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/cobalt/intr.c b/kernel/cobalt/intr.c
index 14dc0b3..5123363 100644
--- a/kernel/cobalt/intr.c
+++ b/kernel/cobalt/intr.c
@@ -625,9 +625,7 @@ static void xnintr_irq_handler(unsigned int irq, void 
*cookie)
 
if (s & XN_IRQ_DISABLE)
set_bit(XN_IRQSTAT_DISABLED, >status);
-#ifdef CONFIG_SMP
-done:
-#endif
+
xnlock_put(>lock);
 
if (s & XN_IRQ_DISABLE)


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/wrappers: add wrapper for reinit_completion()

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 0517ffe676269b07bc0c1d1a4c3b0128c2e89235
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0517ffe676269b07bc0c1d1a4c3b0128c2e89235

Author: Philippe Gerum 
Date:   Thu Mar  3 09:16:21 2016 +0100

cobalt/wrappers: add wrapper for reinit_completion()

---

 .../cobalt/include/asm-generic/xenomai/wrappers.h  |   50 +++-
 1 file changed, 28 insertions(+), 22 deletions(-)

diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h 
b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index 8ceed3a..060ce85 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -29,33 +29,34 @@
 /*
  * To keep the #ifdefery as readable as possible, please:
  *
- * - keep the conditional structure flat, no nesting (e.g. do not nest
+ * - keep the conditional structure flat, no nesting (e.g. do not fold
  *   the pre-3.11 conditions into the pre-3.14 ones).
- * - group all wrappers which share the same condition.
+ * - group all wrappers for a single kernel revision.
+ * - list conditional blocks in order of kernel release, latest first
  * - identify the first kernel release for which the wrapper should
  *   be defined, instead of testing the existence of a preprocessor
  *   symbol, so that obsolete wrappers can be spotted.
- * - put the newer wrappers in front, so that old wrappers can be removed
- *   without side effects on newer wrappers.
  */
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
 #define user_msghdr msghdr
-#endif /* < 3.19 */
+#endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
 #include 
-#include 
 
 #undef alloc_netdev
 #define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \
alloc_netdev_mqs(sizeof_priv, name, setup, 1, 1)
+ 
+#include 
 
 static inline unsigned char *
 trace_seq_buffer_ptr(struct trace_seq *s)
 {
return s->buffer + s->len;
 }
+
 #endif /* < 3.17 */
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
@@ -71,28 +72,30 @@ trace_seq_buffer_ptr(struct trace_seq *s)
 #include 
 
 #ifdef CONFIG_PCI
-#define pci_enable_msix_range \
-   COBALT_BACKPORT(pci_enable_msix_range)
+#define pci_enable_msix_range COBALT_BACKPORT(pci_enable_msix_range)
 #ifdef CONFIG_PCI_MSI
 int pci_enable_msix_range(struct pci_dev *dev,
-   struct msix_entry *entries,
-   int minvec, int maxvec);
-#else /* not pci msi */
-static inline int pci_enable_msix_range(struct pci_dev *dev,
-   struct msix_entry *entries,
-   int minvec, int maxvec)
-{ return -ENOSYS; }
-#endif /* not pci msi */
-#endif /* pci */
+ struct msix_entry *entries,
+ int minvec, int maxvec);
+#else /* !CONFIG_PCI_MSI */
+static inline
+int pci_enable_msix_range(struct pci_dev *dev,
+ struct msix_entry *entries,
+ int minvec, int maxvec)
+{
+   return -ENOSYS;
+}
+#endif /* !CONFIG_PCI_MSI */
+#endif /* CONFIG_PCI */
 #endif /* < 3.14 */
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
 #include 
 #include 
 
-#define dma_set_mask_and_coherent \
-   COBALT_BACKPORT(dma_set_mask_and_coherent)
-static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask)
+#define dma_set_mask_and_coherent COBALT_BACKPORT(dma_set_mask_and_coherent)
+static inline
+int dma_set_mask_and_coherent(struct device *dev, u64 mask)
 {
int rc = dma_set_mask(dev, mask);
if (rc == 0)
@@ -114,8 +117,11 @@ struct device *
 devm_hwmon_device_register_with_groups(struct device *dev, const char *name,
void *drvdata,
const struct attribute_group **groups);
-#endif /* hwmon */
-#endif /* < 3,13 */
+#endif /* !CONFIG_HWMON */
+
+#define reinit_completion(__x) INIT_COMPLETION(*(__x))
+
+#endif /* < 3.13 */
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
 #define DEVICE_ATTR_RW(_name)  __ATTR_RW(_name)


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : utils/corectl: fix handling of argument to --stop ( grace period)

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: b09e20cc82f6c79cf982d13cfcb176221800a306
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b09e20cc82f6c79cf982d13cfcb176221800a306

Author: Philippe Gerum 
Date:   Wed Mar  2 15:22:53 2016 +0100

utils/corectl: fix handling of argument to --stop (grace period)

---

 utils/corectl/corectl.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/utils/corectl/corectl.c b/utils/corectl/corectl.c
index 1e82e99..41b8773 100644
--- a/utils/corectl/corectl.c
+++ b/utils/corectl/corectl.c
@@ -62,10 +62,10 @@ void application_usage(void)
fprintf(stderr, "--status   query Xenomai/cobalt 
status\n");
 }
 
-static int core_stop(int grace_period)
+static int core_stop(__u32 grace_period)
 {
return cobalt_corectl(_CC_COBALT_STOP_CORE,
- _period, sizeof(_period));
+ _period, sizeof(grace_period));
 }
 
 static int core_start(void)
@@ -106,7 +106,8 @@ static int core_status(void)
 
 int main(int argc, char *const argv[])
 {
-   int lindex, c, grace_period = 0, ret;
+   __u32 grace_period = 0;
+   int lindex, c, ret;

for (;;) {
c = getopt_long_only(argc, argv, "", options, );


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/x86: upgrade I-pipe support

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 4c7e2ff49a4e52ad4a23c0be0b5faf665024957d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4c7e2ff49a4e52ad4a23c0be0b5faf665024957d

Author: Philippe Gerum 
Date:   Mon Feb 29 10:10:50 2016 +0100

cobalt/x86: upgrade I-pipe support

---

 .../arch/x86/patches/ipipe-core-4.1.18-x86-1.patch |15641 
 1 file changed, 15641 insertions(+)

Diff:   
http://git.xenomai.org/?p=xenomai-3.git;a=commitdiff;h=4c7e2ff49a4e52ad4a23c0be0b5faf665024957d

___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/posix/corectl: clarify argument types for mixed ABI support

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 75c95c08da6384dfea241cc639357608c93b9917
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=75c95c08da6384dfea241cc639357608c93b9917

Author: Philippe Gerum 
Date:   Wed Mar  2 15:22:15 2016 +0100

cobalt/posix/corectl: clarify argument types for mixed ABI support

---

 kernel/cobalt/posix/corectl.c |   12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/kernel/cobalt/posix/corectl.c b/kernel/cobalt/posix/corectl.c
index f01a562..6ec9934 100644
--- a/kernel/cobalt/posix/corectl.c
+++ b/kernel/cobalt/posix/corectl.c
@@ -110,9 +110,10 @@ static int do_conf_option(int option, void __user *u_buf, 
size_t u_bufsz)
 
 static int stop_services(const void __user *u_buf, size_t u_bufsz)
 {
-   const int final_grace_period = 3; /* seconds */
+   const u32 final_grace_period = 3; /* seconds */
enum cobalt_run_states state;
-   int ret, timeout;
+   __u32 grace_period;
+   int ret;
 
/*
 * XXX: we don't have any syscall for unbinding a thread from
@@ -123,10 +124,11 @@ static int stop_services(const void __user *u_buf, size_t 
u_bufsz)
if (xnthread_current())
return -EPERM;
 
-   if (u_bufsz != sizeof(int))
+   if (u_bufsz != sizeof(__u32))
return -EINVAL;
 
-   ret = cobalt_copy_from_user(, u_buf, sizeof(timeout));
+   ret = cobalt_copy_from_user(_period,
+   u_buf, sizeof(grace_period));
if (ret)
return ret;
 
@@ -138,7 +140,7 @@ static int stop_services(const void __user *u_buf, size_t 
u_bufsz)
break;
case COBALT_STATE_RUNNING:
/* Kill user threads. */
-   ret = xnthread_killall(timeout, XNUSER);
+   ret = xnthread_killall(grace_period, XNUSER);
if (ret) {
set_realtime_core_state(state);
return ret;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/thread: fix SMP race with xnthread_join()

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 6bb194a5f0dc6fcfb0979d45d45fb2c6a5a62463
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6bb194a5f0dc6fcfb0979d45d45fb2c6a5a62463

Author: Philippe Gerum 
Date:   Tue Mar  1 12:50:29 2016 +0100

cobalt/thread: fix SMP race with xnthread_join()

The situation below would cause a kernel crash on any earlier 3.x
release, with ktask implemented in a dynamically loaded/unloaded
module:

CPU0:  rtdm_task_destroy(ktask)
   ...
   rmmod(module)

CPU1:  ktask()
   ...
   ...
   __xnthread_test_cancel()
   do_exit()
  (last) schedule()
 OOPS: prev still treading on stale memory

In this case, the module would be unmapped too early, before the
cancelled task can ultimately schedule away.

The changes also fix a stale reference from the joiner thread to the
former ->idtag field, after the joinee's TCB has been dropped.

---

 include/cobalt/kernel/thread.h |6 +-
 kernel/cobalt/thread.c |  136 
 2 files changed, 113 insertions(+), 29 deletions(-)

diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h
index f25c6d0..e08a0a2 100644
--- a/include/cobalt/kernel/thread.h
+++ b/include/cobalt/kernel/thread.h
@@ -19,6 +19,7 @@
 #ifndef _COBALT_KERNEL_THREAD_H
 #define _COBALT_KERNEL_THREAD_H
 
+#include 
 #include 
 #include 
 #include 
@@ -107,9 +108,6 @@ struct xnthread {
struct list_head quota_expired;
struct list_head quota_next;
 #endif
-
-   unsigned int idtag; /* Unique ID tag */
-
cpumask_t affinity; /* Processor affinity. */
 
int bprio;  /* Base priority (before PIP boost) */
@@ -184,6 +182,8 @@ struct xnthread {
 
struct xnthread_personality *personality;
 
+   struct completion exited;
+
 #ifdef CONFIG_XENO_OPT_DEBUG
const char *exe_path;   /* Executable path */
u32 proghash;   /* Hash value for exe_path */
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 462d917..07b0c8f 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -40,16 +41,14 @@
 #include 
 #include "debug.h"
 
+static DECLARE_WAIT_QUEUE_HEAD(join_all);
+
 /**
  * @ingroup cobalt_core
  * @defgroup cobalt_core_thread Thread services
  * @{
  */
 
-static DECLARE_WAIT_QUEUE_HEAD(nkjoinq);
-
-static unsigned int idtags;
-
 static void timeout_handler(struct xntimer *timer)
 {
struct xnthread *thread = container_of(timer, struct xnthread, rtimer);
@@ -158,20 +157,13 @@ int __xnthread_init(struct xnthread *thread,
const union xnsched_policy_param *sched_param)
 {
int flags = attr->flags, ret, gravity;
-   spl_t s;
 
flags &= ~XNSUSP;
 #ifndef CONFIG_XENO_ARCH_FPU
flags &= ~XNFPU;
 #endif
-   if (flags & XNROOT)
-   thread->idtag = 0;
-   else {
-   xnlock_get_irqsave(, s);
-   thread->idtag = ++idtags ?: 1;
-   xnlock_put_irqrestore(, s);
+   if ((flags & XNROOT) == 0)
flags |= XNDORMANT;
-   }
 
if (attr->name)
ksformat(thread->name,
@@ -207,6 +199,7 @@ int __xnthread_init(struct xnthread *thread,
/* These will be filled by xnthread_start() */
thread->entry = NULL;
thread->cookie = NULL;
+   init_completion(>exited);
 
gravity = flags & XNUSER ? XNTIMER_UGRAVITY : XNTIMER_KGRAVITY;
xntimer_init(>rtimer, , timeout_handler,
@@ -480,8 +473,6 @@ static inline void cleanup_tcb(struct xnthread *thread) /* 
nklock held, irqs off
xnthread_clear_state(thread, XNREADY);
}
 
-   thread->idtag = 0;
-
if (xnthread_test_state(thread, XNPEND))
xnsynch_forget_sleeper(thread);
 
@@ -521,10 +512,15 @@ void __xnthread_cleanup(struct xnthread *curr)
cleanup_tcb(curr);
xnlock_put_irqrestore(, s);
 
+   /* Wake up the joiner if any (we can't have more than one). */
+   complete(>exited);
+
+   /* Notify our exit to xnthread_killall() if need be. */
+   if (waitqueue_active(_all))
+   wake_up(_all);
+
/* Finalize last since this incurs releasing the TCB. */
xnthread_run_handler_stack(curr, finalize_thread);
-
-   wake_up();
 }
 
 /*
@@ -1583,6 +1579,40 @@ out:
 }
 EXPORT_SYMBOL_GPL(xnthread_cancel);
 
+struct wait_grace_struct {
+   struct completion done;
+   struct rcu_head rcu;
+};
+
+static void grace_elapsed(struct rcu_head *head)
+{
+   struct wait_grace_struct *wgs;
+
+   wgs = container_of(head, struct wait_grace_struct, rcu);
+   complete(>done);
+}
+
+static void wait_grace_period(struct pid *pid)
+{
+   struct wait_grace_struct wait = {
+   .done = COMPLETION_INITIALIZER_ONSTACK(wait.done),
+  

[Xenomai-git] Philippe Gerum : cobalt/init: get main heap memory from vmalloc()

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 00ecc7cb46166bf983209b6e9a5090b05dc6472c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=00ecc7cb46166bf983209b6e9a5090b05dc6472c

Author: Philippe Gerum 
Date:   Sun Feb 28 08:23:32 2016 +0100

cobalt/init: get main heap memory from vmalloc()

There is no reason to ask for physically contiguous memory from
alloc_pages[_exact]() for the main heap: real-time heaps are certainly
no place for getting DMA-suitable buffers from.

Using alloc_pages*() for common Cobalt heaps is a problem:

- this raises the probability of getting allocation failures in case
  of memory fragmentation (although seldom at boot time, some
  Cobalt-based modules also using such services could fail allocating
  their heap later on).

- this restricts the maximum heap size to MAX_ORDER (currently 4Mb),
  which may be too small in some configurations.

Therefore, switch from alloc_pages_exact() to vmalloc().

---

 include/cobalt/kernel/heap.h |4 
 kernel/cobalt/heap.c |   28 
 kernel/cobalt/init.c |7 +++
 3 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/include/cobalt/kernel/heap.h b/include/cobalt/kernel/heap.h
index 988004f..a1cea69 100644
--- a/include/cobalt/kernel/heap.h
+++ b/include/cobalt/kernel/heap.h
@@ -130,6 +130,10 @@ static inline void xnheap_cleanup_proc(void) { }
 
 /* Public interface. */
 
+void *xnheap_vmalloc(size_t size);
+
+void xnheap_vfree(void *p);
+
 int xnheap_init(struct xnheap *heap, void *membase, u32 size);
 
 void xnheap_set_name(struct xnheap *heap,
diff --git a/kernel/cobalt/heap.c b/kernel/cobalt/heap.c
index 70f1c8f..2fcb6ba 100644
--- a/kernel/cobalt/heap.c
+++ b/kernel/cobalt/heap.c
@@ -21,6 +21,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -655,4 +657,30 @@ out:
 }
 EXPORT_SYMBOL_GPL(xnheap_check_block);
 
+void *xnheap_vmalloc(size_t size)
+{
+   /*
+* We want memory used in real-time context to be pulled from
+* ZONE_NORMAL, however we don't need it to be physically
+* contiguous.
+*
+* 32bit systems which would need HIGHMEM for running a Cobalt
+* configuration would also be required to support PTE
+* pinning, which not all architectures provide.  Moreover,
+* pinning PTEs eagerly for a potentially (very) large amount
+* of memory may quickly degrade performance.
+*
+* If using a different kernel/user memory split cannot be the
+* answer for those configs, it's likely that basing such
+* software on a 32bit system had to be wrong in the first
+* place anyway.
+*/
+   return __vmalloc(size, GFP_KERNEL, PAGE_KERNEL);
+}
+
+void xnheap_vfree(void *p)
+{
+   vfree(p);
+}
+
 /** @} */
diff --git a/kernel/cobalt/init.c b/kernel/cobalt/init.c
index 0eab3be..6cbb67b 100644
--- a/kernel/cobalt/init.c
+++ b/kernel/cobalt/init.c
@@ -18,6 +18,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -127,7 +128,6 @@ static void sys_shutdown(void)
struct xnthread *thread, *tmp;
struct xnsched *sched;
void *membase;
-   u32 memsize;
int cpu;
spl_t s;
 
@@ -155,9 +155,8 @@ static void sys_shutdown(void)
 
xnregistry_cleanup();
membase = xnheap_get_membase(_heap);
-   memsize = xnheap_get_size(_heap);
xnheap_destroy(_heap);
-   free_pages_exact(membase, memsize);
+   vfree(membase);
 }
 
 static int __init mach_setup(void)
@@ -290,7 +289,7 @@ static __init int sys_init(void)
if (sysheap_size_arg == 0)
sysheap_size_arg = CONFIG_XENO_OPT_SYS_HEAPSZ;
 
-   heapaddr = alloc_pages_exact(sysheap_size_arg * 1024, GFP_KERNEL);
+   heapaddr = vmalloc(sysheap_size_arg * 1024);
if (heapaddr == NULL ||
xnheap_init(_heap, heapaddr, sysheap_size_arg * 1024)) {
return -ENOMEM;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib/smokey: add barrier support helpers

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: b37c05f860c6cbdf572b0b3955fd0eb2c7bab2b7
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b37c05f860c6cbdf572b0b3955fd0eb2c7bab2b7

Author: Philippe Gerum 
Date:   Wed Feb 24 09:06:35 2016 +0100

lib/smokey: add barrier support helpers

---

 include/smokey/smokey.h |   15 +
 lib/smokey/helpers.c|   57 +++
 2 files changed, 72 insertions(+)

diff --git a/include/smokey/smokey.h b/include/smokey/smokey.h
index 35b5153..d3c9987 100644
--- a/include/smokey/smokey.h
+++ b/include/smokey/smokey.h
@@ -19,6 +19,7 @@
 #define _XENOMAI_SMOKEY_SMOKEY_H
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -132,6 +133,12 @@ struct smokey_test {
 #define smokey_warning(__fmt, __args...)   \
__smokey_warning(__FILE__, __LINE__, __fmt, ##__args)
 
+struct smokey_barrier {
+   pthread_mutex_t lock;
+   pthread_cond_t barrier;
+   int signaled;
+};
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -159,6 +166,14 @@ void smokey_note(const char *fmt, ...);
 void __smokey_warning(const char *file, int lineno,
  const char *fmt, ...);
 
+int smokey_barrier_init(struct smokey_barrier *b);
+
+void smokey_barrier_destroy(struct smokey_barrier *b);
+
+int smokey_barrier_wait(struct smokey_barrier *b);
+
+void smokey_barrier_release(struct smokey_barrier *b);
+   
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/smokey/helpers.c b/lib/smokey/helpers.c
index 279054f..b52afed 100644
--- a/lib/smokey/helpers.c
+++ b/lib/smokey/helpers.c
@@ -164,3 +164,60 @@ void __smokey_warning(const char *file, int lineno,
 
va_end(ap);
 }
+
+int smokey_barrier_init(struct smokey_barrier *b)
+{
+   pthread_mutexattr_t mattr;
+   pthread_condattr_t cattr;
+   int ret;
+
+   b->signaled = 0;
+   pthread_mutexattr_init();
+   pthread_mutexattr_settype(, PTHREAD_MUTEX_NORMAL);
+   pthread_mutexattr_setpshared(, PTHREAD_PROCESS_PRIVATE);
+   pthread_mutexattr_setprotocol(, PTHREAD_PRIO_NONE);
+   ret = __RT(pthread_mutex_init(>lock, ));
+   pthread_mutexattr_destroy();
+   if (ret)
+   return ret;
+
+   pthread_condattr_init();
+   pthread_condattr_setpshared(, PTHREAD_PROCESS_PRIVATE);
+   ret = __RT(pthread_cond_init(>barrier, ));
+   pthread_condattr_destroy();
+   if (ret)
+   __RT(pthread_mutex_destroy(>lock));
+
+   return ret;
+}
+
+void smokey_barrier_destroy(struct smokey_barrier *b)
+{
+   __RT(pthread_cond_destroy(>barrier));
+   __RT(pthread_mutex_destroy(>lock));
+}
+
+int smokey_barrier_wait(struct smokey_barrier *b)
+{
+   int ret;
+   
+   __RT(pthread_mutex_lock(>lock));
+
+   while (!b->signaled) {
+   ret = __RT(pthread_cond_wait(>barrier, >lock));
+   if (ret)
+   break;
+   }
+
+   __RT(pthread_mutex_unlock(>lock));
+
+   return ret;
+}
+
+void smokey_barrier_release(struct smokey_barrier *b)
+{
+   __RT(pthread_mutex_lock(>lock));
+   b->signaled = 1;
+   __RT(pthread_cond_broadcast(>barrier));
+   __RT(pthread_mutex_unlock(>lock));
+}


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/powerpc: upgrade I-pipe support

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: ffe206cef87026df98544b62c27c6d102068c700
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ffe206cef87026df98544b62c27c6d102068c700

Author: Philippe Gerum 
Date:   Mon Feb 29 10:12:06 2016 +0100

cobalt/powerpc: upgrade I-pipe support

---

 .../patches/ipipe-core-4.1.18-powerpc-1.patch  |15898 
 1 file changed, 15898 insertions(+)

Diff:   
http://git.xenomai.org/?p=xenomai-3.git;a=commitdiff;h=ffe206cef87026df98544b62c27c6d102068c700

___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/registry: return -EAGAIN upon lack of registry slot

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: c854d7b39976884f2d44367b19020a11f2c7ffd0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c854d7b39976884f2d44367b19020a11f2c7ffd0

Author: Philippe Gerum 
Date:   Fri Feb 12 17:00:54 2016 +0100

cobalt/registry: return -EAGAIN upon lack of registry slot

-ENOMEM is confusing in this case, does not actually reflect the error
condition, and does not match the error code commonly returned by
POSIX services for denoting a (temporary) lack of resources.
Besides, this source of error was not even mentioned in the
documentation of the affected services.

All error codes must be detected, and any program that might have
specifically checked for -ENOMEM during error recovery in the affected
services was potentially confused, so this change does not introduce a
significant ABI variation.

---

 include/rtdm/uapi/ipc.h |3 ++-
 kernel/cobalt/registry.c|2 +-
 kernel/cobalt/rtdm/device.c |3 +++
 lib/cobalt/cond.c   |1 +
 lib/cobalt/mq.c |1 +
 lib/cobalt/mutex.c  |1 +
 lib/cobalt/semaphore.c  |1 +
 7 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/rtdm/uapi/ipc.h b/include/rtdm/uapi/ipc.h
index a558150..432cd9b 100644
--- a/include/rtdm/uapi/ipc.h
+++ b/include/rtdm/uapi/ipc.h
@@ -174,7 +174,8 @@ int close__AF_RTIPC(int sockfd);
  *   - -ENOMEM (Not enough memory)
  *   - -EINVAL (Invalid parameter)
  *   - -EADDRINUSE (Socket already bound to a port, or no port available)
- *   .
+ *   - -EAGAIN (no registry slot available, check/raise
+ * CONFIG_XENO_OPT_REGISTRY_NRSLOTS) .
  *
  * @par Calling context:
  * non-RT
diff --git a/kernel/cobalt/registry.c b/kernel/cobalt/registry.c
index ba46bd0..9d14863 100644
--- a/kernel/cobalt/registry.c
+++ b/kernel/cobalt/registry.c
@@ -637,7 +637,7 @@ int xnregistry_enter(const char *key, void *objaddr,
xnlock_get_irqsave(, s);
 
if (list_empty(_object_list)) {
-   ret = -ENOMEM;
+   ret = -EAGAIN;
goto unlock_and_exit;
}
 
diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index 9c5aeb1..660f61c 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -352,6 +352,9 @@ static void unregister_driver(struct rtdm_driver *drv)
  * - -ENOMEM is returned if a memory allocation failed in the process
  * of registering the device.
  *
+ * - -EAGAIN is returned if no registry slot is available (check/raise
+ * CONFIG_XENO_OPT_REGISTRY_NRSLOTS).
+ *
  * @coretags{secondary-only}
  */
 int rtdm_dev_register(struct rtdm_device *dev)
diff --git a/lib/cobalt/cond.c b/lib/cobalt/cond.c
index 7eeb9e6..00a2018 100644
--- a/lib/cobalt/cond.c
+++ b/lib/cobalt/cond.c
@@ -103,6 +103,7 @@ void cobalt_default_condattr_init(void)
  * - EBUSY, the condition variable @a cond was already initialized;
  * - ENOMEM, insufficient memory available from the system heap to initialize 
the
  *   condition variable, increase CONFIG_XENO_OPT_SYS_HEAPSZ.
+ * - EAGAIN, no registry slot available, check/raise 
CONFIG_XENO_OPT_REGISTRY_NRSLOTS.
  *
  * @see
  * http://www.opengroup.org/onlinepubs/95399/functions/pthread_cond_init.html;>
diff --git a/lib/cobalt/mq.c b/lib/cobalt/mq.c
index a361688..471d9b3 100644
--- a/lib/cobalt/mq.c
+++ b/lib/cobalt/mq.c
@@ -93,6 +93,7 @@
  * - EPERM, attempting to create a message queue from an invalid context;
  * - EINVAL, the @a attr argument is invalid;
  * - EMFILE, too many descriptors are currently open.
+ * - EAGAIN, no registry slot available, check/raise 
CONFIG_XENO_OPT_REGISTRY_NRSLOTS.
  *
  * @see
  * http://www.opengroup.org/onlinepubs/95399/functions/mq_open.html;>
diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c
index 979c91b..9d8a914 100644
--- a/lib/cobalt/mutex.c
+++ b/lib/cobalt/mutex.c
@@ -98,6 +98,7 @@ void cobalt_mutex_init(void)
  * - EAGAIN, insufficient memory available to initialize the
  *   mutex, increase CONFIG_XENO_OPT_SHARED_HEAPSZ for a process-shared
  *   mutex, or CONFIG_XENO_OPT_PRIVATE_HEAPSZ for a process-private mutex.
+ * - EAGAIN, no registry slot available, check/raise 
CONFIG_XENO_OPT_REGISTRY_NRSLOTS.
  *
  * @see
  * http://www.opengroup.org/onlinepubs/95399/functions/pthread_mutex_init.html;>
diff --git a/lib/cobalt/semaphore.c b/lib/cobalt/semaphore.c
index 5a69968..45705d4 100644
--- a/lib/cobalt/semaphore.c
+++ b/lib/cobalt/semaphore.c
@@ -75,6 +75,7 @@ struct cobalt_sem_state *sem_get_state(struct 
cobalt_sem_shadow *shadow)
  * - EAGAIN, insufficient memory available to initialize the
  *   semaphore, increase CONFIG_XENO_OPT_SHARED_HEAPSZ for a process-shared
  *   semaphore, or CONFIG_XENO_OPT_PRIVATE_HEAPSZ for a process-private 
semaphore.
+ * - EAGAIN, no registry slot available, check/raise 
CONFIG_XENO_OPT_REGISTRY_NRSLOTS.
  * - EINVAL, the @a value argument exceeds @a SEM_VALUE_MAX.
  *
  * @see



[Xenomai-git] Philippe Gerum : doc/rtdm: work around Doxygen weirdness

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 671a0ef832b0bdc958e85d919f18cef87530a669
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=671a0ef832b0bdc958e85d919f18cef87530a669

Author: Philippe Gerum 
Date:   Tue Feb 16 12:02:16 2016 +0100

doc/rtdm: work around Doxygen weirdness

---

 include/cobalt/kernel/rtdm/driver.h |   42 +--
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index b0a37c4..01601c3 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -419,9 +419,9 @@ void rtdm_toseq_init(rtdm_toseq_t *timeout_seq, 
nanosecs_rel_t timeout);
  * respect to all interrupt handlers (including for real-time IRQs)
  * and Xenomai threads running on all CPUs.
  *
- * @param context name of local variable to store the context in. This
- * variable updated by the real-time core will hold the information
- * required to leave the atomic section properly.
+ * @param __context name of local variable to store the context
+ * in. This variable updated by the real-time core will hold the
+ * information required to leave the atomic section properly.
  *
  * @note Atomic sections may be nested. The caller is allowed to sleep
  * on a blocking Xenomai service from primary mode within an atomic
@@ -437,10 +437,10 @@ void rtdm_toseq_init(rtdm_toseq_t *timeout_seq, 
nanosecs_rel_t timeout);
  * purpose of porting existing dual-kernel drivers which still depend
  * on the obsolete RTDM_EXECUTE_ATOMICALLY() construct.
  */
-#define cobalt_atomic_enter(context)   \
-   do {\
-   xnlock_get_irqsave(, (context)); \
-   xnsched_lock(); \
+#define cobalt_atomic_enter(__context) \
+   do {\
+   xnlock_get_irqsave(, (__context));   \
+   xnsched_lock(); \
} while (0)
 
 /**
@@ -450,15 +450,15 @@ void rtdm_toseq_init(rtdm_toseq_t *timeout_seq, 
nanosecs_rel_t timeout);
  * cobalt_atomic_enter(), restoring the preemption and interrupt state
  * which prevailed prior to entering the exited section.
  *
- * @param context name of local variable which stored the context.
+ * @param __context name of local variable which stored the context.
  *
  * @warning This service is not portable to the Mercury core, and
  * should be restricted to Cobalt-specific use cases.
  */
-#define cobalt_atomic_leave(context)   \
+#define cobalt_atomic_leave(__context) \
do {\
xnsched_unlock();   \
-   xnlock_put_irqrestore(, (context));  \
+   xnlock_put_irqrestore(, (__context));\
} while (0)
 
 /**
@@ -574,14 +574,16 @@ static inline void rtdm_lock_put(rtdm_lock_t *lock)
 }
 
 /**
- * @fn void rtdm_lock_get_irqsave(rtdm_lock_t *lock, rtdm_lockctx_t context)
  * Acquire lock and disable preemption, by stalling the head domain.
  *
- * @param lock Address of lock variable
- * @param context name of local variable to store the context in
+ * @param __lock Address of lock variable
+ * @param __context name of local variable to store the context in
  *
  * @coretags{unrestricted}
  */
+#define rtdm_lock_get_irqsave(__lock, __context)   \
+   ((__context) = __rtdm_lock_get_irqsave(__lock))
+
 static inline rtdm_lockctx_t __rtdm_lock_get_irqsave(rtdm_lock_t *lock)
 {
rtdm_lockctx_t context;
@@ -592,8 +594,6 @@ static inline rtdm_lockctx_t 
__rtdm_lock_get_irqsave(rtdm_lock_t *lock)
 
return context;
 }
-#define rtdm_lock_get_irqsave(__lock, __context)   \
-   ((__context) = __rtdm_lock_get_irqsave(__lock))
 
 /**
  * Release lock and restore preemption state
@@ -614,22 +614,22 @@ void rtdm_lock_put_irqrestore(rtdm_lock_t *lock, 
rtdm_lockctx_t context)
 /**
  * Disable preemption locally
  *
- * @param context name of local variable to store the context in
+ * @param __context name of local variable to store the context in
  *
  * @coretags{unrestricted}
  */
-#define rtdm_lock_irqsave(context) \
-   splhigh(context)
+#define rtdm_lock_irqsave(__context)   \
+   splhigh(__context)
 
 /**
  * Restore preemption state
  *
- * @param context name of local variable which stored the context
+ * @param __context name of local variable which stored the context
  *
  * @coretags{unrestricted}
  */
-#define rtdm_lock_irqrestore(context)  \
-   splexit(context)
+#define rtdm_lock_irqrestore(__context)\
+   splexit(__context)
 
 /** @} Spinlock with Preemption Deactivation */
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org

[Xenomai-git] Philippe Gerum : lib/smokey: init: fix regression introduced by #9489274

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: e370cd1fc50615f5221210c37c968ceb8e5afb89
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e370cd1fc50615f5221210c37c968ceb8e5afb89

Author: Philippe Gerum 
Date:   Mon Feb 29 11:53:22 2016 +0100

lib/smokey: init: fix regression introduced by #9489274

---

 lib/smokey/init.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/smokey/init.c b/lib/smokey/init.c
index 0db3ec9..b69f24c 100644
--- a/lib/smokey/init.c
+++ b/lib/smokey/init.c
@@ -508,7 +508,8 @@ static int smokey_parse_option(int optnum, const char 
*optarg)
 {
switch (optnum) {
case run_opt:
-   include_arg = strdup(optarg);
+   if (optarg)
+   include_arg = strdup(optarg);
break;
case exclude_opt:
exclude_arg = strdup(optarg);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/syncobj: fix race in aborted wait_grant/ drain operations

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 6150e5b86ec32e1b1e41bbfbc9e3bbb8d619b08b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6150e5b86ec32e1b1e41bbfbc9e3bbb8d619b08b

Author: Philippe Gerum 
Date:   Tue Feb  9 11:51:00 2016 +0100

copperplate/syncobj: fix race in aborted wait_grant/drain operations

Fixup a potential race upon return from grant/drain_wait operations,
e.g. given two threads A and B:

A:enqueue_waiter(self)
A:monitor_wait
   A:monitor_unlock
   A:[timed] sleep
   A:wakeup on timeout/interrupt
  B:monitor_lock
  B:look_for_queued_waiter
 (found A, update A's state)
  B:monitor_unlock
   A:dequeue_waiter(self)
   A:return -ETIMEDOUT/-EINTR

The race may happen anytime between the timeout/interrupt event is
received by A, and the moment it grabs back the monitor lock before
unqueuing. When the race happens, B can squeeze in a signal before A
unqueues after resumption on error.

Problem: A's internal state has been updated (e.g. some data
transferred to it), but it will receive -ETIMEDOUT/-EINTR, causing it
to miss the update eventually.

The fix involves filtering out -ETIMEDOUT/-EINTR errors upon return
from wait_grant/drain operations whenever the syncobj was actually
signaled.

This issue was detected and described by
http://xenomai.org/pipermail/xenomai/2016-February/035852.html

---

 lib/copperplate/syncobj.c |   51 -
 1 file changed, 46 insertions(+), 5 deletions(-)

diff --git a/lib/copperplate/syncobj.c b/lib/copperplate/syncobj.c
index 1b3d545..bf04b29 100644
--- a/lib/copperplate/syncobj.c
+++ b/lib/copperplate/syncobj.c
@@ -453,14 +453,55 @@ struct threadobj *syncobj_peek_drain(struct syncobj *sobj)
 
 static int wait_epilogue(struct syncobj *sobj,
 struct syncstate *syns,
-struct threadobj *current)
+struct threadobj *current,
+int ret)
 {
current->run_state = __THREAD_S_RUNNING;
 
+   /*
+* Fixup a potential race upon return from grant/drain_wait
+* operations, e.g. given two threads A and B:
+*
+* A:enqueue_waiter(self)
+* A:monitor_wait
+*A:monitor_unlock
+*A:[timed] sleep
+*A:wakeup on timeout/interrupt
+*   B:monitor_lock
+*   B:look_for_queued_waiter
+*  (found A, update A's state)
+*   B:monitor_unlock
+*A:dequeue_waiter(self)
+*A:return -ETIMEDOUT/-EINTR
+*
+* The race may happen anytime between the timeout/interrupt
+* event is received by A, and the moment it grabs back the
+* monitor lock before unqueuing. When the race happens, B can
+* squeeze in a signal before A unqueues after resumption on
+* error.
+*
+* Problem: A's internal state has been updated (e.g. some
+* data transferred to it), but it will receive
+* -ETIMEDOUT/-EINTR, causing it to miss the update
+* eventually.
+*
+* Solution: fixup the status code upon return from
+* wait_grant/drain operations, so that -ETIMEDOUT/-EINTR is
+* never returned to the caller if the syncobj was actually
+* signaled. We still allow the SYNCOBJ_FLUSHED condition to
+* override that success code though.
+*
+* Whether a condition should be deemed satisfied if it is
+* signaled during the race window described above is
+* debatable, but this is a simple and straightforward way to
+* handle such grey area.
+*/
+
if (current->wait_sobj) {
dequeue_waiter(sobj, current);
current->wait_sobj = NULL;
-   }
+   } else if (ret == -ETIMEDOUT || ret == -EINTR)
+   ret = 0;
 
sobj->wait_count--;
assert(sobj->wait_count >= 0);
@@ -477,7 +518,7 @@ static int wait_epilogue(struct syncobj *sobj,
if (current->wait_status & SYNCOBJ_FLUSHED)
return -EINTR;
 
-   return 0;
+   return ret;
 }
 
 int syncobj_wait_grant(struct syncobj *sobj, const struct timespec *timeout,
@@ -515,7 +556,7 @@ int syncobj_wait_grant(struct syncobj *sobj, const struct 
timespec *timeout,
 
pthread_setcancelstate(state, NULL);
 
-   return wait_epilogue(sobj, syns, current) ?: ret;
+   return wait_epilogue(sobj, syns, current, ret);
 }
 
 int syncobj_wait_drain(struct syncobj *sobj, const struct timespec *timeout,
@@ -553,7 +594,7 @@ int syncobj_wait_drain(struct syncobj *sobj, const struct 
timespec *timeout,
 
pthread_setcancelstate(state, NULL);
 
-   return wait_epilogue(sobj, syns, current) ?: ret;
+   return wait_epilogue(sobj, syns, current, ret);
 }
 
 int syncobj_destroy(struct syncobj *sobj, struct syncstate *syns)


___
Xenomai-git mailing 

[Xenomai-git] Philippe Gerum : testsuite/smokey: add test checking Cobalt' s cpu affinity control

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: f6f82cb5a7ae024cb874f72b0167bad748c74d27
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f6f82cb5a7ae024cb874f72b0167bad748c74d27

Author: Philippe Gerum 
Date:   Fri Feb 26 11:44:16 2016 +0100

testsuite/smokey: add test checking Cobalt's cpu affinity control

---

 configure.ac |1 +
 testsuite/smokey/Makefile.am |3 +-
 testsuite/smokey/cpu-affinity/Makefile.am|9 +
 testsuite/smokey/cpu-affinity/cpu-affinity.c |  252 ++
 4 files changed, 264 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index f450673..d71aa38 100644
--- a/configure.ac
+++ b/configure.ac
@@ -909,6 +909,7 @@ AC_CONFIG_FILES([ \
testsuite/smokey/net_packet_dgram/Makefile \
testsuite/smokey/net_packet_raw/Makefile \
testsuite/smokey/net_common/Makefile \
+   testsuite/smokey/cpu-affinity/Makefile \
testsuite/clocktest/Makefile \
testsuite/xeno-test/Makefile \
utils/Makefile \
diff --git a/testsuite/smokey/Makefile.am b/testsuite/smokey/Makefile.am
index 174b393..51292f1 100644
--- a/testsuite/smokey/Makefile.am
+++ b/testsuite/smokey/Makefile.am
@@ -8,6 +8,7 @@ smokey_SOURCES = main.c
 COBALT_SUBDIRS =   \
arith   \
bufp\
+   cpu-affinity\
fpu-stress  \
iddp\
leaks   \
@@ -32,7 +33,7 @@ COBALT_SUBDIRS =  \
 MERCURY_SUBDIRS =
 
 DIST_SUBDIRS = $(COBALT_SUBDIRS) $(MERCURY_SUBDIRS)
-   
+
 if XENO_COBALT
 wrappers = $(XENO_POSIX_WRAPPERS)
 SUBDIRS = $(COBALT_SUBDIRS)
diff --git a/testsuite/smokey/cpu-affinity/Makefile.am 
b/testsuite/smokey/cpu-affinity/Makefile.am
new file mode 100644
index 000..0d2e4e6
--- /dev/null
+++ b/testsuite/smokey/cpu-affinity/Makefile.am
@@ -0,0 +1,9 @@
+
+noinst_LIBRARIES = libcpu-affinity.a
+
+libcpu_affinity_a_SOURCES = cpu-affinity.c
+
+libcpu_affinity_a_CPPFLAGS =   \
+   @XENO_USER_CFLAGS@  \
+   -I$(top_srcdir) \
+   -I$(top_srcdir)/include
diff --git a/testsuite/smokey/cpu-affinity/cpu-affinity.c 
b/testsuite/smokey/cpu-affinity/cpu-affinity.c
new file mode 100644
index 000..2674f76
--- /dev/null
+++ b/testsuite/smokey/cpu-affinity/cpu-affinity.c
@@ -0,0 +1,252 @@
+/*
+ * Test CPU affinity control mechanisms.
+ *
+ * Copyright (C) Philippe Gerum 
+ *
+ * Released under the terms of GPLv2.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+smokey_test_plugin(cpu_affinity,
+  SMOKEY_NOARGS,
+  "Check CPU affinity control."
+);
+
+static cpu_set_t cpu_realtime_set, cpu_online_set;
+
+struct test_context {
+   sem_t done;
+   int status;
+   int kfd;
+   int nrt_cpu;
+};
+
+static void *test_thread(void *arg)
+{
+   int cpu, cpu_in_rt_set, status = 0, ncpu, ret;
+   struct test_context *p = arg;
+   cpu_set_t set;
+
+   cpu = get_current_cpu();
+   if (!__Fassert(cpu < 0)) {
+   status = cpu;
+   goto out;
+   }
+
+   /*
+* When emerging, we should be running on a member of the
+* real-time CPU set.
+*/
+   cpu_in_rt_set = CPU_ISSET(cpu, _realtime_set);
+   if (!__Tassert(cpu_in_rt_set)) {
+   status = -EINVAL;
+   goto out;
+   }
+
+   smokey_trace(" user thread starts on CPU%d, ok", cpu);
+
+   for (ncpu = 0; ncpu < CPU_SETSIZE; ncpu++) {
+   if (ncpu == cpu || !CPU_ISSET(ncpu, _realtime_set))
+   continue;
+   CPU_ZERO();
+   CPU_SET(ncpu, );
+   if (!__Terrno(ret, sched_setaffinity(0, sizeof(set), ))) {
+   status = ret;
+   goto out;
+   }
+   smokey_trace(" user thread moved to CPU%d, good", ncpu);
+   }
+out:
+   p->status = status;
+   __STD(sem_post(>done));
+   
+   return NULL;
+}
+
+static int load_test_module(void)
+{
+   int fd, status;
+   
+   status = system("modprobe -q xeno_rtdmtest");
+   if (status < 0 || WEXITSTATUS(status))
+   return -ENOSYS;
+
+   /* Open the RTDM actor device. */
+   fd = open("/dev/rtdm/rtdmx", O_RDWR);
+   if (fd < 0)
+   return -errno;
+
+   return fd;
+}
+
+static void unload_test_module(int fd)
+{
+   close(fd);
+   system("rmmod xeno_rtdmtest");
+}
+
+static void *__run_cpu_affinity(void *arg)
+{
+   struct test_context *context = arg;
+   struct sched_param param;
+   struct timespec ts, now;
+   pthread_attr_t thattr;
+   cpu_set_t set;
+   pthread_t tid;
+   int ret;
+
+   smokey_trace(".. control thread binding to non-RT CPU%d",
+context->nrt_cpu);
+
+   __STD(sem_init(>done, 0, 0));
+
+   

[Xenomai-git] Philippe Gerum : cobalt/arm: upgrade I-pipe support

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 6b01589f714663dd645bf3243ea934a767ac0d12
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6b01589f714663dd645bf3243ea934a767ac0d12

Author: Philippe Gerum 
Date:   Mon Feb 29 10:10:20 2016 +0100

cobalt/arm: upgrade I-pipe support

---

 .../arch/arm/patches/ipipe-core-4.1.18-arm-1.patch |23942 
 1 file changed, 23942 insertions(+)

Diff:   
http://git.xenomai.org/?p=xenomai-3.git;a=commitdiff;h=6b01589f714663dd645bf3243ea934a767ac0d12

___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/thread: force secondary mode for joining threads

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: e4c9b3d581f3ee349c52f39c321c0dc82b2a4ad1
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e4c9b3d581f3ee349c52f39c321c0dc82b2a4ad1

Author: Philippe Gerum 
Date:   Tue Mar  1 10:00:59 2016 +0100

cobalt/thread: force secondary mode for joining threads

Make xnthread_join() switch the caller to secondary mode prior to
waiting for the target thread termination. The original runtime mode
is restored upon return.

Since the joiner was already synchronized on an event that may be sent
by the joinee from secondary mode exclusively, this change does not
drop any real-time guarantee for the joiner: there has never been any
in the first place.

This is a preparation step to a stricter synchronization between the
joiner and the joinee, especially in the SMP case.

---

 include/cobalt/kernel/thread.h |2 --
 kernel/cobalt/posix/process.c  |2 --
 kernel/cobalt/thread.c |   75 +---
 3 files changed, 31 insertions(+), 48 deletions(-)

diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h
index 59d6027..f25c6d0 100644
--- a/include/cobalt/kernel/thread.h
+++ b/include/cobalt/kernel/thread.h
@@ -188,8 +188,6 @@ struct xnthread {
const char *exe_path;   /* Executable path */
u32 proghash;   /* Hash value for exe_path */
 #endif
-   /** Exit event for joining the thread. */
-   struct xnsynch join_synch;
 };
 
 static inline int xnthread_get_state(const struct xnthread *thread)
diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
index 788a24a..5b80521 100644
--- a/kernel/cobalt/posix/process.c
+++ b/kernel/cobalt/posix/process.c
@@ -1048,8 +1048,6 @@ static void __handle_taskexit_event(struct task_struct *p)
unregister_debugged_thread(thread);
 
xnthread_run_handler_stack(thread, exit_thread);
-   /* Waiters will receive EIDRM */
-   xnsynch_destroy(>join_synch);
xnsched_run();
 
if (xnthread_test_state(thread, XNUSER)) {
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 2b0cf60..462d917 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -204,7 +204,6 @@ int __xnthread_init(struct xnthread *thread,
memset(>stat, 0, sizeof(thread->stat));
thread->selector = NULL;
INIT_LIST_HEAD(>claimq);
-   xnsynch_init(>join_synch, XNSYNCH_FIFO, NULL);
/* These will be filled by xnthread_start() */
thread->entry = NULL;
thread->cookie = NULL;
@@ -1594,7 +1593,9 @@ EXPORT_SYMBOL_GPL(xnthread_cancel);
  * immediately.
  *
  * xnthread_join() adapts to the calling context (primary or
- * secondary).
+ * secondary), switching to secondary mode if needed for the duration
+ * of the wait. Upon return, the original runtime mode is restored,
+ * unless a Linux signal is pending.
  *
  * @param thread The descriptor address of the thread to join with.
  *
@@ -1617,62 +1618,48 @@ EXPORT_SYMBOL_GPL(xnthread_cancel);
  */
 int xnthread_join(struct xnthread *thread, bool uninterruptible)
 {
+   struct xnthread *curr = xnthread_current();
+   int ret = 0, switched = 0;
unsigned int tag;
spl_t s;
-   int ret;
 
XENO_BUG_ON(COBALT, xnthread_test_state(thread, XNROOT));
 
+   if (thread == curr)
+   return -EDEADLK;
+
xnlock_get_irqsave(, s);
 
-   tag = thread->idtag;
-   if (xnthread_test_info(thread, XNDORMANT) || tag == 0) {
-   xnlock_put_irqrestore(, s);
-   return 0;
+   if (xnthread_test_state(thread, XNJOINED)) {
+   ret = -EBUSY;
+   goto out;
}
 
+   tag = thread->idtag;
+   if (xnthread_test_info(thread, XNDORMANT) || tag == 0)
+   goto out;
+
trace_cobalt_thread_join(thread);
 
-   if (ipipe_root_p) {
-   if (xnthread_test_state(thread, XNJOINED)) {
-   ret = -EBUSY;
-   goto out;
-   }
-   xnthread_set_state(thread, XNJOINED);
+   xnthread_set_state(thread, XNJOINED);
+   
+   if (!xnthread_test_state(curr, XNRELAX|XNROOT)) {
+   xnlock_put_irqrestore(, s);
+   xnthread_relax(0, 0);
+   switched = 1;
+   } else
xnlock_put_irqrestore(, s);
-   /*
-* Only a very few threads are likely to terminate within a
-* short time frame at any point in time, so experiencing a
-* thundering herd effect due to synchronizing on a single
-* wait queue is quite unlikely. In any case, we run in
-* secondary mode.
-*/
-   if (uninterruptible)
-   wait_event(nkjoinq, thread->idtag != tag);
-   else if (wait_event_interruptible(nkjoinq,
-  

[Xenomai-git] Philippe Gerum : cobalt/thread: do not demote kthreads when cancelling

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 17ba6d91ade9b8a3e1d0c132645d1e925cca3458
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=17ba6d91ade9b8a3e1d0c132645d1e925cca3458

Author: Philippe Gerum 
Date:   Tue Mar  1 08:36:18 2016 +0100

cobalt/thread: do not demote kthreads when cancelling

There is no point in switching a kthread to weak scheduling when
cancelling it, as it must reach a cancellation point asap as part of
its work loop anyway. Would it omit testing for cancellation, weak
scheduling would not help enforcing the exit request anyway.

---

 kernel/cobalt/thread.c |   19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 26ce90f..2b0cf60 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -1562,16 +1562,21 @@ check_self_cancel:
return;
}
 
-   __xnthread_demote(thread);
-
/*
-* A userland thread undergoing the weak scheduling policy is
-* unlikely to issue Cobalt syscalls frequently, which may
-* defer cancellation significantly: send it a regular
-* termination signal too.
+* Force the non-current thread to exit:
+*
+* - unblock a user thread, switch it to weak scheduling,
+* then send it SIGTERM.
+*
+* - just unblock a kernel thread, it is expected to reach a
+* cancellation point soon after
+* (i.e. xnthread_test_cancel()).
 */
-   if (xnthread_test_state(thread, XNWEAK|XNUSER) == (XNWEAK|XNUSER))
+   if (xnthread_test_state(thread, XNUSER)) {
+   __xnthread_demote(thread);
xnthread_signal(thread, SIGTERM, 0);
+   } else
+   __xnthread_kick(thread);
 out:
xnlock_put_irqrestore(, s);
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/posix/mqueue: get buffer memory from vmalloc()

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: c5a02a6d95f47aa62792eee81bdb45ac6576a8b7
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c5a02a6d95f47aa62792eee81bdb45ac6576a8b7

Author: Philippe Gerum 
Date:   Sun Feb 28 08:16:18 2016 +0100

cobalt/posix/mqueue: get buffer memory from vmalloc()

---

 kernel/cobalt/posix/mqueue.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c
index 5ffa5f9..0f5e19e 100644
--- a/kernel/cobalt/posix/mqueue.c
+++ b/kernel/cobalt/posix/mqueue.c
@@ -126,7 +126,7 @@ static inline int mq_init(struct cobalt_mq *mq, const 
struct mq_attr *attr)
if (get_order(memsize) > MAX_ORDER)
return -ENOSPC;
 
-   mem = alloc_pages_exact(memsize, GFP_KERNEL);
+   mem = xnheap_vmalloc(memsize);
if (mem == NULL)
return -ENOSPC;
 
@@ -167,7 +167,7 @@ static inline void mq_destroy(struct cobalt_mq *mq)
xnselect_destroy(>read_select);
xnselect_destroy(>write_select);
xnregistry_remove(mq->handle);
-   free_pages_exact(mq->mem, mq->memsize);
+   xnheap_vfree(mq->mem);
kfree(mq);
 
if (resched)


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : debian/doc: switch mailing list URL to https

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 0218ffe76d6c8f63f10fa2fb634bb19c58fcad2d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0218ffe76d6c8f63f10fa2fb634bb19c58fcad2d

Author: Philippe Gerum 
Date:   Tue Feb 23 16:46:57 2016 +0100

debian/doc: switch mailing list URL to https

---

 debian/xenomai-kernel-source.README.Debian |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/xenomai-kernel-source.README.Debian 
b/debian/xenomai-kernel-source.README.Debian
index e82fade..bb5131d 100644
--- a/debian/xenomai-kernel-source.README.Debian
+++ b/debian/xenomai-kernel-source.README.Debian
@@ -17,4 +17,4 @@ particular about the options which should not be enabled see:
 http://www.xenomai.org/index.php/Configuring_x86_kernels
 
 You can also get help on the Xenomai mailing list. Subscribe here:
-http://www.xenomai.org/mailman/listinfo/xenomai
+https://www.xenomai.org/mailman/listinfo/xenomai


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/ipc: bufp: fix wrong TX timeout

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 63de8c561e65223c5265b851d3cff57073b85bba
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=63de8c561e65223c5265b851d3cff57073b85bba

Author: Philippe Gerum 
Date:   Sat Feb 27 19:29:22 2016 +0100

drivers/ipc: bufp: fix wrong TX timeout

---

 kernel/drivers/ipc/bufp.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/drivers/ipc/bufp.c b/kernel/drivers/ipc/bufp.c
index 7ea8b2c..ecce4f9 100644
--- a/kernel/drivers/ipc/bufp.c
+++ b/kernel/drivers/ipc/bufp.c
@@ -423,7 +423,7 @@ static ssize_t __bufp_writebuf(struct bufp_socket *rsk,
 
len = bufd->b_len;
 
-   rtdm_toseq_init(, sk->rx_timeout);
+   rtdm_toseq_init(, sk->tx_timeout);
 
cobalt_atomic_enter(s);
 redo:


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/timer: allow binding core timers to passive CPUs

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: c2026a16156529357940cd16d6340f18b360ae52
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c2026a16156529357940cd16d6340f18b360ae52

Author: Philippe Gerum 
Date:   Wed Mar  2 12:08:32 2016 +0100

cobalt/timer: allow binding core timers to passive CPUs

Some timers initialized by the Cobalt core may have a valid reason to
live on CPUs excluded from the real-time set. A typical example would
be the host timer from the scheduler slot, which relays ticks to the
regular kernel. Other core timers are just better dealt with when
created and left passive on those CPUs.

Mark all core timers specifically, and exclude them from the LART
detection code in __xntimer_init(). This fixes a spurious Cobalt debug
assertion seen on SMP at boot, when the real-time CPU set is
restricted to a subset of the online CPU set.

---

 include/cobalt/kernel/timer.h |4 +++-
 kernel/cobalt/sched.c |6 +++---
 kernel/cobalt/thread.c|2 ++
 kernel/cobalt/timer.c |9 ++---
 4 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/include/cobalt/kernel/timer.h b/include/cobalt/kernel/timer.h
index 00aa411..5868fcb 100644
--- a/include/cobalt/kernel/timer.h
+++ b/include/cobalt/kernel/timer.h
@@ -51,11 +51,13 @@ typedef enum xntmode {
 #define XNTIMER_RUNNING   0x0040
 #define XNTIMER_KGRAVITY  0x0080
 #define XNTIMER_UGRAVITY  0x0100
-#define XNTIMER_IGRAVITY  0/* most conservative */
+#define XNTIMER_IGRAVITY  0 /* most conservative */
 
 #define XNTIMER_GRAVITY_MASK   (XNTIMER_KGRAVITY|XNTIMER_UGRAVITY)
 #define XNTIMER_INIT_MASK  (XNTIMER_GRAVITY_MASK|XNTIMER_NOBLCK)
 
+#define __XNTIMER_CORE0x1000
+
 /* These flags are available to the real-time interfaces */
 #define XNTIMER_SPARE0  0x0100
 #define XNTIMER_SPARE1  0x0200
diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index 3863dab..dfb8ce7 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -193,11 +193,11 @@ void xnsched_init(struct xnsched *sched, int cpu)
 * exit code.
 */
xntimer_init(>htimer, , NULL,
-sched, XNTIMER_IGRAVITY);
+sched, XNTIMER_IGRAVITY|__XNTIMER_CORE);
xntimer_set_priority(>htimer, XNTIMER_LOPRIO);
xntimer_set_name(>htimer, htimer_name);
xntimer_init(>rrbtimer, , roundrobin_handler,
-sched, XNTIMER_IGRAVITY);
+sched, XNTIMER_IGRAVITY|__XNTIMER_CORE);
xntimer_set_name(>rrbtimer, rrbtimer_name);
xntimer_set_priority(>rrbtimer, XNTIMER_LOPRIO);
 
@@ -212,7 +212,7 @@ void xnsched_init(struct xnsched *sched, int cpu)
 
 #ifdef CONFIG_XENO_OPT_WATCHDOG
xntimer_init(>wdtimer, , watchdog_handler,
-sched, XNTIMER_NOBLCK|XNTIMER_IGRAVITY);
+sched, XNTIMER_NOBLCK|XNTIMER_IGRAVITY|__XNTIMER_CORE);
xntimer_set_name(>wdtimer, "[watchdog]");
xntimer_set_priority(>wdtimer, XNTIMER_LOPRIO);
 #endif /* CONFIG_XENO_OPT_WATCHDOG */
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 07b0c8f..b758d50 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -202,6 +202,8 @@ int __xnthread_init(struct xnthread *thread,
init_completion(>exited);
 
gravity = flags & XNUSER ? XNTIMER_UGRAVITY : XNTIMER_KGRAVITY;
+   if (flags & XNROOT)
+   gravity |= __XNTIMER_CORE;
xntimer_init(>rtimer, , timeout_handler,
 sched, gravity);
xntimer_set_name(>rtimer, thread->name);
diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
index 3e85a53..ee16198 100644
--- a/kernel/cobalt/timer.c
+++ b/kernel/cobalt/timer.c
@@ -363,10 +363,13 @@ void __xntimer_init(struct xntimer *timer,
 * clock device on the CPU served by the specified
 * scheduler slot. This reveals a CPU affinity
 * mismatch between the clock hardware and the client
-* code initializing the timer.
+* code initializing the timer. This check excludes
+* core timers which may have their own reason to bind
+* to a passive CPU (e.g. host timer).
 */
-   XENO_WARN_ON_SMP(COBALT, !cpumask_test_cpu(xnsched_cpu(sched),
-  >affinity));
+   XENO_WARN_ON_SMP(COBALT, !(flags & __XNTIMER_CORE) &&
+!cpumask_test_cpu(xnsched_cpu(sched),
+  >affinity));
timer->sched = sched;
} else {
cpu = xnclock_get_default_cpu(clock, 0);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/traceobj: not all return values are status codes

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: a873e7dc93feaf20e97b358ab8193f5f3c7274d0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a873e7dc93feaf20e97b358ab8193f5f3c7274d0

Author: Philippe Gerum 
Date:   Tue Feb  9 11:49:19 2016 +0100

copperplate/traceobj: not all return values are status codes

---

 lib/copperplate/traceobj.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/copperplate/traceobj.c b/lib/copperplate/traceobj.c
index 8d4ee9b..40b74c6 100644
--- a/lib/copperplate/traceobj.c
+++ b/lib/copperplate/traceobj.c
@@ -222,8 +222,7 @@ void __traceobj_check_abort(struct traceobj *trobj,
 {
dump_marks_on_error(trobj);
panic("wrong return status:\n  %s:%d => %s (want %s)", 
file, line,
- symerror(received > 0 ? -received : received),
- symerror(expected > 0 ? -expected : expected));
+ symerror(received), symerror(expected));
 }
 
 void __traceobj_check_warn(struct traceobj *trobj,
@@ -232,8 +231,7 @@ void __traceobj_check_warn(struct traceobj *trobj,
 {
dump_marks_on_error(trobj);
warning("wrong return status:\n  %s:%d => %s (want %s)", 
file, line,
-   symerror(received > 0 ? -received : received),
-   symerror(expected > 0 ? -expected : expected));
+   symerror(received), symerror(expected));
 }
 
 void __traceobj_mark(struct traceobj *trobj,


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/umm: get UMM heaps from the normal zone

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 1be2d32881b5ac6b311ac87a1fad2b816aec225f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1be2d32881b5ac6b311ac87a1fad2b816aec225f

Author: Philippe Gerum 
Date:   Fri Mar  4 11:27:07 2016 +0100

cobalt/umm: get UMM heaps from the normal zone

---

 kernel/cobalt/posix/memory.c  |2 +-
 kernel/cobalt/posix/process.c |1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/cobalt/posix/memory.c b/kernel/cobalt/posix/memory.c
index 5304272..1d888a2 100644
--- a/kernel/cobalt/posix/memory.c
+++ b/kernel/cobalt/posix/memory.c
@@ -321,7 +321,7 @@ int cobalt_umm_init(struct cobalt_umm *umm, u32 size,
secondary_mode_only();
 
size = PAGE_ALIGN(size);
-   basemem = __vmalloc(size, GFP_KERNEL|__GFP_HIGHMEM|__GFP_ZERO,
+   basemem = __vmalloc(size, GFP_KERNEL|__GFP_ZERO,
xnarch_cache_aliasing() ?
pgprot_noncached(PAGE_KERNEL) : PAGE_KERNEL);
if (basemem == NULL)
diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
index 28fde9e..5c152e8 100644
--- a/kernel/cobalt/posix/process.c
+++ b/kernel/cobalt/posix/process.c
@@ -34,7 +34,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/thread: wait for RCU grace period after killall

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 248297b3e7ae5516140b836eda749099cbecd1f8
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=248297b3e7ae5516140b836eda749099cbecd1f8

Author: Philippe Gerum 
Date:   Wed Mar  2 15:09:11 2016 +0100

cobalt/thread: wait for RCU grace period after killall

---

 kernel/cobalt/thread.c |   17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index b758d50..7983165 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -1594,7 +1594,7 @@ static void grace_elapsed(struct rcu_head *head)
complete(>done);
 }
 
-static void wait_grace_period(struct pid *pid)
+static void wait_for_rcu_grace_period(struct pid *pid)
 {
struct wait_grace_struct wait = {
.done = COMPLETION_INITIALIZER_ONSTACK(wait.done),
@@ -1606,6 +1606,8 @@ static void wait_grace_period(struct pid *pid)
for (;;) {
call_rcu(, grace_elapsed);
wait_for_completion();
+   if (pid == NULL)
+   break;
rcu_read_lock();
p = pid_task(pid, PIDTYPE_PID);
rcu_read_unlock();
@@ -1724,7 +1726,7 @@ int xnthread_join(struct xnthread *thread, bool 
uninterruptible)
 * (__xnthread_cleanup), then waits for a full RCU grace
 * period to have elapsed. Since the completion signal is sent
 * on behalf of do_exit(), we may assume that the joinee has
-* scheduled away before the grace period ends.
+* scheduled away before the RCU grace period ends.
 */
if (uninterruptible)
wait_for_completion(>exited);
@@ -1737,7 +1739,7 @@ int xnthread_join(struct xnthread *thread, bool 
uninterruptible)
}
 
/* Make sure the joinee has scheduled away ultimately. */
-   wait_grace_period(pid);
+   wait_for_rcu_grace_period(pid);
 
put_pid(pid);
 done:
@@ -2632,10 +2634,10 @@ int xnthread_killall(int grace, int mask)
xnlock_put_irqrestore(, s);
 
/*
-* Cancel then join all existing user threads during the grace
+* Cancel then join all existing threads during the grace
 * period. It is the caller's responsibility to prevent more
-* user threads to bind to the system if required, we won't
-* make any provision for this here.
+* threads to bind to the system if required, we won't make
+* any provision for this here.
 */
count = nrthreads - nrkilled;
if (XENO_DEBUG(COBALT))
@@ -2652,6 +2654,9 @@ int xnthread_killall(int grace, int mask)
ret = wait_event_interruptible(join_all,
   cobalt_nrthreads == count);
 
+   /* Wait for a full RCU grace period to expire. */
+   wait_for_rcu_grace_period(NULL);
+
if (XENO_DEBUG(COBALT))
printk(XENO_INFO "joined %d threads\n",
   count + nrkilled - cobalt_nrthreads);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/ipc: xddp: get buffer memory from vmalloc()

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 19159de4b43204f8de40a7d8b3894404a6e5e51f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=19159de4b43204f8de40a7d8b3894404a6e5e51f

Author: Philippe Gerum 
Date:   Sun Feb 28 08:21:24 2016 +0100

drivers/ipc: xddp: get buffer memory from vmalloc()

---

 kernel/drivers/ipc/xddp.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/drivers/ipc/xddp.c b/kernel/drivers/ipc/xddp.c
index 9bd3644..a528061 100644
--- a/kernel/drivers/ipc/xddp.c
+++ b/kernel/drivers/ipc/xddp.c
@@ -19,11 +19,11 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include "internal.h"
 
@@ -206,7 +206,7 @@ static void __xddp_release_handler(void *skarg) /* nklock 
free */
poolmem = xnheap_get_membase(>privpool);
poolsz = xnheap_get_size(>privpool);
xnheap_destroy(>privpool);
-   free_pages_exact(poolmem, poolsz);
+   xnheap_vfree(poolmem);
} else if (sk->buffer)
xnfree(sk->buffer);
 
@@ -691,7 +691,7 @@ static int __xddp_bind_socket(struct rtipc_private *priv,
if (poolsz > 0) {
poolsz = xnheap_rounded_size(poolsz);
poolsz += xnheap_rounded_size(sk->reqbufsz);
-   poolmem = alloc_pages_exact(poolsz, GFP_KERNEL);
+   poolmem = xnheap_vmalloc(poolsz);
if (poolmem == NULL) {
ret = -ENOMEM;
goto fail;
@@ -699,7 +699,7 @@ static int __xddp_bind_socket(struct rtipc_private *priv,
 
ret = xnheap_init(>privpool, poolmem, poolsz);
if (ret) {
-   free_pages_exact(poolmem, poolsz);
+   xnheap_vfree(poolmem);
goto fail;
}
 
@@ -732,7 +732,7 @@ static int __xddp_bind_socket(struct rtipc_private *priv,
fail_freeheap:
if (poolsz > 0) {
xnheap_destroy(>privpool);
-   free_pages_exact(poolmem, poolsz);
+   xnheap_vfree(poolmem);
}
fail:
clear_bit(_XDDP_BINDING, >status);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/ipc: iddp: get buffer memory from vmalloc()

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: b721ca35558a0a813c60ca7d08e184515f0af421
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b721ca35558a0a813c60ca7d08e184515f0af421

Author: Philippe Gerum 
Date:   Sun Feb 28 08:20:45 2016 +0100

drivers/ipc: iddp: get buffer memory from vmalloc()

---

 kernel/drivers/ipc/iddp.c |9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/kernel/drivers/ipc/iddp.c b/kernel/drivers/ipc/iddp.c
index ed09f76..59508f6 100644
--- a/kernel/drivers/ipc/iddp.c
+++ b/kernel/drivers/ipc/iddp.c
@@ -20,7 +20,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -209,7 +208,7 @@ static void iddp_close(struct rtdm_fd *fd)
poolmem = xnheap_get_membase(>privpool);
poolsz = xnheap_get_size(>privpool);
xnheap_destroy(>privpool);
-   free_pages_exact(poolmem, poolsz);
+   xnheap_vfree(poolmem);
return;
}
 
@@ -567,7 +566,7 @@ static int __iddp_bind_socket(struct rtdm_fd *fd,
poolsz = sk->poolsz;
if (poolsz > 0) {
poolsz = xnheap_rounded_size(poolsz);
-   poolmem = alloc_pages_exact(poolsz, GFP_KERNEL);
+   poolmem = xnheap_vmalloc(poolsz);
if (poolmem == NULL) {
ret = -ENOMEM;
goto fail;
@@ -575,7 +574,7 @@ static int __iddp_bind_socket(struct rtdm_fd *fd,
 
ret = xnheap_init(>privpool, poolmem, poolsz);
if (ret) {
-   free_pages_exact(poolmem, poolsz);
+   xnheap_vfree(poolmem);
goto fail;
}
xnheap_set_name(>privpool, "iddp-pool@%d", port);
@@ -594,7 +593,7 @@ static int __iddp_bind_socket(struct rtdm_fd *fd,
if (ret) {
if (poolsz > 0) {
xnheap_destroy(>privpool);
-   free_pages_exact(poolmem, poolsz);
+   xnheap_vfree(poolmem);
}
goto fail;
}


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/kernel: WIP: convert to dovetail interface

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 58942170bc41f06b8d69da462c3a6ce23f0e2a97
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=58942170bc41f06b8d69da462c3a6ce23f0e2a97

Author: Philippe Gerum 
Date:   Tue Dec 29 10:15:25 2015 +0100

cobalt/kernel: WIP: convert to dovetail interface

This is work in progress, with more changes expected from the IRQ
pipeline and dovetail interfaces.

---

 include/cobalt/kernel/apc.h|4 +-
 include/cobalt/kernel/assert.h |4 +-
 include/cobalt/kernel/clock.h  |4 +-
 include/cobalt/kernel/intr.h   |   56 +--
 include/cobalt/kernel/lock.h   |2 +-
 include/cobalt/kernel/rtdm/driver.h|4 +-
 include/cobalt/kernel/sched.h  |4 +-
 include/cobalt/kernel/thread.h |4 +-
 include/cobalt/kernel/timer.h  |2 +
 kernel/cobalt/Kconfig  |2 +-
 kernel/cobalt/apc.c|8 +-
 .../cobalt/arch/arm/include/asm/xenomai/machine.h  |2 -
 .../cobalt/arch/arm/include/asm/xenomai/thread.h   |   11 +-
 kernel/cobalt/arch/arm/machine.c   |   56 ---
 kernel/cobalt/arch/arm/mayday.c|1 -
 kernel/cobalt/arch/arm/syscall.c   |   14 +-
 kernel/cobalt/arch/arm/thread.c|5 +-
 .../arch/arm64/include/asm/xenomai/machine.h   |2 -
 .../cobalt/arch/arm64/include/asm/xenomai/thread.h |9 +-
 kernel/cobalt/arch/arm64/machine.c |   56 ---
 kernel/cobalt/arch/arm64/mayday.c  |1 -
 kernel/cobalt/arch/arm64/syscall.c |   13 +-
 kernel/cobalt/arch/arm64/thread.c  |3 +-
 .../arch/blackfin/include/asm/xenomai/machine.h|2 -
 .../arch/blackfin/include/asm/xenomai/thread.h |3 +-
 kernel/cobalt/arch/blackfin/machine.c  |6 -
 kernel/cobalt/arch/blackfin/mayday.c   |1 -
 kernel/cobalt/arch/blackfin/thread.c   |3 +-
 .../arch/powerpc/include/asm/xenomai/machine.h |2 -
 .../arch/powerpc/include/asm/xenomai/thread.h  |5 +-
 kernel/cobalt/arch/powerpc/machine.c   |6 -
 kernel/cobalt/arch/powerpc/mayday.c|1 -
 kernel/cobalt/arch/powerpc/thread.c|1 -
 .../arch/x86/include/asm/xenomai/calibration.h |4 +-
 .../cobalt/arch/x86/include/asm/xenomai/machine.h  |2 -
 .../arch/x86/include/asm/xenomai/syscall32.h   |4 +-
 .../cobalt/arch/x86/include/asm/xenomai/thread.h   |5 +-
 kernel/cobalt/arch/x86/machine.c   |   36 --
 kernel/cobalt/arch/x86/mayday.c|1 -
 kernel/cobalt/arch/x86/thread.c|4 +-
 kernel/cobalt/clock.c  |   24 +-
 .../cobalt/include/asm-generic/xenomai/machine.h   |   12 +-
 .../include/{ipipe => dovetail}/thread_info.h  |   11 +-
 kernel/cobalt/init.c   |  118 +++---
 kernel/cobalt/intr.c   |  448 
 kernel/cobalt/posix/corectl.c  |4 +-
 kernel/cobalt/posix/process.c  |   85 ++--
 kernel/cobalt/posix/process.h  |4 +-
 kernel/cobalt/posix/syscall.c  |   28 +-
 kernel/cobalt/rtdm/drvlib.c|6 +-
 kernel/cobalt/rtdm/fd.c|   12 +-
 kernel/cobalt/sched.c  |   56 +--
 kernel/cobalt/thread.c |   39 +-
 kernel/cobalt/timer.c  |  374 +++-
 kernel/cobalt/trace/cobalt-core.h  |2 +-
 scripts/Kconfig.frag   |3 +-
 scripts/prepare-kernel.sh  |8 +-
 57 files changed, 617 insertions(+), 970 deletions(-)

diff --git a/include/cobalt/kernel/apc.h b/include/cobalt/kernel/apc.h
index 7075ad0..1ed88b4 100644
--- a/include/cobalt/kernel/apc.h
+++ b/include/cobalt/kernel/apc.h
@@ -19,7 +19,7 @@
 #ifndef _COBALT_KERNEL_APC_H
 #define _COBALT_KERNEL_APC_H
 
-#include 
+#include 
 #include 
 
 /**
@@ -72,7 +72,7 @@ static inline void xnapc_schedule(int apc)
ipipe_restore_head(flags);
 }
 
-void apc_dispatch(unsigned int virq, void *arg);
+irqreturn_t apc_dispatch(int virq, void *dev_id);
 
 /** @} */
 
diff --git a/include/cobalt/kernel/assert.h b/include/cobalt/kernel/assert.h
index 2d2d653..4434571 100644
--- a/include/cobalt/kernel/assert.h
+++ b/include/cobalt/kernel/assert.h
@@ -57,8 +57,8 @@
do { } while (0)
 #endif
 
-#define primary_mode_only()XENO_BUG_ON(CONTEXT, ipipe_root_p)
-#define secondary_mode_only()  XENO_BUG_ON(CONTEXT, !ipipe_root_p)
+#define primary_mode_only()XENO_BUG_ON(CONTEXT, on_root_stage())

[Xenomai-git] Jan Kiszka : cobalt/posix/timer: Return interval value also for stopped timers

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 4b4cef058787c4457ffaa899f6fa086d1947d59e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4b4cef058787c4457ffaa899f6fa086d1947d59e

Author: Jan Kiszka 
Date:   Mon Feb 22 18:34:44 2016 +0100

cobalt/posix/timer: Return interval value also for stopped timers

If a timer is not running, it may still have a non-null interval value.
This has to be returned according to the standard.

Signed-off-by: Jan Kiszka 

---

 kernel/cobalt/posix/timer.c |   10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/kernel/cobalt/posix/timer.c b/kernel/cobalt/posix/timer.c
index 5e77454..cf1c919 100644
--- a/kernel/cobalt/posix/timer.c
+++ b/kernel/cobalt/posix/timer.c
@@ -268,16 +268,14 @@ out:
 void __cobalt_timer_getval(struct xntimer *__restrict__ timer,
   struct itimerspec *__restrict__ value)
 {
+   ns2ts(>it_interval, xntimer_interval(timer));
+
if (!xntimer_running_p(timer)) {
value->it_value.tv_sec = 0;
value->it_value.tv_nsec = 0;
-   value->it_interval.tv_sec = 0;
-   value->it_interval.tv_nsec = 0;
-   return;
+   } else {
+   ns2ts(>it_value, xntimer_get_timeout(timer));
}
-
-   ns2ts(>it_value, xntimer_get_timeout(timer));
-   ns2ts(>it_interval, xntimer_interval(timer));
 }
 
 static inline void


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib/smokey: add --exclude switch for dropping tests from the run list

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 77ce3c54c295924d720548b3d831ab3eae055caa
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=77ce3c54c295924d720548b3d831ab3eae055caa

Author: Philippe Gerum 
Date:   Fri Feb 26 11:13:12 2016 +0100

lib/smokey: add --exclude switch for dropping tests from the run list

---

 lib/smokey/init.c |  129 ++---
 1 file changed, 104 insertions(+), 25 deletions(-)

diff --git a/lib/smokey/init.c b/lib/smokey/init.c
index 403aa72..0db3ec9 100644
--- a/lib/smokey/init.c
+++ b/lib/smokey/init.c
@@ -158,7 +158,8 @@
  *   host program.  The test driver code (e.g. implementing a test
  *   harness program on top of Smokey) may then iterate over the @a
  *   smokey_test_list for accessing each active test individually, in
- *   the enumeration order specified by the user.
+ *   the enumeration order specified by the user (Use
+ *   for_each_smokey_test() for that).
  *
  *   If no argument is passed to --run, Smokey assumes that all tests
  *   detected in the current program should be picked, filling @a
@@ -179,6 +180,10 @@
  * last test defined
  *   - fo* picks any test with a name starting by "fo"
  *
+ * - --exclude= excludes the given tests from the test
+ *   list. The format of the argument is identical to the one accepted
+ *   by the --run option.
+ *
  * - --keep-going sets the boolean flag @a smokey_keep_going to a
  *   non-zero value, indicating to the test driver that receiving a
  *   failure code from a smoke test should not abort the test loop.
@@ -262,10 +267,18 @@ int smokey_on_vm = 0;
 
 static DEFINE_PRIVATE_LIST(register_list);
 
+static DEFINE_PRIVATE_LIST(exclude_list);
+
+static char *include_arg;
+
+static char *exclude_arg;
+
 static int test_count;
 
 static int do_list;
 
+static int do_run;
+
 static const struct option smokey_options[] = {
{
 #define keep_going_opt 0
@@ -278,6 +291,8 @@ static const struct option smokey_options[] = {
 #define run_opt1
.name = "run",
.has_arg = optional_argument,
+   .flag = _run,
+   .val = 1,
},
{
 #define list_opt   2
@@ -293,6 +308,11 @@ static const struct option smokey_options[] = {
.flag = _on_vm,
.val = 1,
},
+   {
+#define exclude_opt4
+   .name = "exclude",
+   .has_arg = required_argument,
+   },
{ /* Sentinel */ }
 };
 
@@ -301,10 +321,11 @@ static void smokey_help(void)
 fprintf(stderr, "--keep-going  don't stop upon test 
error\n");
fprintf(stderr, "--list list all tests\n");
fprintf(stderr, "--run[=]]  run [portion of] the 
test list\n");
+   fprintf(stderr, "--exclude=]exclude test(s) from 
the run list\n");
fprintf(stderr, "--vm   hint about running in a 
virtual environment\n");
 }
 
-static inline void pick_test_range(int start, int end)
+static void pick_test_range(int start, int end)
 {
struct smokey_test *t, *tmp;
 
@@ -329,6 +350,24 @@ static inline void pick_test_range(int start, int end)
} 
 }
 
+static void drop_test_range(int start, int end)
+{
+   struct smokey_test *t, *tmp;
+
+   /*
+* Drop tests from the register list so that we won't find
+* them when applying the inclusion filter next, order is not
+* significant.
+*/
+   pvlist_for_each_entry_safe(t, tmp, _list, __reserved.next) {
+   if (t->__reserved.id >= start &&
+   t->__reserved.id <= end) {
+   pvlist_remove(>__reserved.next);
+   pvlist_append(>__reserved.next, _list);
+   }
+   }
+}
+
 static int resolve_id(const char *s)
 {
struct smokey_test *t;
@@ -353,7 +392,7 @@ static int resolve_id(const char *s)
return -1;
 }
 
-static int glob_match(const char *s)
+static int do_glob_match(const char *s, struct pvlistobj *list)
 {
struct smokey_test *t, *tmp;
int matches = 0;
@@ -364,7 +403,7 @@ static int glob_match(const char *s)
pvlist_for_each_entry_safe(t, tmp, _list, __reserved.next) {
if (!fnmatch(s, t->name, FNM_PATHNAME)) {
pvlist_remove(>__reserved.next);
-   pvlist_append(>__reserved.next, _test_list);
+   pvlist_append(>__reserved.next, list);
matches++;
}
}
@@ -372,7 +411,19 @@ static int glob_match(const char *s)
return matches;
 }
 
-static int build_test_list(const char *test_enum)
+static int glob_match_include(const char *s)
+{
+   return do_glob_match(s, _test_list);
+}
+
+static int glob_match_exclude(const char *s)
+{
+   return do_glob_match(s, _list);
+}
+
+static int 

[Xenomai-git] Philippe Gerum : boilerplate: more helpers to retrieve various CPU information

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 28657fd7fc1b57ede0d35ac179c368d96c0ea543
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=28657fd7fc1b57ede0d35ac179c368d96c0ea543

Author: Philippe Gerum 
Date:   Fri Feb 26 15:55:09 2016 +0100

boilerplate: more helpers to retrieve various CPU information

---

 include/boilerplate/ancillaries.h |7 ++
 lib/boilerplate/ancillaries.c |  138 +
 2 files changed, 145 insertions(+)

diff --git a/include/boilerplate/ancillaries.h 
b/include/boilerplate/ancillaries.h
index 6b87f0c..77d7305 100644
--- a/include/boilerplate/ancillaries.h
+++ b/include/boilerplate/ancillaries.h
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -108,6 +109,12 @@ void error_hook(struct error_frame *ef);
 
 int get_static_cpu_count(void);
 
+int get_online_cpu_set(cpu_set_t *cpuset);
+  
+int get_realtime_cpu_set(cpu_set_t *cpuset);
+
+int get_current_cpu(void);
+   
 pid_t get_thread_pid(void);
 
 char *lookup_command(const char *cmd);
diff --git a/lib/boilerplate/ancillaries.c b/lib/boilerplate/ancillaries.c
index 848adc7..a811a40 100644
--- a/lib/boilerplate/ancillaries.c
+++ b/lib/boilerplate/ancillaries.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -293,6 +294,143 @@ int get_static_cpu_count(void)
return count;
 }
 
+static int __get_online_cpus_from_proc(cpu_set_t *cpuset)
+{
+   char buf[BUFSIZ];
+   FILE *fp;
+   int cpu;
+
+   /* If no hotplug support, fall back to reading /proc/stat. */
+
+   fp = fopen("/proc/stat", "r");
+   if (fp == NULL)
+   return -ENOENT;
+
+   while (fgets(buf, sizeof(buf), fp)) {
+   /*
+* Like the glibc, assume cpu* entries are at the
+* front of /proc/stat and will stay this way.
+*/
+   if (strncmp(buf, "cpu", 3))
+   break;
+   if (!isdigit(buf[3]))
+   continue;
+   cpu = atoi(buf + 3);
+   if (cpu >= 0 && cpu < CPU_SETSIZE)
+   CPU_SET(cpu, cpuset);
+   }
+
+   fclose(fp);
+
+   return 0;
+}
+
+int get_online_cpu_set(cpu_set_t *cpuset)
+{
+   char buf[BUFSIZ], *range, *save_range, *save_bound,
+   *lo_bound, *hi_bound, *p;
+   int cpu_lo, cpu_hi;
+   FILE *fp;
+
+   CPU_ZERO(cpuset);
+
+   fp = fopen("/sys/devices/system/cpu/online", "r");
+   if (fp == NULL)
+   return __get_online_cpus_from_proc(cpuset);
+
+   if (fgets(buf, sizeof(buf), fp) == NULL) {
+   fclose(fp);
+   return -EBADF;
+   }
+
+   p = buf;
+   for (;;) {
+   range = strtok_r(p, " \t", _range);
+   if (range == NULL)
+   break;
+   lo_bound = strtok_r(range, "-", _bound);
+   if (lo_bound) {
+   cpu_lo = atoi(lo_bound);
+   hi_bound = strtok_r(NULL, "-", _bound);
+   if (hi_bound) {
+   cpu_hi = atoi(hi_bound);
+   do {
+   CPU_SET(cpu_lo, cpuset);
+   } while (cpu_lo++ < cpu_hi);
+   } else 
+   CPU_SET(cpu_lo, cpuset);
+   }
+   p = NULL;
+   }
+
+   fclose(fp);
+
+   return 0;
+}
+
+#ifdef CONFIG_XENO_COBALT
+
+#include 
+
+int get_realtime_cpu_set(cpu_set_t *cpuset)
+{
+   unsigned long long cpumask;
+   char buf[BUFSIZ], *p;
+   FILE *fp;
+   int cpu;
+
+   fp = fopen("/sys/module/xenomai/parameters/supported_cpus", "r");
+   if (fp == NULL)
+   return -ENOENT;
+
+   p = fgets(buf, sizeof(buf), fp);
+   fclose(fp);
+   if (p == NULL)
+   return -EBADF;
+
+   errno = 0;
+   cpumask = strtoll(p, NULL, 10);
+   if (cpumask == LLONG_MAX && errno == ERANGE)
+   cpumask = ULLONG_MAX;
+   for (cpu = 0; cpumask != 0; cpu++, cpumask >>= 1) {
+   if (cpumask & 1ULL)
+   CPU_SET(cpu, cpuset);
+   }
+
+   return 0;
+}
+
+int get_current_cpu(void) /* No mode migration */
+{
+   struct cobalt_threadstat stat;
+   int ret;
+
+   ret = cobalt_thread_stat(0, );
+   if (ret)
+   return ret;
+
+   return stat.cpu;
+}
+
+#else  /* CONFIG_XENO_MERCURY */
+
+int get_realtime_cpu_set(cpu_set_t *cpuset)
+{
+   return get_online_cpu_set(cpuset);
+}
+
+int get_current_cpu(void) 
+{
+   int cpu = sched_getcpu();
+
+   if (cpu < 0)
+   return -errno;
+
+   return cpu;
+}
+
+#endif  /* CONFIG_XENO_MERCURY */
+
 pid_t get_thread_pid(void)
 {
return syscall(__NR_gettid);



[Xenomai-git] Jan Kiszka : cobalt/posix/timer: Remove redundant test for stopped timers

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: f17508d9e049477c8aec8e2e0ba38cf8a87e33fb
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f17508d9e049477c8aec8e2e0ba38cf8a87e33fb

Author: Jan Kiszka 
Date:   Mon Feb 22 18:28:27 2016 +0100

cobalt/posix/timer: Remove redundant test for stopped timers

__cobalt_timer_getval already checks this.

Signed-off-by: Jan Kiszka 

---

 kernel/cobalt/posix/timer.c |8 
 1 file changed, 8 deletions(-)

diff --git a/kernel/cobalt/posix/timer.c b/kernel/cobalt/posix/timer.c
index b4cd511..5e77454 100644
--- a/kernel/cobalt/posix/timer.c
+++ b/kernel/cobalt/posix/timer.c
@@ -290,14 +290,6 @@ timer_gettimeout(struct cobalt_timer *__restrict__ timer,
  ret, value) && ret != 0)
return;
 
-   if (!xntimer_running_p(>timerbase)) {
-   value->it_value.tv_sec = 0;
-   value->it_value.tv_nsec = 0;
-   value->it_interval.tv_sec = 0;
-   value->it_interval.tv_nsec = 0;
-   return;
-   }
-
__cobalt_timer_getval(>timerbase, value);
 }
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/ipc: bufp: get buffer memory from vmalloc()

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 5ddefc0c9641b237bab674cf2f8a3c61bb21627f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5ddefc0c9641b237bab674cf2f8a3c61bb21627f

Author: Philippe Gerum 
Date:   Sun Feb 28 08:19:47 2016 +0100

drivers/ipc: bufp: get buffer memory from vmalloc()

---

 kernel/drivers/ipc/bufp.c |9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/kernel/drivers/ipc/bufp.c b/kernel/drivers/ipc/bufp.c
index ecce4f9..6fc51d4 100644
--- a/kernel/drivers/ipc/bufp.c
+++ b/kernel/drivers/ipc/bufp.c
@@ -20,12 +20,11 @@
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include "internal.h"
 
@@ -149,7 +148,7 @@ static void bufp_close(struct rtdm_fd *fd)
xnregistry_remove(sk->handle);
 
if (sk->bufmem)
-   free_pages_exact(sk->bufmem, sk->bufsz);
+   xnheap_vfree(sk->bufmem);
 
kfree(sk);
 }
@@ -704,7 +703,7 @@ static int __bufp_bind_socket(struct rtipc_private *priv,
if (sk->bufsz == 0)
return -ENOBUFS;
 
-   sk->bufmem = alloc_pages_exact(sk->bufsz, GFP_KERNEL);
+   sk->bufmem = xnheap_vmalloc(sk->bufsz);
if (sk->bufmem == NULL) {
ret = -ENOMEM;
goto fail;
@@ -719,7 +718,7 @@ static int __bufp_bind_socket(struct rtipc_private *priv,
ret = xnregistry_enter(sk->label, sk,
   >handle, &__bufp_pnode.node);
if (ret) {
-   free_pages_exact(sk->bufmem, sk->bufsz);
+   xnheap_vfree(sk->bufmem);
goto fail;
}
}


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/posix/signal: get buffer memory from vmalloc()

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: dcc8576834e9302094a4f2ad60af80f9586d504c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=dcc8576834e9302094a4f2ad60af80f9586d504c

Author: Philippe Gerum 
Date:   Sun Feb 28 08:17:30 2016 +0100

cobalt/posix/signal: get buffer memory from vmalloc()

---

 kernel/cobalt/posix/signal.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/posix/signal.c b/kernel/cobalt/posix/signal.c
index d6cda8e..dc16bc8 100644
--- a/kernel/cobalt/posix/signal.c
+++ b/kernel/cobalt/posix/signal.c
@@ -593,7 +593,7 @@ __init int cobalt_signal_init(void)
 {
struct cobalt_sigpending *sigp;
 
-   sigpending_mem = alloc_pages_exact(__SIGPOOL_SIZE, GFP_KERNEL);
+   sigpending_mem = xnheap_vmalloc(__SIGPOOL_SIZE);
if (sigpending_mem == NULL)
return -ENOMEM;
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib/smokey: add timed wait on barrier

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 038bed1b65bc2830bf91b945e9adde1e0c396fda
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=038bed1b65bc2830bf91b945e9adde1e0c396fda

Author: Philippe Gerum 
Date:   Fri Feb 26 18:38:24 2016 +0100

lib/smokey: add timed wait on barrier

Add this chance, fix a potential UMR in smokey_barrier_wait().

---

 include/smokey/smokey.h |3 +++
 lib/smokey/helpers.c|   20 +++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/include/smokey/smokey.h b/include/smokey/smokey.h
index 82e2b64..8351563 100644
--- a/include/smokey/smokey.h
+++ b/include/smokey/smokey.h
@@ -226,6 +226,9 @@ void smokey_barrier_destroy(struct smokey_barrier *b);
 
 int smokey_barrier_wait(struct smokey_barrier *b);
 
+int smokey_barrier_timedwait(struct smokey_barrier *b,
+struct timespec *ts);
+  
 void smokey_barrier_release(struct smokey_barrier *b);

 #ifdef __cplusplus
diff --git a/lib/smokey/helpers.c b/lib/smokey/helpers.c
index b52afed..2b9985d 100644
--- a/lib/smokey/helpers.c
+++ b/lib/smokey/helpers.c
@@ -199,7 +199,7 @@ void smokey_barrier_destroy(struct smokey_barrier *b)
 
 int smokey_barrier_wait(struct smokey_barrier *b)
 {
-   int ret;
+   int ret = 0;

__RT(pthread_mutex_lock(>lock));
 
@@ -214,6 +214,24 @@ int smokey_barrier_wait(struct smokey_barrier *b)
return ret;
 }
 
+int smokey_barrier_timedwait(struct smokey_barrier *b, struct timespec *ts)
+{
+   int ret = 0;
+   
+   __RT(pthread_mutex_lock(>lock));
+
+   while (!b->signaled) {
+   ret = __RT(pthread_cond_timedwait(>barrier,
+ >lock, ts));
+   if (ret)
+   break;
+   }
+
+   __RT(pthread_mutex_unlock(>lock));
+
+   return ret;
+}
+
 void smokey_barrier_release(struct smokey_barrier *b)
 {
__RT(pthread_mutex_lock(>lock));


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib/smokey: add common assertion helpers

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: e080bbaa0bb021f05f65b3a80e618bf24582afd2
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e080bbaa0bb021f05f65b3a80e618bf24582afd2

Author: Philippe Gerum 
Date:   Wed Feb 24 16:32:17 2016 +0100

lib/smokey: add common assertion helpers

---

 include/smokey/smokey.h |   54 +++
 1 file changed, 54 insertions(+)

diff --git a/include/smokey/smokey.h b/include/smokey/smokey.h
index d3c9987..82e2b64 100644
--- a/include/smokey/smokey.h
+++ b/include/smokey/smokey.h
@@ -133,6 +133,60 @@ struct smokey_test {
 #define smokey_warning(__fmt, __args...)   \
__smokey_warning(__FILE__, __LINE__, __fmt, ##__args)
 
+#define __T(__ret, __action)   \
+   ({  \
+   (__ret) = (__action);   \
+   if (__ret) {\
+   if ((__ret) > 0)\
+   (__ret) = -(__ret); \
+   smokey_warning("FAILED: %s (=%s)",  \
+  __stringify(__action),   \
+  symerror(__ret));\
+   }   \
+   (__ret) == 0;   \
+   })
+
+#define __F(__ret, __action)   \
+   ({  \
+   (__ret) = (__action);   \
+   if ((__ret) == 0)   \
+   smokey_warning("FAILED: %s (=0)",   \
+  __stringify(__action));  \
+   else if ((__ret) > 0)   \
+   (__ret) = -(__ret); \
+   (__ret) != 0;   \
+   })
+
+#define __Terrno(__ret, __action)  \
+   ({  \
+   (__ret) = (__action);   \
+   if (__ret) {\
+   (__ret) = -errno;   \
+   smokey_warning("FAILED: %s (=%s)",  \
+  __stringify(__action),   \
+  symerror(__ret));\
+   }   \
+   (__ret) == 0;   \
+   })
+
+#define __Tassert(__expr)  \
+   ({  \
+   int __ret = !!(__expr); \
+   if (!__ret) \
+   smokey_warning("FAILED: %s (=false)",   \
+  __stringify(__expr));\
+   __ret;  \
+   })
+
+#define __Fassert(__expr)  \
+   ({  \
+   int __ret = (__expr);   \
+   if (__ret)  \
+   smokey_warning("FAILED: %s (=true)",\
+  __stringify(__expr));\
+   !__ret; \
+   })
+
 struct smokey_barrier {
pthread_mutex_t lock;
pthread_cond_t barrier;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/init: get system heap from the normal zone

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 4f9655d6d5a32985fa582ddf47fe7529bf28f567
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4f9655d6d5a32985fa582ddf47fe7529bf28f567

Author: Philippe Gerum 
Date:   Fri Mar  4 11:26:39 2016 +0100

cobalt/init: get system heap from the normal zone

---

 kernel/cobalt/init.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/cobalt/init.c b/kernel/cobalt/init.c
index 6cbb67b..5a6fdbf 100644
--- a/kernel/cobalt/init.c
+++ b/kernel/cobalt/init.c
@@ -18,7 +18,6 @@
  */
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -156,7 +155,7 @@ static void sys_shutdown(void)
xnregistry_cleanup();
membase = xnheap_get_membase(_heap);
xnheap_destroy(_heap);
-   vfree(membase);
+   xnheap_vfree(membase);
 }
 
 static int __init mach_setup(void)
@@ -289,7 +288,7 @@ static __init int sys_init(void)
if (sysheap_size_arg == 0)
sysheap_size_arg = CONFIG_XENO_OPT_SYS_HEAPSZ;
 
-   heapaddr = vmalloc(sysheap_size_arg * 1024);
+   heapaddr = xnheap_vmalloc(sysheap_size_arg * 1024);
if (heapaddr == NULL ||
xnheap_init(_heap, heapaddr, sysheap_size_arg * 1024)) {
return -ENOMEM;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/umm: get UMM heaps from the normal zone

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 1be2d32881b5ac6b311ac87a1fad2b816aec225f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1be2d32881b5ac6b311ac87a1fad2b816aec225f

Author: Philippe Gerum 
Date:   Fri Mar  4 11:27:07 2016 +0100

cobalt/umm: get UMM heaps from the normal zone

---

 kernel/cobalt/posix/memory.c  |2 +-
 kernel/cobalt/posix/process.c |1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/cobalt/posix/memory.c b/kernel/cobalt/posix/memory.c
index 5304272..1d888a2 100644
--- a/kernel/cobalt/posix/memory.c
+++ b/kernel/cobalt/posix/memory.c
@@ -321,7 +321,7 @@ int cobalt_umm_init(struct cobalt_umm *umm, u32 size,
secondary_mode_only();
 
size = PAGE_ALIGN(size);
-   basemem = __vmalloc(size, GFP_KERNEL|__GFP_HIGHMEM|__GFP_ZERO,
+   basemem = __vmalloc(size, GFP_KERNEL|__GFP_ZERO,
xnarch_cache_aliasing() ?
pgprot_noncached(PAGE_KERNEL) : PAGE_KERNEL);
if (basemem == NULL)
diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
index 28fde9e..5c152e8 100644
--- a/kernel/cobalt/posix/process.c
+++ b/kernel/cobalt/posix/process.c
@@ -34,7 +34,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/init: get system heap from the normal zone

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 1e3bf2f96b54b75b2f8764beb4f1ead70a4ffbb0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1e3bf2f96b54b75b2f8764beb4f1ead70a4ffbb0

Author: Philippe Gerum 
Date:   Fri Mar  4 11:26:39 2016 +0100

cobalt/init: get system heap from the normal zone

---

 kernel/cobalt/init.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/cobalt/init.c b/kernel/cobalt/init.c
index 6cbb67b..5a6fdbf 100644
--- a/kernel/cobalt/init.c
+++ b/kernel/cobalt/init.c
@@ -18,7 +18,6 @@
  */
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -156,7 +155,7 @@ static void sys_shutdown(void)
xnregistry_cleanup();
membase = xnheap_get_membase(_heap);
xnheap_destroy(_heap);
-   vfree(membase);
+   xnheap_vfree(membase);
 }
 
 static int __init mach_setup(void)
@@ -289,7 +288,7 @@ static __init int sys_init(void)
if (sysheap_size_arg == 0)
sysheap_size_arg = CONFIG_XENO_OPT_SYS_HEAPSZ;
 
-   heapaddr = vmalloc(sysheap_size_arg * 1024);
+   heapaddr = xnheap_vmalloc(sysheap_size_arg * 1024);
if (heapaddr == NULL ||
xnheap_init(_heap, heapaddr, sysheap_size_arg * 1024)) {
return -ENOMEM;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/umm: get UMM heaps from the normal zone

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: b34fa9d81f55127b42c000a87d09bb14b17c3e39
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b34fa9d81f55127b42c000a87d09bb14b17c3e39

Author: Philippe Gerum 
Date:   Fri Mar  4 11:27:07 2016 +0100

cobalt/umm: get UMM heaps from the normal zone

---

 kernel/cobalt/posix/memory.c  |2 +-
 kernel/cobalt/posix/process.c |1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/cobalt/posix/memory.c b/kernel/cobalt/posix/memory.c
index 5304272..1d888a2 100644
--- a/kernel/cobalt/posix/memory.c
+++ b/kernel/cobalt/posix/memory.c
@@ -321,7 +321,7 @@ int cobalt_umm_init(struct cobalt_umm *umm, u32 size,
secondary_mode_only();
 
size = PAGE_ALIGN(size);
-   basemem = __vmalloc(size, GFP_KERNEL|__GFP_HIGHMEM|__GFP_ZERO,
+   basemem = __vmalloc(size, GFP_KERNEL|__GFP_ZERO,
xnarch_cache_aliasing() ?
pgprot_noncached(PAGE_KERNEL) : PAGE_KERNEL);
if (basemem == NULL)
diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
index 28fde9e..5c152e8 100644
--- a/kernel/cobalt/posix/process.c
+++ b/kernel/cobalt/posix/process.c
@@ -34,7 +34,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/kernel: raise default sysheap size to 512 Kb

2016-03-06 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: af2e279b89554fb805b8d94c61fef4dd949bff56
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=af2e279b89554fb805b8d94c61fef4dd949bff56

Author: Philippe Gerum 
Date:   Fri Mar  4 17:59:16 2016 +0100

cobalt/kernel: raise default sysheap size to 512 Kb

---

 kernel/cobalt/Kconfig |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/Kconfig b/kernel/cobalt/Kconfig
index afa62d2..24f09e8 100644
--- a/kernel/cobalt/Kconfig
+++ b/kernel/cobalt/Kconfig
@@ -257,7 +257,7 @@ config XENO_OPT_REGISTRY_NRSLOTS
 
 config XENO_OPT_SYS_HEAPSZ
int "Size of system heap (Kb)"
-   default 256
+   default 512
help
The system heap is used for various internal allocations by
the Cobalt kernel. The size is expressed in Kilobytes.


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git