Skip to content

Commit

Permalink
powerpc/mm: Abstraction for switch_mmu_context()
Browse files Browse the repository at this point in the history
How we switch MMU context differs between hash and radix. For hash we
need to switch the SLB details and for radix we need to switch the PID
SPR.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
Aneesh Kumar K.V authored and Michael Ellerman committed May 1, 2016
1 parent d9225ad commit d2adba3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
25 changes: 13 additions & 12 deletions arch/powerpc/include/asm/mmu_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,23 @@ extern long mm_iommu_ua_to_hpa(struct mm_iommu_table_group_mem_t *mem,
extern long mm_iommu_mapped_inc(struct mm_iommu_table_group_mem_t *mem);
extern void mm_iommu_mapped_dec(struct mm_iommu_table_group_mem_t *mem);
#endif

extern void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next);
extern void switch_slb(struct task_struct *tsk, struct mm_struct *mm);
extern void set_context(unsigned long id, pgd_t *pgd);

#ifdef CONFIG_PPC_BOOK3S_64
static inline void switch_mmu_context(struct mm_struct *prev,
struct mm_struct *next,
struct task_struct *tsk)
{
return switch_slb(tsk, next);
}

extern int __init_new_context(void);
extern void __destroy_context(int context_id);
static inline void mmu_context_init(void) { }
#else
extern void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next,
struct task_struct *tsk);
extern unsigned long __init_new_context(void);
extern void __destroy_context(unsigned long context_id);
extern void mmu_context_init(void);
Expand Down Expand Up @@ -88,17 +95,11 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
if (cpu_has_feature(CPU_FTR_ALTIVEC))
asm volatile ("dssall");
#endif /* CONFIG_ALTIVEC */

/* The actual HW switching method differs between the various
* sub architectures.
/*
* The actual HW switching method differs between the various
* sub architectures. Out of line for now
*/
#ifdef CONFIG_PPC_STD_MMU_64
switch_slb(tsk, next);
#else
/* Out of line for now */
switch_mmu_context(prev, next);
#endif

switch_mmu_context(prev, next, tsk);
}

#define deactivate_mm(tsk,mm) do { } while (0)
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/swsusp.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ void save_processor_state(void)
void restore_processor_state(void)
{
#ifdef CONFIG_PPC32
switch_mmu_context(current->active_mm, current->active_mm);
switch_mmu_context(current->active_mm, current->active_mm, NULL);
#endif
}
3 changes: 2 additions & 1 deletion arch/powerpc/mm/mmu_context_nohash.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ static void context_check_map(void)
static void context_check_map(void) { }
#endif

void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next)
void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next,
struct task_struct *tsk)
{
unsigned int i, id, cpu = smp_processor_id();
unsigned long *map;
Expand Down
2 changes: 1 addition & 1 deletion drivers/cpufreq/pmac32-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ static int pmu_set_cpu_speed(int low_speed)
_set_L3CR(save_l3cr);

/* Restore userland MMU context */
switch_mmu_context(NULL, current->active_mm);
switch_mmu_context(NULL, current->active_mm, NULL);

#ifdef DEBUG_FREQ
printk(KERN_DEBUG "HID1, after: %x\n", mfspr(SPRN_HID1));
Expand Down
4 changes: 2 additions & 2 deletions drivers/macintosh/via-pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1851,7 +1851,7 @@ static int powerbook_sleep_grackle(void)
_set_L2CR(save_l2cr);

/* Restore userland MMU context */
switch_mmu_context(NULL, current->active_mm);
switch_mmu_context(NULL, current->active_mm, NULL);

/* Power things up */
pmu_unlock();
Expand Down Expand Up @@ -1940,7 +1940,7 @@ powerbook_sleep_Core99(void)
_set_L3CR(save_l3cr);

/* Restore userland MMU context */
switch_mmu_context(NULL, current->active_mm);
switch_mmu_context(NULL, current->active_mm, NULL);

/* Tell PMU we are ready */
pmu_unlock();
Expand Down

0 comments on commit d2adba3

Please sign in to comment.