Attention is currently required from: Brian Norris, Peter Marheine, Thomas Heijligen.

Peter Marheine uploaded patch set #8 to this change.

View Change

udelay: only use OS time for delays, except on DOS

As proposed on the mailing list ("RFC: remove the calibrated delay
loop" [1]), this removes the calibrated delay loop and uses OS-based
timing functions for all delays because the calibrated delay loop can
delay for shorter times than intended.

When sleeping this now uses nanosleep() unconditionally, since usleep
was only used on DOS (where DJGPP lacks nanosleep). When busy-looping,
it uses clock_gettime() with CLOCK_MONOTONIC or CLOCK_REALTIME depending
on availability, and gettimeofday() otherwise.

The calibrated delay loop is retained for DOS only, because timer
resolution on DJGPP is only about 50 milliseconds. Since typical delays
in flashrom are around 10 microseconds, using OS timing there would
regress performance by around 500x. The old implementation is reused
with some branches removed based on the knowledge that timer resolution
will not be better than about 50 milliseconds.

Tested by reading and writing flash on several Intel and AMD systems:

* Lenovo P920 (Intel C620, read/verify only)
* "nissa" chromebook (Intel Alder Lake-N)
* "zork" chromebook (AMD Zen+)

[1]: https://mail.coreboot.org/hyperkitty/list/flashrom@flashrom.org/thread/HFH6UHPAKA4JDL4YKPSQPO72KXSSRGME/

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Change-Id: I7ac5450d194a475143698d65d64d8bcd2fd25e3f
---
M Makefile
M include/programmer.h
M libflashrom.c
M meson.build
M tests/meson.build
M tests/tests.c
M tests/tests.h
A tests/udelay.c
M udelay.c
A udelay_dos.c
10 files changed, 261 insertions(+), 172 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/45/81545/8

To view, visit change 81545. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: I7ac5450d194a475143698d65d64d8bcd2fd25e3f
Gerrit-Change-Number: 81545
Gerrit-PatchSet: 8
Gerrit-Owner: Peter Marheine <pmarheine@chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Brian Norris <briannorris@chromium.org>
Gerrit-Reviewer: Thomas Heijligen <src@posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-Attention: Brian Norris <briannorris@chromium.org>
Gerrit-Attention: Thomas Heijligen <src@posteo.de>
Gerrit-Attention: Peter Marheine <pmarheine@chromium.org>
Gerrit-MessageType: newpatchset