[Patch is now also available in 'for-upstream']

ipipe_test_pipeline_from is not atomic /wrt reading the current cpu
number (or an offset for the per-cpu area) and actually reading the
virtualized interrupt state. Work around this by disabling hard IRQs
while accessing this service.

This fixes false-positives of RTDM driver debug checks.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>
---
 include/asm-generic/hal.h |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/include/asm-generic/hal.h b/include/asm-generic/hal.h
index 97c549e..3095b85 100644
--- a/include/asm-generic/hal.h
+++ b/include/asm-generic/hal.h
@@ -117,7 +117,14 @@ 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_local_irq_disabled()                             \
+({                                                             \
+       unsigned long __flags, __ret;                           \
+       local_irq_save_hw(__flags);                             \
+       __ret = ipipe_test_pipeline_from(&rthal_domain);        \
+       local_irq_restore_hw(__flags);                          \
+       __ret;                                                  \
+})
 #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)
-- 
1.6.0.2

Attachment: signature.asc
Description: OpenPGP digital signature

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

Reply via email to