Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Mar 2020 20:30:11 +0000 (UTC)
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r358638 - stable/12/sys/dev/cpufreq
Message-ID:  <202003042030.024KUBBK099864@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: manu
Date: Wed Mar  4 20:30:11 2020
New Revision: 358638
URL: https://svnweb.freebsd.org/changeset/base/358638

Log:
  MFC r355360-r355361
  
  r355360:
  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
  
  r355361:
  cpufreq_dt: Do not fetch again hw.ncpu
  
  MD code already set the global variable mp_ncpus according to
  the tunable hw.ncpu so use the global variable directly.
  
  Reported by:	ian

Modified:
  stable/12/sys/dev/cpufreq/cpufreq_dt.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cpufreq/cpufreq_dt.c
==============================================================================
--- stable/12/sys/dev/cpufreq/cpufreq_dt.c	Wed Mar  4 20:29:49 2020	(r358637)
+++ stable/12/sys/dev/cpufreq/cpufreq_dt.c	Wed Mar  4 20:30:11 2020	(r358638)
@@ -455,7 +455,13 @@ 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 (cpu >= mp_ncpus) {
+		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,
@@ -497,7 +503,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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202003042030.024KUBBK099864>