aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/paca.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/kernel/paca.c')
-rw-r--r--arch/powerpc/kernel/paca.c93
1 files changed, 71 insertions, 22 deletions
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
index d16b1ea55d44..0c40c6f476fe 100644
--- a/arch/powerpc/kernel/paca.c
+++ b/arch/powerpc/kernel/paca.c
@@ -9,11 +9,15 @@
9 9
10#include <linux/threads.h> 10#include <linux/threads.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/lmb.h>
12 13
14#include <asm/firmware.h>
13#include <asm/lppaca.h> 15#include <asm/lppaca.h>
14#include <asm/paca.h> 16#include <asm/paca.h>
15#include <asm/sections.h> 17#include <asm/sections.h>
16#include <asm/pgtable.h> 18#include <asm/pgtable.h>
19#include <asm/iseries/lpar_map.h>
20#include <asm/iseries/hv_types.h>
17 21
18/* This symbol is provided by the linker - let it fill in the paca 22/* This symbol is provided by the linker - let it fill in the paca
19 * field correctly */ 23 * field correctly */
@@ -70,37 +74,82 @@ struct slb_shadow slb_shadow[] __cacheline_aligned = {
70 * processors. The processor VPD array needs one entry per physical 74 * processors. The processor VPD array needs one entry per physical
71 * processor (not thread). 75 * processor (not thread).
72 */ 76 */
73struct paca_struct paca[NR_CPUS]; 77struct paca_struct *paca;
74EXPORT_SYMBOL(paca); 78EXPORT_SYMBOL(paca);
75 79
76void __init initialise_pacas(void) 80struct paca_struct boot_paca;
77{
78 int cpu;
79 81
80 /* The TOC register (GPR2) points 32kB into the TOC, so that 64kB 82void __init initialise_paca(struct paca_struct *new_paca, int cpu)
81 * of the TOC can be addressed using a single machine instruction. 83{
82 */ 84 /* The TOC register (GPR2) points 32kB into the TOC, so that 64kB
85 * of the TOC can be addressed using a single machine instruction.
86 */
83 unsigned long kernel_toc = (unsigned long)(&__toc_start) + 0x8000UL; 87 unsigned long kernel_toc = (unsigned long)(&__toc_start) + 0x8000UL;
84 88
85 /* Can't use for_each_*_cpu, as they aren't functional yet */
86 for (cpu = 0; cpu < NR_CPUS; cpu++) {
87 struct paca_struct *new_paca = &paca[cpu];
88
89#ifdef CONFIG_PPC_BOOK3S 89#ifdef CONFIG_PPC_BOOK3S
90 new_paca->lppaca_ptr = &lppaca[cpu]; 90 new_paca->lppaca_ptr = &lppaca[cpu];
91#else 91#else
92 new_paca->kernel_pgd = swapper_pg_dir; 92 new_paca->kernel_pgd = swapper_pg_dir;
93#endif 93#endif
94 new_paca->lock_token = 0x8000; 94 new_paca->lock_token = 0x8000;
95 new_paca->paca_index = cpu; 95 new_paca->paca_index = cpu;
96 new_paca->kernel_toc = kernel_toc; 96 new_paca->kernel_toc = kernel_toc;
97 new_paca->kernelbase = (unsigned long) _stext; 97 new_paca->kernelbase = (unsigned long) _stext;
98 new_paca->kernel_msr = MSR_KERNEL; 98 new_paca->kernel_msr = MSR_KERNEL;
99 new_paca->hw_cpu_id = 0xffff; 99 new_paca->hw_cpu_id = 0xffff;
100 new_paca->__current = &init_task; 100 new_paca->__current = &init_task;
101#ifdef CONFIG_PPC_STD_MMU_64 101#ifdef CONFIG_PPC_STD_MMU_64
102 new_paca->slb_shadow_ptr = &slb_shadow[cpu]; 102 new_paca->slb_shadow_ptr = &slb_shadow[cpu];
103#endif /* CONFIG_PPC_STD_MMU_64 */ 103#endif /* CONFIG_PPC_STD_MMU_64 */
104}
105
106static int __initdata paca_size;
107
108void __init allocate_pacas(void)
109{
110 int nr_cpus, cpu, limit;
111
112 /*
113 * We can't take SLB misses on the paca, and we want to access them
114 * in real mode, so allocate them within the RMA and also within
115 * the first segment. On iSeries they must be within the area mapped
116 * by the HV, which is HvPagesToMap * HVPAGESIZE bytes.
117 */
118 limit = min(0x10000000ULL, lmb.rmo_size);
119 if (firmware_has_feature(FW_FEATURE_ISERIES))
120 limit = min(limit, HvPagesToMap * HVPAGESIZE);
121
122 nr_cpus = NR_CPUS;
123 /* On iSeries we know we can never have more than 64 cpus */
124 if (firmware_has_feature(FW_FEATURE_ISERIES))
125 nr_cpus = min(64, nr_cpus);
126
127 paca_size = PAGE_ALIGN(sizeof(struct paca_struct) * nr_cpus);
128
129 paca = __va(lmb_alloc_base(paca_size, PAGE_SIZE, limit));
130 memset(paca, 0, paca_size);
131
132 printk(KERN_DEBUG "Allocated %u bytes for %d pacas at %p\n",
133 paca_size, nr_cpus, paca);
134
135 /* Can't use for_each_*_cpu, as they aren't functional yet */
136 for (cpu = 0; cpu < nr_cpus; cpu++)
137 initialise_paca(&paca[cpu], cpu);
138}
139
140void __init free_unused_pacas(void)
141{
142 int new_size;
143
144 new_size = PAGE_ALIGN(sizeof(struct paca_struct) * num_possible_cpus());
145
146 if (new_size >= paca_size)
147 return;
148
149 lmb_free(__pa(paca) + new_size, paca_size - new_size);
150
151 printk(KERN_DEBUG "Freed %u bytes for unused pacas\n",
152 paca_size - new_size);
104 153
105 } 154 paca_size = new_size;
106} 155}