patch-2.4.6 linux/include/asm-mips/mmu_context.h

Next file: linux/include/asm-mips/orion.h
Previous file: linux/include/asm-mips/mipsregs.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.5/linux/include/asm-mips/mmu_context.h linux/include/asm-mips/mmu_context.h
@@ -1,5 +1,4 @@
-/* $Id: mmu_context.h,v 1.7 2000/02/04 07:40:53 ralf Exp $
- *
+/*
  * Switch a MMU context.
  *
  * This file is subject to the terms and conditions of the GNU General Public
@@ -13,11 +12,12 @@
 #define _ASM_MMU_CONTEXT_H
 
 #include <linux/config.h>
+#include <linux/slab.h>
 #include <asm/pgalloc.h>
 
 /* Fuck.  The f-word is here so you can grep for it :-)  */
 extern unsigned long asid_cache;
-extern pgd_t *current_pgd;
+extern pgd_t *current_pgd[];
 
 #if defined(CONFIG_CPU_R3000)
 
@@ -60,7 +60,19 @@
 extern inline int
 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 {
+#ifndef CONFIG_SMP
 	mm->context = 0;
+#else
+	mm->context = (unsigned long)kmalloc(smp_num_cpus * 
+				sizeof(unsigned long), GFP_KERNEL);
+	/*
+ 	 * Init the "context" values so that a tlbpid allocation 
+	 * happens on the first switch.
+ 	 */
+	if (mm->context == 0)
+		return -ENOMEM;
+	memset((void *)mm->context, 0, smp_num_cpus * sizeof(unsigned long));
+#endif
 	return 0;
 }
 
@@ -73,7 +85,7 @@
 	if ((next->context ^ asid) & ASID_VERSION_MASK)
 		get_new_mmu_context(next, asid);
 
-	current_pgd = next->pgd;
+	current_pgd[cpu] = next->pgd;
 	set_entryhi(next->context);
 }
 
@@ -96,7 +108,7 @@
 	/* Unconditionally get a new ASID.  */
 	get_new_mmu_context(next, asid_cache);
 
-	current_pgd = next->pgd;
+	current_pgd[smp_processor_id()] = next->pgd;
 	set_entryhi(next->context);
 }
 

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