From patchwork Thu Oct 30 03:55:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kachhap X-Patchwork-Id: 5193311 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D5DD0C11AC for ; Thu, 30 Oct 2014 03:56:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9E0A820254 for ; Thu, 30 Oct 2014 03:55:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E3F9A2012D for ; Thu, 30 Oct 2014 03:55:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753430AbaJ3Dzr (ORCPT ); Wed, 29 Oct 2014 23:55:47 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:36731 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752590AbaJ3Dzr (ORCPT ); Wed, 29 Oct 2014 23:55:47 -0400 Received: by mail-pa0-f48.google.com with SMTP id ey11so4566100pad.21 for ; Wed, 29 Oct 2014 20:55:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=bjAXK1DnaXJ2T6rrz8lNYBfOETzhKpOVX0U/snljNLA=; b=iVKOjyvxHkFwKmc9TL7pe8ue9xUXdrcbDf/WCq3riRfG6yZKfuUiGApVMWbd3EXDAm 4jNdWKxaiHnvYkk5aTkFQ58+hoZVHFSG4xOyLNErsIlOWPgG6xPZAWWzvt2sfI1371FC E4BntBrgQcnHrx1o6KFvlDMEsjqcxpbPF4TWJmDrEMgnv36+Rj6tQBBsdl2wJUagtA/8 WoWlI+dhotc4ZGDvFAJLeWsErk8jb32GX+DhxTiKOFaAceKWQrnGh6KnLY8SAykWAn+Z /TdXbF9la6277PpDDFlLofriu/jarzb2329FXwWhSFPy8qAmg7M+OpMxQqrnPOAbV2Pt v49A== X-Received: by 10.68.183.34 with SMTP id ej2mr14226383pbc.75.1414641346626; Wed, 29 Oct 2014 20:55:46 -0700 (PDT) Received: from localhost.localdomain ([14.140.216.146]) by mx.google.com with ESMTPSA id p10sm5669272pds.37.2014.10.29.20.55.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Oct 2014 20:55:46 -0700 (PDT) From: Amit Daniel Kachhap To: linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Cc: Catalin Marinas , Mark Rutland , Lorenzo Pieralisi , Ashwin Chaugule , Vladimir Murzin Subject: [PATCH 3/3] arm64: psci: Add support to call cpu_suspend with deepest C state. Date: Thu, 30 Oct 2014 09:25:38 +0530 Message-Id: <1414641338-25279-3-git-send-email-amit.daniel@samsung.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1414641338-25279-1-git-send-email-amit.daniel@samsung.com> References: <1414641338-25279-1-git-send-email-amit.daniel@samsung.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=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 This feature will be useful for system suspend/resume which may intend to invoke cpu_suspend with deepest possible C state level. Signed-off-by: Amit Daniel Kachhap --- arch/arm64/include/asm/psci.h | 2 ++ arch/arm64/kernel/psci.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/arch/arm64/include/asm/psci.h b/arch/arm64/include/asm/psci.h index e5312ea..487e52b 100644 --- a/arch/arm64/include/asm/psci.h +++ b/arch/arm64/include/asm/psci.h @@ -14,6 +14,8 @@ #ifndef __ASM_PSCI_H #define __ASM_PSCI_H +#define CPU_PSCI_IDLE_INDEX_MAX 0xff + int psci_init(void); #endif /* __ASM_PSCI_H */ diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c index 4ebc146..a761513 100644 --- a/arch/arm64/kernel/psci.c +++ b/arch/arm64/kernel/psci.c @@ -70,6 +70,7 @@ enum psci_function { static DEFINE_PER_CPU_READ_MOSTLY(struct psci_power_state *, psci_power_state); static u32 psci_function_id[PSCI_FN_MAX]; +static u32 cpu_psci_idle_state_count; static int psci_to_linux_errno(int errno) { @@ -239,6 +240,8 @@ static int __maybe_unused cpu_psci_cpu_init_idle(struct device_node *cpu_node, if (!count) return -ENODEV; + cpu_psci_idle_state_count = count; + psci_states = kcalloc(count, sizeof(*psci_states), GFP_KERNEL); if (!psci_states) return -ENOMEM; @@ -521,6 +524,11 @@ static int __maybe_unused cpu_psci_cpu_suspend(unsigned long index) { int ret; struct psci_power_state *state = __get_cpu_var(psci_power_state); + + /* Check and select the deepest idle state */ + if (index == CPU_PSCI_IDLE_INDEX_MAX) + index = cpu_psci_idle_state_count; + /* * idle state index 0 corresponds to wfi, should never be called * from the cpu_suspend operations.