mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-17 21:37:35 +07:00
819a88263d
ARM64 CPU operations such as cpu_init and cpu_init_idle take a struct device_node pointer as a parameter, which corresponds to the device tree node of the logical cpu on which the operation has to be applied. With the advent of ACPI on arm64, where MADT static table entries are used to initialize cpus, the device tree node parameter in cpu_ops hooks become useless when booting with ACPI, since in that case cpu device tree nodes are not present and can not be used for cpu initialization. The current cpu_init hook requires a struct device_node pointer parameter because it is called while parsing the device tree to initialize CPUs, when the cpu_logical_map (that is used to match a cpu node reg property to a device tree node) for a given logical cpu id is not set up yet. This means that the cpu_init hook cannot rely on the of_get_cpu_node function to retrieve the device tree node corresponding to the logical cpu id passed in as parameter, so the cpu device tree node must be passed in as a parameter to fix this catch-22 dependency cycle. This patch reshuffles the cpu_logical_map initialization code so that the cpu_init cpu_ops hook can safely use the of_get_cpu_node function to retrieve the cpu device tree node, removing the need for the device tree node pointer parameter. In the process, the patch removes device tree node parameters from all cpu_ops hooks, in preparation for SMP DT/ACPI cpus initialization consolidation. Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Acked-by: Hanjun Guo <hanjun.guo@linaro.org> Acked-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Tested-by: Hanjun Guo <hanjun.guo@linaro.org> Tested-by: Mark Rutland <mark.rutland@arm.com> [DT] Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
134 lines
3.3 KiB
C
134 lines
3.3 KiB
C
/*
|
|
* Spin Table SMP initialisation
|
|
*
|
|
* Copyright (C) 2013 ARM Ltd.
|
|
*
|
|
* 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.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <linux/delay.h>
|
|
#include <linux/init.h>
|
|
#include <linux/of.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/types.h>
|
|
|
|
#include <asm/cacheflush.h>
|
|
#include <asm/cpu_ops.h>
|
|
#include <asm/cputype.h>
|
|
#include <asm/io.h>
|
|
#include <asm/smp_plat.h>
|
|
|
|
extern void secondary_holding_pen(void);
|
|
volatile unsigned long secondary_holding_pen_release = INVALID_HWID;
|
|
|
|
static phys_addr_t cpu_release_addr[NR_CPUS];
|
|
|
|
/*
|
|
* Write secondary_holding_pen_release in a way that is guaranteed to be
|
|
* visible to all observers, irrespective of whether they're taking part
|
|
* in coherency or not. This is necessary for the hotplug code to work
|
|
* reliably.
|
|
*/
|
|
static void write_pen_release(u64 val)
|
|
{
|
|
void *start = (void *)&secondary_holding_pen_release;
|
|
unsigned long size = sizeof(secondary_holding_pen_release);
|
|
|
|
secondary_holding_pen_release = val;
|
|
__flush_dcache_area(start, size);
|
|
}
|
|
|
|
|
|
static int smp_spin_table_cpu_init(unsigned int cpu)
|
|
{
|
|
struct device_node *dn;
|
|
|
|
dn = of_get_cpu_node(cpu, NULL);
|
|
if (!dn)
|
|
return -ENODEV;
|
|
|
|
/*
|
|
* Determine the address from which the CPU is polling.
|
|
*/
|
|
if (of_property_read_u64(dn, "cpu-release-addr",
|
|
&cpu_release_addr[cpu])) {
|
|
pr_err("CPU %d: missing or invalid cpu-release-addr property\n",
|
|
cpu);
|
|
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int smp_spin_table_cpu_prepare(unsigned int cpu)
|
|
{
|
|
__le64 __iomem *release_addr;
|
|
|
|
if (!cpu_release_addr[cpu])
|
|
return -ENODEV;
|
|
|
|
/*
|
|
* The cpu-release-addr may or may not be inside the linear mapping.
|
|
* As ioremap_cache will either give us a new mapping or reuse the
|
|
* existing linear mapping, we can use it to cover both cases. In
|
|
* either case the memory will be MT_NORMAL.
|
|
*/
|
|
release_addr = ioremap_cache(cpu_release_addr[cpu],
|
|
sizeof(*release_addr));
|
|
if (!release_addr)
|
|
return -ENOMEM;
|
|
|
|
/*
|
|
* We write the release address as LE regardless of the native
|
|
* endianess of the kernel. Therefore, any boot-loaders that
|
|
* read this address need to convert this address to the
|
|
* boot-loader's endianess before jumping. This is mandated by
|
|
* the boot protocol.
|
|
*/
|
|
writeq_relaxed(__pa(secondary_holding_pen), release_addr);
|
|
__flush_dcache_area((__force void *)release_addr,
|
|
sizeof(*release_addr));
|
|
|
|
/*
|
|
* Send an event to wake up the secondary CPU.
|
|
*/
|
|
sev();
|
|
|
|
iounmap(release_addr);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int smp_spin_table_cpu_boot(unsigned int cpu)
|
|
{
|
|
/*
|
|
* Update the pen release flag.
|
|
*/
|
|
write_pen_release(cpu_logical_map(cpu));
|
|
|
|
/*
|
|
* Send an event, causing the secondaries to read pen_release.
|
|
*/
|
|
sev();
|
|
|
|
return 0;
|
|
}
|
|
|
|
const struct cpu_operations smp_spin_table_ops = {
|
|
.name = "spin-table",
|
|
.cpu_init = smp_spin_table_cpu_init,
|
|
.cpu_prepare = smp_spin_table_cpu_prepare,
|
|
.cpu_boot = smp_spin_table_cpu_boot,
|
|
};
|