From patchwork Fri Oct 23 14:46:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 7473271 Return-Path: X-Original-To: patchwork-linux-arm@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 252399F6E4 for ; Fri, 23 Oct 2015 14:48:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 355BF2089B for ; Fri, 23 Oct 2015 14:48:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 59C26205D1 for ; Fri, 23 Oct 2015 14:48:38 +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 1Zpdc6-0008K1-57; Fri, 23 Oct 2015 14:46:38 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zpdc1-0008Hr-PJ for linux-arm-kernel@lists.infradead.org; Fri, 23 Oct 2015 14:46:34 +0000 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 B19D23C; Fri, 23 Oct 2015 07:46:04 -0700 (PDT) Received: from red-moon.cambridge.arm.com (red-moon.cambridge.arm.com [10.1.203.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EBB893F49B; Fri, 23 Oct 2015 07:46:08 -0700 (PDT) From: Lorenzo Pieralisi To: arm@kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] drivers: psci: make PSCI 1.0 functions initialization version dependent Date: Fri, 23 Oct 2015 15:46:50 +0100 Message-Id: <1445611610-12871-1-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.5.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151023_074633_844975_7AF1BB04 X-CRM114-Status: GOOD ( 13.25 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Lorenzo Pieralisi , Arnd Bergmann , Kevin Hilman , Sudeep Holla , Olof Johansson 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 The PSCI specifications [1] and the SMC calling convention mandate that unimplemented functions ids must return NOT_SUPPORTED (0xffffffff) if a function id is called but it is not implemented. Consequently, PSCI 1.0 function ids that require the 1.0 PSCI_FEATURES call to be initialized: CPU_SUSPEND (psci_init_cpu_suspend()) SYSTEM_SUSPEND (psci_init_system_suspend()) call the PSCI_FEATURES function id independently of the detected PSCI firmware version, since, if the PSCI_FEATURES function id is not implemented, it must return NOT_SUPPORTED according to the PSCI specifications, causing the initialization functions to fail as expected. Some existing PSCI implementations (ie Qemu PSCI emulation), do not comply with the SMC calling convention and fail if function ids that are not implemented are called from the OS, causing boot failures. To solve this issue, this patch adds code that checks the PSCI firmware version before calling PSCI 1.0 initialization functions so that the OS makes sure that it is calling 1.0 functions only if the firmware version detected is 1.0 or greater, therefore avoiding PSCI calls that are bound to fail and might cause system boot failures owing to non-compliant PSCI firmware implementations. [1] http://infocenter.arm.com/help/topic/com.arm.doc.den0022c/DEN0022C_Power_State_Coordination_Interface.pdf Signed-off-by: Lorenzo Pieralisi Cc: Arnd Bergmann Cc: Kevin Hilman Cc: Sudeep Holla Cc: Olof Johansson Cc: Mark Rutland Acked-by: Sudeep Holla Tested-by: Kevin Hilman --- Arnd, Kevin, Olof, this applies to current arm-soc drivers/psci branch, and solves the issue Kevin detected through kernelci with Qemu emulation: http://lists.infradead.org/pipermail/linux-arm-kernel/2015-October/380304.html Tested on: - Juno host - AMD Seattle host - kvmtool arm64 guest (on Juno arm64 defconfig host) - Qemu x86 host (aarch64 emulation) A run on kernelci and consequent tested-by tags would be much appreciated, thanks for spotting this and for your help. Thanks, Lorenzo drivers/firmware/psci.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 492db42..d24f35d 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -347,9 +347,10 @@ static int __init psci_probe(void) psci_init_migrate(); - psci_init_cpu_suspend(); - - psci_init_system_suspend(); + if (PSCI_VERSION_MAJOR(ver) >= 1) { + psci_init_cpu_suspend(); + psci_init_system_suspend(); + } return 0; }