Skip to content

Commit

Permalink
powerpc/mm: Introduce early_init_mmu() on 64-bit
Browse files Browse the repository at this point in the history
This moves some MMU related init code out of setup_64.c into hash_utils_64.c
and calls it early_init_mmu() and early_init_mmu_secondary(). This will
make it easier to plug in a new MMU type.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Benjamin Herrenschmidt committed Mar 24, 2009
1 parent a033a48 commit 757c74d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 34 deletions.
2 changes: 0 additions & 2 deletions arch/powerpc/include/asm/mmu-hash64.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,6 @@ extern void add_gpage(unsigned long addr, unsigned long page_size,
unsigned long number_of_pages);
extern void demote_segment_4k(struct mm_struct *mm, unsigned long addr);

extern void htab_initialize(void);
extern void htab_initialize_secondary(void);
extern void hpte_init_native(void);
extern void hpte_init_lpar(void);
extern void hpte_init_iSeries(void);
Expand Down
4 changes: 4 additions & 0 deletions arch/powerpc/include/asm/mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ static inline int mmu_has_feature(unsigned long feature)

extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup;

/* MMU initialization (64-bit only fo now) */
extern void early_init_mmu(void);
extern void early_init_mmu_secondary(void);

#endif /* !__ASSEMBLY__ */


Expand Down
35 changes: 5 additions & 30 deletions arch/powerpc/kernel/setup_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ void __init early_setup(unsigned long dt_ptr)

/* Fix up paca fields required for the boot cpu */
get_paca()->cpu_start = 1;
get_paca()->stab_real = __pa((u64)&initial_stab);
get_paca()->stab_addr = (u64)&initial_stab;

/* Probe the machine type */
probe_machine();
Expand All @@ -212,43 +210,20 @@ void __init early_setup(unsigned long dt_ptr)

DBG("Found, Initializing memory management...\n");

/*
* Initialize the MMU Hash table and create the linear mapping
* of memory. Has to be done before stab/slb initialization as
* this is currently where the page size encoding is obtained
*/
htab_initialize();

/*
* Initialize stab / SLB management except on iSeries
*/
if (cpu_has_feature(CPU_FTR_SLB))
slb_initialize();
else if (!firmware_has_feature(FW_FEATURE_ISERIES))
stab_initialize(get_paca()->stab_real);
/* Initialize the hash table or TLB handling */
early_init_mmu();

DBG(" <- early_setup()\n");
}

#ifdef CONFIG_SMP
void early_setup_secondary(void)
{
struct paca_struct *lpaca = get_paca();

/* Mark interrupts enabled in PACA */
lpaca->soft_enabled = 0;
get_paca()->soft_enabled = 0;

/* Initialize hash table for that CPU */
htab_initialize_secondary();

/* Initialize STAB/SLB. We use a virtual address as it works
* in real mode on pSeries and we want a virutal address on
* iSeries anyway
*/
if (cpu_has_feature(CPU_FTR_SLB))
slb_initialize();
else
stab_initialize(lpaca->stab_addr);
/* Initialize the hash table or TLB handling */
early_init_mmu_secondary();
}

#endif /* CONFIG_SMP */
Expand Down
36 changes: 34 additions & 2 deletions arch/powerpc/mm/hash_utils_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ static void __init htab_finish_init(void)
make_bl(htab_call_hpte_updatepp, ppc_md.hpte_updatepp);
}

void __init htab_initialize(void)
static void __init htab_initialize(void)
{
unsigned long table;
unsigned long pteg_count;
Expand Down Expand Up @@ -732,11 +732,43 @@ void __init htab_initialize(void)
#undef KB
#undef MB

void htab_initialize_secondary(void)
void __init early_init_mmu(void)
{
/* Setup initial STAB address in the PACA */
get_paca()->stab_real = __pa((u64)&initial_stab);
get_paca()->stab_addr = (u64)&initial_stab;

/* Initialize the MMU Hash table and create the linear mapping
* of memory. Has to be done before stab/slb initialization as
* this is currently where the page size encoding is obtained
*/
htab_initialize();

/* Initialize stab / SLB management except on iSeries
*/
if (cpu_has_feature(CPU_FTR_SLB))
slb_initialize();
else if (!firmware_has_feature(FW_FEATURE_ISERIES))
stab_initialize(get_paca()->stab_real);
}

#ifdef CONFIG_SMP
void __init early_init_mmu_secondary(void)
{
/* Initialize hash table for that CPU */
if (!firmware_has_feature(FW_FEATURE_LPAR))
mtspr(SPRN_SDR1, _SDR1);

/* Initialize STAB/SLB. We use a virtual address as it works
* in real mode on pSeries and we want a virutal address on
* iSeries anyway
*/
if (cpu_has_feature(CPU_FTR_SLB))
slb_initialize();
else
stab_initialize(get_paca()->stab_addr);
}
#endif /* CONFIG_SMP */

/*
* Called by asm hashtable.S for doing lazy icache flush
Expand Down

0 comments on commit 757c74d

Please sign in to comment.