From: Laurent Dufour <ldufour@linux.ibm.com>
To: Nicholas Piggin <npiggin@gmail.com>, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 10/14] powerpc/rtas: replace rtas_call_unlocked with raw_rtas_call
Date: Mon, 14 Mar 2022 18:30:28 +0100 [thread overview]
Message-ID: <a39f804c-bb3d-4842-d035-5a1a685efb27@linux.ibm.com> (raw)
In-Reply-To: <20220308135047.478297-11-npiggin@gmail.com>
On 08/03/2022, 14:50:43, Nicholas Piggin wrote:
> Use the same calling and rets return convention with the raw rtas
> call rather than requiring callers to load and byteswap return
> values out of rtas_args.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Despite a minor comment below
Reviewed-by: Laurent Dufour <ldufour@linux.ibm.com>
> ---
> arch/powerpc/include/asm/rtas.h | 4 +-
> arch/powerpc/kernel/rtas.c | 53 +++++++++++---------
> arch/powerpc/platforms/pseries/hotplug-cpu.c | 2 +-
> arch/powerpc/platforms/pseries/ras.c | 7 +--
> arch/powerpc/xmon/xmon.c | 2 +-
> 5 files changed, 33 insertions(+), 35 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
> index 82e5b055fa2a..1014ff140cf8 100644
> --- a/arch/powerpc/include/asm/rtas.h
> +++ b/arch/powerpc/include/asm/rtas.h
> @@ -241,8 +241,8 @@ extern int rtas_token(const char *service);
> extern int rtas_service_present(const char *service);
> extern int rtas_call(int token, int, int, int *, ...);
> int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...);
> -void rtas_call_unlocked(struct rtas_args *args, int token, int nargs,
> - int nret, ...);
> +int raw_rtas_call(struct rtas_args *args, int token,
> + int nargs, int nret, int *outputs, ...);
Minor, would it be better to keep the "unlocked" suffix to advise that the
rtas lock is not held here?
> extern void __noreturn rtas_restart(char *cmd);
> extern void rtas_power_off(void);
> extern void __noreturn rtas_halt(void);
> diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
> index fece066115f0..751a20669669 100644
> --- a/arch/powerpc/kernel/rtas.c
> +++ b/arch/powerpc/kernel/rtas.c
> @@ -123,7 +123,7 @@ static void call_rtas_display_status(unsigned char c)
> return;
>
> s = lock_rtas();
> - rtas_call_unlocked(&rtas.args, 10, 1, 1, NULL, c);
> + raw_rtas_call(&rtas.args, 10, 1, 1, NULL, c);
> unlock_rtas(s);
> }
>
> @@ -434,10 +434,9 @@ static char *__fetch_rtas_last_error(char *altbuf)
> #define get_errorlog_buffer() NULL
> #endif
>
> -
> -static void
> -va_rtas_call_unlocked(struct rtas_args *args, int token, int nargs, int nret,
> - va_list list)
> +static int notrace va_raw_rtas_call(struct rtas_args *args, int token,
> + int nargs, int nret, int *outputs,
> + va_list list)
> {
> int i;
>
> @@ -453,21 +452,37 @@ va_rtas_call_unlocked(struct rtas_args *args, int token, int nargs, int nret,
> args->rets[i] = 0;
>
> do_enter_rtas(__pa(args));
> +
> + if (nret > 1 && outputs != NULL) {
> + for (i = 0; i < nret-1; ++i)
> + outputs[i] = be32_to_cpu(args->rets[i+1]);
> + }
> +
> + return (nret > 0) ? be32_to_cpu(args->rets[0]) : 0;
> }
>
> -void rtas_call_unlocked(struct rtas_args *args, int token, int nargs, int nret, ...)
> +/*
> + * Like rtas_call but no kmalloc or printk etc in error handling, so
> + * error won't go through log_error. No tracing, may be called in real mode.
> + * rtas_args must be supplied, and appropriate synchronization for the rtas
> + * call being made has to be performed by the caller.
> + */
> +int notrace raw_rtas_call(struct rtas_args *args, int token,
> + int nargs, int nret, int *outputs, ...)
> {
> va_list list;
> + int ret;
>
> - va_start(list, nret);
> - va_rtas_call_unlocked(args, token, nargs, nret, list);
> + va_start(list, outputs);
> + ret = va_raw_rtas_call(args, token, nargs, nret, outputs, list);
> va_end(list);
> +
> + return ret;
> }
>
> int rtas_call(int token, int nargs, int nret, int *outputs, ...)
> {
> va_list list;
> - int i;
> unsigned long s;
> struct rtas_args *rtas_args;
> char *buff_copy = NULL;
> @@ -482,19 +497,14 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
> rtas_args = &rtas.args;
>
> va_start(list, outputs);
> - va_rtas_call_unlocked(rtas_args, token, nargs, nret, list);
> + ret = va_raw_rtas_call(rtas_args, token, nargs, nret, outputs, list);
> va_end(list);
>
> /* A -1 return code indicates that the last command couldn't
> be completed due to a hardware error. */
> - if (be32_to_cpu(rtas_args->rets[0]) == -1)
> + if (ret == -1)
> buff_copy = __fetch_rtas_last_error(NULL);
>
> - if (nret > 1 && outputs != NULL)
> - for (i = 0; i < nret-1; ++i)
> - outputs[i] = be32_to_cpu(rtas_args->rets[i+1]);
> - ret = (nret > 0)? be32_to_cpu(rtas_args->rets[0]): 0;
> -
> unlock_rtas(s);
>
> if (buff_copy) {
> @@ -950,7 +960,7 @@ int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...)
> va_list list;
> struct rtas_args *args;
> unsigned long flags;
> - int i, ret = 0;
> + int ret;
>
> if (!rtas.entry || token == RTAS_UNKNOWN_SERVICE)
> return -1;
> @@ -962,16 +972,9 @@ int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...)
> args = local_paca->rtas_args_reentrant;
>
> va_start(list, outputs);
> - va_rtas_call_unlocked(args, token, nargs, nret, list);
> + ret = va_raw_rtas_call(args, token, nargs, nret, outputs, list);
> va_end(list);
>
> - if (nret > 1 && outputs)
> - for (i = 0; i < nret - 1; ++i)
> - outputs[i] = be32_to_cpu(args->rets[i + 1]);
> -
> - if (nret > 0)
> - ret = be32_to_cpu(args->rets[0]);
> -
> local_irq_restore(flags);
> preempt_enable();
>
> diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
> index b81fc846d99c..17c05650b6b9 100644
> --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
> +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
> @@ -53,7 +53,7 @@ static void rtas_stop_self(void)
>
> BUG_ON(rtas_stop_self_token == RTAS_UNKNOWN_SERVICE);
>
> - rtas_call_unlocked(&args, rtas_stop_self_token, 0, 1, NULL);
> + raw_rtas_call(&args, rtas_stop_self_token, 0, 1, NULL);
>
> panic("Alas, I survived.\n");
> }
> diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
> index 74c9b1b5bc66..b009ed7de1ee 100644
> --- a/arch/powerpc/platforms/pseries/ras.c
> +++ b/arch/powerpc/platforms/pseries/ras.c
> @@ -465,12 +465,7 @@ static void fwnmi_release_errinfo(void)
> struct rtas_args rtas_args;
> int ret;
>
> - /*
> - * On pseries, the machine check stack is limited to under 4GB, so
> - * args can be on-stack.
> - */
> - rtas_call_unlocked(&rtas_args, ibm_nmi_interlock_token, 0, 1, NULL);
> - ret = be32_to_cpu(rtas_args.rets[0]);
> + ret = raw_rtas_call(&rtas_args, ibm_nmi_interlock_token, 0, 1, NULL);
> if (ret != 0)
> printk(KERN_ERR "FWNMI: nmi-interlock failed: %d\n", ret);
> }
> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> index fd72753e8ad5..6f53e8bccc33 100644
> --- a/arch/powerpc/xmon/xmon.c
> +++ b/arch/powerpc/xmon/xmon.c
> @@ -410,7 +410,7 @@ static inline void disable_surveillance(void)
> if (set_indicator_token == RTAS_UNKNOWN_SERVICE)
> return;
>
> - rtas_call_unlocked(&args, set_indicator_token, 3, 1, NULL,
> + raw_rtas_call(&args, set_indicator_token, 3, 1, NULL,
> SURVEILLANCE_TOKEN, 0, 0);
>
> #endif /* CONFIG_PPC_PSERIES */
next prev parent reply other threads:[~2022-03-14 17:31 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-08 13:50 [PATCH 00/14] powerpc/rtas: various cleanups and improvements Nicholas Piggin
2022-03-08 13:50 ` [PATCH 01/14] powerpc/rtas: Move rtas entry assembly into its own file Nicholas Piggin
2022-03-08 13:50 ` [PATCH 02/14] powerpc/rtas: Make enter_rtas a nokprobe symbol on 64-bit Nicholas Piggin
2022-03-08 13:50 ` [PATCH 03/14] powerpc/rtas: Fix whitespace in rtas_entry.S Nicholas Piggin
2022-03-08 13:50 ` [PATCH 04/14] powerpc/rtas: Call enter_rtas with MSR[EE] disabled Nicholas Piggin
2022-03-14 15:12 ` Laurent Dufour
2022-03-08 13:50 ` [PATCH 05/14] powerpc/rtas: Modernise RI clearing on 64-bit Nicholas Piggin
2022-03-14 15:15 ` Laurent Dufour
2022-03-08 13:50 ` [PATCH 06/14] powerpc/rtas: Load rtas entry MSR explicitly Nicholas Piggin
2022-03-14 15:17 ` Laurent Dufour
2022-03-08 13:50 ` [PATCH 07/14] powerpc/rtas: PACA can be restored directly from SPRG Nicholas Piggin
2022-03-14 15:32 ` Laurent Dufour
2022-03-08 13:50 ` [PATCH 08/14] powerpc/rtas: call enter_rtas in real-mode on 64-bit Nicholas Piggin
2022-03-14 17:09 ` Laurent Dufour
2022-03-17 9:36 ` Laurent Dufour
2022-03-08 13:50 ` [PATCH 09/14] powerpc/rtas: Leave MSR[RI] enabled over RTAS call Nicholas Piggin
2022-03-14 17:17 ` Laurent Dufour
2022-03-08 13:50 ` [PATCH 10/14] powerpc/rtas: replace rtas_call_unlocked with raw_rtas_call Nicholas Piggin
2022-03-14 17:30 ` Laurent Dufour [this message]
2022-03-08 13:50 ` [PATCH 11/14] powerpc/rtas: tidy __fetch_rtas_last_error Nicholas Piggin
2022-03-08 13:50 ` [PATCH 12/14] powerpc/rtas: Close theoretical memory leak Nicholas Piggin
2022-03-15 17:17 ` Laurent Dufour
2022-03-08 13:50 ` [PATCH 13/14] powerpc/rtas: enture rtas_call is called with MMU enabled Nicholas Piggin
2022-03-15 17:18 ` Laurent Dufour
2022-03-08 13:50 ` [PATCH 14/14] powerpc/rtas: Consolidate and improve checking for rtas callers Nicholas Piggin
2022-03-15 17:26 ` Laurent Dufour
2022-03-08 14:51 ` [PATCH 00/14] powerpc/rtas: various cleanups and improvements Christophe Leroy
2022-03-17 11:15 ` Laurent Dufour
2022-05-24 11:08 ` Michael Ellerman
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=a39f804c-bb3d-4842-d035-5a1a685efb27@linux.ibm.com \
--to=ldufour@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).