[PATCH] 2.6 ppc64 RTAS: use dynamic buffer size

Paul Mackerras paulus at samba.org
Sat Jul 24 06:41:56 EST 2004


Linas Vepstas writes:

> heh. I wondered if anyone would notice.. Yes, put this line back to
> where it used to be.
>
> Silly me, for a moment there, I was thinking that firmware was looking
> at this value and so I was desperately trying to make sure it was
> right; I need'nt have worried. I realized this right after I hit
> "send" on email ...
>
> > The rest of it looks fine. If you agree that this hunk can go, I'll
> > send the rest of it upstream.
>
> Yep, Just make sure that 'rets' is set somewhere in there, anywhere
> (e.g. put this line back to how it used to be).

In fact I wasn't quite correct, since the next line dereferenced
err_args.rets.  However, it isn't necessary to set either
err_args.rets or rtas.args.rets in that function, since neither
enter_rtas() nor RTAS itself look at that field.

How about this patch instead?

Regards,
Paul.

diff -urN linux-2.5/arch/ppc64/kernel/rtas.c test25/arch/ppc64/kernel/rtas.c
--- linux-2.5/arch/ppc64/kernel/rtas.c	2004-07-06 08:43:03.000000000 +1000
+++ test25/arch/ppc64/kernel/rtas.c	2004-07-24 05:22:16.716914216 +1000
@@ -22,7 +22,6 @@
 #include <asm/rtas.h>
 #include <asm/semaphore.h>
 #include <asm/machdep.h>
-#include <asm/paca.h>
 #include <asm/page.h>
 #include <asm/param.h>
 #include <asm/system.h>
@@ -73,7 +72,6 @@
 	return tokp ? *tokp : RTAS_UNKNOWN_SERVICE;
 }

-
 /** Return a copy of the detailed error text associated with the
  *  most recent failed call to rtas.  Because the error text
  *  might go stale if there are any other intervening rtas calls,
@@ -84,28 +82,32 @@
 __fetch_rtas_last_error(void)
 {
 	struct rtas_args err_args, save_args;
+	u32 bufsz;
+
+	bufsz = rtas_token ("rtas-error-log-max");
+	if ((bufsz == RTAS_UNKNOWN_SERVICE) ||
+	    (bufsz > RTAS_ERROR_LOG_MAX)) {
+		printk (KERN_WARNING "RTAS: bad log buffer size %d\n", bufsz);
+		bufsz = RTAS_ERROR_LOG_MAX;
+	}

 	err_args.token = rtas_token("rtas-last-error");
 	err_args.nargs = 2;
 	err_args.nret = 1;
-	err_args.rets = (rtas_arg_t *)&(err_args.args[2]);

 	err_args.args[0] = (rtas_arg_t)__pa(rtas_err_buf);
-	err_args.args[1] = RTAS_ERROR_LOG_MAX;
+	err_args.args[1] = bufsz;
 	err_args.args[2] = 0;

 	save_args = rtas.args;
 	rtas.args = err_args;

-	PPCDBG(PPCDBG_RTAS, "\tentering rtas with 0x%lx\n",
-	       __pa(&err_args));
 	enter_rtas(__pa(&rtas.args));
-	PPCDBG(PPCDBG_RTAS, "\treturned from rtas ...\n");

 	err_args = rtas.args;
 	rtas.args = save_args;

-	return err_args.rets[0];
+	return err_args.args[2];
 }

 int rtas_call(int token, int nargs, int nret, int *outputs, ...)

** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc64-dev mailing list