mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-23 03:34:46 +07:00
787047eea2
Writes to /sys/.../cpuX/online fail if we determine the platform doesn't support hotplug for that CPU. Furthermore, if the cpu_die op isn't specified the system hangs when we try to offline a CPU and it comes right back online unexpectedly. Let's figure this stuff out before we make the sysfs nodes so that the online file doesn't even exist if it isn't (at least sometimes) possible to hotplug the CPU. Add a new 'cpu_can_disable' op and repoint all 'cpu_disable' implementations at it because all implementers use the op to indicate if a CPU can be hotplugged or not in a static fashion. With PSCI we may need to add a 'cpu_disable' op so that the secure OS can be migrated off the CPU we're trying to hotplug. In this case, the 'cpu_can_disable' op will indicate that all CPUs are hotpluggable by returning true, but the 'cpu_disable' op will make a PSCI migration call and occasionally fail, denying the hotplug of a CPU. This shouldn't be any worse than x86 where we may indicate that all CPUs are hotpluggable but occasionally we can't offline a CPU due to check_irq_vectors_for_cpu_disable() failing to find a CPU to move vectors to. Cc: Mark Rutland <mark.rutland@arm.com> Cc: Nicolas Pitre <nico@linaro.org> Cc: Dave Martin <Dave.Martin@arm.com> Acked-by: Simon Horman <horms@verge.net.au> [shmobile portion] Tested-by: Simon Horman <horms@verge.net.au> Cc: Magnus Damm <magnus.damm@gmail.com> Cc: <linux-sh@vger.kernel.org> Tested-by: Tyler Baker <tyler.baker@linaro.org> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
120 lines
2.4 KiB
C
120 lines
2.4 KiB
C
/*
|
|
* ARM specific SMP header, this contains our implementation
|
|
* details.
|
|
*/
|
|
#ifndef __ASMARM_SMP_PLAT_H
|
|
#define __ASMARM_SMP_PLAT_H
|
|
|
|
#include <linux/cpumask.h>
|
|
#include <linux/err.h>
|
|
|
|
#include <asm/cpu.h>
|
|
#include <asm/cputype.h>
|
|
|
|
/*
|
|
* Return true if we are running on a SMP platform
|
|
*/
|
|
static inline bool is_smp(void)
|
|
{
|
|
#ifndef CONFIG_SMP
|
|
return false;
|
|
#elif defined(CONFIG_SMP_ON_UP)
|
|
extern unsigned int smp_on_up;
|
|
return !!smp_on_up;
|
|
#else
|
|
return true;
|
|
#endif
|
|
}
|
|
|
|
/**
|
|
* smp_cpuid_part() - return part id for a given cpu
|
|
* @cpu: logical cpu id.
|
|
*
|
|
* Return: part id of logical cpu passed as argument.
|
|
*/
|
|
static inline unsigned int smp_cpuid_part(int cpu)
|
|
{
|
|
struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpu);
|
|
|
|
return is_smp() ? cpu_info->cpuid & ARM_CPU_PART_MASK :
|
|
read_cpuid_part();
|
|
}
|
|
|
|
/* all SMP configurations have the extended CPUID registers */
|
|
#ifndef CONFIG_MMU
|
|
#define tlb_ops_need_broadcast() 0
|
|
#else
|
|
static inline int tlb_ops_need_broadcast(void)
|
|
{
|
|
if (!is_smp())
|
|
return 0;
|
|
|
|
return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2;
|
|
}
|
|
#endif
|
|
|
|
#if !defined(CONFIG_SMP) || __LINUX_ARM_ARCH__ >= 7
|
|
#define cache_ops_need_broadcast() 0
|
|
#else
|
|
static inline int cache_ops_need_broadcast(void)
|
|
{
|
|
if (!is_smp())
|
|
return 0;
|
|
|
|
return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 1;
|
|
}
|
|
#endif
|
|
|
|
/*
|
|
* Logical CPU mapping.
|
|
*/
|
|
extern u32 __cpu_logical_map[];
|
|
#define cpu_logical_map(cpu) __cpu_logical_map[cpu]
|
|
/*
|
|
* Retrieve logical cpu index corresponding to a given MPIDR[23:0]
|
|
* - mpidr: MPIDR[23:0] to be used for the look-up
|
|
*
|
|
* Returns the cpu logical index or -EINVAL on look-up error
|
|
*/
|
|
static inline int get_logical_index(u32 mpidr)
|
|
{
|
|
int cpu;
|
|
for (cpu = 0; cpu < nr_cpu_ids; cpu++)
|
|
if (cpu_logical_map(cpu) == mpidr)
|
|
return cpu;
|
|
return -EINVAL;
|
|
}
|
|
|
|
/*
|
|
* NOTE ! Assembly code relies on the following
|
|
* structure memory layout in order to carry out load
|
|
* multiple from its base address. For more
|
|
* information check arch/arm/kernel/sleep.S
|
|
*/
|
|
struct mpidr_hash {
|
|
u32 mask; /* used by sleep.S */
|
|
u32 shift_aff[3]; /* used by sleep.S */
|
|
u32 bits;
|
|
};
|
|
|
|
extern struct mpidr_hash mpidr_hash;
|
|
|
|
static inline u32 mpidr_hash_size(void)
|
|
{
|
|
return 1 << mpidr_hash.bits;
|
|
}
|
|
|
|
extern int platform_can_secondary_boot(void);
|
|
extern int platform_can_cpu_hotplug(void);
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
extern int platform_can_hotplug_cpu(unsigned int cpu);
|
|
#else
|
|
static inline int platform_can_hotplug_cpu(unsigned int cpu)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#endif
|