From: cheloha Date: Sat, 10 Dec 2022 15:02:29 +0000 (+0000) Subject: alpha: switch to clockintr X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a2504d3f38ac2ad8a5cb1cce334a1dfd852a1e05;p=openbsd alpha: switch to clockintr - Add missing tick_nsec initialization to cpu_initclocks(). - Set stathz = hz, profhz = stathz; we don't have any control over the interrupt clock on alpha so everything has the same frequency. - Set schedhz = 16 to imitate current schedclock() dispatch frequency. Bringup help from claudio@. Tested by miod@ (2-CPU DS25). Link: https://marc.info/?l=openbsd-tech&m=166776333303245&w=2 ok mlarkin@ --- diff --git a/sys/arch/alpha/alpha/clock.c b/sys/arch/alpha/alpha/clock.c index 0ccf551565b..7c16799bc12 100644 --- a/sys/arch/alpha/alpha/clock.c +++ b/sys/arch/alpha/alpha/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.25 2021/02/23 04:44:30 cheloha Exp $ */ +/* $OpenBSD: clock.c,v 1.26 2022/12/10 15:02:29 cheloha Exp $ */ /* $NetBSD: clock.c,v 1.29 2000/06/05 21:47:10 thorpej Exp $ */ /* @@ -42,8 +42,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -54,8 +56,6 @@ #include -extern int schedhz; - struct device *clockdev; const struct clockfns *clockfns; @@ -144,8 +144,7 @@ clockattach(dev, fns) */ /* - * Start the real-time and statistics clocks. Leave stathz 0 since there - * are no other timers available. + * Start the real-time and statistics clocks. */ void cpu_initclocks(void) @@ -159,21 +158,7 @@ cpu_initclocks(void) panic("cpu_initclocks: no clock attached"); tick = 1000000 / hz; /* number of microseconds between interrupts */ - - /* - * Establish the clock interrupt; it's a special case. - * - * We establish the clock interrupt this late because if - * we do it at clock attach time, we may have never been at - * spl0() since taking over the system. Some versions of - * PALcode save a clock interrupt, which would get delivered - * when we spl0() in autoconf.c. If established the clock - * interrupt handler earlier, that interrupt would go to - * hardclock, which would then fall over because the pointer - * to the virtual timers wasn't set at that time. - */ - platform.clockintr = hardclock; - schedhz = 16; + tick_nsec = 1000000000 / hz; evcount_attach(&clk_count, "clock", &clk_irq); @@ -205,22 +190,36 @@ cpu_initclocks(void) rpcc_timecounter.tc_frequency = cycles_per_sec; tc_init(&rpcc_timecounter); + schedhz = 16; + stathz = hz; + profhz = stathz; + clockintr_init(0); + + clockintr_cpu_init(NULL); + + /* + * Establish the clock interrupt; it's a special case. + * + * We establish the clock interrupt this late because if + * we do it at clock attach time, we may have never been at + * spl0() since taking over the system. Some versions of + * PALcode save a clock interrupt, which would get delivered + * when we spl0() in autoconf.c. If established the clock + * interrupt handler earlier, that interrupt would go to + * hardclock, which would then fall over because the pointer + * to the virtual timers wasn't set at that time. + */ + platform.clockintr = clockintr_dispatch; + rtc_todr.todr_gettime = rtc_gettime; rtc_todr.todr_settime = rtc_settime; todr_handle = &rtc_todr; } -/* - * We assume newhz is either stathz or profhz, and that neither will - * change after being set up above. Could recalculate intervals here - * but that would be a drag. - */ void -setstatclockrate(newhz) - int newhz; +setstatclockrate(int newhz) { - - /* nothing we can do */ + clockintr_setstatclockrate(newhz); } u_int diff --git a/sys/arch/alpha/alpha/cpu.c b/sys/arch/alpha/alpha/cpu.c index 2f7258a4520..e2c1671497e 100644 --- a/sys/arch/alpha/alpha/cpu.c +++ b/sys/arch/alpha/alpha/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.45 2022/03/13 08:04:13 mpi Exp $ */ +/* $OpenBSD: cpu.c,v 1.46 2022/12/10 15:02:29 cheloha Exp $ */ /* $NetBSD: cpu.c,v 1.44 2000/05/23 05:12:53 thorpej Exp $ */ /*- @@ -60,6 +60,7 @@ #include +#include #include #include #include @@ -603,6 +604,8 @@ cpu_hatch(struct cpu_info *ci) ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; KERNEL_UNLOCK(); + clockintr_cpu_init(NULL); + (void) alpha_pal_swpipl(ALPHA_PSL_IPL_0); SCHED_LOCK(s); cpu_switchto(NULL, sched_chooseproc()); diff --git a/sys/arch/alpha/alpha/interrupt.c b/sys/arch/alpha/alpha/interrupt.c index 868be573661..4b67b42ead2 100644 --- a/sys/arch/alpha/alpha/interrupt.c +++ b/sys/arch/alpha/alpha/interrupt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interrupt.c,v 1.40 2017/01/21 05:42:03 guenther Exp $ */ +/* $OpenBSD: interrupt.c,v 1.41 2022/12/10 15:02:29 cheloha Exp $ */ /* $NetBSD: interrupt.c,v 1.46 2000/06/03 20:47:36 thorpej Exp $ */ /*- @@ -200,7 +200,6 @@ interrupt(unsigned long a0, unsigned long a1, unsigned long a2, struct trapframe *framep) { struct cpu_info *ci = curcpu(); - extern int schedhz; switch (a0) { case ALPHA_INTR_XPROC: /* interprocessor interrupt */ @@ -227,22 +226,8 @@ interrupt(unsigned long a0, unsigned long a1, unsigned long a2, atomic_add_int(&uvmexp.intrs, 1); if (CPU_IS_PRIMARY(ci)) clk_count.ec_count++; - if (platform.clockintr) { - /* - * Call hardclock(). This will also call - * statclock(). On the primary CPU, it - * will also deal with time-of-day stuff. - */ - (*platform.clockintr)((struct clockframe *)framep); - - /* - * If it's time to call the scheduler clock, - * do so. - */ - if ((++ci->ci_schedstate.spc_schedticks & 0x3f) == 0 && - schedhz != 0) - schedclock(ci->ci_curproc); - } + if (platform.clockintr) + (*platform.clockintr)(framep); break; case ALPHA_INTR_ERROR: /* Machine Check or Correctable Error */ diff --git a/sys/arch/alpha/include/_types.h b/sys/arch/alpha/include/_types.h index 875709fce9f..129259bf070 100644 --- a/sys/arch/alpha/include/_types.h +++ b/sys/arch/alpha/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.24 2018/03/05 01:15:24 deraadt Exp $ */ +/* $OpenBSD: _types.h,v 1.25 2022/12/10 15:02:29 cheloha Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -35,6 +35,8 @@ #ifndef _MACHINE__TYPES_H_ #define _MACHINE__TYPES_H_ +#define __HAVE_CLOCKINTR + #if defined(_KERNEL) typedef struct label_t { long val[10]; diff --git a/sys/arch/alpha/include/cpu.h b/sys/arch/alpha/include/cpu.h index 03afb3a355a..1d0e638dae5 100644 --- a/sys/arch/alpha/include/cpu.h +++ b/sys/arch/alpha/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.67 2022/10/25 15:15:38 guenther Exp $ */ +/* $OpenBSD: cpu.h,v 1.68 2022/12/10 15:02:29 cheloha Exp $ */ /* $NetBSD: cpu.h,v 1.45 2000/08/21 02:03:12 thorpej Exp $ */ /*- @@ -99,6 +99,7 @@ typedef union alpha_t_float { #include #include #include +#include #include #include #include @@ -212,6 +213,7 @@ struct cpu_info { #ifdef GPROF struct gmonparam *ci_gmon; #endif + struct clockintr_queue ci_queue; char ci_panicbuf[512]; }; diff --git a/sys/arch/alpha/include/cpuconf.h b/sys/arch/alpha/include/cpuconf.h index 27d898c7bc7..6bde3d5b907 100644 --- a/sys/arch/alpha/include/cpuconf.h +++ b/sys/arch/alpha/include/cpuconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpuconf.h,v 1.6 2011/03/23 16:54:34 pirofti Exp $ */ +/* $OpenBSD: cpuconf.h,v 1.7 2022/12/10 15:02:29 cheloha Exp $ */ /* $NetBSD: cpuconf.h,v 1.12 2000/06/08 03:10:06 thorpej Exp $ */ /* @@ -67,7 +67,7 @@ struct platform { */ void (*cons_init)(void); void (*device_register)(struct device *, void *); - void (*clockintr)(struct clockframe *); + int (*clockintr)(void *); void (*mcheck_handler)(unsigned long, struct trapframe *, unsigned long, unsigned long); void (*powerdown)(void);