diff options
author | Sam Ravnborg <sam@ravnborg.org> | 2012-07-26 07:02:24 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-07-26 19:46:16 -0400 |
commit | b585e8551b352cee95cf060b7eddc76d16e6120a (patch) | |
tree | 92f5346a503111037a5cbb80b0892b7a04fd97c6 /arch | |
parent | 59b00c792f0302b43e098849febc52386be5fd54 (diff) |
sparc32: centralize all mmu context handling in srmmu.c
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sparc/include/asm/mmu_context_32.h | 8 | ||||
-rw-r--r-- | arch/sparc/include/asm/pgtable_32.h | 32 | ||||
-rw-r--r-- | arch/sparc/kernel/setup_32.c | 1 | ||||
-rw-r--r-- | arch/sparc/mm/fault_32.c | 6 | ||||
-rw-r--r-- | arch/sparc/mm/init_32.c | 18 | ||||
-rw-r--r-- | arch/sparc/mm/srmmu.c | 69 |
6 files changed, 63 insertions, 71 deletions
diff --git a/arch/sparc/include/asm/mmu_context_32.h b/arch/sparc/include/asm/mmu_context_32.h index 01456c900720..2df2a9be8f6d 100644 --- a/arch/sparc/include/asm/mmu_context_32.h +++ b/arch/sparc/include/asm/mmu_context_32.h | |||
@@ -9,14 +9,12 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) | |||
9 | { | 9 | { |
10 | } | 10 | } |
11 | 11 | ||
12 | /* | 12 | /* Initialize a new mmu context. This is invoked when a new |
13 | * Initialize a new mmu context. This is invoked when a new | ||
14 | * address space instance (unique or shared) is instantiated. | 13 | * address space instance (unique or shared) is instantiated. |
15 | */ | 14 | */ |
16 | #define init_new_context(tsk, mm) (((mm)->context = NO_CONTEXT), 0) | 15 | int init_new_context(struct task_struct *tsk, struct mm_struct *mm); |
17 | 16 | ||
18 | /* | 17 | /* Destroy a dead context. This occurs when mmput drops the |
19 | * Destroy a dead context. This occurs when mmput drops the | ||
20 | * mm_users count to zero, the mmaps have been released, and | 18 | * mm_users count to zero, the mmaps have been released, and |
21 | * all the page tables have been flushed. Our job is to destroy | 19 | * all the page tables have been flushed. Our job is to destroy |
22 | * any remaining processor-specific state. | 20 | * any remaining processor-specific state. |
diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h index c704f949b7ef..97a48807361e 100644 --- a/arch/sparc/include/asm/pgtable_32.h +++ b/arch/sparc/include/asm/pgtable_32.h | |||
@@ -79,8 +79,6 @@ extern unsigned long ptr_in_current_pgd; | |||
79 | #define __S110 PAGE_SHARED | 79 | #define __S110 PAGE_SHARED |
80 | #define __S111 PAGE_SHARED | 80 | #define __S111 PAGE_SHARED |
81 | 81 | ||
82 | extern int num_contexts; | ||
83 | |||
84 | /* First physical page can be anywhere, the following is needed so that | 82 | /* First physical page can be anywhere, the following is needed so that |
85 | * va-->pa and vice versa conversions work properly without performance | 83 | * va-->pa and vice versa conversions work properly without performance |
86 | * hit for all __pa()/__va() operations. | 84 | * hit for all __pa()/__va() operations. |
@@ -399,36 +397,6 @@ static inline pte_t pgoff_to_pte(unsigned long pgoff) | |||
399 | */ | 397 | */ |
400 | #define PTE_FILE_MAX_BITS 24 | 398 | #define PTE_FILE_MAX_BITS 24 |
401 | 399 | ||
402 | /* | ||
403 | */ | ||
404 | struct ctx_list { | ||
405 | struct ctx_list *next; | ||
406 | struct ctx_list *prev; | ||
407 | unsigned int ctx_number; | ||
408 | struct mm_struct *ctx_mm; | ||
409 | }; | ||
410 | |||
411 | extern struct ctx_list *ctx_list_pool; /* Dynamically allocated */ | ||
412 | extern struct ctx_list ctx_free; /* Head of free list */ | ||
413 | extern struct ctx_list ctx_used; /* Head of used contexts list */ | ||
414 | |||
415 | #define NO_CONTEXT -1 | ||
416 | |||
417 | static inline void remove_from_ctx_list(struct ctx_list *entry) | ||
418 | { | ||
419 | entry->next->prev = entry->prev; | ||
420 | entry->prev->next = entry->next; | ||
421 | } | ||
422 | |||
423 | static inline void add_to_ctx_list(struct ctx_list *head, struct ctx_list *entry) | ||
424 | { | ||
425 | entry->next = head; | ||
426 | (entry->prev = head->prev)->next = entry; | ||
427 | head->prev = entry; | ||
428 | } | ||
429 | #define add_to_free_ctxlist(entry) add_to_ctx_list(&ctx_free, entry) | ||
430 | #define add_to_used_ctxlist(entry) add_to_ctx_list(&ctx_used, entry) | ||
431 | |||
432 | static inline unsigned long | 400 | static inline unsigned long |
433 | __get_phys (unsigned long addr) | 401 | __get_phys (unsigned long addr) |
434 | { | 402 | { |
diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c index efe3e64bba38..38bf80a22f02 100644 --- a/arch/sparc/kernel/setup_32.c +++ b/arch/sparc/kernel/setup_32.c | |||
@@ -371,7 +371,6 @@ void __init setup_arch(char **cmdline_p) | |||
371 | (*(linux_dbvec->teach_debugger))(); | 371 | (*(linux_dbvec->teach_debugger))(); |
372 | } | 372 | } |
373 | 373 | ||
374 | init_mm.context = (unsigned long) NO_CONTEXT; | ||
375 | init_task.thread.kregs = &fake_swapper_regs; | 374 | init_task.thread.kregs = &fake_swapper_regs; |
376 | 375 | ||
377 | /* Run-time patch instructions to match the cpu model */ | 376 | /* Run-time patch instructions to match the cpu model */ |
diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c index f46cf6be3370..e58f9ee718cb 100644 --- a/arch/sparc/mm/fault_32.c +++ b/arch/sparc/mm/fault_32.c | |||
@@ -32,12 +32,6 @@ | |||
32 | 32 | ||
33 | int show_unhandled_signals = 1; | 33 | int show_unhandled_signals = 1; |
34 | 34 | ||
35 | /* At boot time we determine these two values necessary for setting | ||
36 | * up the segment maps and page table entries (pte's). | ||
37 | */ | ||
38 | |||
39 | int num_contexts; | ||
40 | |||
41 | /* Return how much physical memory we have. */ | 35 | /* Return how much physical memory we have. */ |
42 | unsigned long probe_memory(void) | 36 | unsigned long probe_memory(void) |
43 | { | 37 | { |
diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c index 6d44c2b80d66..020d2afa0030 100644 --- a/arch/sparc/mm/init_32.c +++ b/arch/sparc/mm/init_32.c | |||
@@ -82,24 +82,6 @@ void show_mem(unsigned int filter) | |||
82 | #endif | 82 | #endif |
83 | } | 83 | } |
84 | 84 | ||
85 | void __init sparc_context_init(int numctx) | ||
86 | { | ||
87 | int ctx; | ||
88 | |||
89 | ctx_list_pool = __alloc_bootmem(numctx * sizeof(struct ctx_list), SMP_CACHE_BYTES, 0UL); | ||
90 | |||
91 | for(ctx = 0; ctx < numctx; ctx++) { | ||
92 | struct ctx_list *clist; | ||
93 | |||
94 | clist = (ctx_list_pool + ctx); | ||
95 | clist->ctx_number = ctx; | ||
96 | clist->ctx_mm = NULL; | ||
97 | } | ||
98 | ctx_free.next = ctx_free.prev = &ctx_free; | ||
99 | ctx_used.next = ctx_used.prev = &ctx_used; | ||
100 | for(ctx = 0; ctx < numctx; ctx++) | ||
101 | add_to_free_ctxlist(ctx_list_pool + ctx); | ||
102 | } | ||
103 | 85 | ||
104 | extern unsigned long cmdline_memory_size; | 86 | extern unsigned long cmdline_memory_size; |
105 | unsigned long last_valid_pfn; | 87 | unsigned long last_valid_pfn; |
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c index ab62595cf366..ad93d2ee6be2 100644 --- a/arch/sparc/mm/srmmu.c +++ b/arch/sparc/mm/srmmu.c | |||
@@ -55,10 +55,6 @@ static unsigned int hwbug_bitmask; | |||
55 | int vac_cache_size; | 55 | int vac_cache_size; |
56 | int vac_line_size; | 56 | int vac_line_size; |
57 | 57 | ||
58 | struct ctx_list *ctx_list_pool; | ||
59 | struct ctx_list ctx_free; | ||
60 | struct ctx_list ctx_used; | ||
61 | |||
62 | extern struct resource sparc_iomap; | 58 | extern struct resource sparc_iomap; |
63 | 59 | ||
64 | extern unsigned long last_valid_pfn; | 60 | extern unsigned long last_valid_pfn; |
@@ -355,8 +351,39 @@ void pte_free(struct mm_struct *mm, pgtable_t pte) | |||
355 | srmmu_free_nocache(__nocache_va(p), PTE_SIZE); | 351 | srmmu_free_nocache(__nocache_va(p), PTE_SIZE); |
356 | } | 352 | } |
357 | 353 | ||
358 | /* | 354 | /* context handling - a dynamically sized pool is used */ |
359 | */ | 355 | #define NO_CONTEXT -1 |
356 | |||
357 | struct ctx_list { | ||
358 | struct ctx_list *next; | ||
359 | struct ctx_list *prev; | ||
360 | unsigned int ctx_number; | ||
361 | struct mm_struct *ctx_mm; | ||
362 | }; | ||
363 | |||
364 | static struct ctx_list *ctx_list_pool; | ||
365 | static struct ctx_list ctx_free; | ||
366 | static struct ctx_list ctx_used; | ||
367 | |||
368 | /* At boot time we determine the number of contexts */ | ||
369 | static int num_contexts; | ||
370 | |||
371 | static inline void remove_from_ctx_list(struct ctx_list *entry) | ||
372 | { | ||
373 | entry->next->prev = entry->prev; | ||
374 | entry->prev->next = entry->next; | ||
375 | } | ||
376 | |||
377 | static inline void add_to_ctx_list(struct ctx_list *head, struct ctx_list *entry) | ||
378 | { | ||
379 | entry->next = head; | ||
380 | (entry->prev = head->prev)->next = entry; | ||
381 | head->prev = entry; | ||
382 | } | ||
383 | #define add_to_free_ctxlist(entry) add_to_ctx_list(&ctx_free, entry) | ||
384 | #define add_to_used_ctxlist(entry) add_to_ctx_list(&ctx_used, entry) | ||
385 | |||
386 | |||
360 | static inline void alloc_context(struct mm_struct *old_mm, struct mm_struct *mm) | 387 | static inline void alloc_context(struct mm_struct *old_mm, struct mm_struct *mm) |
361 | { | 388 | { |
362 | struct ctx_list *ctxp; | 389 | struct ctx_list *ctxp; |
@@ -392,6 +419,26 @@ static inline void free_context(int context) | |||
392 | add_to_free_ctxlist(ctx_old); | 419 | add_to_free_ctxlist(ctx_old); |
393 | } | 420 | } |
394 | 421 | ||
422 | static void __init sparc_context_init(int numctx) | ||
423 | { | ||
424 | int ctx; | ||
425 | unsigned long size; | ||
426 | |||
427 | size = numctx * sizeof(struct ctx_list); | ||
428 | ctx_list_pool = __alloc_bootmem(size, SMP_CACHE_BYTES, 0UL); | ||
429 | |||
430 | for (ctx = 0; ctx < numctx; ctx++) { | ||
431 | struct ctx_list *clist; | ||
432 | |||
433 | clist = (ctx_list_pool + ctx); | ||
434 | clist->ctx_number = ctx; | ||
435 | clist->ctx_mm = NULL; | ||
436 | } | ||
437 | ctx_free.next = ctx_free.prev = &ctx_free; | ||
438 | ctx_used.next = ctx_used.prev = &ctx_used; | ||
439 | for (ctx = 0; ctx < numctx; ctx++) | ||
440 | add_to_free_ctxlist(ctx_list_pool + ctx); | ||
441 | } | ||
395 | 442 | ||
396 | void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm, | 443 | void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm, |
397 | struct task_struct *tsk) | 444 | struct task_struct *tsk) |
@@ -799,9 +846,6 @@ static void __init map_kernel(void) | |||
799 | } | 846 | } |
800 | } | 847 | } |
801 | 848 | ||
802 | /* Paging initialization on the Sparc Reference MMU. */ | ||
803 | extern void sparc_context_init(int); | ||
804 | |||
805 | void (*poke_srmmu)(void) __cpuinitdata = NULL; | 849 | void (*poke_srmmu)(void) __cpuinitdata = NULL; |
806 | 850 | ||
807 | extern unsigned long bootmem_init(unsigned long *pages_avail); | 851 | extern unsigned long bootmem_init(unsigned long *pages_avail); |
@@ -816,6 +860,7 @@ void __init srmmu_paging_init(void) | |||
816 | pte_t *pte; | 860 | pte_t *pte; |
817 | unsigned long pages_avail; | 861 | unsigned long pages_avail; |
818 | 862 | ||
863 | init_mm.context = (unsigned long) NO_CONTEXT; | ||
819 | sparc_iomap.start = SUN4M_IOBASE_VADDR; /* 16MB of IOSPACE on all sun4m's. */ | 864 | sparc_iomap.start = SUN4M_IOBASE_VADDR; /* 16MB of IOSPACE on all sun4m's. */ |
820 | 865 | ||
821 | if (sparc_cpu_model == sun4d) | 866 | if (sparc_cpu_model == sun4d) |
@@ -918,6 +963,12 @@ void mmu_info(struct seq_file *m) | |||
918 | srmmu_nocache_map.used << SRMMU_NOCACHE_BITMAP_SHIFT); | 963 | srmmu_nocache_map.used << SRMMU_NOCACHE_BITMAP_SHIFT); |
919 | } | 964 | } |
920 | 965 | ||
966 | int init_new_context(struct task_struct *tsk, struct mm_struct *mm) | ||
967 | { | ||
968 | mm->context = NO_CONTEXT; | ||
969 | return 0; | ||
970 | } | ||
971 | |||
921 | void destroy_context(struct mm_struct *mm) | 972 | void destroy_context(struct mm_struct *mm) |
922 | { | 973 | { |
923 | 974 | ||