Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: tiansm@lemote.com
To: linux-mips@linux-mips.org
Cc: Fuxin Zhang <zhangfx@lemote.com>
Subject: [PATCH 14/15] tlb handling support for Loongson2 processor
Date: Wed,  6 Jun 2007 14:52:51 +0800	[thread overview]
Message-ID: <1181112774155-git-send-email-tiansm@lemote.com> (raw)
In-Reply-To: <11811127722019-git-send-email-tiansm@lemote.com>

From: Fuxin Zhang <zhangfx@lemote.com>

Signed-off-by: Fuxin Zhang <zhangfx@lemote.com>
---
 arch/mips/mm/tlb-r4k.c |   23 ++++++++++++++++++++++-
 arch/mips/mm/tlbex.c   |    8 +++++---
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
index 65160d4..dcd6913 100644
--- a/arch/mips/mm/tlb-r4k.c
+++ b/arch/mips/mm/tlb-r4k.c
@@ -48,6 +48,22 @@ extern void build_tlb_refill_handler(void);
 
 #endif /* CONFIG_MIPS_MT_SMTC */
 
+#if defined(CONFIG_CPU_LOONGSON2)
+/*
+ * LOONGSON2 has a 4 entry itlb which is a subset of dtlb,
+ * unfortrunately, itlb is not totally transparent to software.
+ */
+#define FLUSH_ITLB write_c0_diag(4);
+
+#define FLUSH_ITLB_VM(vma) { if ((vma)->vm_flags & VM_EXEC)  write_c0_diag(4); }
+
+#else
+
+#define FLUSH_ITLB
+#define FLUSH_ITLB_VM(vma)
+
+#endif
+
 void local_flush_tlb_all(void)
 {
 	unsigned long flags;
@@ -73,6 +89,7 @@ void local_flush_tlb_all(void)
 	}
 	tlbw_use_hazard();
 	write_c0_entryhi(old_ctx);
+	FLUSH_ITLB;
 	EXIT_CRITICAL(flags);
 }
 
@@ -136,6 +153,7 @@ void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
 		} else {
 			drop_mmu_context(mm, cpu);
 		}
+		FLUSH_ITLB;
 		EXIT_CRITICAL(flags);
 	}
 }
@@ -178,6 +196,7 @@ void local_flush_tlb_kernel_range(unsigned long start, unsigned long end)
 	} else {
 		local_flush_tlb_all();
 	}
+	FLUSH_ITLB;
 	EXIT_CRITICAL(flags);
 }
 
@@ -210,6 +229,7 @@ void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
 
 	finish:
 		write_c0_entryhi(oldpid);
+		FLUSH_ITLB_VM(vma);
 		EXIT_CRITICAL(flags);
 	}
 }
@@ -241,7 +261,7 @@ void local_flush_tlb_one(unsigned long page)
 		tlbw_use_hazard();
 	}
 	write_c0_entryhi(oldpid);
-
+	FLUSH_ITLB;
 	EXIT_CRITICAL(flags);
 }
 
@@ -293,6 +313,7 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)
 	else
 		tlb_write_indexed();
 	tlbw_use_hazard();
+	FLUSH_ITLB_VM(vma);
 	EXIT_CRITICAL(flags);
 }
 
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index e714929..4ec0964 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -893,6 +893,7 @@ static __init void build_tlb_write_entry(u32 **p, struct label **l,
 	case CPU_4KSC:
 	case CPU_20KC:
 	case CPU_25KF:
+	case CPU_LOONGSON2:
 		tlbw(p);
 		break;
 
@@ -1276,7 +1277,8 @@ static void __init build_r4000_tlb_refill_handler(void)
 	 * need three, with the second nop'ed and the third being
 	 * unused.
 	 */
-#ifdef CONFIG_32BIT
+	/* Loongson2 ebase is different than r4k, we have more space */
+#if defined(CONFIG_32BIT) || defined(CONFIG_CPU_LOONGSON2)
 	if ((p - tlb_handler) > 64)
 		panic("TLB refill handler space exceeded");
 #else
@@ -1289,7 +1291,7 @@ static void __init build_r4000_tlb_refill_handler(void)
 	/*
 	 * Now fold the handler in the TLB refill handler space.
 	 */
-#ifdef CONFIG_32BIT
+#if defined(CONFIG_32BIT) || defined(CONFIG_CPU_LOONGSON2)
 	f = final_handler;
 	/* Simplest case, just copy the handler. */
 	copy_handler(relocs, labels, tlb_handler, p, f);
@@ -1336,7 +1338,7 @@ static void __init build_r4000_tlb_refill_handler(void)
 		final_len);
 
 	f = final_handler;
-#ifdef CONFIG_64BIT
+#if defined(CONFIG_64BIT) && !defined(CONFIG_CPU_LOONGSON2)
 	if (final_len > 32)
 		final_len = 64;
 	else
-- 
1.5.2.1

  parent reply	other threads:[~2007-06-06  6:57 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-06  6:52 Lemote Loongson 2E patch update [take 2] tiansm
2007-06-06  6:52 ` [PATCH 01/15] new files for lemote fulong mini-PC support tiansm
2007-06-11 15:40   ` Ralf Baechle
2007-06-06  6:52 ` [PATCH 02/15] arch related Makefile update for lemote fulong mini-PC tiansm
2007-06-06  6:52 ` [PATCH 03/15] Kconfig update for lemote fulong miniPC tiansm
2007-06-06  6:52 ` [PATCH 04/15] TO_PHYS_MASK for loongson2 tiansm
2007-06-06 17:41   ` Ralf Baechle
2007-06-06  6:52 ` [PATCH 05/15] add MACH_GROUP_LEMOTE & MACH_LEMOTE_FULONG tiansm
2007-06-06  6:52 ` [PATCH 06/15] define Hit_Invalidate_I to Index_Invalidate_I for loongson2 tiansm
2007-06-06  6:52 ` [PATCH 07/15] add Loongson processor definitions tiansm
2007-06-06  6:52 ` [PATCH 08/15] define MODULE_PROC_FAMILY for Loongson2 tiansm
2007-06-06  6:52 ` [PATCH 09/15] add serial port definition for lemote fulong tiansm
2007-06-12 12:34   ` Ralf Baechle
2007-06-12 12:57     ` Fuxin Zhang
2007-06-12 13:01       ` Ralf Baechle
2007-06-13 18:57       ` Ralf Baechle
2007-06-06  6:52 ` [PATCH 10/15] make cpu_probe recognize Loongson2 tiansm
2007-06-06  6:52 ` [PATCH 11/15] add Loongson support to /proc/cpuinfo tiansm
2007-06-06  6:52 ` [PATCH 12/15] cheat for support of more than 256MB memory tiansm
2007-06-06  6:52 ` [PATCH 13/15] define MODULE_PROC_FAMILY for Loongson2 tiansm
2007-06-06  6:52 ` tiansm [this message]
2007-06-06  6:52 ` [PATCH 15/15] work around for more than 256MB memory support tiansm
2007-06-06  8:01   ` Franck Bui-Huu
2007-06-06 18:28     ` Ralf Baechle
2007-06-07  6:04       ` [PATCH] override of arch/mips/mm/cache.c: __uncached_access tiansm
2007-06-07  6:22         ` Fuxin Zhang
2007-06-07 17:05           ` Ralf Baechle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1181112774155-git-send-email-tiansm@lemote.com \
    --to=tiansm@lemote.com \
    --cc=linux-mips@linux-mips.org \
    --cc=zhangfx@lemote.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox