powerpc/64: Move MMU backend selection out of platform code
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 5 Jul 2016 05:03:51 +0000 (15:03 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 21 Jul 2016 08:56:38 +0000 (18:56 +1000)
We move it into early_mmu_init() based on firmware features. For PS3,
we have to move the setting of these into early_init_devtree().

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/ps3.h
arch/powerpc/kernel/prom.c
arch/powerpc/mm/hash_utils_64.c
arch/powerpc/mm/pgtable-radix.c
arch/powerpc/platforms/cell/setup.c
arch/powerpc/platforms/maple/setup.c
arch/powerpc/platforms/pasemi/setup.c
arch/powerpc/platforms/powermac/setup.c
arch/powerpc/platforms/powernv/setup.c
arch/powerpc/platforms/ps3/setup.c
arch/powerpc/platforms/pseries/setup.c

index a1bc7e7584228a9e02215aeb2ee96e21194752c5..a19f831a4cc9acdc6b0974e1d84240646983b0a6 100644 (file)
@@ -526,4 +526,6 @@ void ps3_sync_irq(int node);
 u32 ps3_get_hw_thread_id(int cpu);
 u64 ps3_get_spe_id(void *arg);
 
+void ps3_early_mm_init(void);
+
 #endif
index 2bd1784e65b3d5c18bb3de0e5e6f438aebb6b2e8..bae3db791150157b2374ab0f27bed0bc371494cd 100644 (file)
@@ -759,6 +759,12 @@ void __init early_init_devtree(void *params)
        /* Now try to figure out if we are running on LPAR and so on */
        pseries_probe_fw_features();
 
+#ifdef CONFIG_PPC_PS3
+       /* Identify PS3 firmware */
+       if (of_flat_dt_is_compatible(of_get_flat_dt_root(), "sony,ps3"))
+               powerpc_firmware_features |= FW_FEATURE_PS3_POSSIBLE;
+#endif
+
        DBG(" <- early_init_devtree()\n");
 }
 
index 859ecaa928e9b16673a1e13b5f90ee35e5984a17..336fad6524df76967613840e0dc3b0d198b44404 100644 (file)
@@ -58,6 +58,7 @@
 #include <asm/firmware.h>
 #include <asm/tm.h>
 #include <asm/trace.h>
+#include <asm/ps3.h>
 
 #ifdef DEBUG
 #define DBG(fmt...) udbg_printf(fmt)
@@ -872,6 +873,11 @@ static void __init htab_initialize(void)
 #undef KB
 #undef MB
 
+void __init __weak hpte_init_lpar(void)
+{
+       panic("FW_FEATURE_LPAR set but no LPAR support compiled\n");
+}
+
 void __init hash__early_init_mmu(void)
 {
        /*
@@ -908,6 +914,14 @@ void __init hash__early_init_mmu(void)
        pci_io_base = ISA_IO_BASE;
 #endif
 
+       /* Select appropriate backend */
+       if (firmware_has_feature(FW_FEATURE_PS3_LV1))
+               ps3_early_mm_init();
+       else if (firmware_has_feature(FW_FEATURE_LPAR))
+               hpte_init_lpar();
+       else
+               hpte_init_native();
+
        /* Initialize the MMU Hash table and create the linear mapping
         * of memory. Has to be done before SLB initialization as this is
         * currently where the page size encoding is obtained.
index 4ea1094c9fc4681afc7765ef0e5fb932d8cae97a..003ff48a11b6212888fac831ad8ab7057d2e84cd 100644 (file)
@@ -345,6 +345,7 @@ void __init radix__early_init_mmu(void)
 
        radix_init_page_sizes();
        if (!firmware_has_feature(FW_FEATURE_LPAR)) {
+               radix_init_native();
                lpcr = mfspr(SPRN_LPCR);
                mtspr(SPRN_LPCR, lpcr | LPCR_UPRT | LPCR_HR);
                radix_init_partition_table();
index 36cff28d0293b528b6d5b8847132f43a48a87f89..e342f7833db5bca267d8636a112535d7916f90cb 100644 (file)
@@ -261,7 +261,6 @@ static int __init cell_probe(void)
            !of_flat_dt_is_compatible(root, "IBM,CPBW-1.0"))
                return 0;
 
-       hpte_init_native();
        pm_power_off = rtas_power_off;
 
        return 1;
index 99b9b96ab05969f16be21816a9562030bafc3a0a..b1ecd991a0fbefc4f7947e13f27ff3603f998bdc 100644 (file)
@@ -306,7 +306,6 @@ static int __init maple_probe(void)
            !of_flat_dt_is_compatible(root, "Momentum,Apache"))
                return 0;
 
-       hpte_init_native();
        pm_power_off = maple_power_off;
 
        return 1;
index 7349644c9828d1dee288a8201f3e0db968820a68..924d01d9b3756113aed137f2faa0c0013756a2df 100644 (file)
@@ -426,8 +426,6 @@ static int __init pas_probe(void)
            !of_flat_dt_is_compatible(root, "pasemi,pwrficient"))
                return 0;
 
-       hpte_init_native();
-
        alloc_iobmap_l2();
 
        return 1;
index 4ad61687c67050761ec06560adbc8ff6793ab3ac..795bf8cfddd90cec086738da77ce15cc336d8d50 100644 (file)
@@ -599,10 +599,6 @@ static int __init pmac_probe(void)
            !of_flat_dt_is_compatible(root, "MacRISC"))
                return 0;
 
-#ifdef CONFIG_PPC64
-       hpte_init_native();
-#endif
-
 #ifdef CONFIG_PPC32
        /* isa_io_base gets set in pmac_pci_init */
        ISA_DMA_THRESHOLD = ~0L;
index 8492bbbcfc0812400fe342a5a5208023626372f1..f70ea83502b26d0e74764edb7dea5f25f93bf896 100644 (file)
@@ -273,11 +273,6 @@ static int __init pnv_probe(void)
        if (!of_flat_dt_is_compatible(root, "ibm,powernv"))
                return 0;
 
-       if (IS_ENABLED(CONFIG_PPC_RADIX_MMU) && radix_enabled())
-               radix_init_native();
-       else if (IS_ENABLED(CONFIG_PPC_STD_MMU_64))
-               hpte_init_native();
-
        if (firmware_has_feature(FW_FEATURE_OPAL))
                pnv_setup_machdep_opal();
 
index 486ecd017535787a47c9a5da1cb45868a90e2b89..b7fdf88474e83e21cbb09905d2c760c149951e89 100644 (file)
@@ -226,9 +226,17 @@ static void __init ps3_progress(char *s, unsigned short hex)
        printk("*** %04x : %s\n", hex, s ? s : "");
 }
 
-static int __init ps3_probe(void)
+void __init ps3_early_mm_init(void)
 {
        unsigned long htab_size;
+
+       ps3_mm_init();
+       ps3_mm_vas_create(&htab_size);
+       ps3_hpte_init(htab_size);
+}
+
+static int __init ps3_probe(void)
+{
        unsigned long dt_root;
 
        DBG(" -> %s:%d\n", __func__, __LINE__);
@@ -237,12 +245,7 @@ static int __init ps3_probe(void)
        if (!of_flat_dt_is_compatible(dt_root, "sony,ps3"))
                return 0;
 
-       powerpc_firmware_features |= FW_FEATURE_PS3_POSSIBLE;
-
        ps3_os_area_save_params();
-       ps3_mm_init();
-       ps3_mm_vas_create(&htab_size);
-       ps3_hpte_init(htab_size);
        pm_power_off = ps3_power_off;
 
        DBG(" <- %s:%d\n", __func__, __LINE__);
index ba7dc126b5e5bb789ab77c0cc4b07fb6473fd51d..240721348ebc8bf567521d6b18bbc5dacf81dcc1 100644 (file)
@@ -687,13 +687,6 @@ static int __init pSeries_probe(void)
            of_flat_dt_is_compatible(root, "IBM,CBEA"))
                return 0;
 
-       pr_debug("pSeries detected, looking for LPAR capability...\n");
-
-       if (firmware_has_feature(FW_FEATURE_LPAR))
-               hpte_init_lpar();
-       else
-               hpte_init_native();
-
        pm_power_off = pseries_power_off;
 
        pr_debug("Machine is%s LPAR !\n",