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: 160211 Delivered-To: patches@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp14045781jad; Wed, 13 Mar 2019 01:37:12 -0700 (PDT) X-Received: by 2002:a2e:2c0d:: with SMTP id s13mr23832430ljs.96.1552466232819; Wed, 13 Mar 2019 01:37:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552466232; cv=none; d=google.com; s=arc-20160816; b=Azg+eWXYwj7sQWtRPK4pP9wsLPbDnumgku6S9Ex5R6vtjt8hJh9RQcYIpJl94V4BrN tTA572b2Yugv2b+ICR209oY6z3UjkD8k43lRTFc4K3UXlfdlwwDr8eZ9UYT5BOusZwXQ gjrXLAmmMeMdrYepYxu2+I04mblCWcF86hHAWuLXjUHdcYQWCdcEqJeYFB/467sUcuvE NBRhlYCCkJfrQOrCqeDgm7GpHB7SX5oX1LJwfJLR9imXWtelZucAhphjGFYFoPLZsLXS 0IYhyP7ocbb/eC1qGFr9ZD/ecYbpYfmdVuCj5U0huuCj6le4emqCm/AIs5aI/KgdlBbJ H0zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=49oAUcefl7Qs60t5vd0C3ulsmkkBE/5vo7x8P2YQaHM=; b=ql02whM55v+DSm4SlglCaL6+TpNVAlMf5zKD/AlwMfJBV+7kzxa002r0njaMLV7Sr7 21oeTxoExmj82svlpf5fP9ZXHwWpG0Mh6+7m9Ud82KWqcxJtVqNxdVHK21VTpWJGdwcP u2Ngju2L9jRLZse7KT7tp6eC6uhRVdOlFJFZgbSeNyvooGf4jx/58AwQX4Z9KjRBEkIV Q3ZUnbGf9cqL9tjOELlHjEsf/QlHdG/xKbJ4PafhbVlGhdEy7ID6HMJGPFOKwcs0ENEp ueWIp15ZTxgErnZJMcIWip8bYHXSDRYcn1GGkC8ZWDjMCLD/9G+1SY2JnOXp41iX6uo8 3IvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AaW900pJ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id u67sor6521120lja.6.2019.03.13.01.37.12 for (Google Transport Security); Wed, 13 Mar 2019 01:37:12 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AaW900pJ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=ZwcJRSvjbJJIyLKWz4XHoP2ubLswLz5L3ROp49BGwG0h3joojaGzYpr4pKuDQZB4dQ FUbOmxmpMYcZc50VY6gs18ek4SCxR8fPzIuZ8vyzhN3XdaMkwJw/CpJTUb08FuTMPLKf wOd35GZGx3NnzMh9DPsCSPglFCnxxoGgaoLDB8uUuJg0d/bMyQtlt0JD6I6JQ2YSXFXF 0ERVy1oHMB+iin0+cubyf2+KHOde5qyfIfSuBl6ukmbXzayhcO+x1xvjzy3HATZSQHS8 fjSNUVKtkd2N8jYIbwO2B972bqzd7nsroeoJ30U0xOKwWn6jUIy0tbbCJksQ1a/wpMsL f1Ng== X-Gm-Message-State: APjAAAVKIG71Y/HgwYogdDkRG6ecwVRRP2P+6kkYww0OWrMT/TEcs366 apmpiW6uuVb3XqyijBjqFxg5+BQ+ 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) Return-Path: 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> 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(-) -- 2.17.1 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