Commit 954e6da5 authored by Nathan Fontenot's avatar Nathan Fontenot Committed by Benjamin Herrenschmidt

powerpc: Correct smt_enabled=X boot option for > 2 threads per core

The 'smt_enabled=X' boot option does not handle values of X > 2.
For Power 7 processors with smt modes of 0,1,2,3, and 4 this does
not work.  This patch allows the smt_enabled option to be set to
any value limited to a max equal to the number of threads per
core.
Signed-off-by: default avatarNathan Fontenot <nfont@austin.ibm.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 1afb56cf
...@@ -95,7 +95,7 @@ int ucache_bsize; ...@@ -95,7 +95,7 @@ int ucache_bsize;
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
static int smt_enabled_cmdline; static char *smt_enabled_cmdline;
/* Look for ibm,smt-enabled OF option */ /* Look for ibm,smt-enabled OF option */
static void check_smt_enabled(void) static void check_smt_enabled(void)
...@@ -103,37 +103,46 @@ static void check_smt_enabled(void) ...@@ -103,37 +103,46 @@ static void check_smt_enabled(void)
struct device_node *dn; struct device_node *dn;
const char *smt_option; const char *smt_option;
/* Allow the command line to overrule the OF option */ /* Default to enabling all threads */
if (smt_enabled_cmdline) smt_enabled_at_boot = threads_per_core;
return;
dn = of_find_node_by_path("/options");
if (dn) {
smt_option = of_get_property(dn, "ibm,smt-enabled", NULL);
if (smt_option) { /* Allow the command line to overrule the OF option */
if (!strcmp(smt_option, "on")) if (smt_enabled_cmdline) {
smt_enabled_at_boot = 1; if (!strcmp(smt_enabled_cmdline, "on"))
else if (!strcmp(smt_option, "off")) smt_enabled_at_boot = threads_per_core;
smt_enabled_at_boot = 0; else if (!strcmp(smt_enabled_cmdline, "off"))
} smt_enabled_at_boot = 0;
} else {
long smt;
int rc;
rc = strict_strtol(smt_enabled_cmdline, 10, &smt);
if (!rc)
smt_enabled_at_boot =
min(threads_per_core, (int)smt);
}
} else {
dn = of_find_node_by_path("/options");
if (dn) {
smt_option = of_get_property(dn, "ibm,smt-enabled",
NULL);
if (smt_option) {
if (!strcmp(smt_option, "on"))
smt_enabled_at_boot = threads_per_core;
else if (!strcmp(smt_option, "off"))
smt_enabled_at_boot = 0;
}
of_node_put(dn);
}
}
} }
/* Look for smt-enabled= cmdline option */ /* Look for smt-enabled= cmdline option */
static int __init early_smt_enabled(char *p) static int __init early_smt_enabled(char *p)
{ {
smt_enabled_cmdline = 1; smt_enabled_cmdline = p;
if (!p)
return 0;
if (!strcmp(p, "on") || !strcmp(p, "1"))
smt_enabled_at_boot = 1;
else if (!strcmp(p, "off") || !strcmp(p, "0"))
smt_enabled_at_boot = 0;
return 0; return 0;
} }
early_param("smt-enabled", early_smt_enabled); early_param("smt-enabled", early_smt_enabled);
...@@ -380,8 +389,8 @@ void __init setup_system(void) ...@@ -380,8 +389,8 @@ void __init setup_system(void)
*/ */
xmon_setup(); xmon_setup();
check_smt_enabled();
smp_setup_cpu_maps(); smp_setup_cpu_maps();
check_smt_enabled();
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
/* Release secondary cpus out of their spinloops at 0x60 now that /* Release secondary cpus out of their spinloops at 0x60 now that
......
...@@ -182,10 +182,13 @@ static int smp_pSeries_cpu_bootable(unsigned int nr) ...@@ -182,10 +182,13 @@ static int smp_pSeries_cpu_bootable(unsigned int nr)
/* Special case - we inhibit secondary thread startup /* Special case - we inhibit secondary thread startup
* during boot if the user requests it. * during boot if the user requests it.
*/ */
if (system_state < SYSTEM_RUNNING && if (system_state < SYSTEM_RUNNING && cpu_has_feature(CPU_FTR_SMT)) {
cpu_has_feature(CPU_FTR_SMT) && if (!smt_enabled_at_boot && cpu_thread_in_core(nr) != 0)
!smt_enabled_at_boot && cpu_thread_in_core(nr) != 0) return 0;
return 0; if (smt_enabled_at_boot
&& cpu_thread_in_core(nr) >= smt_enabled_at_boot)
return 0;
}
return 1; return 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment