svn commit: r355360 - head/sys/dev/cpufreq
Emmanuel Vadot
manu at FreeBSD.org
Tue Dec 3 22:08:55 UTC 2019
Author: manu
Date: Tue Dec 3 22:08:54 2019
New Revision: 355360
URL: https://svnweb.freebsd.org/changeset/base/355360
Log:
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
Modified:
head/sys/dev/cpufreq/cpufreq_dt.c
Modified: head/sys/dev/cpufreq/cpufreq_dt.c
==============================================================================
--- head/sys/dev/cpufreq/cpufreq_dt.c Tue Dec 3 22:01:45 2019 (r355359)
+++ head/sys/dev/cpufreq/cpufreq_dt.c Tue Dec 3 22:08:54 2019 (r355360)
@@ -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,7 +454,15 @@ 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) {
if (regulator_get_by_ofw_property(dev, node,
@@ -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)
More information about the svn-src-all
mailing list