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: 5193321 Return-Path: X-Original-To: patchwork-linux-arm@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 01BBCC11AC for ; Thu, 30 Oct 2014 03:58:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 445B6201FE for ; Thu, 30 Oct 2014 03:58:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF8BF201C7 for ; Thu, 30 Oct 2014 03:58:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XjgqY-0001As-7t; Thu, 30 Oct 2014 03:56:26 +0000 Received: from mail-pa0-x22c.google.com ([2607:f8b0:400e:c03::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XjgqG-0000xq-8A for linux-arm-kernel@lists.infradead.org; Thu, 30 Oct 2014 03:56:08 +0000 Received: by mail-pa0-f44.google.com with SMTP id bj1so4568860pad.17 for ; Wed, 29 Oct 2014 20:55:47 -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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141029_205608_354082_90EAC2DB X-CRM114-Status: GOOD ( 12.81 ) X-Spam-Score: -0.7 (/) Cc: Mark Rutland , Catalin Marinas , Vladimir Murzin , Lorenzo Pieralisi , Ashwin Chaugule X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,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.