From patchwork Wed May 2 10:30:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 134826 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp513033lji; Wed, 2 May 2018 03:30:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqQBG0NyIRHPvG9tCScrlTCBFc8cCZScH44kKlYVXv1O7RTwiKey4Qs61CTs8CjpaTp3c0F X-Received: by 2002:a65:5047:: with SMTP id k7-v6mr15400400pgo.93.1525257017165; Wed, 02 May 2018 03:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525257017; cv=none; d=google.com; s=arc-20160816; b=RqUMfJ1yPMMq4pDq9aLMqhzPUfmF3IViRibtyMniIBZ8DCFHX/bAk4L3GGv19h+mfm zFat5tlXKjfJe1957BIBUfyy8wfOhWeQo2KUjwQoq4uKV5jb2hElHJw2HGTSFaUmKkgN R2iA0e8miy4VmLNCesTBd/PJV6JN8zFeaSHWKpmcUhs286OokTH50eP4ZlgAqm1Jiz/G uqNvsK4eaczBrGn6X6OKPBBMxEMbaYG6vZMcyXlEZSV40K10uBVbfVmlZZ/IypN6GnqQ UELkDWb5npNZRHsGY1S/x6nqff3wE3AkNTLwYLb1tdIPX9zFnfcAqVU+pmNYrLNtac5W /cTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=mk5YKzgMy2Rgyw5rS1huUJz+wFNLKCukbLoV/jHcLfY=; b=BzKbJklaruktf/vui2Kmlpc8CuHD+F7pemr0lZVqAOiQsNarqbCltgyWZrw98FMXy3 33LF53NTUXaERucbqSiA2iZM/nOdGXK9F2D/ctxwDS5sO9Y3MDRSMoIifvlQljh7R5+M 1Y7haOZON/k07m31FTvyVoTWKn7HypWFtE9B2CUcBJOm4BueuIUAPIJ0Ub/1f+mINJ1M qNr+jeDS//33lLLda2wMihN6/+OhSUJNRIsab+1cR/zkw6j/IX2y4s9i+1u0OcnVFNzG t4HBx1BbOSkLqyRlVdcl+AsKk9IqBj7N6qNnHKL0G6fnOegJuyDbLPcBcOjOsgxb91g0 bxtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s88si11580381pfe.290.2018.05.02.03.30.16; Wed, 02 May 2018 03:30:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751202AbeEBKaP (ORCPT + 29 others); Wed, 2 May 2018 06:30:15 -0400 Received: from foss.arm.com ([217.140.101.70]:56854 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751011AbeEBKaL (ORCPT ); Wed, 2 May 2018 06:30:11 -0400 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 64CDB1435; Wed, 2 May 2018 03:30:11 -0700 (PDT) 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 E01693F487; Wed, 2 May 2018 03:30:09 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Will Wong , Florian Fainelli , Sudeep Holla , Mark Rutland , Lorenzo Pieralisi Subject: [PATCH v2] firmware/psci: add support for SYSTEM_RESET2 Date: Wed, 2 May 2018 11:30:03 +0100 Message-Id: <1525257003-8608-1-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525186288-536-1-git-send-email-sudeep.holla@arm.com> References: <1525186288-536-1-git-send-email-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PSCI v1.1 introduced SYSTEM_RESET2 to allow both architectural resets where the semantics are described by the PSCI specification itself as well as vendor-specific resets. Currently only system warm reset semantics is defined as part of architectural resets by the specification. This patch implements support for SYSTEM_RESET2 by making using of reboot_mode passed by the reboot infrastructure in the kernel. Cc: Mark Rutland Cc: Lorenzo Pieralisi Signed-off-by: Sudeep Holla --- drivers/firmware/psci.c | 21 +++++++++++++++++++++ include/uapi/linux/psci.h | 2 ++ 2 files changed, 23 insertions(+) v1->v2: - Added mising static anotation to psci_system_reset2_supported - Added missing ')' in the comment -- 2.7.4 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index c80ec1d03274..91748725534e 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -88,6 +88,7 @@ static u32 psci_function_id[PSCI_FN_MAX]; PSCI_1_0_EXT_POWER_STATE_TYPE_MASK) static u32 psci_cpu_suspend_feature; +static bool psci_system_reset2_supported; static inline bool psci_has_ext_power_state(void) { @@ -253,6 +254,15 @@ static int get_set_conduit_method(struct device_node *np) static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd) { + if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) && + psci_system_reset2_supported) + /* + * reset_type[31] = 0 (architectural) + * reset_type[30:0] = 0 (SYSTEM_WARM_RESET) + * cookie = 0 (ignored by the implementation) + */ + invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), 0, 0, 0); + invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0); } @@ -451,6 +461,16 @@ static const struct platform_suspend_ops psci_suspend_ops = { .enter = psci_system_suspend_enter, }; +static void __init psci_init_system_reset2(void) +{ + int ret; + + ret = psci_features(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2)); + + if (ret != PSCI_RET_NOT_SUPPORTED) + psci_system_reset2_supported = true; +} + static void __init psci_init_system_suspend(void) { int ret; @@ -588,6 +608,7 @@ static int __init psci_probe(void) psci_init_smccc(); psci_init_cpu_suspend(); psci_init_system_suspend(); + psci_init_system_reset2(); } return 0; diff --git a/include/uapi/linux/psci.h b/include/uapi/linux/psci.h index b3bcabe380da..5b0ba0062541 100644 --- a/include/uapi/linux/psci.h +++ b/include/uapi/linux/psci.h @@ -49,8 +49,10 @@ #define PSCI_1_0_FN_PSCI_FEATURES PSCI_0_2_FN(10) #define PSCI_1_0_FN_SYSTEM_SUSPEND PSCI_0_2_FN(14) +#define PSCI_1_1_FN_SYSTEM_RESET2 PSCI_0_2_FN(18) #define PSCI_1_0_FN64_SYSTEM_SUSPEND PSCI_0_2_FN64(14) +#define PSCI_1_1_FN64_SYSTEM_RESET2 PSCI_0_2_FN64(18) /* PSCI v0.2 power state encoding for CPU_SUSPEND function */ #define PSCI_0_2_POWER_STATE_ID_MASK 0xffff