Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Dave Martin and committed by
Nicolas Pitre
d08e2e09 29064b88

+22
+20
arch/arm/common/bL_switcher.c
··· 532 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 555 static void bL_switcher_trace_trigger_cpu(void *__always_unused info) 536 556 { 537 557 trace_cpu_migrate_current(get_ns(), read_mpidr());
+2
arch/arm/include/asm/bL_switcher.h
··· 55 55 void bL_switcher_put_enabled(void); 56 56 57 57 int bL_switcher_trace_trigger(void); 58 + int bL_switcher_get_logical_index(u32 mpidr); 58 59 59 60 #else 60 61 static inline int bL_switcher_register_notifier(struct notifier_block *nb) ··· 71 70 static inline bool bL_switcher_get_enabled(void) { return false; } 72 71 static inline void bL_switcher_put_enabled(void) { } 73 72 static inline int bL_switcher_trace_trigger(void) { return 0; } 73 + static inline int bL_switcher_get_logical_index(u32 mpidr) { return -EUNATCH; } 74 74 #endif /* CONFIG_BL_SWITCHER */ 75 75 76 76 #endif