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/sparc/mm | |
| 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/sparc/mm')
| -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 |
3 files changed, 60 insertions, 33 deletions
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 | ||
