[Xenomai-git] Philippe Gerum : lib/cobalt/mutex: add support for priority ceiling protocol

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: a69b5a0a0d678006b1b0405501815e28945c188a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a69b5a0a0d678006b1b0405501815e28945c188a

Author: Philippe Gerum 
Date:   Tue Feb 16 10:13:03 2016 +0100

lib/cobalt/mutex: add support for priority ceiling protocol

---

 configure.ac   |2 +
 include/boilerplate/libc.h |   19 +++
 include/cobalt/pthread.h   |7 ++
 lib/cobalt/cobalt.wrappers |2 +
 lib/cobalt/init.c  |1 +
 lib/cobalt/internal.h  |8 ++
 lib/cobalt/mutex.c |  292 +++-
 lib/cobalt/sched.c |   33 -
 lib/cobalt/thread.c|7 +-
 9 files changed, 306 insertions(+), 65 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9eeb34d..c9d0fcf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -511,6 +511,8 @@ save_LIBS="$LIBS"
 LIBS="$LIBS -lrt -lpthread"
 AC_CHECK_FUNCS([pthread_mutexattr_setprotocol  \
pthread_mutexattr_getprotocol   \
+   pthread_mutexattr_getprioceiling \
+   pthread_mutexattr_setprioceiling \
pthread_mutexattr_setrobust_np  \
pthread_condattr_getclock   \
pthread_condattr_setclock   \
diff --git a/include/boilerplate/libc.h b/include/boilerplate/libc.h
index 134176e..80ababf 100644
--- a/include/boilerplate/libc.h
+++ b/include/boilerplate/libc.h
@@ -108,6 +108,25 @@ int pthread_mutexattr_getprotocol(const 
pthread_mutexattr_t *
 }
 #endif /* !HAVE_PTHREAD_MUTEXATTR_GETPROTOCOL */
 
+#ifndef HAVE_PTHREAD_MUTEXATTR_SETPRIOCEILING
+static inline
+int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr,
+int prioceiling)
+{
+   return ENOSYS;
+}
+#endif /* !HAVE_PTHREAD_MUTEXATTR_SETPRIOCEILING */
+
+#ifndef HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING
+static inline
+int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *
+ __restrict attr,
+int *__restrict prioceiling)
+{
+   return ENOSYS;
+}
+#endif /* !HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING */
+
 #ifndef HAVE_PTHREAD_ATTR_SETAFFINITY_NP
 #include 
 static inline
diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h
index 386c337..f1b1c8a 100644
--- a/include/cobalt/pthread.h
+++ b/include/cobalt/pthread.h
@@ -67,6 +67,13 @@ COBALT_DECL(int, pthread_mutex_trylock(pthread_mutex_t 
*mutex));
 
 COBALT_DECL(int, pthread_mutex_unlock(pthread_mutex_t *mutex));
 
+COBALT_DECL(int, pthread_mutex_setprioceiling(pthread_mutex_t *__restrict 
mutex,
+ int prioceiling,
+ int *__restrict old_ceiling));
+  
+COBALT_DECL(int, pthread_mutex_getprioceiling(pthread_mutex_t *__restrict 
mutex,
+ int *__restrict old_ceiling));
+
 COBALT_DECL(int, pthread_cond_init (pthread_cond_t *cond,
const pthread_condattr_t *attr));
 
diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers
index 0378abf..4f883f3 100644
--- a/lib/cobalt/cobalt.wrappers
+++ b/lib/cobalt/cobalt.wrappers
@@ -32,6 +32,8 @@
 --wrap pthread_mutex_trylock
 --wrap pthread_mutex_timedlock
 --wrap pthread_mutex_unlock
+--wrap pthread_mutex_setprioceiling
+--wrap pthread_mutex_getprioceiling
 --wrap pthread_cond_init
 --wrap pthread_cond_destroy
 --wrap pthread_cond_wait
diff --git a/lib/cobalt/init.c b/lib/cobalt/init.c
index f260744..69d4763 100644
--- a/lib/cobalt/init.c
+++ b/lib/cobalt/init.c
@@ -177,6 +177,7 @@ static void __cobalt_init(void)
sizeof(struct cobalt_sem_shadow));
 
cobalt_mutex_init();
+   cobalt_sched_init();
cobalt_thread_init();
cobalt_print_init();
 }
diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
index df1f7c0..3241e9b 100644
--- a/lib/cobalt/internal.h
+++ b/lib/cobalt/internal.h
@@ -57,6 +57,8 @@ void cobalt_thread_init(void);
 
 int cobalt_thread_probe(pid_t pid);
 
+void cobalt_sched_init(void);
+
 void cobalt_print_init(void);
 
 void cobalt_print_init_atfork(void);
@@ -78,4 +80,10 @@ void cobalt_check_features(struct cobalt_featinfo *finfo);
 
 extern struct sigaction __cobalt_orig_sigdebug;
 
+extern int __cobalt_std_fifo_minpri,
+  __cobalt_std_fifo_maxpri;
+
+extern int __cobalt_std_rr_minpri,
+  __cobalt_std_rr_maxpri;
+
 #endif /* _LIB_COBALT_INTERNAL_H */
diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c
index c98d2ea..f066ea3 100644
--- a/lib/cobalt/mutex.c
+++ b/lib/cobalt/mutex.c
@@ -99,6 +99,9 @@ void cobalt_mutex_init(void)
  *   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.
+ * - ENOSYS, @a attr mentions 

[Xenomai-git] Philippe Gerum : cobalt/arm64: drop aarch32 bits from feature set

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: d31f6ef5009f5e0aea235d677cac2c3a8513ec97
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d31f6ef5009f5e0aea235d677cac2c3a8513ec97

Author: Philippe Gerum 
Date:   Thu Sep 17 02:16:10 2015 +0200

cobalt/arm64: drop aarch32 bits from feature set

---

 .../arch/arm64/include/asm/xenomai/features.h  |   44 ++--
 1 file changed, 4 insertions(+), 40 deletions(-)

diff --git a/lib/cobalt/arch/arm64/include/asm/xenomai/features.h 
b/lib/cobalt/arch/arm64/include/asm/xenomai/features.h
index 0d6702b..6dfe64c 100644
--- a/lib/cobalt/arch/arm64/include/asm/xenomai/features.h
+++ b/lib/cobalt/arch/arm64/include/asm/xenomai/features.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Philippe Gerum .
+ * Copyright (C) 2015 Philippe Gerum .
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -15,52 +15,16 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
-#ifndef _LIB_COBALT_ARM_FEATURES_H
-#define _LIB_COBALT_ARM_FEATURES_H
+#ifndef _LIB_COBALT_ARM64_FEATURES_H
+#define _LIB_COBALT_ARM64_FEATURES_H
 
 #include_next 
 #include 
 
-#if defined(__ARM_ARCH_2__)
-#define __LINUX_ARM_ARCH__ 2
-#endif /* armv2 */
-
-#if defined(__ARM_ARCH_3__)
-#define __LINUX_ARM_ARCH__ 3
-#endif /* armv3 */
-
-#if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
-#define __LINUX_ARM_ARCH__ 4
-#endif /* armv4 */
-
-#if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \
-   || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__)
-#define __LINUX_ARM_ARCH__ 5
-#endif /* armv5 */
-
-#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6K__) \
-   || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__)
-#define __LINUX_ARM_ARCH__ 6
-#endif /* armv6 */
-
-#if defined(__ARM_ARCH_7A__)
-#define __LINUX_ARM_ARCH__ 7
-#endif /* armv7 */
-
-#if defined(__aarch64__)
 #define __LINUX_ARM_ARCH__ 8
-#endif /* armv8 */
-
-#ifndef __LINUX_ARM_ARCH__
-#error "Could not find current ARM architecture"
-#endif
-
-#if __LINUX_ARM_ARCH__ < 6 && defined(CONFIG_SMP)
-#error "SMP not supported below armv6, compile with -march=armv6 or above"
-#endif
 
 #include 
 
 int cobalt_fp_detect(void);
 
-#endif /* !_LIB_COBALT_ARM_FEATURES_H */
+#endif /* !_LIB_COBALT_ARM64_FEATURES_H */


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


[Xenomai-git] Jan Kiszka : cobalt/kernel: Introduce __SCHED_CURRENT policy to setschedparam_ex

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 3a8f597f27f551bed669d0b5ae78872017709581
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3a8f597f27f551bed669d0b5ae78872017709581

Author: Jan Kiszka 
Date:   Tue Mar  8 14:41:28 2016 +0100

cobalt/kernel: Introduce __SCHED_CURRENT policy to setschedparam_ex

Define the internal scheduling policy "current": it shall refer to the
target thread's current scheduling policy. This will allow to model
pthread_setschedprio on top of pthread_setschedparam_ex with only a
single syscall.

Signed-off-by: Jan Kiszka 

---

 include/cobalt/uapi/sched.h|3 +++
 kernel/cobalt/posix/thread.c   |   10 ++
 kernel/cobalt/trace/cobalt-posix.h |3 ++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/cobalt/uapi/sched.h b/include/cobalt/uapi/sched.h
index b672095..2a1df44 100644
--- a/include/cobalt/uapi/sched.h
+++ b/include/cobalt/uapi/sched.h
@@ -21,6 +21,9 @@
 #define SCHED_COBALT   42
 #define SCHED_WEAK 43
 
+/* for internal use */
+#define __SCHED_CURRENT44
+
 #ifndef SCHED_SPORADIC
 #define SCHED_SPORADIC 10
 #define sched_ss_low_priority  sched_u.ss.__sched_low_priority
diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index d87edb1..217b81b 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -242,6 +242,7 @@ struct xnthread_personality *cobalt_thread_finalize(struct 
xnthread *zombie)
 int __cobalt_thread_setschedparam_ex(struct cobalt_thread *thread, int policy,
 const struct sched_param_ex *param_ex)
 {
+   struct xnthread *base_thread = >threadbase;
struct xnsched_class *sched_class;
union xnsched_policy_param param;
xnticks_t tslice;
@@ -256,6 +257,15 @@ int __cobalt_thread_setschedparam_ex(struct cobalt_thread 
*thread, int policy,
goto out;
}
 
+   if (policy == __SCHED_CURRENT) {
+   policy = base_thread->base_class->policy;
+   if (xnthread_base_priority(base_thread) == 0)
+   policy = SCHED_NORMAL;
+   else if (base_thread->base_class == _class_rt &&
+xnthread_test_state(base_thread, XNRRB))
+   policy = SCHED_RR;
+   }
+
tslice = thread->threadbase.rrperiod;
sched_class = cobalt_sched_policy_param(, policy,
param_ex, );
diff --git a/kernel/cobalt/trace/cobalt-posix.h 
b/kernel/cobalt/trace/cobalt-posix.h
index 9b8f1ff..cc98a19 100644
--- a/kernel/cobalt/trace/cobalt-posix.h
+++ b/kernel/cobalt/trace/cobalt-posix.h
@@ -88,7 +88,8 @@ DECLARE_EVENT_CLASS(syscall_exit,
 {SCHED_QUOTA, "quota"},\
 {SCHED_SPORADIC, "sporadic"},  \
 {SCHED_COBALT, "cobalt"},  \
-{SCHED_WEAK, "weak"})
+{SCHED_WEAK, "weak"},  \
+{__SCHED_CURRENT, ""})
 
 #define cobalt_print_sched_params(__policy, __p_ex)\
 ({ \


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


[Xenomai-git] Philippe Gerum : cobalt/powerpc: drop obsolete config knob

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c538682ea1626a33c13bcee2350f61867e12caaa
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c538682ea1626a33c13bcee2350f61867e12caaa

Author: Philippe Gerum 
Date:   Sat Nov 14 18:14:53 2015 +0100

cobalt/powerpc: drop obsolete config knob

As of fbe1164, CONFIG_XENO_ARCH_UNLOCKED_SWITCH is not tested anymore
in the code base.

---

 kernel/cobalt/arch/powerpc/Kconfig |3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/cobalt/arch/powerpc/Kconfig 
b/kernel/cobalt/arch/powerpc/Kconfig
index 1cabef3..2069288 100644
--- a/kernel/cobalt/arch/powerpc/Kconfig
+++ b/kernel/cobalt/arch/powerpc/Kconfig
@@ -10,6 +10,3 @@ config XENO_ARCH_FPU
 
 config XENO_ARCH_SYS3264
 def_bool n
-
-config XENO_ARCH_UNLOCKED_SWITCH
-   def_bool n


___
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()

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 1d01a02cd9c08218668478d58504981464ccda5b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1d01a02cd9c08218668478d58504981464ccda5b

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

cobalt/wrappers: add wrapper for reinit_completion()

---

 kernel/cobalt/include/asm-generic/xenomai/wrappers.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h 
b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index 8e1dc39..96ca5f1 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -61,7 +61,6 @@
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
 #include 
-#include 
 
 #undef alloc_netdev
 #define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \
@@ -74,6 +73,7 @@ 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)


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


[Xenomai-git] Jan Kiszka : cobalt: Align structure of mutex_trylock with mutex_timedlock

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: ecb1129d9b78f4deab7230e6ead678e438cd7be7
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ecb1129d9b78f4deab7230e6ead678e438cd7be7

Author: Jan Kiszka 
Date:   Fri Jul 14 20:32:40 2017 +0200

cobalt: Align structure of mutex_trylock with mutex_timedlock

No need to have different patterns, and the one of mutex_timedlock is
more compact.

Signed-off-by: Jan Kiszka 

---

 lib/cobalt/mutex.c |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c
index f066ea3..ed32bba 100644
--- a/lib/cobalt/mutex.c
+++ b/lib/cobalt/mutex.c
@@ -531,10 +531,8 @@ fast_path:
} else {
 slow_path:
ret = xnsynch_fast_owner_check(mutex_get_ownerp(_mutex), cur);
-   if (ret < 0)
-   goto do_syscall;
-
-   ret = -EBUSY;
+   if (ret == 0)
+   ret = -EBUSY;
}
 
if (ret == -EBUSY) {
@@ -552,7 +550,6 @@ slow_path:
return EBUSY;
}
 
-do_syscall:
do {
ret = XENOMAI_SYSCALL1(sc_cobalt_mutex_trylock, _mutex);
} while (ret == -EINTR);


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


[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 605b18bbbf2cf942e1952c73f482ef0b8c00fd19
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=605b18bbbf2cf942e1952c73f482ef0b8c00fd19

Author: Jan Kiszka 
Date:   Mon May 30 14:58:07 2016 +0200

lib/cobalt: Provide RT-capable usleep

User may expect this (probably last) sleeping service to be available
under Cobalt just like sleep, nanosleep & Co.

Signed-off-by: Jan Kiszka 

---

 include/cobalt/unistd.h|2 ++
 lib/cobalt/clock.c |   14 ++
 lib/cobalt/cobalt.wrappers |1 +
 lib/cobalt/wrappers.c  |6 ++
 4 files changed, 23 insertions(+)

diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h
index 8ad2b40..fe3992a 100644
--- a/include/cobalt/unistd.h
+++ b/include/cobalt/unistd.h
@@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes));
 
 COBALT_DECL(unsigned int, sleep(unsigned int seconds));
 
+COBALT_DECL(int, usleep(useconds_t usec));
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c
index 0450019..7b4ef54 100644
--- a/lib/cobalt/clock.c
+++ b/lib/cobalt/clock.c
@@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds))
return 0;
 }
 
+/* @apitags{thread-unrestricted, switch-primary} */
+
+COBALT_IMPL(int, usleep, (useconds_t usec))
+{
+   struct timespec rqt;
+
+   if (cobalt_get_current_fast() == XN_NO_HANDLE)
+   return __STD(usleep(usec));
+
+   rqt.tv_sec = usec / 100;
+   rqt.tv_nsec = (usec % 100) * 1000;
+   return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL));
+}
+
 /* @apitags{unrestricted} */
 
 COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz))
diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers
index f8bda39..91bd5ef 100644
--- a/lib/cobalt/cobalt.wrappers
+++ b/lib/cobalt/cobalt.wrappers
@@ -108,6 +108,7 @@
 --wrap sigqueue
 --wrap kill
 --wrap sleep
+--wrap usleep
 --wrap mmap
 --wrap mmap64
 --wrap time
diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c
index 8dd28fb..0507786 100644
--- a/lib/cobalt/wrappers.c
+++ b/lib/cobalt/wrappers.c
@@ -529,3 +529,9 @@ unsigned int __real_sleep(unsigned int seconds)
 {
return sleep(seconds);
 }
+
+__weak
+int __real_usleep(useconds_t usec)
+{
+   return usleep(usec);
+}


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


[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: machine.h: use slightly faster ffnz implementation

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c89ba7367c4029b9e70f3964f61771d49f6f1c9e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c89ba7367c4029b9e70f3964f61771d49f6f1c9e

Author: Dmitriy Cherkasov 
Date:   Wed Jun 17 16:09:20 2015 -0700

cobalt/arm64: machine.h: use slightly faster ffnz implementation

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h |   12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
index 417a7b0..b8290bf 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
@@ -37,13 +37,23 @@
 #include 
 #include 
 #include 
+#include 
 
 /* D-side always behaves as PIPT on AArch64 (see 
arch/arm64/include/asm/cachetype.h) */
 #define xnarch_cache_aliasing() 0
 
 static inline __attribute_const__ unsigned long ffnz(unsigned long ul)
 {
-   return __builtin_ffsl(ul) - 1;
+   int __r;
+
+   /* zero input is not valid */
+   XENO_WARN_ON(COBALT, ul == 0);
+
+   __asm__ ("rbit\t%0, %1\n"
+"clz\t%0, %0\n"
+   : "=r" (__r) : "r"(ul) : "cc");
+
+   return __r;
 }
 
 #include 


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: assume TLS is properly supported

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 430a6964686d514497aa033292ce74cd4b29119d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=430a6964686d514497aa033292ce74cd4b29119d

Author: Philippe Gerum 
Date:   Thu Sep 17 02:19:57 2015 +0200

cobalt/arm64: assume TLS is properly supported

---

 lib/cobalt/arch/arm64/include/asm/xenomai/syscall.h |9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/lib/cobalt/arch/arm64/include/asm/xenomai/syscall.h 
b/lib/cobalt/arch/arm64/include/asm/xenomai/syscall.h
index 1d5806c..8e7ad61 100644
--- a/lib/cobalt/arch/arm64/include/asm/xenomai/syscall.h
+++ b/lib/cobalt/arch/arm64/include/asm/xenomai/syscall.h
@@ -18,8 +18,8 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
-#ifndef _LIB_COBALT_ARM_SYSCALL_H
-#define _LIB_COBALT_ARM_SYSCALL_H
+#ifndef _LIB_COBALT_ARM64_SYSCALL_H
+#define _LIB_COBALT_ARM64_SYSCALL_H
 
 #include 
 #include 
@@ -29,9 +29,6 @@
  * Some of the following macros have been adapted from Linux's
  * implementation of the syscall mechanism in :
  */
-#if defined(HAVE_TLS) && __GNUC__ == 4 && __GNUC_MINOR__ >= 3
-#error TLS support (__thread) is broken with GCC >= 4.3, use --disable-tls 
when configuring
-#endif
 
 #define LOADARGS_0(syscode, dummy...)  \
__a0 = (unsigned long) (syscode)
@@ -143,4 +140,4 @@
 #define XENOMAI_SYSBIND(breq)  \
XENOMAI_DO_SYSCALL(1,sc_cobalt_bind,breq)
 
-#endif /* !_LIB_COBALT_ARM_SYSCALL_H */
+#endif /* !_LIB_COBALT_ARM64_SYSCALL_H */


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


[Xenomai-git] Jan Kiszka : smokey/posix-mutex: Fix test case by destroying barriers correctly

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 781e878eaf90db46239bef8c1fbd1df83aa61b18
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=781e878eaf90db46239bef8c1fbd1df83aa61b18

Author: Jan Kiszka 
Date:   Tue Dec  6 16:34:48 2016 +0100

smokey/posix-mutex: Fix test case by destroying barriers correctly

At least on x86-64-compat, the missing destruction of the smokey
barriers, specifically their embedded mutexes, cause crashes of the
test. The reason is likely a mismatch between the kernel's and
userland's view on which object is still active, combined with the fact
that userland kept them on the volatile stack.

Signed-off-by: Jan Kiszka 

---

 testsuite/smokey/posix-mutex/posix-mutex.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/testsuite/smokey/posix-mutex/posix-mutex.c 
b/testsuite/smokey/posix-mutex/posix-mutex.c
index 151c2f3..9a1592b 100644
--- a/testsuite/smokey/posix-mutex/posix-mutex.c
+++ b/testsuite/smokey/posix-mutex/posix-mutex.c
@@ -291,6 +291,8 @@ static int do_contend(pthread_mutex_t *mutex, int type)
if (!__Tassert(status == NULL))
return -EINVAL;
 
+   smokey_barrier_destroy();
+
return 0;
 }
 
@@ -471,6 +473,8 @@ static int do_pi_contend(int prio)
if (!__T(ret, pthread_mutex_destroy()))
return ret;
 
+   smokey_barrier_destroy();
+
return 0;
 }
 
@@ -578,6 +582,8 @@ static int do_steal(int may_steal)
if (!__T(ret, pthread_mutex_destroy()))
return ret;
 
+   smokey_barrier_destroy();
+
return 0;
 }
 


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


[Xenomai-git] Jan Kiszka : cobalt/kernel: Trigger missing reschedule after PP deboost

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: d7706fd2b0fe201218af51402572bd2424423fab
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d7706fd2b0fe201218af51402572bd2424423fab

Author: Jan Kiszka 
Date:   Mon May  9 21:22:23 2016 +0200

cobalt/kernel: Trigger missing reschedule after PP deboost

xnsynch_release also needs to tell the caller about the potential need
for a reschedule after deboosting for prio-protection.

Signed-off-by: Jan Kiszka 

---

 kernel/cobalt/synch.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c
index d8b83d9..f3b70a2 100644
--- a/kernel/cobalt/synch.c
+++ b/kernel/cobalt/synch.c
@@ -949,8 +949,10 @@ bool xnsynch_release(struct xnsynch *synch, struct 
xnthread *curr)
else if (h != currh)/* FLCEIL set, FLCLAIM clear. */
atomic_set(lockp, XN_NO_HANDLE);
 
-   if (synch->status & XNSYNCH_PP)
+   if (synch->status & XNSYNCH_PP) {
clear_pp_boost(synch, curr);
+   need_resched = true;
+   }
 
xnlock_put_irqrestore(, s);
 


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: thread: move all TCB initializers out of line

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 43153139cc12072738473b4e70e06134ecbe5595
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=43153139cc12072738473b4e70e06134ecbe5595

Author: Philippe Gerum 
Date:   Fri Sep  9 16:07:54 2016 +0200

cobalt/arm64: thread: move all TCB initializers out of line

Does not impact performances and fixes inclusion hell for pulling the
struct xnthread definition for good.

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h |6 +-
 kernel/cobalt/arch/arm64/thread.c |6 ++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
index ac1f1f7..319f4d8 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
@@ -60,11 +60,7 @@ int xnarch_escalate(void);
 
 #if defined(CONFIG_XENO_ARCH_FPU)
 
-static inline void xnarch_init_root_tcb(struct xnthread *thread)
-{
-   struct xnarchtcb *tcb = xnthread_archtcb(thread);
-   tcb->fpup = NULL;
-}
+void xnarch_init_root_tcb(struct xnthread *thread);
 
 void xnarch_init_shadow_tcb(struct xnthread *thread);
 
diff --git a/kernel/cobalt/arch/arm64/thread.c 
b/kernel/cobalt/arch/arm64/thread.c
index b987e09..3097aeb 100644
--- a/kernel/cobalt/arch/arm64/thread.c
+++ b/kernel/cobalt/arch/arm64/thread.c
@@ -98,6 +98,12 @@ void xnarch_init_shadow_tcb(struct xnthread *thread)
tcb->fpup = >core.host_task->thread.fpsimd_state;
 }
 
+void xnarch_init_root_tcb(struct xnthread *thread)
+{
+   struct xnarchtcb *tcb = >tcb;
+   tcb->fpup = NULL;
+}
+
 #endif /* CONFIG_XENO_ARCH_FPU */
 
 void xnarch_switch_to(struct xnthread *out, struct xnthread *in)


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: fix build w/ pre-4.8 kernels

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 834488d4b62e8adadb22fa6fdce7115db015e709
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=834488d4b62e8adadb22fa6fdce7115db015e709

Author: Philippe Gerum 
Date:   Mon May 15 17:03:02 2017 +0200

cobalt/arm64: fix build w/ pre-4.8 kernels

---

 kernel/cobalt/arch/arm64/machine.c |4 
 1 file changed, 4 insertions(+)

diff --git a/kernel/cobalt/arch/arm64/machine.c 
b/kernel/cobalt/arch/arm64/machine.c
index 1711d76..b8f80ac 100644
--- a/kernel/cobalt/arch/arm64/machine.c
+++ b/kernel/cobalt/arch/arm64/machine.c
@@ -35,7 +35,11 @@ static void mach_arm_prefault(struct vm_area_struct *vma)
flags = (vma->vm_flags & VM_MAYWRITE) ? FAULT_FLAG_WRITE : 0;
for (addr = vma->vm_start;
 addr != vma->vm_end; addr += PAGE_SIZE)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)
+   handle_mm_fault(vma->vm_mm, vma, addr, flags);
+#else
handle_mm_fault(vma, addr, flags);
+#endif
}
 }
 


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: no fpsimd support in real-time kthread context

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c190aac5ce2c73614059f2c32dbd17abd4bcf7df
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c190aac5ce2c73614059f2c32dbd17abd4bcf7df

Author: Philippe Gerum 
Date:   Wed May 24 17:41:41 2017 +0200

cobalt/arm64: no fpsimd support in real-time kthread context

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h
index cfdf0b3..b7e3f52 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h
@@ -27,7 +27,7 @@
 
 static inline int fp_kernel_supported(void)
 {
-   return 1;
+   return 0;
 }
 
 static inline int fp_linux_begin(void)


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


[Xenomai-git] Gilles Chanteperdrix : testsuite/smokey: add RTnet raw packets test

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 2da0a49c5f7cf0ae7e91a547e437b39201b3d201
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2da0a49c5f7cf0ae7e91a547e437b39201b3d201

Author: Gilles Chanteperdrix 
Date:   Sun Nov  1 19:14:40 2015 +0100

testsuite/smokey: add RTnet raw packets test

---

 configure.ac |1 +
 1 file changed, 1 insertion(+)

diff --git a/configure.ac b/configure.ac
index 7f258ed..457d026 100644
--- a/configure.ac
+++ b/configure.ac
@@ -924,6 +924,7 @@ AC_CONFIG_FILES([ \
testsuite/smokey/fpu-stress/Makefile \
testsuite/smokey/net_udp/Makefile \
testsuite/smokey/net_packet_dgram/Makefile \
+   testsuite/smokey/net_packet_raw/Makefile \
testsuite/smokey/net_common/Makefile \
testsuite/clocktest/Makefile \
testsuite/xeno-test/Makefile \


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: sanitize calibration file

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 9c4d531ed143bac24069550b5b489133f0bef39e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9c4d531ed143bac24069550b5b489133f0bef39e

Author: Philippe Gerum 
Date:   Thu Sep 17 04:01:49 2015 +0200

cobalt/arm64: sanitize calibration file

---

 .../arch/arm64/include/asm/xenomai/calibration.h   |   44 +---
 1 file changed, 11 insertions(+), 33 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/calibration.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/calibration.h
index e303a04..e85521e 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/calibration.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/calibration.h
@@ -1,13 +1,10 @@
 /*
- * Copyright (C) 2001,2002,2003,2004,2005 Philippe Gerum .
+ * Copyright (C) 2015 Philippe Gerum .
  *
- * ARM port
- *   Copyright (C) 2005 Stelian Pop
- *
- * Xenomai is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * Xenomai is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
  *
  * Xenomai is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,41 +16,22 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-#ifndef _COBALT_ARM_ASM_CALIBRATION_H
-#define _COBALT_ARM_ASM_CALIBRATION_H
-
-unsigned int omap_rev(void);
-#define cpu_is_omap44xx() ((omap_rev() & 0xff) == 0x44)
+#ifndef _COBALT_ARM64_ASM_CALIBRATION_H
+#define _COBALT_ARM64_ASM_CALIBRATION_H
 
 static inline void xnarch_get_latencies(struct xnclock_gravity *p)
 {
unsigned int ulat;
 #if CONFIG_XENO_OPT_TIMING_SCHEDLAT != 0
ulat = CONFIG_XENO_OPT_TIMING_SCHEDLAT;
-#elif defined(CONFIG_ARCH_AT91RM9200)
-   ulat = 8500;
-#elif defined(CONFIG_ARCH_AT91SAM9263)
-   ulat = 11000;
-#elif defined(CONFIG_SOC_IMX6Q)
-   ulat = 6000;
-#elif defined(CONFIG_ARCH_MX51)
-   ulat = 5000;
-#elif defined(CONFIG_ARCH_MX53)
-   ulat = 5000;
-#elif defined(CONFIG_ARCH_MX6)
-   ulat = 2000;
-#elif defined(CONFIG_SOC_IMX7)
-   ulat = 2000;
-#elif defined(CONFIG_SOC_LS1021A)
-   ulat = 2800;
-#elif defined(CONFIG_ARCH_OMAP)
-   ulat = cpu_is_omap44xx() ? 2500 : 5000;
+#elif defined(CONFIG_ARCH_HISI)
+   ulat = 4000;
 #else
-   ulat = 9500;/* XXX sane? */
+   ulat = 4000;
 #endif
p->user = xnclock_ns_to_ticks(, ulat);
p->kernel = xnclock_ns_to_ticks(, 
CONFIG_XENO_OPT_TIMING_KSCHEDLAT);
p->irq = xnclock_ns_to_ticks(, CONFIG_XENO_OPT_TIMING_IRQLAT);
 }
 
-#endif /* !_COBALT_ARM_ASM_CALIBRATION_H */
+#endif /* !_COBALT_ARM64_ASM_CALIBRATION_H */


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


[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 47529713f5a67529533fd4032ed97ebf07d71877
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=47529713f5a67529533fd4032ed97ebf07d71877

Author: Philippe Gerum 
Date:   Fri Mar 18 12:12:50 2016 +0100

cobalt/thread: add schedparam lazy propagation

Provide a mechanism for carrying out a lazy propagation of schedparam
updates to the regular kernel, so that userland does not have to
switch to secondary mode for this.

When userland issues sc_cobalt_thread_setschedparam_ex for updating
the scheduling parameters of a Xenomai thread, a request for
propagating this change to the regular kernel is made pending. Such
request will be committed later, either when:

- the thread relaxes if it is running in primary mode when the update
  request is received;

- next time the thread calls back into the Cobalt core as a result of
  receiving a HOME action from a SIGSHADOW notification, which is sent
  if such thread was relaxed at the time of the update request.

As a result, the target thread will have propagated the schedparams
update to the regular kernel as soon as it resumes (relaxed) execution
in user-space.

---

 include/cobalt/kernel/thread.h  |8 +
 include/cobalt/uapi/kernel/thread.h |1 +
 include/cobalt/uapi/signal.h|1 +
 kernel/cobalt/posix/syscall.c   |9 ++
 kernel/cobalt/thread.c  |   55 +++
 5 files changed, 74 insertions(+)

diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h
index 07b6996..a4d826e 100644
--- a/include/cobalt/kernel/thread.h
+++ b/include/cobalt/kernel/thread.h
@@ -567,6 +567,14 @@ int xnthread_set_schedparam(struct xnthread *thread,
 
 int xnthread_killall(int grace, int mask);
 
+void __xnthread_propagate_schedparam(struct xnthread *curr);
+
+static inline void xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   if (xnthread_test_info(curr, XNSCHEDP))
+   __xnthread_propagate_schedparam(curr);
+}
+
 extern struct xnthread_personality xenomai_personality;
 
 /** @} */
diff --git a/include/cobalt/uapi/kernel/thread.h 
b/include/cobalt/uapi/kernel/thread.h
index 37637f6..6f30fcd 100644
--- a/include/cobalt/uapi/kernel/thread.h
+++ b/include/cobalt/uapi/kernel/thread.h
@@ -71,6 +71,7 @@
 #define XNROBBED  0x0020 /**< Robbed from resource ownership */
 #define XNCANCELD 0x0040 /**< Cancellation request is pending */
 #define XNPIALERT 0x0080 /**< Priority inversion alert (SIGDEBUG sent) */
+#define XNSCHEDP  0x0100 /**< schedparam propagation is pending */
 
 /* Local information flags (private to current thread) */
 
diff --git a/include/cobalt/uapi/signal.h b/include/cobalt/uapi/signal.h
index b5483d7..8a7ea15 100644
--- a/include/cobalt/uapi/signal.h
+++ b/include/cobalt/uapi/signal.h
@@ -47,6 +47,7 @@
 /* SIGSHADOW action codes. */
 #define SIGSHADOW_ACTION_HARDEN1
 #define SIGSHADOW_ACTION_BACKTRACE 2
+#define SIGSHADOW_ACTION_HOME  3
 #define SIGSHADOW_BACKTRACE_DEPTH  16
 
 #define SIGDEBUG   SIGXCPU
diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index 2582949..0aeff28 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* We want to run the syscall in the current Linux
+* domain. This is a slow path, so proceed with any
+* pending schedparam update on the fly.
+*/
+   switched = 0;
+   if (thread)
+   xnthread_propagate_schedparam(thread);
}
 
ret = handler(__xn_reg_arglist(regs));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 9f2261e..b8304e2 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1969,6 +1970,11 @@ int __xnthread_set_schedparam(struct xnthread *thread,
thread->lock_count == 0)
xnsched_putback(thread);
 
+   xnthread_set_info(thread, XNSCHEDP);
+   /* Ask the target thread to call back if relaxed. */
+   if (xnthread_test_state(thread, XNRELAX))
+   xnthread_signal(thread, SIGSHADOW, SIGSHADOW_ACTION_HOME);
+   
return ret;
 }
 
@@ -2090,6 +2096,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: thread: use kernel switch_to

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 0352b5f3b4e68775a4d5ee904736f4b9034e9177
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0352b5f3b4e68775a4d5ee904736f4b9034e9177

Author: Dmitriy Cherkasov 
Date:   Fri May 15 23:26:18 2015 -0700

cobalt/arm64: thread: use kernel switch_to

---

 kernel/cobalt/arch/arm64/Makefile |2 +-
 kernel/cobalt/arch/arm64/switch.S |  167 -
 kernel/cobalt/arch/arm64/thread.c |5 +-
 3 files changed, 2 insertions(+), 172 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/Makefile 
b/kernel/cobalt/arch/arm64/Makefile
index a135f99..af0a0e8 100644
--- a/kernel/cobalt/arch/arm64/Makefile
+++ b/kernel/cobalt/arch/arm64/Makefile
@@ -1,5 +1,5 @@
 obj-$(CONFIG_XENOMAI) += xenomai.o
 
-xenomai-y := machine.o mayday.o thread.o switch.o syscall.o
+xenomai-y := machine.o mayday.o thread.o syscall.o
 
 ccflags-y := -Iarch/arm64/xenomai/include -Iinclude/xenomai
diff --git a/kernel/cobalt/arch/arm64/switch.S 
b/kernel/cobalt/arch/arm64/switch.S
deleted file mode 100644
index 505fd5a..000
--- a/kernel/cobalt/arch/arm64/switch.S
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2005 Stelian Pop.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
- * USA; either version 2 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#ifdef CONFIG_VFP
-#include 
-#endif
-
-   .macro fpu_switch tmp
-#ifdef CONFIG_VFP
-#if __LINUX_ARM_ARCH__ <= 6
-#ifdef CONFIG_JUMP_LABEL
-9998:  nop
-   .pushsection __jump_table, "aw"
-   .word   9998b, f, __xeno_vfp_key
-   .popsection
-#else
-   ldr \tmp, =elf_hwcap
-   ldr \tmp, [\tmp]
-   tst \tmp, #HWCAP_VFP
-   beq f
-#endif
-#endif
-   @ Always disable VFP so we can lazily save/restore the old
-   @ state. This occurs in the context of the previous thread.
-   VFPFMRX \tmp, FPEXC
-   bic \tmp, \tmp, #FPEXC_EN
-   VFPFMXR FPEXC, \tmp
-#if __LINUX_ARM_ARCH__ <= 6
-:
-#endif
-#endif
-   .endm
-
-   .text
-
-#if defined(CONFIG_VFP) && defined(CONFIG_XENO_ARCH_FPU)
-/* Copied from vfp_save_state in arch/arm/vfp/vfphw.S
- * r0 = pointer to union vfp_state, r1 = fpexc
- */
-ENTRY(__asm_vfp_save)
-   VFPFSTMIA   r0, r2  @ save the working registers
-   VFPFMRX r2, FPSCR   @ current status
-   tst r1, #FPEXC_EX   @ is there additional state to save?
-   beq 1f
-   VFPFMRX r3, FPINST  @ FPINST (only if FPEXC.EX is set)
-   tst r1, #FPEXC_FP2V @ is there an FPINST2 to read?
-   beq 1f
-   VFPFMRX r12, FPINST2@ FPINST2 if needed (and present)
-1:
-   stmia   r0, {r1, r2, r3, r12}   @ save FPEXC, FPSCR, FPINST, 
FPINST2
-   mov pc, lr
-ENDPROC(__asm_vfp_save)
-
-/* Copied from no_old_VFP_process in arch/arm/vfp/vfphw.S
- * r0 = pointer to union vfp_state
- * r1 = current cpu
- */
-ENTRY(__asm_vfp_load)
-#ifdef CONFIG_SMP
-   str r1, [r0, #VFP_CPU]
-#endif
-   VFPFLDMIA   r0, r2  @ reload the working registers while
-   @ FPEXC is in a safe state
-   ldmia   r0, {r1, r2, r3, r12}   @ load FPEXC, FPSCR, FPINST, 
FPINST2
-   tst r1, #FPEXC_EX   @ is there additional state to restore?
-   beq 1f
-   VFPFMXR FPINST, r3  @ restore FPINST (only if FPEXC.EX is 
set)
-   tst r1, #FPEXC_FP2V @ is there an FPINST2 to write?
-   beq 1f
-   VFPFMXR FPINST2, r12@ FPINST2 if needed (and present)
-1:
-   VFPFMXR FPSCR, r2   @ restore status
-   mov pc, lr
-ENDPROC(__asm_vfp_load)
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)
-   .macro load_tls base, tp, tpuser
-   ldr \tp, [\base, #TI_TP_VALUE]
-   .endm
-
-   .macro switch_tls base, tp, tpuser, tmp1, tmp2
-   set_tls \tp, \tmp1, \tmp2
-   .endm
-#else
-   .macro load_tls base, tp, tpuser
-   ldr \tp, [\base, #TI_TP_VALUE]
-   ldr \tpuser, [\base, #TI_TP_VALUE + 4]
-   .endm
-#endif
-
-/*
-/*
- * Switch context routine.
- *
- * Registers 

[Xenomai-git] Philippe Gerum : cobalt/arm64: drop useless test on target architecture

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: a3b1bb510fd6ff8cba194b9b55287faef019add6
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a3b1bb510fd6ff8cba194b9b55287faef019add6

Author: Philippe Gerum 
Date:   Sat Oct 17 14:43:25 2015 +0200

cobalt/arm64: drop useless test on target architecture

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h |7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h
index ea1b06e..74423f6 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h
@@ -28,10 +28,9 @@
 
 #define XENOMAI_FEAT_MAN (__xn_feat_generic_man_mask)
 
-#ifndef __aarch64__
-#define XNARCH_HAVE_LLMULSHFT1
-#define XNARCH_HAVE_NODIV_LLIMD  1
-#endif
+#undef XNARCH_HAVE_LLMULSHFT
+
+#undef XNARCH_HAVE_NODIV_LLIMD
 
 struct cobalt_featinfo_archdep { /* no arch-specific feature */ };
 


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: leave mm tracking to the pipeline

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 535c5a226d311f0191f8d55c8e2ebb2199188540
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=535c5a226d311f0191f8d55c8e2ebb2199188540

Author: Philippe Gerum 
Date:   Thu Sep 17 15:08:34 2015 +0200

cobalt/arm64: leave mm tracking to the pipeline

---

 kernel/cobalt/arch/arm64/Kconfig |3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/Kconfig b/kernel/cobalt/arch/arm64/Kconfig
index 927c647..dd5a8c6 100644
--- a/kernel/cobalt/arch/arm64/Kconfig
+++ b/kernel/cobalt/arch/arm64/Kconfig
@@ -4,9 +4,6 @@ source "drivers/xenomai/Kconfig"
 config XENO_ARCH_UNLOCKED_SWITCH
def_bool IPIPE_WANT_PREEMPTIBLE_SWITCH
 
-config IPIPE_WANT_ACTIVE_MM
-   def_bool y
-
 config XENO_ARCH_WANT_TIP
def_bool y
 


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: restrict unlocked switch to SMP

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: bd9e42e723aff3531b03614a56dfde450d2579da
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bd9e42e723aff3531b03614a56dfde450d2579da

Author: Philippe Gerum 
Date:   Thu Sep 17 11:43:50 2015 +0200

cobalt/arm64: restrict unlocked switch to SMP

Unlocked switching for Xenomai/ARM was specifically introduced for
improving the interrupt latency on low-end armv4/armv5 platforms with
VIVT caches.

The once massive overhead imposed on the MMU context switching code
for invalidating the cache is long gone with VIPT indexing, and
keeping IRQs off while switching the memory context on armv8 these
days is not an issue. Actually, the complexity of the code involved in
dealing with unlocked switching may overbalance the expected gain.

However, the mainline kernel implementation for ASID management in the
SMP case currently requires us to keep IRQs enabled when allocating a
new MM context over the Xenomai domain, just like it did for aarch32
during the 2.6.3x time frame until the IPI-based approach was
eventually dropped.

So, let's restrict unlocked switching to the SMP case, forcing it off
otherwise, in the hope we can drop it entirely in the future.

At this chance, CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH moves to the
kernel area, where it actually belongs.

---

 kernel/cobalt/arch/arm64/Kconfig |   21 +
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/Kconfig b/kernel/cobalt/arch/arm64/Kconfig
index dc6485d..927c647 100644
--- a/kernel/cobalt/arch/arm64/Kconfig
+++ b/kernel/cobalt/arch/arm64/Kconfig
@@ -1,27 +1,8 @@
 source "kernel/xenomai/Kconfig"
 source "drivers/xenomai/Kconfig"
 
-menu "Machine/platform-specific options"
-
 config XENO_ARCH_UNLOCKED_SWITCH
-   bool "Unlocked context switch"
-   default y
-   help
-   The Cobalt core may allow non-atomic execution of the
-   machine-dependent context switching code, so that other CPUs
-   and/or local interrupts may execute concurrently.
-
-   This option reduces interrupt latency when costly cache and
-   TLB flushes are required to switch context.
-
-   You definitely want to enable that option on low-end ARM
-   platforms.
-endmenu
-
-config IPIPE_WANT_PREEMPTIBLE_SWITCH
-   bool
-   default y if XENO_ARCH_UNLOCKED_SWITCH
-   default n if !XENO_ARCH_UNLOCKED_SWITCH
+   def_bool IPIPE_WANT_PREEMPTIBLE_SWITCH
 
 config IPIPE_WANT_ACTIVE_MM
def_bool y


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


[Xenomai-git] Philippe Gerum : cobalt/arm: fixups for kernel 4.8+

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 4b044c1e1005aa76a5eabd15e25a22bbaef5a66b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4b044c1e1005aa76a5eabd15e25a22bbaef5a66b

Author: Philippe Gerum 
Date:   Sun May 14 19:41:55 2017 +0200

cobalt/arm: fixups for kernel 4.8+

At this chance, stop using the obsolete flush_cache_all() routine
which cannot honor the documented semantics for arm64.

Besides, calibrating the access times to the timer registers in
no-cache conditions does not make sense.

---

 kernel/cobalt/arch/arm64/machine.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/machine.c 
b/kernel/cobalt/arch/arm64/machine.c
index ddf65a8..1711d76 100644
--- a/kernel/cobalt/arch/arm64/machine.c
+++ b/kernel/cobalt/arch/arm64/machine.c
@@ -35,7 +35,7 @@ static void mach_arm_prefault(struct vm_area_struct *vma)
flags = (vma->vm_flags & VM_MAYWRITE) ? FAULT_FLAG_WRITE : 0;
for (addr = vma->vm_start;
 addr != vma->vm_end; addr += PAGE_SIZE)
-   handle_mm_fault(vma->vm_mm, vma, addr, flags);
+   handle_mm_fault(vma, addr, flags);
}
 }
 
@@ -63,7 +63,6 @@ static unsigned long mach_arm_calibrate(void)
barrier();
 
for (i = 0; i < CALIBRATION_LOOPS; i++) {
-   flush_cache_all();
for (j = 0; j < CALIBRATION_LOOPS; j++) {
ipipe_read_tsc(start);
barrier();


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: fix inclusion guards

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 6b8726b8dcec8449b2d3a1f8def18e10e6a2
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6b8726b8dcec8449b2d3a1f8def18e10e6a2

Author: Philippe Gerum 
Date:   Sat Oct 17 14:40:53 2015 +0200

cobalt/arm64: fix inclusion guards

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/features.h  |8 
 kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h|6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h   |6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h   |6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/syscall32.h |6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h|7 +++
 kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/arith.h|6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h |6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h   |6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/syscall.h  |6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/tsc.h  |6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/wrappers.h  |6 +++---
 12 files changed, 37 insertions(+), 38 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/features.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/features.h
index d485286..112408f 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/features.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/features.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Philippe Gerum .
+ * Copyright (C) 2015 Philippe Gerum .
  *
  * ARM port
  *   Copyright (C) 2005 Stelian Pop
@@ -19,12 +19,12 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-#ifndef _COBALT_ARM_ASM_FEATURES_H
-#define _COBALT_ARM_ASM_FEATURES_H
+#ifndef _COBALT_ARM64_ASM_FEATURES_H
+#define _COBALT_ARM64_ASM_FEATURES_H
 
 struct cobalt_featinfo;
 static inline void collect_arch_features(struct cobalt_featinfo *p) { }
 
 #include 
 
-#endif /* !_COBALT_ARM_ASM_FEATURES_H */
+#endif /* !_COBALT_ARM64_ASM_FEATURES_H */
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h
index 743d758..cfdf0b3 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h
@@ -16,8 +16,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-#ifndef _COBALT_ARM_ASM_FPTEST_H
-#define _COBALT_ARM_ASM_FPTEST_H
+#ifndef _COBALT_ARM64_ASM_FPTEST_H
+#define _COBALT_ARM64_ASM_FPTEST_H
 
 #include 
 #include 
@@ -44,4 +44,4 @@ static inline int fp_detect(void)
return have_fp ? __COBALT_HAVE_FPU : 0;
 }
 
-#endif /* _COBALT_ARM_ASM_FPTEST_H */
+#endif /* _COBALT_ARM64_ASM_FPTEST_H */
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
index b8290bf..7444cc8 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
@@ -20,8 +20,8 @@
  *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  *   02111-1307, USA.
  */
-#ifndef _COBALT_ARM_ASM_MACHINE_H
-#define _COBALT_ARM_ASM_MACHINE_H
+#ifndef _COBALT_ARM64_ASM_MACHINE_H
+#define _COBALT_ARM64_ASM_MACHINE_H
 
 #include 
 #include 
@@ -58,4 +58,4 @@ static inline __attribute_const__ unsigned long ffnz(unsigned 
long ul)
 
 #include 
 
-#endif /* !_COBALT_ARM_ASM_MACHINE_H */
+#endif /* !_COBALT_ARM64_ASM_MACHINE_H */
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
index 77c1716..949f287 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
@@ -19,8 +19,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-#ifndef _COBALT_ARM_ASM_SYSCALL_H
-#define _COBALT_ARM_ASM_SYSCALL_H
+#ifndef _COBALT_ARM64_ASM_SYSCALL_H
+#define _COBALT_ARM64_ASM_SYSCALL_H
 
 #include 
 #include 
@@ -75,4 +75,4 @@ int xnarch_local_syscall(unsigned long a1, unsigned long a2,
 unsigned long a3, unsigned long a4,
 unsigned long a5);
 
-#endif /* !_COBALT_ARM_ASM_SYSCALL_H */
+#endif /* !_COBALT_ARM64_ASM_SYSCALL_H */
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall32.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall32.h
index 95c5a11..a66ddd6 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall32.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall32.h
@@ -16,9 +16,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-#ifndef _COBALT_ARM_ASM_SYSCALL32_H
-#define _COBALT_ARM_ASM_SYSCALL32_H
+#ifndef 

[Xenomai-git] Jorge Ramirez-Ortiz : gpiopwm: pwm signal generator and servo motor control demo code

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: ad1e755fd6fffdae0b08bfe5e7160b953611c226
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ad1e755fd6fffdae0b08bfe5e7160b953611c226

Author: Jorge Ramirez-Ortiz 
Date:   Tue Mar 15 19:18:15 2016 -0400

gpiopwm: pwm signal generator and servo motor control demo code

---

 demo/posix/cobalt/Makefile.am|6 +
 demo/posix/cobalt/gpiopwm.c  |  448 ++
 include/cobalt/kernel/rtdm/gpiopwm.h |   24 ++
 include/rtdm/uapi/gpiopwm.h  |   56 +
 include/rtdm/uapi/rtdm.h |1 +
 kernel/drivers/Kconfig   |1 +
 kernel/drivers/Makefile  |2 +-
 kernel/drivers/gpiopwm/Kconfig   |9 +
 kernel/drivers/gpiopwm/Makefile  |5 +
 kernel/drivers/gpiopwm/gpiopwm.c |  301 +++
 10 files changed, 852 insertions(+), 1 deletion(-)

diff --git a/demo/posix/cobalt/Makefile.am b/demo/posix/cobalt/Makefile.am
index cba9247..2a22967 100644
--- a/demo/posix/cobalt/Makefile.am
+++ b/demo/posix/cobalt/Makefile.am
@@ -3,6 +3,7 @@ demodir = @XENO_DEMO_DIR@
 CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
 
 demo_PROGRAMS =\
+   gpiopwm \
bufp-label  \
bufp-readwrite  \
can_rtt \
@@ -24,6 +25,11 @@ ldadd =  \
 @XENO_USER_LDADD@  \
-lpthread -lrt
 
+gpiopwm_SOURCES = gpiopwm.c
+gpiopwm_CPPFLAGS = $(cppflags) -I$(top_srcdir)/include/rtdm/uapi
+gpiopwm_LDFLAGS = $(ldflags)
+gpiopwm_LDADD = $(ldadd)
+
 bufp_label_SOURCES = bufp-label.c
 bufp_label_CPPFLAGS = $(cppflags)
 bufp_label_LDFLAGS = $(ldflags)
diff --git a/demo/posix/cobalt/gpiopwm.c b/demo/posix/cobalt/gpiopwm.c
new file mode 100644
index 000..e093fbe
--- /dev/null
+++ b/demo/posix/cobalt/gpiopwm.c
@@ -0,0 +1,448 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MIN_DUTY_CYCLE 0
+#define MAX_DUTY_CYCLE 100
+
+typedef void *(*gpiopwm_control_thread)(void *cookie);
+#define DEVICE_NAME "/dev/rtdm/gpiopwm"
+char *device_name;
+int dev;
+
+static sem_t synch;
+static sem_t setup;
+static int stop;
+static int step = 1;
+static int port = 6;
+
+#define GPIO_PWM_SERVO_CONFIG  \
+{  \
+   .duty_cycle =   50, \
+   .range_min  =   950,\
+   .range_max  =   2050,   \
+   .period =   2000,   \
+   .gpio   =   1,  \
+}
+
+static struct gpiopwm config = GPIO_PWM_SERVO_CONFIG;
+
+static void fail(const char *reason)
+{
+   perror(reason);
+   exit(EXIT_FAILURE);
+}
+
+static void sem_sync(sem_t *sem)
+{
+   int ret;
+
+   for (;;) {
+   ret = sem_wait(sem);
+   if (ret == 0)
+   return;
+   if (errno != EINTR)
+   fail("sem_wait");
+   }
+}
+
+static inline void clear_screen(void)
+{
+   const char* cmd = "\e[1;1H\e[2J";
+   int ret;
+
+   ret = write(2, cmd, strlen(cmd));
+   if (!ret)
+   error(1, ret, "clear screen error");
+}
+
+static inline void print_config(char *str)
+{
+   printf("Config: %s\n", str);
+   printf(" device : %s\n", device_name);
+   printf(" range  : [%d, %d]\n", config.range_min, config.range_max);
+   printf(" period : %d nsec\n", config.period);
+   printf(" gpio pin   : %d\n", config.gpio);
+   printf(" duty cycle : %d\n", config.duty_cycle);
+}
+
+static inline void input_message(void)
+{
+   print_config("");
+   printf("\n GPIO PWM Control\n");
+   printf( "  Enter duty_cycle [0-100] : ");
+}
+
+static void setup_sched_parameters(pthread_attr_t *attr, int prio)
+{
+   struct sched_param p;
+   int ret;
+
+   ret = pthread_attr_init(attr);
+   if (ret)
+   error(1, ret, "pthread_attr_init()");
+
+   ret = pthread_attr_setinheritsched(attr, PTHREAD_EXPLICIT_SCHED);
+   if (ret)
+   error(1, ret, "pthread_attr_setinheritsched()");
+
+   ret = pthread_attr_setschedpolicy(attr, prio ? SCHED_FIFO : 
SCHED_OTHER);
+   if (ret)
+   error(1, ret, "pthread_attr_setschedpolicy()");
+
+   p.sched_priority = prio;
+   ret = pthread_attr_setschedparam(attr, );
+   if (ret)
+   error(1, ret, "pthread_attr_setschedparam()");
+}
+
+static void *gpiopwm_init_thread(void *cookie)
+{
+   int ret;
+
+   pthread_setname_np(pthread_self(), "gpio-pwm-handler");
+   ret = ioctl(dev, GPIOPWM_RTIOC_SET_CONFIG, config);
+   if (ret)
+   error(1, ret, "failed to set config");
+
+   ioctl(dev, GPIOPWM_RTIOC_START);
+
+ 

[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: fix error check [SIGSEGV]

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 5fb5bba84bcc45607fec5d1f0c54efa6d876a68a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5fb5bba84bcc45607fec5d1f0c54efa6d876a68a

Author: Jorge Ramirez-Ortiz 
Date:   Wed Oct  5 21:34:27 2016 +0200

utils/analogy: fix error check [SIGSEGV]

---

 utils/analogy/cmd_read.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/utils/analogy/cmd_read.c b/utils/analogy/cmd_read.c
index a507801..86522f4 100644
--- a/utils/analogy/cmd_read.c
+++ b/utils/analogy/cmd_read.c
@@ -261,12 +261,12 @@ static int map_subdevice_buffer(a4l_desc_t *dsc, unsigned 
long *buf_size, void *
 
 static int cmd_read(struct arguments *arg)
 {
-   unsigned int i, scan_size = 0, cnt = 0, ret = 0, len, ofs;
+   unsigned int i, scan_size = 0, cnt = 0, len, ofs;
dump_function_t dump_function = dump_text;
a4l_desc_t dsc = { .sbdata = NULL };
unsigned long buf_size;
char **argv = arg->argv;
-   int argc = arg->argc;
+   int ret = 0, argc = arg->argc;
void *map = NULL;
 
for (;;) {


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


[Xenomai-git] Philippe Gerum : cobalt/syscalls: reject binding attempt to disabled core with EAGAIN

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: ff077e980455959b13f379042d3047c6624b98e8
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ff077e980455959b13f379042d3047c6624b98e8

Author: Philippe Gerum 
Date:   Thu Jun  1 09:43:53 2017 +0200

cobalt/syscalls: reject binding attempt to disabled core with EAGAIN

---

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

diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index 25d21ea..0f905bf 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -314,7 +314,7 @@ static COBALT_SYSCALL(bind, lostage,
f = _ret;
featreq = breq.feat_req;
if (!realtime_core_running() && (featreq & __xn_feat_control) == 0)
-   return -EPERM;
+   return -EAGAIN;
 
/*
 * Calculate the missing feature set:


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: use regular context switching code

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: cff05e3238ab17e30a3cc002d160052fe12f8042
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=cff05e3238ab17e30a3cc002d160052fe12f8042

Author: Philippe Gerum 
Date:   Mon May 22 12:06:46 2017 +0200

cobalt/arm64: use regular context switching code

Since 4.9.x, the interrupt pipeline implementation guarantees that the
regular context switching code may be used over the head stage,
including the fpu management bits.

Drop the open coded support and use mainline's implementation instead.

At this chance, drop the useless conditionals for handling the non-FPU
case: this one does not apply to arm64.

---

 .../cobalt/arch/arm64/include/asm/xenomai/thread.h |   44 +++-
 kernel/cobalt/arch/arm64/thread.c  |   14 +--
 2 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
index 319f4d8..eab6851 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
@@ -19,11 +19,16 @@
 #ifndef _COBALT_ARM64_ASM_THREAD_H
 #define _COBALT_ARM64_ASM_THREAD_H
 
+#include 
 #include 
 
+#if defined(CONFIG_XENO_ARCH_FPU) && LINUX_VERSION_CODE < KERNEL_VERSION(4,9,0)
+#define ARM64_XENO_OLD_SWITCH
+#endif
+
 struct xnarchtcb {
struct xntcb core;
-#ifdef CONFIG_XENO_ARCH_FPU
+#ifdef ARM64_XENO_OLD_SWITCH
struct fpsimd_state xnfpsimd_state;
struct fpsimd_state *fpup;
 #define xnarch_fpu_ptr(tcb) ((tcb)->fpup)
@@ -58,53 +63,36 @@ static inline void xnarch_enter_root(struct xnthread *root) 
{ }
 
 int xnarch_escalate(void);
 
-#if defined(CONFIG_XENO_ARCH_FPU)
+#ifdef ARM64_XENO_OLD_SWITCH
 
 void xnarch_init_root_tcb(struct xnthread *thread);
 
 void xnarch_init_shadow_tcb(struct xnthread *thread);
 
-static inline int xnarch_fault_fpu_p(struct ipipe_trap_data *d)
-{
-   return xnarch_fault_trap(d) == IPIPE_TRAP_FPU_ACC;
-}
-
 void xnarch_leave_root(struct xnthread *root);
 
 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
 
-static inline int
-xnarch_handle_fpu_fault(struct xnthread *from,
-   struct xnthread *to, struct ipipe_trap_data *d)
-{
-   return 0;
-}
-
-#else /* !CONFIG_XENO_ARCH_FPU */
+#else /* !ARM64_XENO_OLD_SWITCH */
 
 static inline void xnarch_init_root_tcb(struct xnthread *thread) { }
 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
+static inline void xnarch_leave_root(struct xnthread *root) { }
+static inline void xnarch_switch_fpu(struct xnthread *f, struct xnthread *t) { 
}
+
+#endif /*  !ARM64_XENO_OLD_SWITCH */
 
-/*
- * Userland may raise FPU faults with FPU-enabled kernels, regardless
- * of whether real-time threads actually use FPU, so we simply ignore
- * these faults.
- */
 static inline int xnarch_fault_fpu_p(struct ipipe_trap_data *d)
 {
-   return 0;
+   return xnarch_fault_trap(d) == IPIPE_TRAP_FPU_ACC;
 }
 
-static inline void xnarch_leave_root(struct xnthread *root) { }
-
-static inline void xnarch_switch_fpu(struct xnthread *f, struct xnthread *t) { 
}
-
-static inline int xnarch_handle_fpu_fault(struct xnthread *from, 
-   struct xnthread *to, struct 
ipipe_trap_data *d)
+static inline int
+xnarch_handle_fpu_fault(struct xnthread *from,
+   struct xnthread *to, struct ipipe_trap_data *d)
 {
return 0;
 }
-#endif /*  !CONFIG_XENO_ARCH_FPU */
 
 static inline void xnarch_enable_kfpu(void) { }
 
diff --git a/kernel/cobalt/arch/arm64/thread.c 
b/kernel/cobalt/arch/arm64/thread.c
index 3097aeb..270c99f 100644
--- a/kernel/cobalt/arch/arm64/thread.c
+++ b/kernel/cobalt/arch/arm64/thread.c
@@ -33,9 +33,10 @@
 #include 
 #include 
 #include 
-#include 
 
-#ifdef CONFIG_XENO_ARCH_FPU
+#ifdef ARM64_XENO_OLD_SWITCH
+
+#include 
 
 #define FPSIMD_EN (0x3 << 20)
 
@@ -104,13 +105,13 @@ void xnarch_init_root_tcb(struct xnthread *thread)
tcb->fpup = NULL;
 }
 
-#endif /* CONFIG_XENO_ARCH_FPU */
+#endif /* ARM64_XENO_OLD_SWITCH */
 
 void xnarch_switch_to(struct xnthread *out, struct xnthread *in)
 {
struct xnarchtcb *out_tcb = >tcb, *in_tcb = >tcb;
+   struct task_struct *prev, *next, *last;
struct mm_struct *prev_mm, *next_mm;
-   struct task_struct *prev, *next;
 
next = in_tcb->core.host_task;
prev = out_tcb->core.host_task;
@@ -133,7 +134,12 @@ void xnarch_switch_to(struct xnthread *out, struct 
xnthread *in)
enter_lazy_tlb(prev_mm, next);
}
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,9,0)
ipipe_switch_to(prev, next);
+   (void)last;
+#else
+   switch_to(prev, next, last);
+#endif
 }
 
 int xnarch_escalate(void)


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

[Xenomai-git] Gilles Chanteperdrix : cobalt/arm64: attempt at fixing fpu switch

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: f499ed192819b17d7e933d31d7739061a8a2927d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f499ed192819b17d7e933d31d7739061a8a2927d

Author: Gilles Chanteperdrix 
Date:   Fri Oct 30 17:14:00 2015 +0100

cobalt/arm64: attempt at fixing fpu switch

Return to eager switching, since user-space applications use FPU
registers even when not using the FPU, but use an auxiliary backup area
when the "TIF_FOREIGN_FPSTATE" bit is set, in order to avoid clobbering
the saved FPU state.

---

 .../cobalt/arch/arm64/include/asm/xenomai/thread.h |   14 +++--
 kernel/cobalt/arch/arm64/thread.c  |   54 +---
 2 files changed, 25 insertions(+), 43 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
index 9055e58..4b247ac 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
@@ -24,6 +24,7 @@
 struct xnarchtcb {
struct xntcb core;
 #ifdef CONFIG_XENO_ARCH_FPU
+   struct fpsimd_state xnfpsimd_state;
struct fpsimd_state *fpup;
 #define xnarch_fpu_ptr(tcb) ((tcb)->fpup)
 #endif
@@ -67,7 +68,10 @@ static inline void xnarch_init_root_tcb(struct xnthread 
*thread)
 
 void xnarch_init_shadow_tcb(struct xnthread *thread);
 
-int xnarch_fault_fpu_p(struct ipipe_trap_data *d);
+static inline int xnarch_fault_fpu_p(struct ipipe_trap_data *d)
+{
+   return xnarch_fault_trap(d) == IPIPE_TRAP_FPU_ACC;
+}
 
 void xnarch_leave_root(struct xnthread *root);
 
@@ -75,8 +79,12 @@ void xnarch_save_fpu(struct xnthread *thread);
 
 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
 
-int xnarch_handle_fpu_fault(struct xnthread *from, 
-   struct xnthread *to, struct ipipe_trap_data *d);
+static inline int
+xnarch_handle_fpu_fault(struct xnthread *from,
+   struct xnthread *to, struct ipipe_trap_data *d)
+{
+   return 0;
+}
 
 #else /* !CONFIG_XENO_ARCH_FPU */
 
diff --git a/kernel/cobalt/arch/arm64/thread.c 
b/kernel/cobalt/arch/arm64/thread.c
index 2238751..b987e09 100644
--- a/kernel/cobalt/arch/arm64/thread.c
+++ b/kernel/cobalt/arch/arm64/thread.c
@@ -6,6 +6,7 @@
  * 
  * ARM64 port
  *   Copyright (C) 2015 Dmitriy Cherkasov 
+ *   Copyright (C) 2015 Gilles Chanteperdrix 
  *
  * Xenomai is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by
@@ -41,7 +42,7 @@
 static inline unsigned long get_cpacr(void)
 {
unsigned long result;
-   __asm__ __volatile__("mrs %0, cpacr_el1": "=r"(result));
+   __asm__ ("mrs %0, cpacr_el1": "=r"(result));
return result;
 }
 
@@ -53,21 +54,20 @@ static inline void set_cpacr(long val)
: /* */ : "r"(val));
 }
 
-static void enable_fpsimd(void)
+static inline void enable_fpsimd(void)
 {
-   unsigned long cpacr = get_cpacr();
-   cpacr |= FPSIMD_EN;
-   set_cpacr(cpacr);
+   set_cpacr(get_cpacr() | FPSIMD_EN);
 }
 
-int xnarch_fault_fpu_p(struct ipipe_trap_data *d)
+static inline struct fpsimd_state *get_fpu_owner(struct xnarchtcb *rootcb)
 {
-   return (d->exception == IPIPE_TRAP_FPU_ACC);
-}
+   struct task_struct *curr = rootcb->core.host_task;
 
-static inline struct fpsimd_state *get_fpu_owner(struct xnarchtcb *tcb)
-{
-   return &(tcb->core.tsp->fpsimd_state);
+   if (test_ti_thread_flag(task_thread_info(curr), TIF_FOREIGN_FPSTATE))
+   /* Foreign fpu state, use auxiliary backup area */
+   return >xnfpsimd_state;
+
+   return >thread.fpsimd_state;
 }
 
 void xnarch_leave_root(struct xnthread *root)
@@ -76,13 +76,6 @@ void xnarch_leave_root(struct xnthread *root)
rootcb->fpup = get_fpu_owner(rootcb);
 }
 
-void xnarch_save_fpu(struct xnthread *thread)
-{
-   struct xnarchtcb *tcb = &(thread->tcb);
-   if (xnarch_fpu_ptr(tcb))
-   fpsimd_save_state(tcb->fpup);
-}
-
 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *to)
 {
struct fpsimd_state *const from_fpup = from ? from->tcb.fpup : NULL;
@@ -93,35 +86,16 @@ void xnarch_switch_fpu(struct xnthread *from, struct 
xnthread *to)
if (from_fpup == to_fpup)
return;
 
-   if (from_fpup)
-   fpsimd_save_state(from_fpup);
+   fpsimd_save_state(from_fpup);
 
fpsimd_load_state(to_fpup);
-}
-
-int xnarch_handle_fpu_fault(struct xnthread *from, 
-   struct xnthread *to, struct ipipe_trap_data *d)
-{
-   spl_t s;
-
-   /* FPU should already be enabled for XNFPU tasks. */
-   if (xnthread_test_state(to, XNFPU))
-   BUG();
-
-   xnlock_get_irqsave(, s);
-   xnthread_set_state(to, XNFPU);
-   xnlock_put_irqrestore(, s);
-
-   xnarch_switch_fpu(from, 

[Xenomai-git] Philippe Gerum : cobalt/arch: fixup READMEs

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: bb10dc18700f4e937e51d1ec5c00b0cea4fc01d9
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bb10dc18700f4e937e51d1ec5c00b0cea4fc01d9

Author: Philippe Gerum 
Date:   Mon Nov  2 15:41:31 2015 +0100

cobalt/arch: fixup READMEs

---

 kernel/cobalt/arch/arm64/patches/README |   16 
 1 file changed, 16 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/patches/README 
b/kernel/cobalt/arch/arm64/patches/README
deleted file mode 100644
index fd85e06..000
--- a/kernel/cobalt/arch/arm64/patches/README
+++ /dev/null
@@ -1,16 +0,0 @@
--- arch/arm64/patches
-
-Xenomai needs special kernel support to deliver fast and deterministic
-response time to external interrupts, and also to provide real-time
-services highly integrated with the standard Linux kernel.
-
-This support is provided by the interrupt pipeline (aka I-pipe) in the
-form of a kernel patch you have to apply against a vanilla kernel
-tree, before you attempt to compile the Xenomai codebase against the
-latter kernel.
-
-The Xenomai arm64 port is work in progress. The I-pipe support for
-this architecture is exclusively available from this development tree
-at the moment:
-
-git://git.xenomai.org/ipipe.git, branch devel/ipipe-3.18-linaro-arm64.


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


[Xenomai-git] Philippe Gerum : cobalt/kernel: fixup for v3.19+ (trace_seq)

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 626c150b7da7bbc68cab134862302ddfa9694b96
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=626c150b7da7bbc68cab134862302ddfa9694b96

Author: Philippe Gerum 
Date:   Tue Nov  3 13:11:25 2015 +0100

cobalt/kernel: fixup for v3.19+ (trace_seq)

---

 kernel/cobalt/include/asm-generic/xenomai/wrappers.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h 
b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index 96ca5f1..8e1dc39 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -61,6 +61,7 @@
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
 #include 
+#include 
 
 #undef alloc_netdev
 #define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \
@@ -73,7 +74,6 @@ 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)


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


[Xenomai-git] Jan Kiszka : smokey/posix-mutex: Fix test case /wrt mutex object reuse

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c1adcfd1da9dffcf23054aefc393ed573adee039
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c1adcfd1da9dffcf23054aefc393ed573adee039

Author: Jan Kiszka 
Date:   Thu Feb 25 11:29:00 2016 +0100

smokey/posix-mutex: Fix test case /wrt mutex object reuse

Mutex objects created on the stack must be properly destroyed after use.
Otherwise, succeeding tests that use the same stack layout will consider
them busy and refuse to recreate the mutexes.

Signed-off-by: Jan Kiszka 

---

 testsuite/smokey/posix-mutex/posix-mutex.c |   26 +-
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/testsuite/smokey/posix-mutex/posix-mutex.c 
b/testsuite/smokey/posix-mutex/posix-mutex.c
index ae82fc1..151c2f3 100644
--- a/testsuite/smokey/posix-mutex/posix-mutex.c
+++ b/testsuite/smokey/posix-mutex/posix-mutex.c
@@ -623,7 +623,10 @@ static int protect_raise(void)
 
if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM))
return -EINVAL;
-   
+
+   if (!__T(ret, pthread_mutex_destroy()))
+   return ret;
+
return 0;
 }
 
@@ -651,7 +654,10 @@ static int protect_lower(void)
 
if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM))
return -EINVAL;
-   
+
+   if (!__T(ret, pthread_mutex_destroy()))
+   return ret;
+
return 0;
 }
 
@@ -699,7 +705,10 @@ static int protect_weak(void)
if (!__T(ret, pthread_setschedparam(pthread_self(),
old_policy, _param)))
return ret;
-   
+
+   if (!__T(ret, pthread_mutex_destroy()))
+   return ret;
+
return 0;
 }
 
@@ -745,7 +754,11 @@ static int protect_nesting_protect(void)
 
if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM))
return -EINVAL;
-   
+
+   if (!__T(ret, pthread_mutex_destroy(_high)) ||
+   !__T(ret, pthread_mutex_destroy(_very_high)))
+   return ret;
+
return 0;
 }
 
@@ -782,7 +795,10 @@ static int protect_nesting_pi(void)
/* PP boost just dropped: HIGH -> MEDIUM. */
if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM))
return -EINVAL;
-   
+
+   if (!__T(ret, pthread_mutex_destroy(_pp)))
+   return ret;
+
return 0;
 }
 


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


[Xenomai-git] Philippe Gerum : cobalt/kernel: fixup for v3.19+ (user_msghdr)

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 258c792620c5c236226807cb084775ff39f94f30
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=258c792620c5c236226807cb084775ff39f94f30

Author: Philippe Gerum 
Date:   Mon Nov  2 20:45:10 2015 +0100

cobalt/kernel: fixup for v3.19+ (user_msghdr)

---

 kernel/cobalt/include/asm-generic/xenomai/wrappers.h |1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h 
b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index fa2dae4..96ca5f1 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -38,6 +38,7 @@
  *   symbol, so that obsolete wrappers can be spotted.
  */
 
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
 #define in_ia32_syscall() (current_thread_info()->status & TS_COMPAT)
 #endif


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


[Xenomai-git] Philippe Gerum : cobalt/arm: track current mm unconditionally

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: b7094435ad866072dd17522b4c3df039a47e3440
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b7094435ad866072dd17522b4c3df039a47e3440

Author: Philippe Gerum 
Date:   Sat Nov 14 15:21:02 2015 +0100

cobalt/arm: track current mm unconditionally

All pipelines Cobalt can work with (i.e. 3.10+) for the arm
architecture do provide the mm tracking feature unconditionally, so
there is no point in keeping any build switch for it.

---

 kernel/cobalt/arch/arm/Kconfig |3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/cobalt/arch/arm/Kconfig b/kernel/cobalt/arch/arm/Kconfig
index 2043d70..0c4e0aa 100644
--- a/kernel/cobalt/arch/arm/Kconfig
+++ b/kernel/cobalt/arch/arm/Kconfig
@@ -23,9 +23,6 @@ config IPIPE_WANT_PREEMPTIBLE_SWITCH
default y if XENO_ARCH_UNLOCKED_SWITCH
default n if !XENO_ARCH_UNLOCKED_SWITCH
 
-config IPIPE_WANT_ACTIVE_MM
-   def_bool y
-
 config XENO_ARCH_FPU
def_bool VFP
 


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


[Xenomai-git] Philippe Gerum : testsuite/smokey: mutex: simplify, introduce PP tests

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 075e015e864e34a1c1c6365536d97e5d8413c27d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=075e015e864e34a1c1c6365536d97e5d8413c27d

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

testsuite/smokey: mutex: simplify, introduce PP tests

At this chance, the lock stealing test is also fixed.

---

 testsuite/smokey/posix-mutex/posix-mutex.c | 1357 ++--
 1 file changed, 670 insertions(+), 687 deletions(-)

diff --git a/testsuite/smokey/posix-mutex/posix-mutex.c 
b/testsuite/smokey/posix-mutex/posix-mutex.c
index ac71b31..ae82fc1 100644
--- a/testsuite/smokey/posix-mutex/posix-mutex.c
+++ b/testsuite/smokey/posix-mutex/posix-mutex.c
@@ -4,6 +4,7 @@
  * Copyright (C) Gilles Chanteperdrix  ,
  *   Marion Deveaud ,
  *   Jan Kiszka 
+ *   Philippe Gerum 
  *
  * Released under the terms of GPLv2.
  */
@@ -17,8 +18,6 @@
 #include 
 #include 
 #include 
-#include 
-#include "lib/cobalt/current.h"
 #include 
 
 smokey_test_plugin(posix_mutex,
@@ -26,886 +25,870 @@ smokey_test_plugin(posix_mutex,
   "Check POSIX mutex services"
 );
 
-#define MUTEX_CREATE   1
-#define MUTEX_LOCK 2
-#define MUTEX_TRYLOCK  3
-#define MUTEX_TIMED_LOCK   4
-#define MUTEX_UNLOCK   5
-#define MUTEX_DESTROY  6
-#define COND_CREATE7
-#define COND_SIGNAL8
-#define COND_WAIT  9
-#define COND_DESTROY   10
-#define THREAD_DETACH  11
-#define THREAD_CREATE  12
-#define THREAD_JOIN13
-#define THREAD_RENICE   14
-
-#define NS_PER_MS  100
-
 static const char *reason_str[] = {
-   [SIGDEBUG_UNDEFINED] = "undefined",
+   [SIGDEBUG_UNDEFINED] = "received SIGDEBUG for unknown reason",
[SIGDEBUG_MIGRATE_SIGNAL] = "received signal",
[SIGDEBUG_MIGRATE_SYSCALL] = "invoked syscall",
[SIGDEBUG_MIGRATE_FAULT] = "triggered fault",
[SIGDEBUG_MIGRATE_PRIOINV] = "affected by priority inversion",
-   [SIGDEBUG_NOMLOCK] = "missing mlockall",
-   [SIGDEBUG_WATCHDOG] = "runaway thread",
+   [SIGDEBUG_NOMLOCK] = "process memory not locked",
+   [SIGDEBUG_WATCHDOG] = "watchdog triggered (period too short?)",
+   [SIGDEBUG_LOCK_BREAK] = "scheduler lock break",
 };
 
 static void sigdebug(int sig, siginfo_t *si, void *context)
 {
+   const char fmt[] = "%s, this is unexpected.\n"
+   "(enabling CONFIG_XENO_OPT_DEBUG_TRACE_RELAX may help)\n";
unsigned int reason = sigdebug_reason(si);
+   int n __attribute__ ((unused));
+   static char buffer[256];
 
-   smokey_trace("\nSIGDEBUG received, reason %d: %s\n", reason,
-reason <= SIGDEBUG_WATCHDOG ? reason_str[reason] : 
"");
-}
+   if (reason > SIGDEBUG_WATCHDOG)
+   reason = SIGDEBUG_UNDEFINED;
 
-static inline unsigned long long timer_get_tsc(void)
-{
-   return clockobj_get_tsc();
+   n = snprintf(buffer, sizeof(buffer), fmt, reason_str[reason]);
+   n = write(STDERR_FILENO, buffer, n);
 }
 
-static inline unsigned long long timer_tsc2ns(unsigned long long tsc)
-{
-   return clockobj_tsc_to_ns(tsc);
-}
+#define THREAD_PRIO_WEAK   0
+#define THREAD_PRIO_LOW1
+#define THREAD_PRIO_MEDIUM 2
+#define THREAD_PRIO_HIGH   3
+#define THREAD_PRIO_VERY_HIGH  4
 
-static void add_timespec(struct timespec *ts, unsigned long long value)
-{
-   ts->tv_sec += value / 10;
-   ts->tv_nsec += value % 10;
-   if (ts->tv_nsec > 10) {
-   ts->tv_sec++;
-   ts->tv_nsec -= 10;
-   }
-}
+#define MAX_100_MS  1ULL
+
+struct locker_context {
+   pthread_mutex_t *mutex;
+   struct smokey_barrier *barrier;
+   int lock_acquired;
+};
 
-static void ms_sleep(int time)
+static void sleep_ms(unsigned int ms)  /* < 1000 */
 {
struct timespec ts;
-
+   
ts.tv_sec = 0;
-   ts.tv_nsec = time*NS_PER_MS;
-
-   nanosleep(, NULL);
+   ts.tv_nsec = ms * 100;
+   clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL);
 }
 
-static void check_current_prio(int expected_prio)
+static int get_effective_prio(void) 
 {
struct cobalt_threadstat stat;
int ret;
 
ret = cobalt_thread_stat(0, );
-   if (ret) {
-   fprintf(stderr,
-   "FAILURE: cobalt_threadstat (%s)\n", strerror(-ret));
-   exit(EXIT_FAILURE);
-   }
+   if (ret)
+   return ret;
 
-   if (stat.cprio != expected_prio) {
-   fprintf(stderr,
-   "FAILURE: current prio (%d) != expected prio (%d)\n",
-   stat.cprio, expected_prio);
-   exit(EXIT_FAILURE);
-   }
+   

[Xenomai-git] Philippe Gerum : cobalt/arm64: drop obsolete config knob

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 636617111ea4c39b7796fc5e1ce946934f739dad
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=636617111ea4c39b7796fc5e1ce946934f739dad

Author: Philippe Gerum 
Date:   Sat Nov 14 18:17:49 2015 +0100

cobalt/arm64: drop obsolete config knob

All existing ARM64 pipeline implementations provide the
CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH knob, which is tested directly in
the Xenomai code base.  No need for CONFIG_XENO_ARCH_UNLOCKED_SWITCH
anymore.

---

 kernel/cobalt/arch/arm64/Kconfig |3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/Kconfig b/kernel/cobalt/arch/arm64/Kconfig
index 572de3e..bdf5f16 100644
--- a/kernel/cobalt/arch/arm64/Kconfig
+++ b/kernel/cobalt/arch/arm64/Kconfig
@@ -1,9 +1,6 @@
 source "kernel/xenomai/Kconfig"
 source "drivers/xenomai/Kconfig"
 
-config XENO_ARCH_UNLOCKED_SWITCH
-   def_bool IPIPE_WANT_PREEMPTIBLE_SWITCH
-
 config XENO_ARCH_FPU
def_bool y
 


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


[Xenomai-git] Jan Kiszka : cobalt: Do not destroy info flags on remote thread suspension

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 368f1ef5d1bb67d90159ea912e58d6a3dacc89a8
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=368f1ef5d1bb67d90159ea912e58d6a3dacc89a8

Author: Jan Kiszka 
Date:   Wed Jul 26 17:59:27 2017 +0200

cobalt: Do not destroy info flags on remote thread suspension

Scenario: A high prio thread is running and a low-prio is waiting for a
timeout. Now the timeout occurs, and the low-prio thread is woken up but
can't run yet. If the high-prio thread suspends the low-prio one,
XNTIMEO will be lost due to that. Similar scenarios a possible with
other info flags and remote suspension reasons.

Address them by clearing info flags only if the current thread is
suspending itself.

Signed-off-by: Jan Kiszka 

---

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

diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 1fdea99..067026e 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -900,8 +900,13 @@ void xnthread_suspend(struct xnthread *thread, int mask,
(oldstate & XNTRAPLB) != 0)
goto lock_break;
}
-   xnthread_clear_info(thread,
-   
XNRMID|XNTIMEO|XNBREAK|XNWAKEN|XNROBBED|XNKICKED);
+   /*
+* Do not destroy the info left behind by yet unprocessed
+* wakeups when suspending a remote thread.
+*/
+   if (thread == sched->curr)
+   xnthread_clear_info(thread, XNRMID|XNTIMEO|XNBREAK|
+   XNWAKEN|XNROBBED|XNKICKED);
}
 
/*


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


[Xenomai-git] Philippe Gerum : cobalt/powerpc: drop support for unlocked context switch

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: ccc6a6235ccf2c124adc273c20aaeca53ecff6b0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ccc6a6235ccf2c124adc273c20aaeca53ecff6b0

Author: Philippe Gerum 
Date:   Sat Nov 14 16:41:13 2015 +0100

cobalt/powerpc: drop support for unlocked context switch

This feature never actually brought any measurable gain on powerpc
platforms, compared to the complexity of its implementation in the
pipeline. It was primarily aimed at reducing latency for interrupt
handlers when costly cache and TLB flushes are required to switch
context, at the expense of increasing the scheduling latency.  It
turned out to be counter-productive on common powerpc platforms, with
efficient MMUs.

This feature has been default off for a while now, and 4.1+ pipelines
won't provide support for it anymore. Time to drop support from
Xenomai too.

---

 kernel/cobalt/arch/powerpc/Kconfig |   20 +---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/kernel/cobalt/arch/powerpc/Kconfig 
b/kernel/cobalt/arch/powerpc/Kconfig
index 40eae0b..1cabef3 100644
--- a/kernel/cobalt/arch/powerpc/Kconfig
+++ b/kernel/cobalt/arch/powerpc/Kconfig
@@ -5,29 +5,11 @@ config XENO_ARCH_MATH_EMU
 bool
default y if MATH_EMU || MATH_EMULATION
 
-config IPIPE_WANT_PREEMPTIBLE_SWITCH
-bool
-   default y if XENO_ARCH_UNLOCKED_SWITCH
-   default n if !XENO_ARCH_UNLOCKED_SWITCH
-
 config XENO_ARCH_FPU
def_bool PPC_FPU
 
 config XENO_ARCH_SYS3264
 def_bool n
 
-menu "Machine/platform-specific options"
-
 config XENO_ARCH_UNLOCKED_SWITCH
-   bool "Unlocked context switch"
-   depends on IPIPE_HAVE_PREEMPTIBLE_SWITCH
-   default y
-   help
-
-   The Cobalt core may allow non-atomic execution of the
-   machine-dependent context switching code, so that other CPUs
-   and/or local interrupts may execute concurrently.
-
-   This option reduces interrupt latency when costly cache and
-   TLB flushes are required to switch context.
-endmenu
+   def_bool n


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


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

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 0521016513cbbb62e4f0226fba5ef8f6de8e7a6d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0521016513cbbb62e4f0226fba5ef8f6de8e7a6d

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 +
 1 file changed, 1 insertion(+)

diff --git a/configure.ac b/configure.ac
index 457d026..9eeb34d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -926,6 +926,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 \


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


[Xenomai-git] Philippe Gerum : lib/cobalt: use lazy schedparam propagation

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 4892e0a3520b02dab3591653f81762f64410b4e5
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4892e0a3520b02dab3591653f81762f64410b4e5

Author: Philippe Gerum 
Date:   Fri Mar 18 12:12:27 2016 +0100

lib/cobalt: use lazy schedparam propagation

Do not switch to secondary mode upon schedparam updates for
propagating changes to the regular kernel, if the caller runs in
primary mode when entering pthread_setschedparam*() or
sched_setscheduler(). In such a case, the update request to the
regular kernel is left pending until the target thread resumes
execution in relaxed mode, at which point it is committed.

CAUTION: This mechanism won't update the schedparams cached by the
glibc for the caller in user-space, but this is the deal: we don't
relax threads which issue pthread_setschedparam[_ex]() from primary
mode anymore, but then only the kernel side (Cobalt and the host
kernel) will be aware of the change, and glibc might cache obsolete
information.

If the caller already runs in relaxed mode on entry to these services,
the update request takes place immediately, via the regular (g)libc
calls.

In any case, the new scheduling parameters for the target thread are
immediately applied by Cobalt, regardless of the update path followed
for the regular kernel.

---

 lib/cobalt/internal.c  |   43 ++
 lib/cobalt/sched.c |   13 
 lib/cobalt/sigshadow.c |8 +
 lib/cobalt/thread.c|   80 +---
 4 files changed, 86 insertions(+), 58 deletions(-)

diff --git a/lib/cobalt/internal.c b/lib/cobalt/internal.c
index 49744c4..ebc3624 100644
--- a/lib/cobalt/internal.c
+++ b/lib/cobalt/internal.c
@@ -516,6 +516,49 @@ int cobalt_sched_weighted_prio(int policy,
return XENOMAI_SYSCALL2(sc_cobalt_sched_weightprio, policy, param_ex);
 }
 
+int cobalt_xlate_schedparam(int policy,
+   const struct sched_param_ex *param_ex,
+   struct sched_param *param)
+{
+   int std_policy, priority;
+
+   /*
+* Translates Cobalt scheduling parameters to native ones,
+* based on a best approximation for Cobalt policies which are
+* not available from the host kernel.
+*/
+   std_policy = policy;
+   priority = param_ex->sched_priority;
+
+   switch (policy) {
+   case SCHED_WEAK:
+   std_policy = priority ? SCHED_FIFO : SCHED_OTHER;
+   break;
+   default:
+   std_policy = SCHED_FIFO;
+   /* falldown wanted. */
+   case SCHED_OTHER:
+   case SCHED_FIFO:
+   case SCHED_RR:
+   /*
+* The Cobalt priority range is larger than those of
+* the native SCHED_FIFO/RR classes, so we have to cap
+* the priority value accordingly.  We also remap
+* "weak" (negative) priorities - which are only
+* meaningful for the Cobalt core - to regular values.
+*/
+   if (priority > __cobalt_std_fifo_maxpri)
+   priority = __cobalt_std_fifo_maxpri;
+   }
+
+   if (priority < 0)
+   priority = -priority;
+   
+   memset(param, 0, sizeof(*param));
+   param->sched_priority = priority;
+
+   return std_policy;
+}
 
 /*
  * Temporary compatibility aliases which should be phased out at next
diff --git a/lib/cobalt/sched.c b/lib/cobalt/sched.c
index b0292b5..87b9235 100644
--- a/lib/cobalt/sched.c
+++ b/lib/cobalt/sched.c
@@ -26,7 +26,6 @@
 #include 
 #include 
 #include 
-#include "current.h"
 #include "internal.h"
 
 /**
@@ -297,11 +296,13 @@ int sched_setscheduler_ex(pid_t pid,
return EINVAL;
 
/* See pthread_setschedparam_ex(). */
-   
-   std_policy = cobalt_xlate_schedparam(policy, param_ex, _param);
-   ret = __STD(sched_setscheduler(pid, std_policy, _param));
-   if (ret)
-   return errno;
+
+   if (cobalt_is_relaxed()) {
+   std_policy = cobalt_xlate_schedparam(policy, param_ex, 
_param);
+   ret = __STD(sched_setscheduler(pid, std_policy, _param));
+   if (ret)
+   return errno;
+   }
 
ret = -XENOMAI_SYSCALL5(sc_cobalt_sched_setscheduler_ex,
pid, policy, param_ex,
diff --git a/lib/cobalt/sigshadow.c b/lib/cobalt/sigshadow.c
index f58e341..fc8adf6 100644
--- a/lib/cobalt/sigshadow.c
+++ b/lib/cobalt/sigshadow.c
@@ -57,6 +57,14 @@ int cobalt_sigshadow_handler(int sig, siginfo_t *si, void 
*ctxt)
skip = nr > 3 ? 3 : 0;
XENOMAI_SYSCALL3(sc_cobalt_backtrace, nr - skip, frames + skip, 
arg);
break;
+   case SIGSHADOW_ACTION_HOME:
+   /*
+* We have been asked to call home from the current
+* context: sending a query for retrieving 

[Xenomai-git] Jan Kiszka : lib/cobalt: Wrap pthread_setschedprio for proper real-time support

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 7b60732784e7023337010ff3b0738543e8640e4b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7b60732784e7023337010ff3b0738543e8640e4b

Author: Jan Kiszka 
Date:   Tue Mar  8 14:46:59 2016 +0100

lib/cobalt: Wrap pthread_setschedprio for proper real-time support

Implement pthread_setschedprio on top of pthread_setschedparam_ex with
the help of the new __SCHED_CURRENT policy. This ensures that prio
changes are directly applied to the real-time core, and that with just
a single syscall.

Signed-off-by: Jan Kiszka 

---

 include/cobalt/pthread.h   |2 ++
 lib/cobalt/cobalt.wrappers |1 +
 lib/cobalt/thread.c|9 +
 lib/cobalt/wrappers.c  |6 ++
 4 files changed, 18 insertions(+)

diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h
index f1b1c8a..3e9bd47 100644
--- a/include/cobalt/pthread.h
+++ b/include/cobalt/pthread.h
@@ -53,6 +53,8 @@ COBALT_DECL(int, pthread_setschedparam(pthread_t thread,
   int policy,
   const struct sched_param *param));
 
+COBALT_DECL(int, pthread_setschedprio(pthread_t thread, int prio));
+
 COBALT_DECL(int, pthread_mutex_init(pthread_mutex_t *mutex,
const pthread_mutexattr_t *attr));
 
diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers
index 4f883f3..f8bda39 100644
--- a/lib/cobalt/cobalt.wrappers
+++ b/lib/cobalt/cobalt.wrappers
@@ -2,6 +2,7 @@
 --wrap pthread_create
 --wrap pthread_setschedparam
 --wrap pthread_getschedparam
+--wrap pthread_setschedprio
 --wrap pthread_yield
 --wrap sched_yield
 --wrap sched_get_priority_min
diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index 908516f..62ca0a0 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -650,6 +650,15 @@ int pthread_setschedparam_ex(pthread_t thread,
return ret;
 }
 
+COBALT_IMPL(int, pthread_setschedprio, (pthread_t thread, int prio))
+{
+   struct sched_param_ex param_ex = {
+   .sched_priority = prio,
+   };
+
+   return pthread_setschedparam_ex(thread, __SCHED_CURRENT, _ex);
+}
+
 /**
  * Get the scheduling policy and parameters of the specified thread.
  *
diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c
index 8bd9190..8dd28fb 100644
--- a/lib/cobalt/wrappers.c
+++ b/lib/cobalt/wrappers.c
@@ -60,6 +60,12 @@ int __real_pthread_getschedparam(pthread_t thread,
 }
 
 __weak
+int __real_pthread_setschedprio(pthread_t thread, int prio)
+{
+   return pthread_setschedprio(thread, prio);
+}
+
+__weak
 int __real_sched_yield(void)
 {
return sched_yield();


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


[Xenomai-git] Philippe Gerum : cobalt/sched: detect preemptible switch support in pipeline

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 13b41f76d3126d082881f8ef091adfc5b3a04e5d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=13b41f76d3126d082881f8ef091adfc5b3a04e5d

Author: Philippe Gerum 
Date:   Sat Nov 14 18:07:15 2015 +0100

cobalt/sched: detect preemptible switch support in pipeline

CONFIG_XENO_ARCH_UNLOCKED_SWITCH is merely an alias for
CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH, which is only meaningful to the
ARM architecture, now that PowerPC dropped such support.

Use the pipeline symbol directly to make the dependency explicit.

---

 include/cobalt/kernel/sched.h |8 
 kernel/cobalt/sched.c |   16 
 kernel/cobalt/thread.c|2 +-
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/cobalt/kernel/sched.h b/include/cobalt/kernel/sched.h
index fe1df7d..d5d93c2 100644
--- a/include/cobalt/kernel/sched.h
+++ b/include/cobalt/kernel/sched.h
@@ -93,7 +93,7 @@ struct xnsched {
struct xntimer rrbtimer;
/*!< Root thread control block. */
struct xnthread rootcb;
-#ifdef CONFIG_XENO_ARCH_UNLOCKED_SWITCH
+#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
struct xnthread *last;
 #endif
 #ifdef CONFIG_XENO_ARCH_FPU
@@ -329,7 +329,7 @@ static inline int xnsched_primary_p(void)
return !xnsched_unblockable_p();
 }
 
-#ifdef CONFIG_XENO_ARCH_UNLOCKED_SWITCH
+#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
 
 struct xnsched *xnsched_finish_unlocked_switch(struct xnsched *sched);
 
@@ -341,7 +341,7 @@ int xnsched_maybe_resched_after_unlocked_switch(struct 
xnsched *sched)
return sched->status & XNRESCHED;
 }
 
-#else /* !CONFIG_XENO_ARCH_UNLOCKED_SWITCH */
+#else /* !CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH */
 
 static inline struct xnsched *
 xnsched_finish_unlocked_switch(struct xnsched *sched)
@@ -358,7 +358,7 @@ xnsched_maybe_resched_after_unlocked_switch(struct xnsched 
*sched)
return 0;
 }
 
-#endif /* !CONFIG_XENO_ARCH_UNLOCKED_SWITCH */
+#endif /* !CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH */
 
 #ifdef CONFIG_XENO_OPT_WATCHDOG
 static inline void xnsched_reset_watchdog(struct xnsched *sched)
diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index e071919..d6674a7 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -293,7 +293,7 @@ struct xnthread *xnsched_pick_next(struct xnsched *sched)
 #endif /* CONFIG_XENO_OPT_SCHED_CLASSES */
 }
 
-#ifdef CONFIG_XENO_ARCH_UNLOCKED_SWITCH
+#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
 
 struct xnsched *xnsched_finish_unlocked_switch(struct xnsched *sched)
 {
@@ -319,7 +319,7 @@ struct xnsched *xnsched_finish_unlocked_switch(struct 
xnsched *sched)
return sched;
 }
 
-#endif /* CONFIG_XENO_ARCH_UNLOCKED_SWITCH */
+#endif /* CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH */
 
 void xnsched_lock(void)
 {
@@ -477,16 +477,16 @@ void xnsched_migrate(struct xnthread *thread, struct 
xnsched *sched)
xnsched_set_resched(thread->sched);
migrate_thread(thread, sched);
 
-#ifdef CONFIG_XENO_ARCH_UNLOCKED_SWITCH
+#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
/*
 * Mark the thread in flight, xnsched_finish_unlocked_switch()
 * will put the thread on the remote runqueue.
 */
xnthread_set_state(thread, XNMIGRATE);
-#else /* !CONFIG_XENO_ARCH_UNLOCKED_SWITCH */
+#else
/* Move thread to the remote runnable queue. */
xnsched_putback(thread);
-#endif /* !CONFIG_XENO_ARCH_UNLOCKED_SWITCH */
+#endif
 }
 
 /*
@@ -692,11 +692,11 @@ struct xnthread *xnsched_rt_pick(struct xnsched *sched)
 static inline void switch_context(struct xnsched *sched,
  struct xnthread *prev, struct xnthread *next)
 {
-#ifdef CONFIG_XENO_ARCH_UNLOCKED_SWITCH
+#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
sched->last = prev;
sched->status |= XNINSW;
xnlock_clear_irqon();
-#endif /* !CONFIG_XENO_ARCH_UNLOCKED_SWITCH */
+#endif
 
xnarch_switch_to(prev, next);
 }
@@ -771,7 +771,7 @@ static inline void enter_root(struct xnthread *root)
 {
struct xnarchtcb *rootcb __maybe_unused = xnthread_archtcb(root);
 
-#ifdef CONFIG_XENO_ARCH_UNLOCKED_SWITCH
+#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
if (rootcb->core.mm == NULL)
set_ti_thread_flag(rootcb->core.tip, TIF_MMSWITCH_INT);
 #endif
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index b3027d0..adb15e6 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -408,7 +408,7 @@ EXPORT_SYMBOL_GPL(xnthread_prepare_wait);
 static inline int moving_target(struct xnsched *sched, struct xnthread *thread)
 {
int ret = 0;
-#ifdef CONFIG_XENO_ARCH_UNLOCKED_SWITCH
+#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
/*
 * When deleting a thread in the course of a context switch or
 * in flight to another CPU with nklock unlocked on a distant


___
Xenomai-git mailing list

[Xenomai-git] Philippe Gerum : cobalt/arm64: use lazy fpsimd switch mode

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: cf10dfe7f50098d5207de1618d418197f9a7607a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=cf10dfe7f50098d5207de1618d418197f9a7607a

Author: Philippe Gerum 
Date:   Mon Oct 19 10:38:21 2015 +0200

cobalt/arm64: use lazy fpsimd switch mode

---

 kernel/cobalt/arch/arm64/thread.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/arch/arm64/thread.c 
b/kernel/cobalt/arch/arm64/thread.c
index 5282b0c..2238751 100644
--- a/kernel/cobalt/arch/arm64/thread.c
+++ b/kernel/cobalt/arch/arm64/thread.c
@@ -153,7 +153,7 @@ void xnarch_switch_to(struct xnthread *out, struct xnthread 
*in)
enter_lazy_tlb(prev_mm, next);
}
 
-   __switch_to(prev, next);
+   ipipe_switch_to(prev, next);
 }
 
 int xnarch_escalate(void)


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


[Xenomai-git] Philippe Gerum : drivers/spi: enable backend driver for all BCM2835-based SoCs

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 88709db3ed52856ab8a228fd7cb23ef372ef0c7a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=88709db3ed52856ab8a228fd7cb23ef372ef0c7a

Author: Philippe Gerum 
Date:   Tue Jul 25 18:32:46 2017 +0200

drivers/spi: enable backend driver for all BCM2835-based SoCs

---

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

diff --git a/kernel/drivers/spi/Kconfig b/kernel/drivers/spi/Kconfig
index 817e9b9..9f14985 100644
--- a/kernel/drivers/spi/Kconfig
+++ b/kernel/drivers/spi/Kconfig
@@ -5,7 +5,7 @@ config XENO_DRIVERS_SPI
tristate
 
 config XENO_DRIVERS_SPI_BCM2835
-   depends on ARCH_BCM2708
+   depends on ARCH_BCM2708 || ARCH_BCM2835
select XENO_DRIVERS_SPI
tristate "Support for BCM2835 SPI"
help


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


[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: set cache aliasing and disable floating point coprocessor instructions form aarch64 /arm64

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: f67e4bd40870dcddcd9e97b965338425038cbe1e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f67e4bd40870dcddcd9e97b965338425038cbe1e

Author: Dmitriy Cherkasov 
Date:   Thu May  7 16:41:45 2015 -0700

cobalt/arm64: set cache aliasing and disable floating point coprocessor 
instructions form aarch64/arm64

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h|3 ++-
 .../cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h   |   13 -
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
index cf07a3f..e078564 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
@@ -38,7 +38,8 @@
 #include 
 #include 
 
-#define xnarch_cache_aliasing() cache_is_vivt()
+/* D-side always behaves as PIPT on AArch64 (see 
arch/arm64/include/asm/cachetype.h) */
+#define xnarch_cache_aliasing() 0
 
 static inline __attribute_const__ unsigned long ffnz(unsigned long ul)
 {
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h
index b81d109..65a3e31 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h
@@ -18,10 +18,17 @@
 #ifndef _COBALT_ARM_ASM_UAPI_FPTEST_H
 #define _COBALT_ARM_ASM_UAPI_FPTEST_H
 
+#ifdef __aarch64__
+/* CP10 and CP11, used for the FP/NEON operations, are already excluded from
+the list of valid operands for the generic coprocessor instructions */
+#define __COBALT_HAVE_VFP  0
+#else
 #define __COBALT_HAVE_VFP  0x1
+#endif
 
 static inline void fp_regs_set(int features, unsigned int val)
 {
+#if __COBALT_HAVE_VFP != 0
unsigned long long e[16];
unsigned int i;
 
@@ -34,12 +41,15 @@ static inline void fp_regs_set(int features, unsigned int 
val)
__asm__ __volatile__("ldc p11, cr0, [%0],#32*4":
 "=r"(i): "0"([0]): "memory");
}
+#endif
 }
 
 static inline unsigned int fp_regs_check(int features, unsigned int val,
 int (*report)(const char *fmt, ...))
 {
-   unsigned int result = val, i;
+   unsigned int result = val;
+#if __COBALT_HAVE_VFP != 0
+   unsigned int i;
unsigned long long e[16];
 
if (features & __COBALT_HAVE_VFP) {
@@ -54,6 +64,7 @@ static inline unsigned int fp_regs_check(int features, 
unsigned int val,
result = e[i];
}
}
+#endif
 
return result;
 }


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


[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: add basic FPU support

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: b4a20881b8ed7ba36c5bd24d06c3475ea3387d54
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b4a20881b8ed7ba36c5bd24d06c3475ea3387d54

Author: Dmitriy Cherkasov 
Date:   Fri Sep 11 17:58:54 2015 -0700

cobalt/arm64: add basic FPU support

---

 kernel/cobalt/arch/arm64/Kconfig   |2 +-
 .../cobalt/arch/arm64/include/asm/xenomai/fptest.h |   11 +-
 .../cobalt/arch/arm64/include/asm/xenomai/thread.h |   17 +-
 .../arch/arm64/include/asm/xenomai/uapi/fptest.h   |   83 +++--
 kernel/cobalt/arch/arm64/thread.c  |  329 +---
 lib/cobalt/arch/arm64/features.c   |4 +-
 6 files changed, 153 insertions(+), 293 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/Kconfig b/kernel/cobalt/arch/arm64/Kconfig
index dd5a8c6..27b5026 100644
--- a/kernel/cobalt/arch/arm64/Kconfig
+++ b/kernel/cobalt/arch/arm64/Kconfig
@@ -8,7 +8,7 @@ config XENO_ARCH_WANT_TIP
def_bool y
 
 config XENO_ARCH_FPU
-   def_bool VFP
+   def_bool y
 
 config XENO_ARCH_SYS3264
 def_bool n
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h
index a76f1e6..743d758 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h
@@ -20,15 +20,10 @@
 #define _COBALT_ARM_ASM_FPTEST_H
 
 #include 
+#include 
 #include 
 
-#ifdef CONFIG_VFP
-#define have_vfp (elf_hwcap & HWCAP_VFP)
-#else /* !CONFIG_VFP */
-#define have_vfp 0
-#endif /* !CONFIG_VFP */
-
-#include 
+#define have_fp (elf_hwcap & HWCAP_FP)
 
 static inline int fp_kernel_supported(void)
 {
@@ -46,7 +41,7 @@ static inline void fp_linux_end(void)
 
 static inline int fp_detect(void)
 {
-   return have_vfp ? __COBALT_HAVE_VFP : 0;
+   return have_fp ? __COBALT_HAVE_FPU : 0;
 }
 
 #endif /* _COBALT_ARM_ASM_FPTEST_H */
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
index a8d7ed4..bfcceb4 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
@@ -21,21 +21,12 @@
 
 #include 
 
-#ifdef CONFIG_XENO_ARCH_FPU
-#ifdef CONFIG_VFP
-#include 
-#endif /* CONFIG_VFP */
-#endif /* !CONFIG_XENO_ARCH_FPU */
 
 struct xnarchtcb {
struct xntcb core;
 #ifdef CONFIG_XENO_ARCH_FPU
-#ifdef CONFIG_VFP
-   union vfp_state *fpup;
+   struct fpsimd_state *fpup;
 #define xnarch_fpu_ptr(tcb) ((tcb)->fpup)
-#else
-#define xnarch_fpu_ptr(tcb) NULL
-#endif
 #endif
struct {
unsigned long pc;
@@ -67,7 +58,7 @@ static inline void xnarch_enter_root(struct xnthread *root) { 
}
 
 int xnarch_escalate(void);
 
-#if defined(CONFIG_XENO_ARCH_FPU) && defined(CONFIG_VFP)
+#if defined(CONFIG_XENO_ARCH_FPU)
 
 static inline void xnarch_init_root_tcb(struct xnthread *thread)
 {
@@ -88,7 +79,7 @@ void xnarch_switch_fpu(struct xnthread *from, struct xnthread 
*thread);
 int xnarch_handle_fpu_fault(struct xnthread *from, 
struct xnthread *to, struct ipipe_trap_data *d);
 
-#else /* !CONFIG_XENO_ARCH_FPU || !CONFIG_VFP */
+#else /* !CONFIG_XENO_ARCH_FPU */
 
 static inline void xnarch_init_root_tcb(struct xnthread *thread) { }
 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
@@ -114,7 +105,7 @@ static inline int xnarch_handle_fpu_fault(struct xnthread 
*from,
 {
return 0;
 }
-#endif /*  !CONFIG_XENO_ARCH_FPU || !CONFIG_VFP */
+#endif /*  !CONFIG_XENO_ARCH_FPU */
 
 static inline void xnarch_enable_kfpu(void) { }
 
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h
index 65a3e31..25bc976 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h
@@ -18,53 +18,86 @@
 #ifndef _COBALT_ARM_ASM_UAPI_FPTEST_H
 #define _COBALT_ARM_ASM_UAPI_FPTEST_H
 
-#ifdef __aarch64__
-/* CP10 and CP11, used for the FP/NEON operations, are already excluded from
-the list of valid operands for the generic coprocessor instructions */
-#define __COBALT_HAVE_VFP  0
-#else
-#define __COBALT_HAVE_VFP  0x1
-#endif
+#define __COBALT_HAVE_FPU  0x1
 
 static inline void fp_regs_set(int features, unsigned int val)
 {
-#if __COBALT_HAVE_VFP != 0
-   unsigned long long e[16];
+
+   unsigned long long e[32];
unsigned int i;
 
-   if (features & __COBALT_HAVE_VFP) {
-   for (i = 0; i < 16; i++)
+   if (features & __COBALT_HAVE_FPU) {
+
+   for (i = 0; i < 32; i++)
e[i] = val;
 
-   /* vldm %0!, {d0-d15},
-  AKA fldmiax %0!, {d0-d15} */
-   __asm__ __volatile__("ldc p11, cr0, [%0],#32*4":
-"=r"(i): "0"([0]): "memory");
+

[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: Makefile: fix arch path

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: aae388e70166e1b43ff8477bc810cb06acbb7ad3
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=aae388e70166e1b43ff8477bc810cb06acbb7ad3

Author: Dmitriy Cherkasov 
Date:   Thu May  7 13:54:32 2015 -0700

cobalt/arm64: Makefile: fix arch path

---

 kernel/cobalt/arch/arm64/Makefile |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/arch/arm64/Makefile 
b/kernel/cobalt/arch/arm64/Makefile
index f2e4e20..a135f99 100644
--- a/kernel/cobalt/arch/arm64/Makefile
+++ b/kernel/cobalt/arch/arm64/Makefile
@@ -2,4 +2,4 @@ obj-$(CONFIG_XENOMAI) += xenomai.o
 
 xenomai-y := machine.o mayday.o thread.o switch.o syscall.o
 
-ccflags-y := -Iarch/arm/xenomai/include -Iinclude/xenomai
+ccflags-y := -Iarch/arm64/xenomai/include -Iinclude/xenomai


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


[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: populate arch/arm64 with a copy of arch/ arm.

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c3300fa9983d73c63e2536fae39b91197b0fef55
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c3300fa9983d73c63e2536fae39b91197b0fef55

Author: Dmitriy Cherkasov 
Date:   Wed May  6 15:27:23 2015 -0700

cobalt/arm64: populate arch/arm64 with a copy of arch/arm.

kernel/cobalt/arch/arm -> kernel/cobalt/arch/arm64
lib/cobalt/arch/arm -> lib/cobalt/arch/arm64

---

 configure.ac   |   12 +-
 kernel/cobalt/arch/arm64/Kconfig   |   40 +++
 kernel/cobalt/arch/arm64/Makefile  |5 +
 .../arch/arm64/include/asm/xenomai/calibration.h   |   59 
 .../arch/arm64/include/asm/xenomai/features.h  |   30 ++
 .../cobalt/arch/arm64/include/asm/xenomai/fptest.h |   52 +++
 .../arch/arm64/include/asm/xenomai/machine.h   |   85 +
 .../arch/arm64/include/asm/xenomai/syscall.h   |   74 
 .../arch/arm64/include/asm/xenomai/syscall32.h |   24 ++
 .../cobalt/arch/arm64/include/asm/xenomai/thread.h |  123 +++
 .../arch/arm64/include/asm/xenomai/uapi/arith.h|  142 
 .../arch/arm64/include/asm/xenomai/uapi/features.h |   43 +++
 .../arch/arm64/include/asm/xenomai/uapi/fptest.h   |   61 
 .../arch/arm64/include/asm/xenomai/uapi/syscall.h  |   34 ++
 .../arch/arm64/include/asm/xenomai/uapi/tsc.h  |   25 ++
 .../arch/arm64/include/asm/xenomai/wrappers.h  |   27 ++
 kernel/cobalt/arch/arm64/machine.c |  119 +++
 kernel/cobalt/arch/arm64/mayday.c  |  146 
 kernel/cobalt/arch/arm64/switch.S  |  167 +
 kernel/cobalt/arch/arm64/syscall.c |   53 +++
 kernel/cobalt/arch/arm64/thread.c  |  355 
 lib/cobalt/arch/Makefile.am|2 +-
 lib/cobalt/arch/arm64/Makefile.am  |   13 +
 lib/cobalt/arch/arm64/features.c   |  102 ++
 lib/cobalt/arch/arm64/include/Makefile.am  |2 +
 lib/cobalt/arch/arm64/include/asm/Makefile.am  |2 +
 .../arch/arm64/include/asm/xenomai/Makefile.am |5 +
 .../arch/arm64/include/asm/xenomai/features.h  |   62 
 .../arch/arm64/include/asm/xenomai/syscall.h   |  138 
 lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h|   48 +++
 30 files changed, 2047 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6593f5d..97bebf0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -139,6 +139,10 @@ case "$build_for" in
target_cpu_arch=arm
CONFIG_XENO_DEFAULT_PERIOD=100
;;
+ aarch64-*)
+   target_cpu_arch=arm64
+   CONFIG_XENO_DEFAULT_PERIOD=100
+   ;;
  x86_64-*|amd64-*)
use_tls=yes
target_cpu_arch=x86
@@ -361,7 +365,7 @@ fi
 
 dnl VSYSCALL (default: enabled) for Cobalt/x86
 
-if test $XENO_TARGET_ARCH = x86 -a $rtcore_type = cobalt; then
+if test $target_cpu_arch = x86 -a $rtcore_type = cobalt; then
   CONFIG_XENO_X86_VSYSCALL=y
   AC_MSG_CHECKING(for x86 VSYSCALL availability)
   AC_ARG_ENABLE(x86-vsyscall,
@@ -788,7 +792,7 @@ dnl Autoconf-generated symbols have been listed.
 AH_BOTTOM([#endif /* __IN_XENO__ */])
 
 if test $rtcore_type = cobalt; then
-   XENO_USER_CFLAGS="-I$topdir/lib/cobalt/arch/$XENO_TARGET_ARCH/include 
-I$topdir/kernel/cobalt/arch/$XENO_TARGET_ARCH/include $XENO_USER_CFLAGS"
+   XENO_USER_CFLAGS="-I$topdir/lib/cobalt/arch/$target_cpu_arch/include 
-I$topdir/kernel/cobalt/arch/$target_cpu_arch/include $XENO_USER_CFLAGS"
XENO_COBALT_CFLAGS="$XENO_USER_CFLAGS"
case "$build_for" in
 i*86*-*) XENO_COBALT_CFLAGS="$XENO_COBALT_CFLAGS -fno-omit-frame-pointer";;
@@ -868,6 +872,10 @@ AC_CONFIG_FILES([ \
lib/cobalt/arch/arm/include/Makefile \
lib/cobalt/arch/arm/include/asm/Makefile \
lib/cobalt/arch/arm/include/asm/xenomai/Makefile \
+   lib/cobalt/arch/arm64/Makefile \
+   lib/cobalt/arch/arm64/include/Makefile \
+   lib/cobalt/arch/arm64/include/asm/Makefile \
+   lib/cobalt/arch/arm64/include/asm/xenomai/Makefile \
lib/cobalt/arch/powerpc/Makefile \
lib/cobalt/arch/powerpc/include/Makefile \
lib/cobalt/arch/powerpc/include/asm/Makefile \
diff --git a/kernel/cobalt/arch/arm64/Kconfig b/kernel/cobalt/arch/arm64/Kconfig
new file mode 100644
index 000..dc6485d
--- /dev/null
+++ b/kernel/cobalt/arch/arm64/Kconfig
@@ -0,0 +1,40 @@
+source "kernel/xenomai/Kconfig"
+source "drivers/xenomai/Kconfig"
+
+menu "Machine/platform-specific options"
+
+config XENO_ARCH_UNLOCKED_SWITCH
+   bool "Unlocked context switch"
+   default y
+   help
+   The Cobalt core may allow non-atomic execution of the
+   machine-dependent context switching code, so that other CPUs
+   and/or local interrupts may execute concurrently.
+
+   This option reduces interrupt latency when costly cache and
+   TLB flushes are required to switch context.
+
+  

[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: add lazy FPU switching

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: a0d1084cb55cce427783635674691faa8e982328
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a0d1084cb55cce427783635674691faa8e982328

Author: Dmitriy Cherkasov 
Date:   Thu Oct  1 15:47:41 2015 -0700

cobalt/arm64: add lazy FPU switching

---

 kernel/cobalt/arch/arm64/thread.c |   83 +++--
 1 file changed, 62 insertions(+), 21 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/thread.c 
b/kernel/cobalt/arch/arm64/thread.c
index 316525f6..db369be 100644
--- a/kernel/cobalt/arch/arm64/thread.c
+++ b/kernel/cobalt/arch/arm64/thread.c
@@ -32,16 +32,31 @@
 #include 
 #include 
 #include 
-
+#include 
 
 #if defined(CONFIG_XENO_ARCH_FPU)
 
-static DEFINE_MUTEX(vfp_check_lock);
+static void enable_fpsimd(void) {
+   __asm__ __volatile__("mrs x1, cpacr_el1\n\
+   orr x1, x1, #(0x3 << 20)\n\
+   msr cpacr_el1, x1\n\
+   isb" : : : "x1", "memory", "cc");
+}
 
+static void disable_fpsimd(void) {
+   __asm__ __volatile__("mrs x1, cpacr_el1\n\
+   and x1, x1, #~(0x3 << 20)\n\
+   msr cpacr_el1, x1\n\
+   isb" : : : "x1", "memory", "cc");
+}
 
 int xnarch_fault_fpu_p(struct ipipe_trap_data *d)
 {
-   /* FPU never trapped, this will be a fault */
+   /* check if this is an FPU access trap to be handled by Xenomai */
+   if(d->exception == IPIPE_TRAP_FPU_ACC){
+   return 1;
+   }
+   /* FPU already enabled, propagate fault to kernel */
return 0;
 }
 
@@ -53,6 +68,7 @@ void xnarch_leave_root(struct xnthread *root)
 {
struct xnarchtcb *rootcb = xnthread_archtcb(root);
rootcb->fpup = get_fpu_owner(rootcb);
+   disable_fpsimd();
 }
 
 void xnarch_save_fpu(struct xnthread *thread)
@@ -65,45 +81,67 @@ void xnarch_save_fpu(struct xnthread *thread)
 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *to)
 {
struct fpsimd_state *const from_fpup = from ? from->tcb.fpup : NULL;
-
-   /* always switch, no lazy switching */
-
struct fpsimd_state *const to_fpup = to->tcb.fpup;
 
-   if (from_fpup == to_fpup)
-   return;
+   /*
+* This only gets called if XNFPU flag is set, or if migrating to Linux.
+* In both cases, this means turn on FPU and switch.
+*/
+   enable_fpsimd();
+
+   if (xnthread_test_state(to, XNROOT) == 0) {
+   if (from_fpup == to_fpup)
+   return;
 
-   if (from_fpup)
-   fpsimd_save_state(from_fpup);
+   if (from_fpup)
+   fpsimd_save_state(from_fpup);
 
-   fpsimd_load_state(to_fpup);
+   fpsimd_load_state(to_fpup);
+   }
+   else {
+   /* Going to Linux. */
+   if (from_fpup)
+   fpsimd_save_state(from_fpup);
 
-   /* always set FPU enabled */
-   xnthread_set_state(to, XNFPU);
+   fpsimd_load_state(to_fpup);
+   }
 
 }
 
 int xnarch_handle_fpu_fault(struct xnthread *from, 
struct xnthread *to, struct ipipe_trap_data *d)
 {
-   /* FPU always enabled, faults force exit to Linux */
-   return 0;
+   spl_t s;
+
+   if (xnthread_test_state(to, XNFPU))
+   /* FPU is already enabled, probably an exception */
+  return 0;
+
+   xnlock_get_irqsave(, s);
+   xnthread_set_state(to, XNFPU);
+   xnlock_put_irqrestore(, s);
+
+   xnarch_switch_fpu(from, to);
+
+   return 1;
+
 }
 
 void xnarch_init_shadow_tcb(struct xnthread *thread)
 {
+   spl_t s;
struct xnarchtcb *tcb = xnthread_archtcb(thread);
 
tcb->fpup = &(tcb->core.host_task->thread.fpsimd_state);
 
-   /* XNFPU is always set, no lazy switching */
-   xnthread_set_state(thread, XNFPU);
+   xnlock_get_irqsave(, s);
+   xnthread_clear_state(thread, XNFPU);
+   xnlock_put_irqrestore(, s);
+
 }
 #endif /* CONFIG_XENO_ARCH_FPU */
 
-
 /* Switch support functions */
-
 static void xnarch_tls_thread_switch(struct task_struct *next)
 {
unsigned long tpidr, tpidrro;
@@ -141,8 +179,7 @@ static inline void xnarch_contextidr_thread_switch(struct 
task_struct *next)
 {
 }
 #endif
-
-/*/Switch support functions */
+/* End switch support functions */
 
 void xnarch_switch_to(struct xnthread *out, struct xnthread *in)
 {
@@ -173,6 +210,10 @@ void xnarch_switch_to(struct xnthread *out, struct 
xnthread *in)
xnarch_tls_thread_switch(in_tcb->core.tip->task);
xnarch_contextidr_thread_switch(in_tcb->core.tip->task);
 
+   /* check if we need to switch FPU on return to Linux */
+   if (xnthread_test_state(in, XNROOT) == 1)
+   xnarch_switch_fpu(out, in);
+
/*
 * Complete any pending TLB or cache maintenance on this CPU in case
 * the thread 

[Xenomai-git] Don Mahurin : cobalt/arm64: Use empty mayday implementation for arm64.

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c6cba227cc5d6e2bd400c354d25b81c1dfc6088a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c6cba227cc5d6e2bd400c354d25b81c1dfc6088a

Author: Don Mahurin 
Date:   Mon Sep 14 12:52:27 2015 -0700

cobalt/arm64: Use empty mayday implementation for arm64.

The arm mayday implementation was not correct for arm64. Replace with empty 
implementation.
Handle mayday in the linux domain, using xnthread_relax. This change is 
essentially the same as the general change proposed in the 'Mayday issues 
again' discussion (Jan Kiszka, Jun 21), though only applied to arch/arm64.

---

 kernel/cobalt/arch/arm64/mayday.c |   86 +
 1 file changed, 1 insertion(+), 85 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/mayday.c 
b/kernel/cobalt/arch/arm64/mayday.c
index bc51ad6..ca1151c 100644
--- a/kernel/cobalt/arch/arm64/mayday.c
+++ b/kernel/cobalt/arch/arm64/mayday.c
@@ -28,72 +28,6 @@ static void *mayday;
 
 static inline void setup_mayday(void *page)
 {
-   /*
-* We want this code to appear at the top of the MAYDAY page:
-*
-* ifdef ARM_EABI
-*
-* e59f000c ldr r0, [pc, #12]
-* e59f700c ldr r7, [pc, #12]
-* ef00 svc 0x
-* e3a0 mov r0, #0
-* e580 str r0, [r0]; 
-* 105e .word   0x105e  ; sc_cobalt_mayday | 
__COBALT_SYSCALL_BIT
-* 000f0042 .word   0x000f0042
-*
-* elif ARM_OABI
-*
-* e59f0008 ldr r0, [pc, #8]
-* ef9f0042 swi 0x009f0042
-* e3a0 mov r0, #0
-* e580 str r0, [r0]; 
-* 105e .word   0x105e  ; sc_cobalt_mayday | 
__COBALT_SYSCALL_BIT
-*
-* endif
-*
-* 32bit instruction words will be laid out by the compiler as
-* the target endianness requires.
-*
-* We don't mess with CPSR here, so no need to save/restore it
-* in handle/fixup code.
-*/
-#ifdef __ARM_EABI__
-   static const struct {
-   u32 ldr_r0;
-   u32 ldr_r7;
-   u32 swi_0;
-   u32 mov_r0;
-   u32 str_r0;
-   u32 cst_r0;
-   u32 cst_r7;
-   } code = {
-   .ldr_r0 = 0xe59f000c,
-   .ldr_r7 = 0xe59f700c,
-   .swi_0 = 0xef00,
-   .mov_r0 = 0xe3a0,
-   .str_r0 = 0xe580,
-   .cst_r0 =  __xn_syscode(sc_cobalt_mayday),
-   .cst_r7 = 0x000f0042,
-   };
-#else /* OABI */
-   static const struct {
-   u32 ldr_r0;
-   u32 swi_syscall;
-   u32 mov_r0;
-   u32 str_r0;
-   u32 cst_r0;
-   } code = {
-   .ldr_r0 = 0xe59f0008,
-   .swi_syscall = 0xef9f0042,
-   .mov_r0 = 0xe3a0,
-   .str_r0 = 0xe580,
-   .cst_r0 =  __xn_syscode(sc_cobalt_mayday),
-   };
-#endif /* OABI */
-
-   memcpy(page, , sizeof(code));
-
-   flush_dcache_page(vmalloc_to_page(page));
 }
 
 int xnarch_init_mayday(void)
@@ -120,27 +54,9 @@ void *xnarch_get_mayday_page(void)
 void xnarch_handle_mayday(struct xnarchtcb *tcb, struct pt_regs *regs,
  unsigned long tramp)
 {
-   tcb->mayday.pc = regs->pc;
-   tcb->mayday.r0 = regs->regs[0];
-#ifdef __ARM_EABI__
-   tcb->mayday.r7 = regs->regs[7];
-#endif
-#ifdef CONFIG_ARM_THUMB
-   /* The code on the mayday page must be run in ARM mode */
-   tcb->mayday.psr = regs->cpsr;
-   regs->cpsr &= ~PSR_T_BIT;
-#endif
-   regs->pc = tramp;
+   xnthread_relax(0, 0);
 }
 
 void xnarch_fixup_mayday(struct xnarchtcb *tcb, struct pt_regs *regs)
 {
-   regs->pc = tcb->mayday.pc;
-   regs->regs[0] = tcb->mayday.r0;
-#ifdef __ARM_EABI__
-   regs->regs[7] = tcb->mayday.r7;
-#endif
-#ifdef CONFIG_ARM_THUMB
-   regs->cpsr = tcb->mayday.psr;
-#endif
 }


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


[Xenomai-git] Philippe Gerum : alchemy/mutex: create: detect invalid caller earlier

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: ed5025ddb8cc536be814b7851ff6d4e5aa90d398
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ed5025ddb8cc536be814b7851ff6d4e5aa90d398

Author: Philippe Gerum 
Date:   Tue Jul 25 11:39:09 2017 +0200

alchemy/mutex: create: detect invalid caller earlier

---

 lib/alchemy/mutex.c |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/alchemy/mutex.c b/lib/alchemy/mutex.c
index 3aa55dd..99ba8c6 100644
--- a/lib/alchemy/mutex.c
+++ b/lib/alchemy/mutex.c
@@ -108,7 +108,7 @@ int rt_mutex_create(RT_MUTEX *mutex, const char *name)
struct alchemy_mutex *mcb;
pthread_mutexattr_t mattr;
struct service svc;
-   int ret = 0;
+   int ret;
 
if (threadobj_irq_p())
return -EPERM;
@@ -133,7 +133,12 @@ int rt_mutex_create(RT_MUTEX *mutex, const char *name)
pthread_mutexattr_settype(, PTHREAD_MUTEX_RECURSIVE);
/* pthread_mutexattr_setrobust_np() might not be implemented. */
pthread_mutexattr_setrobust_np(, PTHREAD_MUTEX_ROBUST_NP);
-   __RT(pthread_mutex_init(>lock, ));
+   ret = __RT(pthread_mutex_init(>lock, ));
+   if (ret) {
+   xnfree(mcb);
+   goto out;
+   }
+   
pthread_mutexattr_destroy();
 
mcb->magic = mutex_magic;


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


[Xenomai-git] Philippe Gerum : alchemy: return error codes from synchronized cluster ops unmodified

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c70058681f271068cffd7334f89166b53e97565a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c70058681f271068cffd7334f89166b53e97565a

Author: Philippe Gerum 
Date:   Wed Jul 26 17:05:06 2017 +0200

alchemy: return error codes from synchronized cluster ops unmodified

Stop remapping { EPERM, ENOMEM } -> EEXIST upon syncluster_addobj()
failure, this creates confusion regarding the actual cause of the
issue. Besides, this serves no purpose since the hash table ops do
return EEXIST as expected upon any attempt to index an object with a
conflicting name.

At this chance, fix up the documentation about receiving the EPERM
status.

http://www.xenomai.org/pipermail/xenomai/2017-July/037476.html

---

 lib/alchemy/buffer.c |   11 +--
 lib/alchemy/cond.c   |   10 +-
 lib/alchemy/event.c  |   10 +-
 lib/alchemy/heap.c   |   11 +--
 lib/alchemy/mutex.c  |   10 +-
 lib/alchemy/pipe.c   |   11 +--
 lib/alchemy/queue.c  |   11 +--
 lib/alchemy/sem.c|   10 +-
 lib/alchemy/task.c   |   11 ++-
 9 files changed, 50 insertions(+), 45 deletions(-)

diff --git a/lib/alchemy/buffer.c b/lib/alchemy/buffer.c
index ac4a9ba..4e81445 100644
--- a/lib/alchemy/buffer.c
+++ b/lib/alchemy/buffer.c
@@ -202,10 +202,10 @@ fnref_register(libalchemy, buffer_finalize);
  * - -EEXIST is returned if the @a name is conflicting with an already
  * registered buffer.
  *
- * - -EPERM is returned if this service was called from an
- * asynchronous context.
+ * - -EPERM is returned if this service was called from an invalid
+ * context, e.g. interrupt or non-Xenomai thread.
  *
- * @apitags{mode-unrestricted, switch-secondary}
+ * @apitags{xthread-only, mode-unrestricted, switch-secondary}
  *
  * @note Buffers can be shared by multiple processes which belong to
  * the same Xenomai session.
@@ -263,10 +263,9 @@ int rt_buffer_create(RT_BUFFER *bf, const char *name,
warning("failed to export buffer %s to registry, %s",
bcb->name, symerror(ret));
 
-   if (syncluster_addobj(_buffer_table, bcb->name, >cobj)) {
-   ret = -EEXIST;
+   ret = syncluster_addobj(_buffer_table, bcb->name, >cobj);
+   if (ret)
goto fail_register;
-   }
 
bf->handle = mainheap_ref(bcb, uintptr_t);
 
diff --git a/lib/alchemy/cond.c b/lib/alchemy/cond.c
index 1f424b1..8c9adbb 100644
--- a/lib/alchemy/cond.c
+++ b/lib/alchemy/cond.c
@@ -95,10 +95,10 @@ static struct registry_operations registry_ops;
  * - -EEXIST is returned if the @a name is conflicting with an already
  * registered condition variable.
  *
- * - -EPERM is returned if this service was called from an
- * asynchronous context.
+ * - -EPERM is returned if this service was called from an invalid
+ * context, e.g. interrupt or non-Xenomai thread.
  *
- * @apitags{mode-unrestricted, switch-secondary}
+ * @apitags{xthread-only, mode-unrestricted, switch-secondary}
  *
  * @note Condition variables can be shared by multiple processes which
  * belong to the same Xenomai session.
@@ -156,11 +156,11 @@ int rt_cond_create(RT_COND *cond, const char *name)
ret = 0;
}
 
-   if (syncluster_addobj(_cond_table, ccb->name, >cobj)) {
+   ret = syncluster_addobj(_cond_table, ccb->name, >cobj);
+   if (ret) {
registry_destroy_file(>fsobj);
__RT(pthread_cond_destroy(>cond));
xnfree(ccb);
-   ret = -EEXIST;
} else
cond->handle = mainheap_ref(ccb, uintptr_t);
 out:
diff --git a/lib/alchemy/event.c b/lib/alchemy/event.c
index 15379fc..40bd15e 100644
--- a/lib/alchemy/event.c
+++ b/lib/alchemy/event.c
@@ -157,10 +157,10 @@ fnref_register(libalchemy, event_finalize);
  * - -EEXIST is returned if the @a name is conflicting with an already
  * registered event flag group.
  *
- * - -EPERM is returned if this service was called from an
- * asynchronous context.
+ * - -EPERM is returned if this service was called from an invalid
+ * context, e.g. interrupt or non-Xenomai thread.
  *
- * @apitags{mode-unrestricted, switch-secondary}
+ * @apitags{xthread-only, mode-unrestricted, switch-secondary}
  *
  * @note Event flag groups can be shared by multiple processes which
  * belong to the same Xenomai session.
@@ -213,11 +213,11 @@ int rt_event_create(RT_EVENT *event, const char *name,
ret = 0;
}
 
-   if (syncluster_addobj(_event_table, evcb->name, >cobj)) {
+   ret = syncluster_addobj(_event_table, evcb->name, >cobj);
+   if (ret) {
registry_destroy_file(>fsobj);
eventobj_uninit(>evobj);
xnfree(evcb);
-   ret = -EEXIST;
} else
event->handle = mainheap_ref(evcb, uintptr_t);
 out:
diff --git a/lib/alchemy/heap.c b/lib/alchemy/heap.c
index 84daed3..4715375 100644
--- 

[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: thread.h & syscall.h: fix register references for arm64

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: cde4d49ae47d1eb3d9cd6f16a7086045a0faac6f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=cde4d49ae47d1eb3d9cd6f16a7086045a0faac6f

Author: Dmitriy Cherkasov 
Date:   Thu May  7 16:41:09 2015 -0700

cobalt/arm64: thread.h & syscall.h: fix register references for arm64

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h |8 ++--
 kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h  |2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
index f0a1090..2fdd890 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
@@ -28,12 +28,16 @@
 #include 
 #include 
 
+#ifndef __NR_SYSCALL_BASE
+#define __NR_SYSCALL_BASE 0
+#endif
+
 #ifndef __ARM_NR_ipipe
 /* Legacy pipelines do not define this. */
 #define __ARM_NR_ipipe (__NR_SYSCALL_BASE + XENO_ARM_SYSCALL)
 #endif
 
-#define __xn_reg_sys(__regs)   ((__regs)->ARM_ORIG_r0)
+#define __xn_reg_sys(__regs)   ((__regs)->orig_x0)
 /* In OABI_COMPAT mode, handle both OABI and EABI userspace syscalls */
 #ifdef CONFIG_OABI_COMPAT
 #define __xn_syscall_p(__regs) (((__regs)->regs[7] == __NR_OABI_SYSCALL_BASE + 
XENO_ARM_SYSCALL) || \
@@ -49,7 +53,7 @@
 #define __xn_reg_arg3(__regs)  ((__regs)->regs[3])
 #define __xn_reg_arg4(__regs)  ((__regs)->regs[4])
 #define __xn_reg_arg5(__regs)  ((__regs)->regs[5])
-#define __xn_reg_pc(__regs)((__regs)->ip)
+#define __xn_reg_pc(__regs)((__regs)->pc)
 #define __xn_reg_sp(__regs)((__regs)->sp)
 
 static inline void __xn_error_return(struct pt_regs *regs, int v)
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
index 11439a3..958f340 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
@@ -52,7 +52,7 @@ struct xnarchtcb {
 #define xnarch_fault_regs(d)   ((d)->regs)
 #define xnarch_fault_trap(d)   ((d)->exception)
 #define xnarch_fault_code(d)   (0)
-#define xnarch_fault_pc(d) ((d)->regs->ARM_pc - (thumb_mode((d)->regs) ? 2 
: 4)) /* XXX ? */
+#define xnarch_fault_pc(d) ((d)->regs->pc - 4) /* XXX ? */
 
 #define xnarch_fault_pf_p(d)   ((d)->exception == IPIPE_TRAP_ACCESS)
 #define xnarch_fault_bp_p(d)   ((current->ptrace & PT_PTRACED) &&  \


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


[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: prepare-kernel: add arm64 arch

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 20eba7c672f66da12917967ef68509e2f105d0c9
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=20eba7c672f66da12917967ef68509e2f105d0c9

Author: Dmitriy Cherkasov 
Date:   Wed May  6 15:27:10 2015 -0700

cobalt/arm64: prepare-kernel: add arm64 arch

---

 scripts/prepare-kernel.sh |3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 89f3276..f0b0109 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -284,6 +284,9 @@ while : ; do
arm)
   linux_arch=arm
   ;;
+   arm64)
+  linux_arch=arm64
+  ;;
sh|sh4)
   linux_arch=sh
   ;;


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


[Xenomai-git] Don Mahurin : lib/cobalt/arm64: implement syscall for armv8/aarch64

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: b89e9fd312798a68cf5d54139fd4e8af81bee320
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b89e9fd312798a68cf5d54139fd4e8af81bee320

Author: Don Mahurin 
Date:   Fri May  8 10:39:32 2015 -0700

lib/cobalt/arm64: implement syscall for armv8/aarch64

---

 lib/cobalt/arch/arm64/include/asm/xenomai/syscall.h |8 
 1 file changed, 8 insertions(+)

diff --git a/lib/cobalt/arch/arm64/include/asm/xenomai/syscall.h 
b/lib/cobalt/arch/arm64/include/asm/xenomai/syscall.h
index 8f48eb1..1d5806c 100644
--- a/lib/cobalt/arch/arm64/include/asm/xenomai/syscall.h
+++ b/lib/cobalt/arch/arm64/include/asm/xenomai/syscall.h
@@ -88,6 +88,7 @@
 #define __sys2(x)  #x
 #define __sys1(x)  __sys2(x)
 
+#ifndef __aarch64__
 #ifdef __ARM_EABI__
 #define __SYS_REG , "r7"
 #define __SYS_REG_DECL register unsigned long __r7 __asm__ ("r7")
@@ -102,6 +103,13 @@
 #define __NR_OABI_SYSCALL_BASE 0x90
 #define __SYS_CALLOP "swi\t" __sys1(__NR_OABI_SYSCALL_BASE + XENO_ARM_SYSCALL) 
""
 #endif
+#else
+#define __SYS_REG , "r8"
+#define __SYS_REG_DECL register unsigned long __r8 __asm__ ("r8")
+#define __SYS_REG_SET __r8 = XENO_ARM_SYSCALL
+#define __SYS_REG_INPUT ,"r" (__r8)
+#define __SYS_CALLOP "svc\t0"
+#endif
 
 #define XENOMAI_DO_SYSCALL(nr, op, args...)\
({  \


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


[Xenomai-git] Don Mahurin : lib/cobalt/arm64: replace tsc counter

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 3d8cfb8bf349941fc8c9bf06724fd5f5ad769f3e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3d8cfb8bf349941fc8c9bf06724fd5f5ad769f3e

Author: Don Mahurin 
Date:   Wed May 13 09:36:25 2015 -0700

lib/cobalt/arm64: replace tsc counter

---

 lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h |   19 +++
 1 file changed, 19 insertions(+)

diff --git a/lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h 
b/lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h
index 594c4ad..a055427 100644
--- a/lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h
+++ b/lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h
@@ -27,6 +27,8 @@
 
 #include 
 #include 
+#include 
+#include 
 
 /*
  * Putting kuser_tsc_get and kinfo.counter in the same struct results
@@ -39,10 +41,27 @@ struct __xn_full_tscinfo {
 };
 extern struct __xn_full_tscinfo __xn_tscinfo;
 
+static inline uint64_t get_counter(void)
+{
+uint64_t cval;
+
+#ifdef __aarch64__
+   asm volatile("isb; mrs %0, cntvct_el0; isb; " : "=r" (cval) :: 
"memory");
+#else
+   asm volatile("isb; mrrc p15, 1, %Q0, %R0, c14; isb" : "=r" (cval) :: 
"memory");
+#endif
+
+   return cval;
+}
+
 static inline __attribute__((always_inline))
 unsigned long long cobalt_read_tsc(void)
 {
+#ifndef __aarch64__
return __xn_tscinfo.kuser_tsc_get(__xn_tscinfo.kinfo.counter);
+#else
+   return get_counter();
+#endif
 }
 
 #endif /* !_LIB_COBALT_ARM_TSC_H */


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


[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: update register struct usage for arm64

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: f791dcca1016c213cd1815386e156c255835fc5d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f791dcca1016c213cd1815386e156c255835fc5d

Author: Dmitriy Cherkasov 
Date:   Thu May  7 13:58:14 2015 -0700

cobalt/arm64: update register struct usage for arm64

---

 .../arch/arm64/include/asm/xenomai/syscall.h   |   22 ++--
 kernel/cobalt/arch/arm64/mayday.c  |   20 +-
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
index d80df77..f0a1090 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
@@ -36,21 +36,21 @@
 #define __xn_reg_sys(__regs)   ((__regs)->ARM_ORIG_r0)
 /* In OABI_COMPAT mode, handle both OABI and EABI userspace syscalls */
 #ifdef CONFIG_OABI_COMPAT
-#define __xn_syscall_p(__regs) (((__regs)->ARM_r7 == __NR_OABI_SYSCALL_BASE + 
XENO_ARM_SYSCALL) || \
-((__regs)->ARM_r7 == __ARM_NR_ipipe))
+#define __xn_syscall_p(__regs) (((__regs)->regs[7] == __NR_OABI_SYSCALL_BASE + 
XENO_ARM_SYSCALL) || \
+((__regs)->regs[7] == __ARM_NR_ipipe))
 #else /* !CONFIG_OABI_COMPAT */
-#define __xn_syscall_p(__regs) ((__regs)->ARM_r7 == __ARM_NR_ipipe)
+#define __xn_syscall_p(__regs) ((__regs)->regs[7] == __ARM_NR_ipipe)
 #endif /* !CONFIG_OABI_COMPAT */
 #define __xn_syscall(__regs)   (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)
 
-#define __xn_reg_rval(__regs)  ((__regs)->ARM_r0)
-#define __xn_reg_arg1(__regs)  ((__regs)->ARM_r1)
-#define __xn_reg_arg2(__regs)  ((__regs)->ARM_r2)
-#define __xn_reg_arg3(__regs)  ((__regs)->ARM_r3)
-#define __xn_reg_arg4(__regs)  ((__regs)->ARM_r4)
-#define __xn_reg_arg5(__regs)  ((__regs)->ARM_r5)
-#define __xn_reg_pc(__regs)((__regs)->ARM_ip)
-#define __xn_reg_sp(__regs)((__regs)->ARM_sp)
+#define __xn_reg_rval(__regs)  ((__regs)->regs[0])
+#define __xn_reg_arg1(__regs)  ((__regs)->regs[1])
+#define __xn_reg_arg2(__regs)  ((__regs)->regs[2])
+#define __xn_reg_arg3(__regs)  ((__regs)->regs[3])
+#define __xn_reg_arg4(__regs)  ((__regs)->regs[4])
+#define __xn_reg_arg5(__regs)  ((__regs)->regs[5])
+#define __xn_reg_pc(__regs)((__regs)->ip)
+#define __xn_reg_sp(__regs)((__regs)->sp)
 
 static inline void __xn_error_return(struct pt_regs *regs, int v)
 {
diff --git a/kernel/cobalt/arch/arm64/mayday.c 
b/kernel/cobalt/arch/arm64/mayday.c
index 20e4559..bc51ad6 100644
--- a/kernel/cobalt/arch/arm64/mayday.c
+++ b/kernel/cobalt/arch/arm64/mayday.c
@@ -120,27 +120,27 @@ void *xnarch_get_mayday_page(void)
 void xnarch_handle_mayday(struct xnarchtcb *tcb, struct pt_regs *regs,
  unsigned long tramp)
 {
-   tcb->mayday.pc = regs->ARM_pc;
-   tcb->mayday.r0 = regs->ARM_r0;
+   tcb->mayday.pc = regs->pc;
+   tcb->mayday.r0 = regs->regs[0];
 #ifdef __ARM_EABI__
-   tcb->mayday.r7 = regs->ARM_r7;
+   tcb->mayday.r7 = regs->regs[7];
 #endif
 #ifdef CONFIG_ARM_THUMB
/* The code on the mayday page must be run in ARM mode */
-   tcb->mayday.psr = regs->ARM_cpsr;
-   regs->ARM_cpsr &= ~PSR_T_BIT;
+   tcb->mayday.psr = regs->cpsr;
+   regs->cpsr &= ~PSR_T_BIT;
 #endif
-   regs->ARM_pc = tramp;
+   regs->pc = tramp;
 }
 
 void xnarch_fixup_mayday(struct xnarchtcb *tcb, struct pt_regs *regs)
 {
-   regs->ARM_pc = tcb->mayday.pc;
-   regs->ARM_r0 = tcb->mayday.r0;
+   regs->pc = tcb->mayday.pc;
+   regs->regs[0] = tcb->mayday.r0;
 #ifdef __ARM_EABI__
-   regs->ARM_r7 = tcb->mayday.r7;
+   regs->regs[7] = tcb->mayday.r7;
 #endif
 #ifdef CONFIG_ARM_THUMB
-   regs->ARM_cpsr = tcb->mayday.psr;
+   regs->cpsr = tcb->mayday.psr;
 #endif
 }


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: switch to regular system call convention

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 9fabe70c9d6942d7839dc24a2a946a52e6585598
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9fabe70c9d6942d7839dc24a2a946a52e6585598

Author: Philippe Gerum 
Date:   Mon Oct 19 15:54:55 2015 +0200

cobalt/arm64: switch to regular system call convention

---

 .../arch/arm64/include/asm/xenomai/syscall.h   |   29 +---
 .../arch/arm64/include/asm/xenomai/uapi/syscall.h  |8 +-
 lib/cobalt/arch/arm64/features.c   |8 -
 .../arch/arm64/include/asm/xenomai/syscall.h   |  180 
 lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h|   19 +--
 5 files changed, 78 insertions(+), 166 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
index 949f287..9fc6522 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
@@ -28,31 +28,16 @@
 #include 
 #include 
 
-#ifndef __NR_SYSCALL_BASE
-#define __NR_SYSCALL_BASE 0
-#endif
-
-#ifndef __ARM_NR_ipipe
-/* Legacy pipelines do not define this. */
-#define __ARM_NR_ipipe (__NR_SYSCALL_BASE + XENO_ARM_SYSCALL)
-#endif
-
-#define __xn_reg_sys(__regs)   ((__regs)->orig_x0)
-/* In OABI_COMPAT mode, handle both OABI and EABI userspace syscalls */
-#ifdef CONFIG_OABI_COMPAT
-#define __xn_syscall_p(__regs) (((__regs)->regs[8] == __NR_OABI_SYSCALL_BASE + 
XENO_ARM_SYSCALL) || \
-((__regs)->regs[8] == __ARM_NR_ipipe))
-#else /* !CONFIG_OABI_COMPAT */
-#define __xn_syscall_p(__regs) ((__regs)->regs[8] == __ARM_NR_ipipe)
-#endif /* !CONFIG_OABI_COMPAT */
+#define __xn_reg_sys(__regs)   ((unsigned long)(__regs)->syscallno)
+#define __xn_syscall_p(regs)   ((__xn_reg_sys(regs) & __COBALT_SYSCALL_BIT) != 
0)
 #define __xn_syscall(__regs)   ((unsigned long)(__xn_reg_sys(__regs) & 
~__COBALT_SYSCALL_BIT))
 
 #define __xn_reg_rval(__regs)  ((__regs)->regs[0])
-#define __xn_reg_arg1(__regs)  ((__regs)->regs[1])
-#define __xn_reg_arg2(__regs)  ((__regs)->regs[2])
-#define __xn_reg_arg3(__regs)  ((__regs)->regs[3])
-#define __xn_reg_arg4(__regs)  ((__regs)->regs[4])
-#define __xn_reg_arg5(__regs)  ((__regs)->regs[5])
+#define __xn_reg_arg1(__regs)  ((__regs)->regs[0])
+#define __xn_reg_arg2(__regs)  ((__regs)->regs[1])
+#define __xn_reg_arg3(__regs)  ((__regs)->regs[2])
+#define __xn_reg_arg4(__regs)  ((__regs)->regs[3])
+#define __xn_reg_arg5(__regs)  ((__regs)->regs[4])
 #define __xn_reg_pc(__regs)((__regs)->pc)
 #define __xn_reg_sp(__regs)((__regs)->sp)
 
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/syscall.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/syscall.h
index 60dabd5..5b319d6 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/syscall.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/syscall.h
@@ -23,12 +23,6 @@
 
 #define __xn_syscode(__nr) (__COBALT_SYSCALL_BIT | (__nr))
 
-#define XENO_ARM_SYSCALL0x000F0042 /* carefully chosen... */
-
-#define XENOMAI_SYSARCH_ATOMIC_ADD_RETURN  0
-#define XENOMAI_SYSARCH_ATOMIC_SET_MASK1
-#define XENOMAI_SYSARCH_ATOMIC_CLEAR_MASK  2
-#define XENOMAI_SYSARCH_XCHG   3
-#define XENOMAI_SYSARCH_TSCINFO 4
+#define XENOMAI_SYSARCH_TSCINFO0
 
 #endif /* !_COBALT_ARM64_ASM_UAPI_SYSCALL_H */
diff --git a/lib/cobalt/arch/arm64/features.c b/lib/cobalt/arch/arm64/features.c
index f5253a6..254c8ae 100644
--- a/lib/cobalt/arch/arm64/features.c
+++ b/lib/cobalt/arch/arm64/features.c
@@ -59,14 +59,6 @@ void cobalt_check_features(struct cobalt_featinfo *finfo)
 
page_size = sysconf(_SC_PAGESIZE);
 
-#ifndef __aarch64__
-   __xn_tscinfo.kuser_tsc_get =
-   (__xn_rdtsc_t *)(0x1004 -
-   ((*(unsigned *)(0x0ffc) + 3) << 5));
-#else
-   __xn_tscinfo.kuser_tsc_get = 0;
-#endif
-
phys_addr = (unsigned long)__xn_tscinfo.kinfo.counter;
 
addr = __STD(mmap(NULL, page_size, PROT_READ, MAP_SHARED,
diff --git a/lib/cobalt/arch/arm64/include/asm/xenomai/syscall.h 
b/lib/cobalt/arch/arm64/include/asm/xenomai/syscall.h
index 8e7ad61..d2dfda6 100644
--- a/lib/cobalt/arch/arm64/include/asm/xenomai/syscall.h
+++ b/lib/cobalt/arch/arm64/include/asm/xenomai/syscall.h
@@ -1,8 +1,5 @@
 /*
- * Copyright (C) 2001,2002,2003,2004 Philippe Gerum .
- *
- * ARM port
- *   Copyright (C) 2005 Stelian Pop
+ * Copyright (C) 2015 Philippe Gerum .
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,119 +22,76 @@
 #include 
 #include 
 
-/*
- * Some of the following macros have been adapted from Linux's
- * implementation of the syscall mechanism in :
- */
-
-#define LOADARGS_0(syscode, dummy...)  \
-   __a0 = (unsigned long) (syscode)
-#define 

[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: remove code for unrelated arm architecture

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 887219ff6ca1399d43c699de4064fb8409088161
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=887219ff6ca1399d43c699de4064fb8409088161

Author: Dmitriy Cherkasov 
Date:   Thu May  7 13:56:22 2015 -0700

cobalt/arm64: remove code for unrelated arm architecture

---

 .../arch/arm64/include/asm/xenomai/machine.h   |   33 
 .../arch/arm64/include/asm/xenomai/uapi/arith.h|4 +--
 2 files changed, 2 insertions(+), 35 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
index d6e965f..cf07a3f 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
@@ -32,53 +32,20 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #define xnarch_cache_aliasing() cache_is_vivt()
 
-#if __LINUX_ARM_ARCH__ < 5
-static inline __attribute_const__ unsigned long ffnz(unsigned long x)
-{
-   int r = 0;
-
-   if (!x)
-   return 0;
-   if (!(x & 0x)) {
-   x >>= 16;
-   r += 16;
-   }
-   if (!(x & 0xff)) {
-   x >>= 8;
-   r += 8;
-   }
-   if (!(x & 0xf)) {
-   x >>= 4;
-   r += 4;
-   }
-   if (!(x & 3)) {
-   x >>= 2;
-   r += 2;
-   }
-   if (!(x & 1)) {
-   x >>= 1;
-   r += 1;
-   }
-   return r;
-}
-#else
 static inline __attribute_const__ unsigned long ffnz(unsigned long ul)
 {
int __r;
__asm__("clz\t%0, %1" : "=r" (__r) : "r"(ul & (-ul)) : "cc");
return 31 - __r;
 }
-#endif
 
 #include 
 
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/arith.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/arith.h
index cf897b4..165cd9d 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/arith.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/arith.h
@@ -20,7 +20,7 @@
 
 #include 
 
-#if __LINUX_ARM_ARCH__ >= 4 && (!defined(CONFIG_THUMB2_KERNEL) || 
!defined(CONFIG_FTRACE))
+#if !defined(CONFIG_FTRACE)
 static inline __attribute__((__const__)) unsigned long long
 mach_arm_nodiv_ullimd(const unsigned long long op,
   const unsigned long long frac,
@@ -49,7 +49,7 @@ mach_arm_nodiv_llimd(const long long op,
 
 #include 
 
-#if __LINUX_ARM_ARCH__ >= 4 && (!defined(CONFIG_THUMB2_KERNEL) || 
!defined(CONFIG_FTRACE))
+#if !defined(CONFIG_FTRACE)
 #define mach_arm_nodiv_ullimd_str  \
"umull %[tl], %[rl], %[opl], %[fracl]\n\t"  \
"umull %[rm], %[rh], %[oph], %[frach]\n\t"  \


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


[Xenomai-git] Henning Schild : lib/alchemy: change API context tags

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 7357d8164c904338988c6db2516fe38794ad7e2c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7357d8164c904338988c6db2516fe38794ad7e2c

Author: Henning Schild 
Date:   Tue Jul 11 13:32:00 2017 +0200

lib/alchemy: change API context tags

changing the prio always changes the secondary-mode thread as well
see:
  http://xenomai.org/migrating-from-xenomai-2-x-to-3-x/#Scheduling

Signed-off-by: Henning Schild 

---

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

diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c
index d647d5c..12acafc 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -1243,7 +1243,7 @@ RT_TASK *rt_task_self(void)
  * - -EPERM is returned if @a task is NULL and this service was called
  * from an invalid context.
  *
- * @apitags{mode-unrestricted, switch-primary}
+ * @apitags{mode-unrestricted, switch-primary, switch-secondary}
  *
  * @note The caller must be an Alchemy task if @a task is NULL.
  *


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


[Xenomai-git] Don Mahurin : cobalt/arm64: fix build for mismatched printf type (%lx, u64) on arm64.

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 5df870dc30486abb40b59a494c40333ed0d4e480
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5df870dc30486abb40b59a494c40333ed0d4e480

Author: Don Mahurin 
Date:   Wed Sep  2 13:48:36 2015 -0700

cobalt/arm64: fix build for mismatched printf type (%lx,u64) on arm64.

pc and orig_r0 are u64 on arm64 and 'unsigned long' or arm and other platforms. 
printf referencing these are using %lx. On arm64, long and long long (and u64) 
are 64 bits. Rather than changing printf format, chnage arm64 macros to cast to 
unsigned long.

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h |2 +-
 kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h  |2 +-
 kernel/cobalt/posix/syscall.c  |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
index 7bf95fb..77c1716 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
@@ -45,7 +45,7 @@
 #else /* !CONFIG_OABI_COMPAT */
 #define __xn_syscall_p(__regs) ((__regs)->regs[8] == __ARM_NR_ipipe)
 #endif /* !CONFIG_OABI_COMPAT */
-#define __xn_syscall(__regs)   (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)
+#define __xn_syscall(__regs)   ((unsigned long)(__xn_reg_sys(__regs) & 
~__COBALT_SYSCALL_BIT))
 
 #define __xn_reg_rval(__regs)  ((__regs)->regs[0])
 #define __xn_reg_arg1(__regs)  ((__regs)->regs[1])
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
index 958f340..a8d7ed4 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
@@ -52,7 +52,7 @@ struct xnarchtcb {
 #define xnarch_fault_regs(d)   ((d)->regs)
 #define xnarch_fault_trap(d)   ((d)->exception)
 #define xnarch_fault_code(d)   (0)
-#define xnarch_fault_pc(d) ((d)->regs->pc - 4) /* XXX ? */
+#define xnarch_fault_pc(d) ((unsigned long)((d)->regs->pc - 4)) /* XXX ? */
 
 #define xnarch_fault_pf_p(d)   ((d)->exception == IPIPE_TRAP_ACCESS)
 #define xnarch_fault_bp_p(d)   ((current->ptrace & PT_PTRACED) &&  \
diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index 2926d7e..8186a0f 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -666,7 +666,7 @@ linux_syscall:
return KEVENT_PROPAGATE;
 
 bad_syscall:
-   printk(XENO_WARNING "bad syscall <%#llx>\n", __xn_syscall(regs));
+   printk(XENO_WARNING "bad syscall <%#lx>\n", __xn_syscall(regs));
 
__xn_error_return(regs, -ENOSYS);
 


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


[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: FPU code cleanup

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: a62c774495ac864cecd5912f80c1f37c99c85f4e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a62c774495ac864cecd5912f80c1f37c99c85f4e

Author: Dmitriy Cherkasov 
Date:   Fri Oct  2 12:54:37 2015 -0700

cobalt/arm64: FPU code cleanup

---

 kernel/cobalt/arch/arm64/thread.c |   89 -
 1 file changed, 39 insertions(+), 50 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/thread.c 
b/kernel/cobalt/arch/arm64/thread.c
index db369be..35dbd72 100644
--- a/kernel/cobalt/arch/arm64/thread.c
+++ b/kernel/cobalt/arch/arm64/thread.c
@@ -36,31 +36,44 @@
 
 #if defined(CONFIG_XENO_ARCH_FPU)
 
-static void enable_fpsimd(void) {
-   __asm__ __volatile__("mrs x1, cpacr_el1\n\
-   orr x1, x1, #(0x3 << 20)\n\
-   msr cpacr_el1, x1\n\
-   isb" : : : "x1", "memory", "cc");
+#define FPSIMD_EN (0x3 << 20)
+
+static inline unsigned long get_cpacr(void)
+{
+   unsigned long result;
+   __asm__ __volatile__("mrs %0, cpacr_el1": "=r"(result));
+   return result;
+}
+
+static inline void set_cpacr(long val)
+{
+   __asm__ __volatile__ (
+   "msr cpacr_el1, %0\n\t"
+   "isb"
+   : /* */ : "r"(val));
 }
 
-static void disable_fpsimd(void) {
-   __asm__ __volatile__("mrs x1, cpacr_el1\n\
-   and x1, x1, #~(0x3 << 20)\n\
-   msr cpacr_el1, x1\n\
-   isb" : : : "x1", "memory", "cc");
+static void enable_fpsimd(void)
+{
+   unsigned long cpacr = get_cpacr();
+   cpacr |= FPSIMD_EN;
+   set_cpacr(cpacr);
+}
+
+static void disable_fpsimd(void)
+{
+   unsigned long cpacr = get_cpacr();
+   cpacr &= ~FPSIMD_EN;
+   set_cpacr(cpacr);
 }
 
 int xnarch_fault_fpu_p(struct ipipe_trap_data *d)
 {
-   /* check if this is an FPU access trap to be handled by Xenomai */
-   if(d->exception == IPIPE_TRAP_FPU_ACC){
-   return 1;
-   }
-   /* FPU already enabled, propagate fault to kernel */
-   return 0;
+   return (d->exception == IPIPE_TRAP_FPU_ACC);
 }
 
-static inline struct fpsimd_state *get_fpu_owner(struct xnarchtcb *tcb) {
+static inline struct fpsimd_state *get_fpu_owner(struct xnarchtcb *tcb)
+{
return &(tcb->core.tsp->fpsimd_state);
 }
 
@@ -68,7 +81,6 @@ void xnarch_leave_root(struct xnthread *root)
 {
struct xnarchtcb *rootcb = xnthread_archtcb(root);
rootcb->fpup = get_fpu_owner(rootcb);
-   disable_fpsimd();
 }
 
 void xnarch_save_fpu(struct xnthread *thread)
@@ -83,29 +95,15 @@ void xnarch_switch_fpu(struct xnthread *from, struct 
xnthread *to)
struct fpsimd_state *const from_fpup = from ? from->tcb.fpup : NULL;
struct fpsimd_state *const to_fpup = to->tcb.fpup;
 
-   /*
-* This only gets called if XNFPU flag is set, or if migrating to Linux.
-* In both cases, this means turn on FPU and switch.
-*/
enable_fpsimd();
 
-   if (xnthread_test_state(to, XNROOT) == 0) {
-   if (from_fpup == to_fpup)
-   return;
-
-   if (from_fpup)
-   fpsimd_save_state(from_fpup);
-
-   fpsimd_load_state(to_fpup);
-   }
-   else {
-   /* Going to Linux. */
-   if (from_fpup)
-   fpsimd_save_state(from_fpup);
+   if (from_fpup == to_fpup)
+   return;
 
-   fpsimd_load_state(to_fpup);
-   }
+   if (from_fpup)
+   fpsimd_save_state(from_fpup);
 
+   fpsimd_load_state(to_fpup);
 }
 
 int xnarch_handle_fpu_fault(struct xnthread *from, 
@@ -113,9 +111,9 @@ int xnarch_handle_fpu_fault(struct xnthread *from,
 {
spl_t s;
 
+   /* FPU should already be enabled for XNFPU tasks. */
if (xnthread_test_state(to, XNFPU))
-   /* FPU is already enabled, probably an exception */
-  return 0;
+   BUG();
 
xnlock_get_irqsave(, s);
xnthread_set_state(to, XNFPU);
@@ -124,20 +122,13 @@ int xnarch_handle_fpu_fault(struct xnthread *from,
xnarch_switch_fpu(from, to);
 
return 1;
-
 }
 
 void xnarch_init_shadow_tcb(struct xnthread *thread)
 {
-   spl_t s;
struct xnarchtcb *tcb = xnthread_archtcb(thread);
-
tcb->fpup = &(tcb->core.host_task->thread.fpsimd_state);
-
-   xnlock_get_irqsave(, s);
xnthread_clear_state(thread, XNFPU);
-   xnlock_put_irqrestore(, s);
-
 }
 #endif /* CONFIG_XENO_ARCH_FPU */
 
@@ -210,16 +201,14 @@ void xnarch_switch_to(struct xnthread *out, struct 
xnthread *in)
xnarch_tls_thread_switch(in_tcb->core.tip->task);
xnarch_contextidr_thread_switch(in_tcb->core.tip->task);
 
-   /* check if we need to switch FPU on return to Linux */
-   if (xnthread_test_state(in, XNROOT) == 1)
-   

[Xenomai-git] Jan Kiszka : cobalt: Fix conditional build by avoiding #if XENO_DEBUG()

2017-07-27 Thread git repository hosting
Module: xenomai-jki
Branch: for-forge
Commit: dfb1d31ee3346f415b2ece4301d8a5f9d7dec4c1
URL:
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=dfb1d31ee3346f415b2ece4301d8a5f9d7dec4c1

Author: Jan Kiszka 
Date:   Wed Jul 26 18:50:43 2017 +0200

cobalt: Fix conditional build by avoiding #if XENO_DEBUG()

In contrast to #ifdef CONFIG_x, #if IS_ENABLED(x) (or our wrapper of
the latter) does not update the dependency information for kbuild. So,
switching any config easily left inconsistent build artifacts behind.

This conversion also fixes de66d324a93d: there is and there was never a
CONFIG_XENO_DEBUG_LOCKING.

Signed-off-by: Jan Kiszka 

---

 include/cobalt/kernel/assert.h |2 +-
 include/cobalt/kernel/lock.h   |   14 +++---
 include/cobalt/kernel/sched-sporadic.h |2 +-
 include/cobalt/kernel/synch.h  |6 +++---
 include/cobalt/kernel/tree.h   |2 +-
 kernel/cobalt/bufd.c   |   10 +-
 kernel/cobalt/debug.c  |4 ++--
 kernel/cobalt/posix/process.c  |2 +-
 kernel/cobalt/procfs.c |   10 +-
 kernel/cobalt/sched-sporadic.c |8 
 kernel/cobalt/synch.c  |4 ++--
 11 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/include/cobalt/kernel/assert.h b/include/cobalt/kernel/assert.h
index 2d2d653..86d0a48 100644
--- a/include/cobalt/kernel/assert.h
+++ b/include/cobalt/kernel/assert.h
@@ -63,7 +63,7 @@
 #define realtime_cpu_only()XENO_BUG_ON(CONTEXT, 
!xnsched_supported_cpu(ipipe_processor_id()))
 #define thread_only()  XENO_BUG_ON(CONTEXT, xnsched_interrupt_p())
 #define irqoff_only()  XENO_BUG_ON(CONTEXT, hard_irqs_disabled() == 0)
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 #define atomic_only()  XENO_BUG_ON(CONTEXT, (xnlock_is_owner() 
&& hard_irqs_disabled()) == 0)
 #define preemptible_only() XENO_BUG_ON(CONTEXT, xnlock_is_owner() 
|| hard_irqs_disabled())
 #else
diff --git a/include/cobalt/kernel/lock.h b/include/cobalt/kernel/lock.h
index 36f8168..4b1909f 100644
--- a/include/cobalt/kernel/lock.h
+++ b/include/cobalt/kernel/lock.h
@@ -63,7 +63,7 @@ typedef unsigned long spl_t;
  */
 #define spltest()   ipipe_test_head()
 
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 
 struct xnlock {
unsigned owner;
@@ -112,7 +112,7 @@ int xnlock_dbg_release(struct xnlock *lock,
 
 DECLARE_PER_CPU(struct xnlockinfo, xnlock_stats);
 
-#else /* !XENO_DEBUG(LOCKING) */
+#else /* !CONFIG_XENO_OPT_DEBUG_LOCKING */
 
 struct xnlock {
unsigned owner;
@@ -150,9 +150,9 @@ static inline int xnlock_dbg_release(struct xnlock *lock)
return 0;
 }
 
-#endif /* !XENO_DEBUG(LOCKING) */
+#endif /* !CONFIG_XENO_OPT_DEBUG_LOCKING */
 
-#if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
+#if defined(CONFIG_SMP) || defined(CONFIG_XENO_OPT_DEBUG_LOCKING)
 
 #define xnlock_get(lock)   __xnlock_get(lock  XNLOCK_DBG_CONTEXT)
 #define xnlock_put(lock)   __xnlock_put(lock  XNLOCK_DBG_CONTEXT)
@@ -209,7 +209,7 @@ int ___xnlock_get(struct xnlock *lock /*, */ 
XNLOCK_DBG_CONTEXT_ARGS);
 void ___xnlock_put(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS);
 #endif /* out of line xnlock */
 
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 /* Disable UP-over-SMP kernel optimization in debug mode. */
 #define __locking_active__  1
 #else
@@ -263,7 +263,7 @@ static inline void __xnlock_put(struct xnlock *lock /*, */ 
XNLOCK_DBG_CONTEXT_AR
 
 #undef __locking_active__
 
-#else /* !(CONFIG_SMP || XENO_DEBUG(LOCKING) */
+#else /* !(CONFIG_SMP || CONFIG_XENO_OPT_DEBUG_LOCKING) */
 
 #define xnlock_init(lock)  do { } while(0)
 #define xnlock_get(lock)   do { } while(0)
@@ -279,7 +279,7 @@ static inline void __xnlock_put(struct xnlock *lock /*, */ 
XNLOCK_DBG_CONTEXT_AR
 #define DEFINE_XNLOCK(lock)
 #define DEFINE_PRIVATE_XNLOCK(lock)
 
-#endif /* !(CONFIG_SMP || XENO_DEBUG(LOCKING)) */
+#endif /* !(CONFIG_SMP || CONFIG_XENO_OPT_DEBUG_LOCKING) */
 
 DECLARE_EXTERN_XNLOCK(nklock);
 
diff --git a/include/cobalt/kernel/sched-sporadic.h 
b/include/cobalt/kernel/sched-sporadic.h
index 0eade47..50ca406 100644
--- a/include/cobalt/kernel/sched-sporadic.h
+++ b/include/cobalt/kernel/sched-sporadic.h
@@ -56,7 +56,7 @@ struct xnsched_sporadic_data {
 };
 
 struct xnsched_sporadic {
-#if XENO_DEBUG(COBALT)
+#ifdef CONFIG_XENO_OPT_DEBUG_COBALT
unsigned long drop_retries;
 #endif
 };
diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h
index b3a8004..a2bf80d 100644
--- a/include/cobalt/kernel/synch.h
+++ b/include/cobalt/kernel/synch.h
@@ -115,21 +115,21 @@ static inline struct xnthread *xnsynch_owner(struct 
xnsynch *synch)
 #define xnsynch_owner_check(synch, thread) \
xnsynch_fast_owner_check((synch)->fastlock, thread->handle)
 
-#if 

[Xenomai-git] Jan Kiszka : cobalt: Do not destroy info flags on remote thread suspension

2017-07-27 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 368f1ef5d1bb67d90159ea912e58d6a3dacc89a8
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=368f1ef5d1bb67d90159ea912e58d6a3dacc89a8

Author: Jan Kiszka 
Date:   Wed Jul 26 17:59:27 2017 +0200

cobalt: Do not destroy info flags on remote thread suspension

Scenario: A high prio thread is running and a low-prio is waiting for a
timeout. Now the timeout occurs, and the low-prio thread is woken up but
can't run yet. If the high-prio thread suspends the low-prio one,
XNTIMEO will be lost due to that. Similar scenarios a possible with
other info flags and remote suspension reasons.

Address them by clearing info flags only if the current thread is
suspending itself.

Signed-off-by: Jan Kiszka 

---

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

diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 1fdea99..067026e 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -900,8 +900,13 @@ void xnthread_suspend(struct xnthread *thread, int mask,
(oldstate & XNTRAPLB) != 0)
goto lock_break;
}
-   xnthread_clear_info(thread,
-   
XNRMID|XNTIMEO|XNBREAK|XNWAKEN|XNROBBED|XNKICKED);
+   /*
+* Do not destroy the info left behind by yet unprocessed
+* wakeups when suspending a remote thread.
+*/
+   if (thread == sched->curr)
+   xnthread_clear_info(thread, XNRMID|XNTIMEO|XNBREAK|
+   XNWAKEN|XNROBBED|XNKICKED);
}
 
/*


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


[Xenomai-git] Jan Kiszka : cobalt: Fix conditional build of lock_vfile registration

2017-07-26 Thread git repository hosting
Module: xenomai-jki
Branch: for-forge
Commit: 634a95c9c023dda40607e5e5c1dd43761f59e541
URL:
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=634a95c9c023dda40607e5e5c1dd43761f59e541

Author: Jan Kiszka 
Date:   Wed Jul 26 18:50:43 2017 +0200

cobalt: Fix conditional build of lock_vfile registration

There is and there was never a CONFIG_XENO_DEBUG_LOCKING.
Fixes de66d324a93d.

Signed-off-by: Jan Kiszka 

---

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

diff --git a/kernel/cobalt/procfs.c b/kernel/cobalt/procfs.c
index 9d193af..85aea0c 100644
--- a/kernel/cobalt/procfs.c
+++ b/kernel/cobalt/procfs.c
@@ -216,7 +216,7 @@ static struct xnvfile_regular apc_vfile = {
 void xnprocfs_cleanup_tree(void)
 {
 #ifdef CONFIG_XENO_OPT_DEBUG
-#ifdef CONFIG_XENO_DEBUG_LOCKING
+#if XENO_DEBUG(LOCKING)
xnvfile_destroy_regular(_vfile);
 #endif
xnvfile_destroy_dir(_debug_vfroot);
@@ -253,7 +253,7 @@ int __init xnprocfs_init_tree(void)
xnvfile_init_regular("apc", _vfile, _vfroot);
 #ifdef CONFIG_XENO_OPT_DEBUG
xnvfile_init_dir("debug", _debug_vfroot, _vfroot);
-#ifdef CONFIG_XENO_DEBUG_LOCKING
+#if XENO_DEBUG(LOCKING)
xnvfile_init_regular("lock", _vfile, _debug_vfroot);
 #endif
 #endif


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


[Xenomai-git] Jan Kiszka : cobalt/syscall: Filter out invalid Linux syscalls

2017-07-26 Thread git repository hosting
Module: xenomai-jki
Branch: for-forge
Commit: 92fadda472ad755db2d7b9443d3b2108a35e5d14
URL:
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=92fadda472ad755db2d7b9443d3b2108a35e5d14

Author: Jan Kiszka 
Date:   Mon Jul 24 14:22:29 2017 +0200

cobalt/syscall: Filter out invalid Linux syscalls

Suggested by Philippe Gerum: Instead of propagating them down the
pipeline, triggering a XENO_BUG_ON in ipipe_fastcall_hook, catch invalid
Linux syscalls early and terminate them immediately.

Signed-off-by: Jan Kiszka 

---

 kernel/cobalt/posix/syscall.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index 0f905bf..8edba1f 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "internal.h"
 #include "thread.h"
 #include "sched.h"
@@ -656,6 +657,8 @@ linux_syscall:
 */
return KEVENT_PROPAGATE;
 
+   if (__xn_reg_sys(regs) >= NR_syscalls)
+   goto bad_syscall;
/*
 * From now on, we know that we have a valid shadow thread
 * pointer.


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


[Xenomai-git] Jan Kiszka : cobalt: Do not destroy info flags on remote thread suspension

2017-07-26 Thread git repository hosting
Module: xenomai-jki
Branch: for-forge
Commit: db4297c074d3f8c9bbd90130a725f84b7dfc0f12
URL:
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=db4297c074d3f8c9bbd90130a725f84b7dfc0f12

Author: Jan Kiszka 
Date:   Wed Jul 26 17:59:27 2017 +0200

cobalt: Do not destroy info flags on remote thread suspension

Scenario: A high prio thread is running and a low-prio is waiting for a
timeout. Now the timeout occurs, and the low-prio thread is woken up but
can't run yet. If the high-prio thread suspends the low-prio one,
XNTIMEO will be lost due to that. Similar scenarios a possible with
other info flags and remote suspension reasons.

Address them by clearing info flags only if the current thread is
suspending itself.

Signed-off-by: Jan Kiszka 

---

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

diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 81ef81f..b8304e2 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -916,8 +916,13 @@ void xnthread_suspend(struct xnthread *thread, int mask,
(oldstate & XNTRAPLB) != 0)
goto lock_break;
}
-   xnthread_clear_info(thread,
-   
XNRMID|XNTIMEO|XNBREAK|XNWAKEN|XNROBBED|XNKICKED);
+   /*
+* Do not destroy the info left behind by yet unprocessed
+* wakeups when suspending a remote thread.
+*/
+   if (thread == sched->curr)
+   xnthread_clear_info(thread, XNRMID|XNTIMEO|XNBREAK|
+   XNWAKEN|XNROBBED|XNKICKED);
}
 
/*


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


[Xenomai-git] Philippe Gerum : alchemy: return error codes from synchronized cluster ops unmodified

2017-07-26 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: c70058681f271068cffd7334f89166b53e97565a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c70058681f271068cffd7334f89166b53e97565a

Author: Philippe Gerum 
Date:   Wed Jul 26 17:05:06 2017 +0200

alchemy: return error codes from synchronized cluster ops unmodified

Stop remapping { EPERM, ENOMEM } -> EEXIST upon syncluster_addobj()
failure, this creates confusion regarding the actual cause of the
issue. Besides, this serves no purpose since the hash table ops do
return EEXIST as expected upon any attempt to index an object with a
conflicting name.

At this chance, fix up the documentation about receiving the EPERM
status.

http://www.xenomai.org/pipermail/xenomai/2017-July/037476.html

---

 lib/alchemy/buffer.c |   11 +--
 lib/alchemy/cond.c   |   10 +-
 lib/alchemy/event.c  |   10 +-
 lib/alchemy/heap.c   |   11 +--
 lib/alchemy/mutex.c  |   10 +-
 lib/alchemy/pipe.c   |   11 +--
 lib/alchemy/queue.c  |   11 +--
 lib/alchemy/sem.c|   10 +-
 lib/alchemy/task.c   |   11 ++-
 9 files changed, 50 insertions(+), 45 deletions(-)

diff --git a/lib/alchemy/buffer.c b/lib/alchemy/buffer.c
index ac4a9ba..4e81445 100644
--- a/lib/alchemy/buffer.c
+++ b/lib/alchemy/buffer.c
@@ -202,10 +202,10 @@ fnref_register(libalchemy, buffer_finalize);
  * - -EEXIST is returned if the @a name is conflicting with an already
  * registered buffer.
  *
- * - -EPERM is returned if this service was called from an
- * asynchronous context.
+ * - -EPERM is returned if this service was called from an invalid
+ * context, e.g. interrupt or non-Xenomai thread.
  *
- * @apitags{mode-unrestricted, switch-secondary}
+ * @apitags{xthread-only, mode-unrestricted, switch-secondary}
  *
  * @note Buffers can be shared by multiple processes which belong to
  * the same Xenomai session.
@@ -263,10 +263,9 @@ int rt_buffer_create(RT_BUFFER *bf, const char *name,
warning("failed to export buffer %s to registry, %s",
bcb->name, symerror(ret));
 
-   if (syncluster_addobj(_buffer_table, bcb->name, >cobj)) {
-   ret = -EEXIST;
+   ret = syncluster_addobj(_buffer_table, bcb->name, >cobj);
+   if (ret)
goto fail_register;
-   }
 
bf->handle = mainheap_ref(bcb, uintptr_t);
 
diff --git a/lib/alchemy/cond.c b/lib/alchemy/cond.c
index 1f424b1..8c9adbb 100644
--- a/lib/alchemy/cond.c
+++ b/lib/alchemy/cond.c
@@ -95,10 +95,10 @@ static struct registry_operations registry_ops;
  * - -EEXIST is returned if the @a name is conflicting with an already
  * registered condition variable.
  *
- * - -EPERM is returned if this service was called from an
- * asynchronous context.
+ * - -EPERM is returned if this service was called from an invalid
+ * context, e.g. interrupt or non-Xenomai thread.
  *
- * @apitags{mode-unrestricted, switch-secondary}
+ * @apitags{xthread-only, mode-unrestricted, switch-secondary}
  *
  * @note Condition variables can be shared by multiple processes which
  * belong to the same Xenomai session.
@@ -156,11 +156,11 @@ int rt_cond_create(RT_COND *cond, const char *name)
ret = 0;
}
 
-   if (syncluster_addobj(_cond_table, ccb->name, >cobj)) {
+   ret = syncluster_addobj(_cond_table, ccb->name, >cobj);
+   if (ret) {
registry_destroy_file(>fsobj);
__RT(pthread_cond_destroy(>cond));
xnfree(ccb);
-   ret = -EEXIST;
} else
cond->handle = mainheap_ref(ccb, uintptr_t);
 out:
diff --git a/lib/alchemy/event.c b/lib/alchemy/event.c
index 15379fc..40bd15e 100644
--- a/lib/alchemy/event.c
+++ b/lib/alchemy/event.c
@@ -157,10 +157,10 @@ fnref_register(libalchemy, event_finalize);
  * - -EEXIST is returned if the @a name is conflicting with an already
  * registered event flag group.
  *
- * - -EPERM is returned if this service was called from an
- * asynchronous context.
+ * - -EPERM is returned if this service was called from an invalid
+ * context, e.g. interrupt or non-Xenomai thread.
  *
- * @apitags{mode-unrestricted, switch-secondary}
+ * @apitags{xthread-only, mode-unrestricted, switch-secondary}
  *
  * @note Event flag groups can be shared by multiple processes which
  * belong to the same Xenomai session.
@@ -213,11 +213,11 @@ int rt_event_create(RT_EVENT *event, const char *name,
ret = 0;
}
 
-   if (syncluster_addobj(_event_table, evcb->name, >cobj)) {
+   ret = syncluster_addobj(_event_table, evcb->name, >cobj);
+   if (ret) {
registry_destroy_file(>fsobj);
eventobj_uninit(>evobj);
xnfree(evcb);
-   ret = -EEXIST;
} else
event->handle = mainheap_ref(evcb, uintptr_t);
 out:
diff --git a/lib/alchemy/heap.c b/lib/alchemy/heap.c
index 84daed3..4715375 100644
--- 

[Xenomai-git] Philippe Gerum : drivers/spi: enable backend driver for all BCM2835-based SoCs

2017-07-26 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 88709db3ed52856ab8a228fd7cb23ef372ef0c7a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=88709db3ed52856ab8a228fd7cb23ef372ef0c7a

Author: Philippe Gerum 
Date:   Tue Jul 25 18:32:46 2017 +0200

drivers/spi: enable backend driver for all BCM2835-based SoCs

---

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

diff --git a/kernel/drivers/spi/Kconfig b/kernel/drivers/spi/Kconfig
index 817e9b9..9f14985 100644
--- a/kernel/drivers/spi/Kconfig
+++ b/kernel/drivers/spi/Kconfig
@@ -5,7 +5,7 @@ config XENO_DRIVERS_SPI
tristate
 
 config XENO_DRIVERS_SPI_BCM2835
-   depends on ARCH_BCM2708
+   depends on ARCH_BCM2708 || ARCH_BCM2835
select XENO_DRIVERS_SPI
tristate "Support for BCM2835 SPI"
help


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


[Xenomai-git] Philippe Gerum : drivers/gpio: enable backend driver for all BCM2835-based SoCs

2017-07-26 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 8492040ec950888cffc8f425e9a9d90c0c82f8aa
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8492040ec950888cffc8f425e9a9d90c0c82f8aa

Author: Philippe Gerum 
Date:   Tue Jul 25 18:37:06 2017 +0200

drivers/gpio: enable backend driver for all BCM2835-based SoCs

---

 kernel/drivers/gpio/Kconfig|2 +-
 kernel/drivers/gpio/gpio-bcm2835.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/drivers/gpio/Kconfig b/kernel/drivers/gpio/Kconfig
index 74c56d4..058dc5f 100644
--- a/kernel/drivers/gpio/Kconfig
+++ b/kernel/drivers/gpio/Kconfig
@@ -10,7 +10,7 @@ config XENO_DRIVERS_GPIO
 if XENO_DRIVERS_GPIO
 
 config XENO_DRIVERS_GPIO_BCM2835
-   depends on MACH_BCM2708
+   depends on MACH_BCM2708 || ARCH_BCM2835
bool "Support for BCM2835 GPIOs"
help
 
diff --git a/kernel/drivers/gpio/gpio-bcm2835.c 
b/kernel/drivers/gpio/gpio-bcm2835.c
index 6328955..186df66 100644
--- a/kernel/drivers/gpio/gpio-bcm2835.c
+++ b/kernel/drivers/gpio/gpio-bcm2835.c
@@ -22,7 +22,7 @@
 
 static int __init bcm2835_gpio_init(void)
 {
-   return rtdm_gpiochip_scan_of(NULL, "brcm,bcm2835-gpio",
+   return rtdm_gpiochip_scan_of(NULL, "brcm,bcm2835-gpio",
 RTDM_SUBCLASS_BCM2835);
 }
 module_init(bcm2835_gpio_init);


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


[Xenomai-git] Henning Schild : lib/alchemy: change API context tags

2017-07-26 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 7357d8164c904338988c6db2516fe38794ad7e2c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7357d8164c904338988c6db2516fe38794ad7e2c

Author: Henning Schild 
Date:   Tue Jul 11 13:32:00 2017 +0200

lib/alchemy: change API context tags

changing the prio always changes the secondary-mode thread as well
see:
  http://xenomai.org/migrating-from-xenomai-2-x-to-3-x/#Scheduling

Signed-off-by: Henning Schild 

---

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

diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c
index d647d5c..12acafc 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -1243,7 +1243,7 @@ RT_TASK *rt_task_self(void)
  * - -EPERM is returned if @a task is NULL and this service was called
  * from an invalid context.
  *
- * @apitags{mode-unrestricted, switch-primary}
+ * @apitags{mode-unrestricted, switch-primary, switch-secondary}
  *
  * @note The caller must be an Alchemy task if @a task is NULL.
  *


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


[Xenomai-git] Philippe Gerum : alchemy/mutex: create: detect invalid caller earlier

2017-07-26 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: ed5025ddb8cc536be814b7851ff6d4e5aa90d398
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ed5025ddb8cc536be814b7851ff6d4e5aa90d398

Author: Philippe Gerum 
Date:   Tue Jul 25 11:39:09 2017 +0200

alchemy/mutex: create: detect invalid caller earlier

---

 lib/alchemy/mutex.c |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/alchemy/mutex.c b/lib/alchemy/mutex.c
index 3aa55dd..99ba8c6 100644
--- a/lib/alchemy/mutex.c
+++ b/lib/alchemy/mutex.c
@@ -108,7 +108,7 @@ int rt_mutex_create(RT_MUTEX *mutex, const char *name)
struct alchemy_mutex *mcb;
pthread_mutexattr_t mattr;
struct service svc;
-   int ret = 0;
+   int ret;
 
if (threadobj_irq_p())
return -EPERM;
@@ -133,7 +133,12 @@ int rt_mutex_create(RT_MUTEX *mutex, const char *name)
pthread_mutexattr_settype(, PTHREAD_MUTEX_RECURSIVE);
/* pthread_mutexattr_setrobust_np() might not be implemented. */
pthread_mutexattr_setrobust_np(, PTHREAD_MUTEX_ROBUST_NP);
-   __RT(pthread_mutex_init(>lock, ));
+   ret = __RT(pthread_mutex_init(>lock, ));
+   if (ret) {
+   xnfree(mcb);
+   goto out;
+   }
+   
pthread_mutexattr_destroy();
 
mcb->magic = mutex_magic;


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


[Xenomai-git] Philippe Gerum : testsuite: fix error code wreckage in failure reports

2017-07-26 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 6dd1d22d54e1d0862a737955aa5a2fa7a72809d9
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6dd1d22d54e1d0862a737955aa5a2fa7a72809d9

Author: Philippe Gerum 
Date:   Wed Jul 26 13:09:45 2017 +0200

testsuite: fix error code wreckage in failure reports

---

 testsuite/gpiotest/gpiotest.c |4 ++--
 testsuite/smokey/rtdm/rtdm.c  |   10 +-
 testsuite/spitest/spitest.c   |8 
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c
index a845ef5..3c8c6c3 100644
--- a/testsuite/gpiotest/gpiotest.c
+++ b/testsuite/gpiotest/gpiotest.c
@@ -167,7 +167,7 @@ static int run_read_value(struct smokey_test *t, int argc, 
char *const argv[])
return ret;
}
 
-   if (!__T(ret, ioctl(fd, GPIO_RTIOC_DIR_IN)))
+   if (!__Terrno(ret, ioctl(fd, GPIO_RTIOC_DIR_IN)))
return ret;
 
ret = read(fd, , sizeof(value));
@@ -203,7 +203,7 @@ static int run_write_value(struct smokey_test *t, int argc, 
char *const argv[])
}
 
value = 1;
-   if (!__T(ret, ioctl(fd, GPIO_RTIOC_DIR_OUT, )))
+   if (!__Terrno(ret, ioctl(fd, GPIO_RTIOC_DIR_OUT, )))
return ret;

ret = write(fd, , sizeof(value));
diff --git a/testsuite/smokey/rtdm/rtdm.c b/testsuite/smokey/rtdm/rtdm.c
index c41daa7..e8056be 100644
--- a/testsuite/smokey/rtdm/rtdm.c
+++ b/testsuite/smokey/rtdm/rtdm.c
@@ -85,7 +85,7 @@ static int do_handover(int fd)
if (!__Tassert(magic == 0))
return -EINVAL;
 
-   if (!__T(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_SECONDARY, )))
+   if (!__Terrno(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_SECONDARY, )))
return ret;
 
if (!__Tassert(magic == RTTST_RTDM_MAGIC_SECONDARY))
@@ -98,13 +98,13 @@ static int do_handover(int fd)
SCHED_FIFO, )))
return ret;

-   if (!__T(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_PRIMARY, )))
+   if (!__Terrno(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_PRIMARY, )))
return ret;
 
if (!__Tassert(magic == RTTST_RTDM_MAGIC_PRIMARY))
return -EINVAL;
 
-   if (!__T(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_SECONDARY, )))
+   if (!__Terrno(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_SECONDARY, )))
return ret;
 
if (!__Tassert(magic == RTTST_RTDM_MAGIC_SECONDARY))
@@ -117,13 +117,13 @@ static int do_handover(int fd)
SCHED_WEAK, )))
return ret;

-   if (!__T(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_PRIMARY, )))
+   if (!__Terrno(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_PRIMARY, )))
return ret;
 
if (!__Tassert(magic == RTTST_RTDM_MAGIC_PRIMARY))
return -EINVAL;
 
-   if (!__T(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_SECONDARY, )))
+   if (!__Terrno(ret, ioctl(fd, RTTST_RTIOC_RTDM_PING_SECONDARY, )))
return ret;
 
if (!__Tassert(magic == RTTST_RTDM_MAGIC_SECONDARY))
diff --git a/testsuite/spitest/spitest.c b/testsuite/spitest/spitest.c
index b25dc70..debf1b6 100644
--- a/testsuite/spitest/spitest.c
+++ b/testsuite/spitest/spitest.c
@@ -311,7 +311,7 @@ static int do_spi_loop(int fd)
if (ret < 0)
break;
clock_gettime(CLOCK_MONOTONIC, );
-   if (!__T(ret, ioctl(fd, SPI_RTIOC_TRANSFER)))
+   if (!__Terrno(ret, ioctl(fd, SPI_RTIOC_TRANSFER)))
return ret;
if (with_latency) {
clock_gettime(CLOCK_MONOTONIC, );
@@ -382,7 +382,7 @@ static int run_spi_transfer(struct smokey_test *t, int 
argc, char *const argv[])
}
 
iobufs.io_len = TRANSFER_SIZE;
-   if (!__T(ret, ioctl(fd, SPI_RTIOC_SET_IOBUFS, )))
+   if (!__Terrno(ret, ioctl(fd, SPI_RTIOC_SET_IOBUFS, )))
return ret;
 
p = mmap(NULL, iobufs.map_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
@@ -400,10 +400,10 @@ static int run_spi_transfer(struct smokey_test *t, int 
argc, char *const argv[])
config.mode = SPI_MODE_0;
config.bits_per_word = 8;
config.speed_hz = speed_hz;
-   if (!__T(ret, ioctl(fd, SPI_RTIOC_SET_CONFIG, )))
+   if (!__Terrno(ret, ioctl(fd, SPI_RTIOC_SET_CONFIG, )))
return ret;
 
-   if (!__T(ret, ioctl(fd, SPI_RTIOC_GET_CONFIG, )))
+   if (!__Terrno(ret, ioctl(fd, SPI_RTIOC_GET_CONFIG, )))
return ret;
 
smokey_trace("speed=%u hz, mode=%#x, bits=%u",


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


[Xenomai-git] New commits on branch next

2017-07-17 Thread git repository hosting
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=52a86bf0909a8e50547474208d1c5e9c16275d00
Author: Jan Kiszka 
Date:   Fri Jul 14 17:19:39 2017 +0200

smokey: Add test cases for trylock on ceiling mutexes

This reveals a bug in the trylock kernel slow-path when
CONFIG_XENO_OPT_DEBUG_MUTEX_SLEEP is set.

Signed-off-by: Jan Kiszka 

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2a0fb0ed680294d3b53541aea8ca01ccab054bae
Author: Jan Kiszka 
Date:   Fri Jul 14 20:32:40 2017 +0200

cobalt: Align structure of mutex_trylock with mutex_timedlock

No need to have different patterns, and the one of mutex_timedlock is
more compact.

Signed-off-by: Jan Kiszka 

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d98c1314cad64671399613fb3a319c3e541655e9
Author: Jan Kiszka 
Date:   Fri Jul 14 20:34:25 2017 +0200

cobalt: Fix slow-path of mutex_trylock in kernel

We missed to call set_current_owner on successful acquisition. That
destroyed prio ceiling and could even cause a crash when lock debugging
was enabled.

This can easily be addressed by switching the open-coded trylock to
xnsynch_try_acquire. Nice side effect: less code.

Signed-off-by: Jan Kiszka 

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c2678d423e3e7f4087ea15d1a99043937b899161
Author: Philippe Gerum 
Date:   Thu Jun 1 09:46:29 2017 +0200

lib/cobalt: init: hint about failure due to disabled core

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1d96b27ef5790dd73b9033a0265d24fea6cd89ed
Author: Philippe Gerum 
Date:   Thu Jun 1 09:43:53 2017 +0200

cobalt/syscalls: reject binding attempt to disabled core with EAGAIN

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a939bf5cb1f8be9a976b7c1cde1f9876db47a609
Author: Philippe Gerum 
Date:   Wed May 24 17:41:41 2017 +0200

cobalt/arm64: no fpsimd support in real-time kthread context

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2ef1f0401704f9ae681fc863b4ca1f564fe7068e
Author: Philippe Gerum 
Date:   Mon May 22 12:06:46 2017 +0200

cobalt/arm64: use regular context switching code

Since 4.9.x, the interrupt pipeline implementation guarantees that the
regular context switching code may be used over the head stage,
including the fpu management bits.

Drop the open coded support and use mainline's implementation instead.

At this chance, drop the useless conditionals for handling the non-FPU
case: this one does not apply to arm64.

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c41fdb85ec04625df3bd6f2440af7256e608106e
Author: Philippe Gerum 
Date:   Mon May 15 17:03:02 2017 +0200

cobalt/arm64: fix build w/ pre-4.8 kernels

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=38087ea9b33fc3387ab7c9c33631cf632f633382
Author: Philippe Gerum 
Date:   Sun May 14 19:41:55 2017 +0200

cobalt/arm: fixups for kernel 4.8+

At this chance, stop using the obsolete flush_cache_all() routine
which cannot honor the documented semantics for arm64.

Besides, calibrating the access times to the timer registers in
no-cache conditions does not make sense.

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bd9cd6ecf171956706f436db43cb846bb84850b4
Author: Philippe Gerum 
Date:   Sat Feb 15 16:42:09 2014 +0100

config: bump UAPI level

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6b149bc5df0b1d8c88960d44d0bffe3f3ae72e26
Author: Philippe Gerum 
Date:   Wed Feb 15 16:17:54 2017 +0100

cobalt/arm64: add README

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=16454372ded2f6c2c01fb2e916402d9cfa1fbee7
Author: Jan Kiszka 
Date:   Tue Dec 6 16:34:48 2016 +0100

smokey/posix-mutex: Fix test case by destroying barriers correctly

At least on x86-64-compat, the missing destruction of the smokey
barriers, specifically their embedded mutexes, cause crashes of the
test. The reason is likely a mismatch between the kernel's and
userland's view on which object is still active, combined with the fact
that userland kept them on the volatile stack.

Signed-off-by: Jan Kiszka 

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=07ffc470bc8463822b0047402affc525564c4bde
Author: Jorge Ramirez-Ortiz 
Date:   Wed Mar 30 13:30:11 2016 -0400

gpiopwm: display udp server information

URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4da78d88bcd49846e4945c124b1b3f29e889b37d
Author: Jorge Ramirez-Ortiz 
Date:   Tue 

[Xenomai-git] Philippe Gerum : cobalt/sched: quota: reject configuration of non-rt CPU [ steely]

2017-07-17 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 230bfaaa5efc5fe33b39c2be624ba3fa31a39d30
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=230bfaaa5efc5fe33b39c2be624ba3fa31a39d30

Author: Philippe Gerum 
Date:   Sat Jul  8 20:16:22 2017 +0200

cobalt/sched: quota: reject configuration of non-rt CPU [steely]

---

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

diff --git a/kernel/cobalt/posix/sched.c b/kernel/cobalt/posix/sched.c
index b73d531..4ae8738 100644
--- a/kernel/cobalt/posix/sched.c
+++ b/kernel/cobalt/posix/sched.c
@@ -622,7 +622,7 @@ int __cobalt_sched_setconfig_np(int cpu, int policy,
 
trace_cobalt_sched_setconfig(cpu, policy, len);
 
-   if (cpu < 0 || cpu >= NR_CPUS || !cpu_online(cpu))
+   if (cpu < 0 || cpu >= NR_CPUS || !xnsched_supported_cpu(cpu))
return -EINVAL;
 
if (len == 0)


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


[Xenomai-git] Giulio Moro : drivers/gpio: fixup for kernel 4.4+ series

2017-07-17 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: e438ae51e9aaa8ef74aa50653ae0024f7a669f99
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e438ae51e9aaa8ef74aa50653ae0024f7a669f99

Author: Giulio Moro 
Date:   Mon Jul  3 15:54:45 2017 +0200

drivers/gpio: fixup for kernel 4.4+ series

---

 kernel/cobalt/include/asm-generic/xenomai/wrappers.h |   18 --
 kernel/drivers/gpio/gpio-core.c  |2 +-
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h 
b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index c9e6e87..b79cd1b 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -42,6 +42,18 @@
 #define in_ia32_syscall() (current_thread_info()->status & TS_COMPAT)
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,4,0)
+#define cobalt_gpiochip_dev(__gc)  ((__gc)->dev)
+#else
+#define cobalt_gpiochip_dev(__gc)  ((__gc)->parent)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0)
+#define cobalt_get_restart_block(p)(_thread_info(p)->restart_block)
+#else
+#define cobalt_get_restart_block(p)(&(p)->restart_block)
+#endif
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
 #define user_msghdr msghdr
 #endif
@@ -137,10 +149,4 @@ devm_hwmon_device_register_with_groups(struct device *dev, 
const char *name,
 #error "Xenomai/cobalt requires Linux kernel 3.10 or above"
 #endif /* < 3.10 */
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0)
-#define cobalt_get_restart_block(p)(_thread_info(p)->restart_block)
-#else
-#define cobalt_get_restart_block(p)(&(p)->restart_block)
-#endif
-
 #endif /* _COBALT_ASM_GENERIC_WRAPPERS_H */
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index b8cb044..c8f2825 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -428,7 +428,7 @@ static int match_gpio_chip(struct gpio_chip *gc, void *data)
 {
struct device *dev = data;
 
-   return gc->dev == dev;
+   return cobalt_gpiochip_dev(gc) == dev;
 }
 
 static int add_gpio_chip(struct gpio_chip *gc, int type)


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


[Xenomai-git] Philippe Gerum : cobalt/wrappers: adapt to include/sched split

2017-07-17 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: af3d951dec131fbbbacd0ba975ec3825a8214efa
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=af3d951dec131fbbbacd0ba975ec3825a8214efa

Author: Philippe Gerum 
Date:   Mon Jul  3 18:49:29 2017 +0200

cobalt/wrappers: adapt to include/sched split

---

 .../cobalt/include/asm-generic/xenomai/wrappers.h  |2 +-
 kernel/cobalt/include/linux/xenomai/wrappers.h |   46 
 kernel/cobalt/posix/process.c  |2 +-
 kernel/cobalt/thread.c |2 +-
 scripts/prepare-kernel.sh  |1 +
 5 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h 
b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index b79cd1b..fa2dae4 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -18,7 +18,7 @@
  */
 #ifndef _COBALT_ASM_GENERIC_WRAPPERS_H
 
-#include 
+#include 
 
 #ifdef CONFIG_IPIPE_LEGACY
 #error "CONFIG_IPIPE_LEGACY must be switched off"
diff --git a/kernel/cobalt/include/linux/xenomai/wrappers.h 
b/kernel/cobalt/include/linux/xenomai/wrappers.h
new file mode 100644
index 000..1d16db4
--- /dev/null
+++ b/kernel/cobalt/include/linux/xenomai/wrappers.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 Philippe Gerum .
+ *
+ * Xenomai is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Xenomai is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Xenomai; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+#ifndef _COBALT_LINUX_WRAPPERS_H
+#define _COBALT_LINUX_WRAPPERS_H
+
+#include 
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0)
+#include 
+#include 
+
+#define cobalt_set_task_state(tsk, state_value)\
+   set_task_state(tsk, state_value)
+#else
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+/*
+ * The co-kernel can still do this sanely for a thread which is
+ * currently active on the head stage.
+ */
+#define cobalt_set_task_state(tsk, state_value)\
+   smp_store_mb((tsk)->state, (state_value))
+#endif
+
+#endif /* !_COBALT_LINUX_WRAPPERS_H */
diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
index af94f4d..152c07b 100644
--- a/kernel/cobalt/posix/process.c
+++ b/kernel/cobalt/posix/process.c
@@ -1200,7 +1200,7 @@ static int handle_sigwake_event(struct task_struct *p)
 * we don't break any undergoing ptrace.
 */
if (p->state & (TASK_INTERRUPTIBLE|TASK_UNINTERRUPTIBLE))
-   set_task_state(p, p->state | TASK_NOWAKEUP);
+   cobalt_set_task_state(p, p->state | TASK_NOWAKEUP);
 
__xnthread_kick(thread);
 
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 6a86265..1fdea99 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -2139,7 +2139,7 @@ void xnthread_relax(int notify, int reason)
 * dropped by xnthread_suspend().
 */
xnlock_get();
-   set_task_state(p, p->state & ~TASK_NOWAKEUP);
+   set_current_state(p->state & ~TASK_NOWAKEUP);
xnthread_run_handler_stack(thread, relax_thread);
xnthread_suspend(thread, XNRELAX, XN_INFINITE, XN_RELATIVE, NULL);
splnone();
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 398ebcb..89f3276 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -426,6 +426,7 @@ patch_link n cobalt-core.h kernel/cobalt/trace 
include/trace/events
 patch_link n cobalt-rtdm.h kernel/cobalt/trace include/trace/events
 patch_link n cobalt-posix.h kernel/cobalt/trace include/trace/events
 patch_link r n kernel/cobalt/include/asm-generic/xenomai 
include/asm-generic/xenomai
+patch_link r n kernel/cobalt/include/linux/xenomai include/linux/xenomai
 patch_link n m kernel/cobalt/posix kernel/xenomai/posix
 patch_link n m kernel/cobalt/rtdm kernel/xenomai/rtdm
 patch_link r m kernel/drivers drivers/xenomai


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


[Xenomai-git] Philippe Gerum : cobalt/sched: fix preemption enable/disable helpers [ steely]

2017-07-17 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 09b1fbf5e30c6a5b60085159883d1584ba25510f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=09b1fbf5e30c6a5b60085159883d1584ba25510f

Author: Philippe Gerum 
Date:   Sun Jul  2 19:52:40 2017 +0200

cobalt/sched: fix preemption enable/disable helpers [steely]

- XNINIRQ implicitly locks the scheduler, no need to track the
per-thread lock count in this case.

- sched->curr cannot be NULL, the root thread placeholder is there if
no Cobalt thread is currently active.

- a relaxed thread which is currently active on the scheduler slot is
  represented by the root thread placeholder, so there is no point in
  testing for XNRELAX.

There is a short window of time during which a thread in flight to
relaxed mode might be preempted by an IRQ, while sched->curr !=
>rootcb and XNRELAX is set in the sched->curr state. This case
is filtered out early as a side-effect of checking for XNINIRQ.

---

 kernel/cobalt/sched.c |   31 +++
 1 file changed, 7 insertions(+), 24 deletions(-)

diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index cbe14bd..bc7a7e8 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -326,6 +326,8 @@ void xnsched_lock(void)
struct xnsched *sched = xnsched_current();
struct xnthread *curr = sched->curr;
 
+   if (sched->lflags & XNINIRQ)
+   return;
/*
 * CAUTION: The fast xnthread_current() accessor carries the
 * relevant lock nesting count only if current runs in primary
@@ -334,19 +336,8 @@ void xnsched_lock(void)
 * current scheduler, which must be done with IRQs off.
 * Either way, we don't need to grab the super lock.
 */
-   if (unlikely(curr == NULL || xnthread_test_state(curr, XNRELAX))) {
-   /*
-* In IRQ: scheduler already locked, and we may have
-* interrupted xnthread_relax() where the BUG_ON condition is
-* temporarily false.
-*/
-   if (sched->lflags & XNINIRQ)
-   return;
-
-   irqoff_only();
-   curr = >rootcb;
-   XENO_BUG_ON(COBALT, xnsched_current()->curr != curr);
-   }
+   XENO_WARN_ON_ONCE(COBALT, (curr->state & XNROOT) &&
+ !hard_irqs_disabled());
 
curr->lock_count++;
 }
@@ -357,17 +348,9 @@ void xnsched_unlock(void)
struct xnsched *sched = xnsched_current();
struct xnthread *curr = sched->curr;
 
-   if (unlikely(curr == NULL || xnthread_test_state(curr, XNRELAX))) {
-   /*
-* In IRQ
-*/
-   if (sched->lflags & XNINIRQ)
-   return;
-
-   irqoff_only();
-   curr = _current()->rootcb;
-   }
-
+   if (sched->lflags & XNINIRQ)
+   return;
+   
if (!XENO_ASSERT(COBALT, curr->lock_count > 0))
return;



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


[Xenomai-git] Philippe Gerum : cobalt/arm: add calibration value for Altera socfpga

2017-07-17 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 8b6fbbc7b80c0f0169567dfc4c50e2a7a502f7b5
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8b6fbbc7b80c0f0169567dfc4c50e2a7a502f7b5

Author: Philippe Gerum 
Date:   Thu Jul 13 09:22:56 2017 +0200

cobalt/arm: add calibration value for Altera socfpga

---

 kernel/cobalt/arch/arm/include/asm/xenomai/calibration.h |2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/calibration.h 
b/kernel/cobalt/arch/arm/include/asm/xenomai/calibration.h
index fa96f65..d227cae 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/calibration.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/calibration.h
@@ -50,6 +50,8 @@ static inline void xnarch_get_latencies(struct 
xnclock_gravity *p)
ulat = cpu_is_omap44xx() ? 2500 : 5000;
 #elif defined(CONFIG_ARCH_STI)
ulat = 6000;
+#elif defined(CONFIG_ARCH_SOCFPGA)
+   ulat = 4500;
 #else
ulat = 9500;/* XXX sane? */
 #endif


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


[Xenomai-git] Jan Kiszka : cobalt: Fix mutex_trylock slow-path in userspace

2017-07-17 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: f1812c5f71b325e5195b7f976346eed6c12f495f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f1812c5f71b325e5195b7f976346eed6c12f495f

Author: Jan Kiszka 
Date:   Fri Jul 14 20:29:06 2017 +0200

cobalt: Fix mutex_trylock slow-path in userspace

There was a misplaced return that caused a premature EBUSY in case
xnsynch_fast_acquire returned -EAGAIN or xnsynch_fast_owner_check
failed.

Signed-off-by: Jan Kiszka 

---

 lib/cobalt/mutex.c |   15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c
index eba236b..c98d2ea 100644
--- a/lib/cobalt/mutex.c
+++ b/lib/cobalt/mutex.c
@@ -486,16 +486,17 @@ COBALT_IMPL(int, pthread_mutex_trylock, (pthread_mutex_t 
*mutex))
err = -EBUSY;
}
 
-   if (err == -EBUSY && _mutex->attr.type == PTHREAD_MUTEX_RECURSIVE) {
-   if (_mutex->lockcnt == UINT32_MAX)
-   return EAGAIN;
+   if (err == -EBUSY) {
+   if (_mutex->attr.type == PTHREAD_MUTEX_RECURSIVE) {
+   if (_mutex->lockcnt == UINT32_MAX)
+   return EAGAIN;
 
-   ++_mutex->lockcnt;
-   return 0;
+   ++_mutex->lockcnt;
+   return 0;
+   }
+   return EBUSY;
}
 
-   return EBUSY;
-
 do_syscall:
 
do {


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


[Xenomai-git] Philippe Gerum : cobalt: fix deprecated vsprintf format specifier

2017-07-01 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 18933674794e8aa11a6af6da589822d0bbc0169c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=18933674794e8aa11a6af6da589822d0bbc0169c

Author: Philippe Gerum 
Date:   Sat Jul  1 16:27:29 2017 +0200

cobalt: fix deprecated vsprintf format specifier

---

 kernel/cobalt/heap.c   |2 +-
 kernel/cobalt/trace/cobalt-posix.h |8 
 kernel/cobalt/trace/cobalt-rtdm.h  |2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/cobalt/heap.c b/kernel/cobalt/heap.c
index ce4ef54..5aacc9a 100644
--- a/kernel/cobalt/heap.c
+++ b/kernel/cobalt/heap.c
@@ -114,7 +114,7 @@ static int vfile_show(struct xnvfile_snapshot_iterator *it, 
void *data)
xnvfile_printf(it, "%9s %9s  %s\n",
   "TOTAL", "FREE", "NAME");
else
-   xnvfile_printf(it, "%9Zu %9Zu  %s\n",
+   xnvfile_printf(it, "%9zu %9zu  %s\n",
   p->all_mem,
   p->free_mem,
   p->name);
diff --git a/kernel/cobalt/trace/cobalt-posix.h 
b/kernel/cobalt/trace/cobalt-posix.h
index eaac70d..9b8f1ff 100644
--- a/kernel/cobalt/trace/cobalt-posix.h
+++ b/kernel/cobalt/trace/cobalt-posix.h
@@ -370,7 +370,7 @@ TRACE_EVENT(cobalt_sched_setconfig,
__entry->policy = policy;
__entry->len = len;
),
-   TP_printk("cpu=%d policy=%d(%s) len=%Zu",
+   TP_printk("cpu=%d policy=%d(%s) len=%zu",
  __entry->cpu, __entry->policy,
  cobalt_print_sched_policy(__entry->policy),
  __entry->len)
@@ -882,7 +882,7 @@ TRACE_EVENT(cobalt_mq_send,
__entry->len = len;
__entry->prio = prio;
),
-   TP_printk("mqd=%d buf=%p len=%Zu prio=%u",
+   TP_printk("mqd=%d buf=%p len=%zu prio=%u",
  __entry->mqd, __entry->u_buf, __entry->len,
  __entry->prio)
 );
@@ -903,7 +903,7 @@ TRACE_EVENT(cobalt_mq_timedreceive,
__entry->len = len;
__assign_timespec(timeout, timeout);
),
-   TP_printk("mqd=%d buf=%p len=%Zu timeout=(%ld.%09ld)",
+   TP_printk("mqd=%d buf=%p len=%zu timeout=(%ld.%09ld)",
  __entry->mqd, __entry->u_buf, __entry->len,
  __timespec_args(timeout))
 );
@@ -921,7 +921,7 @@ TRACE_EVENT(cobalt_mq_receive,
__entry->u_buf = u_buf;
__entry->len = len;
),
-   TP_printk("mqd=%d buf=%p len=%Zu",
+   TP_printk("mqd=%d buf=%p len=%zu",
  __entry->mqd, __entry->u_buf, __entry->len)
 );
 
diff --git a/kernel/cobalt/trace/cobalt-rtdm.h 
b/kernel/cobalt/trace/cobalt-rtdm.h
index 10bdb3a..6634cd6 100644
--- a/kernel/cobalt/trace/cobalt-rtdm.h
+++ b/kernel/cobalt/trace/cobalt-rtdm.h
@@ -320,7 +320,7 @@ TRACE_EVENT(cobalt_fd_mmap,
__entry->flags = rma->flags;
),
 
-   TP_printk("device=%p fd=%d area={ len:%Zu, off:%Lu }"
+   TP_printk("device=%p fd=%d area={ len:%zu, off:%Lu }"
  " prot=%#x(%s) flags=%#x(%s) pid=%d comm=%s",
  __entry->dev, __entry->ufd, __entry->length,
  (unsigned long long)__entry->offset,


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


[Xenomai-git] Philippe Gerum : cobalt/rtdm: device: fix error path

2017-07-01 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 992dbdfc6840308b1335764900b35cf537df8274
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=992dbdfc6840308b1335764900b35cf537df8274

Author: Philippe Gerum 
Date:   Mon Jun 19 21:15:19 2017 +0200

cobalt/rtdm: device: fix error path

---

 kernel/cobalt/rtdm/device.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index b174c1b..14e5642 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -454,7 +454,7 @@ int rtdm_dev_register(struct rtdm_device *dev)
if (IS_ERR(kdev)) {
xnregistry_remove(dev->named.handle);
ret = PTR_ERR(kdev);
-   goto fail;
+   goto fail2;
}
__set_bit(minor, drv->minor_map);
} else {
@@ -477,7 +477,7 @@ int rtdm_dev_register(struct rtdm_device *dev)
 dev, dev->name);
if (IS_ERR(kdev)) {
ret = PTR_ERR(kdev);
-   goto fail;
+   goto fail2;
}
 
id = get_proto_id(drv->protocol_family, drv->socket_type);
@@ -500,7 +500,7 @@ int rtdm_dev_register(struct rtdm_device *dev)
 fail:
if (kdev)
device_destroy(kdev_class, rdev);
-
+fail2:
unregister_driver(drv);
 
mutex_unlock(_lock);


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


[Xenomai-git] Philippe Gerum : cobalt/debug: make build-time dependency on DEBUG_LOCKING obvious

2017-07-01 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 8deca757201a19ebbabd1d58682a2697ea555de0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8deca757201a19ebbabd1d58682a2697ea555de0

Author: Philippe Gerum 
Date:   Mon Jun 19 16:27:28 2017 +0200

cobalt/debug: make build-time dependency on DEBUG_LOCKING obvious

Testing XENO_DEBUG(LOCKING) in #if conditionals may confuse the
build-time dependency engine. Prior to this fix, turning on the
locking debug option without removing cobalt/debug.o may cause
undefined references at next build, such as:

kernel/built-in.o: In function `xnlock_dbg_release':
:(.text+0x111ed8): undefined reference to `xnlock_stats'
kernel/built-in.o: In function `lock_vfile_show':
:(.text+0x1186e8): undefined reference to `xnlock_stats'
kernel/built-in.o: In function `lock_vfile_store':
:(.text+0x118864): undefined reference to `xnlock_stats'

---

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

diff --git a/kernel/cobalt/lock.c b/kernel/cobalt/lock.c
index a1b2e37..e48072d 100644
--- a/kernel/cobalt/lock.c
+++ b/kernel/cobalt/lock.c
@@ -39,7 +39,7 @@
  * @{
  */
 DEFINE_XNLOCK(nklock);
-#if defined(CONFIG_SMP) || XENO_DEBUG(LOCKING)
+#if defined(CONFIG_SMP) || defined(CONFIG_XENO_OPT_DEBUG_LOCKING)
 EXPORT_SYMBOL_GPL(nklock);
 
 #ifdef CONFIG_XENO_ARCH_OUTOFLINE_XNLOCK
@@ -57,7 +57,7 @@ EXPORT_SYMBOL_GPL(___xnlock_put);
 #endif /* out of line xnlock */
 #endif /* CONFIG_SMP || XENO_DEBUG(LOCKING) */
 
-#if XENO_DEBUG(LOCKING)
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 DEFINE_PER_CPU(struct xnlockinfo, xnlock_stats);
 EXPORT_PER_CPU_SYMBOL_GPL(xnlock_stats);
 #endif


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


[Xenomai-git] Philippe Gerum : cobalt: increase default core size settings

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

Author: Philippe Gerum 
Date:   Wed May 24 18:32:48 2017 +0200

cobalt: increase default core size settings

Since the multi-core CPUs invaded the embedded space, the default
settings should meet the common allocation requirements for current
SMP configurations, which largely depend on per-CPU resources.

Set Cobalt's system heap size to 4Mb, and UMM heaps to 256k.

At this chance, also increase the default number of available POSIX
timers Cobalt can manage.

---

 kernel/cobalt/Kconfig |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/cobalt/Kconfig b/kernel/cobalt/Kconfig
index 1d7c7cc..231a1ad 100644
--- a/kernel/cobalt/Kconfig
+++ b/kernel/cobalt/Kconfig
@@ -251,14 +251,14 @@ config XENO_OPT_REGISTRY_NRSLOTS
 
 config XENO_OPT_SYS_HEAPSZ
int "Size of system heap (Kb)"
-   default 512
+   default 4096
help
The system heap is used for various internal allocations by
the Cobalt kernel. The size is expressed in Kilobytes.
 
 config XENO_OPT_PRIVATE_HEAPSZ
int "Size of private heap (Kb)"
-   default 64
+   default 256
help
The Cobalt kernel implements fast IPC mechanisms within the
scope of a process which require a private kernel memory heap
@@ -270,7 +270,7 @@ config XENO_OPT_PRIVATE_HEAPSZ
 
 config XENO_OPT_SHARED_HEAPSZ
int "Size of shared heap (Kb)"
-   default 64
+   default 256
help
The Cobalt kernel implements fast IPC mechanisms between
processes which require a shared kernel memory heap to be
@@ -282,7 +282,7 @@ config XENO_OPT_SHARED_HEAPSZ
 
 config XENO_OPT_NRTIMERS
int "Maximum number of POSIX timers per process"
-   default 128
+   default 256
help
This tunable controls how many POSIX timers can exist at any
given time for each Cobalt process (a timer is created by a


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


[Xenomai-git] Philippe Gerum : boilerplate/setup: accept CPU ranges in --cpu-affinity

2017-06-11 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 53974367e350fbe1de289a796424ba7b2d176431
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=53974367e350fbe1de289a796424ba7b2d176431

Author: Philippe Gerum 
Date:   Thu May 25 10:33:40 2017 +0200

boilerplate/setup: accept CPU ranges in --cpu-affinity

e.g. --cpu-affinity=0-2 selects CPU0, CPU1 and CPU2.
 --cpu-affinity=3-4,7 selects CPU3, CPU4 and CPU7.
 --cpu-affinity=1- selects a range from CPU1 to the last CPU configured.

NOTE: if a selected CPU is configured but not online, the setup may
fail with -EINVAL.

---

 lib/boilerplate/setup.c |   69 ++-
 1 file changed, 56 insertions(+), 13 deletions(-)

diff --git a/lib/boilerplate/setup.c b/lib/boilerplate/setup.c
index e534e66..eb9b7e1 100644
--- a/lib/boilerplate/setup.c
+++ b/lib/boilerplate/setup.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -150,20 +151,56 @@ static inline void dump_configuration(void)
printf("AUTOMATIC_BOOTSTRAP=%d\n", xenomai_auto_bootstrap);
 }
 
+static inline int resolve_cpuid(const char *s)
+{
+   return isdigit(*s) ? atoi(s) : -1;
+}
+
 static int collect_cpu_affinity(const char *cpu_list)
 {
-   char *s = strdup(cpu_list), *p, *n;
-   int ret, cpu;
-
-   n = s;
-   while ((p = strtok(n, ",")) != NULL) {
-   cpu = atoi(p);
-   if (cpu >= CPU_SETSIZE) {
-   free(s);
-   early_warning("invalid CPU number '%d'", cpu);
-   return -EINVAL;
+   char *s, *n, *range, *range_p = NULL, *id, *id_r;
+   int start, end, cpu, nr_cpus, ret;
+
+   /*
+* We don't know which CPUs are online yet, but we may know
+* which CPU identifier range is valid. Ask for the number of
+* processors configured to find out.
+*/
+   nr_cpus = (int)sysconf(_SC_NPROCESSORS_CONF);
+   if (nr_cpus < 0) {
+   ret = -errno;
+   warning("sysconf(_SC_NPROCESSORS_CONF) failed [%s]", 
symerror(ret));
+   return ret;
+   }
+
+   s = n = strdup(cpu_list);
+   while ((range = strtok_r(n, ",", _p)) != NULL) {
+   if (*range == '\0')
+   continue;
+   end = -1;
+   if (range[strlen(range)-1] == '-')
+   end = nr_cpus - 1;
+   id = strtok_r(range, "-", _r);
+   if (id) {
+   start = resolve_cpuid(id);
+   if (*range == '-') {
+   end = start;
+   start = 0;
+   }
+   id = strtok_r(NULL, "-", _r);
+   if (id)
+   end = resolve_cpuid(id);
+   else if (end < 0)
+   end = start;
+   if (start < 0 || start >= nr_cpus ||
+   end < 0 || end >= nr_cpus)
+   goto fail;
+   } else {
+   start = 0;
+   end = nr_cpus - 1;
}
-   CPU_SET(cpu, &__base_setup_data.cpu_affinity);
+   for (cpu = start; cpu <= end; cpu++)
+   CPU_SET(cpu, &__base_setup_data.cpu_affinity);
n = NULL;
}
 
@@ -182,11 +219,17 @@ static int collect_cpu_affinity(const char *cpu_list)
ret = sched_setaffinity(0, sizeof(__base_setup_data.cpu_affinity),
&__base_setup_data.cpu_affinity);
if (ret) {
-   early_warning("invalid CPU in affinity list '%s'", cpu_list);
-   return -errno;
+   ret = -errno;
+   early_warning("invalid CPU in '%s'", cpu_list);
+   return ret;
}
 
return 0;
+fail:
+   warning("invalid CPU number/range in '%s'", cpu_list);
+   free(s);
+
+   return -EINVAL;
 }
 
 static inline char **prep_args(int argc, char *const argv[], int *largcp)


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


[Xenomai-git] Philippe Gerum : testsuite/switchtest: handle --cpu-affinity argument

2017-06-11 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 062a06e49a523dd0f7fec123183f237a297a93cd
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=062a06e49a523dd0f7fec123183f237a297a93cd

Author: Philippe Gerum 
Date:   Wed May 24 20:12:07 2017 +0200

testsuite/switchtest: handle --cpu-affinity argument

We may want to limit the test to a selected set of CPUs, the
--cpu-affinity base setting can express this set for us.

e.g. switchtest --cpu-affinity=0,7 will run the test over CPU0 and
CPU7 exclusively.

---

 testsuite/switchtest/switchtest.c |  126 +
 1 file changed, 72 insertions(+), 54 deletions(-)

diff --git a/testsuite/switchtest/switchtest.c 
b/testsuite/switchtest/switchtest.c
index 2f1dae3..20b8ab2 100644
--- a/testsuite/switchtest/switchtest.c
+++ b/testsuite/switchtest/switchtest.c
@@ -38,6 +38,17 @@
 #include 
 #include 
 #include 
+#include 
+
+static unsigned int nr_cpus;
+
+#define for_each_cpu(__cpu)\
+   for (__cpu = 0; __cpu < CPU_SETSIZE; __cpu++)   \
+   if (CPU_ISSET(__cpu, &__base_setup_data.cpu_affinity))
+
+#define for_each_cpu_index(__cpu, __index) \
+   for (__cpu = 0, __index = -1; __cpu < CPU_SETSIZE; __cpu++) \
+   if (CPU_ISSET(__cpu, &__base_setup_data.cpu_affinity) && 
++__index >= 0)
 
 #if CONFIG_SMP
 #define smp_sched_setaffinity(pid,len,mask) sched_setaffinity(pid,len,mask)
@@ -74,7 +85,7 @@ struct task_params {
 };
 
 struct cpu_tasks {
-   unsigned index;
+   unsigned int index;
struct task_params *tasks;
unsigned tasks_count;
unsigned capacity;
@@ -705,6 +716,7 @@ static int parse_arg(struct task_params *param,
unsigned long cpu;
char *cpu_end;
unsigned i;
+   int n;
 
param->type = param->fp = 0;
param->cpu = [0];
@@ -747,7 +759,13 @@ static int parse_arg(struct task_params *param,
if (*cpu_end != '\0' || (cpu == ULONG_MAX && errno))
return -1;
 
-   param->cpu = [cpu];
+   param->cpu = [nr_cpus]; /* Invalid at first. */
+   for_each_cpu_index(i, n)
+   if (i == cpu) {
+   param->cpu = [n];
+   break;
+   }
+   
return 0;
 }
 
@@ -974,13 +992,7 @@ static unsigned long xatoul(const char *str)
 
 static void usage(FILE *fd, const char *progname)
 {
-   unsigned i, j, nr_cpus;
-
-#if CONFIG_SMP
-   nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
-#else /* !CONFIG_SMP */
-   nr_cpus = 1;
-#endif /* !CONFIG_SMP */
+   unsigned i, j;
 
fprintf(fd,
"Usage:\n"
@@ -1024,17 +1036,19 @@ static void usage(FILE *fd, const char *progname)
"Passing no 'threadspec' is equivalent to running:\n%s",
progname, progname);
 
-   for (i = 0; i < nr_cpus; i++)
+   for_each_cpu(i) {
for (j = 0; j < sizeof(all_fp)/sizeof(char *); j++)
fprintf(fd, " %s%d", all_fp[j], i);
+   }
 
fprintf(fd,
"\n\nPassing only the --nofpu or -n argument is equivalent to "
"running:\n%s", progname);
 
-   for (i = 0; i < nr_cpus; i++)
+   for_each_cpu(i) {
for (j = 0; j < sizeof(all_nofp)/sizeof(char *); j++)
fprintf(fd, " %s%d", all_nofp[j], i);
+   }
fprintf(fd, "\n\n");
 }
 
@@ -1106,7 +1120,7 @@ static int check_fpu(void)
 
 int main(int argc, const char *argv[])
 {
-   unsigned i, j, nr_cpus, use_fp = 1, stress = 0;
+   unsigned i, j, n, use_fp = 1, stress = 0;
pthread_attr_t rt_attr;
const char *progname = argv[0];
struct cpu_tasks *cpus;
@@ -1125,19 +1139,24 @@ int main(int argc, const char *argv[])
}
 
 #if CONFIG_SMP
-   nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+   nr_cpus = CPU_COUNT(&__base_setup_data.cpu_affinity);
+   if (nr_cpus == 0) {
+   nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+   if (nr_cpus == -1) {
+   fprintf(stderr,
+   "Error %d while getting the number of cpus 
(%s)\n",
+   errno,
+   strerror(errno));
+   exit(EXIT_FAILURE);
+   }
+   for (i = 0; i < nr_cpus; i++)
+   CPU_SET(i, &__base_setup_data.cpu_affinity);
+   }
 #else /* !CONFIG_SMP */
nr_cpus = 1;
+   CPU_SET(0, &__base_setup_data.cpu_affinity);
 #endif /* !CONFIG_SMP */
 
-   if (nr_cpus == -1) {
-   fprintf(stderr,
-   "Error %d while getting the number of cpus (%s)\n",
-   errno,
-   strerror(errno));
-   exit(EXIT_FAILURE);
-   }
-
fp_features = cobalt_fp_detect();
 
/* Parse command line options. */
@@ -1234,46 

[Xenomai-git] Jorge Ramirez-Ortiz : gpiopwm: display udp server information

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

Author: Jorge Ramirez-Ortiz 
Date:   Wed Mar 30 13:30:11 2016 -0400

gpiopwm: display udp server information

---

 demo/posix/cobalt/gpiopwm.c |   62 ---
 1 file changed, 59 insertions(+), 3 deletions(-)

diff --git a/demo/posix/cobalt/gpiopwm.c b/demo/posix/cobalt/gpiopwm.c
index e093fbe..71a87d4 100644
--- a/demo/posix/cobalt/gpiopwm.c
+++ b/demo/posix/cobalt/gpiopwm.c
@@ -18,9 +18,10 @@
 #include 
 #include 
 #include 
+#include 
 
-#define MIN_DUTY_CYCLE 0
-#define MAX_DUTY_CYCLE 100
+#define MIN_DUTY_CYCLE (0)
+#define MAX_DUTY_CYCLE (100)
 
 typedef void *(*gpiopwm_control_thread)(void *cookie);
 #define DEVICE_NAME "/dev/rtdm/gpiopwm"
@@ -33,6 +34,11 @@ static int stop;
 static int step = 1;
 static int port = 6;
 
+#define MAX_IP_INTERFACES  (9)
+static char *ip_str[MAX_IP_INTERFACES + 1];
+static int last_ip;
+
+
 #define GPIO_PWM_SERVO_CONFIG  \
 {  \
.duty_cycle =   50, \
@@ -75,7 +81,11 @@ static inline void clear_screen(void)
 
 static inline void print_config(char *str)
 {
+   int i;
+
printf("Config: %s\n", str);
+   for (i = 0; i < last_ip ; i++)
+   printf("%s", ip_str[i]);
printf(" device : %s\n", device_name);
printf(" range  : [%d, %d]\n", config.range_min, config.range_max);
printf(" period : %d nsec\n", config.period);
@@ -90,6 +100,51 @@ static inline void input_message(void)
printf( "  Enter duty_cycle [0-100] : ");
 }
 
+static void get_ip_addresses(void)
+{
+   char ip[INET_ADDRSTRLEN];
+   struct sockaddr_in *s_in;
+   struct ifconf ifconf;
+   struct ifreq ifr[10];
+   int ret;
+   int ifs;
+   int i;
+   int s;
+
+   s = socket(AF_INET, SOCK_STREAM, 0);
+   if (s < 0)
+   return;
+
+   ifconf.ifc_buf = (char *) ifr;
+   ifconf.ifc_len = sizeof(ifr);
+
+   if (ioctl(s, SIOCGIFCONF, ) == -1)
+   return;
+
+   ifs = ifconf.ifc_len / sizeof(ifr[0]);
+
+   /* we wont _display_ more than MAX_IP_INTERFACES */
+   if (ifs > MAX_IP_INTERFACES)
+   ifs = MAX_IP_INTERFACES;
+
+   last_ip = ifs + 1;
+
+   for (i = 0; i < ifs; i++) {
+   s_in = (struct sockaddr_in *) [i].ifr_addr;
+   if (!inet_ntop(AF_INET, _in->sin_addr, ip, sizeof(ip)))
+   return;
+   ret = asprintf(_str[i]," ip  : %s\n", ip);
+   if (ret)
+   perror("asprintf");
+   }
+
+   ret = asprintf(_str[i]," port: %d\n\n", port);
+   if (ret)
+   perror("asprintf");
+
+   close(s);
+}
+
 static void setup_sched_parameters(pthread_attr_t *attr, int prio)
 {
struct sched_param p;
@@ -171,7 +226,7 @@ static void *gpiopwm_udp_ctrl_thread(void *cookie)
for (;;) {
 
clear_screen();
-   print_config("UDP server");
+   print_config("UDP Server\n");
 
memset(buf,'\0', blen);
ret = recvfrom(sockfd, buf, blen - 1, 0, , );
@@ -382,6 +437,7 @@ int main(int argc, char *argv[])
case udp_opt:
handler = gpiopwm_udp_ctrl_thread;
port = atoi(optarg);
+   get_ip_addresses();
break;
case config_opt:
p = strtok(optarg,":");


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


[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release

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

Author: Jan Kiszka 
Date:   Mon May  9 21:19:04 2016 +0200

cobalt/kernel: Return need_resched flag from xnsynch_release

We currently return the next owner, but no caller of xnsynch_release
evaluates this beyond != NULL and calls xnsched_run in that case.
Simplify the API by returning a need_resched flag directly. This will
also help with fixing the missing reschedule after PP deboost.

Signed-off-by: Jan Kiszka 

---

 include/cobalt/kernel/synch.h |3 +--
 kernel/cobalt/posix/mutex.c   |2 +-
 kernel/cobalt/rtdm/drvlib.c   |2 +-
 kernel/cobalt/synch.c |   23 +++
 4 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h
index 246d2b9..b3a8004 100644
--- a/include/cobalt/kernel/synch.h
+++ b/include/cobalt/kernel/synch.h
@@ -164,8 +164,7 @@ int __must_check xnsynch_acquire(struct xnsynch *synch,
 
 int __must_check xnsynch_try_acquire(struct xnsynch *synch);
 
-struct xnthread *xnsynch_release(struct xnsynch *synch,
-struct xnthread *thread);
+bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread);
 
 struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch);
 
diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c
index c6020ff..f99874b 100644
--- a/kernel/cobalt/posix/mutex.c
+++ b/kernel/cobalt/posix/mutex.c
@@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr,
cobalt_cond_deferred_signals(cond);
}
}
-   need_resched |= xnsynch_release(>synchbase, curr) != NULL;
+   need_resched |= xnsynch_release(>synchbase, curr);
 
return need_resched;
 }
diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c
index 248a9a8..6f4f51e 100644
--- a/kernel/cobalt/rtdm/drvlib.c
+++ b/kernel/cobalt/rtdm/drvlib.c
@@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex)
trace_cobalt_driver_mutex_release(mutex);
 
if (unlikely(xnsynch_release(>synch_base,
-xnsched_current_thread()) != NULL))
+xnsched_current_thread(
xnsched_run();
 }
 EXPORT_SYMBOL_GPL(rtdm_mutex_unlock);
diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c
index 976261d..d8b83d9 100644
--- a/kernel/cobalt/synch.c
+++ b/kernel/cobalt/synch.c
@@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch,
drop_booster(synch, owner);
 }
 
-static struct xnthread *transfer_ownership(struct xnsynch *synch,
-  struct xnthread *lastowner)
+static bool transfer_ownership(struct xnsynch *synch,
+  struct xnthread *lastowner)
 {  /* nklock held, irqs off */
struct xnthread *nextowner;
xnhandle_t nextownerh;
@@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch 
*synch,
if (list_empty(>pendq)) {
synch->owner = NULL;
atomic_set(lockp, XN_NO_HANDLE);
-   return NULL;
+   return false;
}
 
nextowner = list_first_entry(>pendq, struct xnthread, plink);
@@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch 
*synch,
 
atomic_set(lockp, nextownerh);
 
-   return nextowner;
+   return true;
 }
 
 /**
- * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread 
*curr)
+ * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr)
  * @brief Release a resource and pass it to the next waiting thread.
  *
  * This service releases the ownership of the given synchronization
@@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch 
*synch,
  * @param curr The descriptor address of the current thread, which
  * must own the object at the time of calling.
  *
- * @return The descriptor address of the unblocked thread.
+ * @return True if a reschedule is required.
  *
  * @sideeffect
  *
@@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch 
*synch,
  *
  * @coretags{primary-only, might-switch}
  */
-struct xnthread *xnsynch_release(struct xnsynch *synch,
-struct xnthread *curr)
+bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr)
 {
-   struct xnthread *nextowner = NULL;
+   bool need_resched = false;
xnhandle_t currh, h;
atomic_t *lockp;
spl_t s;
@@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch,
trace_cobalt_synch_release(synch);
 
if (xnthread_put_resource(curr))
-   return NULL;
+

[Xenomai-git] Jan Kiszka : smokey/posix-mutex: Fix test case by destroying barriers correctly

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

Author: Jan Kiszka 
Date:   Tue Dec  6 16:34:48 2016 +0100

smokey/posix-mutex: Fix test case by destroying barriers correctly

At least on x86-64-compat, the missing destruction of the smokey
barriers, specifically their embedded mutexes, cause crashes of the
test. The reason is likely a mismatch between the kernel's and
userland's view on which object is still active, combined with the fact
that userland kept them on the volatile stack.

Signed-off-by: Jan Kiszka 

---

 testsuite/smokey/posix-mutex/posix-mutex.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/testsuite/smokey/posix-mutex/posix-mutex.c 
b/testsuite/smokey/posix-mutex/posix-mutex.c
index 151c2f3..9a1592b 100644
--- a/testsuite/smokey/posix-mutex/posix-mutex.c
+++ b/testsuite/smokey/posix-mutex/posix-mutex.c
@@ -291,6 +291,8 @@ static int do_contend(pthread_mutex_t *mutex, int type)
if (!__Tassert(status == NULL))
return -EINVAL;
 
+   smokey_barrier_destroy();
+
return 0;
 }
 
@@ -471,6 +473,8 @@ static int do_pi_contend(int prio)
if (!__T(ret, pthread_mutex_destroy()))
return ret;
 
+   smokey_barrier_destroy();
+
return 0;
 }
 
@@ -578,6 +582,8 @@ static int do_steal(int may_steal)
if (!__T(ret, pthread_mutex_destroy()))
return ret;
 
+   smokey_barrier_destroy();
+
return 0;
 }
 


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


[Xenomai-git] Philippe Gerum : cobalt: increase default core size settings

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

Author: Philippe Gerum 
Date:   Wed May 24 18:32:48 2017 +0200

cobalt: increase default core size settings

Since the multi-core CPUs invaded the embedded space, the default
settings should meet the common allocation requirements for current
SMP configurations, which largely depend on per-CPU resources.

Set Cobalt's system heap size to 4Mb, and UMM heaps to 256k.

At this chance, also increase the default number of available POSIX
timers Cobalt can manage.

---

 kernel/cobalt/Kconfig |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/cobalt/Kconfig b/kernel/cobalt/Kconfig
index 1d7c7cc..231a1ad 100644
--- a/kernel/cobalt/Kconfig
+++ b/kernel/cobalt/Kconfig
@@ -251,14 +251,14 @@ config XENO_OPT_REGISTRY_NRSLOTS
 
 config XENO_OPT_SYS_HEAPSZ
int "Size of system heap (Kb)"
-   default 512
+   default 4096
help
The system heap is used for various internal allocations by
the Cobalt kernel. The size is expressed in Kilobytes.
 
 config XENO_OPT_PRIVATE_HEAPSZ
int "Size of private heap (Kb)"
-   default 64
+   default 256
help
The Cobalt kernel implements fast IPC mechanisms within the
scope of a process which require a private kernel memory heap
@@ -270,7 +270,7 @@ config XENO_OPT_PRIVATE_HEAPSZ
 
 config XENO_OPT_SHARED_HEAPSZ
int "Size of shared heap (Kb)"
-   default 64
+   default 256
help
The Cobalt kernel implements fast IPC mechanisms between
processes which require a shared kernel memory heap to be
@@ -282,7 +282,7 @@ config XENO_OPT_SHARED_HEAPSZ
 
 config XENO_OPT_NRTIMERS
int "Maximum number of POSIX timers per process"
-   default 128
+   default 256
help
This tunable controls how many POSIX timers can exist at any
given time for each Cobalt process (a timer is created by a


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


[Xenomai-git] Philippe Gerum : testsuite/switchtest: handle --cpu-affinity argument

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

Author: Philippe Gerum 
Date:   Wed May 24 20:12:07 2017 +0200

testsuite/switchtest: handle --cpu-affinity argument

We may want to limit the test to a selected set of CPUs, the
--cpu-affinity base setting can express this set for us.

e.g. switchtest --cpu-affinity=0,7 will run the test over CPU0 and
CPU7 exclusively.

---

 testsuite/switchtest/switchtest.c |  126 +
 1 file changed, 72 insertions(+), 54 deletions(-)

diff --git a/testsuite/switchtest/switchtest.c 
b/testsuite/switchtest/switchtest.c
index 5c102a2..015bde6 100644
--- a/testsuite/switchtest/switchtest.c
+++ b/testsuite/switchtest/switchtest.c
@@ -39,6 +39,17 @@
 #include 
 #include 
 #include 
+#include 
+
+static unsigned int nr_cpus;
+
+#define for_each_cpu(__cpu)\
+   for (__cpu = 0; __cpu < CPU_SETSIZE; __cpu++)   \
+   if (CPU_ISSET(__cpu, &__base_setup_data.cpu_affinity))
+
+#define for_each_cpu_index(__cpu, __index) \
+   for (__cpu = 0, __index = -1; __cpu < CPU_SETSIZE; __cpu++) \
+   if (CPU_ISSET(__cpu, &__base_setup_data.cpu_affinity) && 
++__index >= 0)
 
 #if CONFIG_SMP
 #define smp_sched_setaffinity(pid,len,mask) sched_setaffinity(pid,len,mask)
@@ -75,7 +86,7 @@ struct task_params {
 };
 
 struct cpu_tasks {
-   unsigned index;
+   unsigned int index;
struct task_params *tasks;
unsigned tasks_count;
unsigned capacity;
@@ -715,6 +726,7 @@ static int parse_arg(struct task_params *param,
unsigned long cpu;
char *cpu_end;
unsigned i;
+   int n;
 
param->type = param->fp = 0;
param->cpu = [0];
@@ -757,7 +769,13 @@ static int parse_arg(struct task_params *param,
if (*cpu_end != '\0' || (cpu == ULONG_MAX && errno))
return -1;
 
-   param->cpu = [cpu];
+   param->cpu = [nr_cpus]; /* Invalid at first. */
+   for_each_cpu_index(i, n)
+   if (i == cpu) {
+   param->cpu = [n];
+   break;
+   }
+   
return 0;
 }
 
@@ -984,13 +1002,7 @@ static unsigned long xatoul(const char *str)
 
 static void usage(FILE *fd, const char *progname)
 {
-   unsigned i, j, nr_cpus;
-
-#if CONFIG_SMP
-   nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
-#else /* !CONFIG_SMP */
-   nr_cpus = 1;
-#endif /* !CONFIG_SMP */
+   unsigned i, j;
 
fprintf(fd,
"Usage:\n"
@@ -1034,17 +1046,19 @@ static void usage(FILE *fd, const char *progname)
"Passing no 'threadspec' is equivalent to running:\n%s",
progname, progname);
 
-   for (i = 0; i < nr_cpus; i++)
+   for_each_cpu(i) {
for (j = 0; j < sizeof(all_fp)/sizeof(char *); j++)
fprintf(fd, " %s%d", all_fp[j], i);
+   }
 
fprintf(fd,
"\n\nPassing only the --nofpu or -n argument is equivalent to "
"running:\n%s", progname);
 
-   for (i = 0; i < nr_cpus; i++)
+   for_each_cpu(i) {
for (j = 0; j < sizeof(all_nofp)/sizeof(char *); j++)
fprintf(fd, " %s%d", all_nofp[j], i);
+   }
fprintf(fd, "\n\n");
 }
 
@@ -1116,7 +1130,7 @@ static int check_fpu(void)
 
 int main(int argc, const char *argv[])
 {
-   unsigned i, j, nr_cpus, use_fp = 1, stress = 0;
+   unsigned i, j, n, use_fp = 1, stress = 0;
pthread_attr_t rt_attr;
const char *progname = argv[0];
struct cpu_tasks *cpus;
@@ -1135,19 +1149,24 @@ int main(int argc, const char *argv[])
}
 
 #if CONFIG_SMP
-   nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+   nr_cpus = CPU_COUNT(&__base_setup_data.cpu_affinity);
+   if (nr_cpus == 0) {
+   nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+   if (nr_cpus == -1) {
+   fprintf(stderr,
+   "Error %d while getting the number of cpus 
(%s)\n",
+   errno,
+   strerror(errno));
+   exit(EXIT_FAILURE);
+   }
+   for (i = 0; i < nr_cpus; i++)
+   CPU_SET(i, &__base_setup_data.cpu_affinity);
+   }
 #else /* !CONFIG_SMP */
nr_cpus = 1;
+   CPU_SET(0, &__base_setup_data.cpu_affinity);
 #endif /* !CONFIG_SMP */
 
-   if (nr_cpus == -1) {
-   fprintf(stderr,
-   "Error %d while getting the number of cpus (%s)\n",
-   errno,
-   strerror(errno));
-   exit(EXIT_FAILURE);
-   }
-
fp_features = cobalt_fp_detect();
 
/* Parse command line options. */
@@ -1244,46 +1263,46 @@ 

[Xenomai-git] Philippe Gerum : lib/cobalt: init: hint about failure due to disabled core

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

Author: Philippe Gerum 
Date:   Thu Jun  1 09:46:29 2017 +0200

lib/cobalt: init: hint about failure due to disabled core

---

 lib/cobalt/init.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/cobalt/init.c b/lib/cobalt/init.c
index 69d4763..800d487 100644
--- a/lib/cobalt/init.c
+++ b/lib/cobalt/init.c
@@ -112,6 +112,9 @@ static void low_init(void)
case -ENOEXEC:
early_panic("ABI mismatch: required r%lu, provided r%lu",
XENOMAI_ABI_REV, f->feat_abirev);
+   case -EAGAIN:
+   early_panic("Cobalt core present but disabled "
+   "(use corectl --start)");
case -ENOSYS:
early_panic("Cobalt core not enabled in kernel");
default:


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


[Xenomai-git] Philippe Gerum : cobalt/syscalls: reject binding attempt to disabled core with EAGAIN

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

Author: Philippe Gerum 
Date:   Thu Jun  1 09:43:53 2017 +0200

cobalt/syscalls: reject binding attempt to disabled core with EAGAIN

---

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

diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index 25d21ea..0f905bf 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -314,7 +314,7 @@ static COBALT_SYSCALL(bind, lostage,
f = _ret;
featreq = breq.feat_req;
if (!realtime_core_running() && (featreq & __xn_feat_control) == 0)
-   return -EPERM;
+   return -EAGAIN;
 
/*
 * Calculate the missing feature set:


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


[Xenomai-git] Philippe Gerum : cobalt/arm: fixups for kernel 4.8+

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

Author: Philippe Gerum 
Date:   Sun May 14 19:41:55 2017 +0200

cobalt/arm: fixups for kernel 4.8+

At this chance, stop using the obsolete flush_cache_all() routine
which cannot honor the documented semantics for arm64.

Besides, calibrating the access times to the timer registers in
no-cache conditions does not make sense.

---

 kernel/cobalt/arch/arm64/machine.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/machine.c 
b/kernel/cobalt/arch/arm64/machine.c
index ddf65a8..1711d76 100644
--- a/kernel/cobalt/arch/arm64/machine.c
+++ b/kernel/cobalt/arch/arm64/machine.c
@@ -35,7 +35,7 @@ static void mach_arm_prefault(struct vm_area_struct *vma)
flags = (vma->vm_flags & VM_MAYWRITE) ? FAULT_FLAG_WRITE : 0;
for (addr = vma->vm_start;
 addr != vma->vm_end; addr += PAGE_SIZE)
-   handle_mm_fault(vma->vm_mm, vma, addr, flags);
+   handle_mm_fault(vma, addr, flags);
}
 }
 
@@ -63,7 +63,6 @@ static unsigned long mach_arm_calibrate(void)
barrier();
 
for (i = 0; i < CALIBRATION_LOOPS; i++) {
-   flush_cache_all();
for (j = 0; j < CALIBRATION_LOOPS; j++) {
ipipe_read_tsc(start);
barrier();


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


[Xenomai-git] Jorge Ramirez-Ortiz : gpiopwm: pwm signal generator and servo motor control demo code

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

Author: Jorge Ramirez-Ortiz 
Date:   Tue Mar 15 19:18:15 2016 -0400

gpiopwm: pwm signal generator and servo motor control demo code

---

 demo/posix/cobalt/Makefile.am|6 +
 demo/posix/cobalt/gpiopwm.c  |  448 ++
 include/cobalt/kernel/rtdm/gpiopwm.h |   24 ++
 include/rtdm/uapi/gpiopwm.h  |   56 +
 include/rtdm/uapi/rtdm.h |1 +
 kernel/drivers/Kconfig   |1 +
 kernel/drivers/Makefile  |2 +-
 kernel/drivers/gpiopwm/Kconfig   |9 +
 kernel/drivers/gpiopwm/Makefile  |5 +
 kernel/drivers/gpiopwm/gpiopwm.c |  301 +++
 10 files changed, 852 insertions(+), 1 deletion(-)

diff --git a/demo/posix/cobalt/Makefile.am b/demo/posix/cobalt/Makefile.am
index cba9247..2a22967 100644
--- a/demo/posix/cobalt/Makefile.am
+++ b/demo/posix/cobalt/Makefile.am
@@ -3,6 +3,7 @@ demodir = @XENO_DEMO_DIR@
 CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
 
 demo_PROGRAMS =\
+   gpiopwm \
bufp-label  \
bufp-readwrite  \
can_rtt \
@@ -24,6 +25,11 @@ ldadd =  \
 @XENO_USER_LDADD@  \
-lpthread -lrt
 
+gpiopwm_SOURCES = gpiopwm.c
+gpiopwm_CPPFLAGS = $(cppflags) -I$(top_srcdir)/include/rtdm/uapi
+gpiopwm_LDFLAGS = $(ldflags)
+gpiopwm_LDADD = $(ldadd)
+
 bufp_label_SOURCES = bufp-label.c
 bufp_label_CPPFLAGS = $(cppflags)
 bufp_label_LDFLAGS = $(ldflags)
diff --git a/demo/posix/cobalt/gpiopwm.c b/demo/posix/cobalt/gpiopwm.c
new file mode 100644
index 000..e093fbe
--- /dev/null
+++ b/demo/posix/cobalt/gpiopwm.c
@@ -0,0 +1,448 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MIN_DUTY_CYCLE 0
+#define MAX_DUTY_CYCLE 100
+
+typedef void *(*gpiopwm_control_thread)(void *cookie);
+#define DEVICE_NAME "/dev/rtdm/gpiopwm"
+char *device_name;
+int dev;
+
+static sem_t synch;
+static sem_t setup;
+static int stop;
+static int step = 1;
+static int port = 6;
+
+#define GPIO_PWM_SERVO_CONFIG  \
+{  \
+   .duty_cycle =   50, \
+   .range_min  =   950,\
+   .range_max  =   2050,   \
+   .period =   2000,   \
+   .gpio   =   1,  \
+}
+
+static struct gpiopwm config = GPIO_PWM_SERVO_CONFIG;
+
+static void fail(const char *reason)
+{
+   perror(reason);
+   exit(EXIT_FAILURE);
+}
+
+static void sem_sync(sem_t *sem)
+{
+   int ret;
+
+   for (;;) {
+   ret = sem_wait(sem);
+   if (ret == 0)
+   return;
+   if (errno != EINTR)
+   fail("sem_wait");
+   }
+}
+
+static inline void clear_screen(void)
+{
+   const char* cmd = "\e[1;1H\e[2J";
+   int ret;
+
+   ret = write(2, cmd, strlen(cmd));
+   if (!ret)
+   error(1, ret, "clear screen error");
+}
+
+static inline void print_config(char *str)
+{
+   printf("Config: %s\n", str);
+   printf(" device : %s\n", device_name);
+   printf(" range  : [%d, %d]\n", config.range_min, config.range_max);
+   printf(" period : %d nsec\n", config.period);
+   printf(" gpio pin   : %d\n", config.gpio);
+   printf(" duty cycle : %d\n", config.duty_cycle);
+}
+
+static inline void input_message(void)
+{
+   print_config("");
+   printf("\n GPIO PWM Control\n");
+   printf( "  Enter duty_cycle [0-100] : ");
+}
+
+static void setup_sched_parameters(pthread_attr_t *attr, int prio)
+{
+   struct sched_param p;
+   int ret;
+
+   ret = pthread_attr_init(attr);
+   if (ret)
+   error(1, ret, "pthread_attr_init()");
+
+   ret = pthread_attr_setinheritsched(attr, PTHREAD_EXPLICIT_SCHED);
+   if (ret)
+   error(1, ret, "pthread_attr_setinheritsched()");
+
+   ret = pthread_attr_setschedpolicy(attr, prio ? SCHED_FIFO : 
SCHED_OTHER);
+   if (ret)
+   error(1, ret, "pthread_attr_setschedpolicy()");
+
+   p.sched_priority = prio;
+   ret = pthread_attr_setschedparam(attr, );
+   if (ret)
+   error(1, ret, "pthread_attr_setschedparam()");
+}
+
+static void *gpiopwm_init_thread(void *cookie)
+{
+   int ret;
+
+   pthread_setname_np(pthread_self(), "gpio-pwm-handler");
+   ret = ioctl(dev, GPIOPWM_RTIOC_SET_CONFIG, config);
+   if (ret)
+   error(1, ret, "failed to set config");
+
+   ioctl(dev, GPIOPWM_RTIOC_START);
+
+ 

[Xenomai-git] Philippe Gerum : cobalt/arm64: thread: move all TCB initializers out of line

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

Author: Philippe Gerum 
Date:   Fri Sep  9 16:07:54 2016 +0200

cobalt/arm64: thread: move all TCB initializers out of line

Does not impact performances and fixes inclusion hell for pulling the
struct xnthread definition for good.

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h |6 +-
 kernel/cobalt/arch/arm64/thread.c |6 ++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
index ac1f1f7..319f4d8 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
@@ -60,11 +60,7 @@ int xnarch_escalate(void);
 
 #if defined(CONFIG_XENO_ARCH_FPU)
 
-static inline void xnarch_init_root_tcb(struct xnthread *thread)
-{
-   struct xnarchtcb *tcb = xnthread_archtcb(thread);
-   tcb->fpup = NULL;
-}
+void xnarch_init_root_tcb(struct xnthread *thread);
 
 void xnarch_init_shadow_tcb(struct xnthread *thread);
 
diff --git a/kernel/cobalt/arch/arm64/thread.c 
b/kernel/cobalt/arch/arm64/thread.c
index b987e09..3097aeb 100644
--- a/kernel/cobalt/arch/arm64/thread.c
+++ b/kernel/cobalt/arch/arm64/thread.c
@@ -98,6 +98,12 @@ void xnarch_init_shadow_tcb(struct xnthread *thread)
tcb->fpup = >core.host_task->thread.fpsimd_state;
 }
 
+void xnarch_init_root_tcb(struct xnthread *thread)
+{
+   struct xnarchtcb *tcb = >tcb;
+   tcb->fpup = NULL;
+}
+
 #endif /* CONFIG_XENO_ARCH_FPU */
 
 void xnarch_switch_to(struct xnthread *out, struct xnthread *in)


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: no fpsimd support in real-time kthread context

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

Author: Philippe Gerum 
Date:   Wed May 24 17:41:41 2017 +0200

cobalt/arm64: no fpsimd support in real-time kthread context

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h
index cfdf0b3..b7e3f52 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h
@@ -27,7 +27,7 @@
 
 static inline int fp_kernel_supported(void)
 {
-   return 1;
+   return 0;
 }
 
 static inline int fp_linux_begin(void)


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: fpu: drop obsolete xnarch_save_fpu()

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

Author: Philippe Gerum 
Date:   Thu Sep  8 16:29:59 2016 +0200

cobalt/arm64: fpu: drop obsolete xnarch_save_fpu()

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h |4 
 1 file changed, 4 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
index 4b247ac..ac1f1f7 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
@@ -75,8 +75,6 @@ static inline int xnarch_fault_fpu_p(struct ipipe_trap_data 
*d)
 
 void xnarch_leave_root(struct xnthread *root);
 
-void xnarch_save_fpu(struct xnthread *thread);
-
 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
 
 static inline int
@@ -103,8 +101,6 @@ static inline int xnarch_fault_fpu_p(struct ipipe_trap_data 
*d)
 
 static inline void xnarch_leave_root(struct xnthread *root) { }
 
-static inline void xnarch_save_fpu(struct xnthread *thread) { }
-
 static inline void xnarch_switch_fpu(struct xnthread *f, struct xnthread *t) { 
}
 
 static inline int xnarch_handle_fpu_fault(struct xnthread *from, 


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


[Xenomai-git] Philippe Gerum : lib/cobalt: add config switch to enable lazy setsched update mode

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

Author: Philippe Gerum 
Date:   Sun Mar 20 17:58:33 2016 +0100

lib/cobalt: add config switch to enable lazy setsched update mode

--enable-lazy-setsched should be given for enabling lazy propagation
of scheduling parameters upon calls to pthread_setschedparam*(),
sched_setscheduler(). Defaults to off.

---

 configure.ac  |   19 +++
 lib/cobalt/internal.h |   12 
 lib/cobalt/sched.c|2 +-
 lib/cobalt/thread.c   |3 ++-
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index dd3a1ec..b90fa70 100644
--- a/configure.ac
+++ b/configure.ac
@@ -291,6 +291,25 @@ if test x$workaround_condvar_pi = xy; then
fi
 fi
 
+dnl Lazy schedparam propagation for Cobalt (default: off)
+
+unset lazy_setsched_update
+AC_MSG_CHECKING(whether to enable lazy scheduling parameter update)
+AC_ARG_ENABLE(lazy-setsched,
+   AS_HELP_STRING([--enable-lazy-setsched], [Enable lazy scheduling 
parameter update]),
+   [case "$enableval" in
+   y | yes) lazy_setsched_update=y ;;
+   *) unset lazy_setsched_update ;;
+   esac])
+AC_MSG_RESULT(${lazy_setsched_update:-no})
+if test x$lazy_setsched_update = xy; then
+   if test x$rtcore_type = xcobalt; then
+   AC_DEFINE(CONFIG_XENO_LAZY_SETSCHED,1,[config])
+   else
+AC_MSG_WARN([No lazy scheduling parameter updates over Mercury - 
ignoring])
+   fi
+fi
+
 dnl Enable shared multi-processing (default: off)
 
 use_pshared=
diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
index 3241e9b..cccbbf1 100644
--- a/lib/cobalt/internal.h
+++ b/lib/cobalt/internal.h
@@ -37,6 +37,18 @@ static inline int cobalt_should_warn(void)
return (cobalt_get_current_mode() & (XNRELAX|XNWARN)) == XNWARN;
 }
 
+#ifdef CONFIG_XENO_LAZY_SETSCHED
+static inline int cobalt_eager_setsched(void)
+{
+   return cobalt_is_relaxed();
+}
+#else
+static inline int cobalt_eager_setsched(void)
+{
+   return 1;
+}
+#endif
+
 static inline
 struct cobalt_mutex_state *mutex_get_state(struct cobalt_mutex_shadow *shadow)
 {
diff --git a/lib/cobalt/sched.c b/lib/cobalt/sched.c
index 87b9235..94f3323 100644
--- a/lib/cobalt/sched.c
+++ b/lib/cobalt/sched.c
@@ -297,7 +297,7 @@ int sched_setscheduler_ex(pid_t pid,
 
/* See pthread_setschedparam_ex(). */
 
-   if (cobalt_is_relaxed()) {
+   if (cobalt_eager_setsched()) {
std_policy = cobalt_xlate_schedparam(policy, param_ex, 
_param);
ret = __STD(sched_setscheduler(pid, std_policy, _param));
if (ret)
diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index 8b4568d..908516f 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -629,7 +629,8 @@ int pthread_setschedparam_ex(pthread_t thread,
 * threads should refrain from mixing APIs for managing
 * scheduling parameters, and only rely on libcobalt for this.
 */
-   if (cobalt_is_relaxed()) { /* True if shadow not mapped yet. */
+   if (cobalt_eager_setsched()) {
+   /* True if disabled or shadow not mapped yet. */
std_policy = cobalt_xlate_schedparam(policy, param_ex, 
_param);
ret = __STD(pthread_setschedparam(thread, std_policy, 
_param));
if (ret)


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


[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: fix error check [SIGSEGV]

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

Author: Jorge Ramirez-Ortiz 
Date:   Wed Oct  5 21:34:27 2016 +0200

utils/analogy: fix error check [SIGSEGV]

---

 utils/analogy/cmd_read.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/utils/analogy/cmd_read.c b/utils/analogy/cmd_read.c
index a507801..86522f4 100644
--- a/utils/analogy/cmd_read.c
+++ b/utils/analogy/cmd_read.c
@@ -261,12 +261,12 @@ static int map_subdevice_buffer(a4l_desc_t *dsc, unsigned 
long *buf_size, void *
 
 static int cmd_read(struct arguments *arg)
 {
-   unsigned int i, scan_size = 0, cnt = 0, ret = 0, len, ofs;
+   unsigned int i, scan_size = 0, cnt = 0, len, ofs;
dump_function_t dump_function = dump_text;
a4l_desc_t dsc = { .sbdata = NULL };
unsigned long buf_size;
char **argv = arg->argv;
-   int argc = arg->argc;
+   int ret = 0, argc = arg->argc;
void *map = NULL;
 
for (;;) {


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


[Xenomai-git] Philippe Gerum : net/drivers/e1000: work around UMR issue

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

Author: Philippe Gerum 
Date:   Sun Aug  7 11:29:06 2016 +0200

net/drivers/e1000: work around UMR issue

---

 kernel/drivers/net/drivers/e1000/e1000_hw.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/drivers/net/drivers/e1000/e1000_hw.c 
b/kernel/drivers/net/drivers/e1000/e1000_hw.c
index 311d48d..d974653 100644
--- a/kernel/drivers/net/drivers/e1000/e1000_hw.c
+++ b/kernel/drivers/net/drivers/e1000/e1000_hw.c
@@ -8804,7 +8804,7 @@ e1000_verify_write_ich8_byte(struct e1000_hw *hw, 
uint32_t index, uint8_t byte)
 {
 int32_t error = E1000_SUCCESS;
 int32_t program_retries;
-uint8_t temp_byte;
+uint8_t temp_byte = 0;
 
 e1000_write_ich8_byte(hw, index, byte);
 usec_delay(100);


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


<    2   3   4   5   6   7   8   9   10   11   >