mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-13 03:06:54 +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>
100 lines
2.3 KiB
C
100 lines
2.3 KiB
C
/*
|
|
* linux/arch/arm/mach-vexpress/mcpm_platsmp.c
|
|
*
|
|
* Created by: Nicolas Pitre, November 2012
|
|
* Copyright: (C) 2012-2013 Linaro Limited
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* Code to handle secondary CPU bringup and hotplug for the cluster power API.
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <asm/mcpm.h>
|
|
#include <asm/smp.h>
|
|
#include <asm/smp_plat.h>
|
|
|
|
static void cpu_to_pcpu(unsigned int cpu,
|
|
unsigned int *pcpu, unsigned int *pcluster)
|
|
{
|
|
unsigned int mpidr;
|
|
|
|
mpidr = cpu_logical_map(cpu);
|
|
*pcpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
|
|
*pcluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
|
|
}
|
|
|
|
static int mcpm_boot_secondary(unsigned int cpu, struct task_struct *idle)
|
|
{
|
|
unsigned int pcpu, pcluster, ret;
|
|
extern void secondary_startup(void);
|
|
|
|
cpu_to_pcpu(cpu, &pcpu, &pcluster);
|
|
|
|
pr_debug("%s: logical CPU %d is physical CPU %d cluster %d\n",
|
|
__func__, cpu, pcpu, pcluster);
|
|
|
|
mcpm_set_entry_vector(pcpu, pcluster, NULL);
|
|
ret = mcpm_cpu_power_up(pcpu, pcluster);
|
|
if (ret)
|
|
return ret;
|
|
mcpm_set_entry_vector(pcpu, pcluster, secondary_startup);
|
|
arch_send_wakeup_ipi_mask(cpumask_of(cpu));
|
|
dsb_sev();
|
|
return 0;
|
|
}
|
|
|
|
static void mcpm_secondary_init(unsigned int cpu)
|
|
{
|
|
mcpm_cpu_powered_up();
|
|
}
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
|
|
static int mcpm_cpu_kill(unsigned int cpu)
|
|
{
|
|
unsigned int pcpu, pcluster;
|
|
|
|
cpu_to_pcpu(cpu, &pcpu, &pcluster);
|
|
|
|
return !mcpm_wait_for_cpu_powerdown(pcpu, pcluster);
|
|
}
|
|
|
|
static bool mcpm_cpu_can_disable(unsigned int cpu)
|
|
{
|
|
/* We assume all CPUs may be shut down. */
|
|
return true;
|
|
}
|
|
|
|
static void mcpm_cpu_die(unsigned int cpu)
|
|
{
|
|
unsigned int mpidr, pcpu, pcluster;
|
|
mpidr = read_cpuid_mpidr();
|
|
pcpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
|
|
pcluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
|
|
mcpm_set_entry_vector(pcpu, pcluster, NULL);
|
|
mcpm_cpu_power_down();
|
|
}
|
|
|
|
#endif
|
|
|
|
static struct smp_operations __initdata mcpm_smp_ops = {
|
|
.smp_boot_secondary = mcpm_boot_secondary,
|
|
.smp_secondary_init = mcpm_secondary_init,
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
.cpu_kill = mcpm_cpu_kill,
|
|
.cpu_can_disable = mcpm_cpu_can_disable,
|
|
.cpu_die = mcpm_cpu_die,
|
|
#endif
|
|
};
|
|
|
|
void __init mcpm_smp_set_ops(void)
|
|
{
|
|
smp_set_ops(&mcpm_smp_ops);
|
|
}
|