From f4914fc43fa6e7340b3ba983c698f3efa83b7962 Mon Sep 17 00:00:00 2001 From: Scott Soule Cheloha Date: Fri, 21 Apr 2023 16:35:21 +0000 Subject: clockintr: prepare to hoist clockqueue_init() out of clockintr_cpu_init() Reorganize the initialization block in clockintr_cpu_init() so that it doesn't break when clockqueue_init() is called separately: - If CQ_INTRCLOCK is not set, this is the first clockintr_cpu_init() call and we can install the intrclock given as argument. - If any of the internal clock interrupt handles are NULL, this is the first clockintr_cpu_init() call and we need to establish them. --- sys/kern/kern_clockintr.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'sys') diff --git a/sys/kern/kern_clockintr.c b/sys/kern/kern_clockintr.c index 8f065f54cdd..b95346f123c 100644 --- a/sys/kern/kern_clockintr.c +++ b/sys/kern/kern_clockintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clockintr.c,v 1.17 2023/04/21 15:49:37 cheloha Exp $ */ +/* $OpenBSD: kern_clockintr.c,v 1.18 2023/04/21 16:35:20 cheloha Exp $ */ /* * Copyright (c) 2003 Dale Rahn * Copyright (c) 2020 Mark Kettenis @@ -114,28 +114,28 @@ clockintr_cpu_init(const struct intrclock *ic) KASSERT(ISSET(clockintr_flags, CL_INIT)); - if (!ISSET(cq->cq_flags, CQ_INIT)) { - clockqueue_init(cq); - if (ic != NULL) { - cq->cq_intrclock = *ic; - SET(cq->cq_flags, CQ_INTRCLOCK); - } + clockqueue_init(cq); + if (ic != NULL && !ISSET(cq->cq_flags, CQ_INTRCLOCK)) { + cq->cq_intrclock = *ic; + SET(cq->cq_flags, CQ_INTRCLOCK); + } - /* TODO: Remove these from struct clockintr_queue. */ + /* TODO: Remove these from struct clockintr_queue. */ + if (cq->cq_hardclock == NULL) { cq->cq_hardclock = clockintr_establish(cq, clockintr_hardclock); if (cq->cq_hardclock == NULL) panic("%s: failed to establish hardclock", __func__); + } + if (cq->cq_statclock == NULL) { cq->cq_statclock = clockintr_establish(cq, clockintr_statclock); if (cq->cq_statclock == NULL) panic("%s: failed to establish statclock", __func__); - if (schedhz != 0) { - cq->cq_schedclock = clockintr_establish(cq, - clockintr_schedclock); - if (cq->cq_schedclock == NULL) { - panic("%s: failed to establish schedclock", - __func__); - } - } + } + if (schedhz != 0 && cq->cq_schedclock == NULL) { + cq->cq_schedclock = clockintr_establish(cq, + clockintr_schedclock); + if (cq->cq_schedclock == NULL) + panic("%s: failed to establish schedclock", __func__); } /* -- cgit v1.2.3