Abolish per-CPU RTAS args

David Gibson david at gibson.dropbear.id.au
Mon Jun 28 11:55:45 EST 2004


On Sun, Jun 27, 2004 at 04:05:19AM -0500, Nathan Lynch wrote:
>
> David Gibson wrote:
> >On Fri, Jun 25, 2004 at 04:25:34PM -0500, Joel Schopp wrote:
> >>cpu 0x0: Vector: 700 (Program Check) at [c0000000005739f0]
> >>   pc: c00000000003ab1c: .rtas_stop_self+0x34/0x70
> >>   lr: c00000000003e25c: .cpu_die+0x30/0x3c
> >>   sp: c000000000573c70
> >>  msr: 8000000000021032
> >> current = 0xc000000000605810
> >> paca    = 0xc000000000574000
> >>   pid   = 0, comm = swapper
> >>enter ? for help
> >>0:mon> t
> >>[c000000000573d00] c00000000003e25c .cpu_die+0x30/0x3c
> >>[c000000000573d70] c000000000014ee8 .default_idle+0xe8/0xec
> >>[c000000000573e00] c0000000000151d0 .cpu_idle+0x2c/0x44
> >>[c000000000573e70] c00000000000c548 .rest_init+0x74/0x8c
> >>[c000000000573ef0] c0000000005218a0 .start_kernel+0x224/0x284
> >>[c000000000573f90] c00000000000c270 .__setup_cpu_power3+0x0/0x4
> >>
> >>Don't have time to investigate this much now, but it looks like the
> >>rtas_stop_self didn't work so well.  Will poke at it next week.
> >
> >
> >Bother.  I wonder if it's hitting the BUG_ON() in there - if you get a
> >chance, can you see if there is a BUG message before it enters xmon?
>
> I don't have a way to test this at the moment, but moving this part
> (from setup.c):
>
> +#if defined(CONFIG_HOTPLUG_CPU) &&  !defined(CONFIG_PPC_PMAC)
> +	rtas_stop_self_args.token = rtas_token("stop-self");
> +#endif /* CONFIG_HOTPLUG_CPU && !CONFIG_PPC_PMAC */
>
> down a few lines to after finish_device_tree() has been called should
> fix it.  rtas_token() won't work until after finish_device_tree()
> has run.

Ah, yes, that would explain it.  Joel, could you test with this
revised patch:

This patch removes the RTAS arguments structure on ppc64 from the
PACA.  The args have to be in the RMO, but since we have a global
spinlock for RTAS anyway, there's no reason to have a separate copy of
the args per-CPU.  This patch replaces the PACA field with a single
instance in the global rtas structure.

The one exception is for the rtas_stop_self() call, which can't take
the lock, because it never returns.  But it has a fixed set of
arguments, so we can use another global instance which is initialized
at boot.

This lets us remove rtas.h from paca.h, which substantially reduces
overall #include hairiness (because paca.h is now, as it wants to be,
a nice low-level structure-defining header which relies on very little
and can safely be included almost anywhere).  Although it does add
some noise to the patch, because a bunch of places relied on the
indirect inclusion of rtas.h, or even more indirect inclusions (see
the hunks applying to eeh.h and current.h!).



Index: working-2.6/arch/ppc64/kernel/rtas.c
===================================================================
--- working-2.6.orig/arch/ppc64/kernel/rtas.c	2004-06-21 11:29:19.000000000 +1000
+++ working-2.6/arch/ppc64/kernel/rtas.c	2004-06-28 11:54:01.775174032 +1000
@@ -68,11 +68,10 @@
 void
 call_rtas_display_status(char c)
 {
-	struct rtas_args *args;
+	struct rtas_args *args = &rtas.args;
 	unsigned long s;

 	spin_lock_irqsave(&rtas.lock, s);
-	args = &(get_paca()->xRtas);

 	args->token = 10;
 	args->nargs = 1;
@@ -113,15 +112,15 @@
 	err_args.args[2] = 0;

 	temp_args = *rtas_args;
-	get_paca()->xRtas = err_args;
+	rtas.args = err_args;

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

-	err_args = get_paca()->xRtas;
-	get_paca()->xRtas = temp_args;
+	err_args = rtas.args;
+	rtas.args = temp_args;

 	return err_args.rets[0];
 }
@@ -159,7 +158,7 @@

 	/* Gotta do something different here, use global lock for now... */
 	spin_lock_irqsave(&rtas.lock, s);
-	rtas_args = &(get_paca()->xRtas);
+	rtas_args = &rtas.args;

 	rtas_args->token = token;
 	rtas_args->nargs = nargs;
@@ -481,9 +480,9 @@

 	spin_lock_irqsave(&rtas.lock, flags);

-	get_paca()->xRtas = args;
-	enter_rtas(__pa(&get_paca()->xRtas));
-	args = get_paca()->xRtas;
+	rtas.args = args;
+	enter_rtas(__pa(&rtas.args));
+	args = rtas.args;

 	spin_unlock_irqrestore(&rtas.lock, flags);

@@ -501,19 +500,23 @@
 }

 #ifdef CONFIG_HOTPLUG_CPU
-/* This version can't take the spinlock. */
+/* This version can't take the spinlock, because it never returns */
+
+struct rtas_args rtas_stop_self_args = {
+	/* The token is initialized for real in setup_system() */
+	.token = RTAS_UNKNOWN_SERVICE,
+	.nargs = 0,
+	.nret = 1,
+	.rets = &rtas_stop_self_args.args[0],
+};

 void rtas_stop_self(void)
 {
-	struct rtas_args *rtas_args = &(get_paca()->xRtas);
+	struct rtas_args *rtas_args = &rtas_stop_self_args;

 	local_irq_disable();

-	rtas_args->token = rtas_token("stop-self");
 	BUG_ON(rtas_args->token == RTAS_UNKNOWN_SERVICE);
-	rtas_args->nargs = 0;
-	rtas_args->nret  = 1;
-	rtas_args->rets  = &(rtas_args->args[0]);

 	printk("%u %u Ready to die...\n",
 	       smp_processor_id(), hard_smp_processor_id());
Index: working-2.6/arch/ppc64/kernel/traps.c
===================================================================
--- working-2.6.orig/arch/ppc64/kernel/traps.c	2004-06-28 11:54:01.477085176 +1000
+++ working-2.6/arch/ppc64/kernel/traps.c	2004-06-28 11:54:01.776173880 +1000
@@ -36,6 +36,7 @@
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <asm/ppcdebug.h>
+#include <asm/rtas.h>

 #ifdef CONFIG_PPC_PSERIES
 /* This is true if we are using the firmware NMI handler (typically LPAR) */
Index: working-2.6/arch/ppc64/kernel/eeh.c
===================================================================
--- working-2.6.orig/arch/ppc64/kernel/eeh.c	2004-06-04 10:53:50.000000000 +1000
+++ working-2.6/arch/ppc64/kernel/eeh.c	2004-06-28 11:54:01.787172208 +1000
@@ -31,6 +31,7 @@
 #include <asm/io.h>
 #include <asm/machdep.h>
 #include <asm/pgtable.h>
+#include <asm/rtas.h>
 #include "pci.h"

 #undef DEBUG
Index: working-2.6/arch/ppc64/kernel/rtc.c
===================================================================
--- working-2.6.orig/arch/ppc64/kernel/rtc.c	2004-05-20 12:57:53.000000000 +1000
+++ working-2.6/arch/ppc64/kernel/rtc.c	2004-06-28 11:54:01.797170688 +1000
@@ -40,6 +40,7 @@
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <asm/time.h>
+#include <asm/rtas.h>

 #include <asm/iSeries/LparData.h>
 #include <asm/iSeries/mf.h>
Index: working-2.6/arch/ppc64/kernel/setup.c
===================================================================
--- working-2.6.orig/arch/ppc64/kernel/setup.c	2004-05-26 11:12:58.000000000 +1000
+++ working-2.6/arch/ppc64/kernel/setup.c	2004-06-28 11:55:54.746169360 +1000
@@ -45,6 +45,7 @@
 #include <asm/btext.h>
 #include <asm/nvram.h>
 #include <asm/system.h>
+#include <asm/rtas.h>

 extern unsigned long klimit;
 /* extern void *stab; */
@@ -255,6 +256,10 @@
 	}
 #endif /* CONFIG_PPC_PMAC */

+#if defined(CONFIG_HOTPLUG_CPU) &&  !defined(CONFIG_PPC_PMAC)
+	rtas_stop_self_args.token = rtas_token("stop-self");
+#endif /* CONFIG_HOTPLUG_CPU && !CONFIG_PPC_PMAC */
+
 	/* Finish initializing the hash table (do the dynamic
 	 * patching for the fast-path hashtable.S code)
 	 */
Index: working-2.6/arch/ppc64/kernel/pSeries_pci.c
===================================================================
--- working-2.6.orig/arch/ppc64/kernel/pSeries_pci.c	2004-05-20 12:57:52.000000000 +1000
+++ working-2.6/arch/ppc64/kernel/pSeries_pci.c	2004-06-28 11:54:01.806169320 +1000
@@ -40,6 +40,7 @@
 #include <asm/ppcdebug.h>
 #include <asm/naca.h>
 #include <asm/iommu.h>
+#include <asm/rtas.h>

 #include "open_pic.h"
 #include "pci.h"
Index: working-2.6/arch/ppc64/kernel/smp.c
===================================================================
--- working-2.6.orig/arch/ppc64/kernel/smp.c	2004-06-09 10:11:50.000000000 +1000
+++ working-2.6/arch/ppc64/kernel/smp.c	2004-06-28 11:54:01.808169016 +1000
@@ -52,6 +52,7 @@
 #include <asm/xics.h>
 #include <asm/cputable.h>
 #include <asm/system.h>
+#include <asm/rtas.h>

 int smp_threads_ready;
 unsigned long cache_decay_ticks;
Index: working-2.6/arch/ppc64/kernel/lparcfg.c
===================================================================
--- working-2.6.orig/arch/ppc64/kernel/lparcfg.c	2004-05-20 12:57:52.000000000 +1000
+++ working-2.6/arch/ppc64/kernel/lparcfg.c	2004-06-28 11:54:01.809168864 +1000
@@ -28,6 +28,7 @@
 #include <asm/iSeries/ItLpPaca.h>
 #include <asm/hvcall.h>
 #include <asm/cputable.h>
+#include <asm/rtas.h>

 #define MODULE_VERS "1.0"
 #define MODULE_NAME "lparcfg"
Index: working-2.6/arch/ppc64/xmon/xmon.c
===================================================================
--- working-2.6.orig/arch/ppc64/xmon/xmon.c	2004-06-21 11:29:19.000000000 +1000
+++ working-2.6/arch/ppc64/xmon/xmon.c	2004-06-28 11:54:01.823166736 +1000
@@ -30,6 +30,7 @@
 #include <asm/paca.h>
 #include <asm/ppcdebug.h>
 #include <asm/cputable.h>
+#include <asm/rtas.h>

 #include "nonstdio.h"
 #include "privinst.h"
Index: working-2.6/include/asm-ppc64/rtas.h
===================================================================
--- working-2.6.orig/include/asm-ppc64/rtas.h	2004-05-24 11:20:52.000000000 +1000
+++ working-2.6/include/asm-ppc64/rtas.h	2004-06-28 11:54:01.835164912 +1000
@@ -51,18 +51,17 @@
 	u32 nargs;
 	u32 nret;
 	rtas_arg_t args[16];
-#if 0
-	spinlock_t lock;
-#endif
 	rtas_arg_t *rets;     /* Pointer to return values in args[]. */
 };

+extern struct rtas_args rtas_stop_self_args;
+
 struct rtas_t {
 	unsigned long entry;		/* physical address pointer */
 	unsigned long base;		/* physical address pointer */
 	unsigned long size;
 	spinlock_t lock;
-
+	struct rtas_args args;
 	struct device_node *dev;	/* virtual address pointer */
 };

Index: working-2.6/include/asm-ppc64/paca.h
===================================================================
--- working-2.6.orig/include/asm-ppc64/paca.h	2004-06-21 11:29:20.000000000 +1000
+++ working-2.6/include/asm-ppc64/paca.h	2004-06-28 11:54:01.898155336 +1000
@@ -29,7 +29,6 @@
 #include	<asm/iSeries/ItLpPaca.h>
 #include	<asm/iSeries/ItLpRegSave.h>
 #include	<asm/iSeries/ItLpQueue.h>
-#include	<asm/rtas.h>
 #include	<asm/mmu.h>
 #include	<asm/processor.h>

@@ -122,10 +121,9 @@
  * CACHE_LINE_17-18 0x0800 - 0x08FF Reserved
  *=====================================================================================
  */
-	struct rtas_args xRtas;		/* Per processor RTAS struct */
 	u64 xR1;			/* r1 save for RTAS calls */
 	u64 xSavedMsr;			/* Old msr saved here by HvCall */
-	u8 rsvd5[256-16-sizeof(struct rtas_args)];
+	u8 rsvd5[256-16];

 /*=====================================================================================
  * CACHE_LINE_19-30 0x0900 - 0x0EFF Reserved
Index: working-2.6/include/asm-ppc64/eeh.h
===================================================================
--- working-2.6.orig/include/asm-ppc64/eeh.h	2004-06-22 09:56:21.000000000 +1000
+++ working-2.6/include/asm-ppc64/eeh.h	2004-06-28 11:54:01.909153664 +1000
@@ -24,6 +24,7 @@
 #include <linux/init.h>

 struct pci_dev;
+struct device_node;

 /* I/O addresses are converted to EEH "tokens" such that a driver will cause
  * a bad page fault if the address is used directly (i.e. these addresses are
Index: working-2.6/include/asm-ppc64/current.h
===================================================================
--- working-2.6.orig/include/asm-ppc64/current.h	2004-06-09 10:11:50.000000000 +1000
+++ working-2.6/include/asm-ppc64/current.h	2004-06-28 11:54:01.971144240 +1000
@@ -10,8 +10,6 @@
  * 2 of the License, or (at your option) any later version.
  */

-#include <asm/thread_info.h>
-
 #define get_current()   (get_paca()->xCurrent)
 #define current         get_current()

Index: working-2.6/drivers/pci/hotplug/rpadlpar_core.c
===================================================================
--- working-2.6.orig/drivers/pci/hotplug/rpadlpar_core.c	2004-05-20 12:58:18.000000000 +1000
+++ working-2.6/drivers/pci/hotplug/rpadlpar_core.c	2004-06-28 11:54:01.980142872 +1000
@@ -18,6 +18,7 @@
 #include <linux/pci.h>
 #include <asm/pci-bridge.h>
 #include <asm/semaphore.h>
+#include <asm/rtas.h>
 #include "../pci.h"
 #include "rpaphp.h"
 #include "rpadlpar.h"
Index: working-2.6/drivers/pci/hotplug/rpaphp_pci.c
===================================================================
--- working-2.6.orig/drivers/pci/hotplug/rpaphp_pci.c	2004-05-20 12:58:18.000000000 +1000
+++ working-2.6/drivers/pci/hotplug/rpaphp_pci.c	2004-06-28 11:54:01.981142720 +1000
@@ -24,6 +24,7 @@
  */
 #include <linux/pci.h>
 #include <asm/pci-bridge.h>
+#include <asm/rtas.h>
 #include "../pci.h"		/* for pci_add_new_bus */

 #include "rpaphp.h"
Index: working-2.6/drivers/pci/hotplug/rpaphp_slot.c
===================================================================
--- working-2.6.orig/drivers/pci/hotplug/rpaphp_slot.c	2004-05-20 12:58:18.000000000 +1000
+++ working-2.6/drivers/pci/hotplug/rpaphp_slot.c	2004-06-28 11:54:01.982142568 +1000
@@ -27,6 +27,7 @@
 #include <linux/kobject.h>
 #include <linux/sysfs.h>
 #include <linux/pci.h>
+#include <asm/rtas.h>
 #include "rpaphp.h"

 static ssize_t location_read_file (struct hotplug_slot *php_slot, char *buf)



--
David Gibson			| For every complex problem there is a
david AT gibson.dropbear.id.au	| solution which is simple, neat and
				| wrong.
http://www.ozlabs.org/people/dgibson

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





More information about the Linuxppc64-dev mailing list