From owner-svn-src-stable@freebsd.org Thu Jun 18 23:31:57 2020 Return-Path: Delivered-To: svn-src-stable@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 378E4337DE8; Thu, 18 Jun 2020 23:31:57 +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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 49nyrY0mwSz4FHn; Thu, 18 Jun 2020 23:31:57 +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 15D7411EBB; Thu, 18 Jun 2020 23:31:57 +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 05INVuJt057569; Thu, 18 Jun 2020 23:31:56 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05INVuhN057568; Thu, 18 Jun 2020 23:31:56 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202006182331.05INVuhN057568@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Thu, 18 Jun 2020 23:31:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r362352 - stable/12/sys/dev/cpufreq X-SVN-Group: stable-12 X-SVN-Commit-Author: manu X-SVN-Commit-Paths: stable/12/sys/dev/cpufreq X-SVN-Commit-Revision: 362352 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jun 2020 23:31:57 -0000 Author: manu Date: Thu Jun 18 23:31:56 2020 New Revision: 362352 URL: https://svnweb.freebsd.org/changeset/base/362352 Log: MFC r358555, r358799-r358800 r358555: cpufreq_dt: Improve multiple opp support When looking for cpu with the same OPP starts from the root /cpus node so each instance of cpufreq_dt will now each cpu with the same operating point. Also test that the node we are testing have the property "device_type" set to be equal to "cpu". While here add more debug printfs (off by defaults). r358799: cpufreq_dt: Fix r358555 Before skipping the current cpu when trying to find the ones that have the same opp, record that this one have this opp. Reported by: mmel X-MFC-With: r358555 r358800: cpufreq: Unbreak build. 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 Thu Jun 18 23:23:21 2020 (r362351) +++ stable/12/sys/dev/cpufreq/cpufreq_dt.c Thu Jun 18 23:31:56 2020 (r362352) @@ -82,6 +82,7 @@ struct cpufreq_dt_softc { struct cpufreq_dt_opp *opp; ssize_t nopp; + int cpu; cpuset_t cpus; }; @@ -170,6 +171,13 @@ cpufreq_dt_set(device_t dev, const struct cf_setting * sc = device_get_softc(dev); + DEBUG(dev, "Working on cpu %d\n", sc->cpu); + DEBUG(dev, "We have %d cpu on this dev\n", CPU_COUNT(&sc->cpus)); + if (!CPU_ISSET(sc->cpu, &sc->cpus)) { + DEBUG(dev, "Not for this CPU\n"); + return (0); + } + if (clk_get_freq(sc->clk, &freq) != 0) { device_printf(dev, "Can't get current clk freq\n"); return (ENXIO); @@ -191,7 +199,6 @@ cpufreq_dt_set(device_t dev, const struct cf_setting * return (ENOENT); } uvolt = copp->uvolt_target; - } opp = cpufreq_dt_find_opp(sc->dev, set->freq * 1000000); @@ -450,14 +457,16 @@ cpufreq_dt_attach(device_t dev) int cpu; uint64_t freq; int rv = 0; + char device_type[16]; enum opp_version version; 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)); + sc->cpu = device_get_unit(device_get_parent(dev)); - if (cpu >= mp_ncpus) { + DEBUG(dev, "cpu=%d\n", sc->cpu); + if (sc->cpu >= mp_ncpus) { device_printf(dev, "Not attaching as cpu is not present\n"); return (ENXIO); } @@ -503,7 +512,19 @@ cpufreq_dt_attach(device_t dev) * Find all CPUs that share the same opp table */ CPU_ZERO(&sc->cpus); - for (cnode = node; cnode > 0; cnode = OF_peer(cnode), cpu++) { + cnode = OF_parent(node); + for (cpu = 0, cnode = OF_child(cnode); cnode > 0; cnode = OF_peer(cnode)) { + if (OF_getprop(cnode, "device_type", device_type, sizeof(device_type)) <= 0) + continue; + if (strcmp(device_type, "cpu") != 0) + continue; + if (cpu == sc->cpu) { + DEBUG(dev, "Skipping our cpu\n"); + CPU_SET(cpu, &sc->cpus); + cpu++; + continue; + } + DEBUG(dev, "Testing CPU %d\n", cpu); copp = -1; if (version == OPP_V1) OF_getencprop(cnode, "operating-points", &copp, @@ -511,8 +532,11 @@ cpufreq_dt_attach(device_t dev) else if (version == OPP_V2) OF_getencprop(cnode, "operating-points-v2", &copp, sizeof(copp)); - if (opp == copp) + if (opp == copp) { + DEBUG(dev, "CPU %d is using the same opp as this one (%d)\n", cpu, sc->cpu); CPU_SET(cpu, &sc->cpus); + } + cpu++; } if (clk_get_freq(sc->clk, &freq) == 0)