From patchwork Mon Nov 23 14:28:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juri Lelli X-Patchwork-Id: 57156 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1468187lbb; Mon, 23 Nov 2015 06:29:24 -0800 (PST) X-Received: by 10.98.87.138 with SMTP id i10mr16232989pfj.69.1448288964793; Mon, 23 Nov 2015 06:29:24 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ut4si20331016pbc.128.2015.11.23.06.29.22; Mon, 23 Nov 2015 06:29:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755249AbbKWO3U (ORCPT + 28 others); Mon, 23 Nov 2015 09:29:20 -0500 Received: from foss.arm.com ([217.140.101.70]:56155 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755192AbbKWO3F (ORCPT ); Mon, 23 Nov 2015 09:29:05 -0500 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 47E265E2; Mon, 23 Nov 2015 06:28:48 -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 81E063F308; Mon, 23 Nov 2015 06:29:02 -0800 (PST) From: Juri Lelli To: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, peterz@infradead.org, vincent.guittot@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, linux@arm.linux.org.uk, sudeep.holla@arm.com, lorenzo.pieralisi@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, morten.rasmussen@arm.com, dietmar.eggemann@arm.com, juri.lelli@arm.com, Mark Brown Subject: [RFC PATCH 5/8] arm64: parse cpu capacity from DT Date: Mon, 23 Nov 2015 14:28:38 +0000 Message-Id: <1448288921-30307-6-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With the introduction of cpu capacity bindings, CPU capacities can now be extracted from DT. Add parsing of such information at boot time. Also, store such information using per CPU variables, as we do for arm. Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Sudeep Holla Signed-off-by: Juri Lelli --- arch/arm64/kernel/topology.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) -- 2.2.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index 694f6de..4423cc5 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -23,6 +23,45 @@ #include #include +static DEFINE_PER_CPU(unsigned long, cpu_scale) = SCHED_CAPACITY_SCALE; + +unsigned long arch_scale_cpu_capacity(struct sched_domain *sd, int cpu) +{ + return per_cpu(cpu_scale, cpu); +} + +static void set_capacity_scale(unsigned int cpu, unsigned long capacity) +{ + per_cpu(cpu_scale, cpu) = capacity; +} + +static u32 capacity_scale = SCHED_CAPACITY_SCALE; + +static void __init parse_cpu_capacity(struct device_node *cpu_node, int cpu) +{ + int ret; + 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)); + } +} + static int __init get_cpu_for_node(struct device_node *node) { struct device_node *cpu_node; @@ -34,6 +73,7 @@ static int __init get_cpu_for_node(struct device_node *node) for_each_possible_cpu(cpu) { if (of_get_cpu_node(cpu, NULL) == cpu_node) { + parse_cpu_capacity(cpu_node, cpu); of_node_put(cpu_node); return cpu; } @@ -173,6 +213,12 @@ static int __init parse_dt_topology(void) return 0; } + 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); + /* * When topology is provided cpu-map is essentially a root * cluster with restricted subnodes.