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: 50387 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 037F3228FD for ; Sat, 27 Jun 2015 03:03:04 +0000 (UTC) Received: by wiea6 with SMTP id a6sf9791566wie.1 for ; Fri, 26 Jun 2015 20:03:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=w2Nchg05WAmYK5xYml5b4hoKQ113+kXM7VuFWxynYco=; b=RZ8iZ0ART1p1gVBBGkSHzwbE7BAkWD9cbrFRLEUvkV8qpYwLlJM4uM8oJVHCjmv07E tniCL7leT1zMPbyrNsJ+ibac8hkTocBrLbA48r5lUsh9E7hBrQOwBrIepGSKuPjdmefJ +5SZ+GcHkJ8nm5zSiJT+mLpsNxDb6+1uF1eOV9VmdgKCJnGarfCAvDyWdRC4VTrXLwfT PUk1CXKY+5lQP1irNNIw48pxc74zM0U0LJmDIfkuRcS0Gfd87z0V1p356jHUTY2irpeB zQDlvVjpIRGOmCVU2g5v2jd3DcFKa/Gby+JFeCnI2+35+h8d0emQqJvJyWt0Q88/X2Ch 2TVQ== X-Gm-Message-State: ALoCoQn2r6JvoGzJtgegWXFLeUG+/4MNh0GMEEyM/IDFR6NJGNJxjquLJNnaWFZu3b2OFD+TA4fT X-Received: by 10.180.90.106 with SMTP id bv10mr926918wib.6.1435374183328; Fri, 26 Jun 2015 20:03:03 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.194 with SMTP id v2ls660326lag.59.gmail; Fri, 26 Jun 2015 20:03:03 -0700 (PDT) X-Received: by 10.112.148.230 with SMTP id tv6mr4295942lbb.89.1435374182991; Fri, 26 Jun 2015 20:03:02 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id v6si27677759laj.100.2015.06.26.20.03.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jun 2015 20:03:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by lagh6 with SMTP id h6so2715949lag.2 for ; Fri, 26 Jun 2015 20:03:02 -0700 (PDT) X-Received: by 10.112.93.37 with SMTP id cr5mr4374131lbb.106.1435374182750; Fri, 26 Jun 2015 20:03:02 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp295161lbb; Fri, 26 Jun 2015 20:03:01 -0700 (PDT) X-Received: by 10.66.129.161 with SMTP id nx1mr9474469pab.84.1435374174487; Fri, 26 Jun 2015 20:02:54 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6si51225212pat.122.2015.06.26.20.02.53; Fri, 26 Jun 2015 20:02:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751773AbbF0DCv (ORCPT + 11 others); Fri, 26 Jun 2015 23:02:51 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:34431 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751732AbbF0DCu (ORCPT ); Fri, 26 Jun 2015 23:02:50 -0400 Received: by pdbep18 with SMTP id ep18so63069559pdb.1 for ; Fri, 26 Jun 2015 20:02:50 -0700 (PDT) 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 Cc: geert@linux-m68k.org, k.kozlowski@samsung.com, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, msivasub@codeaurora.org, agross@codeaurora.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> Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lina.iyer@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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