From patchwork Mon Nov 23 14:28:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juri Lelli X-Patchwork-Id: 57160 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1469109lbb; Mon, 23 Nov 2015 06:30:59 -0800 (PST) X-Received: by 10.66.167.101 with SMTP id zn5mr36665244pab.48.1448289059419; Mon, 23 Nov 2015 06:30:59 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id v89si19867560pfi.245.2015.11.23.06.30.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2015 06:30:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a0s7U-00087Z-Gh; Mon, 23 Nov 2015 14:29:28 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a0s7H-000820-Rj for linux-arm-kernel@lists.infradead.org; Mon, 23 Nov 2015 14:29:17 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D1DF25D0; Mon, 23 Nov 2015 06:28:41 -0800 (PST) Received: from e106622-lin.cambridge.arm.com (e106622-lin.cambridge.arm.com [10.1.208.152]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 437053F308; Mon, 23 Nov 2015 06:28:56 -0800 (PST) From: Juri Lelli To: linux-kernel@vger.kernel.org Subject: [RFC PATCH 3/8] arm: parse cpu capacity from DT Date: Mon, 23 Nov 2015 14:28:36 +0000 Message-Id: <1448288921-30307-4-git-send-email-juri.lelli@arm.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1448288921-30307-1-git-send-email-juri.lelli@arm.com> References: <1448288921-30307-1-git-send-email-juri.lelli@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151123_062916_094385_1D5A5DDD X-CRM114-Status: GOOD ( 10.69 ) X-Spam-Score: -7.5 (-------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-7.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.101.70 listed in list.dnswl.org] -0.6 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, lorenzo.pieralisi@arm.com, vincent.guittot@linaro.org, juri.lelli@arm.com, linux-pm@vger.kernel.org, peterz@infradead.org, catalin.marinas@arm.com, will.deacon@arm.com, dietmar.eggemann@arm.com, robh+dt@kernel.org, sudeep.holla@arm.com, linux@arm.linux.org.uk, morten.rasmussen@arm.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org With the introduction of cpu capacity bindings, CPU capacities can now be extracted from DT. Add parsing of such information at boot time. We keep code that can produce same information, based on different DT properties and hard-coded values, as fall-back for backward compatibility. Cc: Russell King Signed-off-by: Juri Lelli --- arch/arm/kernel/topology.c | 50 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) -- 2.2.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index ec279d1..ecbff03 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c @@ -78,6 +78,35 @@ static unsigned long *__cpu_capacity; #define cpu_capacity(cpu) __cpu_capacity[cpu] static unsigned long middle_capacity = 1; +static bool capacity_from_dt = true; +static u32 capacity_scale = SCHED_CAPACITY_SCALE; + +static int __init parse_cpu_capacity(struct device_node *cpu_node, int cpu) +{ + int ret = 1; + u32 cpu_capacity; + + ret = of_property_read_u32(cpu_node, + "capacity", + &cpu_capacity); + if (!ret) { + u64 capacity; + + /* + * Enforce capacity <= capacity-scale. + */ + cpu_capacity = cpu_capacity <= capacity_scale ? cpu_capacity : + capacity_scale; + capacity = (cpu_capacity << SCHED_CAPACITY_SHIFT) / + capacity_scale; + + set_capacity_scale(cpu, capacity); + pr_info("CPU%d: DT cpu capacity %lu\n", + cpu, arch_scale_cpu_capacity(NULL, cpu)); + } + + return !ret; +} /* * Iterate all CPUs' descriptor in DT and compute the efficiency @@ -99,6 +128,18 @@ static void __init parse_dt_topology(void) __cpu_capacity = kcalloc(nr_cpu_ids, sizeof(*__cpu_capacity), GFP_NOWAIT); + cn = of_find_node_by_path("/cpus"); + if (!cn) { + pr_err("No CPU information found in DT\n"); + return; + } + + if (!of_property_read_u32(cn, "capacity-scale", &capacity_scale)) + pr_info("DT cpus capacity-scale %u\n", capacity_scale); + else + pr_debug("DT cpus capacity-scale not found: assuming %u\n", + capacity_scale); + for_each_possible_cpu(cpu) { const u32 *rate; int len; @@ -110,6 +151,13 @@ static void __init parse_dt_topology(void) continue; } + if (parse_cpu_capacity(cn, cpu)) { + of_node_put(cn); + continue; + } + + capacity_from_dt = false; + for (cpu_eff = table_efficiency; cpu_eff->compatible; cpu_eff++) if (of_device_is_compatible(cn, cpu_eff->compatible)) break; @@ -160,7 +208,7 @@ static void __init parse_dt_topology(void) */ static void update_cpu_capacity(unsigned int cpu) { - if (!cpu_capacity(cpu)) + if (!cpu_capacity(cpu) || capacity_from_dt) return; set_capacity_scale(cpu, cpu_capacity(cpu) / middle_capacity);