Skip to content

Commit 166dd7d

Browse files
ozbenhmpe
authored andcommitted
powerpc/64: Move MMU backend selection out of platform code
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>
1 parent 91b6fad commit 166dd7d

11 files changed

Lines changed: 32 additions & 26 deletions

File tree

‎arch/powerpc/include/asm/ps3.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,4 +526,6 @@ void ps3_sync_irq(int node);
526526
u32 ps3_get_hw_thread_id(int cpu);
527527
u64 ps3_get_spe_id(void *arg);
528528

529+
void ps3_early_mm_init(void);
530+
529531
#endif

‎arch/powerpc/kernel/prom.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,12 @@ void __init early_init_devtree(void *params)
759759
/* Now try to figure out if we are running on LPAR and so on */
760760
pseries_probe_fw_features();
761761

762+
#ifdef CONFIG_PPC_PS3
763+
/* Identify PS3 firmware */
764+
if (of_flat_dt_is_compatible(of_get_flat_dt_root(), "sony,ps3"))
765+
powerpc_firmware_features |= FW_FEATURE_PS3_POSSIBLE;
766+
#endif
767+
762768
DBG(" <- early_init_devtree()\n");
763769
}
764770

‎arch/powerpc/mm/hash_utils_64.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#include <asm/firmware.h>
5959
#include <asm/tm.h>
6060
#include <asm/trace.h>
61+
#include <asm/ps3.h>
6162

6263
#ifdef DEBUG
6364
#define DBG(fmt...) udbg_printf(fmt)
@@ -872,6 +873,11 @@ static void __init htab_initialize(void)
872873
#undef KB
873874
#undef MB
874875

876+
void __init __weak hpte_init_lpar(void)
877+
{
878+
panic("FW_FEATURE_LPAR set but no LPAR support compiled\n");
879+
}
880+
875881
void __init hash__early_init_mmu(void)
876882
{
877883
/*
@@ -908,6 +914,14 @@ void __init hash__early_init_mmu(void)
908914
pci_io_base = ISA_IO_BASE;
909915
#endif
910916

917+
/* Select appropriate backend */
918+
if (firmware_has_feature(FW_FEATURE_PS3_LV1))
919+
ps3_early_mm_init();
920+
else if (firmware_has_feature(FW_FEATURE_LPAR))
921+
hpte_init_lpar();
922+
else
923+
hpte_init_native();
924+
911925
/* Initialize the MMU Hash table and create the linear mapping
912926
* of memory. Has to be done before SLB initialization as this is
913927
* currently where the page size encoding is obtained.

‎arch/powerpc/mm/pgtable-radix.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ void __init radix__early_init_mmu(void)
345345

346346
radix_init_page_sizes();
347347
if (!firmware_has_feature(FW_FEATURE_LPAR)) {
348+
radix_init_native();
348349
lpcr = mfspr(SPRN_LPCR);
349350
mtspr(SPRN_LPCR, lpcr | LPCR_UPRT | LPCR_HR);
350351
radix_init_partition_table();

‎arch/powerpc/platforms/cell/setup.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ static int __init cell_probe(void)
261261
!of_flat_dt_is_compatible(root, "IBM,CPBW-1.0"))
262262
return 0;
263263

264-
hpte_init_native();
265264
pm_power_off = rtas_power_off;
266265

267266
return 1;

‎arch/powerpc/platforms/maple/setup.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ static int __init maple_probe(void)
306306
!of_flat_dt_is_compatible(root, "Momentum,Apache"))
307307
return 0;
308308

309-
hpte_init_native();
310309
pm_power_off = maple_power_off;
311310

312311
return 1;

‎arch/powerpc/platforms/pasemi/setup.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,6 @@ static int __init pas_probe(void)
426426
!of_flat_dt_is_compatible(root, "pasemi,pwrficient"))
427427
return 0;
428428

429-
hpte_init_native();
430-
431429
alloc_iobmap_l2();
432430

433431
return 1;

‎arch/powerpc/platforms/powermac/setup.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,10 +599,6 @@ static int __init pmac_probe(void)
599599
!of_flat_dt_is_compatible(root, "MacRISC"))
600600
return 0;
601601

602-
#ifdef CONFIG_PPC64
603-
hpte_init_native();
604-
#endif
605-
606602
#ifdef CONFIG_PPC32
607603
/* isa_io_base gets set in pmac_pci_init */
608604
ISA_DMA_THRESHOLD = ~0L;

‎arch/powerpc/platforms/powernv/setup.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,6 @@ static int __init pnv_probe(void)
273273
if (!of_flat_dt_is_compatible(root, "ibm,powernv"))
274274
return 0;
275275

276-
if (IS_ENABLED(CONFIG_PPC_RADIX_MMU) && radix_enabled())
277-
radix_init_native();
278-
else if (IS_ENABLED(CONFIG_PPC_STD_MMU_64))
279-
hpte_init_native();
280-
281276
if (firmware_has_feature(FW_FEATURE_OPAL))
282277
pnv_setup_machdep_opal();
283278

‎arch/powerpc/platforms/ps3/setup.c‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,17 @@ static void __init ps3_progress(char *s, unsigned short hex)
226226
printk("*** %04x : %s\n", hex, s ? s : "");
227227
}
228228

229-
static int __init ps3_probe(void)
229+
void __init ps3_early_mm_init(void)
230230
{
231231
unsigned long htab_size;
232+
233+
ps3_mm_init();
234+
ps3_mm_vas_create(&htab_size);
235+
ps3_hpte_init(htab_size);
236+
}
237+
238+
static int __init ps3_probe(void)
239+
{
232240
unsigned long dt_root;
233241

234242
DBG(" -> %s:%d\n", __func__, __LINE__);
@@ -237,12 +245,7 @@ static int __init ps3_probe(void)
237245
if (!of_flat_dt_is_compatible(dt_root, "sony,ps3"))
238246
return 0;
239247

240-
powerpc_firmware_features |= FW_FEATURE_PS3_POSSIBLE;
241-
242248
ps3_os_area_save_params();
243-
ps3_mm_init();
244-
ps3_mm_vas_create(&htab_size);
245-
ps3_hpte_init(htab_size);
246249
pm_power_off = ps3_power_off;
247250

248251
DBG(" <- %s:%d\n", __func__, __LINE__);

0 commit comments

Comments
 (0)