aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Vadot <manu@FreeBSD.org>2019-12-03 22:08:54 +0000
committerEmmanuel Vadot <manu@FreeBSD.org>2019-12-03 22:08:54 +0000
commit4b23e1e53ab4774e8e0f002ffc4402ae683c98c1 (patch)
tree743c78ec65dc9cb2730565672262043f2e6ee44d
parent357145a0ce086b873893a66f3f18279fe72a52e4 (diff)
downloadsrc-4b23e1e53ab4774e8e0f002ffc4402ae683c98c1.tar.gz
src-4b23e1e53ab4774e8e0f002ffc4402ae683c98c1.zip
cpufreq_dt: Do not attach the device if the cpu isn't present
If we boot with hw.ncpu=X (available on arm and arm64 at least) we shouldn't attach the cpufreq driver as cf_set_method will try to get the cpuid and it doesn't exists. This solves cpufreq panicing on RockChip RK3399 when booting with hw.ncpu=4 MFC after: 1 week
Notes
Notes: svn path=/head/; revision=355360
-rw-r--r--sys/dev/cpufreq/cpufreq_dt.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/dev/cpufreq/cpufreq_dt.c b/sys/dev/cpufreq/cpufreq_dt.c
index 0633184fe618..061345f1bfca 100644
--- a/sys/dev/cpufreq/cpufreq_dt.c
+++ b/sys/dev/cpufreq/cpufreq_dt.c
@@ -446,7 +446,7 @@ cpufreq_dt_attach(device_t dev)
struct cpufreq_dt_softc *sc;
phandle_t node;
phandle_t cnode, opp, copp;
- int cpu;
+ int cpu, ncpu;
uint64_t freq;
int rv = 0;
enum opp_version version;
@@ -454,6 +454,14 @@ cpufreq_dt_attach(device_t dev)
sc = device_get_softc(dev);
sc->dev = dev;
node = ofw_bus_get_node(device_get_parent(dev));
+ cpu = device_get_unit(device_get_parent(dev));
+
+ if (TUNABLE_INT_FETCH("hw.ncpu", &ncpu)) {
+ if (cpu >= ncpu) {
+ device_printf(dev, "Not attaching as cpu is not present\n");
+ return (ENXIO);
+ }
+ }
if (regulator_get_by_ofw_property(dev, node,
"cpu-supply", &sc->reg) != 0) {
@@ -496,7 +504,6 @@ cpufreq_dt_attach(device_t dev)
* Find all CPUs that share the same opp table
*/
CPU_ZERO(&sc->cpus);
- cpu = device_get_unit(device_get_parent(dev));
for (cnode = node; cnode > 0; cnode = OF_peer(cnode), cpu++) {
copp = -1;
if (version == OPP_V1)