diff options
author | Dave Martin <dave.martin@linaro.org> | 2013-02-13 11:20:44 -0500 |
---|---|---|
committer | Nicolas Pitre <nicolas.pitre@linaro.org> | 2013-09-23 18:47:31 -0400 |
commit | d08e2e09042bd3f7ef66a35cb4bb92794ab26bb2 (patch) | |
tree | e34b0ae05a946887e11432db8f09d0110c9d6077 /arch/arm/common/bL_switcher.c | |
parent | 29064b88466ee725613db16d8c05b0ec5443a309 (diff) |
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>
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Diffstat (limited to 'arch/arm/common/bL_switcher.c')
-rw-r--r-- | arch/arm/common/bL_switcher.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/arch/arm/common/bL_switcher.c b/arch/arm/common/bL_switcher.c index f4878a36047a..63bbc4f70564 100644 --- a/arch/arm/common/bL_switcher.c +++ b/arch/arm/common/bL_switcher.c | |||
@@ -532,6 +532,26 @@ static int bL_switcher_halve_cpus(void) | |||
532 | return 0; | 532 | return 0; |
533 | } | 533 | } |
534 | 534 | ||
535 | /* Determine the logical CPU a given physical CPU is grouped on. */ | ||
536 | int bL_switcher_get_logical_index(u32 mpidr) | ||
537 | { | ||
538 | int cpu; | ||
539 | |||
540 | if (!bL_switcher_active) | ||
541 | return -EUNATCH; | ||
542 | |||
543 | mpidr &= MPIDR_HWID_BITMASK; | ||
544 | for_each_online_cpu(cpu) { | ||
545 | int pairing = bL_switcher_cpu_pairing[cpu]; | ||
546 | if (pairing == -1) | ||
547 | continue; | ||
548 | if ((mpidr == cpu_logical_map(cpu)) || | ||
549 | (mpidr == cpu_logical_map(pairing))) | ||
550 | return cpu; | ||
551 | } | ||
552 | return -EINVAL; | ||
553 | } | ||
554 | |||
535 | static void bL_switcher_trace_trigger_cpu(void *__always_unused info) | 555 | static void bL_switcher_trace_trigger_cpu(void *__always_unused info) |
536 | { | 556 | { |
537 | trace_cpu_migrate_current(get_ns(), read_mpidr()); | 557 | trace_cpu_migrate_current(get_ns(), read_mpidr()); |