diff options
| -rw-r--r-- | arch/ia64/mm/contig.c | 74 |
1 files changed, 41 insertions, 33 deletions
diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c index d3c538be466c..7e9c275ea148 100644 --- a/arch/ia64/mm/contig.c +++ b/arch/ia64/mm/contig.c | |||
| @@ -146,6 +146,46 @@ find_bootmap_location (unsigned long start, unsigned long end, void *arg) | |||
| 146 | return 0; | 146 | return 0; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | #ifdef CONFIG_SMP | ||
| 150 | static void *cpu_data; | ||
| 151 | /** | ||
| 152 | * per_cpu_init - setup per-cpu variables | ||
| 153 | * | ||
| 154 | * Allocate and setup per-cpu data areas. | ||
| 155 | */ | ||
| 156 | void * __cpuinit | ||
| 157 | per_cpu_init (void) | ||
| 158 | { | ||
| 159 | int cpu; | ||
| 160 | static int first_time=1; | ||
| 161 | |||
| 162 | /* | ||
| 163 | * get_free_pages() cannot be used before cpu_init() done. BSP | ||
| 164 | * allocates "NR_CPUS" pages for all CPUs to avoid that AP calls | ||
| 165 | * get_zeroed_page(). | ||
| 166 | */ | ||
| 167 | if (first_time) { | ||
| 168 | first_time=0; | ||
| 169 | for (cpu = 0; cpu < NR_CPUS; cpu++) { | ||
| 170 | memcpy(cpu_data, __phys_per_cpu_start, __per_cpu_end - __per_cpu_start); | ||
| 171 | __per_cpu_offset[cpu] = (char *) cpu_data - __per_cpu_start; | ||
| 172 | cpu_data += PERCPU_PAGE_SIZE; | ||
| 173 | per_cpu(local_per_cpu_offset, cpu) = __per_cpu_offset[cpu]; | ||
| 174 | } | ||
| 175 | } | ||
| 176 | return __per_cpu_start + __per_cpu_offset[smp_processor_id()]; | ||
| 177 | } | ||
| 178 | |||
| 179 | static inline void | ||
| 180 | alloc_per_cpu_data(void) | ||
| 181 | { | ||
| 182 | cpu_data = __alloc_bootmem(PERCPU_PAGE_SIZE * NR_CPUS, | ||
| 183 | PERCPU_PAGE_SIZE, __pa(MAX_DMA_ADDRESS)); | ||
| 184 | } | ||
| 185 | #else | ||
| 186 | #define alloc_per_cpu_data() do { } while (0) | ||
| 187 | #endif /* CONFIG_SMP */ | ||
| 188 | |||
| 149 | /** | 189 | /** |
| 150 | * find_memory - setup memory map | 190 | * find_memory - setup memory map |
| 151 | * | 191 | * |
| @@ -182,41 +222,9 @@ find_memory (void) | |||
| 182 | 222 | ||
| 183 | find_initrd(); | 223 | find_initrd(); |
| 184 | 224 | ||
| 225 | alloc_per_cpu_data(); | ||
| 185 | } | 226 | } |
| 186 | 227 | ||
| 187 | #ifdef CONFIG_SMP | ||
| 188 | /** | ||
| 189 | * per_cpu_init - setup per-cpu variables | ||
| 190 | * | ||
| 191 | * Allocate and setup per-cpu data areas. | ||
| 192 | */ | ||
| 193 | void * __cpuinit | ||
| 194 | per_cpu_init (void) | ||
| 195 | { | ||
| 196 | void *cpu_data; | ||
| 197 | int cpu; | ||
| 198 | static int first_time=1; | ||
| 199 | |||
| 200 | /* | ||
| 201 | * get_free_pages() cannot be used before cpu_init() done. BSP | ||
| 202 | * allocates "NR_CPUS" pages for all CPUs to avoid that AP calls | ||
| 203 | * get_zeroed_page(). | ||
| 204 | */ | ||
| 205 | if (first_time) { | ||
| 206 | first_time=0; | ||
| 207 | cpu_data = __alloc_bootmem(PERCPU_PAGE_SIZE * NR_CPUS, | ||
| 208 | PERCPU_PAGE_SIZE, __pa(MAX_DMA_ADDRESS)); | ||
| 209 | for (cpu = 0; cpu < NR_CPUS; cpu++) { | ||
| 210 | memcpy(cpu_data, __phys_per_cpu_start, __per_cpu_end - __per_cpu_start); | ||
| 211 | __per_cpu_offset[cpu] = (char *) cpu_data - __per_cpu_start; | ||
| 212 | cpu_data += PERCPU_PAGE_SIZE; | ||
| 213 | per_cpu(local_per_cpu_offset, cpu) = __per_cpu_offset[cpu]; | ||
| 214 | } | ||
| 215 | } | ||
| 216 | return __per_cpu_start + __per_cpu_offset[smp_processor_id()]; | ||
| 217 | } | ||
| 218 | #endif /* CONFIG_SMP */ | ||
| 219 | |||
| 220 | static int | 228 | static int |
| 221 | count_pages (u64 start, u64 end, void *arg) | 229 | count_pages (u64 start, u64 end, void *arg) |
| 222 | { | 230 | { |
