From patchwork Fri Oct 18 11:54:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 21128 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2AF3B246F1 for ; Fri, 18 Oct 2013 11:55:30 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id w10sf5864255pde.8 for ; Fri, 18 Oct 2013 04:55:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=fMrbUqCS2fOKqinlK29hfNt8dViPeF1pkKoAxvyu4k4=; b=dhSDSvLR+SOMY+C1RBXvYNek9krATiGzhwD6TiaDjds5vwDsvF1rdmO8ye5U23ePtW wZQbZzl4qhsrG1VdGTTAj+9Gzv2uSFkmOt14RxUCO1vF5PHKDEq9kEpzr2Plc7ndGpUC jjMRk8XLUhnRONBP5K0AKHBWyiCpkI5oNcNDiA81QzHw26G+V1K37ZMzUniIjEoC8KZs LBTUQjSSlTZHXVAshVKcu+8pXaMOrDPtIkImn1WVdehczKlk75CaYN8GzgEoz4z9aRF6 x7HoCBXqSmjU3iwSbu1Mv1rxJcMthXQnnmeM6F8xIZauCsZD5qKWyPnMXszuyLPA4yV1 Cv0Q== X-Received: by 10.66.121.194 with SMTP id lm2mr1122429pab.20.1382097329510; Fri, 18 Oct 2013 04:55:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.105.34 with SMTP id gj2ls1338337qeb.52.gmail; Fri, 18 Oct 2013 04:55:29 -0700 (PDT) X-Received: by 10.58.133.77 with SMTP id pa13mr188311veb.21.1382097329346; Fri, 18 Oct 2013 04:55:29 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id vr9si227382vcb.126.2013.10.18.04.55.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 04:55:29 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id pa12so2008991veb.12 for ; Fri, 18 Oct 2013 04:55:29 -0700 (PDT) X-Gm-Message-State: ALoCoQkKF0ghvX0F5NKfPYo0ezt7JJHhPKysoJcR3VkIGed7s8fVjgfkyIuP2ka6STIf6mUdHBFk X-Received: by 10.58.146.71 with SMTP id ta7mr72819veb.23.1382097329252; Fri, 18 Oct 2013 04:55:29 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp29573vcz; Fri, 18 Oct 2013 04:55:28 -0700 (PDT) X-Received: by 10.180.208.2 with SMTP id ma2mr2115674wic.52.1382097327782; Fri, 18 Oct 2013 04:55:27 -0700 (PDT) Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com [74.125.82.44]) by mx.google.com with ESMTPS id fr4si4164482wic.30.2013.10.18.04.55.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 04:55:27 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.44 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) client-ip=74.125.82.44; Received: by mail-wg0-f44.google.com with SMTP id n12so3625143wgh.35 for ; Fri, 18 Oct 2013 04:55:27 -0700 (PDT) X-Received: by 10.195.13.164 with SMTP id ez4mr2252846wjd.11.1382097327148; Fri, 18 Oct 2013 04:55:27 -0700 (PDT) Received: from localhost.localdomain (LPuteaux-156-14-44-212.w82-127.abo.wanadoo.fr. [82.127.83.212]) by mx.google.com with ESMTPSA id ey4sm2753241wic.11.2013.10.18.04.55.15 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 04:55:26 -0700 (PDT) From: Vincent Guittot To: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@kernel.org, pjt@google.com, Morten.Rasmussen@arm.com, cmetcalf@tilera.com, tony.luck@intel.com, alex.shi@intel.com, preeti@linux.vnet.ibm.com, linaro-kernel@lists.linaro.org, lorenzo.pieralisi@arm.com, devicetree@vger.kernel.org, rob.herring@calxeda.com, linux@arm.linux.org.uk, linux-arm-kernel@lists.infradead.org Cc: rjw@sisk.pl, paulmck@linux.vnet.ibm.com, corbet@lwn.net, tglx@linutronix.de, len.brown@intel.com, arjan@linux.intel.com, amit.kucheria@linaro.org, l.majewski@samsung.com, Vincent Guittot Subject: [RFC][PATCH v5 02/14] ARM: sched: clear SD_SHARE_POWERDOMAIN Date: Fri, 18 Oct 2013 13:54:53 +0200 Message-Id: <1382097293-30245-1-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: vincent.guittot@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The ARM platforms take advantage of packing tasks on few cores if the latters can be powergated independantly. We use DT and the cpu topology descirption to define at which level a core can be independantly powergated to the others and the SD_SHARE_POWERDOMAIN will be set accordingly at MC and CPU sched_domain level. The power-gate properties should be added with the value 1 in cpu and cluster node when then can power gate independantly from the other. As an example of a quad cores system which can power gate each core independantly, we should have a DT similar to the example below cpus { #address-cells = <1>; #size-cells = <0>; cpu-map { cluster0 { power-gate = <1>; core0 { cpu = <&cpu0>; power-gate = <1>; }; core1 { cpu = <&cpu1>; power-gate = <1>; }; core2 { cpu = <&cpu2>; power-gate = <1>; }; core3 { cpu = <&cpu3>; power-gate = <1>; }; }; }; ... }; Signed-off-by: Vincent Guittot --- arch/arm/include/asm/topology.h | 4 ++++ arch/arm/kernel/topology.c | 50 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/topology.h b/arch/arm/include/asm/topology.h index 58b8b84..5102847 100644 --- a/arch/arm/include/asm/topology.h +++ b/arch/arm/include/asm/topology.h @@ -5,12 +5,16 @@ #include +#define CPU_CORE_GATE 0x1 +#define CPU_CLUSTER_GATE 0x2 + struct cputopo_arm { int thread_id; int core_id; int socket_id; cpumask_t thread_sibling; cpumask_t core_sibling; + int flags; }; extern struct cputopo_arm cpu_topology[NR_CPUS]; diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index 85a8737..f38f1f9 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c @@ -24,6 +24,7 @@ #include #include +#include /* * cpu power scale management @@ -79,6 +80,51 @@ unsigned long *__cpu_capacity; unsigned long middle_capacity = 1; +static int __init get_dt_power_topology(struct device_node *topo) +{ + const u32 *reg; + int len, power = 0; + int flag = CPU_CORE_GATE; + + for (; topo; topo = of_get_next_parent(topo)) { + reg = of_get_property(topo, "power-gate", &len); + if (reg && len == 4 && be32_to_cpup(reg)) + power |= flag; + flag <<= 1; + } + + return power; +} + +#define for_each_subnode_with_property(dn, pn, prop_name) \ + for (dn = of_find_node_with_property(pn, prop_name); dn; \ + dn = of_find_node_with_property(dn, prop_name)) + +static void __init init_dt_power_topology(void) +{ + struct device_node *cn, *topo; + + /* Get power domain topology information */ + cn = of_find_node_by_path("/cpus/cpu-map"); + if (!cn) { + pr_warn("Missing cpu-map node, bailing out\n"); + return; + } + + for_each_subnode_with_property(topo, cn, "cpu") { + struct device_node *cpu; + + cpu = of_parse_phandle(topo, "cpu", 0); + if (cpu) { + u32 hwid; + + of_property_read_u32(cpu, "reg", &hwid); + cpu_topology[get_logical_index(hwid)].flags = get_dt_power_topology(topo); + + } + } +} + /* * Iterate all CPUs' descriptor in DT and compute the efficiency * (as per table_efficiency). Also calculate a middle efficiency @@ -151,6 +197,8 @@ static void __init parse_dt_topology(void) middle_capacity = ((max_capacity / 3) >> (SCHED_POWER_SHIFT-1)) + 1; + /* Retrieve power topology information from DT */ + init_dt_power_topology(); } /* @@ -283,7 +331,7 @@ void __init init_cpu_topology(void) cpu_topo->socket_id = -1; cpumask_clear(&cpu_topo->core_sibling); cpumask_clear(&cpu_topo->thread_sibling); - + cpu_topo->flags = 0; set_power_scale(cpu, SCHED_POWER_SCALE); } smp_wmb();