From: hanjun.guo@linaro.org (Hanjun Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv2 05/12] arm64: psci: support unsigned return values
Date: Tue, 19 May 2015 16:25:31 +0800 [thread overview]
Message-ID: <555AF37B.9050300@linaro.org> (raw)
In-Reply-To: <1431945503-6939-6-git-send-email-mark.rutland@arm.com>
On 2015?05?18? 18:38, Mark Rutland wrote:
> PSCI_VERSION and MIGRATE_INFO_TYPE_UP_CPU return unsigned values, with
> the latter returning a 64-bit value. However, the PSCI invocation
> functions have prototypes returning int.
>
> This patch upgrades the invocation functions to return unsigned long,
> with a new typedef to keep things legible. As PSCI_VERSION cannot return
> a negative value, the erroneous check against PSCI_RET_NOT_SUPPORTED is
> also removed. The unrelated psci_initcall_t typedef is moved closer to
> its first user, to avoid confusion with the invocation functions.
>
> In preparation for sharing the code with ARM, unsigned long is used in
> preference of u64. In the SMC32 calling convention, the relevant fields
> will be 32 bits wide.
>
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> ---
> arch/arm64/kernel/psci.c | 47 ++++++++++++++++++-----------------------------
> 1 file changed, 18 insertions(+), 29 deletions(-)
>
> diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c
> index 66b5b75..9c4de4b 100644
> --- a/arch/arm64/kernel/psci.c
> +++ b/arch/arm64/kernel/psci.c
> @@ -56,11 +56,11 @@ struct psci_operations {
>
> static struct psci_operations psci_ops;
>
> -static int (*invoke_psci_fn)(u64, u64, u64, u64);
> -typedef int (*psci_initcall_t)(const struct device_node *);
> -
> -asmlinkage int __invoke_psci_fn_hvc(u64, u64, u64, u64);
> -asmlinkage int __invoke_psci_fn_smc(u64, u64, u64, u64);
> +typedef unsigned long (psci_fn)(unsigned long, unsigned long,
> + unsigned long, unsigned long);
> +asmlinkage psci_fn __invoke_psci_fn_hvc;
> +asmlinkage psci_fn __invoke_psci_fn_smc;
> +static psci_fn *invoke_psci_fn;
>
> enum psci_function {
> PSCI_FN_CPU_SUSPEND,
> @@ -112,12 +112,9 @@ static void psci_power_state_unpack(u32 power_state,
> PSCI_0_2_POWER_STATE_AFFL_SHIFT;
> }
>
> -static int psci_get_version(void)
> +static u32 psci_get_version(void)
> {
> - int err;
> -
> - err = invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
> - return err;
> + return invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
> }
>
> static int psci_cpu_suspend(struct psci_power_state state,
> @@ -293,25 +290,15 @@ static void __init psci_0_2_set_functions(void)
> */
> static int __init psci_probe(void)
> {
> - int ver = psci_get_version();
> -
> - if (ver == PSCI_RET_NOT_SUPPORTED) {
> - /*
> - * PSCI versions >=0.2 mandates implementation of
> - * PSCI_VERSION.
> - */
> - pr_err("PSCI firmware does not comply with the v0.2 spec.\n");
> - return -EOPNOTSUPP;
> - } else {
> - pr_info("PSCIv%d.%d detected in firmware.\n",
> - PSCI_VERSION_MAJOR(ver),
> - PSCI_VERSION_MINOR(ver));
> -
> - if (PSCI_VERSION_MAJOR(ver) == 0 &&
> - PSCI_VERSION_MINOR(ver) < 2) {
> - pr_err("Conflicting PSCI version detected.\n");
> - return -EINVAL;
> - }
> + u32 ver = psci_get_version();
> +
> + pr_info("PSCIv%d.%d detected in firmware.\n",
> + PSCI_VERSION_MAJOR(ver),
> + PSCI_VERSION_MINOR(ver));
> +
> + if (PSCI_VERSION_MAJOR(ver) == 0 && PSCI_VERSION_MINOR(ver) < 2) {
> + pr_err("Conflicting PSCI version detected.\n");
> + return -EINVAL;
simplified the code both for DT and ACPI,
Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org>
Thanks
Hanjun
next prev parent reply other threads:[~2015-05-19 8:25 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-18 10:38 [PATCHv2 00/12] arm/arm64: Unify PSCI client support Mark Rutland
2015-05-18 10:38 ` [PATCHv2 01/12] arm/arm64: kvm: add missing PSCI include Mark Rutland
2015-05-19 3:37 ` Hanjun Guo
2015-05-18 10:38 ` [PATCHv2 02/12] arm64: smp_plat: add get_logical_index Mark Rutland
2015-05-18 17:09 ` Catalin Marinas
2015-05-18 17:55 ` Mark Rutland
2015-05-19 3:47 ` Hanjun Guo
2015-05-19 8:31 ` Catalin Marinas
2015-05-19 9:10 ` Mark Rutland
2015-05-18 10:38 ` [PATCHv2 03/12] arm64: smp: consistently use error codes Mark Rutland
2015-05-18 17:21 ` Catalin Marinas
2015-05-19 8:17 ` Hanjun Guo
2015-05-18 10:38 ` [PATCHv2 04/12] arm64: psci: remove unnecessary id indirection Mark Rutland
2015-05-18 17:28 ` Catalin Marinas
2015-05-19 8:21 ` Hanjun Guo
2015-05-18 10:38 ` [PATCHv2 05/12] arm64: psci: support unsigned return values Mark Rutland
2015-05-18 17:29 ` Catalin Marinas
2015-05-19 8:25 ` Hanjun Guo [this message]
2015-05-18 10:38 ` [PATCHv2 06/12] arm64: psci: account for Trusted OS instances Mark Rutland
2015-05-18 17:33 ` Catalin Marinas
2015-05-18 10:38 ` [PATCHv2 07/12] arm64: psci: kill psci_power_state Mark Rutland
2015-05-18 17:36 ` Catalin Marinas
2015-05-18 18:11 ` Mark Rutland
2015-05-18 10:38 ` [PATCHv2 08/12] arm64: psci: remove ACPI coupling Mark Rutland
2015-05-18 17:38 ` Catalin Marinas
2015-05-19 8:40 ` Hanjun Guo
2015-05-19 9:18 ` Mark Rutland
2015-05-18 10:38 ` [PATCHv2 09/12] arm64: psci: factor invocation code to drivers Mark Rutland
2015-05-18 17:40 ` Catalin Marinas
2015-05-19 8:46 ` Hanjun Guo
2015-05-18 10:38 ` [PATCHv2 10/12] drivers: psci: support native SMC{32,64} calls Mark Rutland
2015-05-18 17:43 ` Catalin Marinas
2015-05-18 17:49 ` Mark Rutland
2015-05-18 10:38 ` [PATCHv2 11/12] ARM: migrate to common PSCI client code Mark Rutland
2015-05-18 17:45 ` Catalin Marinas
2015-05-18 10:38 ` [PATCHv2 12/12] MAINTAINERS: add PSCI entry Mark Rutland
2015-05-18 17:45 ` Catalin Marinas
2015-05-18 17:49 ` [PATCHv2 00/12] arm/arm64: Unify PSCI client support Catalin Marinas
2015-05-19 9:03 ` Lorenzo Pieralisi
2015-05-19 9:32 ` Mark Rutland
2015-05-19 15:20 ` Catalin Marinas
2015-05-19 8:54 ` Hanjun Guo
2015-05-19 9:33 ` Mark Rutland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=555AF37B.9050300@linaro.org \
--to=hanjun.guo@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.