From patchwork Wed Mar 13 08:36:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10850715 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B1181390 for ; Wed, 13 Mar 2019 08:37:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 381C0298F1 for ; Wed, 13 Mar 2019 08:37:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2BCB829A9C; Wed, 13 Mar 2019 08:37:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7EEA298F1 for ; Wed, 13 Mar 2019 08:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727315AbfCMIhQ (ORCPT ); Wed, 13 Mar 2019 04:37:16 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:36473 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727307AbfCMIhO (ORCPT ); Wed, 13 Mar 2019 04:37:14 -0400 Received: by mail-lj1-f193.google.com with SMTP id v10so761149lji.3 for ; Wed, 13 Mar 2019 01:37:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=49oAUcefl7Qs60t5vd0C3ulsmkkBE/5vo7x8P2YQaHM=; b=AaW900pJqH+ZvraqyUDS8w9k7SNv6l9CJOI6zb+S6ZGSC+ZtfC3ivkC+d1hO8U7zeF vWZvnMcRTcLkzbe0HB8fZu9dSaZQtPfSiFc+vkeFKKEHasb4AkRFa8BwFAiTGsFw7wHw u5wXvEwgKu2yP6sjiYHUjL63Nw4xsq2+SC5c7SIuURaiClnK8+SUcTg54Inu2H+FkAm4 bHO8PPsXCEW3QDaaJ34JrQlPQ9GBrHBj7CtfWCIQ4zM6cXVgj41lCL2Jak84pnuXvkS/ 5lEKE86L+2wi3J2SNJmSryHE+qBIqdZCpyD3Xdx0VLeVRenmgE6jVZeqboxv0xzU7/Uu mj4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=49oAUcefl7Qs60t5vd0C3ulsmkkBE/5vo7x8P2YQaHM=; b=BJPibQnppTED+/G3gyKpCL4mURp76FV0NtNCUchkYRAXee4j3ITaxavadCuMcNB5hs QWTkSC3q8DtVhEnQZpdcPzykPeuZHir3unmHNg6/cXI9J8bL+arLlB9OOS+Feq+IqBmS cPKKGt2N8Ca/VR+la7IXbWFXq0k3qQxAQfrRjeGJLUlmMHbaZq4uVvUIQp25gpBLQ3Kn z8bemyfuG2D7H4e3minLbyDiEbIW/Os91yOYSjyty6BlCr/cKiWry8dWGAMFIx4rnCZi dJksy/RNZyH4QvRzR4d+yRS9FQPEm+4RZMtOAEhWl2RxciOTJ4qeOCWr60Mn3Z7rWiys FwgQ== X-Gm-Message-State: APjAAAXokftcsLF3j0MfA5KhCrH+eVWihWKdHz1m+NcHz43QdV+mgmQd 3bsWyehIvZvbx+PHlF2IYynvgA== X-Google-Smtp-Source: APXvYqwM1UOmFchmb8FVNYUvMVbDbX1oYR4zYTRQUF7J3df0h9Vim0zVOeF0kvjf7PGcN1Mbj1ABKg== X-Received: by 2002:a2e:9204:: with SMTP id k4mr17998616ljg.0.1552466232444; Wed, 13 Mar 2019 01:37:12 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id a23sm1707716ljd.20.2019.03.13.01.37.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 01:37:11 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Lorenzo Pieralisi Cc: Sudeep Holla , Mark Rutland , Daniel Lezcano , Lina Iyer , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/5] drivers: firmware: psci: Announce support for OS initiated suspend mode Date: Wed, 13 Mar 2019 09:36:59 +0100 Message-Id: <20190313083659.7100-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190313083659.7100-1-ulf.hansson@linaro.org> References: <20190313083659.7100-1-ulf.hansson@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP PSCI firmware v1.0+, supports two different modes for CPU_SUSPEND. The Platform Coordinated mode, which is the default and mandatory mode, while support for the OS initiated (OSI) mode is optional. In some cases it's interesting for the user/developer to know if the OSI mode is supported by the PSCI FW. Therefore, let's print a message to the log, if that is the case. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson Reviewed-by: Daniel Lezcano Acked-by: Mark Rutland Acked-by: Lorenzo Pieralisi --- drivers/firmware/psci/psci.c | 21 ++++++++++++++++++++- include/uapi/linux/psci.h | 5 +++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index e480e0af632c..eabd01383cd6 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -95,6 +95,11 @@ static inline bool psci_has_ext_power_state(void) PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK; } +static inline bool psci_has_osi_support(void) +{ + return psci_cpu_suspend_feature & PSCI_1_0_OS_INITIATED; +} + static inline bool psci_power_state_loses_context(u32 state) { const u32 mask = psci_has_ext_power_state() ? @@ -659,10 +664,24 @@ static int __init psci_0_1_init(struct device_node *np) return 0; } +static int __init psci_1_0_init(struct device_node *np) +{ + int err; + + err = psci_0_2_init(np); + if (err) + return err; + + if (psci_has_osi_support()) + pr_info("OSI mode supported.\n"); + + return 0; +} + static const struct of_device_id psci_of_match[] __initconst = { { .compatible = "arm,psci", .data = psci_0_1_init}, { .compatible = "arm,psci-0.2", .data = psci_0_2_init}, - { .compatible = "arm,psci-1.0", .data = psci_0_2_init}, + { .compatible = "arm,psci-1.0", .data = psci_1_0_init}, {}, }; diff --git a/include/uapi/linux/psci.h b/include/uapi/linux/psci.h index b3bcabe380da..581f72085c33 100644 --- a/include/uapi/linux/psci.h +++ b/include/uapi/linux/psci.h @@ -49,6 +49,7 @@ #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_0_FN_SET_SUSPEND_MODE PSCI_0_2_FN(15) #define PSCI_1_0_FN64_SYSTEM_SUSPEND PSCI_0_2_FN64(14) @@ -97,6 +98,10 @@ #define PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK \ (0x1 << PSCI_1_0_FEATURES_CPU_SUSPEND_PF_SHIFT) +#define PSCI_1_0_OS_INITIATED BIT(0) +#define PSCI_1_0_SUSPEND_MODE_PC 0 +#define PSCI_1_0_SUSPEND_MODE_OSI 1 + /* PSCI return values (inclusive of all PSCI versions) */ #define PSCI_RET_SUCCESS 0 #define PSCI_RET_NOT_SUPPORTED -1