From: David Gibson 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!). Signed-off-by: Andrew Morton --- 25-akpm/arch/ppc64/kernel/eeh.c | 1 25-akpm/arch/ppc64/kernel/lparcfg.c | 1 25-akpm/arch/ppc64/kernel/pSeries_pci.c | 1 25-akpm/arch/ppc64/kernel/rtas.c | 35 +++++++++++++++------------- 25-akpm/arch/ppc64/kernel/rtc.c | 1 25-akpm/arch/ppc64/kernel/setup.c | 5 ++++ 25-akpm/arch/ppc64/kernel/smp.c | 1 25-akpm/arch/ppc64/kernel/traps.c | 1 25-akpm/arch/ppc64/xmon/xmon.c | 1 25-akpm/drivers/pci/hotplug/rpadlpar_core.c | 1 25-akpm/drivers/pci/hotplug/rpaphp_pci.c | 1 25-akpm/drivers/pci/hotplug/rpaphp_slot.c | 1 25-akpm/include/asm-ppc64/current.h | 2 - 25-akpm/include/asm-ppc64/eeh.h | 1 25-akpm/include/asm-ppc64/paca.h | 4 --- 25-akpm/include/asm-ppc64/rtas.h | 7 ++--- 16 files changed, 39 insertions(+), 25 deletions(-) diff -puN arch/ppc64/kernel/eeh.c~ppc64-remove-rtas-arguments-from-paca arch/ppc64/kernel/eeh.c --- 25/arch/ppc64/kernel/eeh.c~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.557469880 -0700 +++ 25-akpm/arch/ppc64/kernel/eeh.c 2004-06-29 22:35:48.583465928 -0700 @@ -31,6 +31,7 @@ #include #include #include +#include #include "pci.h" #undef DEBUG diff -puN arch/ppc64/kernel/lparcfg.c~ppc64-remove-rtas-arguments-from-paca arch/ppc64/kernel/lparcfg.c --- 25/arch/ppc64/kernel/lparcfg.c~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.558469728 -0700 +++ 25-akpm/arch/ppc64/kernel/lparcfg.c 2004-06-29 22:35:48.587465320 -0700 @@ -28,6 +28,7 @@ #include #include #include +#include #define MODULE_VERS "1.0" #define MODULE_NAME "lparcfg" diff -puN arch/ppc64/kernel/pSeries_pci.c~ppc64-remove-rtas-arguments-from-paca arch/ppc64/kernel/pSeries_pci.c --- 25/arch/ppc64/kernel/pSeries_pci.c~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.560469424 -0700 +++ 25-akpm/arch/ppc64/kernel/pSeries_pci.c 2004-06-29 22:35:48.586465472 -0700 @@ -40,6 +40,7 @@ #include #include #include +#include #include "open_pic.h" #include "pci.h" diff -puN arch/ppc64/kernel/rtas.c~ppc64-remove-rtas-arguments-from-paca arch/ppc64/kernel/rtas.c --- 25/arch/ppc64/kernel/rtas.c~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.561469272 -0700 +++ 25-akpm/arch/ppc64/kernel/rtas.c 2004-06-29 22:35:48.582466080 -0700 @@ -45,11 +45,10 @@ char rtas_data_buf[RTAS_DATA_BUF_SIZE]__ 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; @@ -90,15 +89,15 @@ __log_rtas_error(struct rtas_args *rtas_ 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]; } @@ -134,7 +133,7 @@ int rtas_call(int token, int nargs, int /* 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; @@ -440,9 +439,9 @@ asmlinkage int ppc_rtas(struct rtas_args 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); @@ -460,19 +459,23 @@ asmlinkage int ppc_rtas(struct rtas_args } #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()); diff -puN arch/ppc64/kernel/rtc.c~ppc64-remove-rtas-arguments-from-paca arch/ppc64/kernel/rtc.c --- 25/arch/ppc64/kernel/rtc.c~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.563468968 -0700 +++ 25-akpm/arch/ppc64/kernel/rtc.c 2004-06-29 22:35:48.584465776 -0700 @@ -40,6 +40,7 @@ #include #include #include +#include #include #include diff -puN arch/ppc64/kernel/setup.c~ppc64-remove-rtas-arguments-from-paca arch/ppc64/kernel/setup.c --- 25/arch/ppc64/kernel/setup.c~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.564468816 -0700 +++ 25-akpm/arch/ppc64/kernel/setup.c 2004-06-29 22:35:48.585465624 -0700 @@ -46,6 +46,7 @@ #include #include #include +#include extern unsigned long klimit; /* extern void *stab; */ @@ -254,6 +255,10 @@ void setup_system(unsigned long r3, unsi } #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) */ diff -puN arch/ppc64/kernel/smp.c~ppc64-remove-rtas-arguments-from-paca arch/ppc64/kernel/smp.c --- 25/arch/ppc64/kernel/smp.c~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.566468512 -0700 +++ 25-akpm/arch/ppc64/kernel/smp.c 2004-06-29 22:35:48.587465320 -0700 @@ -52,6 +52,7 @@ #include #include #include +#include int smp_threads_ready; unsigned long cache_decay_ticks; diff -puN arch/ppc64/kernel/traps.c~ppc64-remove-rtas-arguments-from-paca arch/ppc64/kernel/traps.c --- 25/arch/ppc64/kernel/traps.c~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.567468360 -0700 +++ 25-akpm/arch/ppc64/kernel/traps.c 2004-06-29 22:35:48.583465928 -0700 @@ -36,6 +36,7 @@ #include #include #include +#include #ifdef CONFIG_PPC_PSERIES /* This is true if we are using the firmware NMI handler (typically LPAR) */ diff -puN arch/ppc64/xmon/xmon.c~ppc64-remove-rtas-arguments-from-paca arch/ppc64/xmon/xmon.c --- 25/arch/ppc64/xmon/xmon.c~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.569468056 -0700 +++ 25-akpm/arch/ppc64/xmon/xmon.c 2004-06-29 22:35:48.589465016 -0700 @@ -30,6 +30,7 @@ #include #include #include +#include #include "nonstdio.h" #include "privinst.h" diff -puN drivers/pci/hotplug/rpadlpar_core.c~ppc64-remove-rtas-arguments-from-paca drivers/pci/hotplug/rpadlpar_core.c --- 25/drivers/pci/hotplug/rpadlpar_core.c~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.570467904 -0700 +++ 25-akpm/drivers/pci/hotplug/rpadlpar_core.c 2004-06-29 22:35:48.591464712 -0700 @@ -18,6 +18,7 @@ #include #include #include +#include #include "../pci.h" #include "rpaphp.h" #include "rpadlpar.h" diff -puN drivers/pci/hotplug/rpaphp_pci.c~ppc64-remove-rtas-arguments-from-paca drivers/pci/hotplug/rpaphp_pci.c --- 25/drivers/pci/hotplug/rpaphp_pci.c~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.571467752 -0700 +++ 25-akpm/drivers/pci/hotplug/rpaphp_pci.c 2004-06-29 22:35:48.592464560 -0700 @@ -24,6 +24,7 @@ */ #include #include +#include #include "../pci.h" /* for pci_add_new_bus */ #include "rpaphp.h" diff -puN drivers/pci/hotplug/rpaphp_slot.c~ppc64-remove-rtas-arguments-from-paca drivers/pci/hotplug/rpaphp_slot.c --- 25/drivers/pci/hotplug/rpaphp_slot.c~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.573467448 -0700 +++ 25-akpm/drivers/pci/hotplug/rpaphp_slot.c 2004-06-29 22:35:48.592464560 -0700 @@ -27,6 +27,7 @@ #include #include #include +#include #include "rpaphp.h" static ssize_t removable_read_file (struct hotplug_slot *php_slot, char *buf) diff -puN include/asm-ppc64/current.h~ppc64-remove-rtas-arguments-from-paca include/asm-ppc64/current.h --- 25/include/asm-ppc64/current.h~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.574467296 -0700 +++ 25-akpm/include/asm-ppc64/current.h 2004-06-29 22:35:48.591464712 -0700 @@ -10,8 +10,6 @@ * 2 of the License, or (at your option) any later version. */ -#include - #define get_current() (get_paca()->xCurrent) #define current get_current() diff -puN include/asm-ppc64/eeh.h~ppc64-remove-rtas-arguments-from-paca include/asm-ppc64/eeh.h --- 25/include/asm-ppc64/eeh.h~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.575467144 -0700 +++ 25-akpm/include/asm-ppc64/eeh.h 2004-06-29 22:35:48.590464864 -0700 @@ -24,6 +24,7 @@ #include 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 diff -puN include/asm-ppc64/paca.h~ppc64-remove-rtas-arguments-from-paca include/asm-ppc64/paca.h --- 25/include/asm-ppc64/paca.h~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.577466840 -0700 +++ 25-akpm/include/asm-ppc64/paca.h 2004-06-29 22:35:48.590464864 -0700 @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -122,10 +121,9 @@ struct paca_struct { * 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 diff -puN include/asm-ppc64/rtas.h~ppc64-remove-rtas-arguments-from-paca include/asm-ppc64/rtas.h --- 25/include/asm-ppc64/rtas.h~ppc64-remove-rtas-arguments-from-paca 2004-06-29 22:35:48.578466688 -0700 +++ 25-akpm/include/asm-ppc64/rtas.h 2004-06-29 22:35:48.589465016 -0700 @@ -51,18 +51,17 @@ struct rtas_args { 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 */ }; _