Skip to contentSkip to conversation

Pull request: Build fix and RTDM improvements

PATCH New Jan Kiszka 1 participant 5 messages Jun 3, 2009 Generic include/asm header files

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

v2 cover Pull request: Build fix and RTDM improvements

Please pull from

git://xenomai.org/xenomai-jki.git for-upstream

In v2, I added a rthal_local_irq_disabled wrapper and fixed the inverted test in rtdm_lock_get.

Jan Kiszka (4):
nucleus: Add missing header for isspace
hal: Add rthal_local_irq_disabled wrapper
RTDM: Instrument rtdm_lock_get for proper use
RTDM: Avoid namespace pollution in RTDM_EXECUTE_ATOMICALLY

 include/asm-generic/hal.h  |    1 +
 include/rtdm/rtdm_driver.h |   22 +++++++++++++++-------
 ksrc/nucleus/intr.c        |    1 +
 ksrc/skins/rtdm/core.c     |   15 ++++++++++-----
 4 files changed, 27 insertions(+), 12 deletions(-)

--
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux

author
#1 lore raw

PATCH v2 1/4 nucleus: Add missing header for isspace

---

 ksrc/nucleus/intr.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
ksrc/nucleus/intr.c +1 -0
index 81db8bc..97458f5 100644
@@ -973,6 +973,7 @@ int xnintr_query_next(int irq, xnintr_iterator_t *iterator, char *name_buf)
 #ifdef CONFIG_PROC_FS
 
 #include <linux/proc_fs.h>
+#include <linux/ctype.h>
 
 static int format_irq_proc(unsigned int irq, char *str)
 {
author
#2 lore raw

PATCH v2 2/4 hal: Add rthal_local_irq_disabled wrapper

In reply to Jan Kiszka

Add a more handy wrapper to test for the (virtual) IRQ mask of the real-time domain and convert RTDM users to it.

---

 include/asm-generic/hal.h |    1 +
 ksrc/skins/rtdm/core.c    |   15 ++++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)
include/asm-generic/hal.h +1 -0
index e4fdea9..244ca02 100644
@@ -116,6 +116,7 @@ typedef spinlock_t rthal_spinlock_t;
 #endif /* !CONFIG_XENO_OPT_PIPELINE_HEAD */
 #define rthal_local_irq_flags(x)	((x) = ipipe_test_pipeline_from(&rthal_domain) & 1)
 #define rthal_local_irq_test()		ipipe_test_pipeline_from(&rthal_domain)
+#define rthal_local_irq_disabled()	ipipe_test_pipeline_from(&rthal_domain)
 #define rthal_stage_irq_enable(dom)	ipipe_unstall_pipeline_from(dom)
 #define rthal_local_irq_save_hw(x)	local_irq_save_hw(x)
 #define rthal_local_irq_restore_hw(x)	local_irq_restore_hw(x)
ksrc/skins/rtdm/core.c +10 -5
index 853b8af..5843842 100644
@@ -222,7 +222,8 @@ int __rt_dev_open(rtdm_user_info_t *user_info, const char *path, int oflag)
 		ret = device->open_rt(context, user_info, oflag);
 	}
 
-	XENO_ASSERT(RTDM, !rthal_local_irq_test(), rthal_local_irq_enable(););
+	XENO_ASSERT(RTDM, !rthal_local_irq_disabled(),
+		    rthal_local_irq_enable(););
 
 	if (unlikely(ret < 0))
 		goto cleanup_out;
@@ -274,7 +275,8 @@ int __rt_dev_socket(rtdm_user_info_t *user_info, int protocol_family,
 		ret = device->socket_rt(context, user_info, protocol);
 	}
 
-	XENO_ASSERT(RTDM, !rthal_local_irq_test(), rthal_local_irq_enable(););
+	XENO_ASSERT(RTDM, !rthal_local_irq_disabled(),
+		    rthal_local_irq_enable(););
 
 	if (unlikely(ret < 0))
 		goto cleanup_out;
@@ -336,7 +338,8 @@ again:
 		ret = context->ops->close_rt(context, user_info);
 	}
 
-	XENO_ASSERT(RTDM, !rthal_local_irq_test(), rthal_local_irq_enable(););
+	XENO_ASSERT(RTDM, !rthal_local_irq_disabled(),
+		    rthal_local_irq_enable(););
 
 	if (unlikely(ret == -EAGAIN) && nrt_mode) {
 		rtdm_context_unlock(context);
@@ -422,7 +425,8 @@ do {									\
 	else								\
 		ret = ops->operation##_nrt(context, user_info, args);	\
 									\
-	XENO_ASSERT(RTDM, !rthal_local_irq_test(), rthal_local_irq_enable();)
+	XENO_ASSERT(RTDM, !rthal_local_irq_disabled(),			\
+		    rthal_local_irq_enable();)
 
 #define MAJOR_FUNCTION_WRAPPER_BH()					\
 	rtdm_context_unlock(context);					\
@@ -564,7 +568,8 @@ int rtdm_select_bind(int fd, rtdm_selector_t *selector,
 
 	ret = ops->select_bind(context, selector, type, fd_index);
 
-	XENO_ASSERT(RTDM, !rthal_local_irq_test(), rthal_local_irq_enable(););
+	XENO_ASSERT(RTDM, !rthal_local_irq_disabled(),
+		    rthal_local_irq_enable(););
 
 	rtdm_context_unlock(context);
 
author
#3 lore raw

PATCH v2 3/4 RTDM: Instrument rtdm_lock_get for proper use

In reply to Jan Kiszka

In case the user thinks rtdm_lock_get could be used like spin_lock or messes up the IRQ protection for other reasons, catch this with a XENO_BUGON.

---

 include/rtdm/rtdm_driver.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
include/rtdm/rtdm_driver.h +8 -0
index 058a9f8..5fc8b57 100644
@@ -655,7 +655,15 @@ typedef unsigned long rtdm_lockctx_t;
  *
  * Rescheduling: never.
  */
+#ifdef DOXYGEN_CPP /* Beautify doxygen output */
 #define rtdm_lock_get(lock)	rthal_spin_lock(lock)
+#else /* This is how it really works */
+#define rtdm_lock_get(lock)					\
+	do {							\
+		XENO_BUGON(RTDM, !rthal_local_irq_disabled());	\
+		rthal_spin_lock(lock);				\
+	} while (0)
+#endif
 
 /**
  * Release lock without preemption restoration
author
#4 lore raw

PATCH v2 4/4 RTDM: Avoid namespace pollution in RTDM_EXECUTE_ATOMICALLY

In reply to Jan Kiszka

---

 include/rtdm/rtdm_driver.h |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
include/rtdm/rtdm_driver.h +7 -7
index 5fc8b57..7f1f3f8 100644
@@ -595,13 +595,13 @@ int rtdm_select_bind(int fd, rtdm_selector_t *selector,
 	<LEAVE_ATOMIC_SECTION>			\
 }
 #else /* This is how it really works */
-#define RTDM_EXECUTE_ATOMICALLY(code_block)	\
-{						\
-	spl_t s;				\
-						\
-	xnlock_get_irqsave(&nklock, s);		\
-	code_block;				\
-	xnlock_put_irqrestore(&nklock, s);	\
+#define RTDM_EXECUTE_ATOMICALLY(code_block)		\
+{							\
+	spl_t __rtdm_s;					\
+							\
+	xnlock_get_irqsave(&nklock, __rtdm_s);		\
+	code_block;					\
+	xnlock_put_irqrestore(&nklock, __rtdm_s);	\
 }
 #endif
 /** @} Global Lock across Scheduler Invocation */