aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kristiansson <stefan.kristiansson@saunalahti.fi>2013-08-01 03:46:10 -0400
committerStafford Horne <shorne@gmail.com>2017-02-06 07:50:42 -0500
commit742fb582b4540a7b59427dc67be1fe4a5eac7078 (patch)
tree8816ae13e2f26150a9733486b757ced6ed089d50
parent3e06a16339303016b2c57b350a15afeaa7ba7813 (diff)
openrisc: tlb miss handler optimizations
By slightly reorganizing the code, the number of registers used in the tlb miss handlers can be reduced by two, thus removing the need to save them to memory. Also, some dead and commented out code is removed. No functional change. Signed-off-by: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi> Signed-off-by: Jonas Bonn <jonas@southpole.se> Signed-off-by: Stafford Horne <shorne@gmail.com>
-rw-r--r--arch/openrisc/kernel/head.S141
1 files changed, 46 insertions, 95 deletions
diff --git a/arch/openrisc/kernel/head.S b/arch/openrisc/kernel/head.S
index f14793306b03..2346c5b39095 100644
--- a/arch/openrisc/kernel/head.S
+++ b/arch/openrisc/kernel/head.S
@@ -971,8 +971,6 @@ ENTRY(dtlb_miss_handler)
971 EXCEPTION_STORE_GPR2 971 EXCEPTION_STORE_GPR2
972 EXCEPTION_STORE_GPR3 972 EXCEPTION_STORE_GPR3
973 EXCEPTION_STORE_GPR4 973 EXCEPTION_STORE_GPR4
974 EXCEPTION_STORE_GPR5
975 EXCEPTION_STORE_GPR6
976 /* 974 /*
977 * get EA of the miss 975 * get EA of the miss
978 */ 976 */
@@ -980,91 +978,70 @@ ENTRY(dtlb_miss_handler)
980 /* 978 /*
981 * pmd = (pmd_t *)(current_pgd + pgd_index(daddr)); 979 * pmd = (pmd_t *)(current_pgd + pgd_index(daddr));
982 */ 980 */
983 GET_CURRENT_PGD(r3,r5) // r3 is current_pgd, r5 is temp 981 GET_CURRENT_PGD(r3,r4) // r3 is current_pgd, r4 is temp
984 l.srli r4,r2,0x18 // >> PAGE_SHIFT + (PAGE_SHIFT - 2) 982 l.srli r4,r2,0x18 // >> PAGE_SHIFT + (PAGE_SHIFT - 2)
985 l.slli r4,r4,0x2 // to get address << 2 983 l.slli r4,r4,0x2 // to get address << 2
986 l.add r5,r4,r3 // r4 is pgd_index(daddr) 984 l.add r3,r4,r3 // r4 is pgd_index(daddr)
987 /* 985 /*
988 * if (pmd_none(*pmd)) 986 * if (pmd_none(*pmd))
989 * goto pmd_none: 987 * goto pmd_none:
990 */ 988 */
991 tophys (r4,r5) 989 tophys (r4,r3)
992 l.lwz r3,0x0(r4) // get *pmd value 990 l.lwz r3,0x0(r4) // get *pmd value
993 l.sfne r3,r0 991 l.sfne r3,r0
994 l.bnf d_pmd_none 992 l.bnf d_pmd_none
995 l.andi r3,r3,~PAGE_MASK //0x1fff // ~PAGE_MASK 993 l.addi r3,r0,0xffffe000 // PAGE_MASK
996 /* 994
997 * if (pmd_bad(*pmd))
998 * pmd_clear(pmd)
999 * goto pmd_bad:
1000 */
1001// l.sfeq r3,r0 // check *pmd value
1002// l.bf d_pmd_good
1003 l.addi r3,r0,0xffffe000 // PAGE_MASK
1004// l.j d_pmd_bad
1005// l.sw 0x0(r4),r0 // clear pmd
1006d_pmd_good: 995d_pmd_good:
1007 /* 996 /*
1008 * pte = *pte_offset(pmd, daddr); 997 * pte = *pte_offset(pmd, daddr);
1009 */ 998 */
1010 l.lwz r4,0x0(r4) // get **pmd value 999 l.lwz r4,0x0(r4) // get **pmd value
1011 l.and r4,r4,r3 // & PAGE_MASK 1000 l.and r4,r4,r3 // & PAGE_MASK
1012 l.srli r5,r2,0xd // >> PAGE_SHIFT, r2 == EEAR 1001 l.srli r2,r2,0xd // >> PAGE_SHIFT, r2 == EEAR
1013 l.andi r3,r5,0x7ff // (1UL << PAGE_SHIFT - 2) - 1 1002 l.andi r3,r2,0x7ff // (1UL << PAGE_SHIFT - 2) - 1
1014 l.slli r3,r3,0x2 // to get address << 2 1003 l.slli r3,r3,0x2 // to get address << 2
1015 l.add r3,r3,r4 1004 l.add r3,r3,r4
1016 l.lwz r2,0x0(r3) // this is pte at last 1005 l.lwz r3,0x0(r3) // this is pte at last
1017 /* 1006 /*
1018 * if (!pte_present(pte)) 1007 * if (!pte_present(pte))
1019 */ 1008 */
1020 l.andi r4,r2,0x1 1009 l.andi r4,r3,0x1
1021 l.sfne r4,r0 // is pte present 1010 l.sfne r4,r0 // is pte present
1022 l.bnf d_pte_not_present 1011 l.bnf d_pte_not_present
1023 l.addi r3,r0,0xffffe3fa // PAGE_MASK | DTLB_UP_CONVERT_MASK 1012 l.addi r4,r0,0xffffe3fa // PAGE_MASK | DTLB_UP_CONVERT_MASK
1024 /* 1013 /*
1025 * fill DTLB TR register 1014 * fill DTLB TR register
1026 */ 1015 */
1027 l.and r4,r2,r3 // apply the mask 1016 l.and r4,r3,r4 // apply the mask
1028 // Determine number of DMMU sets 1017 // Determine number of DMMU sets
1029 l.mfspr r6, r0, SPR_DMMUCFGR 1018 l.mfspr r2, r0, SPR_DMMUCFGR
1030 l.andi r6, r6, SPR_DMMUCFGR_NTS 1019 l.andi r2, r2, SPR_DMMUCFGR_NTS
1031 l.srli r6, r6, SPR_DMMUCFGR_NTS_OFF 1020 l.srli r2, r2, SPR_DMMUCFGR_NTS_OFF
1032 l.ori r3, r0, 0x1 1021 l.ori r3, r0, 0x1
1033 l.sll r3, r3, r6 // r3 = number DMMU sets DMMUCFGR 1022 l.sll r3, r3, r2 // r3 = number DMMU sets DMMUCFGR
1034 l.addi r6, r3, -1 // r6 = nsets mask 1023 l.addi r2, r3, -1 // r2 = nsets mask
1035 l.and r5, r5, r6 // calc offset: & (NUM_TLB_ENTRIES-1) 1024 l.mfspr r3, r0, SPR_EEAR_BASE
1025 l.srli r3, r3, 0xd // >> PAGE_SHIFT
1026 l.and r2, r3, r2 // calc offset: & (NUM_TLB_ENTRIES-1)
1036 //NUM_TLB_ENTRIES 1027 //NUM_TLB_ENTRIES
1037 l.mtspr r5,r4,SPR_DTLBTR_BASE(0) 1028 l.mtspr r2,r4,SPR_DTLBTR_BASE(0)
1038 /* 1029 /*
1039 * fill DTLB MR register 1030 * fill DTLB MR register
1040 */ 1031 */
1041 l.mfspr r2,r0,SPR_EEAR_BASE 1032 l.slli r3, r3, 0xd /* << PAGE_SHIFT => EA & PAGE_MASK */
1042 l.addi r3,r0,0xffffe000 // PAGE_MASK 1033 l.ori r4,r3,0x1 // set hardware valid bit: DTBL_MR entry
1043 l.and r4,r2,r3 // apply PAGE_MASK to EA (__PHX__ do we really need this?) 1034 l.mtspr r2,r4,SPR_DTLBMR_BASE(0)
1044 l.ori r4,r4,0x1 // set hardware valid bit: DTBL_MR entry
1045 l.mtspr r5,r4,SPR_DTLBMR_BASE(0)
1046 1035
1047 EXCEPTION_LOAD_GPR2 1036 EXCEPTION_LOAD_GPR2
1048 EXCEPTION_LOAD_GPR3 1037 EXCEPTION_LOAD_GPR3
1049 EXCEPTION_LOAD_GPR4 1038 EXCEPTION_LOAD_GPR4
1050 EXCEPTION_LOAD_GPR5
1051 EXCEPTION_LOAD_GPR6
1052 l.rfe
1053d_pmd_bad:
1054 l.nop 1
1055 EXCEPTION_LOAD_GPR2
1056 EXCEPTION_LOAD_GPR3
1057 EXCEPTION_LOAD_GPR4
1058 EXCEPTION_LOAD_GPR5
1059 EXCEPTION_LOAD_GPR6
1060 l.rfe 1039 l.rfe
1061d_pmd_none: 1040d_pmd_none:
1062d_pte_not_present: 1041d_pte_not_present:
1063 EXCEPTION_LOAD_GPR2 1042 EXCEPTION_LOAD_GPR2
1064 EXCEPTION_LOAD_GPR3 1043 EXCEPTION_LOAD_GPR3
1065 EXCEPTION_LOAD_GPR4 1044 EXCEPTION_LOAD_GPR4
1066 EXCEPTION_LOAD_GPR5
1067 EXCEPTION_LOAD_GPR6
1068 EXCEPTION_HANDLE(_dtlb_miss_page_fault_handler) 1045 EXCEPTION_HANDLE(_dtlb_miss_page_fault_handler)
1069 1046
1070/* ==============================================[ ITLB miss handler ]=== */ 1047/* ==============================================[ ITLB miss handler ]=== */
@@ -1072,8 +1049,6 @@ ENTRY(itlb_miss_handler)
1072 EXCEPTION_STORE_GPR2 1049 EXCEPTION_STORE_GPR2
1073 EXCEPTION_STORE_GPR3 1050 EXCEPTION_STORE_GPR3
1074 EXCEPTION_STORE_GPR4 1051 EXCEPTION_STORE_GPR4
1075 EXCEPTION_STORE_GPR5
1076 EXCEPTION_STORE_GPR6
1077 /* 1052 /*
1078 * get EA of the miss 1053 * get EA of the miss
1079 */ 1054 */
@@ -1083,30 +1058,19 @@ ENTRY(itlb_miss_handler)
1083 * pmd = (pmd_t *)(current_pgd + pgd_index(daddr)); 1058 * pmd = (pmd_t *)(current_pgd + pgd_index(daddr));
1084 * 1059 *
1085 */ 1060 */
1086 GET_CURRENT_PGD(r3,r5) // r3 is current_pgd, r5 is temp 1061 GET_CURRENT_PGD(r3,r4) // r3 is current_pgd, r5 is temp
1087 l.srli r4,r2,0x18 // >> PAGE_SHIFT + (PAGE_SHIFT - 2) 1062 l.srli r4,r2,0x18 // >> PAGE_SHIFT + (PAGE_SHIFT - 2)
1088 l.slli r4,r4,0x2 // to get address << 2 1063 l.slli r4,r4,0x2 // to get address << 2
1089 l.add r5,r4,r3 // r4 is pgd_index(daddr) 1064 l.add r3,r4,r3 // r4 is pgd_index(daddr)
1090 /* 1065 /*
1091 * if (pmd_none(*pmd)) 1066 * if (pmd_none(*pmd))
1092 * goto pmd_none: 1067 * goto pmd_none:
1093 */ 1068 */
1094 tophys (r4,r5) 1069 tophys (r4,r3)
1095 l.lwz r3,0x0(r4) // get *pmd value 1070 l.lwz r3,0x0(r4) // get *pmd value
1096 l.sfne r3,r0 1071 l.sfne r3,r0
1097 l.bnf i_pmd_none 1072 l.bnf i_pmd_none
1098 l.andi r3,r3,0x1fff // ~PAGE_MASK 1073 l.addi r3,r0,0xffffe000 // PAGE_MASK
1099 /*
1100 * if (pmd_bad(*pmd))
1101 * pmd_clear(pmd)
1102 * goto pmd_bad:
1103 */
1104
1105// l.sfeq r3,r0 // check *pmd value
1106// l.bf i_pmd_good
1107 l.addi r3,r0,0xffffe000 // PAGE_MASK
1108// l.j i_pmd_bad
1109// l.sw 0x0(r4),r0 // clear pmd
1110 1074
1111i_pmd_good: 1075i_pmd_good:
1112 /* 1076 /*
@@ -1115,35 +1079,36 @@ i_pmd_good:
1115 */ 1079 */
1116 l.lwz r4,0x0(r4) // get **pmd value 1080 l.lwz r4,0x0(r4) // get **pmd value
1117 l.and r4,r4,r3 // & PAGE_MASK 1081 l.and r4,r4,r3 // & PAGE_MASK
1118 l.srli r5,r2,0xd // >> PAGE_SHIFT, r2 == EEAR 1082 l.srli r2,r2,0xd // >> PAGE_SHIFT, r2 == EEAR
1119 l.andi r3,r5,0x7ff // (1UL << PAGE_SHIFT - 2) - 1 1083 l.andi r3,r2,0x7ff // (1UL << PAGE_SHIFT - 2) - 1
1120 l.slli r3,r3,0x2 // to get address << 2 1084 l.slli r3,r3,0x2 // to get address << 2
1121 l.add r3,r3,r4 1085 l.add r3,r3,r4
1122 l.lwz r2,0x0(r3) // this is pte at last 1086 l.lwz r3,0x0(r3) // this is pte at last
1123 /* 1087 /*
1124 * if (!pte_present(pte)) 1088 * if (!pte_present(pte))
1125 * 1089 *
1126 */ 1090 */
1127 l.andi r4,r2,0x1 1091 l.andi r4,r3,0x1
1128 l.sfne r4,r0 // is pte present 1092 l.sfne r4,r0 // is pte present
1129 l.bnf i_pte_not_present 1093 l.bnf i_pte_not_present
1130 l.addi r3,r0,0xffffe03a // PAGE_MASK | ITLB_UP_CONVERT_MASK 1094 l.addi r4,r0,0xffffe03a // PAGE_MASK | ITLB_UP_CONVERT_MASK
1131 /* 1095 /*
1132 * fill ITLB TR register 1096 * fill ITLB TR register
1133 */ 1097 */
1134 l.and r4,r2,r3 // apply the mask 1098 l.and r4,r3,r4 // apply the mask
1135 l.andi r3,r2,0x7c0 // _PAGE_EXEC | _PAGE_SRE | _PAGE_SWE | _PAGE_URE | _PAGE_UWE 1099 l.andi r3,r3,0x7c0 // _PAGE_EXEC | _PAGE_SRE | _PAGE_SWE | _PAGE_URE | _PAGE_UWE
1136// l.andi r3,r2,0x400 // _PAGE_EXEC
1137 l.sfeq r3,r0 1100 l.sfeq r3,r0
1138 l.bf itlb_tr_fill //_workaround 1101 l.bf itlb_tr_fill //_workaround
1139 // Determine number of IMMU sets 1102 // Determine number of IMMU sets
1140 l.mfspr r6, r0, SPR_IMMUCFGR 1103 l.mfspr r2, r0, SPR_IMMUCFGR
1141 l.andi r6, r6, SPR_IMMUCFGR_NTS 1104 l.andi r2, r2, SPR_IMMUCFGR_NTS
1142 l.srli r6, r6, SPR_IMMUCFGR_NTS_OFF 1105 l.srli r2, r2, SPR_IMMUCFGR_NTS_OFF
1143 l.ori r3, r0, 0x1 1106 l.ori r3, r0, 0x1
1144 l.sll r3, r3, r6 // r3 = number IMMU sets IMMUCFGR 1107 l.sll r3, r3, r2 // r3 = number IMMU sets IMMUCFGR
1145 l.addi r6, r3, -1 // r6 = nsets mask 1108 l.addi r2, r3, -1 // r2 = nsets mask
1146 l.and r5, r5, r6 // calc offset: & (NUM_TLB_ENTRIES-1) 1109 l.mfspr r3, r0, SPR_EEAR_BASE
1110 l.srli r3, r3, 0xd // >> PAGE_SHIFT
1111 l.and r2, r3, r2 // calc offset: & (NUM_TLB_ENTRIES-1)
1147 1112
1148/* 1113/*
1149 * __PHX__ :: fixme 1114 * __PHX__ :: fixme
@@ -1155,38 +1120,24 @@ i_pmd_good:
1155itlb_tr_fill_workaround: 1120itlb_tr_fill_workaround:
1156 l.ori r4,r4,0xc0 // | (SPR_ITLBTR_UXE | ITLBTR_SXE) 1121 l.ori r4,r4,0xc0 // | (SPR_ITLBTR_UXE | ITLBTR_SXE)
1157itlb_tr_fill: 1122itlb_tr_fill:
1158 l.mtspr r5,r4,SPR_ITLBTR_BASE(0) 1123 l.mtspr r2,r4,SPR_ITLBTR_BASE(0)
1159 /* 1124 /*
1160 * fill DTLB MR register 1125 * fill DTLB MR register
1161 */ 1126 */
1162 l.mfspr r2,r0,SPR_EEAR_BASE 1127 l.slli r3, r3, 0xd /* << PAGE_SHIFT => EA & PAGE_MASK */
1163 l.addi r3,r0,0xffffe000 // PAGE_MASK 1128 l.ori r4,r3,0x1 // set hardware valid bit: ITBL_MR entry
1164 l.and r4,r2,r3 // apply PAGE_MASK to EA (__PHX__ do we really need this?) 1129 l.mtspr r2,r4,SPR_ITLBMR_BASE(0)
1165 l.ori r4,r4,0x1 // set hardware valid bit: DTBL_MR entry
1166 l.mtspr r5,r4,SPR_ITLBMR_BASE(0)
1167 1130
1168 EXCEPTION_LOAD_GPR2 1131 EXCEPTION_LOAD_GPR2
1169 EXCEPTION_LOAD_GPR3 1132 EXCEPTION_LOAD_GPR3
1170 EXCEPTION_LOAD_GPR4 1133 EXCEPTION_LOAD_GPR4
1171 EXCEPTION_LOAD_GPR5
1172 EXCEPTION_LOAD_GPR6
1173 l.rfe 1134 l.rfe
1174 1135
1175i_pmd_bad:
1176 l.nop 1
1177 EXCEPTION_LOAD_GPR2
1178 EXCEPTION_LOAD_GPR3
1179 EXCEPTION_LOAD_GPR4
1180 EXCEPTION_LOAD_GPR5
1181 EXCEPTION_LOAD_GPR6
1182 l.rfe
1183i_pmd_none: 1136i_pmd_none:
1184i_pte_not_present: 1137i_pte_not_present:
1185 EXCEPTION_LOAD_GPR2 1138 EXCEPTION_LOAD_GPR2
1186 EXCEPTION_LOAD_GPR3 1139 EXCEPTION_LOAD_GPR3
1187 EXCEPTION_LOAD_GPR4 1140 EXCEPTION_LOAD_GPR4
1188 EXCEPTION_LOAD_GPR5
1189 EXCEPTION_LOAD_GPR6
1190 EXCEPTION_HANDLE(_itlb_miss_page_fault_handler) 1141 EXCEPTION_HANDLE(_itlb_miss_page_fault_handler)
1191 1142
1192/* ==============================================[ boot tlb handlers ]=== */ 1143/* ==============================================[ boot tlb handlers ]=== */