Blackfin/ipipe: prepare status bitops for SMP support
authorPhilippe Gerum <rpm@xenomai.org>
Tue, 27 Oct 2009 21:05:31 +0000 (22:05 +0100)
committerMike Frysinger <vapier@gentoo.org>
Tue, 15 Dec 2009 05:15:12 +0000 (00:15 -0500)
Signed-off-by: Philippe Gerum <rpm@xenomai.org>
Signed-off-by: Li Yi <yi.li@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
arch/blackfin/include/asm/ipipe.h
arch/blackfin/include/asm/ipipe_base.h
arch/blackfin/kernel/ipipe.c

index 4617ba66278ffadb2ceb1f3cb524eaaa804cbf49..07bd2e65ab5bd1604c4f0259ee1a27ca396d7b96 100644 (file)
@@ -124,16 +124,6 @@ static inline int __ipipe_check_tickdev(const char *devname)
        return 1;
 }
 
-static inline void __ipipe_lock_root(void)
-{
-       set_bit(IPIPE_SYNCDEFER_FLAG, &ipipe_root_cpudom_var(status));
-}
-
-static inline void __ipipe_unlock_root(void)
-{
-       clear_bit(IPIPE_SYNCDEFER_FLAG, &ipipe_root_cpudom_var(status));
-}
-
 void __ipipe_enable_pipeline(void);
 
 #define __ipipe_hook_critical_ipi(ipd) do { } while (0)
index 490098f532a75a4a55725f13dec848e76540be90..00409201d9edc7d69a225562caef7582e636d447 100644 (file)
 
 extern unsigned long __ipipe_root_status; /* Alias to ipipe_root_cpudom_var(status) */
 
-#define __ipipe_stall_root()                                           \
-       do {                                                            \
-               volatile unsigned long *p = &__ipipe_root_status;       \
-               set_bit(0, p);                                          \
-       } while (0)
-
-#define __ipipe_test_and_stall_root()                                  \
-       ({                                                              \
-               volatile unsigned long *p = &__ipipe_root_status;       \
-               test_and_set_bit(0, p);                                 \
-       })
-
-#define __ipipe_test_root()                                    \
-       ({                                                      \
-               const unsigned long *p = &__ipipe_root_status;  \
-               test_bit(0, p);                                 \
-       })
+void __ipipe_stall_root(void);
+
+unsigned long __ipipe_test_and_stall_root(void);
+
+unsigned long __ipipe_test_root(void);
+
+void __ipipe_lock_root(void);
+
+void __ipipe_unlock_root(void);
 
 #endif /* !__ASSEMBLY__ */
 
index 5d7382396dc02846d62b56506cb9088ae9ed66f6..a77307a4473b3f6ab5395ffb8f1a337982f99483 100644 (file)
@@ -335,3 +335,70 @@ void __ipipe_enable_root_irqs_hw(void)
        __clear_bit(IPIPE_STALL_FLAG, &ipipe_root_cpudom_var(status));
        bfin_sti(bfin_irq_flags);
 }
+
+/*
+ * We could use standard atomic bitops in the following root status
+ * manipulation routines, but let's prepare for SMP support in the
+ * same move, preventing CPU migration as required.
+ */
+void __ipipe_stall_root(void)
+{
+       unsigned long *p, flags;
+
+       local_irq_save_hw(flags);
+       p = &__ipipe_root_status;
+       __set_bit(IPIPE_STALL_FLAG, p);
+       local_irq_restore_hw(flags);
+}
+EXPORT_SYMBOL(__ipipe_stall_root);
+
+unsigned long __ipipe_test_and_stall_root(void)
+{
+       unsigned long *p, flags;
+       int x;
+
+       local_irq_save_hw(flags);
+       p = &__ipipe_root_status;
+       x = __test_and_set_bit(IPIPE_STALL_FLAG, p);
+       local_irq_restore_hw(flags);
+
+       return x;
+}
+EXPORT_SYMBOL(__ipipe_test_and_stall_root);
+
+unsigned long __ipipe_test_root(void)
+{
+       const unsigned long *p;
+       unsigned long flags;
+       int x;
+
+       local_irq_save_hw_smp(flags);
+       p = &__ipipe_root_status;
+       x = test_bit(IPIPE_STALL_FLAG, p);
+       local_irq_restore_hw_smp(flags);
+
+       return x;
+}
+EXPORT_SYMBOL(__ipipe_test_root);
+
+void __ipipe_lock_root(void)
+{
+       unsigned long *p, flags;
+
+       local_irq_save_hw(flags);
+       p = &__ipipe_root_status;
+       __set_bit(IPIPE_SYNCDEFER_FLAG, p);
+       local_irq_restore_hw(flags);
+}
+EXPORT_SYMBOL(__ipipe_lock_root);
+
+void __ipipe_unlock_root(void)
+{
+       unsigned long *p, flags;
+
+       local_irq_save_hw(flags);
+       p = &__ipipe_root_status;
+       __clear_bit(IPIPE_SYNCDEFER_FLAG, p);
+       local_irq_restore_hw(flags);
+}
+EXPORT_SYMBOL(__ipipe_unlock_root);