diff options
Diffstat (limited to 'arch/powerpc/kernel/irq.c')
-rw-r--r-- | arch/powerpc/kernel/irq.c | 57 |
1 files changed, 52 insertions, 5 deletions
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c index e1936952017c..0bd8c7665834 100644 --- a/arch/powerpc/kernel/irq.c +++ b/arch/powerpc/kernel/irq.c | |||
@@ -97,22 +97,69 @@ EXPORT_SYMBOL(irq_desc); | |||
97 | 97 | ||
98 | int distribute_irqs = 1; | 98 | int distribute_irqs = 1; |
99 | 99 | ||
100 | static inline unsigned long get_hard_enabled(void) | ||
101 | { | ||
102 | unsigned long enabled; | ||
103 | |||
104 | __asm__ __volatile__("lbz %0,%1(13)" | ||
105 | : "=r" (enabled) : "i" (offsetof(struct paca_struct, hard_enabled))); | ||
106 | |||
107 | return enabled; | ||
108 | } | ||
109 | |||
110 | static inline void set_soft_enabled(unsigned long enable) | ||
111 | { | ||
112 | __asm__ __volatile__("stb %0,%1(13)" | ||
113 | : : "r" (enable), "i" (offsetof(struct paca_struct, soft_enabled))); | ||
114 | } | ||
115 | |||
100 | void local_irq_restore(unsigned long en) | 116 | void local_irq_restore(unsigned long en) |
101 | { | 117 | { |
102 | get_paca()->soft_enabled = en; | 118 | /* |
119 | * get_paca()->soft_enabled = en; | ||
120 | * Is it ever valid to use local_irq_restore(0) when soft_enabled is 1? | ||
121 | * That was allowed before, and in such a case we do need to take care | ||
122 | * that gcc will set soft_enabled directly via r13, not choose to use | ||
123 | * an intermediate register, lest we're preempted to a different cpu. | ||
124 | */ | ||
125 | set_soft_enabled(en); | ||
103 | if (!en) | 126 | if (!en) |
104 | return; | 127 | return; |
105 | 128 | ||
106 | if (firmware_has_feature(FW_FEATURE_ISERIES)) { | 129 | if (firmware_has_feature(FW_FEATURE_ISERIES)) { |
107 | if (get_paca()->lppaca_ptr->int_dword.any_int) | 130 | /* |
131 | * Do we need to disable preemption here? Not really: in the | ||
132 | * unlikely event that we're preempted to a different cpu in | ||
133 | * between getting r13, loading its lppaca_ptr, and loading | ||
134 | * its any_int, we might call iseries_handle_interrupts without | ||
135 | * an interrupt pending on the new cpu, but that's no disaster, | ||
136 | * is it? And the business of preempting us off the old cpu | ||
137 | * would itself involve a local_irq_restore which handles the | ||
138 | * interrupt to that cpu. | ||
139 | * | ||
140 | * But use "local_paca->lppaca_ptr" instead of "get_lppaca()" | ||
141 | * to avoid any preemption checking added into get_paca(). | ||
142 | */ | ||
143 | if (local_paca->lppaca_ptr->int_dword.any_int) | ||
108 | iseries_handle_interrupts(); | 144 | iseries_handle_interrupts(); |
109 | return; | 145 | return; |
110 | } | 146 | } |
111 | 147 | ||
112 | if (get_paca()->hard_enabled) | 148 | /* |
149 | * if (get_paca()->hard_enabled) return; | ||
150 | * But again we need to take care that gcc gets hard_enabled directly | ||
151 | * via r13, not choose to use an intermediate register, lest we're | ||
152 | * preempted to a different cpu in between the two instructions. | ||
153 | */ | ||
154 | if (get_hard_enabled()) | ||
113 | return; | 155 | return; |
114 | /* need to hard-enable interrupts here */ | 156 | |
115 | get_paca()->hard_enabled = en; | 157 | /* |
158 | * Need to hard-enable interrupts here. Since currently disabled, | ||
159 | * no need to take further asm precautions against preemption; but | ||
160 | * use local_paca instead of get_paca() to avoid preemption checking. | ||
161 | */ | ||
162 | local_paca->hard_enabled = en; | ||
116 | if ((int)mfspr(SPRN_DEC) < 0) | 163 | if ((int)mfspr(SPRN_DEC) < 0) |
117 | mtspr(SPRN_DEC, 1); | 164 | mtspr(SPRN_DEC, 1); |
118 | hard_irq_enable(); | 165 | hard_irq_enable(); |