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: 162006 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp5919969jan; Wed, 10 Apr 2019 01:20:48 -0700 (PDT) X-Received: by 2002:a2e:5bcc:: with SMTP id m73mr13965423lje.100.1554884448378; Wed, 10 Apr 2019 01:20:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554884448; cv=none; d=google.com; s=arc-20160816; b=JMh8RrGcn17FXbEz6HTvoi7raSjtfSJ8DeC9j1uGUstTQAIbL5vhhebnT7/5dSh2DE OnH1XICOf1lkATYQARq/ZhAVfq1+HUVw38j4Z/m6KOdZnGZKzuw2gzF5Gzh36sKNrdqI zx2rFNCmGb8ZRa+/5WR0tLVuHwlC+HwEn3mTsnc9yf7DnRtPbwTsqLel9aMLNA+YPxBZ xM+Uur8EapnPm9XHwqgm+5EIzgmTdrVpByzLW8uuhtftx5i6LiFemtycNe1QHDggoNA8 +WUnxPxTlNa7tkpw7PtVf0MZuE2Th+3S3rWQL1lGUS+sv5Zuh8q2jEWSGuCvlghlha9E NlXA== 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=Banb0evWf9d74deC+eVu1j3AR6/07snxz97O2u3NDpvYwCC4kXCvov5uQT04GgdKne say1UZgnQaZkqWS5xCNJZwKz+1daQUuwnCwXb/JiiB8Rv6bbOgR3+/Onc9sRDQxNPP+V zQ6X7SHN7CspgW2Ru7JyGVtG8hVTlIhE31HxFhnE/UGNSFkEtmk6FcClaSmUYVZLYjtZ 3Gqhhh5T5c6z6qvgmk082RTK7FEkJVBwDT5qMLtLHli621wDWVVZyaP5R3/44B53Yb7E jorXAMouA8nWjGRMrRmsu6A83Zt2Ixw8l2fFoLN5q1UTMEpS+Sl0M8nbxN8LVUWp71Z5 P9dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mStHv7QU; 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 y5sor3368434lfh.66.2019.04.10.01.20.48 for (Google Transport Security); Wed, 10 Apr 2019 01:20:48 -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=mStHv7QU; 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=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=Th4GUd/XIKLoGK90HVbeKZeK/fGKntPsBtbkUNX2bE09qaYVdsByvI3ntazY5/UB7g +YkuJKDY28KGaztul8sBU4sUlnrMBW+2NB98ZVkgQVYk4r5HDPQtcZEXk7isMVeAZanC HcHySR67DeFNj+X3pQc4GS0bVUOdlgJnZrjhBgcVvCch7TgmAjbW0qeDrs1UouD3vLJA Xa67SEzlorfY37OPw2WqVkuAF2xT+MCbuoDTvir/zGKs4NdJVznGbYunxlkoqqXOifvc sbtvD4WejSu2ZEzgsWx2TB7LIGSv+xt6UU8zFcMa/TtvO/iHM5+ofj0xwWQRI2txRJbl WCOA== X-Gm-Message-State: APjAAAXtc6m5Tz1hmpH+GxJmTUhGhdtAiBpE1BNglXXHfNH69hj3O6yn ojpsV7uchSCNqWMBxJixAh/qtmGG 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) 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 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 Cc: Lorenzo Pieralisi , Sudeep Holla , Mark Rutland , Daniel Lezcano , Lina Iyer , Ulf Hansson , linux-arm-kernel@lists.infradead.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> 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