From patchwork Tue Mar 1 21:15:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 8470541 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 52AEC9F8A8 for ; Tue, 1 Mar 2016 21:20:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6403020304 for ; Tue, 1 Mar 2016 21:20:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 775F62010E for ; Tue, 1 Mar 2016 21:20:15 +0000 (UTC) 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 1aargY-0002c6-DU; Tue, 01 Mar 2016 21:18:26 +0000 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aaren-0000rz-9Q for linux-arm-kernel@lists.infradead.org; Tue, 01 Mar 2016 21:16:41 +0000 Received: by mail-pf0-x22c.google.com with SMTP id w128so75060292pfb.2 for ; Tue, 01 Mar 2016 13:16:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LUsnL3sZufQX8YPyy3lno40OmeplZISpCKgBPWmM3Dg=; b=fDioDQ146j2vTlSva1EW5r9U3vbKthRHxl47KbxZuF5lGWLNxtAXYiwLt9ZN75097x RUjUf4nMeFf8Bhvp+287WKxVDAVv3zZ2vjGH8QdmJYlFnYM3GNdgbgs65bRYqEPXL4n1 FH6/U/FaNWSRIXRJobEnSoAfcogznyPomz7j0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LUsnL3sZufQX8YPyy3lno40OmeplZISpCKgBPWmM3Dg=; b=BRLRcQsws/VYSOdOyoPNiKYiz7tB4M+Gi5uTY9ajmyU8ItzsY5yKN+U9KmrzgfYMBn xmADiwRvhPB8GMEcHQJrVTXWhcr0QpT5saAXKdrA3q8wpzs4NrjAhWdRb2nCys5qgnPW t7vTJPX5byTW2ft1LRmFURRZwv3ToogGRc+U8OB0wd0fo6dMFxwvbSGZI4qjEypFxzNX +tZ4qJYM8063Lyc5irgLyogDzXCvS3FXeXl+C2OXoFpRxHdzu/qr/++2gSMwWjrB1Wpl VljCoTHPyuzqFr3ASR69qauPvlFUzsWLQr47L1bppQ6CM4pkhL9t1uoZ92D1gHZYLwqt 0W2g== X-Gm-Message-State: AD7BkJKi38GYC1+k6dOICHaxPqqw5z4KMaoc0DN56vi3azXNg6HvZ6GjIvxLQabPc9WxksNT X-Received: by 10.98.12.8 with SMTP id u8mr33047709pfi.36.1456866976522; Tue, 01 Mar 2016 13:16:16 -0800 (PST) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id kw10sm47749328pab.0.2016.03.01.13.16.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Mar 2016 13:16:15 -0800 (PST) From: Lina Iyer To: ulf.hansson@linaro.org, khilman@kernel.org, rjw@rjwysocki.net, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v3 06/12] PM / cpu_domains: Record CPUs that are part of the domain Date: Tue, 1 Mar 2016 14:15:25 -0700 Message-Id: <1456866931-37851-8-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456866931-37851-1-git-send-email-lina.iyer@linaro.org> References: <1456866931-37851-1-git-send-email-lina.iyer@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160301_131637_637167_1A3764F1 X-CRM114-Status: GOOD ( 17.49 ) X-Spam-Score: -2.7 (--) 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: k.kozlowski@samsung.com, lorenzo.pieralisi@arm.com, ahaslam@baylibre.com, linux-arm-msm@vger.kernel.org, sboyd@codeaurora.org, msivasub@codeaurora.org, geert@linux-m68k.org, Lina Iyer , agross@codeaurora.org, mtitinger@baylibre.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to power down a CPU domain, the domain needs information about the CPUs in that domain. The reference counting for the CPU devices in a domain is done by genpd. In order to understand the idle time for the domain, it is necessary to know which CPUs are part of the domain, so the domain governor may understand the sleep durations of the comprising CPU devices and make a judicious decision on the domain's idle state. This extends to the parent of such domains, which may have multiple such CPU domains and therefore would need to know the sleep patterns of all the CPUs in all the CPU domains. To aid this functionality, traverse up the parent chain and set the CPU in the cpumasks while attaching a CPU to its domain. This mask is provided in the callback to the platform driver to help identify the CPUs in the domain that is being powered off. Signed-off-by: Lina Iyer --- drivers/base/power/cpu_domains.c | 28 ++++++++++++++++++++++++---- include/linux/cpu_domains.h | 4 +++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/base/power/cpu_domains.c b/drivers/base/power/cpu_domains.c index 62704e6..62c1ab9 100644 --- a/drivers/base/power/cpu_domains.c +++ b/drivers/base/power/cpu_domains.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -27,6 +28,7 @@ struct cpu_pm_domain { struct cpu_pd_ops ops; struct generic_pm_domain *genpd; struct cpu_pm_domain *parent; + cpumask_var_t cpus; }; /* List of CPU PM domains we care about */ @@ -50,7 +52,7 @@ struct cpu_pm_domain *to_cpu_pd(struct generic_pm_domain *d) return res; } -static int cpu_pd_attach_cpu(int cpu) +static int cpu_pd_attach_cpu(struct cpu_pm_domain *cpu_pd, int cpu) { int ret; struct device *cpu_dev; @@ -70,6 +72,11 @@ static int cpu_pd_attach_cpu(int cpu) else dev_dbg(cpu_dev, "Attached to domain\n"); + while (!ret && cpu_pd) { + cpumask_set_cpu(cpu, cpu_pd->cpus); + cpu_pd = cpu_pd->parent; + }; + return ret; } @@ -85,8 +92,8 @@ static int cpu_pd_power_off(struct generic_pm_domain *genpd) struct cpu_pm_domain *pd = to_cpu_pd(genpd); return pd->ops.power_off ? pd->ops.power_off(genpd->state_idx, - genpd->states[genpd->state_idx].param), - : 0; + genpd->states[genpd->state_idx].param, + pd->cpus) : 0; } /** @@ -119,6 +126,9 @@ static struct generic_pm_domain *of_init_cpu_pm_domain(struct device_node *dn, if (!pd) goto fail; + if (!zalloc_cpumask_var(&pd->cpus, GFP_KERNEL)) + goto fail; + pd->genpd = genpd; pd->genpd->power_off = cpu_pd_power_off; pd->genpd->power_on = cpu_pd_power_on; @@ -149,6 +159,8 @@ fail: kfree(genpd->name); kfree(genpd); + if (pd) + kfree(pd->cpus); kfree(pd); return ERR_PTR(ret); } @@ -224,6 +236,7 @@ int of_setup_cpu_pd_single(int cpu, const struct cpu_pd_ops *ops) struct device_node *dn; struct generic_pm_domain *genpd; + struct cpu_pm_domain *cpu_pd; dn = of_get_cpu_node(cpu, NULL); if (!dn) @@ -239,7 +252,14 @@ int of_setup_cpu_pd_single(int cpu, const struct cpu_pd_ops *ops) return PTR_ERR(genpd); of_node_put(dn); - return cpu_pd_attach_cpu(cpu); + cpu_pd = to_cpu_pd(genpd); + if (!cpu_pd) { + pr_err("%s: Genpd was created outside CPU PM domains\n", + __func__); + return -ENOENT; + } + + return cpu_pd_attach_cpu(cpu_pd, cpu); } EXPORT_SYMBOL(of_setup_cpu_pd_single); diff --git a/include/linux/cpu_domains.h b/include/linux/cpu_domains.h index 9530b2d..50e3321 100644 --- a/include/linux/cpu_domains.h +++ b/include/linux/cpu_domains.h @@ -13,8 +13,10 @@ #include +struct cpumask; + struct cpu_pd_ops { - int (*power_off)(u32 state_idx, u32 param); + int (*power_off)(u32 state_idx, u32 param, const struct cpumask *mask); int (*power_on)(void); };