From patchwork Sat Jun 27 03:02:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 6684531 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A9461C05AC for ; Sat, 27 Jun 2015 03:07:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 36399206EC for ; Sat, 27 Jun 2015 03:07:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1A6FC20553 for ; Sat, 27 Jun 2015 03:06:59 +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 1Z8gPl-0007Fv-3g; Sat, 27 Jun 2015 03:04:21 +0000 Received: from mail-pd0-f177.google.com ([209.85.192.177]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z8gOd-0006vU-5X for linux-arm-kernel@lists.infradead.org; Sat, 27 Jun 2015 03:03:13 +0000 Received: by pdbci14 with SMTP id ci14so84809302pdb.2 for ; Fri, 26 Jun 2015 20:02:50 -0700 (PDT) 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=/4O2w05v0KW9KRhp3F2Ayh+wtfi3ozRM6mJmoJthmZU=; b=fizLeTsxnZa9NMRk7G6Q2Ijkl0cedc+VnB5l6MYMKCpTpLQ1NkghSF4M1IteWYdalr 6V8yTppM+CRfz2FTNk8S+0Cco8cp7upZsrZOZ/NwQqzRLpVJYRGRSjzsw07CHasZOAhd EEPbmXm75X6kvkri4s6B2BZJZOijTmyaggfJF35U8SpMz1Nq2hXPAHScD28ORyA2Upd9 9eqO2vgHrUATxG1B/zJOKE4VwLHFeFmOLGxq7NQ7+SHhWwpzAwkYdzBU9RlwtjwOHKU1 YKXFTLxbMozfXJSgak3IT6n4tYbOd2+w8K+CPeywf2HnTPkbpOg4F3pZcKhWdYXLHbvG RPIA== X-Gm-Message-State: ALoCoQmFO50Wjau1QeM69ygwXxw8sZCWjGMrQ9WPV3PMrpxryHAxM9yCBAfIwdgF4d7rXPt/jA9O X-Received: by 10.68.69.37 with SMTP id b5mr9342799pbu.35.1435374170281; Fri, 26 Jun 2015 20:02:50 -0700 (PDT) Received: from ubuntu.localdomain (c-24-8-37-141.hsd1.co.comcast.net. [24.8.37.141]) by mx.google.com with ESMTPSA id j7sm34787756pdp.83.2015.06.26.20.02.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jun 2015 20:02:49 -0700 (PDT) From: Lina Iyer To: rjw@rjwysocki.net, ulf.hansson@linaro.org, khilman@linaro.org Subject: [PATCH RFC v2 04/16] WIP: ARM: PM domains for CPUs/clusters Date: Fri, 26 Jun 2015 21:02:24 -0600 Message-Id: <1435374156-19214-5-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435374156-19214-1-git-send-email-lina.iyer@linaro.org> References: <1435374156-19214-1-git-send-email-lina.iyer@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150626_200311_308025_F2E1616C X-CRM114-Status: GOOD ( 19.61 ) X-Spam-Score: -2.6 (--) Cc: k.kozlowski@samsung.com, linux-pm@vger.kernel.org, msivasub@codeaurora.org, geert@linux-m68k.org, agross@codeaurora.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 From: Kevin Hilman diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi index 534f27c..fc59876 100644 --- a/arch/arm/boot/dts/exynos5420.dtsi +++ b/arch/arm/boot/dts/exynos5420.dtsi @@ -61,6 +61,7 @@ reg = <0x0>; clock-frequency = <1800000000>; cci-control-port = <&cci_control1>; + power-domains = <&big_cluster_pd>; }; cpu1: cpu@1 { @@ -69,6 +70,7 @@ reg = <0x1>; clock-frequency = <1800000000>; cci-control-port = <&cci_control1>; + power-domains = <&big_cluster_pd>; }; cpu2: cpu@2 { @@ -77,6 +79,7 @@ reg = <0x2>; clock-frequency = <1800000000>; cci-control-port = <&cci_control1>; + power-domains = <&big_cluster_pd>; }; cpu3: cpu@3 { @@ -85,6 +88,7 @@ reg = <0x3>; clock-frequency = <1800000000>; cci-control-port = <&cci_control1>; + power-domains = <&big_cluster_pd>; }; cpu4: cpu@100 { @@ -93,6 +97,7 @@ reg = <0x100>; clock-frequency = <1000000000>; cci-control-port = <&cci_control0>; + power-domains = <&little_cluster_pd>; }; cpu5: cpu@101 { @@ -101,6 +106,7 @@ reg = <0x101>; clock-frequency = <1000000000>; cci-control-port = <&cci_control0>; + power-domains = <&little_cluster_pd>; }; cpu6: cpu@102 { @@ -109,6 +115,7 @@ reg = <0x102>; clock-frequency = <1000000000>; cci-control-port = <&cci_control0>; + power-domains = <&little_cluster_pd>; }; cpu7: cpu@103 { @@ -117,6 +124,7 @@ reg = <0x103>; clock-frequency = <1000000000>; cci-control-port = <&cci_control0>; + power-domains = <&little_cluster_pd>; }; }; @@ -249,6 +257,16 @@ }; }; + big_cluster_pd: big_cluster { + compatible = "arm,pd"; + #power-domain-cells = <0>; + }; + + little_cluster_pd: little_cluster { + compatible = "arm,pd"; + #power-domain-cells = <0>; + }; + gsc_pd: power-domain@10044000 { compatible = "samsung,exynos4210-pd"; reg = <0x10044000 0x20>; diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index e69f7a1..98ce19c 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -78,6 +78,7 @@ CFLAGS_pj4-cp0.o := -marm AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt obj-$(CONFIG_ARM_CPU_TOPOLOGY) += topology.o obj-$(CONFIG_VDSO) += vdso.o +obj-$(CONFIG_PM_GENERIC_DOMAINS) += domains.o ifneq ($(CONFIG_ARCH_EBSA110),y) obj-y += io.o diff --git a/arch/arm/kernel/domains.c b/arch/arm/kernel/domains.c new file mode 100644 index 0000000..8388f54 --- /dev/null +++ b/arch/arm/kernel/domains.c @@ -0,0 +1,122 @@ +#define DEBUG + +#include +#include +#include +#include +#include +#include +#include +#include + +#define NAME_MAX 16 + +struct arm_pm_domain { + struct generic_pm_domain genpd; +}; + +static inline +struct arm_pm_domain *to_arm_pd(struct generic_pm_domain *d) +{ + return container_of(d, struct arm_pm_domain, genpd); +} + +static int arm_pd_power_down(struct generic_pm_domain *genpd) +{ + /* pr_info("KJH: %s: %s\n", __func__, genpd->name); */ + return 0; +} + +static int arm_pd_power_up(struct generic_pm_domain *genpd) +{ + /* pr_info("KJH: %s: %s\n", __func__, genpd->name); */ + return 0; +} + +static int arm_domain_cpu_init(void) +{ + int cpuid, ret = 0; + + /* Find any CPU nodes with a phandle to this power domain */ + for_each_possible_cpu(cpuid) { + struct device *cpu_dev; + + /* FIXME: this is open-coding of_cpu_device_node_get(), but I want handle to cpu_dev */ + cpu_dev = get_cpu_device(cpuid); + if (!cpu_dev) { + pr_warn("%s: Unable to get device for CPU%d\n", __func__, cpuid); + return -ENODEV; + } + + /* + * HACK: genpd checks if devices are runtime_suspended + * before doing a poweroff of the domain. However, that check + * assumes that that device has a driver. Since CPU devices don't + * have a driver, genpd assumes that the device is runtime_suspended + * and will power off the domain as soon as the any device + * in the domain does a runtime_suspend. + * + * c.f. the following code in pm_genpd_poweroff(): + * + * if (pdd->dev->driver && (!pm_runtime_suspended(pdd->dev) + * || pdd->dev->power.irq_safe)) + * not_suspended++; + * + * Just removing the pdd->dev->driver check would also work, + * but not sure if that's right in the general case. + */ + cpu_dev->driver = kzalloc(sizeof(struct device_driver), GFP_KERNEL); + WARN_ON(!cpu_dev->driver); + + if (cpu_online(cpuid)) { + pm_runtime_set_active(cpu_dev); + pm_runtime_get_noresume(cpu_dev); + } else { + pm_runtime_set_suspended(cpu_dev); + } + pm_runtime_irq_safe(cpu_dev); + pm_runtime_enable(cpu_dev); + + ret = genpd_dev_pm_attach(cpu_dev); + if (ret) { + dev_warn(cpu_dev, "%s: Unable to attach to power-domain: %d\n", __func__, ret); + pm_runtime_disable(cpu_dev); + } + } + + return 0; +} +device_initcall(arm_domain_cpu_init); + +static int arm_domain_init(void) +{ + struct platform_device *pdev; + struct device_node *np; + + for_each_compatible_node(np, NULL, "arm,pd") { + struct arm_pm_domain *pd; + struct device *dev; + + pdev = of_find_device_by_node(np); + dev = &pdev->dev; + + pd = kzalloc(sizeof(*pd), GFP_KERNEL); + if (!pd) { + pr_err("%s: failed to allocate memory for domain\n", + __func__); + return -ENOMEM; + } + + pd->genpd.name = kstrdup(np->name, GFP_KERNEL); + pd->genpd.power_off = arm_pd_power_down; + pd->genpd.power_on = arm_pd_power_up; + platform_set_drvdata(pdev, pd); + + dev_dbg(dev, "adding as generic power domain.\n"); + pm_genpd_init(&pd->genpd, &simple_qos_governor, false); + of_genpd_add_provider_simple(np, &pd->genpd); + } + + return 0; +} +arch_initcall(arm_domain_init); diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 42ffb8b..02140e6 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -5,6 +5,7 @@ * * This file is released under the GPLv2. */ +#define DEBUG #include #include