Skip to content

Commit

Permalink
ARC: setup cpu possible mask according to possible-cpus dts property
Browse files Browse the repository at this point in the history
As we have option in u-boot to set CPU mask for running linux,
we want to pass information to kernel about CPU cores should
be brought up. So we patch kernel dtb in u-boot to set
possible-cpus property.

This also allows us to have correctly setuped MCIP debug mask.

Signed-off-by: Eugeniy Paltsev <[email protected]>
Signed-off-by: Vineet Gupta <[email protected]>
  • Loading branch information
Eugeniy Paltsev authored and vineetgarc committed Feb 28, 2018
1 parent f3205de commit a29a252
Showing 1 changed file with 40 additions and 10 deletions.
50 changes: 40 additions & 10 deletions arch/arc/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/reboot.h>
#include <linux/irqdomain.h>
#include <linux/export.h>
#include <linux/of_fdt.h>

#include <asm/processor.h>
#include <asm/setup.h>
Expand All @@ -47,6 +48,42 @@ void __init smp_prepare_boot_cpu(void)
{
}

static int __init arc_get_cpu_map(const char *name, struct cpumask *cpumask)
{
unsigned long dt_root = of_get_flat_dt_root();
const char *buf;

buf = of_get_flat_dt_prop(dt_root, name, NULL);
if (!buf)
return -EINVAL;

if (cpulist_parse(buf, cpumask))
return -EINVAL;

return 0;
}

/*
* Read from DeviceTree and setup cpu possible mask. If there is no
* "possible-cpus" property in DeviceTree pretend all [0..NR_CPUS-1] exist.
*/
static void __init arc_init_cpu_possible(void)
{
struct cpumask cpumask;

if (arc_get_cpu_map("possible-cpus", &cpumask)) {
pr_warn("Failed to get possible-cpus from dtb, pretending all %u cpus exist\n",
NR_CPUS);

cpumask_setall(&cpumask);
}

if (!cpumask_test_cpu(0, &cpumask))
panic("Master cpu (cpu[0]) is missed in cpu possible mask!");

init_cpu_possible(&cpumask);
}

/*
* Called from setup_arch() before calling setup_processor()
*
Expand All @@ -58,10 +95,7 @@ void __init smp_prepare_boot_cpu(void)
*/
void __init smp_init_cpus(void)
{
unsigned int i;

for (i = 0; i < NR_CPUS; i++)
set_cpu_possible(i, true);
arc_init_cpu_possible();

if (plat_smp_ops.init_early_smp)
plat_smp_ops.init_early_smp();
Expand All @@ -70,16 +104,12 @@ void __init smp_init_cpus(void)
/* called from init ( ) => process 1 */
void __init smp_prepare_cpus(unsigned int max_cpus)
{
int i;

/*
* if platform didn't set the present map already, do it now
* boot cpu is set to present already by init/main.c
*/
if (num_present_cpus() <= 1) {
for (i = 0; i < max_cpus; i++)
set_cpu_present(i, true);
}
if (num_present_cpus() <= 1)
init_cpu_present(cpu_possible_mask);
}

void __init smp_cpus_done(unsigned int max_cpus)
Expand Down

0 comments on commit a29a252

Please sign in to comment.