Commit a2b05b7a authored by Nicholas Piggin's avatar Nicholas Piggin Committed by Michael Ellerman

powerpc/64s: Add dt_cpu_ftrs boot time setup option

Provide a dt_cpu_ftrs= cmdline option to disable the dt_cpu_ftrs CPU
feature discovery, and fall back to the "cputable" based version.

Also allow control of advertising unknown features to userspace and
with this parameter, and remove the clunky CONFIG option.
Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
[mpe: Add explicit early check of bootargs in dt_cpu_ftrs_init()]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent a4700a26
...@@ -866,6 +866,15 @@ ...@@ -866,6 +866,15 @@
dscc4.setup= [NET] dscc4.setup= [NET]
dt_cpu_ftrs= [PPC]
Format: {"off" | "known"}
Control how the dt_cpu_ftrs device-tree binding is
used for CPU feature discovery and setup (if it
exists).
off: Do not use it, fall back to legacy cpu table.
known: Do not pass through unknown features to guests
or userspace, only those that the kernel is aware of.
dump_apple_properties [X86] dump_apple_properties [X86]
Dump name and content of EFI device properties on Dump name and content of EFI device properties on
x86 Macs. Useful for driver authors to determine x86 Macs. Useful for driver authors to determine
......
...@@ -391,11 +391,6 @@ config PPC_DT_CPU_FTRS ...@@ -391,11 +391,6 @@ config PPC_DT_CPU_FTRS
firmware provides this binding. firmware provides this binding.
If you're not sure say Y. If you're not sure say Y.
config PPC_CPUFEATURES_ENABLE_UNKNOWN
bool "cpufeatures pass through unknown features to guest/userspace"
depends on PPC_DT_CPU_FTRS
default y
config HIGHMEM config HIGHMEM
bool "High memory support" bool "High memory support"
depends on PPC32 depends on PPC32
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/export.h> #include <linux/export.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/jump_label.h> #include <linux/jump_label.h>
#include <linux/libfdt.h>
#include <linux/memblock.h> #include <linux/memblock.h>
#include <linux/printk.h> #include <linux/printk.h>
#include <linux/sched.h> #include <linux/sched.h>
...@@ -671,12 +672,24 @@ static struct dt_cpu_feature_match __initdata ...@@ -671,12 +672,24 @@ static struct dt_cpu_feature_match __initdata
{"wait-v3", feat_enable, 0}, {"wait-v3", feat_enable, 0},
}; };
/* XXX: how to configure this? Default + boot time? */ static bool __initdata using_dt_cpu_ftrs;
#ifdef CONFIG_PPC_CPUFEATURES_ENABLE_UNKNOWN static bool __initdata enable_unknown = true;
#define CPU_FEATURE_ENABLE_UNKNOWN 1
#else static int __init dt_cpu_ftrs_parse(char *str)
#define CPU_FEATURE_ENABLE_UNKNOWN 0 {
#endif if (!str)
return 0;
if (!strcmp(str, "off"))
using_dt_cpu_ftrs = false;
else if (!strcmp(str, "known"))
enable_unknown = false;
else
return 1;
return 0;
}
early_param("dt_cpu_ftrs", dt_cpu_ftrs_parse);
static void __init cpufeatures_setup_start(u32 isa) static void __init cpufeatures_setup_start(u32 isa)
{ {
...@@ -707,7 +720,7 @@ static bool __init cpufeatures_process_feature(struct dt_cpu_feature *f) ...@@ -707,7 +720,7 @@ static bool __init cpufeatures_process_feature(struct dt_cpu_feature *f)
} }
} }
if (!known && CPU_FEATURE_ENABLE_UNKNOWN) { if (!known && enable_unknown) {
if (!feat_try_enable_unknown(f)) { if (!feat_try_enable_unknown(f)) {
pr_info("not enabling: %s (unknown and unsupported by kernel)\n", pr_info("not enabling: %s (unknown and unsupported by kernel)\n",
f->name); f->name);
...@@ -756,6 +769,26 @@ static void __init cpufeatures_setup_finished(void) ...@@ -756,6 +769,26 @@ static void __init cpufeatures_setup_finished(void)
cur_cpu_spec->cpu_features, cur_cpu_spec->mmu_features); cur_cpu_spec->cpu_features, cur_cpu_spec->mmu_features);
} }
static int __init disabled_on_cmdline(void)
{
unsigned long root, chosen;
const char *p;
root = of_get_flat_dt_root();
chosen = of_get_flat_dt_subnode_by_name(root, "chosen");
if (chosen == -FDT_ERR_NOTFOUND)
return false;
p = of_get_flat_dt_prop(chosen, "bootargs", NULL);
if (!p)
return false;
if (strstr(p, "dt_cpu_ftrs=off"))
return true;
return false;
}
static int __init fdt_find_cpu_features(unsigned long node, const char *uname, static int __init fdt_find_cpu_features(unsigned long node, const char *uname,
int depth, void *data) int depth, void *data)
{ {
...@@ -766,8 +799,6 @@ static int __init fdt_find_cpu_features(unsigned long node, const char *uname, ...@@ -766,8 +799,6 @@ static int __init fdt_find_cpu_features(unsigned long node, const char *uname,
return 0; return 0;
} }
static bool __initdata using_dt_cpu_ftrs = false;
bool __init dt_cpu_ftrs_in_use(void) bool __init dt_cpu_ftrs_in_use(void)
{ {
return using_dt_cpu_ftrs; return using_dt_cpu_ftrs;
...@@ -775,6 +806,8 @@ bool __init dt_cpu_ftrs_in_use(void) ...@@ -775,6 +806,8 @@ bool __init dt_cpu_ftrs_in_use(void)
bool __init dt_cpu_ftrs_init(void *fdt) bool __init dt_cpu_ftrs_init(void *fdt)
{ {
using_dt_cpu_ftrs = false;
/* Setup and verify the FDT, if it fails we just bail */ /* Setup and verify the FDT, if it fails we just bail */
if (!early_init_dt_verify(fdt)) if (!early_init_dt_verify(fdt))
return false; return false;
...@@ -782,6 +815,9 @@ bool __init dt_cpu_ftrs_init(void *fdt) ...@@ -782,6 +815,9 @@ bool __init dt_cpu_ftrs_init(void *fdt)
if (!of_scan_flat_dt(fdt_find_cpu_features, NULL)) if (!of_scan_flat_dt(fdt_find_cpu_features, NULL))
return false; return false;
if (disabled_on_cmdline())
return false;
cpufeatures_setup_cpu(); cpufeatures_setup_cpu();
using_dt_cpu_ftrs = true; using_dt_cpu_ftrs = true;
...@@ -1027,5 +1063,8 @@ static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const char ...@@ -1027,5 +1063,8 @@ static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const char
void __init dt_cpu_ftrs_scan(void) void __init dt_cpu_ftrs_scan(void)
{ {
if (!using_dt_cpu_ftrs)
return;
of_scan_flat_dt(dt_cpu_ftrs_scan_callback, NULL); of_scan_flat_dt(dt_cpu_ftrs_scan_callback, NULL);
} }
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