Module: xenomai-forge Branch: next Commit: e0ae0c1404b576e09a1fe24820d8b782787a2850 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=e0ae0c1404b576e09a1fe24820d8b782787a2850
Author: Philippe Gerum <[email protected]> Date: Thu May 29 16:38:14 2014 +0200 cobalt/lock: disable UP-over-SMP optimization in debug mode We want the lock state to be checked unconditionally when locking debug mode is on. --- include/cobalt/kernel/lock.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/include/cobalt/kernel/lock.h b/include/cobalt/kernel/lock.h index 25644f8..6ad4910 100644 --- a/include/cobalt/kernel/lock.h +++ b/include/cobalt/kernel/lock.h @@ -195,6 +195,13 @@ 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(XNLOCK) +/* Disable UP-over-SMP kernel optimization in debug mode. */ +#define __locking_active__ 1 +#else +#define __locking_active__ ipipe_smp_p +#endif + static inline spl_t __xnlock_get_irqsave(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS) { @@ -202,7 +209,7 @@ __xnlock_get_irqsave(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS) splhigh(flags); - if (ipipe_smp_p) + if (__locking_active__) flags |= ___xnlock_get(lock /*, */ XNLOCK_DBG_PASS_CONTEXT); return flags; @@ -212,7 +219,7 @@ static inline void __xnlock_put_irqrestore(struct xnlock *lock, spl_t flags /*, */ XNLOCK_DBG_CONTEXT_ARGS) { /* Only release the lock if we didn't take it recursively. */ - if (ipipe_smp_p && !(flags & 2)) + if (__locking_active__ && !(flags & 2)) ___xnlock_put(lock /*, */ XNLOCK_DBG_PASS_CONTEXT); splexit(flags & 1); @@ -220,14 +227,15 @@ static inline void __xnlock_put_irqrestore(struct xnlock *lock, spl_t flags static inline int xnlock_is_owner(struct xnlock *lock) { - if (ipipe_smp_p) + if (__locking_active__) return atomic_read(&lock->owner) == ipipe_processor_id(); - return hard_irqs_disabled(); + + return 1; } static inline int __xnlock_get(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS) { - if (ipipe_smp_p) + if (__locking_active__) return ___xnlock_get(lock /* , */ XNLOCK_DBG_PASS_CONTEXT); return 0; @@ -235,10 +243,12 @@ static inline int __xnlock_get(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARG static inline void __xnlock_put(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS) { - if (ipipe_smp_p) + if (__locking_active__) ___xnlock_put(lock /*, */ XNLOCK_DBG_PASS_CONTEXT); } +#undef __locking_active__ + #else /* !(CONFIG_SMP || XENO_DEBUG(XNLOCK) */ #define xnlock_init(lock) do { } while(0) _______________________________________________ Xenomai-git mailing list [email protected] http://www.xenomai.org/mailman/listinfo/xenomai-git
