From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ulf Hansson 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> References: <20190313083659.7100-1-ulf.hansson@linaro.org> Return-path: In-Reply-To: <20190313083659.7100-1-ulf.hansson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org 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 List-Id: linux-arm-msm@vger.kernel.org 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 -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6963EC43381 for ; Wed, 13 Mar 2019 10:13:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 364DF2087C for ; Wed, 13 Mar 2019 10:13:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="To3uokoF"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="b/8vSH7i"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AaW900pJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 364DF2087C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=EMq37olOPA83EAQWuNB8Wxr0e6l0oXIGgGRIPnuPKvc=; b=To3uokoFf96iI4p0+5GA1qkWI3 K6hUaT3N48VrMxHj5cqRiF7cigyi9iQZJ9ikxdbaMkni0IGyWtFVv79by162j/FbPI66UtJuQByIu XRDiCw6uc/iNuJu89FFpOUlIpHebe2FqYfpesJk16C5+Wsnkd2GTMNpfyMeT9V4O/lHocI/WHY5dx k4I9UKQ9X1tOV9+9Hvzu/fuj3YoYLGU30SSeOw2ct1Y2jGNoMG3Bf+kyam9P5QFt4GAdmR5GNtpLh oqeHicPEpY/lPjwRS72iYySCXX7a0g+DpsLrp/wnqZAYFhc/Mw7TCWFRRodkFWXH8GKOvHzXK4YV9 5AK1NzZg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h40t3-0006Qm-EM; Wed, 13 Mar 2019 10:13:25 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h40oy-0007jP-Rb for linux-arm-kernel@bombadil.infradead.org; Wed, 13 Mar 2019 10:09:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=49oAUcefl7Qs60t5vd0C3ulsmkkBE/5vo7x8P2YQaHM=; b=b/8vSH7ipnPMKzDSAl3efRjv1 +yD2HeYoWWcvnNabKI5BLmVq27coGLsXnVxa9QFyO/kKl5JzSI/2LD57g1ou/1AihMCj1dRoej3aY 3hezFt8sI523qTKeEXn8hoCgkvBkP3k141rkIxiso+oPGNPNsZ34k6z6arceD7T8DrYv1lsQPaf+1 mHYvWIaKgC9m6D8dckkBJ/BUD/5/gMnupV7FhVNSFDvWFa6H9EZ4Dshxe3kj8y6JD6refQSoJZCh2 Q2DWEFOpckQXP1IWnMrLoAld/IT9MWRWRHffxxtaDypRE3FyRHMgQkh6O0o5v46P/ZFBheUuUQq6K xkw+YSRhg==; Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3zOS-0003Bl-0X for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2019 08:37:45 +0000 Received: by mail-lj1-x241.google.com with SMTP id w6so747792ljd.7 for ; Wed, 13 Mar 2019 01:37:43 -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=mlRD/ZS3yRKjvoVXRq/nNPn3HpQRqIGRlsEz/R9OhjV/vLPGUirX7RLxp94HKs9wmk ouARUsoQfF8E8VmrMffk1EMtN0s9U29rwXC38tq4pR/TYCDNm0y2exwrxQmSonCIzfCO oDUi5i4NVos0KY1BGKLcHkVVSzL8ENASDRnH/j9ffzskSikLqYIgRdp5q/BO7xOdXblj 8lud/PSMSQ4jevwpkIkf5K6LB7ASp/Bh05CH7FU+6OlJjbjhpwj5WJjQ+Ov1/PmOgCLC QkICs7BYsvOgYpLZ8Ie7h6YVNeUfQexFxVToAy4SaKarDYX++irXDt6/4TbMZB+e6o/l yCXQ== X-Gm-Message-State: APjAAAWrdHrJgU2/xvJyEVxKSV1gEb3QpZvp0sI+jMFgp3KGrykFiHln fPsziaISsRHlUTqkfhPlH/ALOw== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190313_083744_156463_C53BF11F X-CRM114-Status: GOOD ( 18.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, Daniel Lezcano , linux-kernel@vger.kernel.org, Lina Iyer , Sudeep Holla , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel