From patchwork Thu Jan 21 11:19:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 60064 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp3713621lbb; Thu, 21 Jan 2016 03:19:39 -0800 (PST) X-Received: by 10.98.72.87 with SMTP id v84mr59167374pfa.15.1453375179864; Thu, 21 Jan 2016 03:19:39 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 127si1513402pfa.4.2016.01.21.03.19.39; Thu, 21 Jan 2016 03:19:39 -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 S1759381AbcAULTi (ORCPT + 11 others); Thu, 21 Jan 2016 06:19:38 -0500 Received: from foss.arm.com ([217.140.101.70]:50364 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759379AbcAULTh (ORCPT ); Thu, 21 Jan 2016 06:19:37 -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 779113A1; Thu, 21 Jan 2016 03:18:58 -0800 (PST) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.207.150]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 121643F246; Thu, 21 Jan 2016 03:19:35 -0800 (PST) From: Sudeep Holla To: "Rafael J. Wysocki" , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Lorenzo Pieralisi , Ingo Molnar , Peter Zijlstra Subject: [PATCH] cpuidle: fix fallback mechanism for suspend to idle in absence of enter_freeze Date: Thu, 21 Jan 2016 11:19:29 +0000 Message-Id: <1453375169-14768-1-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 1.9.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Commit 51164251f5c3 ("sched / idle: Drop default_idle_call() fallback from call_cpuidle()") made find_deepest_state() return non-negative value and check all the states with index > 0. Also a result, find_deepest_state() returns 0 even when enter_freeze callbacks are not implemented and enter_freeze_proper is called which ends up crashing the kernel. This patch updates the check for index > 0 in cpuidle_enter_freeze and cpuidle_idle_call(when idle_should_freeze is true) to restore the suspend-to-idle functionality in absence of enter_freeze callback. Fixes: 51164251f5c3 ("sched / idle: Drop default_idle_call() fallback from call_cpuidle()") Cc: "Rafael J. Wysocki" Cc: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: Sudeep Holla --- drivers/cpuidle/cpuidle.c | 2 +- kernel/sched/idle.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) Hi Rafael, I assume you prefer to retain find_deepest_state return non-negative values, so I took this approach for fixing the bug. Do you think we need to support enter_freeze_proper for index 0 ? Regards, Sudeep -- 1.9.1 -- 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 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 046423b0c5ca..f996efc56605 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -153,7 +153,7 @@ int cpuidle_enter_freeze(struct cpuidle_driver *drv, struct cpuidle_device *dev) * be frozen safely. */ index = find_deepest_state(drv, dev, UINT_MAX, 0, true); - if (index >= 0) + if (index > 0) enter_freeze_proper(drv, dev, index); return index; diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index de0e786b2667..544a7133cbd1 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -162,7 +162,7 @@ static void cpuidle_idle_call(void) */ if (idle_should_freeze()) { entered_state = cpuidle_enter_freeze(drv, dev); - if (entered_state >= 0) { + if (entered_state > 0) { local_irq_enable(); goto exit_idle; }