diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2016-07-05 01:07:51 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2016-07-21 05:17:46 -0400 |
commit | b1923caa6e641f3d0a93b5d045aef67ded5aef67 (patch) | |
tree | bfa0d8f2b2f604b86c276a007103586078079f00 /arch/powerpc | |
parent | 009776baa18448b223be73ac74912fef7e17b9e2 (diff) |
powerpc: Merge 32-bit and 64-bit setup_arch()
There is little enough differences now.
mpe: Add a/p/k/setup.h to contain the prototypes and empty versions of
functions we need, rather than using weak functions. Add a few other
empty versions to avoid as many #ifdefs as possible in the code.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/include/asm/rtas.h | 3 | ||||
-rw-r--r-- | arch/powerpc/include/asm/smp.h | 9 | ||||
-rw-r--r-- | arch/powerpc/kernel/setup-common.c | 173 | ||||
-rw-r--r-- | arch/powerpc/kernel/setup.h | 58 | ||||
-rw-r--r-- | arch/powerpc/kernel/setup_32.c | 65 | ||||
-rw-r--r-- | arch/powerpc/kernel/setup_64.c | 175 |
6 files changed, 250 insertions, 233 deletions
diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h index fa3e3c4367bd..9c23baa10b81 100644 --- a/arch/powerpc/include/asm/rtas.h +++ b/arch/powerpc/include/asm/rtas.h | |||
@@ -351,7 +351,6 @@ extern bool rtas_indicator_present(int token, int *maxindex); | |||
351 | extern int rtas_set_indicator(int indicator, int index, int new_value); | 351 | extern int rtas_set_indicator(int indicator, int index, int new_value); |
352 | extern int rtas_set_indicator_fast(int indicator, int index, int new_value); | 352 | extern int rtas_set_indicator_fast(int indicator, int index, int new_value); |
353 | extern void rtas_progress(char *s, unsigned short hex); | 353 | extern void rtas_progress(char *s, unsigned short hex); |
354 | extern void rtas_initialize(void); | ||
355 | extern int rtas_suspend_cpu(struct rtas_suspend_me_data *data); | 354 | extern int rtas_suspend_cpu(struct rtas_suspend_me_data *data); |
356 | extern int rtas_suspend_last_cpu(struct rtas_suspend_me_data *data); | 355 | extern int rtas_suspend_last_cpu(struct rtas_suspend_me_data *data); |
357 | extern int rtas_online_cpus_mask(cpumask_var_t cpus); | 356 | extern int rtas_online_cpus_mask(cpumask_var_t cpus); |
@@ -460,9 +459,11 @@ static inline int page_is_rtas_user_buf(unsigned long pfn) | |||
460 | /* Not the best place to put pSeries_coalesce_init, will be fixed when we | 459 | /* Not the best place to put pSeries_coalesce_init, will be fixed when we |
461 | * move some of the rtas suspend-me stuff to pseries */ | 460 | * move some of the rtas suspend-me stuff to pseries */ |
462 | extern void pSeries_coalesce_init(void); | 461 | extern void pSeries_coalesce_init(void); |
462 | void rtas_initialize(void); | ||
463 | #else | 463 | #else |
464 | static inline int page_is_rtas_user_buf(unsigned long pfn) { return 0;} | 464 | static inline int page_is_rtas_user_buf(unsigned long pfn) { return 0;} |
465 | static inline void pSeries_coalesce_init(void) { } | 465 | static inline void pSeries_coalesce_init(void) { } |
466 | static inline void rtas_initialize(void) { }; | ||
466 | #endif | 467 | #endif |
467 | 468 | ||
468 | extern int call_rtas(const char *, int, int, unsigned long *, ...); | 469 | extern int call_rtas(const char *, int, int, unsigned long *, ...); |
diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h index e1afd4c4f695..0d02c11dc331 100644 --- a/arch/powerpc/include/asm/smp.h +++ b/arch/powerpc/include/asm/smp.h | |||
@@ -160,9 +160,6 @@ static inline void set_hard_smp_processor_id(int cpu, int phys) | |||
160 | { | 160 | { |
161 | paca[cpu].hw_cpu_id = phys; | 161 | paca[cpu].hw_cpu_id = phys; |
162 | } | 162 | } |
163 | |||
164 | extern void smp_release_cpus(void); | ||
165 | |||
166 | #else | 163 | #else |
167 | /* 32-bit */ | 164 | /* 32-bit */ |
168 | #ifndef CONFIG_SMP | 165 | #ifndef CONFIG_SMP |
@@ -179,6 +176,12 @@ static inline void set_hard_smp_processor_id(int cpu, int phys) | |||
179 | #endif /* !CONFIG_SMP */ | 176 | #endif /* !CONFIG_SMP */ |
180 | #endif /* !CONFIG_PPC64 */ | 177 | #endif /* !CONFIG_PPC64 */ |
181 | 178 | ||
179 | #if defined(CONFIG_PPC64) && (defined(CONFIG_SMP) || defined(CONFIG_KEXEC)) | ||
180 | extern void smp_release_cpus(void); | ||
181 | #else | ||
182 | static inline void smp_release_cpus(void) { }; | ||
183 | #endif | ||
184 | |||
182 | extern int smt_enabled_at_boot; | 185 | extern int smt_enabled_at_boot; |
183 | 186 | ||
184 | extern void smp_mpic_probe(void); | 187 | extern void smp_mpic_probe(void); |
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index ca9255e3b763..714b4ba7ab86 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/percpu.h> | 35 | #include <linux/percpu.h> |
36 | #include <linux/memblock.h> | 36 | #include <linux/memblock.h> |
37 | #include <linux/of_platform.h> | 37 | #include <linux/of_platform.h> |
38 | #include <linux/hugetlb.h> | ||
38 | #include <asm/io.h> | 39 | #include <asm/io.h> |
39 | #include <asm/paca.h> | 40 | #include <asm/paca.h> |
40 | #include <asm/prom.h> | 41 | #include <asm/prom.h> |
@@ -61,6 +62,12 @@ | |||
61 | #include <asm/cputhreads.h> | 62 | #include <asm/cputhreads.h> |
62 | #include <mm/mmu_decl.h> | 63 | #include <mm/mmu_decl.h> |
63 | #include <asm/fadump.h> | 64 | #include <asm/fadump.h> |
65 | #include <asm/udbg.h> | ||
66 | #include <asm/hugetlb.h> | ||
67 | #include <asm/livepatch.h> | ||
68 | #include <asm/mmu_context.h> | ||
69 | |||
70 | #include "setup.h" | ||
64 | 71 | ||
65 | #ifdef DEBUG | 72 | #ifdef DEBUG |
66 | #include <asm/udbg.h> | 73 | #include <asm/udbg.h> |
@@ -758,3 +765,169 @@ void arch_setup_pdev_archdata(struct platform_device *pdev) | |||
758 | pdev->dev.dma_mask = &pdev->archdata.dma_mask; | 765 | pdev->dev.dma_mask = &pdev->archdata.dma_mask; |
759 | set_dma_ops(&pdev->dev, &dma_direct_ops); | 766 | set_dma_ops(&pdev->dev, &dma_direct_ops); |
760 | } | 767 | } |
768 | |||
769 | static __init void print_system_info(void) | ||
770 | { | ||
771 | pr_info("-----------------------------------------------------\n"); | ||
772 | #ifdef CONFIG_PPC_STD_MMU_64 | ||
773 | pr_info("ppc64_pft_size = 0x%llx\n", ppc64_pft_size); | ||
774 | #endif | ||
775 | #ifdef CONFIG_PPC_STD_MMU_32 | ||
776 | pr_info("Hash_size = 0x%lx\n", Hash_size); | ||
777 | #endif | ||
778 | pr_info("phys_mem_size = 0x%llx\n", | ||
779 | (unsigned long long)memblock_phys_mem_size()); | ||
780 | |||
781 | pr_info("dcache_bsize = 0x%x\n", dcache_bsize); | ||
782 | pr_info("icache_bsize = 0x%x\n", icache_bsize); | ||
783 | if (ucache_bsize != 0) | ||
784 | pr_info("ucache_bsize = 0x%x\n", ucache_bsize); | ||
785 | |||
786 | pr_info("cpu_features = 0x%016lx\n", cur_cpu_spec->cpu_features); | ||
787 | pr_info(" possible = 0x%016lx\n", | ||
788 | (unsigned long)CPU_FTRS_POSSIBLE); | ||
789 | pr_info(" always = 0x%016lx\n", | ||
790 | (unsigned long)CPU_FTRS_ALWAYS); | ||
791 | pr_info("cpu_user_features = 0x%08x 0x%08x\n", | ||
792 | cur_cpu_spec->cpu_user_features, | ||
793 | cur_cpu_spec->cpu_user_features2); | ||
794 | pr_info("mmu_features = 0x%08x\n", cur_cpu_spec->mmu_features); | ||
795 | #ifdef CONFIG_PPC64 | ||
796 | pr_info("firmware_features = 0x%016lx\n", powerpc_firmware_features); | ||
797 | #endif | ||
798 | |||
799 | #ifdef CONFIG_PPC_STD_MMU_64 | ||
800 | if (htab_address) | ||
801 | pr_info("htab_address = 0x%p\n", htab_address); | ||
802 | if (htab_hash_mask) | ||
803 | pr_info("htab_hash_mask = 0x%lx\n", htab_hash_mask); | ||
804 | #endif | ||
805 | #ifdef CONFIG_PPC_STD_MMU_32 | ||
806 | if (Hash) | ||
807 | pr_info("Hash = 0x%p\n", Hash); | ||
808 | if (Hash_mask) | ||
809 | pr_info("Hash_mask = 0x%lx\n", Hash_mask); | ||
810 | #endif | ||
811 | |||
812 | if (PHYSICAL_START > 0) | ||
813 | pr_info("physical_start = 0x%llx\n", | ||
814 | (unsigned long long)PHYSICAL_START); | ||
815 | pr_info("-----------------------------------------------------\n"); | ||
816 | } | ||
817 | |||
818 | /* | ||
819 | * Called into from start_kernel this initializes memblock, which is used | ||
820 | * to manage page allocation until mem_init is called. | ||
821 | */ | ||
822 | void __init setup_arch(char **cmdline_p) | ||
823 | { | ||
824 | *cmdline_p = boot_command_line; | ||
825 | |||
826 | /* Set a half-reasonable default so udelay does something sensible */ | ||
827 | loops_per_jiffy = 500000000 / HZ; | ||
828 | |||
829 | /* Unflatten the device-tree passed by prom_init or kexec */ | ||
830 | unflatten_device_tree(); | ||
831 | |||
832 | /* | ||
833 | * Initialize cache line/block info from device-tree (on ppc64) or | ||
834 | * just cputable (on ppc32). | ||
835 | */ | ||
836 | initialize_cache_info(); | ||
837 | |||
838 | /* Initialize RTAS if available. */ | ||
839 | rtas_initialize(); | ||
840 | |||
841 | /* Check if we have an initrd provided via the device-tree. */ | ||
842 | check_for_initrd(); | ||
843 | |||
844 | /* Probe the machine type, establish ppc_md. */ | ||
845 | probe_machine(); | ||
846 | |||
847 | /* Setup panic notifier if requested by the platform. */ | ||
848 | setup_panic(); | ||
849 | |||
850 | /* | ||
851 | * Configure ppc_md.power_save (ppc32 only, 64-bit machines do | ||
852 | * it from their respective probe() function. | ||
853 | */ | ||
854 | setup_power_save(); | ||
855 | |||
856 | /* Discover standard serial ports. */ | ||
857 | find_legacy_serial_ports(); | ||
858 | |||
859 | /* Register early console with the printk subsystem. */ | ||
860 | register_early_udbg_console(); | ||
861 | |||
862 | /* Setup the various CPU maps based on the device-tree. */ | ||
863 | smp_setup_cpu_maps(); | ||
864 | |||
865 | /* Initialize xmon. */ | ||
866 | xmon_setup(); | ||
867 | |||
868 | /* Check the SMT related command line arguments (ppc64). */ | ||
869 | check_smt_enabled(); | ||
870 | |||
871 | /* On BookE, setup per-core TLB data structures. */ | ||
872 | setup_tlb_core_data(); | ||
873 | |||
874 | /* | ||
875 | * Release secondary cpus out of their spinloops at 0x60 now that | ||
876 | * we can map physical -> logical CPU ids. | ||
877 | * | ||
878 | * Freescale Book3e parts spin in a loop provided by firmware, | ||
879 | * so smp_release_cpus() does nothing for them. | ||
880 | */ | ||
881 | #ifdef CONFIG_SMP | ||
882 | smp_release_cpus(); | ||
883 | #endif | ||
884 | |||
885 | /* Print various info about the machine that has been gathered so far. */ | ||
886 | print_system_info(); | ||
887 | |||
888 | /* Reserve large chunks of memory for use by CMA for KVM. */ | ||
889 | kvm_cma_reserve(); | ||
890 | |||
891 | /* | ||
892 | * Reserve any gigantic pages requested on the command line. | ||
893 | * memblock needs to have been initialized by the time this is | ||
894 | * called since this will reserve memory. | ||
895 | */ | ||
896 | reserve_hugetlb_gpages(); | ||
897 | |||
898 | klp_init_thread_info(&init_thread_info); | ||
899 | |||
900 | init_mm.start_code = (unsigned long)_stext; | ||
901 | init_mm.end_code = (unsigned long) _etext; | ||
902 | init_mm.end_data = (unsigned long) _edata; | ||
903 | init_mm.brk = klimit; | ||
904 | #ifdef CONFIG_PPC_64K_PAGES | ||
905 | init_mm.context.pte_frag = NULL; | ||
906 | #endif | ||
907 | #ifdef CONFIG_SPAPR_TCE_IOMMU | ||
908 | mm_iommu_init(&init_mm.context); | ||
909 | #endif | ||
910 | irqstack_early_init(); | ||
911 | exc_lvl_early_init(); | ||
912 | emergency_stack_init(); | ||
913 | |||
914 | initmem_init(); | ||
915 | |||
916 | #ifdef CONFIG_DUMMY_CONSOLE | ||
917 | conswitchp = &dummy_con; | ||
918 | #endif | ||
919 | if (ppc_md.setup_arch) | ||
920 | ppc_md.setup_arch(); | ||
921 | |||
922 | paging_init(); | ||
923 | |||
924 | /* Initialize the MMU context management stuff. */ | ||
925 | mmu_context_init(); | ||
926 | |||
927 | #ifdef CONFIG_PPC64 | ||
928 | /* Interrupt code needs to be 64K-aligned. */ | ||
929 | if ((unsigned long)_stext & 0xffff) | ||
930 | panic("Kernelbase not 64K-aligned (0x%lx)!\n", | ||
931 | (unsigned long)_stext); | ||
932 | #endif | ||
933 | } | ||
diff --git a/arch/powerpc/kernel/setup.h b/arch/powerpc/kernel/setup.h new file mode 100644 index 000000000000..cfba134b3024 --- /dev/null +++ b/arch/powerpc/kernel/setup.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | * Prototypes for functions that are shared between setup_(32|64|common).c | ||
3 | * | ||
4 | * Copyright 2016 Michael Ellerman, IBM Corporation. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #ifndef __ARCH_POWERPC_KERNEL_SETUP_H | ||
13 | #define __ARCH_POWERPC_KERNEL_SETUP_H | ||
14 | |||
15 | void initialize_cache_info(void); | ||
16 | void irqstack_early_init(void); | ||
17 | |||
18 | #ifdef CONFIG_PPC32 | ||
19 | void setup_power_save(void); | ||
20 | #else | ||
21 | static inline void setup_power_save(void) { }; | ||
22 | #endif | ||
23 | |||
24 | #if defined(CONFIG_PPC64) && defined(CONFIG_SMP) | ||
25 | void check_smt_enabled(void); | ||
26 | #else | ||
27 | static inline void check_smt_enabled(void) { }; | ||
28 | #endif | ||
29 | |||
30 | #if defined(CONFIG_PPC_BOOK3E) && defined(CONFIG_SMP) | ||
31 | void setup_tlb_core_data(void); | ||
32 | #else | ||
33 | static inline void setup_tlb_core_data(void) { }; | ||
34 | #endif | ||
35 | |||
36 | #if defined(CONFIG_PPC_BOOK3E) || defined(CONFIG_BOOKE) || defined(CONFIG_40x) | ||
37 | void exc_lvl_early_init(void); | ||
38 | #else | ||
39 | static inline void exc_lvl_early_init(void) { }; | ||
40 | #endif | ||
41 | |||
42 | #ifdef CONFIG_PPC64 | ||
43 | void emergency_stack_init(void); | ||
44 | #else | ||
45 | static inline void emergency_stack_init(void) { }; | ||
46 | #endif | ||
47 | |||
48 | /* | ||
49 | * Having this in kvm_ppc.h makes include dependencies too | ||
50 | * tricky to solve for setup-common.c so have it here. | ||
51 | */ | ||
52 | #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE | ||
53 | void kvm_cma_reserve(void); | ||
54 | #else | ||
55 | static inline void kvm_cma_reserve(void) { }; | ||
56 | #endif | ||
57 | |||
58 | #endif /* __ARCH_POWERPC_KERNEL_SETUP_H */ | ||
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 6247a3a4fd4b..00f57754407e 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c | |||
@@ -36,7 +36,6 @@ | |||
36 | #include <asm/time.h> | 36 | #include <asm/time.h> |
37 | #include <asm/serial.h> | 37 | #include <asm/serial.h> |
38 | #include <asm/udbg.h> | 38 | #include <asm/udbg.h> |
39 | #include <asm/mmu_context.h> | ||
40 | #include <asm/code-patching.h> | 39 | #include <asm/code-patching.h> |
41 | 40 | ||
42 | #define DBG(fmt...) | 41 | #define DBG(fmt...) |
@@ -191,7 +190,7 @@ int __init ppc_init(void) | |||
191 | 190 | ||
192 | arch_initcall(ppc_init); | 191 | arch_initcall(ppc_init); |
193 | 192 | ||
194 | static void __init irqstack_early_init(void) | 193 | void __init irqstack_early_init(void) |
195 | { | 194 | { |
196 | unsigned int i; | 195 | unsigned int i; |
197 | 196 | ||
@@ -206,7 +205,7 @@ static void __init irqstack_early_init(void) | |||
206 | } | 205 | } |
207 | 206 | ||
208 | #if defined(CONFIG_BOOKE) || defined(CONFIG_40x) | 207 | #if defined(CONFIG_BOOKE) || defined(CONFIG_40x) |
209 | static void __init exc_lvl_early_init(void) | 208 | void __init exc_lvl_early_init(void) |
210 | { | 209 | { |
211 | unsigned int i, hw_cpu; | 210 | unsigned int i, hw_cpu; |
212 | 211 | ||
@@ -229,11 +228,9 @@ static void __init exc_lvl_early_init(void) | |||
229 | #endif | 228 | #endif |
230 | } | 229 | } |
231 | } | 230 | } |
232 | #else | ||
233 | #define exc_lvl_early_init() | ||
234 | #endif | 231 | #endif |
235 | 232 | ||
236 | static void setup_power_save(void) | 233 | void __init setup_power_save(void) |
237 | { | 234 | { |
238 | #ifdef CONFIG_6xx | 235 | #ifdef CONFIG_6xx |
239 | if (cpu_has_feature(CPU_FTR_CAN_DOZE) || | 236 | if (cpu_has_feature(CPU_FTR_CAN_DOZE) || |
@@ -248,7 +245,7 @@ static void setup_power_save(void) | |||
248 | #endif | 245 | #endif |
249 | } | 246 | } |
250 | 247 | ||
251 | static __init void initialize_cache_info(void) | 248 | __init void initialize_cache_info(void) |
252 | { | 249 | { |
253 | /* | 250 | /* |
254 | * Set cache line size based on type of cpu as a default. | 251 | * Set cache line size based on type of cpu as a default. |
@@ -261,57 +258,3 @@ static __init void initialize_cache_info(void) | |||
261 | if (cpu_has_feature(CPU_FTR_UNIFIED_ID_CACHE)) | 258 | if (cpu_has_feature(CPU_FTR_UNIFIED_ID_CACHE)) |
262 | ucache_bsize = icache_bsize = dcache_bsize; | 259 | ucache_bsize = icache_bsize = dcache_bsize; |
263 | } | 260 | } |
264 | |||
265 | |||
266 | /* Warning, IO base is not yet inited */ | ||
267 | void __init setup_arch(char **cmdline_p) | ||
268 | { | ||
269 | *cmdline_p = boot_command_line; | ||
270 | |||
271 | /* so udelay does something sensible, assume <= 1000 bogomips */ | ||
272 | loops_per_jiffy = 500000000 / HZ; | ||
273 | |||
274 | unflatten_device_tree(); | ||
275 | initialize_cache_info(); | ||
276 | check_for_initrd(); | ||
277 | |||
278 | probe_machine(); | ||
279 | |||
280 | setup_panic(); | ||
281 | |||
282 | setup_power_save(); | ||
283 | |||
284 | find_legacy_serial_ports(); | ||
285 | |||
286 | /* Register early console */ | ||
287 | register_early_udbg_console(); | ||
288 | |||
289 | smp_setup_cpu_maps(); | ||
290 | |||
291 | xmon_setup(); | ||
292 | |||
293 | init_mm.start_code = (unsigned long)_stext; | ||
294 | init_mm.end_code = (unsigned long) _etext; | ||
295 | init_mm.end_data = (unsigned long) _edata; | ||
296 | init_mm.brk = klimit; | ||
297 | |||
298 | exc_lvl_early_init(); | ||
299 | |||
300 | irqstack_early_init(); | ||
301 | |||
302 | initmem_init(); | ||
303 | if ( ppc_md.progress ) ppc_md.progress("setup_arch: initmem", 0x3eab); | ||
304 | |||
305 | #ifdef CONFIG_DUMMY_CONSOLE | ||
306 | conswitchp = &dummy_con; | ||
307 | #endif | ||
308 | |||
309 | if (ppc_md.setup_arch) | ||
310 | ppc_md.setup_arch(); | ||
311 | if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab); | ||
312 | |||
313 | paging_init(); | ||
314 | |||
315 | /* Initialize the MMU context management stuff */ | ||
316 | mmu_context_init(); | ||
317 | } | ||
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index fba96ada3012..d8216aed22b7 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/pci.h> | 35 | #include <linux/pci.h> |
36 | #include <linux/lockdep.h> | 36 | #include <linux/lockdep.h> |
37 | #include <linux/memblock.h> | 37 | #include <linux/memblock.h> |
38 | #include <linux/hugetlb.h> | ||
39 | #include <linux/memory.h> | 38 | #include <linux/memory.h> |
40 | #include <linux/nmi.h> | 39 | #include <linux/nmi.h> |
41 | 40 | ||
@@ -64,12 +63,10 @@ | |||
64 | #include <asm/xmon.h> | 63 | #include <asm/xmon.h> |
65 | #include <asm/udbg.h> | 64 | #include <asm/udbg.h> |
66 | #include <asm/kexec.h> | 65 | #include <asm/kexec.h> |
67 | #include <asm/mmu_context.h> | ||
68 | #include <asm/code-patching.h> | 66 | #include <asm/code-patching.h> |
69 | #include <asm/kvm_ppc.h> | ||
70 | #include <asm/hugetlb.h> | ||
71 | #include <asm/livepatch.h> | 67 | #include <asm/livepatch.h> |
72 | #include <asm/opal.h> | 68 | #include <asm/opal.h> |
69 | #include <asm/cputhreads.h> | ||
73 | 70 | ||
74 | #ifdef DEBUG | 71 | #ifdef DEBUG |
75 | #define DBG(fmt...) udbg_printf(fmt) | 72 | #define DBG(fmt...) udbg_printf(fmt) |
@@ -100,7 +97,7 @@ int icache_bsize; | |||
100 | int ucache_bsize; | 97 | int ucache_bsize; |
101 | 98 | ||
102 | #if defined(CONFIG_PPC_BOOK3E) && defined(CONFIG_SMP) | 99 | #if defined(CONFIG_PPC_BOOK3E) && defined(CONFIG_SMP) |
103 | static void setup_tlb_core_data(void) | 100 | void __init setup_tlb_core_data(void) |
104 | { | 101 | { |
105 | int cpu; | 102 | int cpu; |
106 | 103 | ||
@@ -133,10 +130,6 @@ static void setup_tlb_core_data(void) | |||
133 | } | 130 | } |
134 | } | 131 | } |
135 | } | 132 | } |
136 | #else | ||
137 | static void setup_tlb_core_data(void) | ||
138 | { | ||
139 | } | ||
140 | #endif | 133 | #endif |
141 | 134 | ||
142 | #ifdef CONFIG_SMP | 135 | #ifdef CONFIG_SMP |
@@ -144,7 +137,7 @@ static void setup_tlb_core_data(void) | |||
144 | static char *smt_enabled_cmdline; | 137 | static char *smt_enabled_cmdline; |
145 | 138 | ||
146 | /* Look for ibm,smt-enabled OF option */ | 139 | /* Look for ibm,smt-enabled OF option */ |
147 | static void check_smt_enabled(void) | 140 | void __init check_smt_enabled(void) |
148 | { | 141 | { |
149 | struct device_node *dn; | 142 | struct device_node *dn; |
150 | const char *smt_option; | 143 | const char *smt_option; |
@@ -193,8 +186,6 @@ static int __init early_smt_enabled(char *p) | |||
193 | } | 186 | } |
194 | early_param("smt-enabled", early_smt_enabled); | 187 | early_param("smt-enabled", early_smt_enabled); |
195 | 188 | ||
196 | #else | ||
197 | #define check_smt_enabled() | ||
198 | #endif /* CONFIG_SMP */ | 189 | #endif /* CONFIG_SMP */ |
199 | 190 | ||
200 | /** Fix up paca fields required for the boot cpu */ | 191 | /** Fix up paca fields required for the boot cpu */ |
@@ -408,7 +399,7 @@ void smp_release_cpus(void) | |||
408 | * cache informations about the CPU that will be used by cache flush | 399 | * cache informations about the CPU that will be used by cache flush |
409 | * routines and/or provided to userland | 400 | * routines and/or provided to userland |
410 | */ | 401 | */ |
411 | static void __init initialize_cache_info(void) | 402 | void __init initialize_cache_info(void) |
412 | { | 403 | { |
413 | struct device_node *np; | 404 | struct device_node *np; |
414 | unsigned long num_cpus = 0; | 405 | unsigned long num_cpus = 0; |
@@ -480,38 +471,6 @@ static void __init initialize_cache_info(void) | |||
480 | DBG(" <- initialize_cache_info()\n"); | 471 | DBG(" <- initialize_cache_info()\n"); |
481 | } | 472 | } |
482 | 473 | ||
483 | static __init void print_system_info(void) | ||
484 | { | ||
485 | pr_info("-----------------------------------------------------\n"); | ||
486 | pr_info("ppc64_pft_size = 0x%llx\n", ppc64_pft_size); | ||
487 | pr_info("phys_mem_size = 0x%llx\n", memblock_phys_mem_size()); | ||
488 | |||
489 | if (ppc64_caches.dline_size != 0x80) | ||
490 | pr_info("dcache_line_size = 0x%x\n", ppc64_caches.dline_size); | ||
491 | if (ppc64_caches.iline_size != 0x80) | ||
492 | pr_info("icache_line_size = 0x%x\n", ppc64_caches.iline_size); | ||
493 | |||
494 | pr_info("cpu_features = 0x%016lx\n", cur_cpu_spec->cpu_features); | ||
495 | pr_info(" possible = 0x%016lx\n", CPU_FTRS_POSSIBLE); | ||
496 | pr_info(" always = 0x%016lx\n", CPU_FTRS_ALWAYS); | ||
497 | pr_info("cpu_user_features = 0x%08x 0x%08x\n", cur_cpu_spec->cpu_user_features, | ||
498 | cur_cpu_spec->cpu_user_features2); | ||
499 | pr_info("mmu_features = 0x%08x\n", cur_cpu_spec->mmu_features); | ||
500 | pr_info("firmware_features = 0x%016lx\n", powerpc_firmware_features); | ||
501 | |||
502 | #ifdef CONFIG_PPC_STD_MMU_64 | ||
503 | if (htab_address) | ||
504 | pr_info("htab_address = 0x%p\n", htab_address); | ||
505 | |||
506 | pr_info("htab_hash_mask = 0x%lx\n", htab_hash_mask); | ||
507 | #endif | ||
508 | |||
509 | if (PHYSICAL_START > 0) | ||
510 | pr_info("physical_start = 0x%llx\n", | ||
511 | (unsigned long long)PHYSICAL_START); | ||
512 | pr_info("-----------------------------------------------------\n"); | ||
513 | } | ||
514 | |||
515 | /* This returns the limit below which memory accesses to the linear | 474 | /* This returns the limit below which memory accesses to the linear |
516 | * mapping are guarnateed not to cause a TLB or SLB miss. This is | 475 | * mapping are guarnateed not to cause a TLB or SLB miss. This is |
517 | * used to allocate interrupt or emergency stacks for which our | 476 | * used to allocate interrupt or emergency stacks for which our |
@@ -533,7 +492,7 @@ static __init u64 safe_stack_limit(void) | |||
533 | #endif | 492 | #endif |
534 | } | 493 | } |
535 | 494 | ||
536 | static void __init irqstack_early_init(void) | 495 | void __init irqstack_early_init(void) |
537 | { | 496 | { |
538 | u64 limit = safe_stack_limit(); | 497 | u64 limit = safe_stack_limit(); |
539 | unsigned int i; | 498 | unsigned int i; |
@@ -553,7 +512,7 @@ static void __init irqstack_early_init(void) | |||
553 | } | 512 | } |
554 | 513 | ||
555 | #ifdef CONFIG_PPC_BOOK3E | 514 | #ifdef CONFIG_PPC_BOOK3E |
556 | static void __init exc_lvl_early_init(void) | 515 | void __init exc_lvl_early_init(void) |
557 | { | 516 | { |
558 | unsigned int i; | 517 | unsigned int i; |
559 | unsigned long sp; | 518 | unsigned long sp; |
@@ -575,8 +534,6 @@ static void __init exc_lvl_early_init(void) | |||
575 | if (cpu_has_feature(CPU_FTR_DEBUG_LVL_EXC)) | 534 | if (cpu_has_feature(CPU_FTR_DEBUG_LVL_EXC)) |
576 | patch_exception(0x040, exc_debug_debug_book3e); | 535 | patch_exception(0x040, exc_debug_debug_book3e); |
577 | } | 536 | } |
578 | #else | ||
579 | #define exc_lvl_early_init() | ||
580 | #endif | 537 | #endif |
581 | 538 | ||
582 | /* | 539 | /* |
@@ -584,7 +541,7 @@ static void __init exc_lvl_early_init(void) | |||
584 | * early in SMP boots before relocation is enabled. Exclusive emergency | 541 | * early in SMP boots before relocation is enabled. Exclusive emergency |
585 | * stack for machine checks. | 542 | * stack for machine checks. |
586 | */ | 543 | */ |
587 | static void __init emergency_stack_init(void) | 544 | void __init emergency_stack_init(void) |
588 | { | 545 | { |
589 | u64 limit; | 546 | u64 limit; |
590 | unsigned int i; | 547 | unsigned int i; |
@@ -615,124 +572,6 @@ static void __init emergency_stack_init(void) | |||
615 | } | 572 | } |
616 | } | 573 | } |
617 | 574 | ||
618 | /* | ||
619 | * Called into from start_kernel this initializes memblock, which is used | ||
620 | * to manage page allocation until mem_init is called. | ||
621 | */ | ||
622 | void __init setup_arch(char **cmdline_p) | ||
623 | { | ||
624 | *cmdline_p = boot_command_line; | ||
625 | |||
626 | /* | ||
627 | * Unflatten the device-tree passed by prom_init or kexec | ||
628 | */ | ||
629 | unflatten_device_tree(); | ||
630 | |||
631 | /* | ||
632 | * Fill the ppc64_caches & systemcfg structures with informations | ||
633 | * retrieved from the device-tree. | ||
634 | */ | ||
635 | initialize_cache_info(); | ||
636 | |||
637 | #ifdef CONFIG_PPC_RTAS | ||
638 | /* | ||
639 | * Initialize RTAS if available | ||
640 | */ | ||
641 | rtas_initialize(); | ||
642 | #endif /* CONFIG_PPC_RTAS */ | ||
643 | |||
644 | /* | ||
645 | * Check if we have an initrd provided via the device-tree | ||
646 | */ | ||
647 | check_for_initrd(); | ||
648 | |||
649 | /* Probe the machine type */ | ||
650 | probe_machine(); | ||
651 | |||
652 | setup_panic(); | ||
653 | |||
654 | /* | ||
655 | * We can discover serial ports now since the above did setup the | ||
656 | * hash table management for us, thus ioremap works. We do that early | ||
657 | * so that further code can be debugged | ||
658 | */ | ||
659 | find_legacy_serial_ports(); | ||
660 | |||
661 | /* | ||
662 | * Register early console | ||
663 | */ | ||
664 | register_early_udbg_console(); | ||
665 | |||
666 | smp_setup_cpu_maps(); | ||
667 | |||
668 | /* | ||
669 | * Initialize xmon | ||
670 | */ | ||
671 | xmon_setup(); | ||
672 | |||
673 | check_smt_enabled(); | ||
674 | setup_tlb_core_data(); | ||
675 | |||
676 | /* | ||
677 | * Freescale Book3e parts spin in a loop provided by firmware, | ||
678 | * so smp_release_cpus() does nothing for them | ||
679 | */ | ||
680 | #if defined(CONFIG_SMP) | ||
681 | /* | ||
682 | * Release secondary cpus out of their spinloops at 0x60 now that | ||
683 | * we can map physical -> logical CPU ids | ||
684 | */ | ||
685 | smp_release_cpus(); | ||
686 | #endif | ||
687 | |||
688 | /* Print various info about the machine that has been gathered so far. */ | ||
689 | print_system_info(); | ||
690 | |||
691 | /* Reserve large chunks of memory for use by CMA for KVM */ | ||
692 | kvm_cma_reserve(); | ||
693 | |||
694 | /* | ||
695 | * Reserve any gigantic pages requested on the command line. | ||
696 | * memblock needs to have been initialized by the time this is | ||
697 | * called since this will reserve memory. | ||
698 | */ | ||
699 | reserve_hugetlb_gpages(); | ||
700 | |||
701 | klp_init_thread_info(&init_thread_info); | ||
702 | |||
703 | init_mm.start_code = (unsigned long)_stext; | ||
704 | init_mm.end_code = (unsigned long) _etext; | ||
705 | init_mm.end_data = (unsigned long) _edata; | ||
706 | init_mm.brk = klimit; | ||
707 | #ifdef CONFIG_PPC_64K_PAGES | ||
708 | init_mm.context.pte_frag = NULL; | ||
709 | #endif | ||
710 | #ifdef CONFIG_SPAPR_TCE_IOMMU | ||
711 | mm_iommu_init(&init_mm.context); | ||
712 | #endif | ||
713 | irqstack_early_init(); | ||
714 | exc_lvl_early_init(); | ||
715 | emergency_stack_init(); | ||
716 | |||
717 | initmem_init(); | ||
718 | |||
719 | #ifdef CONFIG_DUMMY_CONSOLE | ||
720 | conswitchp = &dummy_con; | ||
721 | #endif | ||
722 | if (ppc_md.setup_arch) | ||
723 | ppc_md.setup_arch(); | ||
724 | |||
725 | paging_init(); | ||
726 | |||
727 | /* Initialize the MMU context management stuff */ | ||
728 | mmu_context_init(); | ||
729 | |||
730 | /* Interrupt code needs to be 64K-aligned */ | ||
731 | if ((unsigned long)_stext & 0xffff) | ||
732 | panic("Kernelbase not 64K-aligned (0x%lx)!\n", | ||
733 | (unsigned long)_stext); | ||
734 | } | ||
735 | |||
736 | #ifdef CONFIG_SMP | 575 | #ifdef CONFIG_SMP |
737 | #define PCPU_DYN_SIZE () | 576 | #define PCPU_DYN_SIZE () |
738 | 577 | ||