udelay: Use clock_gettime() if available and precise
Instead of calibrating our busy loop against a coarse clock, check if
a precise clock is available and loop against that. The former is unre-
liable by definition on any modern system that may dynamically reclock
v2: Apparently _POSIX_MONOTONIC_CLOCK being defined only means that
the library knows about CLOCK_MONOTONIC. So check for its support
at runtime and fall back to CLOCK_REALTIME if it's missing.
TEST=Manually added a 10s loop and compared to real time. Run
on Linux RPi3, Linux x86 and my original use case Linux in
VirtualBox (Linux host).
Signed-off-by: Nico Huber <email@example.com>
Reviewed-by: Stefan Reinauer <firstname.lastname@example.org>
Reviewed-by: Philippe Mathieu-Daudé <email@example.com>
Reviewed-by: David Hendricks <firstname.lastname@example.org>
Tested-by: build bot (Jenkins) <email@example.com>
2 files changed