linux-mips
[Top] [All Lists]

[PATCH 2/2] MIPS: microMIPS: Support dynamic ASID sizing.

To: linux-mips@linux-mips.org
Subject: [PATCH 2/2] MIPS: microMIPS: Support dynamic ASID sizing.
From: "Steven J. Hill" <sjhill@mips.com>
Date: Thu, 6 Dec 2012 23:30:22 -0600
Cc: "Steven J. Hill" <sjhill@mips.com>, ralf@linux-mips.org
In-reply-to: <1354858222-29519-1-git-send-email-sjhill@mips.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
References: <1354858222-29519-1-git-send-email-sjhill@mips.com>
Sender: linux-mips-bounce@linux-mips.org
From: "Steven J. Hill" <sjhill@mips.com>

Changes for pure microMIPS cores to dynamically determine the ASID
size at boot time.

Signed-off-by: Steven J. Hill <sjhill@mips.com>
---
 arch/mips/mm/tlbex.c |   31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 6983454..5ffec3d 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -267,11 +267,29 @@ static int check_for_high_segbits __cpuinitdata;
 static void __cpuinit insn_fixup(unsigned int **start, unsigned int **stop,
                                        unsigned int i_const)
 {
-       unsigned int **p, *ip;
+       unsigned int **p;
 
        for (p = start; p < stop; p++) {
+#ifndef CONFIG_CPU_MICROMIPS
+               unsigned int *ip;
+
                ip = *p;
                *ip = (*ip & 0xffff0000) | i_const;
+#else
+               unsigned short *ip;
+
+               ip = ((unsigned short *)((unsigned int)*p - 1));
+               if ((*ip & 0xf000) == 0x4000) {
+                       *ip &= 0xfff1;
+                       *ip |= (i_const << 1);
+               } else if ((*ip & 0xf000) == 0x6000) {
+                       *ip &= 0xfff1;
+                       *ip |= ((i_const >> 2) << 1);
+               } else {
+                       ip++;
+                       *ip = i_const;
+               }
+#endif
        }
 }
 
@@ -290,6 +308,14 @@ static void __cpuinit setup_asid(unsigned int inc, 
unsigned int mask,
        extern asmlinkage void handle_ri_rdhwr_vivt(void);
        unsigned long *vivt_exc;
 
+#ifdef CONFIG_CPU_MICROMIPS
+       /*
+        * Worst case optimised microMIPS addiu instructions support
+        * only a 3-bit immediate value.
+        */
+       if(inc > 7)
+               panic("Invalid ASID increment value!");
+#endif
        asid_insn_fixup(__asid_inc, inc);
        asid_insn_fixup(__asid_mask, mask);
        asid_insn_fixup(__asid_version_mask, version_mask);
@@ -297,6 +323,9 @@ static void __cpuinit setup_asid(unsigned int inc, unsigned 
int mask,
 
        /* Patch up the 'handle_ri_rdhwr_vivt' handler. */
        vivt_exc = (unsigned long *) &handle_ri_rdhwr_vivt;
+#ifdef CONFIG_CPU_MICROMIPS
+       vivt_exc = (unsigned long *)((unsigned long) vivt_exc - 1);
+#endif
        vivt_exc++;
        *vivt_exc = (*vivt_exc & ~mask) | mask;
 
-- 
1.7.9.5


<Prev in Thread] Current Thread [Next in Thread>