From: cheloha Date: Fri, 11 Aug 2023 01:28:19 +0000 (+0000) Subject: agtimer(4/arm64): call CPU_BUSY_CYCLE() during spin-loop X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=284a3223b8d6f2efcc023eea08a50b5615ffd0df;p=openbsd agtimer(4/arm64): call CPU_BUSY_CYCLE() during spin-loop For consistency with other delay(9) implementations, agtimer(4/arm64) ought to call CPU_BUSY_CYCLE() as it spins. kettenis@ notes that we could reduce the power consumed in agtimer_delay() by enabling CNTKCTL_EL1.EVNTEN and configuring ENTKCTL_EL1.EVNTI. kettenis@ also notes that Armv8.7 adds FEAT_WFxT, which will, when the feature appears in real hardware, make it even easier to save power in agtimer_delay(). With input from drahn@ and kettenis@. Thread: https://marc.info/?l=openbsd-tech&m=169146193022516&w=2 ok kettenis@ --- diff --git a/sys/arch/arm64/dev/agtimer.c b/sys/arch/arm64/dev/agtimer.c index ffe40b254a0..32f0688148e 100644 --- a/sys/arch/arm64/dev/agtimer.c +++ b/sys/arch/arm64/dev/agtimer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agtimer.c,v 1.24 2023/08/10 22:58:04 cheloha Exp $ */ +/* $OpenBSD: agtimer.c,v 1.25 2023/08/11 01:28:19 cheloha Exp $ */ /* * Copyright (c) 2011 Dale Rahn * Copyright (c) 2013 Patrick Wildt @@ -328,7 +328,7 @@ agtimer_delay(u_int usecs) start = agtimer_readcnt64(); cycles = (uint64_t)usecs * agtimer_frequency / 1000000; while (agtimer_readcnt64() - start < cycles) - continue; + CPU_BUSY_CYCLE(); } void