We should block non-wakeup interrupts until we're in the resume path and
authorkettenis <kettenis@openbsd.org>
Sat, 15 Jun 2024 18:01:44 +0000 (18:01 +0000)
committerkettenis <kettenis@openbsd.org>
Sat, 15 Jun 2024 18:01:44 +0000 (18:01 +0000)
have disabled interrupts at the CPU level again.  So instead of
cpu_suspended use a new intr_suspended variable that is set and cleared in
intr_enable_wakeup() and intr_disable_wakeup().

ok mglocker@, mlarkin@

sys/arch/amd64/amd64/intr.c

index dcef658..88c65f2 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: intr.c,v 1.59 2024/06/07 06:26:23 jsg Exp $   */
+/*     $OpenBSD: intr.c,v 1.60 2024/06/15 18:01:44 kettenis Exp $      */
 /*     $NetBSD: intr.c,v 1.3 2003/03/03 22:16:20 fvdl Exp $    */
 
 /*
@@ -73,6 +73,8 @@ struct pic softintr_pic = {
        NULL,
 };
 
+int intr_suspended;
+
 /*
  * Fill in default interrupt table (in case of spurious interrupt
  * during configuration of kernel), setup interrupt control unit
@@ -524,7 +526,6 @@ intr_disestablish(struct intrhand *ih)
 int
 intr_handler(struct intrframe *frame, struct intrhand *ih)
 {
-       extern int cpu_suspended;
        struct cpu_info *ci = curcpu();
        int floor;
        int rc;
@@ -536,7 +537,7 @@ intr_handler(struct intrframe *frame, struct intrhand *ih)
         * We may not be able to mask MSIs, so block non-wakeup
         * interrupts while we're suspended.
         */
-       if (cpu_suspended && (ih->ih_flags & IPL_WAKEUP) == 0)
+       if (intr_suspended && (ih->ih_flags & IPL_WAKEUP) == 0)
                return 0;
 
 #ifdef MULTIPROCESSOR
@@ -723,6 +724,8 @@ intr_enable_wakeup(void)
                if (pic->pic_hwmask)
                        pic->pic_hwmask(pic, pin);
        }
+
+       intr_suspended = 1;
 }
 
 void
@@ -732,6 +735,8 @@ intr_disable_wakeup(void)
        struct pic *pic;
        int irq, pin;
 
+       intr_suspended = 0;
+
        for (irq = 0; irq < MAX_INTR_SOURCES; irq++) {
                if (ci->ci_isources[irq] == NULL)
                        continue;