aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Martin <dave.martin@linaro.org>2013-02-13 16:20:44 +0000
committerAndrey Konovalov <andrey.konovalov@linaro.org>2013-05-25 13:05:28 +0400
commitaaf4b25f6cc82715096b0328fc42c466eb44960f (patch)
tree08129d581fde36152d30f808cbc1d051d9ba4cf3
parent0a6da5300c989d978190637506a3a064d3a52492 (diff)
downloadvexpress-lsk-aaf4b25f6cc82715096b0328fc42c466eb44960f.tar.gz
ARM: bL_switcher: Add query interface to discover CPU affinities
When the switcher is active, there is no straightforward way to figure out which logical CPU a given physical CPU maps to. This patch provides a function bL_switcher_get_logical_index(mpidr), which is analogous to get_logical_index(). This function returns the logical CPU on which the specified physical CPU is grouped (or -EINVAL if unknown). If the switcher is inactive or not present, -EUNATCH is returned instead. Signed-off-by: Dave Martin <dave.martin@linaro.org>
-rw-r--r--arch/arm/common/bL_switcher.c14
-rw-r--r--arch/arm/include/asm/bL_switcher.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/arch/arm/common/bL_switcher.c b/arch/arm/common/bL_switcher.c
index 1506bf536d1..e6b1157742f 100644
--- a/arch/arm/common/bL_switcher.c
+++ b/arch/arm/common/bL_switcher.c
@@ -459,6 +459,20 @@ static int bL_switcher_halve_cpus(void)
return 0;
}
+/* Determine the logical CPU a given physical CPU is grouped on. */
+int bL_switcher_get_logical_index(u32 mpidr)
+{
+ int cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
+
+ if (!bL_switcher_active)
+ return -EUNATCH;
+
+ if (cpumask_test_cpu(cpu, &bL_switcher_removed_logical_cpus))
+ return -EINVAL;
+
+ return cpu;
+}
+
static void bL_switcher_trace_trigger_cpu(void *__always_unused info)
{
trace_cpu_migrate_current(get_ns(), read_mpidr() & MPIDR_HWID_BITMASK);
diff --git a/arch/arm/include/asm/bL_switcher.h b/arch/arm/include/asm/bL_switcher.h
index d60e77d179a..ebf8d9872a6 100644
--- a/arch/arm/include/asm/bL_switcher.h
+++ b/arch/arm/include/asm/bL_switcher.h
@@ -47,6 +47,7 @@ bool bL_switcher_get_enabled(void);
void bL_switcher_put_enabled(void);
int bL_switcher_trace_trigger(void);
+int bL_switcher_get_logical_index(u32 mpidr);
#else
static inline int bL_switcher_register_notifier(struct notifier_block *nb)
@@ -62,6 +63,7 @@ static inline int bL_switcher_unregister_notifier(struct notifier_block *nb)
static inline bool bL_switcher_get_enabled(void) { return false; }
static inline void bL_switcher_put_enabled(void) { }
static inline int bL_switcher_trace_trigger(void) { return 0; }
+static inline int bL_switcher_get_logical_index(u32 mpidr) { return -EUNATCH; }
#endif /* CONFIG_BL_SWITCHER */
#endif