From: cheloha Date: Tue, 8 Nov 2022 14:49:20 +0000 (+0000) Subject: i386: add delay_fini() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6a987fc5894d3401681d5ab7aea41419009b814f;p=openbsd i386: add delay_fini() Not all of the clocks with a delay(9) implementation necessarily keep ticking across suspend/resume. We need a clean way to reverse delay_init() during suspend when those clocks stop ticking. Hence, delay_fini(). delay_fini() resets delay_func() to i8254_delay() if the given function pointer is the active delay(9) implementation. ok mlarkin@ --- diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 62e2c88bde7..310208ac4cd 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.657 2022/10/30 17:43:39 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.658 2022/11/08 14:49:20 cheloha Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -3973,12 +3973,22 @@ cpu_rnd_messybits(void) return (ts.tv_nsec ^ (ts.tv_sec << 20)); } +int i386_delay_quality; + void delay_init(void(*fn)(int), int fn_quality) { - static int cur_quality = 0; - if (fn_quality > cur_quality) { + if (fn_quality > i386_delay_quality) { delay_func = fn; - cur_quality = fn_quality; + i386_delay_quality = fn_quality; + } +} + +void +delay_fini(void (*fn)(int)) +{ + if (delay_func == fn) { + delay_func = i8254_delay; + i386_delay_quality = 0; } } diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index 68bc3542a0f..6d707fc2d77 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.179 2022/08/29 02:58:13 jsg Exp $ */ +/* $OpenBSD: cpu.h,v 1.180 2022/11/08 14:49:20 cheloha Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -302,6 +302,7 @@ void signotify(struct proc *); * We need a machine-independent name for this. */ extern void (*delay_func)(int); +void delay_fini(void(*)(int)); void delay_init(void(*)(int), int); struct timeval;