ARM: bL_switcher: Add query interface to discover CPU affinities
authorDave Martin <dave.martin@linaro.org>
Wed, 13 Feb 2013 16:20:44 +0000 (16:20 +0000)
committerNicolas Pitre <nicolas.pitre@linaro.org>
Thu, 20 Jun 2013 04:45:30 +0000 (00:45 -0400)
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>
Signed-off-by: Nicolas Pitre <nico@linaro.org>
arch/arm/common/bL_switcher.c
arch/arm/include/asm/bL_switcher.h

index 38c852627c349e2151d93af7b30d5fdfe7328569..1883c5b3e3f55e0b3c529b56c4dac18b1856b9d3 100644 (file)
@@ -571,6 +571,26 @@ 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;
+
+       if (!bL_switcher_active)
+               return -EUNATCH;
+
+       mpidr &= MPIDR_HWID_BITMASK;
+       for_each_online_cpu(cpu) {
+               int pairing = bL_switcher_cpu_pairing[cpu];
+               if (pairing == -1)
+                       continue;
+               if ((mpidr == cpu_logical_map(cpu)) ||
+                   (mpidr == cpu_logical_map(pairing)))
+                       return cpu;
+       }
+       return -EINVAL;
+}
+
 static void bL_switcher_trace_trigger_cpu(void *__always_unused info)
 {
        trace_cpu_migrate_current(get_ns(), read_mpidr());
index 31df916c40a246f1c8ccba05513f0526e7eb49c4..482383b45c919eaf4e934ba44197ff5129bd498d 100644 (file)
@@ -58,6 +58,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 void bL_switch_request_detach(unsigned int cpu,
@@ -76,6 +77,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