From patchwork Wed Apr 10 08:20:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10893461 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 D50911708 for ; Wed, 10 Apr 2019 08:21:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC3381FF7F for ; Wed, 10 Apr 2019 08:21:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B07DB28A12; Wed, 10 Apr 2019 08:21:46 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 45F631FF7F for ; Wed, 10 Apr 2019 08:21:46 +0000 (UTC) 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=HdJDnHrkj1RO7au3kz+OtYdOyK FilyZBJjXp1vz6CLZWfx8dQgLsqP+37WUO7mEADgmoeDKhEY8cTuU220A/dcPkVYjALcouFqJt49v +dfFQci5t1QF7bgA6iPn08Pte3VMFxb58l3HY8QdY0tx0biG13qmyNAJGSt+WccZnLQFavdFFh8Vi 4ju7VM8FlK4Y2hc6w2nKy5c6LdBe2+9qxpXSeNiKw2W7bmG5evL5Exl1vkWM1ReG9SXqFPPhhtUtF 6jx8yJORCSXhcRCaFTQudLPsswMZSrqCs5uf1SRGWkuOiBm1fI/1XndrQBrwOOLiqueHwreZSl2JN 30sOucHg==; 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 1hE8UF-0000y5-Rw; Wed, 10 Apr 2019 08:21:39 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hE8TR-0008RH-Kr for linux-arm-kernel@lists.infradead.org; Wed, 10 Apr 2019 08:20:54 +0000 Received: by mail-lf1-x143.google.com with SMTP id u24so1119795lfg.5 for ; Wed, 10 Apr 2019 01:20:49 -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=mStHv7QUTH9WDAupaSoNiNHXq56uKPHs6z21Ns4cq2pgt6lYuIwF2y1ydobFZDFkgN k46Q2SZP5ZgY7T277FQDd6kZnntXGYuzX9TiN6F5abjLive7ssOU6xL3aArZ7KC9+Dgo aHOYlHx4xjPDV3fLfRxyNPRR4uDwhdR/a8rh8vP21tjqnO8zoAHY12H2DkMr2VtjyBP9 6MFFADfsLqamKiTq8M1UMjcQbDTzOITDphS+3jEsuZ9QAfSjZdz+Ay288jDWx9ePXqQa pgn8qz6S6UdQDq6t8JNpI4NkYKFB0Ufrc9RruysJpogLhp2ykoAua+bK1LHZf8NcjcuM 7jZA== 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=gEtKBfdjCekqTZ1l+guYfpd06Te7NnOAr5k0IrYba+rcS3rdJO3nO1cRNrO5yGFmYN 0SD4JTEUmJh778SJ6Dgq99s4mpb/2j/h8wzrod9X0Pfj7MUi+6pcnSRjLI7NvB8Re24+ qMDAKCpfbKRXx345BBzXHc96dXboLUUBbzN6S1DgnMcDq44mPM93Gu/SxmlGmO4kTIV+ doNrMATnFhL0VLGY4zeJ5eYHalJbaRz4ObUuyskam672Si0KrezXf+2pXmH+dQBTDuJH byUhBKena1Lvgi4lhLm+YJXHz6fx79azSyGuhPm/7i0R9gaR6N22ZH9qAQtS87dkd7c/ BF+g== X-Gm-Message-State: APjAAAXorM6KFIxO0AJ/kZC8pLN8U3fm1VqBg+GlgZRrt6FBstrVgRPj v1ALXUCl5HFzpJSVOtfv8DjbRQ== X-Google-Smtp-Source: APXvYqwAQdMdf457/T9VKsq8AbW6qHKBEEhAwtd9AMaQ5kzkjyEFANj/vSnEWMDgy3/QbndrOfTM5w== X-Received: by 2002:ac2:5222:: with SMTP id i2mr13231765lfl.32.1554884447978; Wed, 10 Apr 2019 01:20:47 -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 q6sm3385189lfj.36.2019.04.10.01.20.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 01:20:47 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Subject: [RESEND PATCH v2 5/5] drivers: firmware: psci: Announce support for OS initiated suspend mode Date: Wed, 10 Apr 2019 10:20:25 +0200 Message-Id: <20190410082025.5989-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190410082025.5989-1-ulf.hansson@linaro.org> References: <20190410082025.5989-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190410_012049_935807_023F866D X-CRM114-Status: GOOD ( 14.82 ) 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 , Lorenzo Pieralisi , Daniel Lezcano , Lina Iyer , Sudeep Holla , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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