From patchwork Tue Oct 6 14:27:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Titinger X-Patchwork-Id: 7335221 Return-Path: X-Original-To: patchwork-linux-pm@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 EFE519F1D5 for ; Tue, 6 Oct 2015 14:29:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6903920741 for ; Tue, 6 Oct 2015 14:29:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4DAA720718 for ; Tue, 6 Oct 2015 14:29:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753090AbbJFO26 (ORCPT ); Tue, 6 Oct 2015 10:28:58 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:33187 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752925AbbJFO17 (ORCPT ); Tue, 6 Oct 2015 10:27:59 -0400 Received: by wiclk2 with SMTP id lk2so170049879wic.0 for ; Tue, 06 Oct 2015 07:27:58 -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=4kRodAYlPUNBoMp/RKB1yVFyw2Ne5++AHDymuIayOWw=; b=BV6UBAmVP71SFDT3iATmZUnTxo/qnsN7FK50nD2l19t+MxuYkomqZw7p9Ehc5okOai s7lUxwTcbZXWjuyyS4rJyKbefDjVamngywl1pLS9rSdVPaTL2YmksNEN3QjuVMILnyQ3 3/h/+z7HxEY+vskH/CvVOg9pgCUHdMUT2W6WueLxpWmxFWbddzdx6TWTQ04cnRh+GNT3 5vNO4F3SaCSbChyZ/BtX1eq+pitG4wLcIbLrATj+Uo0X7yMKkiLd/fcZ7onDMnt/MyhR cPZJJyfE6NyQsv1mVcVXcnfLTCpRqK5+wusZHmmvHICV+Wsk1+HAWxaNnV9ismhxEzYz Sc5g== X-Gm-Message-State: ALoCoQl01RLPkXbQtv4dEjqPIpFpAhrgaL0xsFRNshW5MFpArrZhovJMmKalzf5LGvv70xTd9ueU X-Received: by 10.180.188.169 with SMTP id gb9mr19288870wic.72.1444141678304; Tue, 06 Oct 2015 07:27:58 -0700 (PDT) Received: from localhost.localdomain (LPoitiers-656-1-62-228.w90-63.abo.wanadoo.fr. [90.63.143.228]) by smtp.gmail.com with ESMTPSA id go5sm20132914wib.3.2015.10.06.07.27.56 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Oct 2015 07:27:57 -0700 (PDT) From: Marc Titinger X-Google-Original-From: Marc Titinger To: khilman@kernel.org, rjw@rjwysocki.net Cc: lina.iyer@linaro.org, ahaslam@baylibre.com, bcousson@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Marc Titinger Subject: [RFC v2 5/6] arm: cpuidle: let genpd handle the cluster power transition with 'power-states' Date: Tue, 6 Oct 2015 16:27:44 +0200 Message-Id: <1444141665-18534-6-git-send-email-mtitinger+renesas@baylibre.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444141665-18534-1-git-send-email-mtitinger+renesas@baylibre.com> References: <20151006022702.GA78570@linaro.org> <1444141665-18534-1-git-send-email-mtitinger+renesas@baylibre.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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: Marc Titinger Cpuidle now handles c-states and power-states differently. c-states do not decrement the reference count for the CPUs in the cluster, while power-states i.e. cluster level states like 'CLUSTER_SLEEP_0' in the case of juno, will. The 'D1' fake device also registers intermediate power-state, for experimentation. Signed-off-by: Marc Titinger --- arch/arm64/boot/dts/arm/juno.dts | 2 +- drivers/cpuidle/cpuidle-arm.c | 52 ++++++++++++++++++++++++++++++++-------- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/arch/arm64/boot/dts/arm/juno.dts b/arch/arm64/boot/dts/arm/juno.dts index cadc5de..0bb0dd7 100644 --- a/arch/arm64/boot/dts/arm/juno.dts +++ b/arch/arm64/boot/dts/arm/juno.dts @@ -47,7 +47,7 @@ }; CLUSTER_SLEEP_0: cluster-sleep-0 { - compatible = "arm,idle-state","arm,power-state"; + compatible = "arm,power-state"; arm,psci-suspend-param = <0x1010000>; local-timer-stop; entry-latency-us = <800>; diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c index 7c791f9..8dd5dc3 100644 --- a/drivers/cpuidle/cpuidle-arm.c +++ b/drivers/cpuidle/cpuidle-arm.c @@ -40,7 +40,6 @@ static int arm_enter_idle_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, int idx) { int ret; - struct device *cpu_dev = get_cpu_device(dev->cpu); if (!idx) { cpu_do_idle(); @@ -50,18 +49,49 @@ static int arm_enter_idle_state(struct cpuidle_device *dev, ret = cpu_pm_enter(); if (!ret) { /* - * Notify runtime PM as well of this cpu powering down - * TODO: Merge CPU_PM and runtime PM. - */ - RCU_NONIDLE(pm_runtime_put_sync(cpu_dev)); - - /* * Pass idle state index to cpu_suspend which in turn will * call the CPU ops suspend protocol with idle index as a * parameter. */ arm_cpuidle_suspend(idx); + cpu_pm_exit(); + } + + return ret ? -1 : idx; +} + +/* + * arm_enter_power_state - delegate state trasition to genpd + * + * dev: cpuidle device + * drv: cpuidle driver + * idx: state index + * + * Called from the CPUidle framework to delegate a state transition + * to the generic domain. This will be a cluster poweroff state + * the Domain will chose to actually turn off the cluster based on + * the status of other CPUs, and devices and subdomains in the Cluster + * domain. +*/ +static int arm_enter_power_state(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int idx) +{ + int ret; + struct device *cpu_dev = get_cpu_device(dev->cpu); + + BUG_ON(idx == 0); + + ret = cpu_pm_enter(); + if (!ret) { + /* + * Notify runtime PM as well of this cpu powering down + * TODO: Merge CPU_PM and runtime PM. + */ + RCU_NONIDLE(pm_runtime_put_sync(cpu_dev)); + + arm_cpuidle_suspend(idx); + RCU_NONIDLE(pm_runtime_get_sync(cpu_dev)); cpu_pm_exit(); } @@ -69,6 +99,7 @@ static int arm_enter_idle_state(struct cpuidle_device *dev, return ret ? -1 : idx; } + static struct cpuidle_driver arm_idle_driver = { .name = "arm_idle", .owner = THIS_MODULE, @@ -90,9 +121,10 @@ static struct cpuidle_driver arm_idle_driver = { }; static const struct of_device_id arm_idle_state_match[] __initconst = { - { .compatible = "arm,idle-state", - .data = arm_enter_idle_state }, - { }, + {.compatible = "arm,idle-state", + .data = arm_enter_idle_state}, + {.compatible = "arm,power-state", + .data = arm_enter_power_state}, }; /*