patch-2.3.13 linux/arch/sparc64/mm/init.c

Next file: linux/arch/sparc64/mm/ultra.S
Previous file: linux/arch/sparc64/mm/generic.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.12/linux/arch/sparc64/mm/init.c linux/arch/sparc64/mm/init.c
@@ -1,4 +1,4 @@
-/*  $Id: init.c,v 1.130 1999/06/29 12:34:06 davem Exp $
+/*  $Id: init.c,v 1.131 1999/07/30 09:35:45 davem Exp $
  *  arch/sparc64/mm/init.c
  *
  *  Copyright (C) 1996-1999 David S. Miller (davem@caip.rutgers.edu)
@@ -42,7 +42,10 @@
 unsigned long phys_base;
 
 /* get_new_mmu_context() uses "cache + 1".  */
+spinlock_t ctx_alloc_lock = SPIN_LOCK_UNLOCKED;
 unsigned long tlb_context_cache = CTX_FIRST_VERSION - 1;
+#define CTX_BMAP_SLOTS (1UL << (CTX_VERSION_SHIFT - 6))
+unsigned long mmu_context_bmap[CTX_BMAP_SLOTS];
 
 /* References to section boundaries */
 extern char __init_begin, __init_end, etext, __bss_start;
@@ -386,7 +389,7 @@
 				dvma_pages_current_offset;
 
 			/* Map the CPU's view. */
-			pgdp = pgd_offset(init_task.mm, addr);
+			pgdp = pgd_offset(&init_mm, addr);
 			pmdp = pmd_alloc_kernel(pgdp, addr);
 			ptep = pte_alloc_kernel(pmdp, addr);
 			pte = mk_pte(the_page, PAGE_KERNEL);
@@ -677,7 +680,7 @@
 			for (vaddr = trans[i].virt;
 			     vaddr < trans[i].virt + trans[i].size;
 			     vaddr += PAGE_SIZE) {
-				pgdp = pgd_offset(init_task.mm, vaddr);
+				pgdp = pgd_offset(&init_mm, vaddr);
 				if (pgd_none(*pgdp)) {
 					pmdp = sparc_init_alloc(&mempool,
 							 PMD_TABLE_SIZE);
@@ -739,7 +742,7 @@
 	int i;
 
 	if (!enter)
-		set_fs(current->tss.current_ds);
+		set_fs(current->thread.current_ds);
 
 	if (!prom_ditlb_set)
 		return;
@@ -957,9 +960,6 @@
 			     : : "r" (pstate));
 }
 
-#define CTX_BMAP_SLOTS (1UL << (CTX_VERSION_SHIFT - 6))
-unsigned long mmu_context_bmap[CTX_BMAP_SLOTS];
-
 /* Caller does TLB context flushing on local CPU if necessary.
  *
  * We must be careful about boundary cases so that we never
@@ -969,14 +969,16 @@
  */
 void get_new_mmu_context(struct mm_struct *mm)
 {
-	unsigned long ctx = (tlb_context_cache + 1) & ~(CTX_VERSION_MASK);
-	unsigned long new_ctx;
+	unsigned long ctx, new_ctx;
 	
+	spin_lock(&ctx_alloc_lock);
+	ctx = CTX_HWBITS(tlb_context_cache + 1);
 	if (ctx == 0)
 		ctx = 1;
-	if ((mm->context != NO_CONTEXT) &&
-	    !((mm->context ^ tlb_context_cache) & CTX_VERSION_MASK))
-		clear_bit(mm->context & ~(CTX_VERSION_MASK), mmu_context_bmap);
+	if (CTX_VALID(mm->context)) {
+		unsigned long nr = CTX_HWBITS(mm->context);
+		mmu_context_bmap[nr>>6] &= ~(1UL << (nr & 63));
+	}
 	new_ctx = find_next_zero_bit(mmu_context_bmap, 1UL << CTX_VERSION_SHIFT, ctx);
 	if (new_ctx >= (1UL << CTX_VERSION_SHIFT)) {
 		new_ctx = find_next_zero_bit(mmu_context_bmap, ctx, 1);
@@ -1003,12 +1005,13 @@
 			goto out;
 		}
 	}
-	set_bit(new_ctx, mmu_context_bmap);
+	mmu_context_bmap[new_ctx>>6] |= (1UL << (new_ctx & 63));
 	new_ctx |= (tlb_context_cache & CTX_VERSION_MASK);
 out:
 	tlb_context_cache = new_ctx;
+	spin_unlock(&ctx_alloc_lock);
+
 	mm->context = new_ctx;
-	mm->cpu_vm_mask = 0;
 }
 
 #ifndef __SMP__
@@ -1049,7 +1052,7 @@
 	pte_t *ptep;
 
 	while (start < end) {
-		pgdp = pgd_offset(init_task.mm, start);
+		pgdp = pgd_offset(&init_mm, start);
 		if (pgd_none(*pgdp)) {
 			pmdp = sparc_init_alloc(&mempool, PAGE_SIZE);
 			memset(pmdp, 0, PAGE_SIZE);
@@ -1073,7 +1076,7 @@
 void sparc_ultra_mapioaddr(unsigned long physaddr, unsigned long virt_addr,
 			   int bus, int rdonly)
 {
-	pgd_t *pgdp = pgd_offset(init_task.mm, virt_addr);
+	pgd_t *pgdp = pgd_offset(&init_mm, virt_addr);
 	pmd_t *pmdp = pmd_offset(pgdp, virt_addr);
 	pte_t *ptep = pte_offset(pmdp, virt_addr);
 	pte_t pte;
@@ -1095,7 +1098,7 @@
 	pmd_t *pmdp;
 	pte_t *ptep;
 
-	pgdp = pgd_offset(init_task.mm, virt_addr);
+	pgdp = pgd_offset(&init_mm, virt_addr);
 	pmdp = pmd_offset(pgdp, virt_addr);
 	ptep = pte_offset(pmdp, virt_addr);
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)