summaryrefslogtreecommitdiff
path: root/sys/arch/arm
diff options
context:
space:
mode:
authorScott Soule Cheloha <cheloha@cvs.openbsd.org>2023-08-23 01:55:48 +0000
committerScott Soule Cheloha <cheloha@cvs.openbsd.org>2023-08-23 01:55:48 +0000
commit03acd21a4e00752d82ce1f3198960b52c475396e (patch)
tree12084f3273f661178be60a73087dc3b53041b423 /sys/arch/arm
parent83fa6d388c3eec5da9f344ef9571ca741627fe5c (diff)
all platforms: separate cpu_initclocks() from cpu_startclock()
To give the primary CPU an opportunity to perform clock interrupt preparation in a machine-independent manner we need to separate the "initialization" parts of cpu_initclocks() from the "start the clock interrupt" parts. Currently, cpu_initclocks() does everything all at once, so there is no space for this MI setup. Many platforms have more-or-less already done this separation by implementing a separate routine named "cpu_startclock()". This patch promotes cpu_startclock() from de facto standard to mandatory API. - Prototype cpu_startclock() in sys/systm.h alongside cpu_initclocks(). The separation of responsibility between the two routines is a bit fuzzy but the basic guidelines are as follows: + cpu_initclocks() must initialize hz, stathz, and profhz, and call clockintr_init(). + cpu_startclock() must call clockintr_cpu_init() and start the clock interrupt cycle on the calling CPU. These guidelines will shift in the future, but that's the way things stand as of *this* commit. - In initclocks(): first call cpu_initclocks(), then do MI setup, and last call cpu_startclock(). - On platforms where cpu_startclock() already exists: don't call cpu_startclock() from cpu_initclocks() anymore. - On platforms where cpu_startclock() doesn't yet exist: implement it. Usually this is as simple as dividing cpu_initclocks() in two. Tested on amd64 (i8254, lapic), arm64, i386 (i8254, lapic), macppc, mips64/octeon, and sparc64. Tested on arm/armv7 (agtimer(4)) by phessler@ and jmatthew@. Tested on m88k/luna88k by aoyama@. Tested on powerpc64 by gkoehler@ and mlarkin@. Tested on riscv64 by jmatthew@. Thread: https://marc.info/?l=openbsd-tech&m=169195251322149&w=2
Diffstat (limited to 'sys/arch/arm')
-rw-r--r--sys/arch/arm/cortex/agtimer.c13
-rw-r--r--sys/arch/arm/cortex/amptimer.c6
-rw-r--r--sys/arch/arm/include/cpu.h4
3 files changed, 3 insertions, 20 deletions
diff --git a/sys/arch/arm/cortex/agtimer.c b/sys/arch/arm/cortex/agtimer.c
index 13b0af6f8e1..88e201abe8a 100644
--- a/sys/arch/arm/cortex/agtimer.c
+++ b/sys/arch/arm/cortex/agtimer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agtimer.c,v 1.18 2023/07/25 18:16:19 cheloha Exp $ */
+/* $OpenBSD: agtimer.c,v 1.19 2023/08/23 01:55:46 cheloha Exp $ */
/*
* Copyright (c) 2011 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2013 Patrick Wildt <patrick@blueri.se>
@@ -227,7 +227,6 @@ void
agtimer_cpu_initclocks(void)
{
struct agtimer_softc *sc = agtimer_cd.cd_devs[0];
- uint32_t reg;
stathz = hz;
profhz = stathz * 10;
@@ -237,21 +236,11 @@ agtimer_cpu_initclocks(void)
agtimer_set_clockrate(agtimer_frequency);
}
- clockintr_cpu_init(&agtimer_intrclock);
-
/* Setup secure and non-secure timer IRQs. */
arm_intr_establish_fdt_idx(sc->sc_node, 0, IPL_CLOCK,
agtimer_intr, NULL, "tick");
arm_intr_establish_fdt_idx(sc->sc_node, 1, IPL_CLOCK,
agtimer_intr, NULL, "tick");
-
- reg = agtimer_get_ctrl();
- reg &= ~GTIMER_CNTP_CTL_IMASK;
- reg |= GTIMER_CNTP_CTL_ENABLE;
- agtimer_set_tval(INT32_MAX);
- agtimer_set_ctrl(reg);
-
- clockintr_trigger();
}
void
diff --git a/sys/arch/arm/cortex/amptimer.c b/sys/arch/arm/cortex/amptimer.c
index 6fcf495791c..299f9fe8c61 100644
--- a/sys/arch/arm/cortex/amptimer.c
+++ b/sys/arch/arm/cortex/amptimer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: amptimer.c,v 1.17 2023/07/25 18:16:19 cheloha Exp $ */
+/* $OpenBSD: amptimer.c,v 1.18 2023/08/23 01:55:46 cheloha Exp $ */
/*
* Copyright (c) 2011 Dale Rahn <drahn@openbsd.org>
*
@@ -301,10 +301,6 @@ amptimer_cpu_initclocks(void)
/* Enable private timer counter and interrupt. */
bus_space_write_4(sc->sc_iot, sc->sc_pioh, PTIMER_CTRL,
(PTIMER_CTRL_ENABLE | PTIMER_CTRL_IRQEN));
-
- /* Start the clock interrupt cycle. */
- clockintr_cpu_init(&amptimer_intrclock);
- clockintr_trigger();
}
void
diff --git a/sys/arch/arm/include/cpu.h b/sys/arch/arm/include/cpu.h
index 986e1798cb9..1ced238694e 100644
--- a/sys/arch/arm/include/cpu.h
+++ b/sys/arch/arm/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.63 2023/07/25 18:16:19 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.64 2023/08/23 01:55:46 cheloha Exp $ */
/* $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $ */
/*
@@ -329,8 +329,6 @@ intr_restore(u_long cpsr)
__asm volatile ("msr cpsr_c, %0" :: "r"(cpsr));
}
-void cpu_startclock(void);
-
#endif /* _KERNEL */
#ifdef MULTIPROCESSOR