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@
-/* $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 <drahn@openbsd.org>
* Copyright (c) 2013 Patrick Wildt <patrick@blueri.se>
start = agtimer_readcnt64();
cycles = (uint64_t)usecs * agtimer_frequency / 1000000;
while (agtimer_readcnt64() - start < cycles)
- continue;
+ CPU_BUSY_CYCLE();
}
void