From patchwork Thu Nov 10 14:24:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 81677 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp751981qge; Thu, 10 Nov 2016 06:25:02 -0800 (PST) X-Received: by 10.99.52.10 with SMTP id b10mr24347492pga.42.1478787902880; Thu, 10 Nov 2016 06:25:02 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a28si5167996pfl.157.2016.11.10.06.25.02; Thu, 10 Nov 2016 06:25:02 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933374AbcKJOYn (ORCPT + 13 others); Thu, 10 Nov 2016 09:24:43 -0500 Received: from foss.arm.com ([217.140.101.70]:49546 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933633AbcKJOYl (ORCPT ); Thu, 10 Nov 2016 09:24:41 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E5E0316; Thu, 10 Nov 2016 06:24:40 -0800 (PST) Received: from e107155-lin.cambridge.arm.com (e107155-lin.cambridge.arm.com [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9FC7C3F318; Thu, 10 Nov 2016 06:24:39 -0800 (PST) From: Sudeep Holla To: linux-pm@vger.kernel.org, "Rafael J . Wysocki" Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Daniel Lezcano , Lorenzo Pieralisi , Andy Gross , Vincent Guittot Subject: [PATCH v2] drivers: cpuidle: assign enter_freeze to same as enter callback function Date: Thu, 10 Nov 2016 14:24:33 +0000 Message-Id: <1478787873-18180-1-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478713410-10727-1-git-send-email-sudeep.holla@arm.com> References: <1478713410-10727-1-git-send-email-sudeep.holla@arm.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org enter_freeze() callback is expected atleast to do the same as enter() but it has to guarantee that interrupts aren't enabled at any point in its execution, as the tick is frozen. CPUs execute ->enter_freeze with the local tick or entire timekeeping suspended, so it must not re-enable interrupts at any point (even temporarily) or attempt to change states of clock event devices. It will be called when the system goes to suspend-to-idle and will reduce power usage because CPUs won't be awaken for unnecessary IRQs (i.e. woken up only on IRQs from "wakeup sources") We can reuse the same code for both the enter() and enter_freeze() callbacks as along as they don't re-enable interrupts. Only "coupled" cpuidle mechanism enables interrupts and doing that with timekeeping suspended is generally not safe. Since this generic DT based idle driver doesn't support "coupled" states, it is safe to assume that the interrupts are not re-enabled. This patch assign enter_freeze to same as enter callback function which helps to save power without any intermittent spurious wakeups from suspend-to-idle. Cc: "Rafael J. Wysocki" Signed-off-by: Sudeep Holla --- drivers/cpuidle/dt_idle_states.c | 6 ++++++ 1 file changed, 6 insertions(+) v1->v2: - Dropped checking and using only states with CPUIDLE_FLAG_TIMER_STOP enabled. -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Tested-by: Andy Gross diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c index a5c111b67f37..ffca4fc0061d 100644 --- a/drivers/cpuidle/dt_idle_states.c +++ b/drivers/cpuidle/dt_idle_states.c @@ -38,6 +38,12 @@ static int init_state_node(struct cpuidle_state *idle_state, * state enter function. */ idle_state->enter = match_id->data; + /* + * Since this is not a "coupled" state, it's safe to assume interrupts + * won't be enabled when it exits allowing the tick to be frozen + * safely. So enter() can be also enter_freeze() callback. + */ + idle_state->enter_freeze = match_id->data; err = of_property_read_u32(state_node, "wakeup-latency-us", &idle_state->exit_latency);