aboutsummaryrefslogtreecommitdiffstats
path: root/arch/tile/mm
diff options
context:
space:
mode:
authorChris Metcalf <cmetcalf@tilera.com>2012-03-27 15:40:20 -0400
committerChris Metcalf <cmetcalf@tilera.com>2012-05-25 12:48:20 -0400
commit51007004f44c9588d70ffb77e1f52479bd5b0e37 (patch)
treeddf8dd2f83554ecbe9de0c690cfab3889308397b /arch/tile/mm
parent76e10d158efb6d4516018846f60c2ab5501900bc (diff)
arch/tile: use interrupt critical sections less
In general we want to avoid ever touching memory while within an interrupt critical section, since the page fault path goes through a different path from the hypervisor when in an interrupt critical section, and we carefully decided with tilegx that we didn't need to support this path in the kernel. (On tilepro we did implement that path as part of supporting atomic instructions in software.) In practice we always need to touch the kernel stack, since that's where we store the interrupt state before releasing the critical section, but this change cleans up a few things. The IRQ_ENABLE macro is split up so that when we want to enable interrupts in a deferred way (e.g. for cpu_idle or for interrupt return) we can read the per-cpu enable mask before entering the critical section. The cache-migration code is changed to use interrupt masking instead of interrupt critical sections. And, the interrupt-entry code is changed so that we defer loading "tp" from per-cpu data until after we have released the interrupt critical section. Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Diffstat (limited to 'arch/tile/mm')
-rw-r--r--arch/tile/mm/init.c4
-rw-r--r--arch/tile/mm/migrate.h6
-rw-r--r--arch/tile/mm/migrate_32.S36
-rw-r--r--arch/tile/mm/migrate_64.S34
4 files changed, 25 insertions, 55 deletions
diff --git a/arch/tile/mm/init.c b/arch/tile/mm/init.c
index 6a9d20ddc34f..1e4633520b35 100644
--- a/arch/tile/mm/init.c
+++ b/arch/tile/mm/init.c
@@ -444,6 +444,7 @@ static pgd_t pgtables[PTRS_PER_PGD]
444 */ 444 */
445static void __init kernel_physical_mapping_init(pgd_t *pgd_base) 445static void __init kernel_physical_mapping_init(pgd_t *pgd_base)
446{ 446{
447 unsigned long long irqmask;
447 unsigned long address, pfn; 448 unsigned long address, pfn;
448 pmd_t *pmd; 449 pmd_t *pmd;
449 pte_t *pte; 450 pte_t *pte;
@@ -633,10 +634,13 @@ static void __init kernel_physical_mapping_init(pgd_t *pgd_base)
633 * - install pgtables[] as the real page table 634 * - install pgtables[] as the real page table
634 * - flush the TLB so the new page table takes effect 635 * - flush the TLB so the new page table takes effect
635 */ 636 */
637 irqmask = interrupt_mask_save_mask();
638 interrupt_mask_set_mask(-1ULL);
636 rc = flush_and_install_context(__pa(pgtables), 639 rc = flush_and_install_context(__pa(pgtables),
637 init_pgprot((unsigned long)pgtables), 640 init_pgprot((unsigned long)pgtables),
638 __get_cpu_var(current_asid), 641 __get_cpu_var(current_asid),
639 cpumask_bits(my_cpu_mask)); 642 cpumask_bits(my_cpu_mask));
643 interrupt_mask_restore_mask(irqmask);
640 BUG_ON(rc != 0); 644 BUG_ON(rc != 0);
641 645
642 /* Copy the page table back to the normal swapper_pg_dir. */ 646 /* Copy the page table back to the normal swapper_pg_dir. */
diff --git a/arch/tile/mm/migrate.h b/arch/tile/mm/migrate.h
index cd45a0837fa6..91683d97917e 100644
--- a/arch/tile/mm/migrate.h
+++ b/arch/tile/mm/migrate.h
@@ -24,6 +24,9 @@
24/* 24/*
25 * This function is used as a helper when setting up the initial 25 * This function is used as a helper when setting up the initial
26 * page table (swapper_pg_dir). 26 * page table (swapper_pg_dir).
27 *
28 * You must mask ALL interrupts prior to invoking this code, since
29 * you can't legally touch the stack during the cache flush.
27 */ 30 */
28extern int flush_and_install_context(HV_PhysAddr page_table, HV_PTE access, 31extern int flush_and_install_context(HV_PhysAddr page_table, HV_PTE access,
29 HV_ASID asid, 32 HV_ASID asid,
@@ -39,6 +42,9 @@ extern int flush_and_install_context(HV_PhysAddr page_table, HV_PTE access,
39 * 42 *
40 * Note that any non-NULL pointers must not point to the page that 43 * Note that any non-NULL pointers must not point to the page that
41 * is handled by the stack_pte itself. 44 * is handled by the stack_pte itself.
45 *
46 * You must mask ALL interrupts prior to invoking this code, since
47 * you can't legally touch the stack during the cache flush.
42 */ 48 */
43extern int homecache_migrate_stack_and_flush(pte_t stack_pte, unsigned long va, 49extern int homecache_migrate_stack_and_flush(pte_t stack_pte, unsigned long va,
44 size_t length, pte_t *stack_ptep, 50 size_t length, pte_t *stack_ptep,
diff --git a/arch/tile/mm/migrate_32.S b/arch/tile/mm/migrate_32.S
index ac01a7cdf77f..5305814bf187 100644
--- a/arch/tile/mm/migrate_32.S
+++ b/arch/tile/mm/migrate_32.S
@@ -40,8 +40,7 @@
40#define FRAME_R32 16 40#define FRAME_R32 16
41#define FRAME_R33 20 41#define FRAME_R33 20
42#define FRAME_R34 24 42#define FRAME_R34 24
43#define FRAME_R35 28 43#define FRAME_SIZE 28
44#define FRAME_SIZE 32
45 44
46 45
47 46
@@ -66,12 +65,11 @@
66#define r_my_cpumask r5 65#define r_my_cpumask r5
67 66
68/* Locals (callee-save); must not be more than FRAME_xxx above. */ 67/* Locals (callee-save); must not be more than FRAME_xxx above. */
69#define r_save_ics r30 68#define r_context_lo r30
70#define r_context_lo r31 69#define r_context_hi r31
71#define r_context_hi r32 70#define r_access_lo r32
72#define r_access_lo r33 71#define r_access_hi r33
73#define r_access_hi r34 72#define r_asid r34
74#define r_asid r35
75 73
76STD_ENTRY(flush_and_install_context) 74STD_ENTRY(flush_and_install_context)
77 /* 75 /*
@@ -104,11 +102,7 @@ STD_ENTRY(flush_and_install_context)
104 sw r_tmp, r33 102 sw r_tmp, r33
105 addi r_tmp, sp, FRAME_R34 103 addi r_tmp, sp, FRAME_R34
106 } 104 }
107 { 105 sw r_tmp, r34
108 sw r_tmp, r34
109 addi r_tmp, sp, FRAME_R35
110 }
111 sw r_tmp, r35
112 106
113 /* Move some arguments to callee-save registers. */ 107 /* Move some arguments to callee-save registers. */
114 { 108 {
@@ -121,13 +115,6 @@ STD_ENTRY(flush_and_install_context)
121 } 115 }
122 move r_asid, r_asid_in 116 move r_asid, r_asid_in
123 117
124 /* Disable interrupts, since we can't use our stack. */
125 {
126 mfspr r_save_ics, INTERRUPT_CRITICAL_SECTION
127 movei r_tmp, 1
128 }
129 mtspr INTERRUPT_CRITICAL_SECTION, r_tmp
130
131 /* First, flush our L2 cache. */ 118 /* First, flush our L2 cache. */
132 { 119 {
133 move r0, zero /* cache_pa */ 120 move r0, zero /* cache_pa */
@@ -163,7 +150,7 @@ STD_ENTRY(flush_and_install_context)
163 } 150 }
164 { 151 {
165 move r4, r_asid 152 move r4, r_asid
166 movei r5, HV_CTX_DIRECTIO 153 moveli r5, HV_CTX_DIRECTIO | CTX_PAGE_FLAG
167 } 154 }
168 jal hv_install_context 155 jal hv_install_context
169 bnz r0, .Ldone 156 bnz r0, .Ldone
@@ -175,9 +162,6 @@ STD_ENTRY(flush_and_install_context)
175 } 162 }
176 163
177.Ldone: 164.Ldone:
178 /* Reset interrupts back how they were before. */
179 mtspr INTERRUPT_CRITICAL_SECTION, r_save_ics
180
181 /* Restore the callee-saved registers and return. */ 165 /* Restore the callee-saved registers and return. */
182 addli lr, sp, FRAME_SIZE 166 addli lr, sp, FRAME_SIZE
183 { 167 {
@@ -202,10 +186,6 @@ STD_ENTRY(flush_and_install_context)
202 } 186 }
203 { 187 {
204 lw r34, r_tmp 188 lw r34, r_tmp
205 addli r_tmp, sp, FRAME_R35
206 }
207 {
208 lw r35, r_tmp
209 addi sp, sp, FRAME_SIZE 189 addi sp, sp, FRAME_SIZE
210 } 190 }
211 jrp lr 191 jrp lr
diff --git a/arch/tile/mm/migrate_64.S b/arch/tile/mm/migrate_64.S
index e76fea688beb..1d15b10833d1 100644
--- a/arch/tile/mm/migrate_64.S
+++ b/arch/tile/mm/migrate_64.S
@@ -38,8 +38,7 @@
38#define FRAME_R30 16 38#define FRAME_R30 16
39#define FRAME_R31 24 39#define FRAME_R31 24
40#define FRAME_R32 32 40#define FRAME_R32 32
41#define FRAME_R33 40 41#define FRAME_SIZE 40
42#define FRAME_SIZE 48
43 42
44 43
45 44
@@ -60,10 +59,9 @@
60#define r_my_cpumask r3 59#define r_my_cpumask r3
61 60
62/* Locals (callee-save); must not be more than FRAME_xxx above. */ 61/* Locals (callee-save); must not be more than FRAME_xxx above. */
63#define r_save_ics r30 62#define r_context r30
64#define r_context r31 63#define r_access r31
65#define r_access r32 64#define r_asid r32
66#define r_asid r33
67 65
68/* 66/*
69 * Caller-save locals and frame constants are the same as 67 * Caller-save locals and frame constants are the same as
@@ -93,11 +91,7 @@ STD_ENTRY(flush_and_install_context)
93 st r_tmp, r31 91 st r_tmp, r31
94 addi r_tmp, sp, FRAME_R32 92 addi r_tmp, sp, FRAME_R32
95 } 93 }
96 { 94 st r_tmp, r32
97 st r_tmp, r32
98 addi r_tmp, sp, FRAME_R33
99 }
100 st r_tmp, r33
101 95
102 /* Move some arguments to callee-save registers. */ 96 /* Move some arguments to callee-save registers. */
103 { 97 {
@@ -106,13 +100,6 @@ STD_ENTRY(flush_and_install_context)
106 } 100 }
107 move r_asid, r_asid_in 101 move r_asid, r_asid_in
108 102
109 /* Disable interrupts, since we can't use our stack. */
110 {
111 mfspr r_save_ics, INTERRUPT_CRITICAL_SECTION
112 movei r_tmp, 1
113 }
114 mtspr INTERRUPT_CRITICAL_SECTION, r_tmp
115
116 /* First, flush our L2 cache. */ 103 /* First, flush our L2 cache. */
117 { 104 {
118 move r0, zero /* cache_pa */ 105 move r0, zero /* cache_pa */
@@ -147,7 +134,7 @@ STD_ENTRY(flush_and_install_context)
147 } 134 }
148 { 135 {
149 move r2, r_asid 136 move r2, r_asid
150 movei r3, HV_CTX_DIRECTIO 137 moveli r3, HV_CTX_DIRECTIO | CTX_PAGE_FLAG
151 } 138 }
152 jal hv_install_context 139 jal hv_install_context
153 bnez r0, 1f 140 bnez r0, 1f
@@ -158,10 +145,7 @@ STD_ENTRY(flush_and_install_context)
158 jal hv_flush_all 145 jal hv_flush_all
159 } 146 }
160 147
1611: /* Reset interrupts back how they were before. */ 1481: /* Restore the callee-saved registers and return. */
162 mtspr INTERRUPT_CRITICAL_SECTION, r_save_ics
163
164 /* Restore the callee-saved registers and return. */
165 addli lr, sp, FRAME_SIZE 149 addli lr, sp, FRAME_SIZE
166 { 150 {
167 ld lr, lr 151 ld lr, lr
@@ -177,10 +161,6 @@ STD_ENTRY(flush_and_install_context)
177 } 161 }
178 { 162 {
179 ld r32, r_tmp 163 ld r32, r_tmp
180 addli r_tmp, sp, FRAME_R33
181 }
182 {
183 ld r33, r_tmp
184 addi sp, sp, FRAME_SIZE 164 addi sp, sp, FRAME_SIZE
185 } 165 }
186 jrp lr 166 jrp lr