linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Laurent Dufour <ldufour@linux.ibm.com>,
	Nicholas Piggin <npiggin@gmail.com>
Subject: [PATCH 11/14] powerpc/rtas: tidy __fetch_rtas_last_error
Date: Tue,  8 Mar 2022 23:50:44 +1000	[thread overview]
Message-ID: <20220308135047.478297-12-npiggin@gmail.com> (raw)
In-Reply-To: <20220308135047.478297-1-npiggin@gmail.com>

__fetch_rtas_last_error can use the same rtas_args as the caller used
for the failed rtas call. It can also use a higher-level helper to
assemble the rtas_args.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/rtas.c | 30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 751a20669669..e047793cbb80 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -385,34 +385,22 @@ static int rtas_last_error_token;
  *  this routine must be called atomically with whatever produced
  *  the error (i.e. with rtas.lock still held from the previous call).
  */
-static char *__fetch_rtas_last_error(char *altbuf)
+static char *__fetch_rtas_last_error(struct rtas_args *args, char *altbuf)
 {
-	struct rtas_args err_args, save_args;
 	u32 bufsz;
 	char *buf = NULL;
+	int ret;
 
 	if (rtas_last_error_token == -1)
 		return NULL;
 
 	bufsz = rtas_get_error_log_max();
 
-	err_args.token = cpu_to_be32(rtas_last_error_token);
-	err_args.nargs = cpu_to_be32(2);
-	err_args.nret = cpu_to_be32(1);
-	err_args.args[0] = cpu_to_be32(__pa(rtas_err_buf));
-	err_args.args[1] = cpu_to_be32(bufsz);
-	err_args.args[2] = 0;
-
-	save_args = rtas.args;
-	rtas.args = err_args;
-
-	do_enter_rtas(__pa(&rtas.args));
-
-	err_args = rtas.args;
-	rtas.args = save_args;
+	ret = raw_rtas_call(args, rtas_last_error_token, 2, 1, NULL,
+				__pa(rtas_err_buf), bufsz);
 
 	/* Log the error in the unlikely case that there was one. */
-	if (unlikely(err_args.args[2] == 0)) {
+	if (unlikely(ret == 0)) {
 		if (altbuf) {
 			buf = altbuf;
 		} else {
@@ -430,8 +418,8 @@ static char *__fetch_rtas_last_error(char *altbuf)
 #define get_errorlog_buffer()	kmalloc(RTAS_ERROR_LOG_MAX, GFP_KERNEL)
 
 #else /* CONFIG_RTAS_ERROR_LOGGING */
-#define __fetch_rtas_last_error(x)	NULL
-#define get_errorlog_buffer()		NULL
+#define __fetch_rtas_last_error(args, x)	NULL
+#define get_errorlog_buffer()			NULL
 #endif
 
 static int notrace va_raw_rtas_call(struct rtas_args *args, int token,
@@ -503,7 +491,7 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
 	/* A -1 return code indicates that the last command couldn't
 	   be completed due to a hardware error. */
 	if (ret == -1)
-		buff_copy = __fetch_rtas_last_error(NULL);
+		buff_copy = __fetch_rtas_last_error(rtas_args, NULL);
 
 	unlock_rtas(s);
 
@@ -1247,7 +1235,7 @@ SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
 	/* A -1 return code indicates that the last command couldn't
 	   be completed due to a hardware error. */
 	if (be32_to_cpu(args.rets[0]) == -1)
-		errbuf = __fetch_rtas_last_error(buff_copy);
+		errbuf = __fetch_rtas_last_error(&rtas.args, buff_copy);
 
 	unlock_rtas(flags);
 
-- 
2.23.0


  parent reply	other threads:[~2022-03-08 13:58 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
2022-03-08 13:50 ` Nicholas Piggin [this message]
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=20220308135047.478297-12-npiggin@gmail.com \
    --to=npiggin@gmail.com \
    --cc=ldufour@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.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 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).