From owner-svn-src-all@freebsd.org Tue Dec 3 22:08:55 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 20E851BF574; Tue, 3 Dec 2019 22:08:55 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47SGN706ltz41s8; Tue, 3 Dec 2019 22:08:55 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DC8081E4D5; Tue, 3 Dec 2019 22:08:54 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xB3M8sC9080529; Tue, 3 Dec 2019 22:08:54 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xB3M8sZf080528; Tue, 3 Dec 2019 22:08:54 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201912032208.xB3M8sZf080528@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Tue, 3 Dec 2019 22:08:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355360 - head/sys/dev/cpufreq X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/cpufreq X-SVN-Commit-Revision: 355360 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Dec 2019 22:08:55 -0000 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)