diff mbox series

[API-NEXT,v2,2/2] linux-gen: more unification of arch-specific code

Message ID 1507143608-13625-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v2,1/2] linux-gen: update api-next to follow merged changes | expand

Commit Message

Github ODP bot Oct. 4, 2017, 7 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 211 (lumag:fix-api-next-merge)
 ** https://github.com/Linaro/odp/pull/211
 ** Patch: https://github.com/Linaro/odp/pull/211.patch
 ** Base sha: 75cfc6f70d5b21d6f04082e1d03a7e677a895280
 ** Merge commit sha: b5aebf54bd0f3e939b778b754975259df1c44de3
 **/
 platform/linux-generic/Makefile.am                 | 11 +++++--
 .../linux-generic/arch/aarch64/odp_cpu_idling.h    | 20 +++++-------
 platform/linux-generic/arch/arm/odp_cpu_idling.h   | 20 +++++-------
 platform/linux-generic/arch/default/odp_cpu.h      | 24 +--------------
 .../linux-generic/arch/default/odp_cpu_idling.h    | 36 ++++++++++++++++++++++
 5 files changed, 59 insertions(+), 52 deletions(-)
 create mode 100644 platform/linux-generic/arch/default/odp_cpu_idling.h
diff mbox series

Patch

diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index f830d69f2..054566817 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -278,6 +278,7 @@  arch_odp_headers = $(srcdir)/arch/arm/odp/api/cpu_arch.h
 noinst_HEADERS += ${srcdir}/arch/arm/odp_atomic.h \
 		  ${srcdir}/arch/arm/odp_cpu.h \
 		  ${srcdir}/arch/arm/odp_cpu_idling.h \
+		  ${srcdir}/arch/default/odp_cpu_idling.h \
 		  ${srcdir}/arch/arm/odp_llsc.h
 endif
 if ARCH_IS_AARCH64
@@ -289,6 +290,7 @@  arch_odp_headers = $(srcdir)/arch/aarch64/odp/api/cpu_arch.h
 noinst_HEADERS += ${srcdir}/arch/aarch64/odp_atomic.h \
 		  ${srcdir}/arch/aarch64/odp_cpu.h \
 		  ${srcdir}/arch/aarch64/odp_cpu_idling.h \
+		  ${srcdir}/arch/default/odp_cpu_idling.h \
 		  ${srcdir}/arch/aarch64/odp_llsc.h
 endif
 if ARCH_IS_MIPS64
@@ -297,7 +299,8 @@  __LIB__libodp_linux_la_SOURCES += arch/mips64/odp_cpu_arch.c \
 				  arch/default/odp_global_time.c \
 				  arch/mips64/odp_sysinfo_parse.c
 arch_odp_headers = $(srcdir)/arch/mips64/odp/api/cpu_arch.h
-noinst_HEADERS += ${srcdir}/arch/default/odp_cpu.h
+noinst_HEADERS += ${srcdir}/arch/default/odp_cpu.h \
+		  ${srcdir}/arch/default/odp_cpu_idling.h
 endif
 if ARCH_IS_POWERPC
 __LIB__libodp_linux_la_SOURCES += arch/default/odp_cpu_arch.c \
@@ -305,7 +308,8 @@  __LIB__libodp_linux_la_SOURCES += arch/default/odp_cpu_arch.c \
 				  arch/default/odp_global_time.c \
 				  arch/powerpc/odp_sysinfo_parse.c
 arch_odp_headers = $(srcdir)/arch/powerpc/odp/api/cpu_arch.h
-noinst_HEADERS += ${srcdir}/arch/default/odp_cpu.h
+noinst_HEADERS += ${srcdir}/arch/default/odp_cpu.h \
+		  ${srcdir}/arch/default/odp_cpu_idling.h
 endif
 if ARCH_IS_X86
 __LIB__libodp_linux_la_SOURCES += arch/x86/cpu_flags.c \
@@ -315,7 +319,8 @@  __LIB__libodp_linux_la_SOURCES += arch/x86/cpu_flags.c \
 				  arch/x86/odp_sysinfo_parse.c
 arch_odp_headers = $(srcdir)/arch/x86/odp/api/cpu_arch.h
 noinst_HEADERS += $(srcdir)/arch/x86/cpu_flags.h
-noinst_HEADERS += ${srcdir}/arch/default/odp_cpu.h
+noinst_HEADERS += ${srcdir}/arch/default/odp_cpu.h \
+		  ${srcdir}/arch/default/odp_cpu_idling.h
 endif
 
 noinst_HEADERS += $(srcdir)/arch/default/odp/api/cpu_arch.h
diff --git a/platform/linux-generic/arch/aarch64/odp_cpu_idling.h b/platform/linux-generic/arch/aarch64/odp_cpu_idling.h
index ab29455bb..e7dec7d9f 100644
--- a/platform/linux-generic/arch/aarch64/odp_cpu_idling.h
+++ b/platform/linux-generic/arch/aarch64/odp_cpu_idling.h
@@ -13,39 +13,33 @@ 
 #error This file should not be included directly, please include odp_cpu.h
 #endif
 
+#ifndef CONFIG_WFE
+
+#include "../default/odp_cpu_idling.h"
+
+#else /* CONFIG_WFE */
+
 static inline void sevl(void)
 {
-#ifdef CONFIG_WFE
 	__asm__ volatile("sevl" : : : );
-#endif
 }
 
 static inline int wfe(void)
 {
-#ifdef CONFIG_WFE
 	__asm__ volatile("wfe" : : : "memory");
-#endif
 	return 1;
 }
 
 static inline void doze(void)
 {
-#ifndef CONFIG_WFE
 	/* When using WFE do not stall the pipeline using other means */
 	odp_cpu_pause();
-#endif
 }
 
-#ifdef CONFIG_WFE
 #define monitor128(addr, mo) lld((addr), (mo))
 #define monitor64(addr, mo) ll64((addr), (mo))
 #define monitor32(addr, mo) ll32((addr), (mo))
 #define monitor8(addr, mo) ll8((addr), (mo))
-#else
-#define monitor128(addr, mo) __atomic_load_n((addr), (mo))
-#define monitor64(addr, mo) __atomic_load_n((addr), (mo))
-#define monitor32(addr, mo) __atomic_load_n((addr), (mo))
-#define monitor8(addr, mo) __atomic_load_n((addr), (mo))
-#endif
+#endif /* CONFIG_WFE */
 
 #endif  /* PLATFORM_LINUXGENERIC_ARCH_ARM_CPU_IDLING_H */
diff --git a/platform/linux-generic/arch/arm/odp_cpu_idling.h b/platform/linux-generic/arch/arm/odp_cpu_idling.h
index ab29455bb..e7dec7d9f 100644
--- a/platform/linux-generic/arch/arm/odp_cpu_idling.h
+++ b/platform/linux-generic/arch/arm/odp_cpu_idling.h
@@ -13,39 +13,33 @@ 
 #error This file should not be included directly, please include odp_cpu.h
 #endif
 
+#ifndef CONFIG_WFE
+
+#include "../default/odp_cpu_idling.h"
+
+#else /* CONFIG_WFE */
+
 static inline void sevl(void)
 {
-#ifdef CONFIG_WFE
 	__asm__ volatile("sevl" : : : );
-#endif
 }
 
 static inline int wfe(void)
 {
-#ifdef CONFIG_WFE
 	__asm__ volatile("wfe" : : : "memory");
-#endif
 	return 1;
 }
 
 static inline void doze(void)
 {
-#ifndef CONFIG_WFE
 	/* When using WFE do not stall the pipeline using other means */
 	odp_cpu_pause();
-#endif
 }
 
-#ifdef CONFIG_WFE
 #define monitor128(addr, mo) lld((addr), (mo))
 #define monitor64(addr, mo) ll64((addr), (mo))
 #define monitor32(addr, mo) ll32((addr), (mo))
 #define monitor8(addr, mo) ll8((addr), (mo))
-#else
-#define monitor128(addr, mo) __atomic_load_n((addr), (mo))
-#define monitor64(addr, mo) __atomic_load_n((addr), (mo))
-#define monitor32(addr, mo) __atomic_load_n((addr), (mo))
-#define monitor8(addr, mo) __atomic_load_n((addr), (mo))
-#endif
+#endif /* CONFIG_WFE */
 
 #endif  /* PLATFORM_LINUXGENERIC_ARCH_ARM_CPU_IDLING_H */
diff --git a/platform/linux-generic/arch/default/odp_cpu.h b/platform/linux-generic/arch/default/odp_cpu.h
index 12a44b93f..2df6f65c8 100644
--- a/platform/linux-generic/arch/default/odp_cpu.h
+++ b/platform/linux-generic/arch/default/odp_cpu.h
@@ -16,28 +16,6 @@ 
 #define atomic_store_release(loc, val, ro) \
 	__atomic_store_n(loc, val, __ATOMIC_RELEASE)
 
-/******************************************************************************
- * Idle mgmt
- *****************************************************************************/
-
-static inline void sevl(void)
-{
-	/* empty */
-}
-
-static inline int wfe(void)
-{
-	return 1;
-}
-
-#define monitor128(addr, mo) __atomic_load_n((addr), (mo))
-#define monitor64(addr, mo) __atomic_load_n((addr), (mo))
-#define monitor32(addr, mo) __atomic_load_n((addr), (mo))
-#define monitor8(addr, mo) __atomic_load_n((addr), (mo))
-
-static inline void doze(void)
-{
-	odp_cpu_pause();
-}
+#include "odp_cpu_idling.h"
 
 #endif
diff --git a/platform/linux-generic/arch/default/odp_cpu_idling.h b/platform/linux-generic/arch/default/odp_cpu_idling.h
new file mode 100644
index 000000000..db1eebd12
--- /dev/null
+++ b/platform/linux-generic/arch/default/odp_cpu_idling.h
@@ -0,0 +1,36 @@ 
+/* Copyright (c) 2017, ARM Limited. All rights reserved.
+ *
+ * Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODP_DEFAULT_CPU_IDLING_H_
+#define ODP_DEFAULT_CPU_IDLING_H_
+
+/******************************************************************************
+ * Idle mgmt
+ *****************************************************************************/
+
+static inline void sevl(void)
+{
+	/* empty */
+}
+
+static inline int wfe(void)
+{
+	return 1;
+}
+
+#define monitor128(addr, mo) __atomic_load_n((addr), (mo))
+#define monitor64(addr, mo) __atomic_load_n((addr), (mo))
+#define monitor32(addr, mo) __atomic_load_n((addr), (mo))
+#define monitor8(addr, mo) __atomic_load_n((addr), (mo))
+
+static inline void doze(void)
+{
+	odp_cpu_pause();
+}
+
+#endif