From: David Daney <ddaney@caviumnetworks.com>
To: linux-mips@linux-mips.org, ralf@linux-mips.org
Cc: David Daney <ddaney@caviumnetworks.com>,
David VomLehn <dvomlehn@cisco.com>
Subject: [PATCH 1/2] MIPS: Replace some magic numbers with symbolic values in tlbex.c (v2)
Date: Wed, 20 May 2009 11:40:58 -0700 [thread overview]
Message-ID: <1242844859-6788-1-git-send-email-ddaney@caviumnetworks.com> (raw)
In-Reply-To: <4A144DFF.90602@caviumnetworks.com>
The logic used to split the r4000 refill handler is liberally
sprinkled with magic numbers. We attempt to explain what they are and
normalize them against a new symbolic value (MIPS64_REFILL_INSNS).
Changes from v1: Corrected spelling in comment.
CC: David VomLehn <dvomlehn@cisco.com>
Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
---
arch/mips/mm/tlbex.c | 34 ++++++++++++++++++++++++++--------
1 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 4dc4f3e..cbc09de 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -649,6 +649,14 @@ static void __cpuinit build_update_entries(u32 **p, unsigned int tmp,
#endif
}
+/*
+ * For a 64-bit kernel, we are using the 64-bit XTLB refill exception
+ * because EXL == 0. If we wrap, we can also use the 32 instruction
+ * slots before the XTLB refill exception handler which belong to the
+ * unused TLB refill exception.
+ */
+#define MIPS64_REFILL_INSNS 32
+
static void __cpuinit build_r4000_tlb_refill_handler(void)
{
u32 *p = tlb_handler;
@@ -702,9 +710,10 @@ static void __cpuinit build_r4000_tlb_refill_handler(void)
if ((p - tlb_handler) > 64)
panic("TLB refill handler space exceeded");
#else
- if (((p - tlb_handler) > 63)
- || (((p - tlb_handler) > 61)
- && uasm_insn_has_bdelay(relocs, tlb_handler + 29)))
+ if (((p - tlb_handler) > (MIPS64_REFILL_INSNS * 2) - 1)
+ || (((p - tlb_handler) > (MIPS64_REFILL_INSNS * 2) - 3)
+ && uasm_insn_has_bdelay(relocs,
+ tlb_handler + MIPS64_REFILL_INSNS - 3)))
panic("TLB refill handler space exceeded");
#endif
@@ -717,16 +726,24 @@ static void __cpuinit build_r4000_tlb_refill_handler(void)
uasm_copy_handler(relocs, labels, tlb_handler, p, f);
final_len = p - tlb_handler;
#else /* CONFIG_64BIT */
- f = final_handler + 32;
- if ((p - tlb_handler) <= 32) {
+ f = final_handler + MIPS64_REFILL_INSNS;
+ if ((p - tlb_handler) <= MIPS64_REFILL_INSNS) {
/* Just copy the handler. */
uasm_copy_handler(relocs, labels, tlb_handler, p, f);
final_len = p - tlb_handler;
} else {
- u32 *split = tlb_handler + 30;
+ /*
+ * Split two instructions before the end. One for the
+ * branch and one for the instruction in the delay
+ * slot.
+ */
+ u32 *split = tlb_handler + MIPS64_REFILL_INSNS - 2;
/*
- * Find the split point.
+ * Find the split point. If the branch would fall in
+ * a delay slot, we must back up an additional
+ * instruction so that it is no longer in a delay
+ * slot.
*/
if (uasm_insn_has_bdelay(relocs, split - 1))
split--;
@@ -749,7 +766,8 @@ static void __cpuinit build_r4000_tlb_refill_handler(void)
/* Copy the rest of the handler. */
uasm_copy_handler(relocs, labels, split, p, final_handler);
- final_len = (f - (final_handler + 32)) + (p - split);
+ final_len = (f - (final_handler + MIPS64_REFILL_INSNS)) +
+ (p - split);
}
#endif /* CONFIG_64BIT */
--
1.6.0.6
next prev parent reply other threads:[~2009-05-20 18:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-20 18:37 [PATCH 0/2] Optimize TLB refill handler folding and cleanup David Daney
2009-05-20 18:40 ` David Daney [this message]
2009-05-20 18:40 ` [PATCH 2/2] MIPS: Fold the TLB refill at the vmalloc path if possible David Daney
2009-05-20 19:06 ` [PATCH 0/2] Optimize TLB refill handler folding and cleanup Ralf Baechle
-- strict thread matches above, loose matches on Subject: below --
2009-05-13 20:48 [PATCH 1/2] MIPS: Replace some magic numbers with symbolic values in tlbex.c David Daney
2009-05-13 22:20 ` [PATCH 1/2] MIPS: Replace some magic numbers with symbolic values in tlbex.c (v2) David Daney
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=1242844859-6788-1-git-send-email-ddaney@caviumnetworks.com \
--to=ddaney@caviumnetworks.com \
--cc=dvomlehn@cisco.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
/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