All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MIPS: Don't branch to eret in TLB refill.
@ 2009-05-12 22:45 David Daney
  2009-05-13  0:23 ` David VomLehn
  0 siblings, 1 reply; 10+ messages in thread
From: David Daney @ 2009-05-12 22:45 UTC (permalink / raw)
  To: linux-mips, ralf; +Cc: David Daney

If the TLB refill handler is too bit and needs to be split, there is
no need to branch around the split if the branch target would be an
eret.  Since the eret returns from the handler, control flow never
passes it.  A branch to an eret is equivalent to the eret itself.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
---
 arch/mips/mm/tlbex.c |   50 +++++++++++++++++++++++++++++++++-----------------
 1 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 4dc4f3e..ffa7104 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -656,6 +656,7 @@ static void __cpuinit build_r4000_tlb_refill_handler(void)
 	struct uasm_reloc *r = relocs;
 	u32 *f;
 	unsigned int final_len;
+	int split_on_eret;
 
 	memset(tlb_handler, 0, sizeof(tlb_handler));
 	memset(labels, 0, sizeof(labels));
@@ -684,6 +685,13 @@ static void __cpuinit build_r4000_tlb_refill_handler(void)
 	build_update_entries(&p, K0, K1);
 	build_tlb_write_entry(&p, &l, &r, tlb_random);
 	uasm_l_leave(&l, p);
+
+	/*
+	 * Check to see if the eret will be the last instruction
+	 * before the split.  If it is, there is no need to branch
+	 * around the split, as we are returning.
+	 */
+	split_on_eret = (p - tlb_handler == 31);
 	uasm_i_eret(&p); /* return from trap */
 
 #ifdef CONFIG_64BIT
@@ -723,28 +731,36 @@ static void __cpuinit build_r4000_tlb_refill_handler(void)
 		uasm_copy_handler(relocs, labels, tlb_handler, p, f);
 		final_len = p - tlb_handler;
 	} else {
-		u32 *split = tlb_handler + 30;
-
-		/*
-		 * Find the split point.
-		 */
-		if (uasm_insn_has_bdelay(relocs, split - 1))
-			split--;
+		u32 *split;
+		if (split_on_eret) {
+			split = tlb_handler + 32;
+		} else {
+			split = tlb_handler + 30;
+
+			/*
+			 * Find the split point.
+			 */
+			if (uasm_insn_has_bdelay(relocs, split - 1))
+				split--;
+		}
 
 		/* Copy first part of the handler. */
 		uasm_copy_handler(relocs, labels, tlb_handler, split, f);
 		f += split - tlb_handler;
 
-		/* Insert branch. */
-		uasm_l_split(&l, final_handler);
-		uasm_il_b(&f, &r, label_split);
-		if (uasm_insn_has_bdelay(relocs, split))
-			uasm_i_nop(&f);
-		else {
-			uasm_copy_handler(relocs, labels, split, split + 1, f);
-			uasm_move_labels(labels, f, f + 1, -1);
-			f++;
-			split++;
+		if (!split_on_eret) {
+			/* Insert branch. */
+			uasm_l_split(&l, final_handler);
+			uasm_il_b(&f, &r, label_split);
+			if (uasm_insn_has_bdelay(relocs, split))
+				uasm_i_nop(&f);
+			else {
+				uasm_copy_handler(relocs, labels,
+						  split, split + 1, f);
+				uasm_move_labels(labels, f, f + 1, -1);
+				f++;
+				split++;
+			}
 		}
 
 		/* Copy the rest of the handler. */
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-05-18 23:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-12 22:45 [PATCH] MIPS: Don't branch to eret in TLB refill David Daney
2009-05-13  0:23 ` David VomLehn
2009-05-13  1:12   ` David Daney
2009-05-13  2:01     ` Paul Gortmaker
2009-05-16  7:28     ` Maciej W. Rozycki
2009-05-18 16:25       ` David Daney
2009-05-18 17:48         ` Maciej W. Rozycki
2009-05-18 19:32           ` [PATCH] MIPS: Fold the TLB refill at the vmalloc path if possible Maciej W. Rozycki
2009-05-18 23:26             ` David Daney
2009-05-18 23:33               ` Maciej W. Rozycki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.