hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/powerpc/include/asm/hw_irq.h
....@@ -25,9 +25,8 @@
2525 #define PACA_IRQ_DBELL 0x02
2626 #define PACA_IRQ_EE 0x04
2727 #define PACA_IRQ_DEC 0x08 /* Or FIT */
28
-#define PACA_IRQ_EE_EDGE 0x10 /* BookE only */
29
-#define PACA_IRQ_HMI 0x20
30
-#define PACA_IRQ_PMI 0x40
28
+#define PACA_IRQ_HMI 0x10
29
+#define PACA_IRQ_PMI 0x20
3130
3231 /*
3332 * Some soft-masked interrupts must be hard masked until they are replayed
....@@ -39,6 +38,8 @@
3938 #define PACA_IRQ_MUST_HARD_MASK (PACA_IRQ_EE)
4039 #endif
4140
41
+#endif /* CONFIG_PPC64 */
42
+
4243 /*
4344 * flags for paca->irq_soft_mask
4445 */
....@@ -47,12 +48,10 @@
4748 #define IRQS_PMI_DISABLED 2
4849 #define IRQS_ALL_DISABLED (IRQS_DISABLED | IRQS_PMI_DISABLED)
4950
50
-#endif /* CONFIG_PPC64 */
51
-
5251 #ifndef __ASSEMBLY__
5352
5453 extern void replay_system_reset(void);
55
-extern void __replay_interrupt(unsigned int vector);
54
+extern void replay_soft_interrupts(void);
5655
5756 extern void timer_interrupt(struct pt_regs *);
5857 extern void timer_broadcast_interrupt(void);
....@@ -176,6 +175,42 @@
176175 return arch_irqs_disabled_flags(arch_local_save_flags());
177176 }
178177
178
+static inline void set_pmi_irq_pending(void)
179
+{
180
+ /*
181
+ * Invoked from PMU callback functions to set PMI bit in the paca.
182
+ * This has to be called with irq's disabled (via hard_irq_disable()).
183
+ */
184
+ if (IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG))
185
+ WARN_ON_ONCE(mfmsr() & MSR_EE);
186
+
187
+ get_paca()->irq_happened |= PACA_IRQ_PMI;
188
+}
189
+
190
+static inline void clear_pmi_irq_pending(void)
191
+{
192
+ /*
193
+ * Invoked from PMU callback functions to clear the pending PMI bit
194
+ * in the paca.
195
+ */
196
+ if (IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG))
197
+ WARN_ON_ONCE(mfmsr() & MSR_EE);
198
+
199
+ get_paca()->irq_happened &= ~PACA_IRQ_PMI;
200
+}
201
+
202
+static inline bool pmi_irq_pending(void)
203
+{
204
+ /*
205
+ * Invoked from PMU callback functions to check if there is a pending
206
+ * PMI bit in the paca.
207
+ */
208
+ if (get_paca()->irq_happened & PACA_IRQ_PMI)
209
+ return true;
210
+
211
+ return false;
212
+}
213
+
179214 #ifdef CONFIG_PPC_BOOK3S
180215 /*
181216 * To support disabling and enabling of irq with PMI, set of
....@@ -200,17 +235,14 @@
200235 #define powerpc_local_irq_pmu_save(flags) \
201236 do { \
202237 raw_local_irq_pmu_save(flags); \
203
- trace_hardirqs_off(); \
238
+ if (!raw_irqs_disabled_flags(flags)) \
239
+ trace_hardirqs_off(); \
204240 } while(0)
205241 #define powerpc_local_irq_pmu_restore(flags) \
206242 do { \
207
- if (raw_irqs_disabled_flags(flags)) { \
208
- raw_local_irq_pmu_restore(flags); \
209
- trace_hardirqs_off(); \
210
- } else { \
243
+ if (!raw_irqs_disabled_flags(flags)) \
211244 trace_hardirqs_on(); \
212
- raw_local_irq_pmu_restore(flags); \
213
- } \
245
+ raw_local_irq_pmu_restore(flags); \
214246 } while(0)
215247 #else
216248 #define powerpc_local_irq_pmu_save(flags) \
....@@ -226,11 +258,15 @@
226258 #endif /* CONFIG_PPC_BOOK3S */
227259
228260 #ifdef CONFIG_PPC_BOOK3E
229
-#define __hard_irq_enable() asm volatile("wrteei 1" : : : "memory")
230
-#define __hard_irq_disable() asm volatile("wrteei 0" : : : "memory")
261
+#define __hard_irq_enable() wrtee(MSR_EE)
262
+#define __hard_irq_disable() wrtee(0)
263
+#define __hard_EE_RI_disable() wrtee(0)
264
+#define __hard_RI_enable() do { } while (0)
231265 #else
232266 #define __hard_irq_enable() __mtmsrd(MSR_EE|MSR_RI, 1)
233267 #define __hard_irq_disable() __mtmsrd(MSR_RI, 1)
268
+#define __hard_EE_RI_disable() __mtmsrd(0, 1)
269
+#define __hard_RI_enable() __mtmsrd(MSR_RI, 1)
234270 #endif
235271
236272 #define hard_irq_disable() do { \
....@@ -246,9 +282,27 @@
246282 } \
247283 } while(0)
248284
285
+static inline bool __lazy_irq_pending(u8 irq_happened)
286
+{
287
+ return !!(irq_happened & ~PACA_IRQ_HARD_DIS);
288
+}
289
+
290
+/*
291
+ * Check if a lazy IRQ is pending. Should be called with IRQs hard disabled.
292
+ */
249293 static inline bool lazy_irq_pending(void)
250294 {
251
- return !!(get_paca()->irq_happened & ~PACA_IRQ_HARD_DIS);
295
+ return __lazy_irq_pending(get_paca()->irq_happened);
296
+}
297
+
298
+/*
299
+ * Check if a lazy IRQ is pending, with no debugging checks.
300
+ * Should be called with IRQs hard disabled.
301
+ * For use in RI disabled code or other constrained situations.
302
+ */
303
+static inline bool lazy_irq_pending_nocheck(void)
304
+{
305
+ return __lazy_irq_pending(local_paca->irq_happened);
252306 }
253307
254308 /*
....@@ -278,9 +332,11 @@
278332
279333 extern void force_external_irq_replay(void);
280334
335
+static inline void irq_soft_mask_regs_set_state(struct pt_regs *regs, unsigned long val)
336
+{
337
+ regs->softe = val;
338
+}
281339 #else /* CONFIG_PPC64 */
282
-
283
-#define SET_MSR_EE(x) mtmsr(x)
284340
285341 static inline unsigned long arch_local_save_flags(void)
286342 {
....@@ -289,47 +345,44 @@
289345
290346 static inline void arch_local_irq_restore(unsigned long flags)
291347 {
292
-#if defined(CONFIG_BOOKE)
293
- asm volatile("wrtee %0" : : "r" (flags) : "memory");
294
-#else
295
- mtmsr(flags);
296
-#endif
348
+ if (IS_ENABLED(CONFIG_BOOKE))
349
+ wrtee(flags);
350
+ else
351
+ mtmsr(flags);
297352 }
298353
299354 static inline unsigned long arch_local_irq_save(void)
300355 {
301356 unsigned long flags = arch_local_save_flags();
302
-#ifdef CONFIG_BOOKE
303
- asm volatile("wrteei 0" : : : "memory");
304
-#elif defined(CONFIG_PPC_8xx)
305
- wrtspr(SPRN_EID);
306
-#else
307
- SET_MSR_EE(flags & ~MSR_EE);
308
-#endif
357
+
358
+ if (IS_ENABLED(CONFIG_BOOKE))
359
+ wrtee(0);
360
+ else if (IS_ENABLED(CONFIG_PPC_8xx))
361
+ wrtspr(SPRN_EID);
362
+ else
363
+ mtmsr(flags & ~MSR_EE);
364
+
309365 return flags;
310366 }
311367
312368 static inline void arch_local_irq_disable(void)
313369 {
314
-#ifdef CONFIG_BOOKE
315
- asm volatile("wrteei 0" : : : "memory");
316
-#elif defined(CONFIG_PPC_8xx)
317
- wrtspr(SPRN_EID);
318
-#else
319
- arch_local_irq_save();
320
-#endif
370
+ if (IS_ENABLED(CONFIG_BOOKE))
371
+ wrtee(0);
372
+ else if (IS_ENABLED(CONFIG_PPC_8xx))
373
+ wrtspr(SPRN_EID);
374
+ else
375
+ mtmsr(mfmsr() & ~MSR_EE);
321376 }
322377
323378 static inline void arch_local_irq_enable(void)
324379 {
325
-#ifdef CONFIG_BOOKE
326
- asm volatile("wrteei 1" : : : "memory");
327
-#elif defined(CONFIG_PPC_8xx)
328
- wrtspr(SPRN_EIE);
329
-#else
330
- unsigned long msr = mfmsr();
331
- SET_MSR_EE(msr | MSR_EE);
332
-#endif
380
+ if (IS_ENABLED(CONFIG_BOOKE))
381
+ wrtee(MSR_EE);
382
+ else if (IS_ENABLED(CONFIG_PPC_8xx))
383
+ wrtspr(SPRN_EIE);
384
+ else
385
+ mtmsr(mfmsr() | MSR_EE);
333386 }
334387
335388 static inline bool arch_irqs_disabled_flags(unsigned long flags)
....@@ -351,15 +404,16 @@
351404
352405 static inline void may_hard_irq_enable(void) { }
353406
407
+static inline void clear_pmi_irq_pending(void) { }
408
+static inline void set_pmi_irq_pending(void) { }
409
+static inline bool pmi_irq_pending(void) { return false; }
410
+
411
+static inline void irq_soft_mask_regs_set_state(struct pt_regs *regs, unsigned long val)
412
+{
413
+}
354414 #endif /* CONFIG_PPC64 */
355415
356416 #define ARCH_IRQ_INIT_FLAGS IRQ_NOREQUEST
357
-
358
-/*
359
- * interrupt-retrigger: should we handle this via lost interrupts and IPIs
360
- * or should we not care like we do now ? --BenH.
361
- */
362
-struct irq_chip;
363417
364418 #endif /* __ASSEMBLY__ */
365419 #endif /* __KERNEL__ */