clockintr: clockintr_cpu_init(): isolate struct clockintr_queue setup
authorcheloha <cheloha@openbsd.org>
Mon, 3 Apr 2023 17:40:51 +0000 (17:40 +0000)
committercheloha <cheloha@openbsd.org>
Mon, 3 Apr 2023 17:40:51 +0000 (17:40 +0000)
We will always need to initialize the clockintr_queue struct.
However, the hardclock, schedclock, and statclock will not always be a
part of that struct.  Move the clockintr_establish() calls in
clockintr_cpu_init() away from the other initialization steps to make
the dependency relationship more obvious.  We need to intialize a
struct clockintr_queue before we can establish clock interrupts.

sys/kern/kern_clockintr.c

index c937d63..45f396e 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_clockintr.c,v 1.6 2023/04/03 00:20:24 cheloha Exp $ */
+/* $OpenBSD: kern_clockintr.c,v 1.7 2023/04/03 17:40:51 cheloha Exp $ */
 /*
  * Copyright (c) 2003 Dale Rahn <drahn@openbsd.org>
  * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
@@ -115,6 +115,13 @@ clockintr_cpu_init(const struct intrclock *ic)
                mtx_init(&cq->cq_mtx, IPL_CLOCK);
                TAILQ_INIT(&cq->cq_est);
                TAILQ_INIT(&cq->cq_pend);
+               if (ic != NULL) {
+                       cq->cq_intrclock = *ic;
+                       SET(cq->cq_flags, CL_CPU_INTRCLOCK);
+               }
+               cq->cq_gen = 1;
+
+               /* TODO: Remove these from struct clockintr_queue. */
                cq->cq_hardclock = clockintr_establish(cq, clockintr_hardclock);
                if (cq->cq_hardclock == NULL)
                        panic("%s: failed to establish hardclock", __func__);
@@ -129,11 +136,6 @@ clockintr_cpu_init(const struct intrclock *ic)
                                    __func__);
                        }
                }
-               if (ic != NULL) {
-                       cq->cq_intrclock = *ic;
-                       SET(cq->cq_flags, CL_CPU_INTRCLOCK);
-               }
-               cq->cq_gen = 1;
        }
 
        /*